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

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

Made a module around the EBIOS code, so that it can be turned off to make room for serial code, still enabled by default in the Makefile

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