source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm@ 156

Last change on this file since 156 was 150, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Redesigned Disk Parameter Tables.
  • Code generalizations for supporting non-IDE devices in the future.
File size: 3.8 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for accessing DPT data.
3
4; Section containing code
5SECTION .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;--------------------------------------------------------------------
16ALIGN JUMP_ALIGN
17AccessDPT_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;--------------------------------------------------------------------
33ALIGN JUMP_ALIGN
34AccessDPT_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;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53AccessDPT_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;--------------------------------------------------------------------
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;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72AccessDPT_GetLCHSfromPCHS:
73 xchg ax, cx
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
78 xchg cx, ax
79 eMOVZX dx, BYTE [di+DPT.bLchsHeads] ; Load L-CHS heads
80 eMOVZX ax, BYTE [di+DPT.bPchsSectors] ; Load Sectors per track
81 ret
82
83
84;--------------------------------------------------------------------
85; AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
86; Parameters:
87; AX: Bitmask to test DRVPARAMS.wFlags
88; DS:DI: Ptr to Disk Parameter Table
89; Returns:
90; ZF: Set if tested bit was zero
91; Cleared if tested bit was non-zero
92; CF: 0
93; Corrupts registers:
94; BX
95;--------------------------------------------------------------------
96ALIGN JUMP_ALIGN
97AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive:
98 call AccessDPT_GetPointerToDRVPARAMStoCSBX
99 test [cs:bx+DRVPARAMS.wFlags], ax
100 ret
101
102;--------------------------------------------------------------------
103; Returns pointer to DRVPARAMS for master or slave drive.
104;
105; AccessDPT_GetPointerToDRVPARAMStoCSBX
106; Parameters:
107; DS:DI: Ptr to Disk Parameter Table
108; Returns:
109; CS:BX: Ptr to DRVPARAMS
110; Corrupts registers:
111; Nothing
112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114AccessDPT_GetPointerToDRVPARAMStoCSBX:
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:
121 ret
Note: See TracBrowser for help on using the repository browser.