source: trunk/AIR-BOOT/SOURCE/REGULAR/DRIVEIO.ASM@ 26

Last change on this file since 26 was 26, checked in by kiewitz, 23 years ago

Updated several Sources.
Note: This comment was created after rebuilding the repo. [2011-07]

File size: 12.3 KB
Line 
1
2; Disclaimer:
3;=============
4; The sourcecode is released via www.netlabs.org CVS *ONLY*.
5; You MUST NOT upload it to other servers nor republish it in any way.
6; The sourcecode is still COPYRIGHTED and NOT RELEASED UNDER GPL.
7; It's (c) Copyright 1998-2003 by Martin Kiewitz.
8; You may recompile the source and do *PRIVATE* modifications, but please keep
9; in mind that modifying this code needs at least *some* assembly skill. If
10; you mess up your system, because you needed to hack your way through, don't
11; blame me. Releasing a customized version of AiR-BOOT, selling it in any form
12; or reusing parts of this source is *PROHIBITED*. Ask me, if you have some
13; idea about new functionality *before* developing the code, otherwise I will
14; definitely reject it. Also please accept, that I have some basic design
15; rules on AiR-BOOT and I will maintain them at all costs, so this won't get
16; another GRUB.
17
18;---------------------------------------------------------------------------
19; AiR-BOOT / DRIVE I/O
20;---------------------------------------------------------------------------
21
22; Note: Some routines set DS/ES to CS, even if its not needed.
23; This was done for SECURITY. So DO NOT remove it. Its there to make
24; sure the correct data is loaded/written to/from harddrive.
25;
26; IF YOU MODIFY ANYTHING IN HERE, YOU CAN EASILY BREAK YOUR HARDDRIVE!
27
28; Will only load base-configuration, will NOT load IPT nor Hide-Config
29; Those are originally loaded on startup and will NOT get reloaded.
30DriveIO_LoadConfiguration Proc Near Uses ax bx cx dx es
31 mov ax, cs
32 mov es, ax
33 mov bx, offset Configuration
34 mov dx, 0080h ; First harddrive, Sector 55...
35 mov cx, 0037h
36 mov ax, 0201h ; Function 02, read 1 sector...
37 int 13h
38 jnc DIOLC_NoError
39 call MBR_LoadError ; Will Abort BootUp
40 DIOLC_NoError:
41 ret
42DriveIO_LoadConfiguration EndP
43
44DriveIO_SaveConfiguration Proc Near Uses ax bx cx dx ds es si
45 mov ax, cs
46 mov ds, ax
47 mov es, ax ; Safety first (CS==DS==ES)
48 ; --- Overwrite Floppy-Name with "FloppyDrive"
49 mov si, offset TXT_Floppy_Drive
50 mov di, offset PartitionTable
51 sub di, 30 ; Adjust to Floppy-Name
52 mov cx, 11
53 rep movsb
54 mov si, offset Configuration ; Calculate new checksum
55 xor bx, bx
56 mov cx, 5 ; Total of 5 Config-Sectors
57 mov dx, [CFG_CheckConfig]
58 mov [CFG_CheckConfig], bx
59 DIOSC_Loop:
60 call MBR_GetCheckOfSector
61 loop DIOSC_Loop
62 mov [CFG_CheckConfig], bx
63 ; --------------------------------------------------------------------
64 ; ES == CS
65 mov bx, offset Configuration
66 mov dx, 0080h ; First harddrive, Sector 55...
67 mov cx, 0037h
68 mov ax, 0305h ; Function 03, 5 sectors to write
69 int 13h
70 jnc DIOSC_NoError
71 call MBR_SaveError ; Will Abort BootUp
72 DIOSC_NoError:
73 ret
74DriveIO_SaveConfiguration EndP
75
76DriveIO_UpdateFloppyName Proc Near Uses bx cx dx ds si es di
77 mov ax, cs
78 mov ds, ax
79 mov es, ax
80
81 mov ah, 00h ; Function 2 - Reset Drive
82 xor dl, dl
83 int 13h
84 xor dx, dx ; Cylinder=0, Head=0
85 mov cx, 1 ; Sector=1, Drive=0
86 mov bx, offset TmpSector ; ES:BX - TmpSector
87 mov ax, 0201h ; Function 2 - Load Sector
88 int 13h
89 jnc DIOUFN_AllFine
90
91 ; --- Overwrite Floppy-Name with "No Disc"
92 mov si, offset TXT_Floppy_NoDisc
93 xor ax, ax
94 DIOUFN_WriteFloppyName:
95 mov di, offset PartitionTable
96 sub di, 30 ; Adjust to Floppy-Name
97 mov cl, 11
98 rep movsb
99 ret ; AX=-1 -> GotDisc, =0 -> NoDisc
100
101 ; --- Floppy found and read, data in TempSector
102 DIOUFN_AllFine:
103 mov ax, -1
104 mov si, offset TXT_Floppy_NoName
105 cmp wptr es:[bx+54], 'AF'
106 jne DIOUFN_WriteFloppyName
107 cmp wptr es:[bx+56], '1T'
108 jne DIOUFN_WriteFloppyName
109 cmp bptr es:[bx+58], '2'
110 jne DIOUFN_WriteFloppyName
111 mov si, bx
112 add si, 43 ; FAT12 - Volume Label Location
113 jmp DIOUFN_WriteFloppyName
114DriveIO_UpdateFloppyName EndP
115
116; =============================================================================
117; HARDDRIVE / GENERAL ACCESS
118; =============================================================================
119; The following routines are used for harddisc/floppy access.
120; The access is done via INT 13h/CHS or INT 13h/LBA.
121; Access will be done prefered by INT 13h/CHS, because it's (I wonder!) much
122; faster, than the LBA-method. I don't know, why LBA is so slow. Perhaps BIOS.
123;
124; Internal access (to AiR-BOOT) is always done via INT 13h/CHS.
125
126Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
127 Routine: Loads partition to ExecBase and checks for validity
128 ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
129 Calling : bx:ax - Absolute sector
130 cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
131 Returns : Carry Set if invalid partition encountered
132 Preserve: all registers
133 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
134DriveIO_LoadPartition Proc Near Uses ds si
135 int 3
136 mov wptr cs:[CurPartition_Location+0], ax
137 mov wptr cs:[CurPartition_Location+2], bx
138 mov wptr cs:[CurPartition_Location+4], dx
139 mov wptr cs:[CurPartition_Location+6], cx ; Saves the location
140 push ExecBaseSeg
141 pop ds
142 mov si, ExecBasePtr ; DS:SI - ExecBase
143 call DriveIO_LoadSector
144 clc
145 cmp word ptr ds:[si+LocBR_Magic], 0AA55h
146 je DIOLP_Success
147 ; We check, if we are scanning partitions. In that case, if CHS is not 0/0/1
148 ; we will display a "bad partition table" message and halt the system.
149 cmp cx, 0001h
150 jne DIOLP_Failed
151 or dh, dh
152 jnz DIOLP_Failed
153 stc ; Set carry, so no partition table
154 DIOLP_Success:
155 ret
156 DIOLP_Failed:
157 jmp DriveIO_GotLoadError
158DriveIO_LoadPartition EndP
159
160Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
161 Routine: Writes a partition from ExecBase to its original sector
162 ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
163 Calling : none
164 Returns : none
165 Preserve: all registers
166 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
167DriveIO_SavePartition Proc Near Uses ax bx cx dx ds si
168 mov ax, wptr cs:[CurPartition_Location+0]
169 mov bx, wptr cs:[CurPartition_Location+2]
170 mov dx, wptr cs:[CurPartition_Location+4]
171 mov cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location
172 push ExecBaseSeg
173 pop ds
174 mov si, ExecBasePtr ; DS:SI - ExecBase
175 call DriveIO_SaveSector
176 ret
177DriveIO_SavePartition EndP
178
179; L„sst DS:SI fr Aufrufer
180DriveIO_LoadTmpSector Proc Near Uses
181 push cs
182 pop ds
183 mov si, offset TmpSector
184 call DriveIO_LoadSector
185 ret
186DriveIO_LoadTmpSector EndP
187
188; L„sst DS:SI fr Aufrufer
189DriveIO_SaveTmpSector Proc Near Uses
190 push cs
191 pop ds
192 mov si, offset TmpSector
193 call DriveIO_SaveSector
194 ret
195DriveIO_SaveTmpSector EndP
196
197; Memory-Block that holds information for LBA-access via INT 13h
198DriveIO_DAP: db 10h ; Size of paket
199 db 0 ; Reserved
200DriveIO_DAP_NumBlocks dw 0 ; Number of blocks
201DriveIO_DAP_Transfer dd 0 ; Transfer Adress
202DriveIO_DAP_Absolute dd 0 ; Absolute Sector
203 dd 0 ; Second Part of QWORD
204
205; Special error message instead of "LOAD ERROR" during partition scanning,
206; so users will notice that something is bad with their partition table(s)
207DriveIO_GotLoadError Proc Near
208 test cs:CurIO_Scanning, 1 ; Must be CS:, cause DS!=CS here
209 jnz InScanMode
210 jmp MBR_LoadError
211 InScanMode:
212 mov si, offset TXT_BrokenPartitionTable
213 push cs
214 pop ds
215 call MBR_Teletype
216 jmp MBRLE_Halt
217DriveIO_GotLoadError EndP
218
219Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
220 Routine: Loads a specified sector to DS:DI
221 ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
222 Calling : bx:ax - Absolute sector
223 cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
224 ds:si - Destination-Adress
225 Returns : none
226 Preserve: all registers
227 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
228DriveIO_LoadSector Proc Near Uses ax bx ds si es di
229 test cs:[CurIO_UseExtension], 1
230 jz DIOLS_UseNormal
231 ; LBA-boundary >16450560 (FB0400h)
232 cmp bx, 00FBh
233 jae DIOLS_UseExtension
234 ; or are we forced do use LBA?
235 test cs:[CFG_ForceLBAUsage], 1
236 jnz DIOLS_UseExtension
237 DIOLS_UseNormal:
238 mov di, 3
239 DIOLS_ErrorLoop:
240 push ds
241 pop es
242 mov bx, si ; ES:BX - Destination
243 mov ax, 0201h ; Function 2 - Load Sector
244 int 13h
245 jnc DIOLS_Success
246 dec di
247 jnz DIOLS_ErrorLoop
248 ; Sector load failed...
249 jmp DriveIO_GotLoadError
250
251 DIOLS_UseExtension:
252 push cx
253 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector
254 mov wptr cs:[DriveIO_DAP_Transfer+0], si
255 mov cx, ds
256 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
257 mov wptr cs:[DriveIO_DAP_Absolute+0], ax
258 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
259 push cs
260 pop ds
261 mov si, offset DriveIO_DAP
262 mov ah, 42h ; Extended Read
263 int 13h
264 pop cx
265 jnc DIOLS_Success
266 ; Sector load failed...
267 jmp DriveIO_GotLoadError
268
269 DIOLS_Success:
270 ret
271DriveIO_LoadSector EndP
272
273Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
274 Routine: Writes DS:SI to a specified sector
275 ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
276 Calling : bx:ax - Absolute sector
277 cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
278 ds:si - Source-Adress
279 Returns : none
280 Preserve: all registers
281 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
282DriveIO_SaveSector Proc Near Uses ax bx cx ds si es di
283 test cs:[CurIO_UseExtension], 1
284 jz DIOSS_UseNormal
285 ; LBA-boundary >16450560 (FB0400h)
286 cmp bx, 00FBh
287 jae DIOSS_UseExtension
288 ; or are we forced do use LBA?
289 test cs:[CFG_ForceLBAUsage], 1
290 jnz DIOSS_UseExtension
291 DIOSS_UseNormal:
292 mov di, 3
293 DIOSS_ErrorLoop:
294 push ds
295 pop es
296 mov bx, si ; ES:BX - Destination
297 mov ax, 0301h ; Function 3 - Write Sector
298 int 13h
299 jnc DIOSS_Success
300 dec di
301 jnz DIOSS_ErrorLoop
302 call MBR_SaveError
303
304 DIOSS_UseExtension:
305 push cx
306 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector
307 mov wptr cs:[DriveIO_DAP_Transfer+0], si
308 mov cx, ds
309 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
310 mov wptr cs:[DriveIO_DAP_Absolute+0], ax
311 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
312 push cs
313 pop ds
314 mov si, offset DriveIO_DAP
315 mov ax, 4300h ; Extended Write (No Verify)
316 int 13h
317 pop cx
318 jnc DIOSS_Success
319 call MBR_SaveError
320
321 DIOSS_Success:
322 ret
323DriveIO_SaveSector EndP
Note: See TracBrowser for help on using the repository browser.