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

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

Added AiR-BOOT Images and support for other languages.
Note: This comment was created after rebuilding the repo. [2011-07]

File size: 11.2 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 YET RELEASED UNDER GPL.
7; It's (c) Copyright 1998-2002 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 BIOS INT 13h or BIOS/Extensions.
121; Access will be done prefered by INT 13h, 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.
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 mov wptr cs:[CurPartition_Location+0], ax
136 mov wptr cs:[CurPartition_Location+2], bx
137 mov wptr cs:[CurPartition_Location+4], dx
138 mov wptr cs:[CurPartition_Location+6], cx ; Saves the location
139 push ExecBaseSeg
140 pop ds
141 mov si, ExecBasePtr ; DS:SI - ExecBase
142 call DriveIO_LoadSector
143 clc
144 cmp word ptr ds:[si+LocBR_Magic], 0AA55h
145 je DIOLP_Success
146 stc
147 DIOLP_Success:
148 ret
149DriveIO_LoadPartition EndP
150
151Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
152 Routine: Writes a partition from ExecBase to its original sector
153 ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
154 Calling : none
155 Returns : none
156 Preserve: all registers
157 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
158DriveIO_SavePartition Proc Near Uses ax bx cx dx ds si
159 mov ax, wptr cs:[CurPartition_Location+0]
160 mov bx, wptr cs:[CurPartition_Location+2]
161 mov dx, wptr cs:[CurPartition_Location+4]
162 mov cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location
163 push ExecBaseSeg
164 pop ds
165 mov si, ExecBasePtr ; DS:SI - ExecBase
166 call DriveIO_SaveSector
167 ret
168DriveIO_SavePartition EndP
169
170; L„sst DS:SI fr Aufrufer
171DriveIO_LoadTmpSector Proc Near Uses
172 push cs
173 pop ds
174 mov si, offset TmpSector
175 call DriveIO_LoadSector
176 ret
177DriveIO_LoadTmpSector EndP
178
179; L„sst DS:SI fr Aufrufer
180DriveIO_SaveTmpSector Proc Near Uses
181 push cs
182 pop ds
183 mov si, offset TmpSector
184 call DriveIO_SaveSector
185 ret
186DriveIO_SaveTmpSector EndP
187
188; Memory-Block that holds information for LBA-access via INT 13h
189DriveIO_DAP: db 10h ; Size of paket
190 db 0 ; Reserved
191DriveIO_DAP_NumBlocks dw 0 ; Number of blocks
192DriveIO_DAP_Transfer dd 0 ; Transfer Adress
193DriveIO_DAP_Absolute dd 0 ; Absolute Sector
194 dd 0 ; Second Part of QWORD
195
196Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
197 Routine: Loads a specified sector to DS:DI
198 ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
199 Calling : bx:ax - Absolute sector
200 cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
201 ds:si - Destination-Adress
202 Returns : none
203 Preserve: all registers
204 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
205DriveIO_LoadSector Proc Near Uses ax bx ds si es di
206 ; LBA-boundary >16450560 (FB0400h)
207 cmp bx, 00FBh
208 jb DIOLS_UseNormal
209 test cs:[CurIO_UseExtension], 1
210 jnz DIOLS_UseExtension
211 DIOLS_UseNormal:
212 mov di, 3
213 DIOLS_ErrorLoop:
214 push ds
215 pop es
216 mov bx, si ; ES:BX - Destination
217 mov ax, 0201h ; Function 2 - Load Sector
218 int 13h
219 jnc DIOLS_Success
220 dec di
221 jnz DIOLS_ErrorLoop
222 call MBR_LoadError
223
224 DIOLS_UseExtension:
225 push cx
226 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector
227 mov wptr cs:[DriveIO_DAP_Transfer+0], si
228 mov cx, ds
229 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
230 mov wptr cs:[DriveIO_DAP_Absolute+0], ax
231 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
232 push cs
233 pop ds
234 mov si, offset DriveIO_DAP
235 mov ah, 42h ; Extended Read
236 int 13h
237 pop cx
238 jnc DIOLS_Success
239 call MBR_LoadError
240
241 DIOLS_Success:
242 ret
243DriveIO_LoadSector EndP
244
245Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
246 Routine: Writes DS:SI to a specified sector
247 ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
248 Calling : bx:ax - Absolute sector
249 cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
250 ds:si - Source-Adress
251 Returns : none
252 Preserve: all registers
253 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
254DriveIO_SaveSector Proc Near Uses ax bx cx ds si es di
255 ; LBA-boundary >16450560 (FB0400h)
256 cmp bx, 00FBh
257 jb DIOSS_UseNormal
258 test cs:[CurIO_UseExtension], 1
259 jnz DIOSS_UseExtension
260 DIOSS_UseNormal:
261 mov di, 3
262 DIOSS_ErrorLoop:
263 push ds
264 pop es
265 mov bx, si ; ES:BX - Destination
266 mov ax, 0301h ; Function 3 - Write Sector
267 int 13h
268 jnc DIOSS_Success
269 dec di
270 jnz DIOSS_ErrorLoop
271 call MBR_SaveError
272
273 DIOSS_UseExtension:
274 push cx
275 mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector
276 mov wptr cs:[DriveIO_DAP_Transfer+0], si
277 mov cx, ds
278 mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
279 mov wptr cs:[DriveIO_DAP_Absolute+0], ax
280 mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
281 push cs
282 pop ds
283 mov si, offset DriveIO_DAP
284 mov ax, 4300h ; Extended Write (No Verify)
285 int 13h
286 pop cx
287 jnc DIOSS_Success
288 call MBR_SaveError
289
290 DIOSS_Success:
291 ret
292DriveIO_SaveSector EndP
Note: See TracBrowser for help on using the repository browser.