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

Last change on this file since 476 was 474, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Drive detection now displays autodetected XT-CF port and skips slave drives for XT-CF.
  • AH=1Eh no longer tries to disable 8-bit mode for memory mapped and DMA transfer modes.
  • Preparations to implement DMA.
File size: 5.6 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-2012 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 mov ax, [es:si+DAP.wSectorCount]
48 test ax, ax
49 jz SHORT ZeroSectorsRequestedSoNoErrors
50 cmp ax, BYTE 127
51 ja SHORT InvalidNumberOfSectorsRequested
52
53 ; Get EBIOS command index to BX
54 ; LBA28 or LBA48 command
55 call Prepare_GetOldInt13hCommandIndexToBX
56 mov al, [di+DPT.bFlagsLow]
57 eSHL_IM al, 1 ; Set CF if LBA48 supported
58 adc bl, bh ; LBA48 EXT commands
59 ret
60%endif ; MODULE_EBIOS
61
62
63;--------------------------------------------------------------------
64; Prepare_GetOldInt13hCommandIndexToBX
65; Parameters:
66; DS:DI: Ptr to DPT
67; Returns:
68; BX: Index to command lookup table
69; Corrupts registers:
70; Nothing
71;--------------------------------------------------------------------
72ALIGN JUMP_ALIGN
73Prepare_GetOldInt13hCommandIndexToBX:
74 ; Block mode or single sector
75 mov bl, [di+DPT.bFlagsHigh]
76 and bx, BYTE FLGH_DPT_BLOCK_MODE_SUPPORTED ; Bit 1
77 ret
78
79
80;---------------------------------------------------------------------
81; Prepare_BufferToESSIforOldInt13hTransfer
82; Parameters:
83; AL: Number of sectors to transfer
84; DS:DI: Ptr to DPT (in RAMVARS segment)
85; SS:BP: Ptr to IDEPACK
86; Parameters on INTPACK:
87; ES:BX: Ptr to data buffer
88; Returns:
89; ES:SI: Ptr to normalized data buffer
90; Exits INT 13h if error
91; Corrupts registers:
92; BX
93;--------------------------------------------------------------------
94ALIGN JUMP_ALIGN
95Prepare_BufferToESSIforOldInt13hTransfer:
96 cmp BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_XTCF_DMA
97 jne SHORT .NormalizeForSmallestPossibleOffset
98
99 ; Normalize segment for physical 64k pages
100 xor bx, bx
101 mov si, [bp+IDEPACK.intpack+INTPACK.es] ; Load segment
102%rep 4
103 shl si, 1
104 rcl bx, 1
105%endrep
106 add si, [bp+IDEPACK.intpack+INTPACK.bx]
107 adc bx, BYTE 0
108 mov es, bx ; ES:SI now has physical address
109 jmp SHORT Prepare_ByValidatingSectorsInALforOldInt13h
110
111 ; Normalize segment for 16b pages
112.NormalizeForSmallestPossibleOffset:
113 mov bx, [bp+IDEPACK.intpack+INTPACK.bx] ; Load offset
114 mov si, bx
115 eSHR_IM bx, 4 ; Divide offset by 16
116 add bx, [bp+IDEPACK.intpack+INTPACK.es]
117 mov es, bx ; Segment normalized
118 and si, BYTE 0Fh ; Offset normalized
119 ; Fall to Prepare_ByValidatingSectorsInALforOldInt13h
120
121
122;---------------------------------------------------------------------
123; Prepare_ByValidatingSectorsInALforOldInt13h
124; Parameters:
125; AL: Number of sectors to transfer
126; Returns:
127; Exits INT 13h if invalid number of sectors in AL
128; Corrupts registers:
129; Nothing
130;--------------------------------------------------------------------
131Prepare_ByValidatingSectorsInALforOldInt13h:
132 test al, al
133 js SHORT .CheckZeroOffsetFor128Sectors ; 128 or more
134 jz SHORT InvalidNumberOfSectorsRequested ; Zero not allowed for old INT 13h
135 ret ; Continue with transfer
136
137ALIGN JUMP_ALIGN
138.CheckZeroOffsetFor128Sectors:
139 cmp al, 128
140 ja SHORT InvalidNumberOfSectorsRequested
141 test si, si ; Offset must be zero to xfer 128 sectors
142 jnz SHORT CannotAlignPointerProperly
143 ret ; Continue with transfer
144
145InvalidDAP:
146InvalidNumberOfSectorsRequested:
147Prepare_ReturnFromInt13hWithInvalidFunctionError:
148 mov ah, RET_HD_INVALID
149 SKIP2B f
150CannotAlignPointerProperly:
151 mov ah, RET_HD_BOUNDARY
152ZeroSectorsRequestedSoNoErrors:
153 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
154
155
156
157; Command lookup tables
158g_rgbReadCommandLookup:
159 db COMMAND_READ_SECTORS ; 00b, CHS or LBA28 single sector
160 db COMMAND_READ_SECTORS_EXT ; 01b, LBA48 single sector
161 db COMMAND_READ_MULTIPLE ; 10b, CHS or LBA28 block mode
162%ifdef MODULE_EBIOS
163 db COMMAND_READ_MULTIPLE_EXT ; 11b, LBA48 block mode
164%endif
165
166g_rgbWriteCommandLookup:
167 db COMMAND_WRITE_SECTORS
168 db COMMAND_WRITE_SECTORS_EXT
169 db COMMAND_WRITE_MULTIPLE
170%ifdef MODULE_EBIOS
171 db COMMAND_WRITE_MULTIPLE_EXT
172%endif
173
174g_rgbVerifyCommandLookup:
175 db COMMAND_VERIFY_SECTORS
176 db COMMAND_VERIFY_SECTORS_EXT
177 db COMMAND_VERIFY_SECTORS
178%ifdef MODULE_EBIOS
179 db COMMAND_VERIFY_SECTORS_EXT
180%endif
Note: See TracBrowser for help on using the repository browser.