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

Last change on this file since 168 was 161, checked in by krille_n_@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Minor size optimizations.
  • Tried to minimize the time spent with interrupts disabled in IdeIrq.asm and Int13h.asm
File size: 3.8 KB
RevLine 
[99]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for accessing DPT data.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
[150]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
[158]36 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ
[150]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:
[158]54 mov bl, [di+DPT.bFlagsLow]
55 and bx, BYTE MASKL_DPT_ADDRESSING_MODE
[150]56 eSHR_IM bx, ADDRESSING_MODE_FIELD_POSITION-1
57 ret
58
59
60;--------------------------------------------------------------------
[3]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:
[161]73 mov al, [di+DPT.bFlagsLow]
74 and al, MASKL_DPT_CHS_SHIFT_COUNT ; Load shift count
75 xchg cx, ax
[150]76 mov bx, [di+DPT.wPchsCylinders] ; Load P-CHS cylinders
77 shr bx, cl ; Shift to L-CHS cylinders
[3]78 xchg cx, ax
[150]79 eMOVZX ax, BYTE [di+DPT.bPchsSectors] ; Load Sectors per track
[161]80 cwd
81 mov dl, [di+DPT.bLchsHeads] ; Load L-CHS heads
[3]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;--------------------------------------------------------------------
97ALIGN JUMP_ALIGN
98AccessDPT_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;--------------------------------------------------------------------
114ALIGN JUMP_ALIGN
115AccessDPT_GetPointerToDRVPARAMStoCSBX:
[150]116 eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS
117 add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS
[158]118 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
[150]119 jz SHORT .ReturnPointerToDRVPARAMS
120 add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS
121.ReturnPointerToDRVPARAMS:
[3]122 ret
Note: See TracBrowser for help on using the repository browser.