| 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.
|
|---|
| 30 | DriveIO_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
|
|---|
| 42 | DriveIO_LoadConfiguration EndP
|
|---|
| 43 |
|
|---|
| 44 | DriveIO_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
|
|---|
| 74 | DriveIO_SaveConfiguration EndP
|
|---|
| 75 |
|
|---|
| 76 | DriveIO_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
|
|---|
| 114 | DriveIO_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 |
|
|---|
| 126 | Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
|
|---|
| 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 | ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
|
|---|
| 134 | DriveIO_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
|
|---|
| 149 | DriveIO_LoadPartition EndP
|
|---|
| 150 |
|
|---|
| 151 | Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
|
|---|
| 152 | Routine: Writes a partition from ExecBase to its original sector
|
|---|
| 153 | ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
|
|---|
| 154 | Calling : none
|
|---|
| 155 | Returns : none
|
|---|
| 156 | Preserve: all registers
|
|---|
| 157 | ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
|
|---|
| 158 | DriveIO_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
|
|---|
| 168 | DriveIO_SavePartition EndP
|
|---|
| 169 |
|
|---|
| 170 | ; Lsst DS:SI fr Aufrufer
|
|---|
| 171 | DriveIO_LoadTmpSector Proc Near Uses
|
|---|
| 172 | push cs
|
|---|
| 173 | pop ds
|
|---|
| 174 | mov si, offset TmpSector
|
|---|
| 175 | call DriveIO_LoadSector
|
|---|
| 176 | ret
|
|---|
| 177 | DriveIO_LoadTmpSector EndP
|
|---|
| 178 |
|
|---|
| 179 | ; Lsst DS:SI fr Aufrufer
|
|---|
| 180 | DriveIO_SaveTmpSector Proc Near Uses
|
|---|
| 181 | push cs
|
|---|
| 182 | pop ds
|
|---|
| 183 | mov si, offset TmpSector
|
|---|
| 184 | call DriveIO_SaveSector
|
|---|
| 185 | ret
|
|---|
| 186 | DriveIO_SaveTmpSector EndP
|
|---|
| 187 |
|
|---|
| 188 | ; Memory-Block that holds information for LBA-access via INT 13h
|
|---|
| 189 | DriveIO_DAP: db 10h ; Size of paket
|
|---|
| 190 | db 0 ; Reserved
|
|---|
| 191 | DriveIO_DAP_NumBlocks dw 0 ; Number of blocks
|
|---|
| 192 | DriveIO_DAP_Transfer dd 0 ; Transfer Adress
|
|---|
| 193 | DriveIO_DAP_Absolute dd 0 ; Absolute Sector
|
|---|
| 194 | dd 0 ; Second Part of QWORD
|
|---|
| 195 |
|
|---|
| 196 | Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
|
|---|
| 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 | ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
|
|---|
| 205 | DriveIO_LoadSector Proc Near Uses ax bx ds si es di
|
|---|
| 206 | test cs:[CurIO_UseExtension], 1
|
|---|
| 207 | jz DIOLS_UseNormal
|
|---|
| 208 | ; LBA-boundary >16450560 (FB0400h)
|
|---|
| 209 | cmp bx, 00FBh
|
|---|
| 210 | jae DIOLS_UseExtension
|
|---|
| 211 | ; or are we forced do use LBA?
|
|---|
| 212 | test cs:[CFG_ForceLBAUsage], 1
|
|---|
| 213 | jnz DIOLS_UseExtension
|
|---|
| 214 | DIOLS_UseNormal:
|
|---|
| 215 | mov di, 3
|
|---|
| 216 | DIOLS_ErrorLoop:
|
|---|
| 217 | push ds
|
|---|
| 218 | pop es
|
|---|
| 219 | mov bx, si ; ES:BX - Destination
|
|---|
| 220 | mov ax, 0201h ; Function 2 - Load Sector
|
|---|
| 221 | int 13h
|
|---|
| 222 | jnc DIOLS_Success
|
|---|
| 223 | dec di
|
|---|
| 224 | jnz DIOLS_ErrorLoop
|
|---|
| 225 | call MBR_LoadError
|
|---|
| 226 |
|
|---|
| 227 | DIOLS_UseExtension:
|
|---|
| 228 | push cx
|
|---|
| 229 | mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector
|
|---|
| 230 | mov wptr cs:[DriveIO_DAP_Transfer+0], si
|
|---|
| 231 | mov cx, ds
|
|---|
| 232 | mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
|
|---|
| 233 | mov wptr cs:[DriveIO_DAP_Absolute+0], ax
|
|---|
| 234 | mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
|
|---|
| 235 | push cs
|
|---|
| 236 | pop ds
|
|---|
| 237 | mov si, offset DriveIO_DAP
|
|---|
| 238 | mov ah, 42h ; Extended Read
|
|---|
| 239 | int 13h
|
|---|
| 240 | pop cx
|
|---|
| 241 | jnc DIOLS_Success
|
|---|
| 242 | call MBR_LoadError
|
|---|
| 243 |
|
|---|
| 244 | DIOLS_Success:
|
|---|
| 245 | ret
|
|---|
| 246 | DriveIO_LoadSector EndP
|
|---|
| 247 |
|
|---|
| 248 | Comment *ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
|
|---|
| 249 | Routine: Writes DS:SI to a specified sector
|
|---|
| 250 | ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
|
|---|
| 251 | Calling : bx:ax - Absolute sector
|
|---|
| 252 | cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
|---|
| 253 | ds:si - Source-Adress
|
|---|
| 254 | Returns : none
|
|---|
| 255 | Preserve: all registers
|
|---|
| 256 | ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ*
|
|---|
| 257 | DriveIO_SaveSector Proc Near Uses ax bx cx ds si es di
|
|---|
| 258 | test cs:[CurIO_UseExtension], 1
|
|---|
| 259 | jz DIOSS_UseNormal
|
|---|
| 260 | ; LBA-boundary >16450560 (FB0400h)
|
|---|
| 261 | cmp bx, 00FBh
|
|---|
| 262 | jae DIOSS_UseExtension
|
|---|
| 263 | ; or are we forced do use LBA?
|
|---|
| 264 | test cs:[CFG_ForceLBAUsage], 1
|
|---|
| 265 | jnz DIOSS_UseExtension
|
|---|
| 266 | DIOSS_UseNormal:
|
|---|
| 267 | mov di, 3
|
|---|
| 268 | DIOSS_ErrorLoop:
|
|---|
| 269 | push ds
|
|---|
| 270 | pop es
|
|---|
| 271 | mov bx, si ; ES:BX - Destination
|
|---|
| 272 | mov ax, 0301h ; Function 3 - Write Sector
|
|---|
| 273 | int 13h
|
|---|
| 274 | jnc DIOSS_Success
|
|---|
| 275 | dec di
|
|---|
| 276 | jnz DIOSS_ErrorLoop
|
|---|
| 277 | call MBR_SaveError
|
|---|
| 278 |
|
|---|
| 279 | DIOSS_UseExtension:
|
|---|
| 280 | push cx
|
|---|
| 281 | mov cs:[DriveIO_DAP_NumBlocks], 1 ; Copy ONE sector
|
|---|
| 282 | mov wptr cs:[DriveIO_DAP_Transfer+0], si
|
|---|
| 283 | mov cx, ds
|
|---|
| 284 | mov wptr cs:[DriveIO_DAP_Transfer+2], cx ; Fill out Transfer Adress
|
|---|
| 285 | mov wptr cs:[DriveIO_DAP_Absolute+0], ax
|
|---|
| 286 | mov wptr cs:[DriveIO_DAP_Absolute+2], bx ; Fill out Absolute Sector
|
|---|
| 287 | push cs
|
|---|
| 288 | pop ds
|
|---|
| 289 | mov si, offset DriveIO_DAP
|
|---|
| 290 | mov ax, 4300h ; Extended Write (No Verify)
|
|---|
| 291 | int 13h
|
|---|
| 292 | pop cx
|
|---|
| 293 | jnc DIOSS_Success
|
|---|
| 294 | call MBR_SaveError
|
|---|
| 295 |
|
|---|
| 296 | DIOSS_Success:
|
|---|
| 297 | ret
|
|---|
| 298 | DriveIO_SaveSector EndP
|
|---|