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

Last change on this file since 339 was 322, checked in by krille_n_@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Commented out the FS and GS segment registers from INTPACK since we never touch them anyway.
  • Minor changes to improve speed in the Int13h handler.
  • Changed Prepare_ByValidatingSectorsInALforOldInt13h so it really doesn't corrupt anything.
  • Changed the makefile so 'make strings' now works even if StringsCompressed.asm is missing or empty.
File size: 4.6 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for preparing data buffer for transfer.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Prepare_ByLoadingDapToESSIandVerifyingForTransfer
9; Parameters:
10; SI: Offset to DAP
11; DS:DI: Ptr to DPT
12; SS:BP: Ptr to IDEPACK
13; Parameters on INTPACK:
14; DS:SI: Ptr to Disk Address Packet
15; Returns:
16; BX: Index to command lookup table
17; ES:SI: Ptr to Disk Address Packet (DAP)
18; Exits from INT 13h if invalid DAP
19; Corrupts registers:
20; AX, DX
21;--------------------------------------------------------------------
22%ifdef MODULE_EBIOS
23ALIGN JUMP_ALIGN
24Prepare_ByLoadingDapToESSIandVerifyingForTransfer:
25 ; Load pointer to DAP to ES:SI and make sure it is valid
26 mov es, [bp+IDEPACK.intpack+INTPACK.ds] ; ES:SI to point Disk Address Packet
27 cmp BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
28 jb SHORT InvalidDAP
29
30 ; Make sure that sector count is valid
31 mov ax, [es:si+DAP.wSectorCount]
32 test ax, ax
33 jz SHORT ZeroSectorsRequestedSoNoErrors
34 cmp ax, BYTE 127
35 ja SHORT InvalidNumberOfSectorsRequested
36
37 ; Get EBIOS command index to BX
38 ; LBA28 or LBA48 command
39 cwd
40 mov al, [es:si+DAP.qwLBA+3] ; Load LBA48 byte 3 (bits 24...31)
41 and al, 0F0h ; Clear LBA28 bits 24...27
42 or ax, [es:si+DAP.qwLBA+4] ; Set bits from LBA bytes 4 and 5
43 cmp dx, ax ; Set CF if any of bits 28...47 set
44 rcl dx, 1 ; DX = 0 for LBA28, DX = 1 for LBA48
45 call Prepare_GetOldInt13hCommandIndexToBX
46 or bx, dx ; Set block mode / single sector bit
47 ret
48%endif
49
50
51;--------------------------------------------------------------------
52; Prepare_GetOldInt13hCommandIndexToBX
53; Parameters:
54; DS:DI: Ptr to DPT
55; Returns:
56; BX: Index to command lookup table
57; Corrupts registers:
58; Nothing
59;--------------------------------------------------------------------
60ALIGN JUMP_ALIGN
61Prepare_GetOldInt13hCommandIndexToBX:
62 ; Block mode or single sector
63 mov bl, [di+DPT.bFlagsHigh]
64 and bx, BYTE FLGH_DPT_BLOCK_MODE_SUPPORTED ; Bit 1
65 ret
66
67
68;---------------------------------------------------------------------
69; Prepare_BufferToESSIforOldInt13hTransfer
70; Parameters:
71; AL: Number of sectors to transfer
72; SS:BP: Ptr to IDEPACK
73; Parameters on INTPACK:
74; ES:BX: Ptr to data buffer
75; Returns:
76; ES:SI: Ptr to normalized data buffer
77; Exits INT 13h if error
78; Corrupts registers:
79; BX
80;--------------------------------------------------------------------
81ALIGN JUMP_ALIGN
82Prepare_BufferToESSIforOldInt13hTransfer:
83 ; Normalize buffer pointer
84 mov bx, [bp+IDEPACK.intpack+INTPACK.bx] ; Load offset
85 mov si, bx
86 eSHR_IM bx, 4 ; Divide offset by 16
87 add bx, [bp+IDEPACK.intpack+INTPACK.es]
88 mov es, bx ; Segment normalized
89 and si, BYTE 0Fh ; Offset normalized
90 ; Fall to Prepare_ByValidatingSectorsInALforOldInt13h
91
92
93;---------------------------------------------------------------------
94; Prepare_ByValidatingSectorsInALforOldInt13h
95; Parameters:
96; AL: Number of sectors to transfer
97; Returns:
98; Exits INT 13h if invalid number of sectors in AL
99; Corrupts registers:
100; Nothing
101;--------------------------------------------------------------------
102ALIGN JUMP_ALIGN
103Prepare_ByValidatingSectorsInALforOldInt13h:
104 test al, al
105 js SHORT .CheckZeroOffsetFor128Sectors ; 128 or more
106 jz SHORT InvalidNumberOfSectorsRequested ; Zero not allowed for old INT 13h
107 ret ; Continue with transfer
108
109ALIGN JUMP_ALIGN
110.CheckZeroOffsetFor128Sectors:
111 cmp al, 128
112 ja SHORT InvalidNumberOfSectorsRequested
113 test si, si ; Offset must be zero to xfer 128 sectors
114 jnz SHORT CannotAlignPointerProperly
115 ret ; Continue with transfer
116
117InvalidDAP:
118InvalidNumberOfSectorsRequested:
119Prepare_ReturnFromInt13hWithInvalidFunctionError:
120 mov ah, RET_HD_INVALID
121 SKIP2B f
122CannotAlignPointerProperly:
123 mov ah, RET_HD_BOUNDARY
124ZeroSectorsRequestedSoNoErrors:
125 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
126
127
128
129; Command lookup tables
130g_rgbReadCommandLookup:
131 db COMMAND_READ_SECTORS ; 00b, CHS or LBA28 single sector
132 db COMMAND_READ_SECTORS_EXT ; 01b, LBA48 single sector
133 db COMMAND_READ_MULTIPLE ; 10b, CHS or LBA28 block mode
134 db COMMAND_READ_MULTIPLE_EXT ; 11b, LBA48 block mode
135
136g_rgbWriteCommandLookup:
137 db COMMAND_WRITE_SECTORS
138 db COMMAND_WRITE_SECTORS_EXT
139 db COMMAND_WRITE_MULTIPLE
140 db COMMAND_WRITE_MULTIPLE_EXT
141
142g_rgbVerifyCommandLookup:
143 db COMMAND_VERIFY_SECTORS
144 db COMMAND_VERIFY_SECTORS_EXT
145 db COMMAND_VERIFY_SECTORS
146 db COMMAND_VERIFY_SECTORS_EXT
Note: See TracBrowser for help on using the repository browser.