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

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

Changes to XTIDE Universal BIOS:

  • AH=0Ch (Seek) should work properly again.
  • More than 127 sectors are no longer allowed for EBIOS functions.
  • Changed location for BOOTNFO structs.
File size: 4.9 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;       AL:     Number of sectors to transfer (for xfer commands)
28;       BH:     Timeout ticks
29;       BL:     IDE Status Register flag to wait after command
30;       DS:DI:  Ptr to DPT (in RAMVARS segment)
31;       ES:SI:  Ptr to DAP (EBIOS Disk Address Packet)
32;       SS:BP:  Ptr to IDEPACK
33;   Returns:
34;       AH:     INT 13h Error Code
35;       CF:     Cleared if success, Set if error
36;   Corrupts registers:
37;       AL, BX, CX, DX, SI, ES
38;--------------------------------------------------------------------
39%ifdef MODULE_EBIOS
40ALIGN JUMP_ALIGN
41Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
42    mov     [bp+IDEPACK.bSectorCount], al
43    mov     [bp+IDEPACK.bCommand], ah
44
45    mov     al, [es:si+DAP.qwLBA]       ; LBA byte 0
46    mov     [bp+IDEPACK.bLbaLow], al
47    mov     ax, [es:si+DAP.qwLBA+1]     ; LBA bytes 1 and 2
48    mov     [bp+IDEPACK.wLbaMiddleAndHigh], ax
49    mov     ah, [es:si+DAP.qwLBA+3]     ; LBA byte 3, LBA28 bits 24...27
50    mov     [bp+IDEPACK.bLbaLowExt], ah
51    mov     cx, [es:si+DAP.qwLBA+4]     ; LBA bytes 4 and 5
52    mov     [bp+IDEPACK.wLbaMiddleAndHighExt], cx
53
54    and     ah, 0Fh                     ; Limit bits for LBA28
55    call    AccessDPT_GetDriveSelectByteToAL
56    or      al, ah
57    mov     [bp+IDEPACK.bDrvAndHead], al
58
59    ; Normalize data buffer pointer to ES:SI
60    mov     ax, [es:si+DAP.dwMemoryAddress]     ; Load offset
61    mov     cx, ax
62    eSHR_IM ax, 4                               ; Divide offset by 16
63    add     ax, [es:si+DAP.dwMemoryAddress+2]   ; Add segment
64    mov     es, ax                              ; Segment normalized
65    mov     si, cx
66    and     si, BYTE 0Fh                        ; Offset normalized
67    jmp     SHORT GetDeviceControlByteToIdepackAndStartTransfer
68%endif
69
70
71;--------------------------------------------------------------------
72; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
73;   Parameters:
74;       AH:     IDE command to issue
75;       AL:     Number of sectors to transfer (for xfer commands)
76;       BH:     Timeout ticks
77;       BL:     IDE Status Register flag to wait after command
78;       CH:     Cylinder number, bits 7...0
79;       CL:     Bits 7...6: Cylinder number bits 9 and 8
80;               Bits 5...0: Starting sector number (1...63)
81;       DH:     Starting head number (0...255)
82;       DS:DI:  Ptr to DPT (in RAMVARS segment)
83;       ES:SI:  Ptr to normalized data buffer (for xfer commands)
84;       SS:BP:  Ptr to IDEPACK (containing INTPACK)
85;   Returns:
86;       AH:     INT 13h Error Code
87;       CF:     Cleared if success, Set if error
88;   Corrupts registers:
89;       AL, BX, CX, DX
90;--------------------------------------------------------------------
91ALIGN JUMP_ALIGN
92Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
93    mov     [bp+IDEPACK.bSectorCount], al
94    mov     [bp+IDEPACK.bCommand], ah
95
96    push    bx
97    call    Address_OldInt13hAddressToIdeAddress
98    call    AccessDPT_GetDriveSelectByteToAL
99    or      al, bh          ; AL now has Drive and Head Select Byte
100    mov     [bp+IDEPACK.bDrvAndHead], al
101    mov     [bp+IDEPACK.bLbaLow], bl
102    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
103    pop     bx
104
105GetDeviceControlByteToIdepackAndStartTransfer:
106    call    AccessDPT_GetDeviceControlByteToAL
107    mov     [bp+IDEPACK.bDeviceControl], al
108    jmp     Device_OutputCommandWithParameters
109
110
111;--------------------------------------------------------------------
112; Idepack_StoreNonExtParametersAndIssueCommandFromAL
113;   Parameters:
114;       BH:     Timeout ticks
115;       BL:     IDE Status Register flag to wait after command
116;       AL:     IDE command to issue
117;       AH:     Parameter to Drive and Head Select Register (Head bits only)
118;       DL:     Parameter to Sector Count Register
119;       DH:     Parameter to LBA Low / Sector Number Register
120;       CL:     Parameter to LBA Middle / Cylinder Low Register
121;       CH:     Parameter to LBA High / Cylinder High Register
122;       SI:     Parameter to Features Register
123;       DS:DI:  Ptr to DPT (in RAMVARS segment)
124;       SS:BP:  Ptr to IDEPACK
125;   Returns:
126;       AH:     INT 13h Error Code
127;       CF:     Cleared if success, Set if error
128;   Corrupts registers:
129;       AL, BX, CX, DX
130;--------------------------------------------------------------------
131ALIGN JUMP_ALIGN
132Idepack_StoreNonExtParametersAndIssueCommandFromAL:
133    mov     [bp+IDEPACK.bFeatures], si
134    mov     [bp+IDEPACK.bCommand], al
135    mov     [bp+IDEPACK.wSectorCountAndLbaLow], dx
136    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
137
138    ; Drive and Head select byte
139    and     ah, MASK_DRVNHEAD_HEAD      ; Keep head bits only
140    call    AccessDPT_GetDriveSelectByteToAL
141    or      al, ah
142    mov     [bp+IDEPACK.bDrvAndHead], al
143
144    ; Device Control byte with interrupts disabled
145    call    AccessDPT_GetDeviceControlByteToAL
146    or      al, FLG_DEVCONTROL_nIEN     ; Disable interrupt
147    mov     [bp+IDEPACK.bDeviceControl], al
148
149    jmp     Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.