[150] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
| 2 | ; Description : Functions for managing IDEPACK struct.
|
---|
| 3 |
|
---|
| 4 | SIZE_OF_FAKE_IDEPACK EQU (IDEPACK_size - INTPACK_size)
|
---|
| 5 |
|
---|
| 6 | ; Section containing code
|
---|
| 7 | SECTION .text
|
---|
| 8 |
|
---|
| 9 | ;--------------------------------------------------------------------
|
---|
| 10 | ; Idepack_FakeToSSBP
|
---|
| 11 | ; Parameters:
|
---|
| 12 | ; Nothing
|
---|
| 13 | ; Returns:
|
---|
| 14 | ; SS:BP: Ptr to IDEPACK
|
---|
| 15 | ; Corrupts registers:
|
---|
| 16 | ; AX
|
---|
| 17 | ;--------------------------------------------------------------------
|
---|
| 18 | Idepack_FakeToSSBP:
|
---|
| 19 | pop ax
|
---|
| 20 | sub sp, BYTE SIZE_OF_FAKE_IDEPACK
|
---|
| 21 | mov bp, sp
|
---|
| 22 | jmp ax
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | ;--------------------------------------------------------------------
|
---|
| 26 | ; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
|
---|
| 27 | ; Parameters:
|
---|
| 28 | ; AH: IDE command to issue
|
---|
| 29 | ; AL: Number of sectors to transfer (1...255, 0=256)
|
---|
| 30 | ; BH: Timeout ticks
|
---|
| 31 | ; BL: IDE Status Register flag to wait after command
|
---|
| 32 | ; CH: Cylinder number, bits 7...0
|
---|
| 33 | ; CL: Bits 7...6: Cylinder number bits 9 and 8
|
---|
| 34 | ; Bits 5...0: Starting sector number (1...63)
|
---|
| 35 | ; DH: Starting head number (0...255)
|
---|
| 36 | ; ES:SI: Ptr to data buffer
|
---|
| 37 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
| 38 | ; SS:BP: Ptr to IDEPACK
|
---|
| 39 | ; Returns:
|
---|
| 40 | ; AH: INT 13h Error Code
|
---|
| 41 | ; CF: Cleared if success, Set if error
|
---|
| 42 | ; Corrupts registers:
|
---|
| 43 | ; AL, BX, CX, DX
|
---|
| 44 | ;--------------------------------------------------------------------
|
---|
| 45 | ALIGN JUMP_ALIGN
|
---|
| 46 | Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
|
---|
| 47 | mov [bp+IDEPACK.bSectorCount], al
|
---|
| 48 | mov [bp+IDEPACK.bCommand], ah
|
---|
| 49 | mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0
|
---|
| 50 |
|
---|
| 51 | push bx
|
---|
[155] | 52 | call Address_OldInt13hAddressToIdeAddress
|
---|
[150] | 53 | call AccessDPT_GetDriveSelectByteToAL
|
---|
| 54 | or al, bh ; AL now has Drive and Head Select Byte
|
---|
| 55 | mov [bp+IDEPACK.bDrvAndHead], al
|
---|
| 56 | mov [bp+IDEPACK.bLbaLow], bl
|
---|
| 57 | mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
|
---|
| 58 | pop bx
|
---|
| 59 |
|
---|
| 60 | call AccessDPT_GetDeviceControlByteToAL
|
---|
| 61 | mov [bp+IDEPACK.bDeviceControl], al
|
---|
| 62 | jmp Device_OutputCommandWithParameters
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 | ;--------------------------------------------------------------------
|
---|
| 66 | ; Idepack_StoreNonExtParametersAndIssueCommandFromAL
|
---|
| 67 | ; Parameters:
|
---|
| 68 | ; BH: Timeout ticks
|
---|
| 69 | ; BL: IDE Status Register flag to wait after command
|
---|
| 70 | ; AL: IDE command to issue
|
---|
| 71 | ; AH: Parameter to Drive and Head Select Register (Head bits only)
|
---|
| 72 | ; DL: Parameter to Sector Count Register
|
---|
| 73 | ; DH: Parameter to LBA Low / Sector Number Register
|
---|
| 74 | ; CL: Parameter to LBA Middle / Cylinder Low Register
|
---|
| 75 | ; CH: Parameter to LBA High / Cylinder High Register
|
---|
| 76 | ; SI: Parameter to Features Register
|
---|
| 77 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
| 78 | ; SS:BP: Ptr to IDEPACK
|
---|
| 79 | ; Returns:
|
---|
| 80 | ; AH: INT 13h Error Code
|
---|
| 81 | ; CF: Cleared if success, Set if error
|
---|
| 82 | ; Corrupts registers:
|
---|
| 83 | ; AL, BX, CX, DX
|
---|
| 84 | ;--------------------------------------------------------------------
|
---|
| 85 | ALIGN JUMP_ALIGN
|
---|
| 86 | Idepack_StoreNonExtParametersAndIssueCommandFromAL:
|
---|
| 87 | mov [bp+IDEPACK.bFeatures], si
|
---|
| 88 | mov [bp+IDEPACK.bCommand], al
|
---|
| 89 | mov [bp+IDEPACK.wSectorCountAndLbaLow], dx
|
---|
| 90 | mov [bp+IDEPACK.wLbaMiddleAndHigh], cx
|
---|
| 91 | mov BYTE [bp+IDEPACK.bSectorCountHighExt], 0
|
---|
| 92 |
|
---|
| 93 | ; Drive and Head select byte
|
---|
| 94 | and ah, MASK_DRVNHEAD_HEAD ; Keep head bits only
|
---|
| 95 | call AccessDPT_GetDriveSelectByteToAL
|
---|
| 96 | or al, ah
|
---|
| 97 | mov [bp+IDEPACK.bDrvAndHead], al
|
---|
| 98 |
|
---|
| 99 | ; Device Control byte with interrupts disabled
|
---|
| 100 | call AccessDPT_GetDeviceControlByteToAL
|
---|
| 101 | or al, FLG_DEVCONTROL_nIEN ; Disable interrupt
|
---|
| 102 | mov [bp+IDEPACK.bDeviceControl], al
|
---|
| 103 |
|
---|
| 104 | jmp Device_OutputCommandWithParameters
|
---|