ide_conf/ 775 433 0 0 5370144146 5546 ide_conf/ide_conf.c 644 433 0 16755 5370144145 7600 /*------------------------------------------------------+ | | | Name: | | ide_conf | | | | Usage: | | ide_conf [drive number] | | | | Description: | | Displays IDE drive configuration under MSDOS. | | Optional drive parameter selects drive for query. | | Legal values are 0..3 where 0 and 1 are drives 0 | | and 1 attached to a primary controller while 2 and | | 3 are drives 0 and 1 attached to a controller at | | the alternate controller address (0x170 - has not | | been tested). If omitted, drive 0 is checked. | | | | Author: | | Frank P. MacLachlan | | | | Date: | | 18-Oct-92 | | | | Compilation using MSC 6.0: | | cl ide_conf.c | | | +------------------------------------------------------*/ #include #include #include "wddefs.h" #define TPS 18 /* ticks/second (really 18.2) */ typedef unsigned long ulong; typedef unsigned int uint; typedef unsigned short ushort; typedef unsigned char uchar; /* ** The following structure corresponds to the ROM BIOS ** disk parameter table: */ #pragma pack(1) typedef struct parms { uint ncyls; uchar nheads; uint res0; uint wpc; uchar ebl; uchar ctlb; uchar res1[3]; uint lzc; uchar nsecs; uchar res2; } BIOS_PARMS; #pragma pack() /* ** The following structure corresponds to the values as returned ** by the ESDI/IDE identify drive command. */ typedef struct { ushort gcfg; /* general configuration */ ushort fcyl; /* number of fixed cyls */ ushort rcyl; /* number of removable cyls */ ushort hds; /* number of heads */ ushort bpt; /* bytes/track */ ushort bps; /* bytes/sector */ ushort spt; /* sectors/track */ ushort isg; /* inter-sector gap */ ushort plo; /* PLO sync field */ ushort vsw; /* vendor status word */ } ID_PARMS; /* ** Used to manipulate identify drive data. */ union { ID_PARMS id_parms; unsigned short id_data[256]; } id_buf; /* pointer to low word of system time value at 0040:006c */ ushort far *TimePtr = (ushort far *)0x0040006cL; int drive = 0; /* drive number */ int wd_base = WDP_BASE0; /* base I/O port addr of HDC */ char *my_name; void reboot(void); void chk_drv(void); void dsp_bios_cfg(void); void dsp_hw_cfg(void); void reset_hdc(void); void delay(int); void sel_drv(uint, uint); void bsy_chk(void); void usage(void); void io_delay(void); void test_hdc(uint, uint, uint); /*----------------------------------------------- | | Main program | +----------------------------------------------*/ main(argc, argv) int argc; char *argv[]; { my_name = argv[0]; if (argc > 1) { if ( sscanf(argv[1], "%d", &drive) < 1 || drive < 0 || drive > 3) usage(); if (drive > 1) { drive &= 1; wd_base = WDP_BASE1; } } chk_drv(); /* make sure controller, drive present */ dsp_bios_cfg(); /* display BIOS drive config */ dsp_hw_cfg(); /* display H/W drive config */ reset_hdc(); /* reset the controller */ dsp_hw_cfg(); /* display H/W drive config */ reboot(); /* ask user to reboot system */ } /*----------------------------------------------- | | Ask user to reboot system. | +----------------------------------------------*/ void reboot() { fprintf(stderr, "Please reboot system!\n"); while (1) ; } /*----------------------------------------------- | | Check if controller, drive present. | +----------------------------------------------*/ void chk_drv() { #define MASK (WDM_BSY|WDM_RDY|WDM_WTF|WDM_SKC) #define EXP (WDM_RDY|WDM_SKC) test_hdc(wd_base+WDP_CL, 0x55, 0xff); test_hdc(wd_base+WDP_CL, 0xaa, 0xff); test_hdc(wd_base+WDP_CH, 0x55, 0x01); test_hdc(wd_base+WDP_CH, 0xaa, 0x01); sel_drv(drive, 0); if ((inp(wd_base+WDP_CSR) & MASK) != EXP) { fprintf(stderr, "Drive missing or status hosed\n"); exit(2); } } /*----------------------------------------------- | | Display BIOS configuration info for this drive. | +----------------------------------------------*/ void dsp_bios_cfg() { /* * Array of pointers to HD parameter table entries indexed * by drive number */ static BIOS_PARMS far * far *dskptr[2] = { (BIOS_PARMS far * far *)(4*0x41L), (BIOS_PARMS far * far *)(4*0x46L) }; BIOS_PARMS far *bpp = *dskptr[drive]; printf("BIOS reports drive has %u cyls, %u hds, %u secs/trk\n\n", bpp->ncyls, bpp->nheads, bpp->nsecs); } /*----------------------------------------------- | | Ask the drive to identify itself. | +----------------------------------------------*/ void dsp_hw_cfg() { int n; /* select drive */ sel_drv(drive, 0); /* Issue Get Drive Parameters cmd */ outp(wd_base+WDP_CSR, WDC_GDP); /* Wait for Busy status to be asserted */ for (n = 1000; n > 0 && (inp(wd_base+WDP_CSR) & WDM_BSY) == 0; n--) ; /* Now wait for Busy status to be negated */ bsy_chk(); /* Print error msg and bail out if error */ if ((n = inp(wd_base+WDP_CSR)) & WDM_HER) { fprintf(stderr, "Identify drive cmd failed: csr=0x%02x, err=0x%02x\n", n, inp(wd_base+WDP_ERR) ); reboot(); } /* Wait for Data request to be asserted */ while ((inp(wd_base+WDP_CSR) & WDM_DRQ) == 0) ; /* Input parameter info from controller */ for (n = 0; n < sizeof(id_buf.id_data)/sizeof(id_buf.id_data[0]); n++) id_buf.id_data[n] = inpw(wd_base+WDP_DAT); /* Print parameter info */ printf("Controller reports drive has %u cyls, %u hds, %u secs/trk\n\n", id_buf.id_parms.fcyl, id_buf.id_parms.hds, id_buf.id_parms.spt); } /*----------------------------------------------- | | Reset hard disk controller (or drive if IDE). | +----------------------------------------------*/ void reset_hdc() { printf("Resetting controller/drive\n\n"); outp(wd_base+WDP_DCR, WDM_RSTGO); delay(2); outp(wd_base+WDP_DCR, WDM_RSTNO|WDM_HS3); delay(1*TPS); } /*----------------------------------------------- | | Delay n system timer ticks. 18.2 ticks = 1 sec. | +----------------------------------------------*/ void delay(n) int n; { int cur_lsb = *TimePtr & 1; while (n-- > 0) { while ((*TimePtr & 1) == cur_lsb) ; cur_lsb = 1 - cur_lsb; } } /*----------------------------------------------- | | Select drive. | +----------------------------------------------*/ void sel_drv(drv, head) uint drv, head; { outp(wd_base+WDP_SDH, WDM_ECC|WDM_512|(drv<<4)|head); bsy_chk(); } /*----------------------------------------------- | | Wait for Busy status to be reset. | +----------------------------------------------*/ void bsy_chk() { while (inp(wd_base+WDP_CSR) & WDM_BSY) ; } /*----------------------------------------------- | | Display usage message, abort. | +----------------------------------------------*/ void usage() { static char msg[] = "Usage: %s [drive]\n" "Drive may be 0..3 (2,3 => drives on alternate controller)\n" "Default is 0\n"; fprintf(stderr, msg, my_name); exit(2); } /*----------------------------------------------- | | Delay a bit between back to back I/O operations. | The delay results from the call/return overhead. | +----------------------------------------------*/ void io_delay() { } /*----------------------------------------------- | | Check if hard disk controller is present and | probably register compatible with the standard | AT controller. Abort if not. | +----------------------------------------------*/ void test_hdc(reg, pat, msk) uint reg; uint pat; uint msk; { outp(reg, pat); io_delay(); io_delay(); io_delay(); io_delay(); io_delay(); io_delay(); if ((inp(reg)&msk) != (pat&msk)) { fprintf(stderr, "Non-compatible or missing Hard Disk Controller!\n"); exit(2); } } nate controller addide_conf/wddefs.h 644 433 0 5647 5370144145 7271 /*------------------------------------------------------+ | Definitions for WD100x hard disk controllers | +------------------------------------------------------*/ /* ** Port definitions: */ #define WDP_BASE0 0x1f0 /* base address of primary controller */ #define WDP_BASE1 0x170 /* base address of alternate controller */ #define WDP_DAT 0 /* offset to data reg (R/W) */ #define WDP_ERR 1 /* offset to error reg (R) */ #define WDP_WPC 1 /* offset to write precompensation reg (W) */ #define WDP_SC 2 /* offset to sector count reg (R/W) */ #define WDP_SEC 3 /* offset to sector address reg (R/W) */ #define WDP_CL 4 /* offset to cyl addr reg - low byte (R/W) */ #define WDP_CH 5 /* offset to cyl addr reg - high byte (R/W) */ #define WDP_SDH 6 /* offset to size/drive/head reg (R/W) */ #define WDP_CSR 7 /* offset to control/status reg (R/W) */ #define WDP_ASR 0x206 /* offset to alternate status reg (R) */ #define WDP_DCR 0x206 /* offset to device control reg (W) */ #define WDP_DAR 0x207 /* offset to device addr reg (R) */ /* ** Controller command definitions: */ #define WDC_HOM 0x10 /* restore drv to trk 0 */ #define WDC_SEK 0x70 /* seek */ #define WDC_RD 0x20 /* read sectors */ #define WDC_WRT 0x30 /* write sectors */ #define WDC_RVS 0x40 /* read verify sectors */ #define WDC_FMT 0x50 /* format track */ #define WDC_TST 0x90 /* perform self test */ #define WDC_IDP 0x91 /* init drive parms */ #define WDC_GDP 0xec /* get drive parameters */ #define WDC_SDP 0x91 /* set drive parameters */ /* ** SDH register mask definitions: */ #define WDM_ECC 0x80 /* enable ECC */ #define WDM_128 0x60 /* 128 bytes/sector */ #define WDM_256 0x00 /* 256 bytes/sector */ #define WDM_512 0x20 /* 512 bytes/sector */ #define WDM_1024 0x40 /* 1024 bytes/sector */ /* ** Command/status register mask definitions: */ #define WDM_HER 0x01 /* hard error (R) */ #define WDM_IDX 0x02 /* index pulse status from drive (R) */ #define WDM_CER 0x04 /* corrected error (R) */ #define WDM_DRQ 0x08 /* data request (R) */ #define WDM_SKC 0x10 /* seek complete (R) */ #define WDM_WTF 0x20 /* write fault (R) */ #define WDM_RDY 0x40 /* ready (R) */ #define WDM_BSY 0x80 /* busy (R) */ #define WDM_DRT 0x01 /* disable retries (W) */ /* ** Error register mask definitions: */ #define WDM_DAE 0x01 /* data address mark not found */ #define WDM_T0E 0x02 /* track 0 error */ #define WDM_CAE 0x04 /* aborted command */ #define WDM_NIE 0x10 /* ID not found */ #define WDM_ICE 0x20 /* CRC error - ID field */ #define WDM_DCE 0x40 /* CRC error - data field */ #define WDM_BBE 0x80 /* bad block detected */ #define WDM_HS3 0x08 /* use reduced write current line for HS3 */ #define WDM_RSTGO 0x04 /* start controller reset */ #define WDM_RSTNO 0x00 /* end controller reset */ #define WDM_IEN 0x02 /* interrupt enable */ set the controller */ dsp_hw_cfg(); /* display H/W drive config */ reboot(); /* ask uide_conf/ide_conf.exe 644 433 0 23701 5370144146 10125 MZ bLpIU3^@~~8JPBQw>=|>J|>J~>J~ &JLp)]3NPxP3PUQLRnPPLQXPUQLQBPPLP-+P6JLP%=PtePxPPÐUJğ&&W‹&O*Q&OQ&7P]U+P6J9PLP:FN~~LPt)LPFt L@PPvPxP[LPtF6L^㉇@F~r6L6F6BPE]Ð31P4PLPwPPLP\PUF&%F&%;Ft+FFFN ދ]U3`F FPLP]3;LPuÐ3#6@NPxP4P3U3vvvq#FN#N;tPxPP]ô0!<s3P˿6+rׁN sZ3PL!ƱH666gP6g P6g6g6&6+۴J!62P +30K3H6;6967P.Iظ6PP6>2uXP66P5!%!>Bt6DL&6,F36Bsy6Jڻ6B&,>3&=t4 t 3u!#,Ar ,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?3_QRSP;ZY=uNW3& _tFNW3 _tFW  u u30<9vFNY+G_^]UWVv~tEuEtEt2}uWj9Eu}uE eM*^_]ÐU^;!r *FtH~ t3ɋѸB!rKF uFVy(6VFѸB!FVy NVB!؋VNF B!r#U^;!r h3Na#uZ>2u4NV?!s >#t7#VW% < u#:t<u#G+_^t< t#@tD! u V?!r԰ ,FV?!r t~tѸB!~ t V떋V딀~ uU^;!r >2u4# t B3ɋ!r#tnV3FFWVfN8 uJ=vFܺ=(s+ԋN< t ;t"j ;u F ^_^!PSQ+Q^@!Yr F;wY[Xß~us #@t ^?u F+Ff^_N uV@!s u#@t ڀ?uYN;s+3"UV^9\s KK9\v\^]UVWNwsr s3_^]ASw_ 3#[uBSw_;t6K3 T;sr#tH;s#rЭtD[GG[Lt +H+ƌQWGtct+IAAw tLs 30?&= t;ru"rHs3#R.Zs t+WGw JBw _YËGtJwN;r9Ws6BSQގƱuGt Ƌ+ÎËشJ!Y[rGtJWWw;w uw=t$OO_U׌؎~3I]UWVv8I6625V4FPv2P)^_]UV2]UVF]U׌؎~ߋNFtI]UV]UFN ȋNu F]S؋Ff ؋F[]2US^vvw7W[]US^WNW[]MS Run-Time Library - Copyright (c) 1990, Microsoft Corp%dl@Please reboot system! Drive missing or status hosed BIOS reports drive has %u cyls, %u hds, %u secs/trk Identify drive cmd failed: csr=0x%02x, err=0x%02x Controller reports drive has %u cyls, %u hds, %u secs/trk Resetting controller/drive Usage: %s [drive] Drive may be 0..3 (2,3 => drives on alternate controller) Default is 0 Non-compatible or missing Hard Disk Controller! !_C_FILE_INFO=AP   BB - ]]EEE50P 0PX000WP ``````ppxxxx(null)       ((((( H z <>R6000 - stack overflow R6003 - integer divide by 0 R6009 - not enough space for environment run-time error R6002 - floating-point support not loaded R6001 - null pointer assignment ---------------------------- | | Display usage message, aborLD$#炀u |ǂu HD3C_^]UVWvDth@udDt tWL $ $Dh3ۊ\uLuuCpt xtu$#@tQ~WS>L \SV[[[Dt֋ T+BUJT QQtS_Y|V;u3F3# tQPPS3_^]UVvPjYށh t LG LGGDD^]UVWvptxt uHhD u8u3 tDDELSP[[ t3_^]UVWvht#3ۊ\#@tVX~t 3E