source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Menus/DriveXlate.asm@ 551

Last change on this file since 551 was 550, checked in by aitotat@…, 11 years ago

Changes to XTIDE Universal BIOS:

  • CREATE_COMPATIBLE_DPT is now MODULE_COMPATIBLE_TABLES.
  • DPTs pointed by INT 41h and INT 46h are now swapped when swapping drives 81h and 80h.
  • Block mode commands are no longer used when block size is set to 1 with AH=24h.
File size: 5.0 KB
RevLine 
[395]1; Project name : XTIDE Universal BIOS
2; Description : Functions for swapping drive letters.
3
4;
[505]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[395]7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
[505]12;
[395]13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[505]16; GNU General Public License for more details.
[395]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[505]18;
[395]19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
[492]24; DriveXlate_ConvertDriveLetterInDLtoDriveNumber
25; Parameters:
26; DS: RAMVARS segment
27; DL: Drive letter ('A'...)
28; Returns:
29; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
30; Corrupts registers:
31; AX
32;--------------------------------------------------------------------
33DriveXlate_ConvertDriveLetterInDLtoDriveNumber:
[547]34 call BootVars_GetLetterForFirstHardDriveToAX
[492]35 cmp dl, al
36 jb SHORT .ConvertLetterInDLtoFloppyDriveNumber
37
38 ; Convert letter in DL to Hard Drive number
39 sub dl, al
40 or dl, 80h
41 ret
42
43.ConvertLetterInDLtoFloppyDriveNumber:
44 sub dl, DEFAULT_FLOPPY_DRIVE_LETTER
45 ret
46
47%ifdef MODULE_HOTKEY
48%if HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber <> DriveXlate_ConvertDriveLetterInDLtoDriveNumber
49 %error "DriveXlate_ConvertDriveLetterInDLtoDriveNumber must be at the top of DriveXlate.asm, and that file must immediately follow HotKeys.asm"
50%endif
[505]51%endif
52
[492]53;--------------------------------------------------------------------
54; DriveXlate_ConvertDriveNumberFromDLtoDriveLetter
55; Parameters:
56; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
57; DS: RAMVARS Segment
58; Returns:
59; DL: Drive letter ('A'...)
60; CF: Set if Hard Drive
61; Clear if Floppy Drive
62; Corrupts registers:
63; AX
64;--------------------------------------------------------------------
65DriveXlate_ConvertDriveNumberFromDLtoDriveLetter:
[505]66 xor dl, 80h
67 js SHORT .GetDefaultFloppyDrive
[492]68
69 ; Store default hard drive to boot from
[547]70 call BootVars_GetLetterForFirstHardDriveToAX
[492]71 add dl, al
72 stc
73 ret
74
75.GetDefaultFloppyDrive:
[505]76 sub dl, 80h - DEFAULT_FLOPPY_DRIVE_LETTER ; Clears CF
[492]77 ret
78
79
80;--------------------------------------------------------------------
[395]81; DriveXlate_ToOrBack
82; Parameters:
83; DL: Drive number to be possibly translated
84; DS: RAMVARS segment
85; Returns:
86; DL: Translated drive number
87; Corrupts registers:
88; DI
89;--------------------------------------------------------------------
90ALIGN JUMP_ALIGN
91DriveXlate_ToOrBack:
92 xchg di, ax ; Backup AX
93
94 mov ah, 80h ; Assume hard disk
95 mov al, [RAMVARS.xlateVars+XLATEVARS.bHDSwap]
96 test dl, ah ; Hard disk?
97 jnz SHORT .SwapDrive ; If so, jump to swap
[550]98
[395]99 mov al, [RAMVARS.xlateVars+XLATEVARS.bFDSwap]
100 cbw
101
102ALIGN JUMP_ALIGN
103.SwapDrive:
104 cmp ah, dl ; Swap DL from 00h/80h to xxh?
105 je SHORT .SwapToXXhInAL
106 cmp al, dl ; Swap DL from xxh to 00h/80h?
107 jne SHORT .RestoreAXandReturn
108 mov al, ah
[550]109
[395]110ALIGN JUMP_ALIGN
111.SwapToXXhInAL:
112 mov dl, al
[550]113
114%ifdef MODULE_COMPATIBLE_TABLES
115 cmp al, 81h
116 jne SHORT .RestoreAXandReturn
117
118 ; Since swapping drive 80h <=> 81h, we need to swap
119 ; DPT pointers in interrupt vectors 41h and 46h.
120 push ds
121 LOAD_BDA_SEGMENT_TO ds, ax
122 mov ax, [HD0_DPT_POINTER_41h*4]
123 xchg [HD1_DPT_POINTER_46h*4], ax
124 mov [HD0_DPT_POINTER_41h*4], ax
125 mov ax, [HD0_DPT_POINTER_41h*4+2]
126 xchg [HD1_DPT_POINTER_46h*4+2], ax
127 mov [HD0_DPT_POINTER_41h*4+2], ax
128 pop ds
129%endif ; MODULE_COMPATIBLE_TABLES
130
[395]131ALIGN JUMP_ALIGN
132.RestoreAXandReturn:
133 xchg ax, di ; Restore AX
134 ret
135
136
137;--------------------------------------------------------------------
138; Resets drive swapping variables to defaults (no swapping).
139;
140; DriveXlate_Reset
141; Parameters:
142; DS: RAMVARS segment
143; Returns:
144; Nothing
145; Corrupts registers:
[528]146; Nothing
[395]147;--------------------------------------------------------------------
148DriveXlate_Reset:
[528]149 mov WORD [RAMVARS.xlateVars+XLATEVARS.wFDandHDswap], 8000h
150 ret
[395]151
[528]152
[395]153;--------------------------------------------------------------------
154; Stores drive to be swapped.
155;
156; DriveXlate_SetDriveToSwap
157; Parameters:
[528]158; DL: Hard Drive to swap to first Hard Drive
159; Floppy Drive to swap to first Floppy Drive
[395]160; DS: RAMVARS segment
161; Returns:
162; Nothing
163; Corrupts registers:
[528]164; Nothing
[395]165;--------------------------------------------------------------------
166DriveXlate_SetDriveToSwap:
167 test dl, dl ; Floppy drive?
[397]168 js SHORT .SetHardDriveToSwap
[528]169
170 ; Set Floppy Drive to swap
171 mov [RAMVARS.xlateVars+XLATEVARS.bFDSwap], dl
172 ret
173
[505]174.SetHardDriveToSwap:
[528]175 mov [RAMVARS.xlateVars+XLATEVARS.bHDSwap], dl
[395]176 ret
Note: See TracBrowser for help on using the repository browser.