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
RevLine 
[218]1; Project name  :   XTIDE Universal BIOS
2; Description   :   Functions for preparing data buffer for transfer.
3
[376]4;
[445]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[445]12;
[376]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.
[445]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
[376]19
[218]20; Section containing code
21SECTION .text
22
[221]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
[558]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
[547]51    mov     al, [es:si+DAP.wSectorCount]
52    test    al, al
[558]53%endif
[547]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.
[221]58    mov     ax, [es:si+DAP.wSectorCount]
59    test    ax, ax
60    jz      SHORT ZeroSectorsRequestedSoNoErrors
61    cmp     ax, BYTE 127
62    ja      SHORT InvalidNumberOfSectorsRequested
[547]63%endif
[221]64
[294]65    ; Get EBIOS command index to BX
[221]66    ; LBA28 or LBA48 command
67    call    Prepare_GetOldInt13hCommandIndexToBX
[421]68    mov     al, [di+DPT.bFlagsLow]
[558]69    eSHL_IM al, 1                   ; Set CF if LBA48 supported
[421]70    adc     bl, bh                  ; LBA48 EXT commands
[221]71    ret
[421]72%endif ; MODULE_EBIOS
[221]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]
[550]88    and     bx, BYTE FLGH_DPT_USE_BLOCK_MODE_COMMANDS   ; Bit 1
[221]89    ret
90
91
[218]92;---------------------------------------------------------------------
[221]93; Prepare_BufferToESSIforOldInt13hTransfer
[218]94;   Parameters:
95;       AL:     Number of sectors to transfer
[474]96;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[218]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
[221]107Prepare_BufferToESSIforOldInt13hTransfer:
[477]108    mov     si, [bp+IDEPACK.intpack+INTPACK.bx] ; Load offset
[480]109    mov     es, [bp+IDEPACK.intpack+INTPACK.es] ; Load segment
[221]110    ; Fall to Prepare_ByValidatingSectorsInALforOldInt13h
[218]111
[221]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:
[218]122    test    al, al
[221]123    js      SHORT .CheckZeroOffsetFor128Sectors     ; 128 or more
124    jz      SHORT InvalidNumberOfSectorsRequested   ; Zero not allowed for old INT 13h
[218]125    ret     ; Continue with transfer
126
127ALIGN JUMP_ALIGN
128.CheckZeroOffsetFor128Sectors:
129    cmp     al, 128
[221]130    ja      SHORT InvalidNumberOfSectorsRequested
[218]131    test    si, si                              ; Offset must be zero to xfer 128 sectors
[221]132    jnz     SHORT CannotAlignPointerProperly
[218]133    ret     ; Continue with transfer
134
[221]135InvalidDAP:
136InvalidNumberOfSectorsRequested:
137Prepare_ReturnFromInt13hWithInvalidFunctionError:
[218]138    mov     ah, RET_HD_INVALID
[322]139    SKIP2B  f
140CannotAlignPointerProperly:
141    mov     ah, RET_HD_BOUNDARY
[221]142ZeroSectorsRequestedSoNoErrors:
[218]143    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
144
[221]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
[413]152%ifdef MODULE_EBIOS
[221]153    db      COMMAND_READ_MULTIPLE_EXT   ; 11b, LBA48 block mode
[413]154%endif
[221]155
156g_rgbWriteCommandLookup:
157    db      COMMAND_WRITE_SECTORS
158    db      COMMAND_WRITE_SECTORS_EXT
159    db      COMMAND_WRITE_MULTIPLE
[413]160%ifdef MODULE_EBIOS
[221]161    db      COMMAND_WRITE_MULTIPLE_EXT
[413]162%endif
[221]163
164g_rgbVerifyCommandLookup:
165    db      COMMAND_VERIFY_SECTORS
166    db      COMMAND_VERIFY_SECTORS_EXT
167    db      COMMAND_VERIFY_SECTORS
[413]168%ifdef MODULE_EBIOS
[221]169    db      COMMAND_VERIFY_SECTORS_EXT
[413]170%endif
Note: See TracBrowser for help on using the repository browser.