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

Last change on this file since 590 was 568, checked in by krille_n_@…, 10 years ago

Changes:

  • SerDrive: Using named pipe mode (serdrive -p) now works under Windows XP/2000/Server 2003.
  • checksum.pl: Added a compatibility fix for 3Com 3C503 cards.
  • XTIDECFG will now scan every possible segment address to find and load the BIOS and/or its settings from EEPROM. This should simplify things for people using combined option ROMs.
  • Fixed a bug from r521 in BootSector.asm where the BIOS would not display a timeout error if it failed to load the boot sector from harddrive.
  • Fixed a bug from r541 in CompatibleDPT.asm where CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI would generate an invalid checksum in the DPTE.
  • Optimizations and other fixes.
File size: 5.3 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
134InvalidDAP:
135InvalidNumberOfSectorsRequested:
136Prepare_ReturnFromInt13hWithInvalidFunctionError:
137 mov ah, RET_HD_INVALID
138 SKIP2B f
139CannotAlignPointerProperly:
140 mov ah, RET_HD_BOUNDARY
141ZeroSectorsRequestedSoNoErrors:
142 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
143
144
145
146; Command lookup tables
147g_rgbReadCommandLookup:
148 db COMMAND_READ_SECTORS ; 00b, CHS or LBA28 single sector
149 db COMMAND_READ_SECTORS_EXT ; 01b, LBA48 single sector
150 db COMMAND_READ_MULTIPLE ; 10b, CHS or LBA28 block mode
151%ifdef MODULE_EBIOS
152 db COMMAND_READ_MULTIPLE_EXT ; 11b, LBA48 block mode
153%endif
154
155g_rgbWriteCommandLookup:
156 db COMMAND_WRITE_SECTORS
157 db COMMAND_WRITE_SECTORS_EXT
158 db COMMAND_WRITE_MULTIPLE
159%ifdef MODULE_EBIOS
160 db COMMAND_WRITE_MULTIPLE_EXT
161%endif
162
163g_rgbVerifyCommandLookup:
164 db COMMAND_VERIFY_SECTORS
165 db COMMAND_VERIFY_SECTORS_EXT
166 db COMMAND_VERIFY_SECTORS
167%ifdef MODULE_EBIOS
168 db COMMAND_VERIFY_SECTORS_EXT
169%endif
Note: See TracBrowser for help on using the repository browser.