1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Functions for accessing DPT data.
|
---|
3 |
|
---|
4 | ; Section containing code
|
---|
5 | SECTION .text
|
---|
6 |
|
---|
7 | ;--------------------------------------------------------------------
|
---|
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.bFlagsLow], FLGL_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.bFlagsLow]
|
---|
55 | and bx, BYTE MASKL_DPT_ADDRESSING_MODE
|
---|
56 | eSHR_IM bx, ADDRESSING_MODE_FIELD_POSITION-1
|
---|
57 | ret
|
---|
58 |
|
---|
59 |
|
---|
60 | ;--------------------------------------------------------------------
|
---|
61 | ; AccessDPT_GetLCHSfromPCHS
|
---|
62 | ; Parameters:
|
---|
63 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
64 | ; Returns:
|
---|
65 | ; AX: Number of L-CHS sectors per track
|
---|
66 | ; BX: Number of L-CHS cylinders
|
---|
67 | ; DX: Number of L-CHS heads
|
---|
68 | ; Corrupts registers:
|
---|
69 | ; Nothing
|
---|
70 | ;--------------------------------------------------------------------
|
---|
71 | ALIGN JUMP_ALIGN
|
---|
72 | AccessDPT_GetLCHSfromPCHS:
|
---|
73 | mov al, [di+DPT.bFlagsLow]
|
---|
74 | and al, MASKL_DPT_CHS_SHIFT_COUNT ; Load shift count
|
---|
75 | xchg cx, ax
|
---|
76 | mov bx, [di+DPT.wPchsCylinders] ; Load P-CHS cylinders
|
---|
77 | shr bx, cl ; Shift to L-CHS cylinders
|
---|
78 | xchg cx, ax
|
---|
79 | eMOVZX ax, BYTE [di+DPT.bPchsSectors] ; Load Sectors per track
|
---|
80 | cwd
|
---|
81 | mov dl, [di+DPT.bLchsHeads] ; Load L-CHS heads
|
---|
82 | ret
|
---|
83 |
|
---|
84 |
|
---|
85 | ;--------------------------------------------------------------------
|
---|
86 | ; AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
|
---|
87 | ; Parameters:
|
---|
88 | ; AX: Bitmask to test DRVPARAMS.wFlags
|
---|
89 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
90 | ; Returns:
|
---|
91 | ; ZF: Set if tested bit was zero
|
---|
92 | ; Cleared if tested bit was non-zero
|
---|
93 | ; CF: 0
|
---|
94 | ; Corrupts registers:
|
---|
95 | ; BX
|
---|
96 | ;--------------------------------------------------------------------
|
---|
97 | ALIGN JUMP_ALIGN
|
---|
98 | AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive:
|
---|
99 | call AccessDPT_GetPointerToDRVPARAMStoCSBX
|
---|
100 | test [cs:bx+DRVPARAMS.wFlags], ax
|
---|
101 | ret
|
---|
102 |
|
---|
103 | ;--------------------------------------------------------------------
|
---|
104 | ; Returns pointer to DRVPARAMS for master or slave drive.
|
---|
105 | ;
|
---|
106 | ; AccessDPT_GetPointerToDRVPARAMStoCSBX
|
---|
107 | ; Parameters:
|
---|
108 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
109 | ; Returns:
|
---|
110 | ; CS:BX: Ptr to DRVPARAMS
|
---|
111 | ; Corrupts registers:
|
---|
112 | ; Nothing
|
---|
113 | ;--------------------------------------------------------------------
|
---|
114 | ALIGN JUMP_ALIGN
|
---|
115 | AccessDPT_GetPointerToDRVPARAMStoCSBX:
|
---|
116 | eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS
|
---|
117 | add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS
|
---|
118 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
|
---|
119 | jz SHORT .ReturnPointerToDRVPARAMS
|
---|
120 | add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS
|
---|
121 | .ReturnPointerToDRVPARAMS:
|
---|
122 | ret
|
---|