source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/DriveXlate.asm @ 99

Last change on this file since 99 was 99, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

  • Even more initialization code inlining.
File size: 7.2 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Functions for swapping drive letters.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Translates drive number when entering INT 13h.
9;
10; DriveXlate_WhenEnteringInt13h
11;   Parameters:
12;       DL:     Drive number to be possibly translated
13;       DS:     RAMVARS segment
14;   Returns:
15;       DL:     Translated drive number
16;   Corrupts registers:
17;       DI
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20DriveXlate_WhenEnteringInt13h:
21    inc     BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
22    cmp     BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt], 1
23    je      SHORT DriveXlate_ToOrBack
24    ret
25
26
27;--------------------------------------------------------------------
28; DriveXlate_WhenLeavingInt13hWithReturnValueInDL
29;   Parameters:
30;       DS:     RAMVARS segment
31;   Returns:
32;       Nothing
33;   Corrupts registers:
34;       DI
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37DriveXlate_WhenLeavingInt13hWithReturnValueInDL:
38    dec     BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
39    ret
40
41;--------------------------------------------------------------------
42; Translates drive number when leaving INT 13h.
43;
44; DriveXlate_WhenLeavingInt13h
45;   Parameters:
46;       DL:     Drive number to be possibly translated
47;       DS:     RAMVARS segment
48;   Returns:
49;       DL:     Translated drive number
50;   Corrupts registers:
51;       DI
52;--------------------------------------------------------------------
53ALIGN JUMP_ALIGN
54DriveXlate_WhenLeavingInt13h:
55    dec     BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
56    jz      SHORT DriveXlate_ToOrBack
57    ret
58
59
60;--------------------------------------------------------------------
61; Translates drive number to or back.
62;
63; DriveXlate_ToOrBack
64;   Parameters:
65;       DL:     Drive number to be possibly translated
66;       DS:     RAMVARS segment
67;   Returns:
68;       DL:     Translated drive number
69;   Corrupts registers:
70;       DI
71;--------------------------------------------------------------------
72ALIGN JUMP_ALIGN
73DriveXlate_ToOrBack:
74    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_DRVXLAT
75    jz      SHORT .Return           ; Return if translation disabled
76    xchg    di, ax                  ; Backup AX
77    call    DriveXlate_SwapFloppyDriveOrHardDisk
78    xchg    ax, di
79.Return:
80    ret
81
82
83;--------------------------------------------------------------------
84; Swaps Floppy Drive or Hard Disk number.
85;
86; DriveXlate_SwapFloppyDriveOrHardDisk
87;   Parameters:
88;       DL:     Drive number to be possibly swapped
89;       DS:     RAMVARS segment
90;   Returns:
91;       DL:     Translated drive number
92;   Corrupts registers:
93;       AX
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
96DriveXlate_SwapFloppyDriveOrHardDisk:
97    test    dl, 80h                         ; Hard disk?
98    jnz     SHORT .SwapHardDisk ; If so, jump to swap
99    ; Fall to .SwapFloppyDrive
100
101;--------------------------------------------------------------------
102; .SwapFloppyDrive
103;   Parameters:
104;       DL:     Drive number to be possibly swapped
105;       DS:     RAMVARS segment
106;   Returns:
107;       DL:     Translated drive number
108;   Corrupts registers:
109;       AX
110;--------------------------------------------------------------------
111.SwapFloppyDrive:
112    eMOVZX  ax, BYTE [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
113    jmp     SHORT SwapDrive
114
115;--------------------------------------------------------------------
116; .SwapHardDisk
117;   Parameters:
118;       DL:     Drive number to be possibly swapped
119;       DS:     RAMVARS segment
120;   Returns:
121;       DL:     Translated drive number
122;   Corrupts registers:
123;       AX
124;--------------------------------------------------------------------
125ALIGN JUMP_ALIGN
126.SwapHardDisk:
127    mov     ah, 80h
128    mov     al, BYTE [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
129    ; Fall to SwapDrive
130
131;--------------------------------------------------------------------
132; SwapDrive
133;   Parameters:
134;       AL:     Drive number to swap to 00h/80h
135;       AH:     00h/80h to be swapped to stored drive number
136;       DL:     Drive number to be possibly swapped
137;   Returns:
138;       DL:     Translated drive number
139;   Corrupts registers:
140;       Nothing
141;--------------------------------------------------------------------
142SwapDrive:
143    cmp     ah, dl              ; Swap DL from 00h/80h to xxh?
144    je      SHORT .SwapToXXhInAL
145    cmp     al, dl              ; Swap DL from xxh to 00h/80h?
146    je      SHORT .SwapTo00hOr80hInAH
147    ret
148ALIGN JUMP_ALIGN
149.SwapTo00hOr80hInAH:
150    mov     dl, ah
151    ret
152ALIGN JUMP_ALIGN
153.SwapToXXhInAL:
154    mov     dl, al
155    ret
156
157
158;--------------------------------------------------------------------
159; Resets drive swapping variables to defaults (no swapping).
160;
161; DriveXlate_Reset
162;   Parameters:
163;       DS:     RAMVARS segment
164;   Returns:
165;       Nothing
166;   Corrupts registers:
167;       AX
168;--------------------------------------------------------------------   
169ALIGN JUMP_ALIGN
170DriveXlate_Reset:
171    mov     WORD [RAMVARS.xlateVars], 8000h ; .bFDSwap and .bHDSwap
172    mov     BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt], 0
173    ret
174
175
176;--------------------------------------------------------------------
177; Stores drive to be swapped.
178;
179; DriveXlate_SetDriveToSwap
180;   Parameters:
181;       DL:     Drive to swap to 00h or 80h
182;       DS:     RAMVARS segment
183;   Returns:
184;       Nothing
185;   Corrupts registers:
186;       Nothing
187;--------------------------------------------------------------------   
188ALIGN JUMP_ALIGN
189DriveXlate_SetDriveToSwap:
190    test    dl, 80h             ; Floppy drive?
191    jnz     SHORT .SetHardDiskToSwap
192.SetFloppyDriveToSwap:
193    mov     [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
194    ret
195ALIGN JUMP_ALIGN
196.SetHardDiskToSwap:
197    mov     [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
198    ret
199
200
201;--------------------------------------------------------------------
202; Checks if INT 13h function returns some value in DL
203; (other than the drive number that was also parameter).
204;
205; DriveXlate_DoesFunctionReturnSomethingInDL
206;   Parameters:
207;       AH:     INT 13h BIOS Function
208;       DL:     Drive number
209;   Returns:
210;       CF:     Set if something is returned in DL
211;               Cleared if only drive number parameter is returned in DL
212;   Corrupts registers:
213;       Nothing
214;--------------------------------------------------------------------   
215ALIGN JUMP_ALIGN
216DriveXlate_DoesFunctionReturnSomethingInDL:
217    cmp     ah, 08h         ; AH=08h, Read Disk Drive Parameters?
218    je      SHORT DriveXlate_FunctionReturnsSomethingInDL
219    test    dl, 80h
220    jz      SHORT DriveXlate_DoesFloppyFunctionReturnSomethingInDL
221    ; Fall to DriveXlate_DoesHardDiskFunctionReturnSomethingInDL
222
223;--------------------------------------------------------------------
224; Checks if INT 13h hard disk or floppy drive function returns some
225; value in DL other than the drive number that was also parameter).
226; Some functions return different values for hard disks and floppy drives.
227;
228; DriveXlate_DoesHardDiskFunctionReturnSomethingInDL
229; DriveXlate_DoesFloppyFunctionReturnSomethingInDL
230;   Parameters:
231;       AH:     INT 13h BIOS Function
232;       DL:     Hard Disk number
233;   Returns:
234;       CF:     Set if something is returned in DL
235;               Cleared if only drive number parameter is returned in DL
236;   Corrupts registers:
237;       Nothing
238;--------------------------------------------------------------------   
239; ALIGN JUMP_ALIGN
240DriveXlate_DoesHardDiskFunctionReturnSomethingInDL:
241    cmp     ah, 15h         ; AH=15h, Read Disk Drive Size?
242    je      SHORT DriveXlate_FunctionReturnsSomethingInDL
243DriveXlate_DoesFloppyFunctionReturnSomethingInDL:
244    clc
245    ret
246
247ALIGN JUMP_ALIGN
248DriveXlate_FunctionReturnsSomethingInDL:
249    stc
250    ret
Note: See TracBrowser for help on using the repository browser.