source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm @ 167

Last change on this file since 167 was 167, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Old Int 13h transfer functions work again.
  • Fixes to eINT13h (EBIOS) support.
File size: 4.6 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Functions for managing IDEPACK struct.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Idepack_FakeToSSBP
9;   Parameters:
10;       Nothing
11;   Returns:
12;       SS:BP:  Ptr to IDEPACK
13;   Corrupts registers:
14;       AX
15;--------------------------------------------------------------------
16Idepack_FakeToSSBP:
17    pop     ax
18    sub     sp, BYTE EXTRA_BYTES_FOR_INTPACK
19    mov     bp, sp
20    jmp     ax
21
22
23;--------------------------------------------------------------------
24; Idepack_ConvertDapToIdepackAndIssueCommandFromAH
25;   Parameters:
26;       AH:     IDE command to issue
27;       BH:     Timeout ticks
28;       BL:     IDE Status Register flag to wait after command
29;       DS:DI:  Ptr to DPT (in RAMVARS segment)
30;       ES:SI:  Ptr to DAP (EBIOS Disk Address Packet)
31;       SS:BP:  Ptr to IDEPACK
32;   Returns:
33;       AH:     INT 13h Error Code
34;       CF:     Cleared if success, Set if error
35;   Corrupts registers:
36;       AL, BX, CX, DX, SI, ES
37;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
39Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
40    mov     [bp+IDEPACK.bCommand], ah
41    mov     al, [es:si+DAP.wSectorCount]
42    mov     [bp+IDEPACK.bSectorCount], al
43
44    mov     al, [es:si+DAP.qwLBA]       ; LBA byte 0
45    mov     [bp+IDEPACK.bLbaLow], al
46    mov     ax, [es:si+DAP.qwLBA+1]     ; LBA bytes 1 and 2
47    mov     [bp+IDEPACK.wLbaMiddleAndHigh], ax
48    mov     ah, [es:si+DAP.qwLBA+3]     ; LBA byte 3, LBA28 bits 24...27
49    mov     [bp+IDEPACK.bLbaLowExt], ah
50    mov     cx, [es:si+DAP.qwLBA+4]     ; LBA bytes 4 and 5
51    mov     [bp+IDEPACK.wLbaMiddleAndHighExt], cx
52
53    and     ah, 0Fh                     ; Limit bits for LBA28
54    call    AccessDPT_GetDriveSelectByteToAL
55    or      al, ah
56    mov     [bp+IDEPACK.bDrvAndHead], al
57    les     si, [es:si+DAP.dwMemoryAddress]
58    jmp     SHORT GetDeviceControlByteToIdepackAndStartTransfer
59
60
61;--------------------------------------------------------------------
62; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
63;   Parameters:
64;       AH:     IDE command to issue
65;       AL:     Number of sectors to transfer (1...255, 0=256)
66;       BH:     Timeout ticks
67;       BL:     IDE Status Register flag to wait after command
68;       CH:     Cylinder number, bits 7...0
69;       CL:     Bits 7...6: Cylinder number bits 9 and 8
70;               Bits 5...0: Starting sector number (1...63)
71;       DH:     Starting head number (0...255)
72;       ES:SI:  Ptr to data buffer
73;       DS:DI:  Ptr to DPT (in RAMVARS segment)
74;       SS:BP:  Ptr to IDEPACK
75;   Returns:
76;       AH:     INT 13h Error Code
77;       CF:     Cleared if success, Set if error
78;   Corrupts registers:
79;       AL, BX, CX, DX
80;--------------------------------------------------------------------
81ALIGN JUMP_ALIGN
82Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
83    mov     [bp+IDEPACK.bSectorCount], al
84    mov     [bp+IDEPACK.bCommand], ah
85
86    push    bx
87    call    Address_OldInt13hAddressToIdeAddress
88    call    AccessDPT_GetDriveSelectByteToAL
89    or      al, bh          ; AL now has Drive and Head Select Byte
90    mov     [bp+IDEPACK.bDrvAndHead], al
91    mov     [bp+IDEPACK.bLbaLow], bl
92    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
93    pop     bx
94
95GetDeviceControlByteToIdepackAndStartTransfer:
96    call    AccessDPT_GetDeviceControlByteToAL
97    mov     [bp+IDEPACK.bDeviceControl], al
98    jmp     Device_OutputCommandWithParameters 
99
100
101;--------------------------------------------------------------------
102; Idepack_StoreNonExtParametersAndIssueCommandFromAL
103;   Parameters:
104;       BH:     Timeout ticks
105;       BL:     IDE Status Register flag to wait after command
106;       AL:     IDE command to issue
107;       AH:     Parameter to Drive and Head Select Register (Head bits only)
108;       DL:     Parameter to Sector Count Register
109;       DH:     Parameter to LBA Low / Sector Number Register
110;       CL:     Parameter to LBA Middle / Cylinder Low Register
111;       CH:     Parameter to LBA High / Cylinder High Register
112;       SI:     Parameter to Features Register
113;       DS:DI:  Ptr to DPT (in RAMVARS segment)
114;       SS:BP:  Ptr to IDEPACK
115;   Returns:
116;       AH:     INT 13h Error Code
117;       CF:     Cleared if success, Set if error
118;   Corrupts registers:
119;       AL, BX, CX, DX
120;--------------------------------------------------------------------
121ALIGN JUMP_ALIGN
122Idepack_StoreNonExtParametersAndIssueCommandFromAL:
123    mov     [bp+IDEPACK.bFeatures], si
124    mov     [bp+IDEPACK.bCommand], al
125    mov     [bp+IDEPACK.wSectorCountAndLbaLow], dx
126    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
127
128    ; Drive and Head select byte
129    and     ah, MASK_DRVNHEAD_HEAD      ; Keep head bits only
130    call    AccessDPT_GetDriveSelectByteToAL
131    or      al, ah
132    mov     [bp+IDEPACK.bDrvAndHead], al
133
134    ; Device Control byte with interrupts disabled
135    call    AccessDPT_GetDeviceControlByteToAL
136    or      al, FLG_DEVCONTROL_nIEN     ; Disable interrupt
137    mov     [bp+IDEPACK.bDeviceControl], al
138
139    jmp     Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.