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

Last change on this file since 146 was 128, checked in by krille_n_@…, 14 years ago

Changes to the XTIDE Universal BIOS:

  • Size optimizations in various files.
File size: 6.5 KB
RevLine 
[99]1; Project name : XTIDE Universal BIOS
[3]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;--------------------------------------------------------------------
[35]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;--------------------------------------------------------------------
[3]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:
[126]97 mov ah, 80h ; Assume hard disk
[3]98 mov al, BYTE [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
[126]99 test dl, ah ; Hard disk?
100 jnz SHORT SwapDrive ; If so, jump to swap
101 mov al, BYTE [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
102 cbw
[99]103 ; Fall to SwapDrive
[3]104
105;--------------------------------------------------------------------
[99]106; SwapDrive
[3]107; Parameters:
108; AL: Drive number to swap to 00h/80h
109; AH: 00h/80h to be swapped to stored drive number
110; DL: Drive number to be possibly swapped
111; Returns:
112; DL: Translated drive number
113; Corrupts registers:
114; Nothing
115;--------------------------------------------------------------------
[126]116ALIGN JUMP_ALIGN
[99]117SwapDrive:
[3]118 cmp ah, dl ; Swap DL from 00h/80h to xxh?
119 je SHORT .SwapToXXhInAL
120 cmp al, dl ; Swap DL from xxh to 00h/80h?
121 je SHORT .SwapTo00hOr80hInAH
122 ret
123ALIGN JUMP_ALIGN
124.SwapTo00hOr80hInAH:
125 mov dl, ah
126 ret
127ALIGN JUMP_ALIGN
128.SwapToXXhInAL:
129 mov dl, al
130 ret
131
132
133;--------------------------------------------------------------------
134; Resets drive swapping variables to defaults (no swapping).
135;
136; DriveXlate_Reset
137; Parameters:
138; DS: RAMVARS segment
139; Returns:
140; Nothing
141; Corrupts registers:
142; AX
[128]143;--------------------------------------------------------------------
[3]144ALIGN JUMP_ALIGN
145DriveXlate_Reset:
146 mov WORD [RAMVARS.xlateVars], 8000h ; .bFDSwap and .bHDSwap
147 mov BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt], 0
148 ret
149
150
151;--------------------------------------------------------------------
152; Stores drive to be swapped.
153;
154; DriveXlate_SetDriveToSwap
155; Parameters:
156; DL: Drive to swap to 00h or 80h
157; DS: RAMVARS segment
158; Returns:
159; Nothing
160; Corrupts registers:
161; Nothing
[128]162;--------------------------------------------------------------------
[3]163ALIGN JUMP_ALIGN
164DriveXlate_SetDriveToSwap:
[128]165 test dl, dl ; Floppy drive?
166 js SHORT .SetHardDiskToSwap
[99]167.SetFloppyDriveToSwap:
[3]168 mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
169 ret
170ALIGN JUMP_ALIGN
[99]171.SetHardDiskToSwap:
[3]172 mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
173 ret
174
175
176;--------------------------------------------------------------------
177; Checks if INT 13h function returns some value in DL
178; (other than the drive number that was also parameter).
179;
180; DriveXlate_DoesFunctionReturnSomethingInDL
181; Parameters:
182; AH: INT 13h BIOS Function
183; DL: Drive number
184; Returns:
185; CF: Set if something is returned in DL
186; Cleared if only drive number parameter is returned in DL
187; Corrupts registers:
188; Nothing
[128]189;--------------------------------------------------------------------
[3]190ALIGN JUMP_ALIGN
191DriveXlate_DoesFunctionReturnSomethingInDL:
192 cmp ah, 08h ; AH=08h, Read Disk Drive Parameters?
193 je SHORT DriveXlate_FunctionReturnsSomethingInDL
[128]194 test dl, dl
195 jns SHORT DriveXlate_DoesFloppyFunctionReturnSomethingInDL
[3]196 ; Fall to DriveXlate_DoesHardDiskFunctionReturnSomethingInDL
197
198;--------------------------------------------------------------------
199; Checks if INT 13h hard disk or floppy drive function returns some
200; value in DL other than the drive number that was also parameter).
201; Some functions return different values for hard disks and floppy drives.
202;
203; DriveXlate_DoesHardDiskFunctionReturnSomethingInDL
204; DriveXlate_DoesFloppyFunctionReturnSomethingInDL
205; Parameters:
206; AH: INT 13h BIOS Function
207; DL: Hard Disk number
208; Returns:
209; CF: Set if something is returned in DL
210; Cleared if only drive number parameter is returned in DL
211; Corrupts registers:
212; Nothing
[128]213;--------------------------------------------------------------------
[3]214; ALIGN JUMP_ALIGN
215DriveXlate_DoesHardDiskFunctionReturnSomethingInDL:
216 cmp ah, 15h ; AH=15h, Read Disk Drive Size?
217 je SHORT DriveXlate_FunctionReturnsSomethingInDL
218DriveXlate_DoesFloppyFunctionReturnSomethingInDL:
219 clc
220 ret
221
222ALIGN JUMP_ALIGN
223DriveXlate_FunctionReturnsSomethingInDL:
224 stc
225 ret
Note: See TracBrowser for help on using the repository browser.