/*static char *SCCSID = "@(#)hyberhd.h  6.1 95/04/26";*/
/*
 *      IBM Confidential
 *
 *      Copyright (c) IBM Corporation 1995
 *
 *      All Rights Reserved
 *
 *  154438   5/10/96  cgw  add drive parm to hddumpsys prototype
 *
 */

#ifndef HYBERI13

/**** i/o addresses                                                     */
#define HD_C0   0x1f0                   /* controller 0                 */
#define HD_C1   0x170                   /* controller 1                 */
#define HD_ASR  0x3f6                   /* alternate status reg         */

/**** register addresses                                                */
#define HD_DR   0                       /* data register                */
#define HD_ER   1                       /* error register               */
#define HD_FR   1                       /* feature register             */
#define HD_SCR  2                       /* sector count register        */
#define HD_SNR  3                       /* sector number register       */
#define HD_CLR  4                       /* cylinder low register        */
#define HD_CHR  5                       /* cylinder high register       */
#define HD_DHR  6                       /* drive/head register          */
#define HD_CR   7                       /* command register             */
#define HD_SR   7                       /* status register              */

/**** status register bits                                              */
#define HD_BSY  0x80                    /* busy                         */
#define HD_DRDY 0x40                    /* drive ready                  */
#define HD_DWF  0x20                    /* drive write fault            */
#define HD_DSC  0x10                    /* drive seek complete          */
#define HD_DRQ  0x08                    /* data request                 */
#define HD_CORR 0x04                    /* corrected data               */
#define HD_IDX  0x02                    /* index                        */
#define HD_ERR  0x01                    /* error                        */

/**** drive/head register                                               */
#define HD_DRV0 0xa0                    /* drive 0 - master             */
#define HD_DRV1 0xb0                    /* drive 1 - slave              */
#define HD_LBA  0x40                    /* logical block addressing     */

/**** commands                                                          */
#define HD_NOP          0x00            /* no-op                        */
#define HD_READ         0x20            /* read sectors w/retry         */
#define HD_WRITE        0x30            /* write sectors w/retry        */
#define HD_READM        0xc4            /* read multiple                */
#define HD_WRITEM       0xc5            /* write sectors w/retry        */
#define HD_SMM          0xc6            /* set multiple mode            */
#define HD_ID           0xec            /* identify drive               */
#define HD_SF           0xef            /* set features                 */

/**** misc                                                              */
#define MAXIO           256             /* largest possible i/o op      */

