Changeset 150 in xtideuniversalbios
- Timestamp:
- Apr 29, 2011, 7:04:13 PM (14 years ago)
- google:author:
- aitotat
- Location:
- trunk/XTIDE_Universal_BIOS
- Files:
-
- 15 added
- 7 deleted
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc
r99 r150 5 5 %define CUSTOMDPT_INC 6 6 7 ; Base DPT for all device types 8 struc DPT ; 8 bytes 9 ; General Disk Parameter Table related 10 .wFlags resb 2 11 .bIdevarsOffset resb 1 ; Offset to IDEVARS for this drive 7 12 8 ; Base Disk Parameter Table for all hard disk drives. 9 ; DPT might have extensions for specific functions. 10 struc DPT 11 ; General Disk Parameter Table related 12 .bSize resb 1 ; Size of DPT (with extensions) in bytes 13 .wDrvNumAndFlags: 14 .bDrvNum resb 1 ; Drive number 15 .bFlags resb 1 ; DPT and Drive related flags 16 .bReset resb 1 ; Drive reset status (for debugging) 17 .bIdeOff resb 1 ; Offset to IDEVARS for this drive 13 ; L-CHS to P-CHS and L-CHS to LBA28 conversion related 14 .bLchsHeads resb 1 ; Number of L-CHS Heads (1...255) 18 15 19 ; Lookup values for L-CHS to P-CHS and L-CHS to LBA28 conversions 20 .bShLtoP resb 1 ; Bit shift count for L-CHS to P-CHS conversion 21 .wLHeads resb 2 ; Number of L-CHS Heads (1...256) 22 23 ; IDE related 24 .wPCyls resb 2 ; Number of P-CHS (IDE) Cylinders (1...16383) 25 .wHeadsAndSectors: 26 .bPHeads resb 1 ; Number of P-CHS (IDE) Heads (1...16) 27 .bPSect resb 1 ; Number of P-CHS (IDE) Sectors per Track (1...63) 28 .bDrvSel resb 1 ; Drive Selection byte for Device/Head Register 29 .bDrvCtrl resb 1 ; Drive Control byte for Device Control Register 30 31 ; Related to Block Mode transfers. 32 ; Block size is specified in sectors (1, 2, 4, 8, 16, 32, 64 or 128). 33 .wSetAndMaxBlock: 34 .bSetBlock resb 1 ; Currect block size (at least 1) 35 .bMaxBlock resb 1 ; Maximum block size, 0 = block mode not supported 16 ; IDE Drive related 17 .wPchsCylinders resb 2 ; Number of P-CHS (IDE) Cylinders (1...16383) 18 .wPchsHeadsAndSectors: 19 .bPchsHeads resb 1 ; Number of P-CHS (IDE) Heads (1...16) 20 .bPchsSectors resb 1 ; Number of P-CHS (IDE) Sectors per Track (1...63) 36 21 endstruc 37 22 38 ; Bit definitions for DPT.bFlags 39 MASK_DPT_ADDR EQU 110b ; Bits 1..2, Addressing Mode 40 FLG_DPT_EBIOS EQU (1<<0) ; EBIOS functions supported for this drive 41 FLG_DPT_FIRSTPART EQU (1<<3) ; First BIOS Partition of the drive (drive reset allowed) 42 FLG_DPT_PARTITION EQU (1<<4) ; BIOS Partition 43 FLG_DPT_USERCHS EQU (1<<5) ; User has specified P-CHS parameters 23 ; DPT for ATA devices 24 struc DPT_ATA ; 8 + 2 bytes = 10 bytes 25 .dpt resb DPT_size 44 26 45 ; Values for different addressing modes (MASK_DPT_ADDR for DPT.bFlags) 46 ADDR_DPT_LCHS EQU 0 ; L-CHS Addressing Mode (NORMAL in many other BIOSes) 47 ADDR_DPT_PCHS EQU 1 ; P-CHS Addressing Mode (LARGE in many other BIOSes) 48 ADDR_DPT_LBA28 EQU 2 ; 28-bit LBA Addressing Mode 49 ADDR_DPT_LBA48 EQU 3 ; 48-bit LBA Addressing Mode 27 ; Block size is specified in sectors (1, 2, 4, 8, 16, 32 or 64). 28 ; 128 is not allowed to prevent offset overflow during data transfer. 29 .wSetAndMaxBlock: 30 .bSetBlock resb 1 ; Current block size (at least 1) 31 .bMaxBlock resb 1 ; Maximum block size, 0 = block mode not supported 32 endstruc 50 33 51 ; Bit definitions for DPT.bReset (inverted) 52 FLG_RESET_nDRDY EQU (1<<0) ; Drive ready to accept commands 53 FLG_RESET_nINITPRMS EQU (1<<1) ; Initialize Device Parameters successfull 54 FLG_RESET_nRECALIBRATE EQU (1<<2) ; Recalibrate successfull 55 FLG_RESET_nSETBLOCK EQU (1<<3) ; Initialize Block Mode successfull 56 MASK_RESET_ALL EQU (FLG_RESET_nDRDY | FLG_RESET_nINITPRMS | FLG_RESET_nRECALIBRATE | FLG_RESET_nSETBLOCK) 34 LARGEST_DPT_SIZE EQU DPT_ATA_size 57 35 58 36 59 ; Extended DPT for XTIDE Universal BIOS partitioned drive. 60 ; This struct cannot exist with EDPT (EBIOS support). 61 struc PART_DPT 62 .dpt resb DPT_size 63 .dwStartLBA: 64 .twStartLBA resb 6 ; Starting 28- or 48-bit LBA for BIOS partition 65 endstruc 37 ; Bit definitions for DPT.wFlags 38 MASK_DPT_CHS_SHIFT_COUNT EQU (7<<0) ; Bits 0...3, P-CHS to L-CHS bit shift count (0...4) 39 FLG_DPT_SLAVE EQU FLG_DRVNHEAD_DRV ; (1<<4), Drive is slave drive 40 MASK_DPT_ADDRESSING_MODE EQU (3<<5) ; Bits 5..6, Addressing Mode (bit 6 == FLG_DRVNHEAD_LBA) 41 FLG_DPT_ENABLE_IRQ EQU (1<<7) 42 FLG_DPT_REVERSED_A0_AND_A3 EQU (1<<8) ; XTIDE mod, Address lines 0 and 3 reversed 43 FLG_DPT_SERIAL_DEVICE EQU (1<<9) ; Serial Port Device 44 FLG_DPT_BLOCK_MODE_SUPPORTED EQU (1<<10) ; Use block transfer commands 66 45 46 FLG_DPT_RESET_nDRDY EQU (1<<12) ; Drive ready to accept commands 47 FLG_DPT_RESET_nINITPRMS EQU (1<<13) ; Initialize Device Parameters successfull 48 FLG_DPT_RESET_nRECALIBRATE EQU (1<<14) ; Recalibrate successfull 49 FLG_DPT_RESET_nSETBLOCK EQU (1<<15) ; Initialize Block Mode successfull 50 MASK_DPT_RESET EQU 0F000h 67 51 68 ; Extended DPT for EBIOS support. 69 ; This struct cannot exist with PDPT (XTIDE Universal BIOS partitioned drive). 70 struc EBDPT 71 .dpt resb DPT_size 72 .dwCapacity: 73 .twCapacity resb 6 ; Total drive capacity in sectors 74 endstruc 52 ; Addressing modes for DPT.wFlags 53 ADDRESSING_MODE_FIELD_POSITION EQU 5 54 ADDRESSING_MODE_LCHS EQU 0 ; L-CHS Addressing Mode (NORMAL in many other BIOSes) 55 ADDRESSING_MODE_PCHS EQU 1 ; P-CHS Addressing Mode (LARGE in many other BIOSes) 56 ADDRESSING_MODE_LBA28 EQU 2 ; 28-bit LBA Addressing Mode 57 ADDRESSING_MODE_LBA48 EQU 3 ; 48-bit LBA Addressing Mode 75 58 76 59 -
trunk/XTIDE_Universal_BIOS/Inc/IDE_8bit.inc
r3 r150 1 ; File name : IDE_8bit.inc 2 ; Project name : IDE BIOS 3 ; Created date : 4.4.2010 4 ; Last update : 13.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Macros for accessing data port(s) on 8-bit 7 3 ; IDE controllers. 8 4 %ifndef IDE_8BIT_INC 9 5 %define IDE_8BIT_INC 10 11 ;--------------------------------------------------------------------12 ; Emulates REP INSW for XTIDE dual (8-bit) data port.13 ;14 ; eREP_DUAL_BYTE_PORT_INSW15 ; Parameters:16 ; CX: Loop count17 ; DX: Port address (must be IDE Data Register)18 ; ES:DI: Ptr to destination buffer19 ; Returns:20 ; CX: Zero21 ; DI: Incremented/decremented22 ; Corrupts registers:23 ; AX, FLAGS24 ;--------------------------------------------------------------------25 %macro eREP_DUAL_BYTE_PORT_INSW 026 push bx27 times 2 shr cx, 1 ; Loop unrolling28 mov bx, 8 ; Bit mask for toggling data low/high reg29 ALIGN JUMP_ALIGN30 %%InswLoop:31 eDUAL_BYTE_PORT_INSW32 eDUAL_BYTE_PORT_INSW33 eDUAL_BYTE_PORT_INSW34 eDUAL_BYTE_PORT_INSW35 loop %%InswLoop36 pop bx37 %endmacro38 6 39 7 ;-------------------------------------------------------------------- … … 66 34 %endmacro 67 35 68 69 ;--------------------------------------------------------------------70 ; Emulates REP OUTSW for XTIDE dual (8-bit) data port.71 ;72 ; eREP_DUAL_BYTE_PORT_OUTSW73 ; Parameters:74 ; CX: Loop count75 ; DX: Port address (must be IDE Data Register)76 ; ES:SI: Ptr to source buffer77 ; Returns:78 ; SI: Incremented/decremented79 ; Corrupts registers:80 ; AX, CX81 ;--------------------------------------------------------------------82 %macro eREP_DUAL_BYTE_PORT_OUTSW 083 push ds84 push bx85 times 2 shr cx, 1 ; Loop unrolling86 mov bx, 8 ; Bit mask for toggling data low/high reg87 push es ; Copy ES...88 pop ds ; ...to DS89 ALIGN JUMP_ALIGN90 %%OutswLoop:91 eDUAL_BYTE_PORT_OUTSW92 eDUAL_BYTE_PORT_OUTSW93 eDUAL_BYTE_PORT_OUTSW94 eDUAL_BYTE_PORT_OUTSW95 loop %%OutswLoop96 pop bx97 pop ds98 %endmacro99 36 100 37 ;-------------------------------------------------------------------- … … 130 67 131 68 132 ;--------------------------------------------------------------------133 ; Emulates REP INSW for IDE controllers with single 8-bit Data Port.134 ;135 ; eREP_SINGLE_BYTE_PORT_INSW136 ; Parameters:137 ; CX: Number of WORDs to transfer138 ; DX: IDE Data Port address139 ; ES:DI: Ptr to destination buffer140 ; Returns:141 ; DI: Incremented/decremented142 ; Corrupts registers:143 ; AL, CX144 ;--------------------------------------------------------------------145 %macro eREP_SINGLE_BYTE_PORT_INSW 0146 %ifdef USE_186 ; INS instruction available147 shl cx, 1 ; WORD count to BYTE count148 rep insb149 %else ; If 8088/8086150 shr cx, 1 ; WORD count to DWORD count151 ALIGN JUMP_ALIGN152 %%InsdLoop:153 in al, dx154 stosb ; Store to [ES:DI]155 in al, dx156 stosb157 in al, dx158 stosb159 in al, dx160 stosb161 loop %%InsdLoop162 %endif163 %endmacro164 165 166 ;--------------------------------------------------------------------167 ; Emulates REP OUTSW for IDE controllers with single 8-bit Data Port.168 ;169 ; eREP_SINGLE_BYTE_PORT_OUTSW170 ; Parameters:171 ; CX: Number of WORDs to transfer172 ; DX: IDE Data Port address173 ; ES:SI: Ptr to source buffer174 ; Returns:175 ; SI: Incremented/decremented176 ; Corrupts registers:177 ; AL, CX178 ;--------------------------------------------------------------------179 %macro eREP_SINGLE_BYTE_PORT_OUTSW 0180 %ifdef USE_186 ; OUTS instruction available181 shl cx, 1 ; WORD count to BYTE count182 eSEG es ; Source is ES segment183 rep outsb184 %else ; If 8088/8086185 shr cx, 1 ; WORD count to DWORD count186 push ds ; Store DS187 push es ; Copy ES...188 pop ds ; ...to DS189 ALIGN JUMP_ALIGN190 %%OutsdLoop:191 lodsb ; Load from [DS:SI] to AL192 out dx, al193 lodsb194 out dx, al195 lodsb196 out dx, al197 lodsb198 out dx, al199 loop %%OutsdLoop200 pop ds ; Restore DS201 %endif202 %endmacro203 204 205 69 %endif ; IDE_8BIT_INC -
trunk/XTIDE_Universal_BIOS/Inc/IdeRegisters.inc
r3 r150 1 ; File name : IdeRegisters.inc 2 ; Project name : IDE BIOS 3 ; Created date : 23.3.2010 4 ; Last update : 23.3.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Equates for IDE registers, flags and commands. 7 3 %ifndef IDEREGISTERS_INC … … 9 5 10 6 ; IDE Register offsets from Command Block base port 11 REG_IDE_DATA EQU 0 ; Data Register 12 REGR_IDE_ERROR EQU 1 ; Error Register 13 REGW_IDE_FEAT EQU 1 ; Features Register (ATA1+) 14 ; REGW_IDE_WRPC EQU 1 ; Write Precompensation Register (obsolete on ATA1+)15 REG_IDE_CNT EQU 2 ; Sector Count Register 16 REG_IDE_SECT EQU 3 ; Sector Number Register (LBA 7...0) 17 REG_IDE_LBA_LOW EQU 3 ; LBA LowRegister18 REG_IDE_LOCYL EQU 4 ; Low Cylinder Register (LBA 15...8) 19 REG_IDE_LBA_MID EQU 4 ; LBA Mid Register 20 REG_IDE_HICYL EQU 5 ; High Cylinder Register (LBA 23...16) 21 REG_IDE_LBA_HIGH EQU 5 ; LBA High Register 22 REG_IDE_DRVHD EQU 6 ; Drive and Head Register (LBA 27...24) 23 REGR_IDE_ST EQU 7 ; Status Register 24 REGW_IDE_CMD EQU 7 ; Command Register 25 REG_IDE_HIDATA EQU 8 ; XTIDE Data High Register(actually first Control Block reg)7 DATA_REGISTER EQU 0 8 ERROR_REGISTER_in EQU 1 ; Read only 9 FEATURES_REGISTER_out EQU 1 ; Write only, ATA1+ 10 ;WRITE_PRECOMPENSATION_out EQU 1 ; Write only, Obsolete on ATA1+ 11 SECTOR_COUNT_REGISTER EQU 2 12 SECTOR_NUMBER_REGISTER EQU 3 ; LBA Low Register 13 LOW_CYLINDER_REGISTER EQU 4 ; LBA Middle Register 14 HIGH_CYLINDER_REGISTER EQU 5 ; LBA High Register 15 LBA_LOW_REGISTER EQU 3 ; LBA 7...0, LBA48 31...24 16 LBA_MIDDLE_REGISTER EQU 4 ; LBA 15...8, LBA48 39...32 17 LBA_HIGH_REGISTER EQU 5 ; LBA 23...16, LBA48 47...40 18 DRIVE_AND_HEAD_SELECT_REGISTER EQU 6 ; LBA28 27...24 19 STATUS_REGISTER_in EQU 7 ; Read only 20 COMMAND_REGISTER_out EQU 7 ; Write only 21 XTIDE_DATA_HIGH_REGISTER EQU 8 ; Non-standard (actually first Control Block reg) 26 22 27 23 ; IDE Register offsets from Control Block base port 28 24 ; (usually Command Block base port + 200h) 29 REGR_IDEC_AST EQU 6 ; Alternate Status Register 30 REGW_IDEC_CTRL EQU 6 ; Device Control Register 31 ; REGR_IDEC_ADDR EQU 7 ; Drive Address Register (obsolete on ATA2+)25 ALTERNATE_STATUS_REGISTER_in EQU 6 ; Read only 26 DEVICE_CONTROL_REGISTER_out EQU 6 ; Write only 27 ;DRIVE_ADDRESS_REGISTER EQU 7 ; Obsolete on ATA2+ 32 28 29 ; Bit mask for XTIDE mod with reversed A0 and A3 address lines 30 MASK_A3_AND_A0_ADDRESS_LINES EQU ((1<<3) | (1<<0)) 33 31 34 32 ; Bit definitions for IDE Error Register 35 FLG_ IDE_ERR_BBK EQU (1<<7) ; Bad Block Detected (reserved on ATA2+, command dependent on ATA4+)36 FLG_ IDE_ERR_UNC EQU (1<<6) ; Uncorrectable Data Error (command dependent on ATA4+)37 FLG_ IDE_ERR_MC EQU (1<<5) ; Media Changed (command dependent on ATA4+)38 FLG_ IDE_ERR_IDNFEQU (1<<4) ; ID Not Found (command dependent on ATA4+)39 FLG_ IDE_ERR_MCR EQU (1<<3) ; Media Change Request (command dependent on ATA4+)40 FLG_ IDE_ERR_ABRTEQU (1<<2) ; Command Aborted41 FLG_ IDE_ERR_TK0NFEQU (1<<1) ; Track 0 Not Found (command dependent on ATA4+)42 FLG_ IDE_ERR_AMNFEQU (1<<0) ; Address Mark Not Found (command dependent on ATA4+)33 FLG_ERROR_BBK EQU (1<<7) ; Bad Block Detected (reserved on ATA2+, command dependent on ATA4+) 34 FLG_ERROR_UNC EQU (1<<6) ; Uncorrectable Data Error (command dependent on ATA4+) 35 FLG_ERROR_MC EQU (1<<5) ; Media Changed (command dependent on ATA4+) 36 FLG_ERROR_IDNF EQU (1<<4) ; ID Not Found (command dependent on ATA4+) 37 FLG_ERROR_MCR EQU (1<<3) ; Media Change Request (command dependent on ATA4+) 38 FLG_ERROR_ABRT EQU (1<<2) ; Command Aborted 39 FLG_ERROR_TK0NF EQU (1<<1) ; Track 0 Not Found (command dependent on ATA4+) 40 FLG_ERROR_AMNF EQU (1<<0) ; Address Mark Not Found (command dependent on ATA4+) 43 41 44 42 ; Bit definitions for IDE Drive and Head Select Register 45 FLG_ IDE_DRVHD_LBA EQU (1<<6) ; LBA Addressing enabled (instead of CHS)46 FLG_ IDE_DRVHD_DRV EQU (1<<4) ; Drive Select (0=Master, 1=Slave)47 MASK_ IDE_DRVHD_HEAD EQU 0Fh ; Head select bits (bits 0...3)48 MASK_ IDE_DRVHD_SET EQU 0A0h ; Bits that must be set to 1 on ATA1 (reserved on ATA2+)43 FLG_DRVNHEAD_LBA EQU (1<<6) ; LBA Addressing enabled (instead of CHS) 44 FLG_DRVNHEAD_DRV EQU (1<<4) ; Drive Select (0=Master, 1=Slave) 45 MASK_DRVNHEAD_HEAD EQU 0Fh ; Head select bits (bits 0...3) 46 MASK_DRVNHEAD_SET EQU 0A0h ; Bits that must be set to 1 on ATA1 (reserved on ATA2+) 49 47 50 48 ; Bit definitions for IDE Status Register 51 FLG_ IDE_ST_BSY EQU (1<<7) ; Busy (other flags undefined when set)52 FLG_ IDE_ST_DRDY EQU (1<<6) ; Device Ready53 FLG_ IDE_ST_DF EQU (1<<5) ; Device Fault (command dependent on ATA4+)54 FLG_ IDE_ST_DSC EQU (1<<4) ; Device Seek Complete (command dependent on ATA4+)55 FLG_ IDE_ST_DRQ EQU (1<<3) ; Data Request56 FLG_ IDE_ST_CORR EQU (1<<2) ; Corrected Data (obsolete on ATA4+)57 FLG_ IDE_ST_IDX EQU (1<<1) ; Index (vendor specific on ATA2+, obsolete on ATA4+)58 FLG_ IDE_ST_ERR EQU (1<<0) ; Error49 FLG_STATUS_BSY EQU (1<<7) ; Busy (other flags undefined when set) 50 FLG_STATUS_DRDY EQU (1<<6) ; Device Ready 51 FLG_STATUS_DF EQU (1<<5) ; Device Fault (command dependent on ATA4+) 52 FLG_STATUS_DSC EQU (1<<4) ; Device Seek Complete (command dependent on ATA4+) 53 FLG_STATUS_DRQ EQU (1<<3) ; Data Request 54 FLG_STATUS_CORR EQU (1<<2) ; Corrected Data (obsolete on ATA4+) 55 FLG_STATUS_IDX EQU (1<<1) ; Index (vendor specific on ATA2+, obsolete on ATA4+) 56 FLG_STATUS_ERR EQU (1<<0) ; Error 59 57 60 58 ; Bit definitions for IDE Device Control Register 61 59 ; Bit 0 must be zero, unlisted bits are reserved. 62 FLG_ IDE_CTRL_O8H EQU (1<<3) ; Drive has more than 8 heads (pre-ATA only, 1 on ATA1, reserved on ATA2+)63 FLG_IDE_CTRL_SRST EQU (1<<2) ; Software Reset 64 FLG_ IDE_CTRL_nIEN EQU (1<<1) ; Negated Interrupt Enable (IRQ disabled when set)65 60 FLG_DEVCONTROL_HOB EQU (1<<7) ; High Order Byte (ATA6+) 61 ;FLG_DEVCONTROL_O8H EQU (1<<3) ; Drive has more than 8 heads (pre-ATA only, 1 on ATA1, reserved on ATA2+) 62 FLG_DEVCONTROL_SRST EQU (1<<2) ; Software Reset 63 FLG_DEVCONTROL_nIEN EQU (1<<1) ; Negated Interrupt Enable (IRQ disabled when set) 66 64 67 65 ; Commands for IDE Controller 68 ;HCMD_RECALIBRATE EQU 10h ; Recalibrate 69 HCMD_READ_SECT EQU 20h ; Read Sectors (with retries) 70 HCMD_WRITE_SECT EQU 30h ; Write Sectors (with retries) 71 HCMD_VERIFY_SECT EQU 40h ; Read Verify Sectors (with retries) 72 ;HCMD_FORMAT EQU 50h ; Format track 73 HCMD_SEEK EQU 70h ; Seek 74 ;HCMD_DIAGNOSTIC EQU 90h ; Execute Device Diagnostic 75 HCMD_INIT_DEV EQU 91h ; Initialize Device Parameters 76 HCMD_READ_MUL EQU 0C4h ; Read Multiple (=block) 77 HCMD_WRITE_MUL EQU 0C5h ; Write Multiple (=block) 78 HCMD_SET_MUL EQU 0C6h ; Set Multiple Mode (=block size) 79 HCMD_ID_DEV EQU 0ECh ; Identify Device 80 HCMD_SET_FEAT EQU 0EFh ; Set Features 81 82 ; Set Features subcommands 83 HFEAT_SET_XFER_MODE EQU 03h ; Set transfer mode based on value in Sector Count register 66 COMMAND_READ_SECTORS EQU 20h 67 COMMAND_READ_SECTORS_EXT EQU 24h ; LBA48 68 COMMAND_WRITE_SECTORS EQU 30h 69 COMMAND_WRITE_SECTORS_EXT EQU 34h ; LBA48 70 COMMAND_VERIFY_SECTORS EQU 40h 71 COMMAND_VERIFY_SECTORS_EXT EQU 42h ; LBA48 72 COMMAND_SEEK EQU 70h 73 COMMAND_INITIALIZE_DEVICE_PARAMETERS EQU 91h 74 COMMAND_SET_MULTIPLE_MODE EQU 0C6h ; Block mode 75 COMMAND_READ_MULTIPLE EQU 0C4h ; Block mode 76 COMMAND_READ_MULTIPLE_EXT EQU 29h ; LBA48, Block mode 77 COMMAND_WRITE_MULTIPLE EQU 0C5h ; Block mode 78 COMMAND_WRITE_MULTIPLE_EXT EQU 39h ; LBA48, Block mode 79 COMMAND_IDENTIFY_DEVICE EQU 0ECh 80 COMMAND_SET_FEATURES EQU 0EFh 84 81 85 82 -
trunk/XTIDE_Universal_BIOS/Inc/Int13h.inc
r28 r150 1 ; File name : Int13h.inc 2 ; Project name : IDE BIOS 3 ; Created date : 23.3.2010 4 ; Last update : 29.7.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Equates used in INT 13h functions. 7 3 %ifndef INT13H_INC … … 40 36 41 37 42 ; Timeout values for IDE controller timeout43 ; 255 is the maximum value. Zero means immediate timeout.44 B_TIMEOUT_BSY EQU (1000/55) ; 1000 ms45 B_TIMEOUT_RDY EQU (1000/55) ; 1000 ms46 B_TIMEOUT_DRQ EQU 255 ; 14 s (some CF cards occasionally have long write delays)47 B_TIMEOUT_DRVINFO EQU (500/55) ; 500 ms48 B_TIMEOUT_RESET EQU 255 ; 14 s49 50 51 52 38 ; Floppy Drive types returned by INT 13h, AH=08h 53 39 FLOPPY_TYPE_525_OR_35_DD EQU 0 … … 59 45 60 46 47 MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS EQU 64 48 49 %define TIMEOUT_AND_STATUS_TO_WAIT(timeout, status) (((timeout)<<8) | (status)) 50 51 61 52 %endif ; INT13H_INC -
trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc
r148 r150 5 5 6 6 ; Segment when RAMVARS is stored to top of interrupt vectors. 7 SEGMENT_RAMVARS_TOP_OF_INTERRUPT_VECTORSEQU 30h7 LITE_MODE_RAMVARS_SEGMENT EQU 30h 8 8 9 9 … … 21 21 struc RAMVARS 22 22 .fpOldI13h resb 4 ; Far pointer to old INT 13h handler 23 .wIdeBase resb 2 ; Base port address for currently handled controller24 23 .wTimeoutCounter resb 2 24 .pInServiceDPT resb 2 ; Ptr to DPT for drive waiting for interrupt 25 .wSignature resb 2 ; Sign for finding stolen 1 kiB 25 26 26 27 .wDrvCntAndFirst: … … 32 33 endstruc 33 34 34 ; Full mode RAM variables. 35 struc FULLRAMVARS 36 .ramVars resb RAMVARS_size 37 .wSign resb 2 ; FULLRAMVARS signature for finding segment 35 RAMVARS_SIGNATURE EQU "Xu" ; RAMVARS signature for .wSignature 36 37 38 struc IDEPACK 39 .bDrvAndHead resb 1 ; LBA28 27...24 40 .bFeatures resb 1 41 42 .wSectorCountAndLbaLow: 43 .bSectorCount resb 1 44 .bSectorNumber: 45 .bLbaLow resb 1 ; LBA 7...0 46 47 .wCylinder: 48 .wLbaMiddleAndHigh: 49 .bLbaMiddle resb 1 ; LBA 15...8 50 .bLbaHigh resb 1 ; LBA 23...16 51 52 .bCommand resb 1 53 .bDeviceControl resb 1 ; Offset 7 shared with PIOVARS 54 55 ; Parameters for 48-bit LBA 56 .wSectorCountHighAndLbaLowExt: 57 .bSectorCountHighExt resb 1 ; LBA48 Sector Count 15...8 58 .bLbaLowExt resb 1 ; LBA48 31...24 59 60 .wLbaMiddleAndHighExt: 61 .bLbaMiddleExt resb 1 ; LBA48 39...32 62 .bLbaHighExt resb 1 ; LBA48 47...40 63 64 .intpack resb INTPACK_size 38 65 endstruc 39 66 40 W_SIGN_FULLRAMVARS EQU "fR" ; FULLRAMVARS signature 67 EXTRA_WORDS_TO_RESERVE_FOR_INTPACK EQU ((IDEPACK_size - INTPACK_size) / 2) 41 68 42 69 -
trunk/XTIDE_Universal_BIOS/Inc/RomVars.inc
r143 r150 41 41 .wPort resb 2 ; IDE Base Port for Command Block (usual) Registers 42 42 .wPortCtrl resb 2 ; IDE Base Port for Control Block Registers 43 .b BusType resb 1 ; Bustype43 .bDevice resb 1 ; Device type 44 44 .bIRQ resb 1 ; Interrupt Request Number 45 45 .drvParamsMaster resb DRVPARAMS_size … … 47 47 endstruc 48 48 49 ; Bus types for IDEVARS.bBusType 50 BUS_TYPE_8_DUAL EQU (0<<1) ; XTIDE transfers with two 8-bit data ports 51 BUS_TYPE_16 EQU (1<<1) ; Normal 16-bit AT-IDE transfers 52 BUS_TYPE_32 EQU (2<<1) ; 32-bit VLB and PCI transfers 53 BUS_TYPE_8_SINGLE EQU (3<<1) ; 8-bit transfers with single 8-bit data port 49 ; Device types for IDEVARS.bDeviceType 50 DEVICE_8BIT_DUAL_PORT_XTIDE EQU (0<<1) 51 DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0 EQU (1<<1) 52 DEVICE_8BIT_SINGLE_PORT EQU (2<<1) 53 DEVICE_16BIT_ATA EQU (3<<1) 54 DEVICE_32BIT_ATA EQU (4<<1) 55 DEVICE_SERIAL_PORT EQU (5<<1) 54 56 55 57 -
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm
r135 r150 111 111 BootMenuPrint_HardDiskMenuitem: 112 112 call PrintDriveNumberAfterTranslationFromDL 113 call FindDPT_ForDriveNumber ; DS:DI to point DPT113 call RamVars_IsDriveHandledByThisBIOS 114 114 jnc SHORT .HardDiskMenuitemForForeignDrive 115 115 ; Fall to .HardDiskMenuitemForOurDrive … … 280 280 ALIGN JUMP_ALIGN 281 281 BootMenuPrint_HardDiskMenuitemInformation: 282 call RamVars_IsDriveHandledByThisBIOS 283 jnc SHORT .HardDiskMenuitemInfoForForeignDrive 282 284 call FindDPT_ForDriveNumber ; DS:DI to point DPT 283 jnc SHORT .HardDiskMenuitemInfoForForeignDrive284 285 ; Fall to .HardDiskMenuitemInfoForOurDrive 285 286 … … 303 304 304 305 ; Get and push L-CHS size 305 call HCapacity_GetSectorCountFromOurAH08h 306 mov [RAMVARS.wTimeoutCounter], dl ; Store drive number 307 call AH15h_GetSectorCountToDXAX 306 308 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat 307 309 308 310 ; Get and push total LBA size 309 mov dl, [ di+DPT.bDrvNum]311 mov dl, [RAMVARS.wTimeoutCounter] ; Restore drive number 310 312 call BootInfo_GetTotalSectorCount 311 313 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat … … 332 334 333 335 call DriveXlate_ToOrBack 334 call HCapacity_GetSectorCountFromForeignAH08h336 call AH15h_GetSectorCountFromForeignDriveToDXAX 335 337 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat 336 338 -
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
r127 r150 17 17 ; Nothing 18 18 ; Corrupts registers: 19 ; AX, BX, CX, DX, SI, DI , ES19 ; AX, BX, CX, DX, SI, DI 20 20 ;-------------------------------------------------------------------- 21 21 ALIGN JUMP_ALIGN … … 24 24 mov si, g_szCfgHeader 25 25 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF 26 call BootMenuPrintCfg_GetPointers 26 eMOVZX ax, BYTE [di+DPT.bIdevarsOffset] 27 xchg si, ax ; CS:SI now points to IDEVARS 27 28 ; Fall to PushAndFormatCfgString 28 29 29 30 30 ;-------------------------------------------------------------------- … … 32 32 ; Parameters: 33 33 ; DS:DI: Ptr to DPT 34 ; ES:BX: Ptr to BOOTNFO35 34 ; CS:SI: Ptr to IDEVARS 36 35 ; Returns: … … 48 47 ; Parameters: 49 48 ; DS:DI: Ptr to DPT 50 ; ES:BX: Ptr to BOOTNFO51 49 ; CS:SI: Ptr to IDEVARS 52 50 ; Returns: … … 56 54 ;-------------------------------------------------------------------- 57 55 PushAddressingMode: 58 xchg ax, bx 59 mov bx, MASK_DPT_ADDR ; Load addressing mode mask 60 and bl, [di+DPT.bFlags] ; Addressing mode now in BX 61 push WORD [cs:bx+.rgszAddressingModeString] 62 xchg bx, ax 63 jmp SHORT .NextPush 64 ALIGN WORD_ALIGN 65 .rgszAddressingModeString: 66 dw g_szLCHS 67 dw g_szPCHS 68 dw g_szLBA28 69 dw g_szLBA48 70 ALIGN JUMP_ALIGN 71 .NextPush: 56 call AccessDPT_GetAddressingModeForWordLookToBX 57 push WORD [cs:bx+rgszAddressingModeString] 72 58 73 59 ;-------------------------------------------------------------------- … … 75 61 ; Parameters: 76 62 ; DS:DI: Ptr to DPT 77 ; ES:BX: Ptr to BOOTNFO78 63 ; CS:SI: Ptr to IDEVARS 79 64 ; Returns: … … 83 68 ;-------------------------------------------------------------------- 84 69 PushBlockMode: 85 eMOVZX ax, BYTE [di+DPT.bSetBlock] 70 mov ax, 1 71 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 72 jz SHORT .PushBlockSizeFromAX 73 mov al, [di+DPT_ATA.bSetBlock] 74 .PushBlockSizeFromAX: 86 75 push ax 87 76 … … 90 79 ; Parameters: 91 80 ; DS:DI: Ptr to DPT 92 ; ES:BX: Ptr to BOOTNFO93 81 ; CS:SI: Ptr to IDEVARS 94 82 ; Returns: … … 99 87 PushBusType: 100 88 xchg ax, bx ; Store BX to AX 101 eMOVZX bx, BYTE [cs:si+IDEVARS.b BusType]102 mov bx, [cs:bx+ .rgwBusTypeValues] ; Char to BL, Int to BH89 eMOVZX bx, BYTE [cs:si+IDEVARS.bDevice] 90 mov bx, [cs:bx+rgwBusTypeValues] ; Char to BL, Int to BH 103 91 eMOVZX dx, bh 104 92 push bx ; Push character 105 push dx ; Push 8, 16 or 3293 push dx ; Push 1, 8, 16 or 32 106 94 xchg bx, ax ; Restore BX 107 jmp SHORT .NextPush108 ALIGN WORD_ALIGN109 .rgwBusTypeValues:110 db 'D', 8 ; BUS_TYPE_8_DUAL111 db ' ', 16 ; BUS_TYPE_16112 db ' ', 32 ; BUS_TYPE_32113 db 'S', 8 ; BUS_TYPE_8_SINGLE114 ALIGN JUMP_ALIGN115 .NextPush:116 95 117 96 ;-------------------------------------------------------------------- … … 119 98 ; Parameters: 120 99 ; DS:DI: Ptr to DPT 121 ; ES:BX: Ptr to BOOTNFO122 100 ; CS:SI: Ptr to IDEVARS 123 101 ; Returns: … … 152 130 ; Parameters: 153 131 ; DS:DI: Ptr to DPT 154 ; ES:BX: Ptr to BOOTNFO155 132 ; CS:SI: Ptr to IDEVARS 156 133 ; Returns: … … 160 137 ;-------------------------------------------------------------------- 161 138 PushResetStatus: 162 eMOVZX ax, BYTE [di+DPT.bReset] 139 mov ax, [di+DPT.wFlags] 140 and ax, MASK_DPT_RESET 163 141 push ax 164 142 … … 177 155 178 156 179 ;-------------------------------------------------------------------- 180 ; BootMenuPrintCfg_GetPointers 181 ; Parameters: 182 ; DS:DI: Ptr to DPT 183 ; Returns: 184 ; DS:DI: Ptr to DPT 185 ; ES:BX: Ptr to BOOTNFO 186 ; CS:SI: Ptr to IDEVARS 187 ; Corrupts registers: 188 ; AX, DL 189 ;-------------------------------------------------------------------- 190 ALIGN JUMP_ALIGN 191 BootMenuPrintCfg_GetPointers: 192 mov dl, [di+DPT.bDrvNum] ; Load Drive number to DL 193 call BootInfo_GetOffsetToBX ; ES:BX now points... 194 LOAD_BDA_SEGMENT_TO es, ax, ! ; ...to BOOTNFO 195 mov al, [di+DPT.bIdeOff] 196 xchg si, ax ; CS:SI now points to IDEVARS 197 ret 157 ALIGN WORD_ALIGN 158 rgszAddressingModeString: 159 dw g_szLCHS 160 dw g_szPCHS 161 dw g_szLBA28 162 dw g_szLBA48 163 164 rgwBusTypeValues: 165 db 'D', 8 ; DEVICE_8BIT_DUAL_PORT_XTIDE 166 db 'X', 8 ; DEVICE_XTIDE_WITH_REVERSED_A3_AND_A0 167 db 'S', 8 ; DEVICE_8BIT_SINGLE_PORT 168 db ' ', 16 ; DEVICE_16BIT_ATA 169 db ' ', 32 ; DEVICE_32BIT_ATA 170 db ' ', 1 ; DEVICE_SERIAL_PORT -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
r148 r150 22 22 Int13h_DiskFunctionsHandler: 23 23 sti ; Enable interrupts 24 SAVE_AND_GET_INTPACK_TO_SSBP 24 cld ; String instructions to increment pointers 25 SAVE_AND_GET_INTPACK_WITH_EXTRA_WORDS_TO_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK 25 26 26 27 call RamVars_GetSegmentToDS … … 46 47 ; DL: Translated drive number 47 48 ; DS: RAMVARS segment 48 ; SS:BP: Ptr to I NTPACK49 ; SS:BP: Ptr to IDEPACK 49 50 ; BX, DI: Corrupted on Int13h_DiskFunctionsHandler 50 51 ; Other: Function specific INT 13h parameters … … 58 59 Int13h_DirectCallToAnotherBios: 59 60 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler 60 mov bx, [bp+I NTPACK.bx]61 mov di, [bp+I NTPACK.di]62 mov ds, [bp+I NTPACK.ds]63 push WORD [bp+I NTPACK.flags]61 mov bx, [bp+IDEPACK.intpack+INTPACK.bx] 62 mov di, [bp+IDEPACK.intpack+INTPACK.di] 63 mov ds, [bp+IDEPACK.intpack+INTPACK.ds] 64 push WORD [bp+IDEPACK.intpack+INTPACK.flags] 64 65 popf 65 66 push bp 66 mov bp, [bp+I NTPACK.bp]67 mov bp, [bp+IDEPACK.intpack+INTPACK.bp] 67 68 int BIOS_DISK_INTERRUPT_13h ; Can safely do as much recursion as it wants 68 69 … … 70 71 pop bp ; Standard INT 13h functions never uses BP as return register 71 72 %ifdef USE_386 72 mov [bp+I NTPACK.gs], gs73 mov [bp+I NTPACK.fs], fs73 mov [bp+IDEPACK.intpack+INTPACK.gs], gs 74 mov [bp+IDEPACK.intpack+INTPACK.fs], fs 74 75 %endif 75 mov [bp+I NTPACK.es], es76 mov [bp+I NTPACK.ds], ds77 mov [bp+I NTPACK.di], di78 mov [bp+I NTPACK.si], si79 mov [bp+I NTPACK.bx], bx80 mov [bp+I NTPACK.dh], dh81 mov [bp+I NTPACK.cx], cx82 mov [bp+I NTPACK.ax], ax76 mov [bp+IDEPACK.intpack+INTPACK.es], es 77 mov [bp+IDEPACK.intpack+INTPACK.ds], ds 78 mov [bp+IDEPACK.intpack+INTPACK.di], di 79 mov [bp+IDEPACK.intpack+INTPACK.si], si 80 mov [bp+IDEPACK.intpack+INTPACK.bx], bx 81 mov [bp+IDEPACK.intpack+INTPACK.dh], dh 82 mov [bp+IDEPACK.intpack+INTPACK.cx], cx 83 mov [bp+IDEPACK.intpack+INTPACK.ax], ax 83 84 pushf 84 pop WORD [bp+I NTPACK.flags]85 pop WORD [bp+IDEPACK.intpack+INTPACK.flags] 85 86 call RamVars_GetSegmentToDS 86 87 cmp dl, [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv] 87 88 je SHORT .ExchangeInt13hHandlers 88 mov [bp+I NTPACK.dl], dl ; Something is returned in DL89 mov [bp+IDEPACK.intpack+INTPACK.dl], dl ; Something is returned in DL 89 90 ALIGN JUMP_ALIGN 90 91 .ExchangeInt13hHandlers: … … 98 99 ; Parameters: 99 100 ; AH: BIOS Error code 100 ; SS:BP: Ptr to I NTPACK101 ; SS:BP: Ptr to IDEPACK 101 102 ; Returns: 102 103 ; All registers are loaded from INTPACK … … 104 105 ALIGN JUMP_ALIGN 105 106 Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH: 106 call HError_SetErrorCodeToBdaAndToIntpackInSSBPfromAH107 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH 107 108 Int13h_ReturnFromHandlerWithoutStoringErrorCode: 108 or WORD [bp+I NTPACK.flags], FLG_FLAGS_IF ; Return with interrupts enabled109 or WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF ; Return with interrupts enabled 109 110 mov sp, bp ; Now we can exit anytime 110 RESTORE_INTPACK_ FROM_SSBP111 RESTORE_INTPACK_WITH_EXTRA_WORDS_FROM_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK 111 112 112 113 … … 146 147 LOAD_BDA_SEGMENT_TO es, di 147 148 mov di, [RAMVARS.fpOldI13h] 149 cli 148 150 xchg di, [es:BIOS_DISK_INTERRUPT_13h*4] 149 151 mov [RAMVARS.fpOldI13h], di … … 152 154 mov [RAMVARS.fpOldI13h+2], di 153 155 pop es 156 sti 157 ret 158 159 160 ;-------------------------------------------------------------------- 161 ; Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH 162 ; Int13h_SetErrorCodeToIntpackInSSBPfromAH 163 ; Parameters: 164 ; AH: BIOS error code (00h = no error) 165 ; SS:BP: Ptr to IDEPACK 166 ; Returns: 167 ; SS:BP: Ptr to IDEPACK with error condition set 168 ; Corrupts registers: 169 ; DS, DI 170 ;-------------------------------------------------------------------- 171 ALIGN JUMP_ALIGN 172 Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH: 173 ; Store error code to BDA 174 LOAD_BDA_SEGMENT_TO ds, di 175 mov [BDA.bHDLastSt], ah 176 177 ; Store error code to INTPACK 178 Int13h_SetErrorCodeToIntpackInSSBPfromAH: 179 mov [bp+IDEPACK.intpack+INTPACK.ah], ah 180 test ah, ah 181 jnz SHORT .SetCFtoIntpack 182 and BYTE [bp+IDEPACK.intpack+INTPACK.flags], ~FLG_FLAGS_CF 183 ret 184 .SetCFtoIntpack: 185 or BYTE [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_CF 154 186 ret 155 187 … … 224 256 ; dw Int13h_UnsupportedFunction ; 3Fh, 225 257 ; dw Int13h_UnsupportedFunction ; 40h, 226 ; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS) 227 ; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS) 228 ; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS) 229 ; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS) 230 ; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS) 231 ; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS) 232 ; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS) 233 ; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS) 234 ; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS) 258 ; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS)* 259 ; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS)* 260 ; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS)* 261 ; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS)* 262 ; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS)*** 263 ; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS)*** 264 ; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS)* 265 ; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS)* 266 ; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS)*** 235 267 ; dw Int13h_UnsupportedFunction ; 4Ah, Initiate Disk Emulation (Bootable CD-ROM) 236 268 ; dw Int13h_UnsupportedFunction ; 4Bh, Terminate Disk Emulation (Bootable CD-ROM) 237 269 ; dw Int13h_UnsupportedFunction ; 4Ch, Initiate Disk Emulation and Boot (Bootable CD-ROM) 238 270 ; dw Int13h_UnsupportedFunction ; 4Dh, Return Boot Catalog (Bootable CD-ROM) 239 ; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS) 271 ; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS)** 272 ; 273 ; * = Enhanced Drive Access Support (minimum required EBIOS functions) 274 ; ** = Enhanced Disk Drive (EDD) Support 275 ; *** = Drive Locking and Ejecting Support -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
r148 r150 13 13 ; If bit 7 is set all hard disks and floppy disks reset. 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Returns with INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEPACK 16 ; Returns with INTPACK: 17 17 ; AH: Int 13h return status (from drive requested in DL) 18 18 ; CF: 0 if succesfull, 1 if error … … 89 89 90 90 ;-------------------------------------------------------------------- 91 ; ResetHardDisksHandledByOurBIOS91 ; AH0h_ResetHardDisksHandledByOurBIOS 92 92 ; Parameters: 93 93 ; BL: Requested drive (DL when entering AH=00h) 94 94 ; DS: RAMVARS segment 95 ; SS:BP: Ptr to IDEPACK 95 96 ; Returns: 96 97 ; BH: Error code from requested drive (if available) 97 98 ; Corrupts registers: 98 ; AX, CX, DX, DI99 ; AX, CX, DX, SI, DI 99 100 ;-------------------------------------------------------------------- 100 101 ALIGN JUMP_ALIGN … … 103 104 test dh, dh 104 105 jz SHORT .AllDrivesReset ; Return if no drives 105 mov dl, [RAMVARS.bFirstDrv] ; Load number of first ourdrive106 mov dl, [RAMVARS.bFirstDrv] ; Load number of our first drive 106 107 add dh, dl ; DH = one past last drive to reset 107 108 ALIGN JUMP_ALIGN … … 132 133 .BackupErrorCodeFromMasterOrSlaveToBH: 133 134 call BackupErrorCodeFromTheRequestedDriveToBH 134 mov cx, [RAMVARS.wIdeBase]; Load base port for resetted drive135 135 call GetBasePortToCX ; Load base port for resetted drive 136 push cx 136 137 inc dx ; DL to next drive 137 call FindDPT_ForDriveNumber ; Get DPT to DS:DI, store port to RAMVARS138 jnc SHORT .NoMoreDrivesOrNoSlaveDrive139 cmp cx, [RAMVARS.wIdeBase]; Next drive is from same controller?138 call GetBasePortToCX 139 pop di 140 cmp cx, di ; Next drive is from same controller? 140 141 je SHORT BackupErrorCodeFromTheRequestedDriveToBH 141 142 .NoMoreDrivesOrNoSlaveDrive: 142 143 dec dx 144 ret 145 146 ;-------------------------------------------------------------------- 147 ; GetBasePortToCX 148 ; Parameters: 149 ; DL: Drive number 150 ; DS: RAMVARS segment 151 ; Returns: 152 ; CX: Base port address 153 ; CF: Set if valid drive number 154 ; Cleared if invalid drive number 155 ; Corrupts registers: 156 ; DI 157 ;-------------------------------------------------------------------- 158 ALIGN JUMP_ALIGN 159 GetBasePortToCX: 160 xchg cx, bx 161 xor bx, bx 162 call FindDPT_ForDriveNumber 163 jnc SHORT .DptNotFound 164 mov bl, [di+DPT.bIdevarsOffset] 165 mov bx, [cs:bx+IDEVARS.wPort] 166 .DptNotFound: 167 xchg bx, cx 143 168 ret 144 169 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH10h_HReady.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h return status 17 17 ; CF: 0 if succesfull, 1 if error … … 19 19 ALIGN JUMP_ALIGN 20 20 AH10h_HandlerForCheckDriveReady: 21 call HStatus_WaitRdyDefTime 22 xor ah, ah 21 %ifdef USE_186 22 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 23 jmp Device_SelectDrive 24 %else 25 call Device_SelectDrive 23 26 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 27 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 15 ; Returns with INTPACK: 16 16 ; AH: BIOS Error code 17 17 ; CF: 0 if succesfull, 1 if error … … 32 32 ; Parameters: 33 33 ; DS:DI: Ptr to DPT (in RAMVARS segment) 34 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 34 35 ; Returns: 35 36 ; AH: BIOS Error code -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; If succesfull: 17 17 ; AH: 3 (Hard disk accessible) … … 25 25 ALIGN JUMP_ALIGN 26 26 AH15h_HandlerForReadDiskDriveSize: 27 call HCapacity_GetSectorCountFromOurAH08h ; Sector count to DX:AX28 mov [bp+I NTPACK.cx], dx; HIWORD to CX29 mov [bp+I NTPACK.dx], ax; LOWORD to DX27 call AH15h_GetSectorCountToDXAX 28 mov [bp+IDEPACK.intpack+INTPACK.cx], dx ; HIWORD to CX 29 mov [bp+IDEPACK.intpack+INTPACK.dx], ax ; LOWORD to DX 30 30 31 31 xor ah, ah 32 call HError_SetErrorCodeToIntpackInSSBPfromAH ; Store success to BDA and CF33 mov BYTE [bp+I NTPACK.ah], 3; Type code = Hard disk32 call Int13h_SetErrorCodeToIntpackInSSBPfromAH ; Store success to BDA and CF 33 mov BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3 ; Type code = Hard disk 34 34 jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode 35 36 37 ;-------------------------------------------------------------------- 38 ; AH15h_GetSectorCountFromForeignDriveToDXAX: 39 ; AH15h_GetSectorCountToDXAX: 40 ; Parameters: 41 ; DL: Drive number 42 ; DS: RAMVARS segment 43 ; DS:DI: Ptr to DPT (AH15h_GetSectorCount only) 44 ; Returns: 45 ; DX:AX: Total sector count 46 ; BX: Zero 47 ; Corrupts registers: 48 ; CX 49 ;-------------------------------------------------------------------- 50 AH15h_GetSectorCountFromForeignDriveToDXAX: 51 mov ah, GET_DRIVE_PARAMETERS 52 call Int13h_CallPreviousInt13hHandler 53 jmp SHORT ConvertAH08hReturnValuesToSectorCount 54 55 ALIGN JUMP_ALIGN 56 AH15h_GetSectorCountToDXAX: 57 call AH8h_GetDriveParameters 58 ; Fall to ConvertAH08hReturnValuesToSectorCount 59 60 ConvertAH08hReturnValuesToSectorCount: 61 call HAddress_ExtractLCHSparametersFromOldInt13hAddress 62 xor ax, ax ; Zero AX 63 inc cx ; Max cylinder number to cylinder count 64 xchg al, bh ; AX=Max head number, BX=Sectors per track 65 inc ax ; AX=Head count 66 mul bx ; AX=Head count * Sectors per track 67 mul cx ; DX:AX = Total sector count 68 xor bx, bx ; Zero BX for 48-bit sector count (and clear CF) 69 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h floppy return status 17 17 ; CF: 0 if AH = RET_HD_SUCCESS, 1 otherwise (error) … … 21 21 LOAD_BDA_SEGMENT_TO ds, ax, ! 22 22 xchg ah, [BDA.bHDLastSt] ; Load and clear last error 23 call HError_SetErrorCodeToIntpackInSSBPfromAH23 call Int13h_SetErrorCodeToIntpackInSSBPfromAH 24 24 jmp Int13h_ReturnFromHandlerWithoutStoringErrorCode -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm
r148 r150 14 14 ; DL: Translated Drive number 15 15 ; DS:DI: Ptr to DPT (in RAMVARS segment) 16 ; SS:BP: Ptr to I NTPACK17 ; Parameters on INTPACK in SS:BP:16 ; SS:BP: Ptr to IDEPACK 17 ; Parameters on INTPACK: 18 18 ; AL: Feature Number (parameter to Features Register = subcommand) 19 ; (Parameter registers are undocumented, the re are specific for this BIOS):20 ; B H: Parameter to Sector Count Register (subcommand specific)21 ; B L: Parameter toSector Number Register (subcommand specific)22 ; CL: Parameter to L ow CylinderRegister (subcommand specific)23 ; CH: Parameter to High CylinderRegister (subcommand specific)24 ; Returns with INTPACK in SS:BP:19 ; (Parameter registers are undocumented, these are specific for this BIOS): 20 ; BL: Parameter to Sector Count Register (subcommand specific) 21 ; BH: Parameter to LBA Low / Sector Number Register (subcommand specific) 22 ; CL: Parameter to LBA Middle / Cylinder Low Register (subcommand specific) 23 ; CH: Parameter to LBA High / Cylinder High Register (subcommand specific) 24 ; Returns with INTPACK: 25 25 ; AH: Int 13h return status 26 26 ; CF: 0 if succesfull, 1 if error … … 28 28 ALIGN JUMP_ALIGN 29 29 AH23h_HandlerForSetControllerFeatures: 30 xchg si, ax ; SI = Feature Number 31 mov dx, [bp+IDEPACK.intpack+INTPACK.bx] 30 32 %ifndef USE_186 31 33 call AH23h_SetControllerFeatures … … 40 42 ; AH23h_SetControllerFeatures 41 43 ; Parameters: 42 ; AL: Feature Number (parameter to Features Register = subcommand)43 ; BH: Parameter to Sector CountRegister (subcommand specific)44 ; BL: Parameter to Sector NumberRegister (subcommand specific)45 ; C L: Parameter to Low CylinderRegister (subcommand specific)46 ; CH: Parameter to High Cylinder Register (subcommand specific)44 ; DL: Parameter to Sector Count Register (subcommand specific) 45 ; DH: Parameter to LBA Low / Sector Number Register (subcommand specific) 46 ; CL: Parameter to LBA Middle / Cylinder Low Register (subcommand specific) 47 ; CH: Parameter to LBA High / Cylinder High Register (subcommand specific) 48 ; SI: Feature Number (parameter to Features Register = subcommand) 47 49 ; DS:DI: Ptr to DPT (in RAMVARS segment) 50 ; SS:BP: Ptr to IDEPACK 48 51 ; Returns: 49 52 ; AH: Int 13h return status 50 53 ; CF: 0 if succesfull, 1 if error 51 54 ; Corrupts registers: 52 ; A X, BX, CX, DX, SI55 ; AL, BX, CX, DX 53 56 ;-------------------------------------------------------------------- 54 57 ALIGN JUMP_ALIGN 55 58 AH23h_SetControllerFeatures: 56 ; Backup AL and BH to SI 57 mov ah, bh 58 xchg si, ax 59 60 ; Select Master or Slave and wait until ready 61 call HDrvSel_SelectDriveAndDisableIRQ 62 jc SHORT .ReturnWithErrorCodeInAH 63 64 ; Output Feature Number 65 mov ax, si ; Feature number to AL 66 mov dx, [RAMVARS.wIdeBase] ; Load base port address 67 inc dx ; REGW_IDE_FEAT 68 out dx, al 69 70 ; Output parameters to Sector Number Register and Cylinder Registers 71 xor bh, bh ; Zero head number 72 dec dx ; Back to base port address 73 call HCommand_OutputTranslatedLCHSaddress 74 75 ; Output parameter to Sector Count Register and command 76 xchg ax, si ; Sector Count Reg param to AH 77 mov al, ah ; Sector Count Reg param to AL 78 mov ah, HCMD_SET_FEAT ; Load Set Features command to AH 79 call HCommand_OutputSectorCountAndCommand 80 81 jmp HStatus_WaitBsyDefTime ; Wait until drive ready 82 .ReturnWithErrorCodeInAH: 83 ret 59 mov al, COMMAND_SET_FEATURES 60 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY) 61 jmp Idepack_StoreNonExtParametersAndIssueCommandFromAL -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEPACK 16 ; Parameters on INTPACK: 17 17 ; AL: Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128) 18 ; Returns with INTPACK in SS:BP:18 ; Returns with INTPACK: 19 19 ; AH: Int 13h return status 20 20 ; CF: 0 if succesfull, 1 if error … … 22 22 ALIGN JUMP_ALIGN 23 23 AH24h_HandlerForSetMultipleBlocks: 24 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 25 jnz SHORT .TryToSetBlockMode 26 stc 27 mov ah, RET_HD_INVALID 28 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 29 30 ALIGN JUMP_ALIGN 31 .TryToSetBlockMode: 24 32 %ifndef USE_186 25 33 call AH24h_SetBlockSize … … 32 40 33 41 ;-------------------------------------------------------------------- 34 ; Sets block size for block mode transfers.35 ;36 42 ; AH24h_SetBlockSize 37 43 ; Parameters: 38 44 ; AL: Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128) 39 45 ; DS:DI: Ptr to DPT (in RAMVARS segment) 46 ; SS:BP: Ptr to IDEPACK 40 47 ; Returns: 41 48 ; AH: Int 13h return status … … 46 53 ALIGN JUMP_ALIGN 47 54 AH24h_SetBlockSize: 48 ; Select Master or Slave and wait until ready 49 mov bl, al ; Backup block size 50 call HDrvSel_SelectDriveAndDisableIRQ ; Select drive and wait until ready 51 jc SHORT .ReturnWithErrorCodeInAH ; Return if error 52 53 ; Output block size and command 54 mov al, bl ; Restore block size to AL 55 mov ah, HCMD_SET_MUL ; Load command to AH 56 mov dx, [RAMVARS.wIdeBase] ; Load base port address 57 add dx, BYTE REG_IDE_CNT 58 call HCommand_OutputSectorCountAndCommand 59 call HStatus_WaitBsyDefTime ; Wait until drive not busy 55 MIN_U al, MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS 56 push ax 57 xchg dx, ax ; DL = Block size (Sector Count Register) 58 mov al, COMMAND_SET_MULTIPLE_MODE 59 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY) 60 call Idepack_StoreNonExtParametersAndIssueCommandFromAL 61 pop bx 60 62 jc SHORT .DisableBlockMode 61 63 62 64 ; Store new block size to DPT and return 63 mov [di+DPT.bSetBlock], bl ; Store new block size 64 xor ah, ah ; Zero AH and CF since success 65 mov [di+DPT_ATA.bSetBlock], bl ; Store new block size 65 66 ret 66 67 .DisableBlockMode: 67 mov BYTE [di+DPT.bSetBlock], 1 ; Disable block mode 68 .ReturnWithErrorCodeInAH: 68 mov BYTE [di+DPT_ATA.bSetBlock], 1 ; Disable block mode 69 69 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEPACK 16 ; Parameters on INTPACK: 17 17 ; ES:BX: Ptr to buffer to receive 512-byte drive information 18 ; Returns with INTPACK in SS:BP:18 ; Returns with INTPACK: 19 19 ; AH: Int 13h return status 20 20 ; CF: 0 if succesfull, 1 if error … … 22 22 ALIGN JUMP_ALIGN 23 23 AH25h_HandlerForGetDriveInformation: 24 ; Wait until previously selected drive is ready 25 call HDrvSel_SelectDriveAndDisableIRQ 26 jc SHORT .ReturnWithErrorCodeInAH ; Return if error 24 push bp 27 25 28 ; Get drive information 29 mov bx, [bp+INTPACK.bx] 30 call HPIO_NormalizeDataPointer 31 push bx 32 mov dx, [RAMVARS.wIdeBase] ; Load base port address 33 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; Load offset to IDEVARS 34 mov bl, [cs:bx+IDEVARS.bBusType]; Load bus type to BL 35 mov bh, [di+DPT.bDrvSel] ; Load drive sel byte to BH 36 pop di ; Pop buffer offset to DI 37 call AH25h_GetDriveInfo ; Get drive information 38 .ReturnWithErrorCodeInAH: 26 mov si, [bp+IDEPACK.intpack+INTPACK.bx] 27 call AccessDPT_GetDriveSelectByteToAL 28 mov bh, al 29 eMOVZX ax, BYTE [di+DPT.bIdevarsOffset] 30 xchg bp, ax 31 call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH 32 33 pop bp 39 34 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 40 41 42 ;--------------------------------------------------------------------43 ; Gets drive information using Identify Device command.44 ;45 ; AH25h_GetDriveInfo46 ; Parameters:47 ; BH: Drive Select byte for Drive and Head Select Register48 ; BL: Bus type49 ; DX: IDE Controller base port address50 ; DS: Segment to RAMVARS51 ; ES:DI: Ptr to buffer to receive 512 byte drive information52 ; Returns:53 ; AH: Int 13h return status (will be stored to BDA)54 ; CF: 0 if succesfull, 1 if error55 ; Corrupts registers:56 ; AL, CX57 ;--------------------------------------------------------------------58 ALIGN JUMP_ALIGN59 AH25h_GetDriveInfo:60 push di61 push dx62 push bx63 64 ; Select Master or Slave drive.65 ; DO NOT WAIT UNTIL CURRENTLY SELECTED IS READY!66 ; It makes slave drive detection impossible if master is not present.67 mov [RAMVARS.wIdeBase], dx ; Store IDE Base port to RAMVARS68 add dx, BYTE REG_IDE_DRVHD ; DX to Drive and Head Sel Register69 mov al, bh ; Drive Select byte to AL70 out dx, al ; Select Master or Slave drive71 sub dx, BYTE REG_IDE_DRVHD ; Back to IDE Base port72 73 ; Wait until ready to accept commands74 xor bh, bh ; BX now contains bus type75 mov cl, B_TIMEOUT_DRVINFO ; Load short timeout76 cmp [RAMVARS.bDrvCnt], bh ; Detecting first drive?77 eCMOVE cl, B_TIMEOUT_RESET ; If so, load long timeout78 call HStatus_WaitRdy ; Wait until ready to accept commands79 jc SHORT .ReturnWithErrorCodeInAH80 81 ; Output command82 mov al, HCMD_ID_DEV ; Load Identify Device command to AL83 out dx, al ; Output command84 call HStatus_WaitDrqDefTime ; Wait until ready to transfer (no IRQ!)85 jc SHORT .ReturnWithErrorCodeInAH86 87 ; Transfer data88 sub dx, BYTE REGR_IDE_ST ; DX to IDE Data Reg89 mov cx, 256 ; Transfer 256 words (single sector)90 cld ; INSW to increment DI91 call [cs:bx+g_rgfnPioRead] ; Read ID sector92 call HStatus_WaitRdyDefTime ; Wait until drive ready93 94 .ReturnWithErrorCodeInAH:95 pop bx96 pop dx97 pop di98 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:17 ; AL: Number of sectors to read (1...255 )15 ; SS:BP: Ptr to IDEPACK 16 ; Parameters on INTPACK: 17 ; AL: Number of sectors to read (1...255, 0=256) 18 18 ; CH: Cylinder number, bits 7...0 19 19 ; CL: Bits 7...6: Cylinder number bits 9 and 8 … … 21 21 ; DH: Starting head number (0...255) 22 22 ; ES:BX: Pointer to buffer recieving data 23 ; Returns with INTPACK in SS:BP:23 ; Returns with INTPACK: 24 24 ; AH: Int 13h/40h floppy return status 25 25 ; AL: Burst error length if AH returns 11h, undefined otherwise … … 28 28 ALIGN JUMP_ALIGN 29 29 AH2h_HandlerForReadDiskSectors: 30 test al, al ; Invalid sector count? 31 jz SHORT AH2h_ZeroCntErr ; If so, return with error 32 33 ; Select sector or block mode command 34 mov ah, HCMD_READ_SECT ; Load sector mode command 35 cmp BYTE [di+DPT.bSetBlock], 1 ; Block mode enabled? 36 eCMOVA ah, HCMD_READ_MUL ; Load block mode command 37 38 ; Transfer data 39 call HCommand_OutputCountAndLCHSandCommand 40 jc SHORT .ReturnWithErrorCodeInAH 41 mov bx, [bp+INTPACK.bx] 42 call HPIO_ReadBlock ; Read data from IDE-controller 43 .ReturnWithErrorCodeInAH: 30 mov ah, COMMAND_READ_SECTORS ; Load sector mode command 31 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 32 eCMOVNZ ah, COMMAND_READ_MULTIPLE ; Load block mode command 33 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 34 mov si, [bp+IDEPACK.intpack+INTPACK.bx] 35 %ifdef USE_186 36 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 37 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 38 %else 39 call Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 44 40 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 45 46 ; Invalid sector count (also for AH=3h and AH=4h) 47 AH2h_ZeroCntErr: 48 mov ah, RET_HD_INVALID ; Invalid value passed 49 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 41 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 16 ; Parameters on INTPACK: 17 17 ; AL: Number of sectors to write 18 18 ; CH: Cylinder number, bits 7...0 … … 21 21 ; DH: Starting head number (0...255) 22 22 ; ES:BX: Pointer to source data 23 ; Returns with INTPACK in SS:BP:23 ; Returns with INTPACK: 24 24 ; AH: Int 13h/40h floppy return status 25 25 ; CF: 0 if successfull, 1 if error … … 27 27 ALIGN JUMP_ALIGN 28 28 AH3h_HandlerForWriteDiskSectors: 29 test al, al ; Invalid sector count? 30 jz SHORT AH2h_ZeroCntErr ; If so, return with error 31 32 ; Select sector or block mode command 33 mov ah, HCMD_WRITE_SECT ; Load sector mode command 34 cmp BYTE [di+DPT.bSetBlock], 1 ; Block mode enabled? 35 eCMOVA ah, HCMD_WRITE_MUL ; Load block mode command 36 37 ; Transfer data 38 call HCommand_OutputCountAndLCHSandCommand 39 jc SHORT .ReturnWithErrorCodeInAH 40 mov bx, [bp+INTPACK.bx] 41 call HPIO_WriteBlock ; Write data to IDE-controller 42 .ReturnWithErrorCodeInAH: 29 ; Prepare parameters 30 mov ah, COMMAND_WRITE_SECTORS ; Load sector mode command 31 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 32 eCMOVNZ ah, COMMAND_WRITE_MULTIPLE ; Load block mode command 33 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ) 34 mov si, [bp+IDEPACK.intpack+INTPACK.bx] 35 %ifdef USE_186 36 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 37 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 38 %else 39 call Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 43 40 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 41 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm
r148 r150 26 26 ALIGN JUMP_ALIGN 27 27 AH4h_HandlerForVerifyDiskSectors: 28 test al, al ; Invalid sector count? 29 jz SHORT AH2h_ZeroCntErr ; If so, return with error 30 31 mov ah, HCMD_VERIFY_SECT ; Load command to AH 32 call HCommand_OutputCountAndLCHSandCommand 33 jc SHORT .ReturnWithErrorCodeInAH 34 mov bx, di ; DS:BX now points to DPT 35 call HStatus_WaitIrqOrRdy ; Wait for IRQ or RDY 36 .ReturnWithErrorCodeInAH: 28 mov ah, COMMAND_WRITE_SECTORS 29 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 30 %ifdef USE_186 31 push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 32 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 33 %else 34 call Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH 37 35 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH 36 %endif -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; CH: Maximum cylinder number, bits 7...0 17 17 ; CL: Bits 7...6: Cylinder number bits 9...8 … … 34 34 call RamVars_GetCountOfKnownDrivesToDL 35 35 .ReturnAfterStoringValuesToIntpack: 36 mov [bp+I NTPACK.cx], cx37 mov [bp+I NTPACK.dx], dx36 mov [bp+IDEPACK.intpack+INTPACK.cx], cx 37 mov [bp+IDEPACK.intpack+INTPACK.dx], dx 38 38 xor ah, ah 39 39 .ReturnErrorFromPreviousInt13hHandler: -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h return status 17 17 ; CF: 0 if succesfull, 1 if error … … 34 34 ; Parameters: 35 35 ; DS:DI: Ptr to DPT (in RAMVARS segment) 36 ; SS:BP: Ptr to IDEPACK 36 37 ; Returns: 37 38 ; AH: Int 13h return status … … 45 46 46 47 ; Try to select drive and wait until ready 47 or BYTE [di+DPT.bReset], MASK_RESET_ALL ; Everything uninitialized 48 call HDrvSel_SelectDriveAndDisableIRQ 48 or WORD [di+DPT.wFlags], MASK_DPT_RESET ; Everything uninitialized 49 call AccessDPT_GetDriveSelectByteToAL 50 mov [bp+IDEPACK.bDrvAndHead], al 51 call Device_SelectDrive 49 52 jc SHORT .ReturnNotSuccessfull 50 and BYTE [di+DPT.bReset], ~FLG_RESET_nDRDY; Clear since success53 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nDRDY ; Clear since success 51 54 52 55 ; Initialize CHS parameters if LBA is not used 53 call AH9h_InitializeDeviceParameters56 call InitializeDeviceParameters 54 57 jc SHORT .RecalibrateDrive 55 and BYTE [di+DPT.bReset], ~FLG_RESET_nINITPRMS58 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nINITPRMS 56 59 57 60 ; Recalibrate drive by seeking to cylinder 0 58 ALIGN JUMP_ALIGN59 61 .RecalibrateDrive: 60 62 call AH11h_RecalibrateDrive 61 63 jc SHORT .InitializeBlockMode 62 and BYTE [di+DPT.bReset], ~FLG_RESET_nRECALIBRATE64 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nRECALIBRATE 63 65 64 66 ; Initialize block mode transfers 65 67 .InitializeBlockMode: 66 call AH9h_InitializeBlockMode68 call InitializeBlockMode 67 69 jc SHORT .ReturnNotSuccessfull 68 and BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK ; Keeps CF clear70 and WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nSETBLOCK ; Keeps CF clear 69 71 70 72 .ReturnNotSuccessfull: … … 74 76 75 77 ;-------------------------------------------------------------------- 76 ; Sends Initialize Device Parameters command to IDE Hard Disk. 77 ; Initialization is used to initialize logical CHS parameters. Drives 78 ; may not support all CHS values. 79 ; This command is only supported by drives that supports CHS addressing. 80 ; 81 ; AH9h_InitializeDeviceParameters 78 ; InitializeDeviceParameters 82 79 ; Parameters: 83 ; DS:DI: Ptr to DPT 84 ; Returns: 85 ; AH: BIOS Error code 86 ; CF: Cleared if succesfull 87 ; Set if any error 88 ; Corrupts registers: 89 ; AL, BX, CX 90 ;-------------------------------------------------------------------- 91 ALIGN JUMP_ALIGN 92 AH9h_InitializeDeviceParameters: 93 ; No need to initialize CHS parameters if LBA mode enabled 94 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA ; Clears CF 95 jnz SHORT .Return 96 97 push dx 98 mov bh, [di+DPT.bPHeads] 99 dec bh ; Max head number 100 mov dx, [RAMVARS.wIdeBase] 101 call HCommand_OutputTranslatedLCHSaddress 102 mov ah, HCMD_INIT_DEV 103 mov al, [di+DPT.bPSect] ; Sectors per track 104 call HCommand_OutputSectorCountAndCommand 105 call HStatus_WaitBsyDefTime ; Wait until drive ready (DRDY won't be set!) 106 pop dx 107 .Return: 108 ret 109 110 111 ;-------------------------------------------------------------------- 112 ; Initializes block mode transfers. 113 ; 114 ; AH9h_InitializeBlockMode 115 ; Parameters: 116 ; DS:DI: Ptr to DPT 80 ; DS:DI: Ptr to DPT (in RAMVARS segment) 81 ; SS:BP: Ptr to IDEPACK 117 82 ; Returns: 118 83 ; AH: BIOS Error code … … 123 88 ;-------------------------------------------------------------------- 124 89 ALIGN JUMP_ALIGN 125 AH9h_InitializeBlockMode: 126 mov ax, FLG_DRVPARAMS_BLOCKMODE 127 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 128 jz SHORT .Return ; Block mode disabled (CF cleared) 129 eMOVZX ax, BYTE [di+DPT.bMaxBlock] ; Load max block size, zero AH 130 test al, al ; Block mode supported? (clears CF) 131 jz SHORT .Return ; If not, return 90 InitializeDeviceParameters: 91 ; No need to initialize CHS parameters if LBA mode enabled 92 test BYTE [di+DPT.wFlags], FLG_DRVNHEAD_LBA ; Clear CF 93 jnz SHORT ReturnSuccessSinceInitializationNotNeeded 94 95 ; Initialize Locigal Sectors per Track and Max Head number 96 mov ah, [di+DPT.bPchsHeads] 97 dec ah ; Max Head number 98 mov dl, [di+DPT.bPchsSectors] ; Sectors per Track 99 mov al, COMMAND_INITIALIZE_DEVICE_PARAMETERS 100 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY) 101 jmp Idepack_StoreNonExtParametersAndIssueCommandFromAL 102 103 104 ;-------------------------------------------------------------------- 105 ; InitializeBlockMode 106 ; Parameters: 107 ; DS:DI: Ptr to DPT (in RAMVARS segment) 108 ; Returns: 109 ; AH: BIOS Error code 110 ; CF: Cleared if succesfull 111 ; Set if any error 112 ; Corrupts registers: 113 ; AL, BX, CX, DX 114 ;-------------------------------------------------------------------- 115 ALIGN JUMP_ALIGN 116 InitializeBlockMode: 117 test WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED ; Clear CF 118 jz SHORT ReturnSuccessSinceInitializationNotNeeded 119 120 mov al, [di+DPT_ATA.bMaxBlock] ; Load max block size, zero AH 132 121 jmp AH24h_SetBlockSize 133 .Return:122 ReturnSuccessSinceInitializationNotNeeded: 134 123 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm
r148 r150 13 13 ; DL: Translated Drive number 14 14 ; DS:DI: Ptr to DPT (in RAMVARS segment) 15 ; SS:BP: Ptr to I NTPACK16 ; Parameters on INTPACK in SS:BP:15 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 16 ; Parameters on INTPACK: 17 17 ; CH: Cylinder number, bits 7...0 18 18 ; CL: Bits 7...6: Cylinder number bits 9 and 8 19 19 ; Bits 5...0: Starting sector number (1...63) 20 20 ; DH: Starting head number (0...255) 21 ; Returns with INTPACK in SS:BP:21 ; Returns with INTPACK: 22 22 ; AH: BIOS Error code 23 23 ; CF: 0 if succesfull, 1 if error … … 33 33 %endif 34 34 35 36 35 ;-------------------------------------------------------------------- 37 36 ; AHCh_SeekToCylinder … … 42 41 ; DH: Starting head number (0...255) 43 42 ; DS:DI: Ptr to DPT (in RAMVARS segment) 43 ; SS:BP: Ptr to IDEREGS_AND_INTPACK 44 44 ; Returns: 45 45 ; AH: BIOS Error code … … 49 49 ;-------------------------------------------------------------------- 50 50 AHCh_SeekToCylinder: 51 mov ax, HCMD_SEEK<<8 ; Load cmd to AH, AL=zero sector cnt 52 call HCommand_OutputCountAndLCHSandCommand 53 jc SHORT .ReturnWithErrorCodeInAH 54 mov bx, di ; DS:BX now points to DPT 55 jmp HStatus_WaitIrqOrRdy ; Wait for IRQ or RDY 56 .ReturnWithErrorCodeInAH: 57 ret 51 mov ah, COMMAND_SEEK 52 mov bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY) 53 jmp Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
r148 r150 12 12 ; DL: Translated Drive number 13 13 ; DS:DI: Ptr to DPT (in RAMVARS segment) 14 ; SS:BP: Ptr to I NTPACK15 ; Returns with INTPACK in SS:BP:14 ; SS:BP: Ptr to IDEPACK 15 ; Returns with INTPACK: 16 16 ; AH: Int 13h return status 17 17 ; CF: 0 if succesfull, 1 if error … … 35 35 ; DL: Drive number 36 36 ; DS: RAMVARS segment 37 ; SS:BP: Ptr to IDEPACK 37 38 ; Returns: 38 39 ; AH: Int 13h return status 39 40 ; CF: 0 if succesfull, 1 if error 40 41 ; Corrupts registers: 41 ; AL, CX, DI42 ; AL, CX, SI, DI 42 43 ;-------------------------------------------------------------------- 43 44 ALIGN JUMP_ALIGN … … 48 49 call FindDPT_ForDriveNumber ; DS:DI now points to DPT 49 50 call Interrupts_UnmaskInterruptControllerForDriveInDSDI 50 call AHDh_ResetMasterAndSlave51 call Device_ResetMasterAndSlaveController 51 52 ;jc SHORT .ReturnError ; CF would be set if slave drive present without master 52 53 ; (error register has special values after reset) 53 54 54 55 ; Initialize Master and Slave drives 55 mov dx, [RAMVARS.wIdeBase] ; Load base port address 56 call AHDh_InitializeMasterAndSlave 56 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] 57 mov dx, [cs:bx+IDEVARS.wPort] 58 call InitializeMasterAndSlaveDriveFromPortInDX 57 59 58 60 pop bx … … 62 64 63 65 ;-------------------------------------------------------------------- 64 ; Resets Master and Slave drives at wanted port. 65 ; Both IDE drives will be reset. It is not possible to reset 66 ; Master or Slave only. 67 ; 68 ; AHDh_ResetMasterAndSlave 69 ; Parameters: 70 ; DS:DI: Ptr to DPT for Master or Slave drive 71 ; Returns: 72 ; CF: 0 if reset succesfull 73 ; 1 if any error 74 ; Corrupts registers: 75 ; AX, BX, CX, DX 76 ;-------------------------------------------------------------------- 77 ALIGN JUMP_ALIGN 78 AHDh_ResetMasterAndSlave: 79 ; Reset controller 80 ; HSR0: Set_SRST 81 mov al, [di+DPT.bDrvCtrl] ; Load value for ACR 82 or al, FLG_IDE_CTRL_SRST ; Set Reset bit 83 call HDrvSel_OutputDeviceControlByte 84 mov ax, 5 ; Delay at least 5us 85 call HTimer_DelayMicrosecondsFromAX 86 87 ; HSR1: Clear_wait 88 mov al, [di+DPT.bDrvCtrl] ; Load value for ACR 89 out dx, al ; End Reset 90 mov ax, 2000 ; Delay at least 2ms 91 call HTimer_DelayMicrosecondsFromAX 92 93 ; HSR2: Check_status 94 mov cl, B_TIMEOUT_RESET ; Reset timeout delay 95 jmp HStatus_WaitBsy 96 97 98 ;-------------------------------------------------------------------- 99 ; Initializes Master and Slave drive. 100 ; 101 ; AHDh_InitializeMasterAndSlave 66 ; InitializeMasterAndSlaveDriveFromPortInDX 102 67 ; Parameters: 103 68 ; DX: IDE Base Port address 69 ; SS:BP: Ptr to IDEPACK 104 70 ; Returns: 105 71 ; AH: Error code … … 107 73 ; 1 if any error 108 74 ; Corrupts registers: 109 ; AL, BX, CX, DX, DI75 ; AL, BX, CX, DX, SI, DI 110 76 ;-------------------------------------------------------------------- 111 77 ALIGN JUMP_ALIGN 112 AHDh_InitializeMasterAndSlave:78 InitializeMasterAndSlaveDriveFromPortInDX: 113 79 push dx ; Store base port address 114 80 xor cx, cx ; Assume no errors 115 call FindDPT_ ForIdeMasterAtPort81 call FindDPT_ToDSDIForIdeMasterAtPortDX 116 82 jnc SHORT .InitializeSlave ; Master drive not present 117 83 call AH9h_InitializeDriveForUse … … 119 85 .InitializeSlave: 120 86 pop dx ; Restore base port address 121 call FindDPT_ ForIdeSlaveAtPort87 call FindDPT_ToDSDIForIdeSlaveAtPortDX 122 88 jnc SHORT .CombineErrors ; Slave drive not present 123 89 call AH9h_InitializeDriveForUse -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HAddress.asm
r3 r150 1 ; File name : HAddress.asm 2 ; Project name : IDE BIOS 3 ; Created date : 11.3.2010 4 ; Last update : 4.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for address translations. 7 3 … … 9 5 SECTION .text 10 6 7 ; Jump table for conversion functions 8 ALIGN WORD_ALIGN 9 g_rgfnAddressTranslation: 10 dw DoNotConvertLCHS ; 0, ADDR_DPT_LCHS 11 dw ConvertLCHStoPCHS ; 1, ADDR_DPT_PCHS 12 dw ConvertLCHStoLBARegisterValues ; 2, ADDR_DPT_LBA28 13 dw ConvertLCHStoLBARegisterValues ; 3, ADDR_DPT_LBA48 14 15 11 16 ;-------------------------------------------------------------------- 12 ; Outputs sector count, L-CHS address and command to IDE registers. 13 ; This function does not wait until command has been completed. 14 ; 15 ; HAddress_ConvertParamsFromBiosLCHStoIDE 17 ; HAddress_OldInt13hAddressToIdeAddress 16 18 ; Parameters: 17 19 ; CH: Cylinder number, bits 7...0 … … 28 30 ; AX, DX 29 31 ;-------------------------------------------------------------------- 30 ALIGN WORD_ALIGN31 g_rgfnAddressTranslation:32 dw HAddress_DoNotConvertLCHS ; 0, ADDR_DPT_LCHS33 dw HAddress_ConvertLCHStoPCHS ; 1, ADDR_DPT_PCHS34 dw HAddress_ConvertLCHStoLBARegisterValues ; 2, ADDR_DPT_LBA2835 dw HAddress_ConvertLCHStoLBARegisterValues ; 3, ADDR_DPT_LBA4836 37 32 ALIGN JUMP_ALIGN 38 HAddress_ConvertParamsFromBiosLCHStoIDE: 39 mov bl, [di+DPT.bFlags] 40 and bx, BYTE MASK_DPT_ADDR ; Addressing mode to BX 33 HAddress_OldInt13hAddressToIdeAddress: 34 call AccessDPT_GetAddressingModeForWordLookToBX 41 35 push WORD [cs:bx+g_rgfnAddressTranslation] ; Push return address 42 ; Fall to HAddress_ExtractLCHS FromBiosParams36 ; Fall to HAddress_ExtractLCHSparametersFromOldInt13hAddress 43 37 44 38 ;--------------------------------------------------------------------- 45 ; Extracts L-CHS parameters from BIOS function parameters. 46 ; 47 ; HAddress_ExtractLCHSFromBiosParams: 39 ; HAddress_ExtractLCHSparametersFromOldInt13hAddress 48 40 ; Parameters: 49 41 ; CH: Cylinder number, bits 7...0 … … 58 50 ; Nothing 59 51 ;-------------------------------------------------------------------- 60 ALIGN JUMP_ALIGN 61 HAddress_ExtractLCHSFromBiosParams: 52 HAddress_ExtractLCHSparametersFromOldInt13hAddress: 62 53 mov bl, cl ; Copy sector number... 63 54 and bl, 3Fh ; ...and limit to 1...63 … … 70 61 71 62 ;--------------------------------------------------------------------- 72 ; Converts BIOSLCHS parameters to IDE P-CHS parameters.63 ; Converts LCHS parameters to IDE P-CHS parameters. 73 64 ; PCylinder = (LCylinder << n) + (LHead / PHeadCount) 74 65 ; PHead = LHead % PHeadCount … … 89 80 ;-------------------------------------------------------------------- 90 81 ALIGN JUMP_ALIGN 91 HAddress_ConvertLCHStoPCHS:82 ConvertLCHStoPCHS: 92 83 ; LHead / PHeadCount and LHead % PHeadCount 93 84 eMOVZX ax, bh ; Copy L-CHS Head number to AX 94 div BYTE [di+DPT.bP Heads]; AL = LHead / PHeadCount, AH = LHead % PHeadCount85 div BYTE [di+DPT.bPchsHeads]; AL = LHead / PHeadCount, AH = LHead % PHeadCount 95 86 mov bh, ah ; Copy P-CHS Head number to BH 96 87 xor ah, ah ; AX = LHead / PHeadCount … … 98 89 ; (LCylinder << n) + (LHead / PHeadCount) 99 90 mov dx, cx ; Copy L-CHS Cylinder number to DX 100 mov cl, [di+DPT.bShLtoP] ; Load shift count 91 mov cl, [di+DPT.wFlags] ; Load shift count 92 and cl, MASK_DPT_CHS_SHIFT_COUNT 101 93 shl dx, cl ; DX = LCylinder << n 102 94 add ax, dx ; AX = P-CHS Cylinder number 103 95 mov cx, ax ; Copy P-CHS Cylinder number to CX 104 ALIGN JUMP_ALIGN 105 HAddress_DoNotConvertLCHS: 96 DoNotConvertLCHS: 106 97 ret 107 98 … … 109 100 ;--------------------------------------------------------------------- 110 101 ; Converts LCHS parameters to 28-bit LBA address. 102 ; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit. 103 ; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1 104 ; 111 105 ; Returned address is in same registers that 112 106 ; HAddress_DoNotConvertLCHS and HAddress_ConvertLCHStoPCHS returns. 113 107 ; 114 ; HAddress_ConvertLCHStoLBARegisterValues:108 ; ConvertLCHStoLBARegisterValues: 115 109 ; Parameters: 116 110 ; BL: Sector number (1...63) … … 127 121 ;-------------------------------------------------------------------- 128 122 ALIGN JUMP_ALIGN 129 HAddress_ConvertLCHStoLBARegisterValues: 130 call HAddress_ConvertLCHStoLBA28 131 mov bl, al ; Sector Number Register (LBA 7...0) 132 mov cl, ah ; Low Cylinder Register (LBA 15...8) 133 mov ch, dl ; High Cylinder Register (LBA 23...16) 134 mov bh, dh ; Drive and Head Register (LBA 27...24) 135 ret 136 137 ;--------------------------------------------------------------------- 138 ; Converts LCHS parameters to 28-bit LBA address. 139 ; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit. 140 ; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1 141 ; 142 ; HAddress_ConvertLCHStoLBA28: 143 ; Parameters: 144 ; BL: Sector number (1...63) 145 ; BH: Head number (0...255) 146 ; CX: Cylinder number (0...1023) 147 ; DS:DI: Ptr to Disk Parameter Table 148 ; Returns: 149 ; DX:AX: 28-bit LBA address (DH is always zero) 150 ; Corrupts registers: 151 ; BX, CX 152 ;-------------------------------------------------------------------- 153 ALIGN JUMP_ALIGN 154 HAddress_ConvertLCHStoLBA28: 123 ConvertLCHStoLBARegisterValues: 155 124 ; cylToSeek*headsPerCyl (18-bit result) 156 125 mov ax, cx ; Copy Cylinder number to AX 157 mul WORD [di+DPT.wLHeads] ; DX:AX = cylToSeek*headsPerCyl 126 eMOVZX dx, BYTE [di+DPT.bLchsHeads] 127 mul dx ; DX:AX = cylToSeek*headsPerCyl 158 128 159 129 ; +=headToSeek (18-bit result) … … 163 133 164 134 ; *=sectPerTrack (18-bit by 6-bit multiplication with 24-bit result) 165 eMOVZX cx, BYTE [di+DPT.bP Sect]; Load Sectors per Track135 eMOVZX cx, BYTE [di+DPT.bPchsSectors] ; Load Sectors per Track 166 136 xchg ax, dx ; Hiword to AX, loword to DX 167 137 mul cl ; AX = hiword * Sectors per Track … … 176 146 add ax, bx ; Add to loword 177 147 adc dl, bh ; Add possible carry to byte2, BH=zero 148 149 ; Copy DX:AX to proper return registers 150 xchg bx, ax ; BL = Sector Number Register (LBA 7...0) 151 mov cl, bh ; Low Cylinder Register (LBA 15...8) 152 mov ch, dl ; High Cylinder Register (LBA 23...16) 153 mov bh, dh ; Drive and Head Register (LBA 27...24) 178 154 ret -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HTimer.asm
r148 r150 6 6 7 7 ;-------------------------------------------------------------------- 8 ; HTimer_InitializeTimeoutWithTicksInC L8 ; HTimer_InitializeTimeoutWithTicksInCX 9 9 ; Parameters: 10 ; C L: Timeout value in system timer ticks10 ; CX: Timeout value in system timer ticks 11 11 ; DS: Segment to RAMVARS 12 12 ; Returns: … … 16 16 ;-------------------------------------------------------------------- 17 17 ALIGN JUMP_ALIGN 18 HTimer_InitializeTimeoutWithTicksInCL: 19 xor ch, ch ; Timeout ticks now in CX 18 HTimer_InitializeTimeoutWithTicksInCX: 20 19 mov [RAMVARS.wTimeoutCounter], cx ; Store timeout ticks 21 20 call ReadTimeFromBdaToCX … … 55 54 HTimer_DelayMicrosecondsFromAX: 56 55 %ifndef USE_AT 57 mov ax, 156 mov ax, 2 58 57 ; Fall to Delay_TimerTicksFromAX 59 58 %else -
trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
r120 r150 1 ; Project name : IDEBIOS1 ; Project name : XTIDE Universal BIOS 2 2 ; Description : Functions for detecting drive for the BIOS. 3 3 … … 43 43 push cx 44 44 mov ax, g_szMaster 45 mov bh, MASK_ IDE_DRVHD_SET ; Select Master drive45 mov bh, MASK_DRVNHEAD_SET ; Select Master drive 46 46 call StartDetectionWithDriveSelectByteInBHandStringInAX ; Detect and create DPT + BOOTNFO 47 47 48 48 mov ax, g_szSlave 49 mov bh, MASK_ IDE_DRVHD_SET | FLG_IDE_DRVHD_DRV49 mov bh, MASK_DRVNHEAD_SET | FLG_DRVNHEAD_DRV 50 50 call StartDetectionWithDriveSelectByteInBHandStringInAX 51 51 pop cx … … 78 78 ; ES: Zero (BDA segment) 79 79 ; Returns: 80 ; ES:SI Ptr to ATA information (read with IDENTIFY DEVICE command)81 80 ; CF: Cleared if ATA-information read successfully 82 81 ; Set if any error 83 82 ; Corrupts registers: 84 ; AX, BL, CX, DX, DI83 ; AX, BL, CX, DX, SI, DI 85 84 ;-------------------------------------------------------------------- 86 85 .ReadAtaInfoFromHardDisk: 87 mov bl, [cs:bp+IDEVARS.bBusType]; Load BUS type 88 mov dx, [cs:bp+IDEVARS.wPort] ; Load IDE Base Port address 89 mov di, BOOTVARS.rgbAtaInfo ; ES:DI now points to ATA info location 90 call AH25h_GetDriveInfo 86 mov si, BOOTVARS.rgbAtaInfo ; ES:SI now points to ATA info location 87 push es 88 push si 89 push bx 90 call Device_IdentifyToBufferInESSIwithDriveSelectByteInBH 91 pop bx 92 pop si 93 pop es 91 94 jnc SHORT CreateBiosTablesForHardDisk 92 95 ; Fall to .ReadAtapiInfoFromDrive … … 103 106 ; BH: Drive Select byte for Drive and Head Register 104 107 ; CS:BP: Ptr to IDEVARS for the drive 105 ; ES: DI Ptr to ATA information for the drive108 ; ES:SI Ptr to ATA information for the drive 106 109 ; DS: RAMVARS segment 107 110 ; ES: BDA/Bootnfo segment … … 112 115 ;-------------------------------------------------------------------- 113 116 CreateBiosTablesForHardDisk: 114 mov si, di ; ES:SI now points to ATA information115 117 call CreateDPT_FromAtaInformation 116 118 jc SHORT .InvalidAtaInfo -
trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
r130 r150 108 108 ; Nothing 109 109 ; Corrupts registers: 110 ; A X, BX, CX, DX, DI110 ; All 111 111 ;-------------------------------------------------------------------- 112 112 .ResetDetectedDrives: 113 jmp AH0h_ResetHardDisksHandledByOurBIOS 113 call Idepack_FakeToSSBP 114 call AH0h_ResetHardDisksHandledByOurBIOS 115 add sp, BYTE SIZE_OF_FAKE_IDEPACK 116 ret -
trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm
r148 r150 111 111 .InstallHighIrqHandler: 112 112 add bx, BYTE INTV_IRQ8 - 8 ; Interrupt vector number 113 mov si, HIRQ_InterruptServiceRoutineForIrqs8to15113 mov si, IdeIrq_InterruptServiceRoutineForIrqs8to15 114 114 jmp SHORT Interrupts_InstallHandlerToVectorInBXFromCSSI 115 115 … … 126 126 .InstallLowIrqHandler: 127 127 add bx, BYTE INTV_IRQ0 ; Interrupt vector number 128 mov si, HIRQ_InterruptServiceRoutineForIrqs2to7128 mov si, IdeIrq_InterruptServiceRoutineForIrqs2to7 129 129 ; Fall to Interrupts_InstallHandlerToVectorInBXFromCSSI 130 130 … … 158 158 ;-------------------------------------------------------------------- 159 159 Interrupts_UnmaskInterruptControllerForDriveInDSDI: 160 eMOVZX bx, BYTE [di+DPT.bIde Off]160 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] 161 161 mov al, [cs:bx+IDEVARS.bIRQ] 162 162 test al, al -
trunk/XTIDE_Universal_BIOS/Src/Main.asm
r143 r150 25 25 %include "BootMenu.inc" ; For Boot Menu 26 26 %include "IDE_8bit.inc" ; For IDE 8-bit data port macros 27 %include "DeviceIDE.inc" ; For IDE device equates 27 28 28 29 … … 55 56 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE 56 57 at ROMVARS.wBootTimeout, dw 30 * TICKS_PER_SECOND ; Boot Menu selection timeout 57 at ROMVARS.bIdeCnt, db 3; Number of supported controllers58 at ROMVARS.bIdeCnt, db 4 ; Number of supported controllers 58 59 at ROMVARS.bBootDrv, db 80h ; Boot Menu default drive 59 60 at ROMVARS.bMinFddCnt, db 0 ; Do not force minimum number of floppy drives … … 62 63 at ROMVARS.ideVars0+IDEVARS.wPort, dw 1F0h ; Controller Command Block base port 63 64 at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 3F0h ; Controller Control Block base port 64 at ROMVARS.ideVars0+IDEVARS.b BusType, db BUS_TYPE_16 ; Bus type65 at ROMVARS.ideVars0+IDEVARS.bIRQ, db 14 ; IRQ65 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_16BIT_ATA 66 at ROMVARS.ideVars0+IDEVARS.bIRQ, db 14 66 67 at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE 67 68 at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE … … 69 70 at ROMVARS.ideVars1+IDEVARS.wPort, dw 170h ; Controller Command Block base port 70 71 at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw 370h ; Controller Control Block base port 71 at ROMVARS.ideVars1+IDEVARS.b BusType, db BUS_TYPE_16 ; Bus type72 at ROMVARS.ideVars1+IDEVARS.bIRQ, db 15 ; IRQ72 at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA 73 at ROMVARS.ideVars1+IDEVARS.bIRQ, db 15 73 74 at ROMVARS.ideVars1+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE 74 75 at ROMVARS.ideVars1+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE … … 76 77 at ROMVARS.ideVars2+IDEVARS.wPort, dw 300h ; Controller Command Block base port 77 78 at ROMVARS.ideVars2+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port 78 at ROMVARS.ideVars2+IDEVARS.b BusType, db BUS_TYPE_8_DUAL ; Bus type79 at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0 ; IRQ79 at ROMVARS.ideVars2+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE 80 at ROMVARS.ideVars2+IDEVARS.bIRQ, db 0 80 81 at ROMVARS.ideVars2+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE 81 82 at ROMVARS.ideVars2+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE … … 83 84 at ROMVARS.ideVars3+IDEVARS.wPort, dw 168h ; Controller Command Block base port 84 85 at ROMVARS.ideVars3+IDEVARS.wPortCtrl, dw 368h ; Controller Control Block base port 85 at ROMVARS.ideVars3+IDEVARS.b BusType, db BUS_TYPE_16 ; Bus type86 at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0 ; IRQ86 at ROMVARS.ideVars3+IDEVARS.bDevice, db DEVICE_16BIT_ATA 87 at ROMVARS.ideVars3+IDEVARS.bIRQ, db 0 87 88 at ROMVARS.ideVars3+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE 88 89 at ROMVARS.ideVars3+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE … … 101 102 at ROMVARS.ideVars0+IDEVARS.wPort, dw 300h ; Controller Command Block base port 102 103 at ROMVARS.ideVars0+IDEVARS.wPortCtrl, dw 308h ; Controller Control Block base port 103 at ROMVARS.ideVars0+IDEVARS.b BusType, db BUS_TYPE_8_DUAL ; Bus type104 at ROMVARS.ideVars0+IDEVARS.bDevice, db DEVICE_8BIT_DUAL_PORT_XTIDE 104 105 at ROMVARS.ideVars0+IDEVARS.bIRQ, db 0 ; IRQ 105 106 at ROMVARS.ideVars0+IDEVARS.drvParamsMaster+DRVPARAMS.wFlags, db FLG_DRVPARAMS_BLOCKMODE … … 146 147 %include "DriveXlate.asm" ; For swapping drive numbers 147 148 %include "HAddress.asm" ; For sector address translations 148 %include "HCapacity.asm" ; For calculating drive capacity149 %include "HError.asm" ; For error checking150 %include "HPIO.asm" ; For PIO transfers151 %include "HIRQ.asm" ; For IRQ handling152 %include "HStatus.asm" ; For reading hard disk status153 %include "HDrvSel.asm" ; For selecting drive to access154 %include "HCommand.asm" ; For outputting command and parameters155 149 %include "HTimer.asm" ; For timeout and delay 156 150 … … 178 172 %include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm 179 173 %include "AH25h_HDrvID.asm" ; Required by Int13h_Jump.asm 174 %include "Device.asm" 175 %include "Idepack.asm" 180 176 177 ; IDE Device support 178 %include "IdeCommand.asm" 179 %include "IdeDPT.asm" 180 %include "IdeIO.asm" 181 %include "IdeIrq.asm" 182 %include "IdeTransfer.asm" 183 %include "IdeWait.asm" 184 %include "IdeError.asm" ; Must be included after IdeWait.asm 185 186 ; Serial Port Device support 187 %include "SerialCommand.asm" 188 %include "SerialDPT.asm" 181 189 182 190 -
trunk/XTIDE_Universal_BIOS/Src/Strings.asm
r143 r150 36 36 g_szSizeDual: db "%s%4-u.%u %ciB / %4-u.%u %ciB",LF,CR,NULL 37 37 g_szCfgHeader: db "Addr.",SINGLE_VERTICAL,"Block",SINGLE_VERTICAL,"Bus", SINGLE_VERTICAL,"IRQ", SINGLE_VERTICAL,"Reset",LF,CR,NULL 38 g_szCfgFormat: db "%s" ,SINGLE_VERTICAL,"%5-u", 38 g_szCfgFormat: db "%s" ,SINGLE_VERTICAL,"%5-u", SINGLE_VERTICAL,"%c%2u",SINGLE_VERTICAL," %c%c",SINGLE_VERTICAL,"%5-x", NULL 39 39 g_szLCHS: db "L-CHS",NULL 40 40 g_szPCHS: db "P-CHS",NULL -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm
r99 r150 6 6 7 7 ;-------------------------------------------------------------------- 8 ; Returns L-CHS values from DPT. 9 ; 8 ; AccessDPT_GetDriveSelectByteToAL 9 ; Parameters: 10 ; DS:DI: Ptr to Disk Parameter Table 11 ; Returns: 12 ; AL: Drive Select Byte 13 ; Corrupts registers: 14 ; Nothing 15 ;-------------------------------------------------------------------- 16 ALIGN JUMP_ALIGN 17 AccessDPT_GetDriveSelectByteToAL: 18 mov al, [di+DPT.wFlags] 19 and al, FLG_DRVNHEAD_LBA | FLG_DRVNHEAD_DRV 20 or al, MASK_DRVNHEAD_SET ; Bits set to 1 for old drives 21 ret 22 23 24 ;-------------------------------------------------------------------- 25 ; AccessDPT_GetDeviceControlByteToAL 26 ; Parameters: 27 ; DS:DI: Ptr to Disk Parameter Table 28 ; Returns: 29 ; AL: Device Control Byte 30 ; Corrupts registers: 31 ; Nothing 32 ;-------------------------------------------------------------------- 33 ALIGN JUMP_ALIGN 34 AccessDPT_GetDeviceControlByteToAL: 35 xor al, al 36 test BYTE [di+DPT.wFlags], FLG_DPT_ENABLE_IRQ 37 jnz SHORT .EnableDeviceIrq 38 or al, FLG_DEVCONTROL_nIEN ; Disable IRQ 39 .EnableDeviceIrq: 40 ret 41 42 43 ;-------------------------------------------------------------------- 44 ; AccessDPT_GetAddressingModeForWordLookToBX 45 ; Parameters: 46 ; DS:DI: Ptr to Disk Parameter Table 47 ; Returns: 48 ; BX: Addressing Mode (L-CHS, P-CHS, LBA28, LBA48) shifted for WORD lookup 49 ; Corrupts registers: 50 ; Nothing 51 ;-------------------------------------------------------------------- 52 ALIGN JUMP_ALIGN 53 AccessDPT_GetAddressingModeForWordLookToBX: 54 mov bl, [di+DPT.wFlags] 55 and bx, BYTE MASK_DPT_ADDRESSING_MODE 56 eSHR_IM bx, ADDRESSING_MODE_FIELD_POSITION-1 57 ret 58 59 60 ;-------------------------------------------------------------------- 10 61 ; AccessDPT_GetLCHSfromPCHS 11 62 ; Parameters: … … 21 72 AccessDPT_GetLCHSfromPCHS: 22 73 xchg ax, cx 23 mov cl, [di+DPT.bShLtoP] ; Load shift count 24 mov bx, [di+DPT.wPCyls] ; Load P-CHS cylinders 25 shr bx, cl ; Shift to L-CHS cylinders 74 mov cl, [di+DPT.wFlags] 75 and cl, MASK_DPT_CHS_SHIFT_COUNT ; Load shift count 76 mov bx, [di+DPT.wPchsCylinders] ; Load P-CHS cylinders 77 shr bx, cl ; Shift to L-CHS cylinders 26 78 xchg cx, ax 27 mov dx, [di+DPT.wLHeads]; Load L-CHS heads28 eMOVZX ax, BYTE [di+DPT.bP Sect] ; Load Sectors per track79 eMOVZX dx, BYTE [di+DPT.bLchsHeads] ; Load L-CHS heads 80 eMOVZX ax, BYTE [di+DPT.bPchsSectors] ; Load Sectors per track 29 81 ret 30 82 31 83 32 84 ;-------------------------------------------------------------------- 33 ; Tests IDEVARS flags for master or slave drive.34 ;35 85 ; AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 36 86 ; Parameters: … … 63 113 ALIGN JUMP_ALIGN 64 114 AccessDPT_GetPointerToDRVPARAMStoCSBX: 65 eMOVZX bx, [di+DPT.bIdeOff] ; CS:BX points to IDEVARS 66 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV 67 jnz SHORT .ReturnPointerToSlaveDRVPARAMS 68 add bx, BYTE IDEVARS.drvParamsMaster 115 eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS 116 add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS 117 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE 118 jz SHORT .ReturnPointerToDRVPARAMS 119 add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS 120 .ReturnPointerToDRVPARAMS: 69 121 ret 70 ALIGN JUMP_ALIGN71 .ReturnPointerToSlaveDRVPARAMS:72 add bx, BYTE IDEVARS.drvParamsSlave73 ret -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm
r128 r150 25 25 ;-------------------------------------------------------------------- 26 26 CreateDPT_FromAtaInformation: 27 call FindDPT_ForNewDrive ; Get new DPT to DS:DI27 call FindDPT_ForNewDriveToDSDI 28 28 ; Fall to .InitializeDPT 29 29 … … 35 35 ; CS:BP: Ptr to IDEVARS for the controller 36 36 ; Returns: 37 ; AX: Zero38 ; Corrupts registers: 39 ; Nothing37 ; Nothing 38 ; Corrupts registers: 39 ; AX 40 40 ;-------------------------------------------------------------------- 41 41 .InitializeDPT: 42 xor ax, ax 43 mov BYTE [di+DPT.bSize], DPT_size 44 mov [di+DPT.wDrvNumAndFlags], ax 45 mov BYTE [di+DPT.bReset], MASK_RESET_ALL 46 mov [di+DPT.bIdeOff], bp 47 mov [di+DPT.bDrvSel], bh 48 ; Fall to .StoreDriveControlByte 49 50 ;-------------------------------------------------------------------- 51 ; .StoreDriveControlByte 52 ; Parameters: 53 ; AX: Zero 42 mov [di+DPT.bIdevarsOffset], bp ; IDEVARS must start in first 256 bytes of ROM 43 ; Fall to .StoreDriveSelectAndDriveControlByte 44 45 ;-------------------------------------------------------------------- 46 ; .StoreDriveSelectAndDriveControlByte 47 ; Parameters: 54 48 ; BH: Drive Select byte for Drive and Head Register 55 49 ; DS:DI: Ptr to Disk Parameter Table … … 61 55 ; AX 62 56 ;-------------------------------------------------------------------- 63 .StoreDriveControlByte: 64 cmp BYTE [cs:bp+IDEVARS.bIRQ], al ; Interrupts enabled? 65 jne SHORT .CheckHeadCount 66 or al, FLG_IDE_CTRL_nIEN ; Disable interrupts 67 .CheckHeadCount: 68 cmp BYTE [es:si+ATA1.wHeadCnt], 8 ; 1...8 heads? 69 jbe SHORT .StoreDrvCtrlByteToDPT 70 or al, FLG_IDE_CTRL_O8H ; Over 8 heads (pre-ATA) 71 .StoreDrvCtrlByteToDPT: 72 mov [di+DPT.bDrvCtrl], al 57 .StoreDriveSelectAndDriveControlByte: 58 mov al, bh 59 and ax, BYTE FLG_DRVNHEAD_DRV ; AL now has Master/Slave bit 60 cmp [cs:bp+IDEVARS.bIRQ], ah ; Interrupts enabled? 61 jz SHORT .StoreFlags ; If not, do not set interrupt flag 62 or al, FLG_DPT_ENABLE_IRQ 63 .StoreFlags: 64 mov [di+DPT.wFlags], ax 73 65 ; Fall to .StorePCHS 74 66 … … 76 68 ; .StorePCHS 77 69 ; Parameters: 78 ; AH: Zero79 70 ; BH: Drive Select byte for Drive and Head Register 80 71 ; DS:DI: Ptr to Disk Parameter Table … … 99 90 mov ax, [cs:bx+DRVPARAMS.wCylinders] 100 91 mov bx, [cs:bx+DRVPARAMS.wHeadsAndSectors] 101 or BYTE [di+DPT.bFlags], FLG_DPT_USERCHS102 92 103 93 .StorePCHStoDPT: 104 mov [di+DPT.wP Cyls], ax105 mov [di+DPT.w HeadsAndSectors], bx94 mov [di+DPT.wPchsCylinders], ax 95 mov [di+DPT.wPchsHeadsAndSectors], bx 106 96 ; Fall to .StoreLCHS 107 97 … … 129 119 jmp SHORT .ShiftLoop 130 120 131 .LimitHeadsTo255: 132 test bh, bh ; 256 heads? 133 jz SHORT .StoreLCHStoDPT ; If less, no correction needed 134 dec bx ; Limit to 255 heads since DOS does not support 256 heads 135 .StoreLCHStoDPT: 136 mov [di+DPT.bShLtoP], cl 137 mov [di+DPT.wLHeads], bx 121 .LimitHeadsTo255: ; DOS does not support drives with 256 heads 122 rcr bh, 1 ; Set CF if 256 heads 123 sbb bl, 0 ; Decrement to 255 if 256 heads 124 or [di+DPT.wFlags], cl 125 mov [di+DPT.bLchsHeads], bl 138 126 ; Fall to .StoreAddressing 139 127 … … 146 134 ; Nothing 147 135 ; Corrupts registers: 148 ; Nothing136 ; AX, BX 149 137 ;-------------------------------------------------------------------- 150 138 .StoreAddressing: 151 cmp WORD [di+DPT.wPCyls], 1024 ; L-CHS possible? (no translation needed) 152 jbe SHORT .StoreBlockMode ; If so, nothing needs to be changed 153 test BYTE [di+DPT.bFlags], FLG_DPT_USERCHS 154 jnz SHORT .StorePCHSaddressing ; Use user defined P-CHS 139 ; Check if L-CHS addressing should be used 140 cmp WORD [di+DPT.wPchsCylinders], 1024 ; L-CHS possible? (no translation needed) 141 jbe SHORT .StoreBlockMode ; If so, nothing needs to be changed 142 143 ; Check if P-CHS addressing should be used 144 mov al, FLG_DRVPARAMS_USERCHS ; User specified CHS? 145 call AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive 146 jnz SHORT .StorePCHSaddressing 155 147 test WORD [es:si+ATA1.wCaps], A2_wCaps_LBA 156 jz SHORT .StorePCHSaddressing ; Use P-CHS since LBA not supported 148 jz SHORT .StorePCHSaddressing ; Use P-CHS since LBA not supported 149 150 ; LBA needs to be used. Check if 48-bit LBA is supported 157 151 test WORD [es:si+ATA6.wSetSup83], A6_wSetSup83_LBA48 158 jz SHORT .StoreLBA28addressing ; Use LBA-28 since LBA-48 not supported159 or BYTE [di+DPT. bFlags], ADDR_DPT_LBA48<<1152 jz SHORT .StoreLBA28addressing ; Use LBA-28 since LBA-48 not supported 153 or BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA48<<ADDRESSING_MODE_FIELD_POSITION 160 154 .StoreLBA28addressing: 161 or BYTE [di+DPT.bFlags], ADDR_DPT_LBA28<<1 162 or BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA 155 or BYTE [di+DPT.wFlags], ADDRESSING_MODE_LBA28<<ADDRESSING_MODE_FIELD_POSITION 163 156 jmp SHORT .StoreBlockMode 164 157 .StorePCHSaddressing: 165 or BYTE [di+DPT. bFlags], ADDR_DPT_PCHS<<1158 or BYTE [di+DPT.wFlags], ADDRESSING_MODE_PCHS<<ADDRESSING_MODE_FIELD_POSITION 166 159 ; Fall to .StoreBlockMode 167 160 … … 174 167 ; Nothing 175 168 ; Corrupts registers: 176 ; AX169 ; Nothing 177 170 ;-------------------------------------------------------------------- 178 171 .StoreBlockMode: 179 mov al, 1 ; Minimum block size is 1 sector 180 mov ah, [es:si+ATA1.bBlckSize] ; Load max block size in sectors 181 mov [di+DPT.wSetAndMaxBlock], ax 182 ; Fall to .StoreEBIOSSupport 183 184 ;-------------------------------------------------------------------- 185 ; .StoreEBIOSSupport 186 ; Parameters: 187 ; DS:DI: Ptr to Disk Parameter Table 188 ; ES:SI: Ptr to 512-byte ATA information read from the drive 189 ; Returns: 190 ; Nothing 191 ; Corrupts registers: 192 ; AX, BX, DX 193 ;-------------------------------------------------------------------- 194 .StoreEBIOSSupport: 195 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE 196 jz SHORT .StoreDriveNumberAndUpdateDriveCount ; No EBIOS support since small DPTs needed 197 198 mov bl, [di+DPT.bFlags] 199 and bx, BYTE MASK_DPT_ADDR ; Addressing mode 200 jmp [cs:bx+.rgwAddrJmp] ; Jump to handle addressing mode 201 .rgwAddrJmp: 202 dw .StoreDriveNumberAndUpdateDriveCount ; ADDR_DPT_LCHS 203 dw .StoreDriveNumberAndUpdateDriveCount ; ADDR_DPT_PCHS 204 dw .SupportForLBA28 ; ADDR_DPT_LBA28 205 dw .SupportForLBA48 ; ADDR_DPT_LBA48 206 207 .SupportForLBA28: 208 sub BYTE [di+DPT.bSize], 2 ; Only 4 bytes for sector count 209 .SupportForLBA48: 210 add BYTE [di+DPT.bSize], EBDPT_size - DPT_size 211 or BYTE [di+DPT.bFlags], FLG_DPT_EBIOS 212 call AtaID_GetTotalSectorCount 213 mov [di+EBDPT.twCapacity], ax 214 mov [di+EBDPT.twCapacity+2], dx 215 mov [di+EBDPT.twCapacity+4], bx 172 cmp BYTE [es:si+ATA1.bBlckSize], 1 ; Max block size in sectors 173 jbe SHORT .BlockModeTransfersNotSupported 174 or WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED 175 .BlockModeTransfersNotSupported: 176 ; Fall to .StoreDeviceSpecificParameters 177 178 ;-------------------------------------------------------------------- 179 ; .StoreDeviceSpecificParameters 180 ; Parameters: 181 ; DS:DI: Ptr to Disk Parameter Table 182 ; ES:SI: Ptr to 512-byte ATA information read from the drive 183 ; Returns: 184 ; Nothing 185 ; Corrupts registers: 186 ; AX, BX, CX, DX 187 ;-------------------------------------------------------------------- 188 .StoreDeviceSpecificParameters: 189 call Device_FinalizeDPT 216 190 ; Fall to .StoreDriveNumberAndUpdateDriveCount 217 191 … … 230 204 ;-------------------------------------------------------------------- 231 205 .StoreDriveNumberAndUpdateDriveCount: 232 ; Make sure that more drives can be accepted 233 mov dl, [es:BDA.bHDCount] ; Load number of hard disks 234 test dl, dl ; Hard disks at maximum? 235 stc ; Assume error 236 js SHORT .TooManyDrives ; If so, return 237 238 ; Store drive number to DPT 239 or dl, 80h ; Set bit 7 since hard disk 240 mov [di+DPT.bDrvNum], dl ; Store drive number 241 242 ; Update BDA and RAMVARS 243 inc BYTE [es:BDA.bHDCount] ; Increment drive count to BDA 244 call RamVars_IncrementHardDiskCount 206 mov dl, [es:BDA.bHDCount] 207 or dl, 80h ; Set bit 7 since hard disk 208 209 inc BYTE [RAMVARS.bDrvCnt] ; Increment drive count to RAMVARS 210 inc BYTE [es:BDA.bHDCount] ; Increment drive count to BDA 211 212 cmp BYTE [RAMVARS.bFirstDrv], 0 ; First drive set? 213 ja SHORT .AllDone ; If so, return 214 mov [RAMVARS.bFirstDrv], dl ; Store first drive number 215 .AllDone: 245 216 clc 246 .TooManyDrives:247 217 ret -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
r3 r150 1 ; File name : FindDPT.asm 2 ; Project name : IDE BIOS 3 ; Created date : 14.3.2010 4 ; Last update : 12.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for finding Disk Parameter Table. 7 3 … … 12 8 ; Finds pointer to first unused Disk Parameter Table. 13 9 ; 14 ; FindDPT_ForNewDrive 10 ; FindDPT_ForNewDriveToDSDI 15 11 ; Parameters: 16 12 ; DS: RAMVARS segment … … 18 14 ; DS:DI: Ptr to first unused DPT 19 15 ; Corrupts registers: 20 ; Nothing16 ; DL 21 17 ;-------------------------------------------------------------------- 22 18 ALIGN JUMP_ALIGN 23 FindDPT_ForNewDrive: 24 push si 25 mov si, FindDPT_ReturnWrongDPT 26 jmp SHORT FindDPT_StartIterationAndReturnAfterDone 27 28 29 ;-------------------------------------------------------------------- 30 ; Finds Disk Parameter Table for 31 ; Master or Slave drive at wanted port. 32 ; 33 ; FindDPT_ForIdeSlaveAtPort 34 ; FindDPT_ForIdeMasterAtPort 35 ; Parameters: 36 ; DX: IDE Base Port address 37 ; DS: RAMVARS segment 38 ; Returns: 39 ; DL: Drive number (if DPT found) 40 ; DS:DI: Ptr to DPT 41 ; CF: Set if wanted DPT found 42 ; Cleared if DPT not found 43 ; Corrupts registers: 44 ; Nothing 45 ;-------------------------------------------------------------------- 46 ALIGN JUMP_ALIGN 47 FindDPT_ForIdeSlaveAtPort: 48 push si 49 mov si, FindDPT_IterateToSlaveAtPortCallback 50 jmp SHORT FindDPT_StartIterationAndReturnAfterDone 51 52 ALIGN JUMP_ALIGN 53 FindDPT_ForIdeMasterAtPort: 54 push si 55 mov si, FindDPT_IterateToMasterAtPortCallback 56 jmp SHORT FindDPT_StartIterationAndReturnAfterDone 57 58 ;-------------------------------------------------------------------- 59 ; Iteration callback for finding DPT using 60 ; IDE base port for Master or Slave drive. 61 ; 62 ; FindDPT_IterateToSlaveAtPortCallback 63 ; FindDPT_IterateToMasterAtPortCallback 64 ; Parameters: 65 ; DX: IDE Base Port address 66 ; DS:DI: Ptr to DPT to examine 67 ; Returns: 68 ; DL: Drive number if correct DPT 69 ; CF: Set if wanted DPT found 70 ; Cleared if wrong DPT 71 ; Corrupts registers: 72 ; Nothing 73 ;-------------------------------------------------------------------- 74 ALIGN JUMP_ALIGN 75 FindDPT_IterateToSlaveAtPortCallback: 76 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV 77 jnz SHORT FindDPT_IterateToMasterOrSlaveAtPortCallback 78 jmp SHORT FindDPT_ReturnWrongDPT ; Return if master drive 79 80 ALIGN JUMP_ALIGN 81 FindDPT_IterateToMasterAtPortCallback: 82 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV 83 jnz SHORT FindDPT_ReturnWrongDPT ; Return if slave drive 84 85 ; If BIOS partitioned, ignore all but first partition 86 ALIGN JUMP_ALIGN 87 FindDPT_IterateToMasterOrSlaveAtPortCallback: 88 test BYTE [di+DPT.bFlags], FLG_DPT_PARTITION 89 jz SHORT .CompareBasePortAddress 90 test BYTE [di+DPT.bFlags], FLG_DPT_FIRSTPART 91 jz SHORT FindDPT_ReturnWrongDPT 92 ALIGN JUMP_ALIGN 93 .CompareBasePortAddress: 94 push bx 95 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; CS:BX now points to IDEVARS 96 cmp dx, [cs:bx+IDEVARS.wPort] ; Wanted port? 97 pop bx 98 jne SHORT FindDPT_ReturnWrongDPT 99 mov dl, [di+DPT.bDrvNum] ; Load drive number 100 stc ; Set CF since wanted DPT 101 ret 19 FindDPT_ForNewDriveToDSDI: 20 mov dl, [RAMVARS.bFirstDrv] 21 add dl, [RAMVARS.bDrvCnt] 22 ; Fall to FindDPT_ForDriveNumber 102 23 103 24 … … 112 33 ; Returns: 113 34 ; DS:DI: Ptr to DPT 114 ; CF: Set if wanted DPT found115 ; Cleared if DPT not found116 35 ; Corrupts registers: 117 36 ; Nothing … … 119 38 ALIGN JUMP_ALIGN 120 39 FindDPT_ForDriveNumber: 121 push si 122 mov si, FindDPT_IterateToDriveNumberCallback 123 FindDPT_StartIterationAndReturnAfterDone: 124 call FindDPT_IterateAllDPTs 125 pop si 40 push dx 41 push ax 42 43 mov al, LARGEST_DPT_SIZE 44 sub dl, [RAMVARS.bFirstDrv] 45 mul dl 46 add ax, BYTE RAMVARS_size 47 xchg di, ax 48 49 pop ax 50 pop dx 126 51 ret 127 52 53 128 54 ;-------------------------------------------------------------------- 129 ; Iteration callback for finding DPT for drive number. 55 ; Finds Disk Parameter Table for 56 ; Master or Slave drive at wanted port. 130 57 ; 131 ; FindDPT_IterateToDriveNumberCallback 58 ; FindDPT_ToDSDIForIdeMasterAtPortDX 59 ; FindDPT_ToDSDIForIdeSlaveAtPortDX 132 60 ; Parameters: 133 ; DL: Drive number to search for 61 ; DX: IDE Base Port address 62 ; DS: RAMVARS segment 63 ; Returns: 64 ; DL: Drive number (if DPT found) 65 ; DS:DI: Ptr to DPT 66 ; CF: Set if wanted DPT found 67 ; Cleared if DPT not found 68 ; Corrupts registers: 69 ; SI 70 ;-------------------------------------------------------------------- 71 ALIGN JUMP_ALIGN 72 FindDPT_ToDSDIForIdeMasterAtPortDX: 73 mov si, FindDPT_IterateToMasterAtPortCallback 74 jmp SHORT IterateAllDPTs 75 76 ALIGN JUMP_ALIGN 77 FindDPT_ToDSDIForIdeSlaveAtPortDX: 78 mov si, FindDPT_IterateToSlaveAtPortCallback 79 jmp SHORT IterateAllDPTs 80 81 ;-------------------------------------------------------------------- 82 ; Iteration callback for finding DPT using 83 ; IDE base port for Master or Slave drive. 84 ; 85 ; FindDPT_IterateToSlaveAtPortCallback 86 ; FindDPT_IterateToMasterAtPortCallback 87 ; Parameters: 88 ; CH: Drive number 89 ; DX: IDE Base Port address 134 90 ; DS:DI: Ptr to DPT to examine 135 91 ; Returns: 92 ; DL: Drive number if correct DPT 136 93 ; CF: Set if wanted DPT found 137 94 ; Cleared if wrong DPT … … 140 97 ;-------------------------------------------------------------------- 141 98 ALIGN JUMP_ALIGN 142 FindDPT_IterateToDriveNumberCallback: 143 cmp dl, [di+DPT.bDrvNum] ; Wanted DPT found? 144 je SHORT FindDPT_RightDriveNumber ; If so, return 145 FindDPT_ReturnWrongDPT: 146 clc ; Clear CF since wrong DPT 99 FindDPT_IterateToSlaveAtPortCallback: 100 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE ; Clears CF 101 jnz SHORT CompareBasePortAddress 102 ret ; Wrong DPT 103 104 ALIGN JUMP_ALIGN 105 FindDPT_IterateToMasterAtPortCallback: 106 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE 107 jnz SHORT ReturnWrongDPT ; Return if slave drive 108 109 CompareBasePortAddress: 110 push bx 111 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS 112 cmp dx, [cs:bx+IDEVARS.wPort] ; Wanted port? 113 pop bx 114 jne SHORT ReturnWrongDPT 115 mov dl, ch ; Return drive number in DL 116 stc ; Set CF since wanted DPT 147 117 ret 148 ALIGN JUMP_ALIGN 149 FindDPT_RightDriveNumber: 150 push bx 151 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; CS:BX now points to IDEVARS 152 mov bx, [cs:bx+IDEVARS.wPort] ; Load IDE Base Port address... 153 mov [RAMVARS.wIdeBase], bx ; ...and store it to RAMVARS 154 pop bx 155 stc 118 ReturnWrongDPT: 119 clc ; Clear CF since wrong DPT 156 120 ret 157 121 … … 160 124 ; Iterates all Disk Parameter Tables. 161 125 ; 162 ; FindDPT_IterateAllDPTs126 ; IterateAllDPTs 163 127 ; Parameters: 164 128 ; BX,DX: Parameters to callback function … … 170 134 ; Cleared if DPT not found 171 135 ; Corrupts registers: 172 ; Nothing ,unless corrupted by callback function136 ; Nothing unless corrupted by callback function 173 137 ;-------------------------------------------------------------------- 174 138 ALIGN JUMP_ALIGN 175 FindDPT_IterateAllDPTs: 176 push ax 139 IterateAllDPTs: 177 140 push cx 141 mov cx, [RAMVARS.wDrvCntAndFirst] 142 jcxz .AllDptsIterated ; Return if no drives 178 143 call FindDPT_PointToFirstDPT ; Point DS:DI to first DPT 179 eMOVZX cx, BYTE [RAMVARS.bDrvCnt] ; Load number of drives180 xor ax, ax ; Zero AX for DPT size and clear CF181 jcxz .Return ; Return if no drives182 144 ALIGN JUMP_ALIGN 183 145 .LoopWhileDPTsLeft: 184 146 call si ; Is wanted DPT? 185 jc SHORT .Return ; If so, return 186 mov al, [di+DPT.bSize] ; Load DPT size to AX 187 add di, ax ; Point to next DPT 188 loop .LoopWhileDPTsLeft ; Check next DPT 147 jc SHORT .AllDptsIterated ; If so, return 148 inc ch ; Increment drive number 149 add di, BYTE LARGEST_DPT_SIZE ; Point to next DPT 150 dec cl ; Decrement drives left 151 jnz SHORT .LoopWhileDPTsLeft 189 152 clc ; Clear CF since DPT not found 190 153 ALIGN JUMP_ALIGN 191 . Return:154 .AllDptsIterated: 192 155 pop cx 193 pop ax194 156 ret 195 157 … … 209 171 FindDPT_PointToFirstDPT: 210 172 mov di, RAMVARS_size 211 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE212 jz SHORT .Return ; RAMVARS used (top of interrupt vectors)213 add di, BYTE FULLRAMVARS_size-RAMVARS_size ; FULLRAMVARS used (top of base memory)214 ALIGN JUMP_ALIGN215 .Return:216 173 ret -
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm
r148 r150 40 40 eSHL_IM ax, 6 ; Segment to first stolen kB (*=40h) 41 41 mov ds, ax 42 mov WORD [ FULLRAMVARS.wSign], W_SIGN_FULLRAMVARS43 ; Fall to .InitializeRamvars FromDS42 mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE 43 ; Fall to .InitializeRamvars 44 44 45 45 ;-------------------------------------------------------------------- … … 59 59 pop es 60 60 call Memory_ZeroESDIwithSizeInCX 61 mov WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE 61 62 ; Fall to .InitializeDriveTranslationAndReturn 62 63 … … 92 93 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE 93 94 jnz SHORT .GetStolenSegmentToDS 94 mov di, SEGMENT_RAMVARS_TOP_OF_INTERRUPT_VECTORS95 mov di, LITE_MODE_RAMVARS_SEGMENT 95 96 mov ds, di 96 97 ret … … 105 106 mov ds, di ; EBDA segment to DS 106 107 add di, BYTE 64 ; DI to next stolen kB 107 cmp WORD [ FULLRAMVARS.wSign], W_SIGN_FULLRAMVARS108 cmp WORD [RAMVARS.wSignature], RAMVARS_SIGNATURE 108 109 jne SHORT .LoopStolenKBs ; Loop until sign found (always found eventually) 109 110 ret … … 167 168 168 169 ;-------------------------------------------------------------------- 169 ; RamVars_IncrementHardDiskCount170 ; Parameters:171 ; DL: Drive number for new drive172 ; DS: RAMVARS segment173 ; Returns:174 ; Nothing175 ; Corrupts registers:176 ; Nothing177 ;--------------------------------------------------------------------178 RamVars_IncrementHardDiskCount:179 inc BYTE [RAMVARS.bDrvCnt] ; Increment drive count to RAMVARS180 cmp BYTE [RAMVARS.bFirstDrv], 0 ; First drive set?181 ja SHORT .Return ; If so, return182 mov [RAMVARS.bFirstDrv], dl ; Store first drive number183 .Return:184 ret185 186 187 ;--------------------------------------------------------------------188 170 ; RamVars_GetHardDiskCountFromBDAtoCX 189 171 ; Parameters: -
trunk/XTIDE_Universal_BIOS/makefile
r145 r150 39 39 HEADERS += Src/Handlers/Int13h/ 40 40 HEADERS += Src/Handlers/Int13h/Common/ 41 HEADERS += Src/Device/ 42 HEADERS += Src/Device/IDE/ 43 HEADERS += Src/Device/Serial/ 41 44 HEADERS += Src/Initialization/ 42 45 HEADERS += Src/Libraries/
Note:
See TracChangeset
for help on using the changeset viewer.