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

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

Changes to XTIDE Universal BIOS:

  • Old Int 13h functions can now transfer 256 sectors per call.
  • eINT 13h functions can now transfer 65535 sectors per call.
File size: 4.7 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     ax, [es:si+DAP.wSectorCount]
42    mov     [bp+IDEPACK.bSectorCount], al
43    mov     [bp+IDEPACK.bSectorCountHighExt], 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    les     si, [es:si+DAP.dwMemoryAddress]
59    jmp     SHORT GetDeviceControlByteToIdepackAndStartTransfer
60
61
62;--------------------------------------------------------------------
63; Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
64;   Parameters:
65;       AH:     IDE command to issue
66;       AL:     Number of sectors to transfer (1...255, 0=256)
67;       BH:     Timeout ticks
68;       BL:     IDE Status Register flag to wait after command
69;       CH:     Cylinder number, bits 7...0
70;       CL:     Bits 7...6: Cylinder number bits 9 and 8
71;               Bits 5...0: Starting sector number (1...63)
72;       DH:     Starting head number (0...255)
73;       ES:SI:  Ptr to data buffer
74;       DS:DI:  Ptr to DPT (in RAMVARS segment)
75;       SS:BP:  Ptr to IDEPACK
76;   Returns:
77;       AH:     INT 13h Error Code
78;       CF:     Cleared if success, Set if error
79;   Corrupts registers:
80;       AL, BX, CX, DX
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
84    mov     [bp+IDEPACK.bCommand], ah
85    test    al, al
86    eCSETZ  ah
87    mov     [bp+IDEPACK.bSectorCount], al
88    mov     [bp+IDEPACK.bSectorCountHighExt], ah
89
90    push    bx
91    call    Address_OldInt13hAddressToIdeAddress
92    call    AccessDPT_GetDriveSelectByteToAL
93    or      al, bh          ; AL now has Drive and Head Select Byte
94    mov     [bp+IDEPACK.bDrvAndHead], al
95    mov     [bp+IDEPACK.bLbaLow], bl
96    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
97    pop     bx
98
99GetDeviceControlByteToIdepackAndStartTransfer:
100    call    AccessDPT_GetDeviceControlByteToAL
101    mov     [bp+IDEPACK.bDeviceControl], al
102    jmp     Device_OutputCommandWithParameters 
103
104
105;--------------------------------------------------------------------
106; Idepack_StoreNonExtParametersAndIssueCommandFromAL
107;   Parameters:
108;       BH:     Timeout ticks
109;       BL:     IDE Status Register flag to wait after command
110;       AL:     IDE command to issue
111;       AH:     Parameter to Drive and Head Select Register (Head bits only)
112;       DL:     Parameter to Sector Count Register
113;       DH:     Parameter to LBA Low / Sector Number Register
114;       CL:     Parameter to LBA Middle / Cylinder Low Register
115;       CH:     Parameter to LBA High / Cylinder High Register
116;       SI:     Parameter to Features Register
117;       DS:DI:  Ptr to DPT (in RAMVARS segment)
118;       SS:BP:  Ptr to IDEPACK
119;   Returns:
120;       AH:     INT 13h Error Code
121;       CF:     Cleared if success, Set if error
122;   Corrupts registers:
123;       AL, BX, CX, DX
124;--------------------------------------------------------------------
125ALIGN JUMP_ALIGN
126Idepack_StoreNonExtParametersAndIssueCommandFromAL:
127    mov     [bp+IDEPACK.bFeatures], si
128    mov     [bp+IDEPACK.bCommand], al
129    mov     [bp+IDEPACK.wSectorCountAndLbaLow], dx
130    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
131    mov     BYTE [bp+IDEPACK.bSectorCountHighExt], 0
132
133    ; Drive and Head select byte
134    and     ah, MASK_DRVNHEAD_HEAD      ; Keep head bits only
135    call    AccessDPT_GetDriveSelectByteToAL
136    or      al, ah
137    mov     [bp+IDEPACK.bDrvAndHead], al
138
139    ; Device Control byte with interrupts disabled
140    call    AccessDPT_GetDeviceControlByteToAL
141    or      al, FLG_DEVCONTROL_nIEN     ; Disable interrupt
142    mov     [bp+IDEPACK.bDeviceControl], al
143
144    jmp     Device_OutputCommandWithParameters
Note: See TracBrowser for help on using the repository browser.