/**** ATA IDENTIFY DEVICE data for devices below 8 GB                   */
/**** Data format - 256 word array                                      */
/****                                                                   */
/**** Note:  The orginal IBM PC BIOS has a limitation on the support    */
/****        of disk drives up to 1024 cylinders, 16 heads and 63       */
/****        sectors per track (with the maximum capacity of 528 MB).   */
/****                                                                   */
/****        BIOS and other software that operate the ATA disk in       */
/****        Cylinder/Head/Sector (CHS) addressing mode use the         */
/****        Identify Drive data words 1, 3, 6 and words 53-58 to       */
/****        ascertain the appropriate translation mode to use and      */
/****        determine the capacity of an ATA disk drive.               */
/****                                                                   */
/****        ATA Standard recommends the following rules for CHS        */
/****        addressing mode for disks up to 8 GB.                      */
/****                                                                   */
/****        WORD 1 (Default Cylinders):                                */
/****          For drives less than or equal to 528 MB, this value      */
/****          shall not exceed 1024 cylinders.                         */
/****                                                                   */
/****          For drives greater than 528 MB but <= 8 GB, the          */
/****          maximum value that shall be placed into the word         */
/****          is determined by the value in Word 3:                    */
/****                                                                   */
/****          value in WORD 3      Max value in WORD 1                 */
/****          ----------------------------------------                 */
/****            1 (01h)            65,535 (FFFFh)                      */
/****            2 (02h)            65,535 (FFFFh)                      */
/****            3 (03h)            65,535 (FFFFh)                      */
/****            4 (04h)            65,535 (FFFFh)                      */
/****            5 (05h)            32,767 (7FFFh)                      */
/****            6 (06h)            32,767 (7FFFh)                      */
/****            7 (07h)            32,767 (7FFFh)                      */
/****            8 (08h)            32,767 (7FFFh)                      */
/****            9 (09h)            16,383 (3FFFh)                      */
/****           10 (0Ah)            16,383 (3FFFh)                      */
/****           11 (0Bh)            16,383 (3FFFh)                      */
/****           12 (0Ch)            16,383 (3FFFh)                      */
/****           13 (0Dh)            16,383 (3FFFh)                      */
/****           14 (0Eh)            16,383 (3FFFh)                      */
/****           15 (0Fh)            16,383 (3FFFh)                      */
/****           16 (10h)            16,383 (3FFFh)                      */
/****                                                                   */
/****        WORD 3 (Default Heads):                                    */
/****          This value shall not exceed 16.                          */
/****                                                                   */
/****        WORD 6 (Default Sectors):                                  */
/****          This value shall not exceed 63                           */
/****                                                                   */
/****        ATA drives that are over 528 MB shall implement word       */
/****        53-58.  Drives not over 528 MB may also implement these    */
/****        words.  These words define the addressing for all sectors  */
/****        accessible in the current CHS mode.                        */
/****                                                                   */
/****        WORD 53                                                    */
/****          Bit 0 of this word shall be set to 1 at all times that   */
/****          the drive is in a valid translation mode.  An attempt    */
/****          to put a drive into one of the unsupported modes shall   */
/****          cause bit 0 of this word to be cleared with word 54-     */
/****          58 set to zereos.                                        */
/****                                                                   */
/****        WORD 54 (Current Cylinders)                                */
/****          This value specify the number of cylinders that can      */
/****          be accessed in the current translation mode.  If an      */
/****          Initialize Drive Parameters command has not been         */
/****          executed, the contents of this word shall be the same    */
/****          as word 1 (Default Cylinders).  If an Initialize Drive   */
/****          Parameters command has been executed, this word is the   */
/****          integer result of dividing the total number of user      */
/****          sectors (this value may be in words 60-61) by the        */
/****          number of sectors per logical cylinders ( [word 55] x    */
/****          [word 56] ), but shall not be greater than 65,535.       */
/****                                                                   */
/****        WORD 55 (Current Heads)                                    */
/****          This value contains the number of heads specified by     */
/****          the last Initialize Drive Parameters command. The        */
/****          initial default shall be the same as word 3.             */
/****                                                                   */
/****        WORD 56 (Current Sectors)                                  */
/****          This value contains the number of sectors specified by   */
/****          the last Initialize Drive Parameters command.  The       */
/****          initial default shall be the same as word 6.             */
/****                                                                   */
/****        WORD 57-58 (Current Capacity in sectors)                   */
/****          This 32-bit value shall be equal to ( [word 54] x        */
/****          [word 55] x [word 56] ).  If words 60-61, LBA sectors,   */
/****          are not zero, this 32-bit value shall be less than or    */
/****          equal to the value in words 60-61 at all times.          */
/****                                                                   */
/****        It is recommended that ATA drives over 528 MB support      */
/****        Logical Block Addressing (LBA).                            */
/****                                                                   */
/****        WORD 60-61                                                 */
/****          This 32-bit value shall specify the total number of      */
/****          sectors available in LBA mode at all times.  This        */
/****          value, if supported, shall be equal or greater than      */
/****          the value in words 57-58 at all times.                   */
/****                                                                   */
/****        The sectors, if any, between the last sector addressable   */
/****        in CHS mode and the last sector addressable in LBA mode    */
/****        are known as "orphan" sectors.  A drive may or may not     */
/****        allow access to these sectors in CHS addressing mode.      */
/****                                                                   */
#define GEN_CONFIG      0     /* Bit significant information            */
  #define GEN_STANDARD 0x8000 /* 15   0 = ATA standard observed         */
  #define GEN_REM_DEV  0x0080 /*  7   1 = removeable media device       */
  #define GEN_FIX_DEV  0x0040 /*  6   1 = fixed controller and/or device*/

