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

Last change on this file since 558 was 558, checked in by krille_n_@…, 11 years ago

Changes:

  • Building the BIOS Drive Information Tool now works again.
  • Moved all XT-CF related code to MODULE_8BIT_IDE_ADVANCED. I don't see how an XT-CF card could work without *_ADVANCED anyway but if I'm wrong, feel free to undo this. Note! The autodetection code in XTIDECFG has NOT been changed to reflect this (still relies on MODULE_8BIT_IDE).
  • Optimizations and fixes in general.
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    eSALC   ; 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
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
123    js      SHORT .CheckZeroOffsetFor128Sectors     ; 128 or more
124    jz      SHORT InvalidNumberOfSectorsRequested   ; Zero not allowed for old INT 13h
125    ret     ; Continue with transfer
126
127ALIGN JUMP_ALIGN
128.CheckZeroOffsetFor128Sectors:
129    cmp     al, 128
130    ja      SHORT InvalidNumberOfSectorsRequested
131    test    si, si                              ; Offset must be zero to xfer 128 sectors
132    jnz     SHORT CannotAlignPointerProperly
133    ret     ; Continue with transfer
134
135InvalidDAP:
136InvalidNumberOfSectorsRequested:
137Prepare_ReturnFromInt13hWithInvalidFunctionError:
138    mov     ah, RET_HD_INVALID
139    SKIP2B  f
140CannotAlignPointerProperly:
141    mov     ah, RET_HD_BOUNDARY
142ZeroSectorsRequestedSoNoErrors:
143    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
144
145
146
147; Command lookup tables
148g_rgbReadCommandLookup:
149    db      COMMAND_READ_SECTORS        ; 00b, CHS or LBA28 single sector
150    db      COMMAND_READ_SECTORS_EXT    ; 01b, LBA48 single sector
151    db      COMMAND_READ_MULTIPLE       ; 10b, CHS or LBA28 block mode
152%ifdef MODULE_EBIOS
153    db      COMMAND_READ_MULTIPLE_EXT   ; 11b, LBA48 block mode
154%endif
155
156g_rgbWriteCommandLookup:
157    db      COMMAND_WRITE_SECTORS
158    db      COMMAND_WRITE_SECTORS_EXT
159    db      COMMAND_WRITE_MULTIPLE
160%ifdef MODULE_EBIOS
161    db      COMMAND_WRITE_MULTIPLE_EXT
162%endif
163
164g_rgbVerifyCommandLookup:
165    db      COMMAND_VERIFY_SECTORS
166    db      COMMAND_VERIFY_SECTORS_EXT
167    db      COMMAND_VERIFY_SECTORS
168%ifdef MODULE_EBIOS
169    db      COMMAND_VERIFY_SECTORS_EXT
170%endif
Note: See TracBrowser for help on using the repository browser.