source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/Prepare.asm@ 619

Last change on this file since 619 was 596, checked in by Krister Nordvall, 6 years ago

Changes:

  • Made changes to HotkeyBar.asm to give the Boot Menu and Hotkey Bar a more consistent look. It will probably seem a bit strange at first to people used to the classic theme.
  • Added the missing parts of USE_NEC_V that should have been committed with the rest in r593.
  • Removed DEFINES_ALL_FEATURES from the BIOS makefile. It didn't work anymore and never really made sense anyway. Added all the official builds to 'make unused' instead which actually uncovered some unused code in the Tiny build.
  • XTIDECFG will no longer load color themes from unrecognized versions of the BIOS.
  • Other fixes in comments and some minor optimizations.
File size: 5.4 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for preparing data buffer for transfer.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
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.
12;
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
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; Prepare_ByLoadingDapToESSIandVerifyingForTransfer
25; Parameters:
26; SI: Offset to DAP
27; DS:DI: Ptr to DPT
28; SS:BP: Ptr to IDEPACK
29; Parameters on INTPACK:
30; DS:SI: Ptr to Disk Address Packet
31; Returns:
32; BX: Index to command lookup table
33; ES:SI: Ptr to Disk Address Packet (DAP)
34; Exits from INT 13h if invalid DAP
35; Corrupts registers:
36; AX, DX
37;--------------------------------------------------------------------
38%ifdef MODULE_EBIOS
39ALIGN JUMP_ALIGN
40Prepare_ByLoadingDapToESSIandVerifyingForTransfer:
41 ; Load pointer to DAP to ES:SI and make sure it is valid
42 mov es, [bp+IDEPACK.intpack+INTPACK.ds] ; ES:SI to point Disk Address Packet
43 cmp BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
44 jb SHORT InvalidDAP
45
46 ; Make sure that sector count is valid
47%ifdef USE_UNDOC_INTEL
48 salc ; Clear AL using CF (CF is cleared since JB above fell through)
49 or al, [es:si+DAP.wSectorCount]
50%else
51 mov al, [es:si+DAP.wSectorCount]
52 test al, al
53%endif
54 jz SHORT ZeroSectorsRequestedSoNoErrors
55 js SHORT InvalidNumberOfSectorsRequested
56
57%if 0 ; Slow version in the unlikely case that high byte needs to be checked.
58 mov ax, [es:si+DAP.wSectorCount]
59 test ax, ax
60 jz SHORT ZeroSectorsRequestedSoNoErrors
61 cmp ax, BYTE 127
62 ja SHORT InvalidNumberOfSectorsRequested
63%endif
64
65 ; Get EBIOS command index to BX
66 ; LBA28 or LBA48 command
67 call Prepare_GetOldInt13hCommandIndexToBX
68 mov al, [di+DPT.bFlagsLow]
69 eSHL_IM al, 1 ; Set CF if LBA48 supported
70 adc bl, bh ; LBA48 EXT commands
71 ret
72%endif ; MODULE_EBIOS
73
74
75;--------------------------------------------------------------------
76; Prepare_GetOldInt13hCommandIndexToBX
77; Parameters:
78; DS:DI: Ptr to DPT
79; Returns:
80; BX: Index to command lookup table
81; Corrupts registers:
82; Nothing
83;--------------------------------------------------------------------
84ALIGN JUMP_ALIGN
85Prepare_GetOldInt13hCommandIndexToBX:
86 ; Block mode or single sector
87 mov bl, [di+DPT.bFlagsHigh]
88 and bx, BYTE FLGH_DPT_USE_BLOCK_MODE_COMMANDS ; Bit 1
89 ret
90
91
92;---------------------------------------------------------------------
93; Prepare_BufferToESSIforOldInt13hTransfer
94; Parameters:
95; AL: Number of sectors to transfer
96; DS:DI: Ptr to DPT (in RAMVARS segment)
97; SS:BP: Ptr to IDEPACK
98; Parameters on INTPACK:
99; ES:BX: Ptr to data buffer
100; Returns:
101; ES:SI: Ptr to normalized data buffer
102; Exits INT 13h if error
103; Corrupts registers:
104; BX
105;--------------------------------------------------------------------
106ALIGN JUMP_ALIGN
107Prepare_BufferToESSIforOldInt13hTransfer:
108 mov si, [bp+IDEPACK.intpack+INTPACK.bx] ; Load offset
109 mov es, [bp+IDEPACK.intpack+INTPACK.es] ; Load segment
110 ; Fall to Prepare_ByValidatingSectorsInALforOldInt13h
111
112;---------------------------------------------------------------------
113; Prepare_ByValidatingSectorsInALforOldInt13h
114; Parameters:
115; AL: Number of sectors to transfer (1...128 is valid)
116; Returns:
117; Exits INT 13h if invalid number of sectors in AL
118; Corrupts registers:
119; Nothing
120;--------------------------------------------------------------------
121Prepare_ByValidatingSectorsInALforOldInt13h:
122 test al, al ; Check if 0 < AL < 128 (Clears OF)
123 jle SHORT .CheckIf128Sectors ; Jump if not
124 ret ; Continue with transfer
125
126ALIGN JUMP_ALIGN
127.CheckIf128Sectors:
128 cmp al, 128
129 jne SHORT InvalidNumberOfSectorsRequested
130 test si, si ; Offset must be zero to xfer 128 sectors
131 jnz SHORT CannotAlignPointerProperly
132 ret ; Continue with transfer
133
134%ifdef MODULE_EBIOS
135InvalidDAP:
136Prepare_ReturnFromInt13hWithInvalidFunctionError:
137%endif
138InvalidNumberOfSectorsRequested:
139 mov ah, RET_HD_INVALID
140 SKIP2B f
141CannotAlignPointerProperly:
142 mov ah, RET_HD_BOUNDARY
143%ifdef MODULE_EBIOS
144ZeroSectorsRequestedSoNoErrors:
145%endif
146 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
147
148
149
150; Command lookup tables
151g_rgbReadCommandLookup:
152 db COMMAND_READ_SECTORS ; 00b, CHS or LBA28 single sector
153 db COMMAND_READ_SECTORS_EXT ; 01b, LBA48 single sector
154 db COMMAND_READ_MULTIPLE ; 10b, CHS or LBA28 block mode
155%ifdef MODULE_EBIOS
156 db COMMAND_READ_MULTIPLE_EXT ; 11b, LBA48 block mode
157%endif
158
159g_rgbWriteCommandLookup:
160 db COMMAND_WRITE_SECTORS
161 db COMMAND_WRITE_SECTORS_EXT
162 db COMMAND_WRITE_MULTIPLE
163%ifdef MODULE_EBIOS
164 db COMMAND_WRITE_MULTIPLE_EXT
165%endif
166
167%ifdef MODULE_EBIOS
168g_rgbVerifyCommandLookup:
169 db COMMAND_VERIFY_SECTORS
170 db COMMAND_VERIFY_SECTORS_EXT
171 db COMMAND_VERIFY_SECTORS
172 db COMMAND_VERIFY_SECTORS_EXT
173%endif
Note: See TracBrowser for help on using the repository browser.