#define DEF_CYLINDERS   1     /* # of cylinders         (HW default)    */
#define DEF_HEADS       3     /* # of heads             (HW default)    */
#define DEF_SPT         6     /* # of sectors per track (HW default)    */
#define MAX_IO_BLKS    47     /* Byte 0 - READ/WRITE MULTIPLE supported */
                              /* 01h - FFh = Maximum # of sectors per   */
                              /*             I/O request.               */
#define DEV_CAP        49     /* Bit significant device capabilities    */
                              /* 13   1 = Standy timer values supported */
                              /* 11   1 = IORDY supported               */
                              /*      0 = IORDY may be supported        */
                              /* 10   1 = IORDY can be disabled         */
                              /*  9   1 = LBA supported                 */
                              /*  8   1 = DMA supported                 */

#define PIO_XFER_CYCLE 51     /* 15 - 8 = PIO data transfer cycle       */
                              /*          timing mode                   */
                              /*  7 - 0 = Vendor specific               */

#define DMA_XFER_CYCLE 52     /* 15 - 8 = DMA data transfer cycle       */
                              /*          timing mode                   */
                              /*  7 - 0 = Vendor specific               */

#define ADV_MODE_INFO  53     /* Bit significatn information            */
                              /*  1   1 = words 64-70 are valid         */
                              /*  0   1 = words 54-58 are valid         */

#define CUR_CYLINDERS  54     /* Current # of logical cylinders         */
#define CUR_HEADS      55     /* Current # of logical heads             */
#define CUR_SPT        56     /* Current # of sectors per track         */

#define CUR_CAP_SEC_L  57     /* Current capacity in sectors            */
#define CUR_CAP_SEC_h  58     /*                                        */

#define CUR_MULTI_IO   59     /* Bit 8  1 = Multiple sector setting     */
                              /*            is valid                    */
                              /* Bit 7-0  = Current setting for # of    */
                              /*            sectors per MULITPLE I/O    */
                              /*            command                     */

#define LBA_LOW        60     /* Total # of addressable sectors         */
#define LBA_HI         61     /*                                        */

#define SINGLE_DMA     62     /* Bit 15-8 = Single word DMA transfer    */
                              /*            mode active                 */
                              /* Bit  7-0 = Single word DMA transfer    */
                              /*            mode supported              */

#define MULTI_DMA      63     /* Bit 15-8 = Multi word DMA transfer     */
                              /*            mode active                 */
                              /* Bit  7-0 = Multi word DMA transfer     */
                              /*            mode supported              */
#define ADV_PIO        64     /* Bit  7-0 = Advanced PIO transfer mode  */
                              /*            supported                   */

#define STD_DMA_TIMING 65     /* Miminum Multiword DMA Transfer Cycle   */
                              /* Time per word (in nanoseconds)         */

#define MFG_DMA_TIMING 66     /* Manufacturer's recommended Multiword   */
                              /* DMA Transfer Cycle Time per word       */

#define PIO_TIMING     67     /* Minimum PIO Transfer Cycle Time        */
                              /* without Flow Control (in nanoseconds)  */

#define PIO_FLOW_TIMING 68    /* Minimum PIO Transfer Cycle Time with   */
                              /* IORDY Flow Control (in nanoseconds)    */


extern unsigned char inb(register long address);
extern void outb(register long data, register long address);
extern long hdReadBlock(register unsigned char *address, register long len, long blksize);
extern long hdWriteBlock(register unsigned char *address, register long len, long blksize);
extern long hdWaitNotBusy();
extern unsigned char hdWaitReady();
#else  /* HYBERI13 */
extern long hdDumpSys(uchar_t drive,
                      uchar_t drive2,
                      ulong_t dlistphy, ulong_t dlistn,
                      ulong_t plistphy, ulong_t plistn,
                      ulong_t iobufphy, ulong_t iobufsz);
#endif /* HYBERI13 */
extern int3();
extern enable();

