| 1 | ; AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
|
|---|
| 2 | ;
|
|---|
| 3 | ; This file is part of AiR-BOOT
|
|---|
| 4 | ;
|
|---|
| 5 | ; AiR-BOOT is free software: you can redistribute it and/or modify it under
|
|---|
| 6 | ; the terms of the GNU General Public License as published by the Free
|
|---|
| 7 | ; Software Foundation, either version 3 of the License, or (at your option)
|
|---|
| 8 | ; any later version.
|
|---|
| 9 | ;
|
|---|
| 10 | ; AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
|
|---|
| 11 | ; WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
|
|---|
| 12 | ; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|---|
| 13 | ; details.
|
|---|
| 14 | ;
|
|---|
| 15 | ; You should have received a copy of the GNU General Public License along with
|
|---|
| 16 | ; AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 17 | ;
|
|---|
| 18 |
|
|---|
| 19 | JUMPS
|
|---|
| 20 |
|
|---|
| 21 | Include ..\..\..\Include\asm.inc
|
|---|
| 22 | include ..\..\..\include\dos\airboot.inc
|
|---|
| 23 |
|
|---|
| 24 | .386p
|
|---|
| 25 | model large, basic
|
|---|
| 26 |
|
|---|
| 27 | code_seg segment public use16
|
|---|
| 28 | assume cs:code_seg, ds:nothing, es:nothing, ss:nothing
|
|---|
| 29 | org 100h
|
|---|
| 30 | air_boot_setup: jmp SETABOOT_Start
|
|---|
| 31 |
|
|---|
| 32 | Introduction: db 'SETABOOT - AiR-BOOT Configuration Utility (DOS) - (c) 2004-2009 by M. Kiewitz',13,10
|
|---|
| 33 | db 0
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | TXT_SYNTAX_Show db 'Syntax:', 13, 10
|
|---|
| 37 | db ' SETABOOT [/T:x or /T:NO][/B][/IBA:name]', 13, 10
|
|---|
| 38 | db 'where the parameters are:', 13, 10
|
|---|
| 39 | db ' T:x Sets timeout value to x seconds.', 13, 10
|
|---|
| 40 | db ' T:NO Disables timeout.', 13, 10
|
|---|
| 41 | db ' B Restarts the system.', 13, 10
|
|---|
| 42 | db ' IBA:name Restarts the system and automatically boot from partition/volume', 13, 10
|
|---|
| 43 | db ' specified as "name".', 13, 10
|
|---|
| 44 | db 0
|
|---|
| 45 |
|
|---|
| 46 | TXT_ERROR_IO db 'Could not access harddrive', 13, 10, 0
|
|---|
| 47 | TXT_ERROR_NoBootManager db 'SETABOOT: AiR-BOOT is not installed.', 13, 10, 0
|
|---|
| 48 | TXT_ERROR_CodeDamaged db 'SETABOOT: AiR-BOOT Code damaged!', 13, 10, 0
|
|---|
| 49 | TXT_ERROR_ConfigDamaged db 'SETABOOT: AiR-BOOT Config damaged!', 13, 10, 0
|
|---|
| 50 | TXT_ERROR_BadParm db 'SETABOOT: Bad parameter', 13, 10, 0
|
|---|
| 51 | TXT_ERROR_PartNotFound db 'SETABOOT: Partition not found in IPT.', 13, 10, 0
|
|---|
| 52 | TXT_ERROR_AnyRequired db 'SETABOOT: AiR-BOOT required for this feature.', 13, 10, 0
|
|---|
| 53 | TXT_ERROR_094required db 'SETABOOT: AiR-BOOT v0.94 required for this feature.', 13, 10, 0
|
|---|
| 54 | TXT_ERROR_PwdProtected db 'SETABOOT: This feature needs password protection to be off.', 13, 10, 0
|
|---|
| 55 | TXT_ERROR_NotBootable db 'SETABOOT: Partition not set bootable.', 13, 10, 0
|
|---|
| 56 | TXT_ConfigUpdated db 'SETABOOT: Configuration updated!', 13, 10, 0
|
|---|
| 57 | TXT_NowRebooting db 'SETABOOT: Now rebooting system...', 13, 10, 0
|
|---|
| 58 |
|
|---|
| 59 | TXT_AiRBOOTdetected db 'SETABOOT: AiR-BOOT ', 0
|
|---|
| 60 | db ' detected.', 13, 10, 0
|
|---|
| 61 |
|
|---|
| 62 | Include ..\..\..\include\dos\Const.asm
|
|---|
| 63 |
|
|---|
| 64 | AiRBOOTdetected db 0
|
|---|
| 65 |
|
|---|
| 66 | DoSetTimer db 0 ; /T:xx
|
|---|
| 67 | DoSetTimerValue db 0
|
|---|
| 68 | DoUnSetTimer db 0 ; /T:NO
|
|---|
| 69 | DoReboot db 0 ; /B
|
|---|
| 70 | DoDirectBoot db 0 ; /IBA:xx
|
|---|
| 71 | DoDirectBootPart db 0
|
|---|
| 72 |
|
|---|
| 73 | SETABOOT_Start: mov ax, cs
|
|---|
| 74 | mov ds, ax
|
|---|
| 75 | mov es, ax ; DS==ES==CS
|
|---|
| 76 | ; Show Introduction message
|
|---|
| 77 | mov si, offset Introduction
|
|---|
| 78 | call MBR_Teletype
|
|---|
| 79 |
|
|---|
| 80 | mov ax, cs
|
|---|
| 81 | mov es, ax
|
|---|
| 82 | mov bx, offset TrackZero
|
|---|
| 83 | mov dx, 0080h ; First harddrive, Sector 1
|
|---|
| 84 | mov cx, 0001h
|
|---|
| 85 | mov ax, 023Bh ; Read 59 sectors
|
|---|
| 86 | int 13h
|
|---|
| 87 | jnc LoadTrackZero_NoError
|
|---|
| 88 | mov si, offset TXT_ERROR_IO
|
|---|
| 89 | call MBR_Teletype
|
|---|
| 90 | jmp GoByeBye
|
|---|
| 91 | LoadTrackZero_NoError:
|
|---|
| 92 | ; Check Master-Boot-Record Signature
|
|---|
| 93 | cmp wptr ds:[TrackZero+01FEh], 0AA55h
|
|---|
| 94 | jne CmdLine_Analyse
|
|---|
| 95 | mov si, offset MBR_AiRBOOTCodeSig
|
|---|
| 96 | mov di, offset TrackZero+2
|
|---|
| 97 | mov cx, MBR_AiRBOOTCodeSigLen
|
|---|
| 98 | repe cmpsb
|
|---|
| 99 | jne CmdLine_Analyse
|
|---|
| 100 | ; We found AiR-BOOT signature, so check if code is intact...
|
|---|
| 101 | movzx cx, bptr ds:[TrackZero+10h]
|
|---|
| 102 | ; CX - Total-Code-Sectors-Used
|
|---|
| 103 | ; Now start at Sector 2 (Code-Image)...
|
|---|
| 104 | mov si, offset TrackZero+512
|
|---|
| 105 | xor bx, bx
|
|---|
| 106 | CheckCode_CheckSumLoop:
|
|---|
| 107 | call MBR_GetCheckOfSector
|
|---|
| 108 | loop CheckCode_CheckSumLoop
|
|---|
| 109 | cmp bx, wptr ds:[TrackZero+11h]
|
|---|
| 110 | jne AiRBOOTCodeCorrupt
|
|---|
| 111 | ; We found AiR-BOOT code that is intact
|
|---|
| 112 | mov ax, wptr ds:[TrackZero+0Dh]
|
|---|
| 113 | mov InstalledVersion_Code, ax
|
|---|
| 114 | ; Check, if Track-Zero also contains Config-Image
|
|---|
| 115 | mov si, offset MBR_AiRBOOTConfigSig
|
|---|
| 116 | mov di, offset TrackZero+6C00h
|
|---|
| 117 | mov cx, MBR_AiRBOOTConfigSigLen
|
|---|
| 118 | repe cmpsb
|
|---|
| 119 | jne AiRBOOTConfigCorrupt
|
|---|
| 120 | ; We found AiR-BOOT CONFIG signature, so check if config okay...
|
|---|
| 121 | mov si, offset TrackZero+6C00h
|
|---|
| 122 | mov dx, wptr ds:[si+20]
|
|---|
| 123 | mov wptr ds:[si+20], 0
|
|---|
| 124 | ; Save Config-Checksum in DX and kill it in [TrackZero]
|
|---|
| 125 | xor bx, bx
|
|---|
| 126 | mov cx, 5 ; Total of 5 sectors
|
|---|
| 127 | CheckConfig_CheckSumLoop:
|
|---|
| 128 | call MBR_GetCheckOfSector
|
|---|
| 129 | loop CheckConfig_CheckSumLoop
|
|---|
| 130 | cmp bx, dx
|
|---|
| 131 | jne AiRBOOTConfigCorrupt
|
|---|
| 132 | mov ax, wptr ds:[TrackZero+6C0Dh]
|
|---|
| 133 | mov InstalledVersion_Config, ax
|
|---|
| 134 | jmp AiRBOOTfound
|
|---|
| 135 |
|
|---|
| 136 | AiRBOOTnotFound:
|
|---|
| 137 | mov si, offset TXT_ERROR_NoBootManager
|
|---|
| 138 | call MBR_Teletype
|
|---|
| 139 | jmp GoByeBye
|
|---|
| 140 | AiRBOOTCodeCorrupt:
|
|---|
| 141 | mov si, offset TXT_ERROR_CodeDamaged
|
|---|
| 142 | call MBR_Teletype
|
|---|
| 143 | jmp GoByeBye
|
|---|
| 144 | AiRBOOTConfigCorrupt:
|
|---|
| 145 | mov si, offset TXT_ERROR_ConfigDamaged
|
|---|
| 146 | call MBR_Teletype
|
|---|
| 147 | jmp GoByeBye
|
|---|
| 148 |
|
|---|
| 149 | ; We found 100% INTACT AiR-BOOT...
|
|---|
| 150 | AiRBOOTfound:
|
|---|
| 151 | mov AiRBOOTdetected, 1
|
|---|
| 152 | mov si, offset TXT_AiRBOOTdetected
|
|---|
| 153 | call MBR_Teletype
|
|---|
| 154 | mov ax, InstalledVersion_Code
|
|---|
| 155 | call MBR_TeletypeNumber
|
|---|
| 156 | mov al, '.'
|
|---|
| 157 | call MBR_TeletypeSingle
|
|---|
| 158 | mov al, ah
|
|---|
| 159 | call MBR_TeletypeNumber2
|
|---|
| 160 | ; Now finish sentence ("detected")
|
|---|
| 161 | call MBR_Teletype
|
|---|
| 162 |
|
|---|
| 163 | CmdLine_Analyse:
|
|---|
| 164 | ; We now analyse the commandline...
|
|---|
| 165 | mov ah, 62h
|
|---|
| 166 | int 21h ; GET CURRENT PSP (into BX)
|
|---|
| 167 | push es
|
|---|
| 168 | mov es, bx ; ES points now to PSP-Segment
|
|---|
| 169 | movzx cx, es:[80h] ; CX - Length of Command-Line
|
|---|
| 170 | or cx, cx
|
|---|
| 171 | jz CmdLine_Done
|
|---|
| 172 | mov di, 81h ; Start at that position
|
|---|
| 173 | CmdLine_Loop:
|
|---|
| 174 | cmp bptr es:[di], '/'
|
|---|
| 175 | jne CmdLine_NextChar
|
|---|
| 176 | ; Found a delimiter
|
|---|
| 177 | inc di
|
|---|
| 178 | dec cx
|
|---|
| 179 | jz CmdLine_Done
|
|---|
| 180 | mov al, bptr es:[di] ; AL - Char that follows '/'
|
|---|
| 181 | cmp al, '?'
|
|---|
| 182 | je CmdLine_ShowSyntax
|
|---|
| 183 | and al, 0DFh ; Upcase AL
|
|---|
| 184 | cmp al, 'T'
|
|---|
| 185 | je CmdLine_SetTimeout
|
|---|
| 186 | cmp al, 'B'
|
|---|
| 187 | je CmdLine_Reboot
|
|---|
| 188 | cmp al, 'I'
|
|---|
| 189 | je CmdLine_RebootTo
|
|---|
| 190 | CmdLine_NextChar:
|
|---|
| 191 | inc di
|
|---|
| 192 | loop CmdLine_Loop
|
|---|
| 193 | jmp CmdLine_Done
|
|---|
| 194 |
|
|---|
| 195 | CmdLine_ShowSyntax:
|
|---|
| 196 | mov si, offset TXT_SYNTAX_Show
|
|---|
| 197 | call MBR_Teletype
|
|---|
| 198 | jmp GoByeBye
|
|---|
| 199 |
|
|---|
| 200 | CmdLine_SetTimeout:
|
|---|
| 201 | cmp AiRBOOTdetected, 1
|
|---|
| 202 | je CmdLine_SetTimeoutGo
|
|---|
| 203 | mov si, offset TXT_ERROR_AnyRequired
|
|---|
| 204 | call MBR_Teletype
|
|---|
| 205 | jmp GoByeBye
|
|---|
| 206 | CmdLine_SetTimeoutGo:
|
|---|
| 207 | inc di
|
|---|
| 208 | dec cx
|
|---|
| 209 | jz CmdLine_BadParm
|
|---|
| 210 | cmp bptr es:[di], ':'
|
|---|
| 211 | jne CmdLine_BadParm
|
|---|
| 212 | inc di
|
|---|
| 213 | dec cx
|
|---|
| 214 | jz CmdLine_BadParm
|
|---|
| 215 | ; Now get number or 'NO' for disabling timer
|
|---|
| 216 | mov dl, bptr es:[di]
|
|---|
| 217 | cmp dl, '0'
|
|---|
| 218 | jb CmdLine_BadParm
|
|---|
| 219 | cmp dl, '9'
|
|---|
| 220 | jbe CmdLine_SetTimeoutNumber
|
|---|
| 221 | cmp dl, 'N'
|
|---|
| 222 | jne CmdLine_BadParm
|
|---|
| 223 | ; We expect that 'N' to get followed by 'O' -> 'NO'
|
|---|
| 224 | inc di
|
|---|
| 225 | dec cx
|
|---|
| 226 | jz CmdLine_BadParm
|
|---|
| 227 | cmp bptr es:[di], 'O'
|
|---|
| 228 | jne CmdLine_BadParm
|
|---|
| 229 | ; We actually disable Timed-Boot
|
|---|
| 230 | mov DoUnSetTimer, 1
|
|---|
| 231 | jmp CmdLine_NextChar
|
|---|
| 232 |
|
|---|
| 233 | ; We expect this to be a number (0-255)
|
|---|
| 234 | CmdLine_SetTimeoutNumber:
|
|---|
| 235 | mov DoSetTimer, 1
|
|---|
| 236 | xor ax, ax
|
|---|
| 237 | mov bx, 10
|
|---|
| 238 | CmdLine_SetTimeoutNumberLoop:
|
|---|
| 239 | ; we definitely got a number in DL
|
|---|
| 240 | sub dl, '0' ; Make 0 out of '0'
|
|---|
| 241 | mul bl ; AX = AL * 10
|
|---|
| 242 | add al, dl
|
|---|
| 243 | adc ah, 0 ; Add the number to AX
|
|---|
| 244 | ; Now get next byte if available
|
|---|
| 245 | inc di
|
|---|
| 246 | dec cx ; No more left, so we are done!
|
|---|
| 247 | jz CmdLine_SetTimeoutNumberDone
|
|---|
| 248 | mov dl, bptr es:[di]
|
|---|
| 249 | cmp dl, ' ' ; Followed by space? -> Done!
|
|---|
| 250 | je CmdLine_SetTimeoutNumberDone
|
|---|
| 251 | cmp dl, '0'
|
|---|
| 252 | jb CmdLine_BadParm
|
|---|
| 253 | cmp dl, '9'
|
|---|
| 254 | ja CmdLine_BadParm
|
|---|
| 255 | jmp CmdLine_SetTimeoutNumberLoop
|
|---|
| 256 | CmdLine_SetTimeoutNumberDone:
|
|---|
| 257 | cmp ax, 255
|
|---|
| 258 | ja CmdLine_BadParm
|
|---|
| 259 | mov DoSetTimerValue, al
|
|---|
| 260 | or cx, cx ; Nothing left on commandline? -> Done
|
|---|
| 261 | jz CmdLine_Done
|
|---|
| 262 | jmp CmdLine_NextChar
|
|---|
| 263 |
|
|---|
| 264 | CmdLine_Reboot:
|
|---|
| 265 | mov DoReboot, 1
|
|---|
| 266 | jmp CmdLine_NextChar
|
|---|
| 267 |
|
|---|
| 268 | CmdLine_RebootTo:
|
|---|
| 269 | cmp AiRBOOTdetected, 1
|
|---|
| 270 | jne CmdLine_RebootToAiRBOOTrequired
|
|---|
| 271 | mov ax, InstalledVersion_Code
|
|---|
| 272 | xchg ah, al
|
|---|
| 273 | cmp ax, 094h
|
|---|
| 274 | jae CmdLine_RebootToVersionOkay
|
|---|
| 275 | CmdLine_RebootToAiRBOOTrequired:
|
|---|
| 276 | mov si, offset TXT_ERROR_094required
|
|---|
| 277 | call MBR_Teletype
|
|---|
| 278 | jmp GoByeBye
|
|---|
| 279 | CmdLine_RebootToVersionOkay:
|
|---|
| 280 | ; Check, if PasswordSystem:BYTE or PasswordedChngBoot:BYTE
|
|---|
| 281 | ; is active. We don't allow automatic boot on passworded
|
|---|
| 282 | ; systems.
|
|---|
| 283 | cmp wptr ds:[TrackZero+6C00h+37], 0
|
|---|
| 284 | je CmdLine_RebootToNoPassword
|
|---|
| 285 | mov si, offset TXT_ERROR_PwdProtected
|
|---|
| 286 | call MBR_Teletype
|
|---|
| 287 | jmp GoByeBye
|
|---|
| 288 | CmdLine_RebootToNoPassword:
|
|---|
| 289 | mov DoDirectBoot, 1
|
|---|
| 290 | mov DoReboot, 1
|
|---|
| 291 | cmp cx, 5 ; We need at least 4 more chars
|
|---|
| 292 | jb CmdLine_BadParm
|
|---|
| 293 | mov ax, wptr es:[di+1]
|
|---|
| 294 | and ax, 0DFDFh ; Upcase AX
|
|---|
| 295 | cmp ax, 'AB'
|
|---|
| 296 | jne CmdLine_BadParm
|
|---|
| 297 | cmp bptr es:[di+3], ':'
|
|---|
| 298 | jne CmdLine_BadParm
|
|---|
| 299 | add di, 4
|
|---|
| 300 | sub cx, 4
|
|---|
| 301 | ; We now need to extract the partition/volume name and
|
|---|
| 302 | ; compare it to IPT entries...
|
|---|
| 303 | ; First we will check, if there is a '"' in front. If that's
|
|---|
| 304 | ; the case, we look for an ending '"'. Otherwise till ' '/EOL
|
|---|
| 305 | mov al, ' '
|
|---|
| 306 | cmp bptr es:[di], '"'
|
|---|
| 307 | jne CmdLine_RebootToExtractName
|
|---|
| 308 | mov al, '"'
|
|---|
| 309 | inc di
|
|---|
| 310 | dec cx
|
|---|
| 311 | jz CmdLine_BadParm
|
|---|
| 312 | CmdLine_RebootToExtractName:
|
|---|
| 313 | ; AL is ending character to look for (or EOL)
|
|---|
| 314 | mov si, di ; Save start of name
|
|---|
| 315 | push cx
|
|---|
| 316 | CmdLine_RebootToExtractNameLoop:
|
|---|
| 317 | cmp bptr es:[di], al
|
|---|
| 318 | je CmdLine_RebootToExtractNameDone
|
|---|
| 319 | inc di
|
|---|
| 320 | dec cx
|
|---|
| 321 | jnz CmdLine_RebootToExtractNameLoop
|
|---|
| 322 | CmdLine_RebootToExtractNameDone:
|
|---|
| 323 | pop cx
|
|---|
| 324 | mov bx, di
|
|---|
| 325 | sub bx, si ; SI (BX) -> Partition/Volume Name
|
|---|
| 326 | or bx, bx
|
|---|
| 327 | jz CmdLine_BadParm ; If Length==0 -> Bad parameter
|
|---|
| 328 | cmp al, '"' ; Skip over '"', if not already at EOS
|
|---|
| 329 | jne CmdLine_RebootToNoFixup
|
|---|
| 330 | or cx, cx
|
|---|
| 331 | jz CmdLine_RebootToNoFixup
|
|---|
| 332 | inc di
|
|---|
| 333 | dec cx
|
|---|
| 334 | CmdLine_RebootToNoFixup:
|
|---|
| 335 | cmp bx, 11
|
|---|
| 336 | jbe CmdLine_RebootToLengthFine
|
|---|
| 337 | mov bx, 11 ; Maximum 11 chars
|
|---|
| 338 | CmdLine_RebootToLengthFine:
|
|---|
| 339 | ; Now we compare that name to the names in our IPT
|
|---|
| 340 | ; SI will keep pointing to partition/volume name to search for
|
|---|
| 341 | ; DI will point to IPT-entry (PartitionName-Item)
|
|---|
| 342 | ; BX contains length of name to search for
|
|---|
| 343 | ; DL holds total IPT entries to go
|
|---|
| 344 | ; DH holds current partition number (base 0)
|
|---|
| 345 | push cx es di
|
|---|
| 346 | mov ax, ds
|
|---|
| 347 | mov es, ax ; ES == DS for now
|
|---|
| 348 | movzx dx, bptr [TrackZero+6C00h+22] ; [Partition count]
|
|---|
| 349 | or dl, dl
|
|---|
| 350 | jz CmdLine_RebootToNotFound
|
|---|
| 351 | mov di, offset TrackZero+6E00h ; Starting at sector 56
|
|---|
| 352 | CmdLine_RebootToSearchLoop:
|
|---|
| 353 | push si di
|
|---|
| 354 | add di, 4 ; Seek to "PartitionName" item
|
|---|
| 355 | mov cx, bx
|
|---|
| 356 | rep cmpsb
|
|---|
| 357 | pop di si
|
|---|
| 358 | je CmdLine_RebootToSearchDone
|
|---|
| 359 | add di, 34 ; Length of IPT entry
|
|---|
| 360 | inc dh ; Partition number +1
|
|---|
| 361 | dec dl ; One partition less to look for
|
|---|
| 362 | jnz CmdLine_RebootToSearchLoop
|
|---|
| 363 | CmdLine_RebootToSearchDone:
|
|---|
| 364 | mov bl, ds:[di+17] ; Get "Flags"
|
|---|
| 365 | pop di es cx
|
|---|
| 366 | or dl, dl ; If no partitions left -> not found
|
|---|
| 367 | jz CmdLine_RebootToNotFound
|
|---|
| 368 | test bl, 1b ; Check, if that's bootable
|
|---|
| 369 | jz CmdLine_RebootToNotBootable
|
|---|
| 370 | ; Remember partition number for later
|
|---|
| 371 | mov DoDirectBootPart, dh
|
|---|
| 372 | or cx, cx ; Nothing left on commandline? -> Done
|
|---|
| 373 | jz CmdLine_Done
|
|---|
| 374 | jmp CmdLine_NextChar
|
|---|
| 375 | CmdLine_RebootToNotFound:
|
|---|
| 376 | mov si, offset TXT_ERROR_PartNotFound
|
|---|
| 377 | call MBR_Teletype
|
|---|
| 378 | jmp GoByeBye
|
|---|
| 379 | CmdLine_RebootToNotBootable:
|
|---|
| 380 | mov si, offset TXT_ERROR_NotBootable
|
|---|
| 381 | call MBR_Teletype
|
|---|
| 382 | jmp GoByeBye
|
|---|
| 383 |
|
|---|
| 384 | CmdLine_BadParm:
|
|---|
| 385 | mov si, offset TXT_ERROR_BadParm
|
|---|
| 386 | call MBR_Teletype
|
|---|
| 387 | jmp GoByeBye
|
|---|
| 388 |
|
|---|
| 389 | CmdLine_Done:
|
|---|
| 390 | ; Set ES back again to DS
|
|---|
| 391 | mov ax, ds
|
|---|
| 392 | mov es, ax
|
|---|
| 393 |
|
|---|
| 394 | mov dl, 1 ; DL shows if anything was changed
|
|---|
| 395 |
|
|---|
| 396 | test DoSetTimer, 1
|
|---|
| 397 | jz NoSetTimer
|
|---|
| 398 | mov al, DoSetTimerValue
|
|---|
| 399 | or al, al
|
|---|
| 400 | jz SetTimerDisableBootmenu
|
|---|
| 401 | ; Set Value [TimedBoot:BYTE] to 1 to enable Timed Boot
|
|---|
| 402 | mov bptr ds:[TrackZero+6C00h+26], 1
|
|---|
| 403 | ; Set Value [TimedSeconds:BYTE]
|
|---|
| 404 | mov bptr ds:[TrackZero+6C00h+27], al
|
|---|
| 405 | jmp DoneSetTimer
|
|---|
| 406 | SetTimerDisableBootmenu:
|
|---|
| 407 | ; Set Value [BootMenuActive:BYTE] to 0 to disable boot menu
|
|---|
| 408 | mov bptr ds:[TrackZero+6C00h+34], 0
|
|---|
| 409 | DoneSetTimer:
|
|---|
| 410 | xor dl, dl
|
|---|
| 411 | NoSetTimer:
|
|---|
| 412 |
|
|---|
| 413 | test DoUnSetTimer, 1
|
|---|
| 414 | jz NoUnSetTimer
|
|---|
| 415 | ; Set Value [TimedBoot:BYTE] to 0 to disable Timed Boot
|
|---|
| 416 | mov bptr ds:[TrackZero+6C00h+26], 0
|
|---|
| 417 | xor dl, dl
|
|---|
| 418 | NoUnSetTimer:
|
|---|
| 419 |
|
|---|
| 420 | test DoDirectBoot, 1
|
|---|
| 421 | jz NoDirectBoot
|
|---|
| 422 | ; Set Value [AutomaticBoot:BYTE] to 1 to enable direct boot
|
|---|
| 423 | mov bptr ds:[TrackZero+6C00h+170], 1
|
|---|
| 424 | mov al, DoDirectBootPart
|
|---|
| 425 | ; Set Value [AutomaticPartition:BYTE] to selection
|
|---|
| 426 | mov bptr ds:[TrackZero+6C00h+171], al
|
|---|
| 427 | xor dl, dl
|
|---|
| 428 | NoDirectBoot:
|
|---|
| 429 |
|
|---|
| 430 | or dl, dl
|
|---|
| 431 | jnz NothingChanged
|
|---|
| 432 | ; Save configuration here...
|
|---|
| 433 | ; Update counter first...
|
|---|
| 434 | add wptr ds:[TrackZero+6C00h+16], 1
|
|---|
| 435 | adc wptr ds:[TrackZero+6C00h+18], 0
|
|---|
| 436 | ; Now update checksum...
|
|---|
| 437 | mov si, offset TrackZero+6C00h
|
|---|
| 438 | ; Save Config-Checksum in DX and kill it in [TrackZero]
|
|---|
| 439 | xor bx, bx
|
|---|
| 440 | mov cx, 5 ; Total of 5 sectors
|
|---|
| 441 | push si
|
|---|
| 442 | SaveConfig_CheckSumLoop:
|
|---|
| 443 | call MBR_GetCheckOfSector
|
|---|
| 444 | loop SaveConfig_CheckSumLoop
|
|---|
| 445 | pop si
|
|---|
| 446 | mov wptr ds:[si+20], bx
|
|---|
| 447 | mov ax, cs
|
|---|
| 448 | mov es, ax ; Make sure that ES is right
|
|---|
| 449 | mov bx, si
|
|---|
| 450 | mov dx, 0080h ; First harddrive, Sector 55...
|
|---|
| 451 | mov cx, 0037h
|
|---|
| 452 | mov ax, 0305h ; Function 03, 5 sectors to write
|
|---|
| 453 | int 13h
|
|---|
| 454 | jnc ConfigUpdated
|
|---|
| 455 | mov si, offset TXT_ERROR_IO
|
|---|
| 456 | call MBR_Teletype
|
|---|
| 457 | jmp GoByeBye
|
|---|
| 458 | ConfigUpdated:
|
|---|
| 459 | mov si, offset TXT_ConfigUpdated
|
|---|
| 460 | call MBR_Teletype
|
|---|
| 461 | NothingChanged:
|
|---|
| 462 |
|
|---|
| 463 | test DoReboot, 1
|
|---|
| 464 | jz NoReboot
|
|---|
| 465 | mov si, offset TXT_NowRebooting
|
|---|
| 466 | call MBR_Teletype
|
|---|
| 467 | mov ax, 8600h
|
|---|
| 468 | mov cx, 65
|
|---|
| 469 | xor dx, dx
|
|---|
| 470 | int 15h ; Wait a little bit...
|
|---|
| 471 | db 0EAh ; Jump to eternity
|
|---|
| 472 | dw 0FFF0h
|
|---|
| 473 | dw 0F000h
|
|---|
| 474 | NoReboot:
|
|---|
| 475 |
|
|---|
| 476 | GoByeBye: mov ax, 4C00h
|
|---|
| 477 | int 21h ; Terminate us...
|
|---|
| 478 | ; End-Of-Code
|
|---|
| 479 |
|
|---|
| 480 | ; In: BX - Base Check, DS:SI - Pointer to 512-byte-area to be included
|
|---|
| 481 | ; Out: BX - Base Check Result
|
|---|
| 482 | ; Destroyed: SI will get updated (+512)
|
|---|
| 483 | MBR_GetCheckOfSector Proc Near Uses ax cx
|
|---|
| 484 | mov cx, 256
|
|---|
| 485 | MBR_GetCheckOfSector_Loop:
|
|---|
| 486 | lodsw
|
|---|
| 487 | xor ax, 0BABEh
|
|---|
| 488 | xor bx, ax
|
|---|
| 489 | loop MBR_GetCheckOfSector_Loop
|
|---|
| 490 | or bx, bx
|
|---|
| 491 | jnz MBR_GetCheckOfSector_NoFixUp
|
|---|
| 492 | mov bx, 1 ; dont allow 0, cause 0 means "empty"
|
|---|
| 493 | MBR_GetCheckOfSector_NoFixUp:
|
|---|
| 494 | ret
|
|---|
| 495 | MBR_GetCheckOfSector EndP
|
|---|
| 496 |
|
|---|
| 497 | ; In: SI - Pointer to begin of string (EOS is 0)
|
|---|
| 498 | ; Destroyed: SI
|
|---|
| 499 | MBR_Teletype Proc Near Uses ax bx cx
|
|---|
| 500 | mov ah, 0Eh
|
|---|
| 501 | mov bx, 7
|
|---|
| 502 | MBR_Teletype_Loop:
|
|---|
| 503 | lodsb
|
|---|
| 504 | or al, al
|
|---|
| 505 | jz MBR_Teletype_End
|
|---|
| 506 | int 10h
|
|---|
| 507 | jmp MBR_Teletype_Loop
|
|---|
| 508 | MBR_Teletype_End:
|
|---|
| 509 | ret
|
|---|
| 510 | MBR_Teletype EndP
|
|---|
| 511 |
|
|---|
| 512 | ; In: AL - Single char to type to screen
|
|---|
| 513 | ; Destroyed: *nothing*
|
|---|
| 514 | MBR_TeletypeSingle Proc Near Uses ax bx
|
|---|
| 515 | mov ah, 0Eh
|
|---|
| 516 | mov bx, 7
|
|---|
| 517 | int 10h
|
|---|
| 518 | ret
|
|---|
| 519 | MBR_TeletypeSingle EndP
|
|---|
| 520 |
|
|---|
| 521 | ; In: AL - BCD-number to type to screen
|
|---|
| 522 | ; Destroyed: *nothing*
|
|---|
| 523 | MBR_TeletypeNumber Proc Near Uses ax bx
|
|---|
| 524 | mov ah, al
|
|---|
| 525 | and ah, 0Fh
|
|---|
| 526 | shr al, 4
|
|---|
| 527 | add ax, 3030h
|
|---|
| 528 | cmp al, 30h
|
|---|
| 529 | je MBR_TTN_SkipDigit
|
|---|
| 530 | call MBR_TeletypeSingle
|
|---|
| 531 | MBR_TTN_SkipDigit:
|
|---|
| 532 | mov al, ah
|
|---|
| 533 | call MBR_TeletypeSingle
|
|---|
| 534 | ret
|
|---|
| 535 | MBR_TeletypeNumber EndP
|
|---|
| 536 |
|
|---|
| 537 | ; In: AL - BCD-number to type to screen (full 2 digits everytime)
|
|---|
| 538 | ; Destroyed: *nothing*
|
|---|
| 539 | MBR_TeletypeNumber2 Proc Near Uses ax bx
|
|---|
| 540 | mov ah, al
|
|---|
| 541 | and ah, 0Fh
|
|---|
| 542 | shr al, 4
|
|---|
| 543 | add ax, 3030h
|
|---|
| 544 | call MBR_TeletypeSingle
|
|---|
| 545 | mov al, ah
|
|---|
| 546 | call MBR_TeletypeSingle
|
|---|
| 547 | ret
|
|---|
| 548 | MBR_TeletypeNumber2 EndP
|
|---|
| 549 |
|
|---|
| 550 | InstalledVersion_Code dw ?
|
|---|
| 551 | InstalledVersion_Config dw ?
|
|---|
| 552 | TrackZero: db 30976 dup (?)
|
|---|
| 553 |
|
|---|
| 554 | code_seg ends
|
|---|
| 555 | end air_boot_setup
|
|---|