source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h/BootSector.asm @ 595

Last change on this file since 595 was 595, checked in by aitotat, 6 years ago
  • Int 19h reset handler now tries to boot from drive A before warm reset. This should help to get INT 10h hooked before launching booter games (meaning system reset without reseting interrupt vector table).
  • Win 95 hack temporarily removed (module not included by default). Very limited testing shows that CMOS hack seems to work with AMI bios but locks on Award BIOS.
File size: 3.8 KB
RevLine 
[392]1; Project name  :   XTIDE Universal BIOS
2; Description   :   Reading and jumping to boot sector.
3
4;
[505]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[392]7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
[505]12;
[392]13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16; GNU General Public License for more details.
[505]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
[392]19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
[505]24; BootSector_TryToLoadFromDriveDL_AndBoot
[392]25;   Parameters:
26;       DL:     Drive to boot from (translated, 00h or 80h)
27;       DS:     RAMVARS segment
28;   Returns:
29;       ES:BX:  Ptr to boot sector (if successful)
30;       CF:     Set if boot sector loaded successfully
31;               Cleared if failed to load boot sector
32;   Corrupts registers:
33;       AX, CX, DH, SI, DI, (DL if failed to read boot sector)
34;--------------------------------------------------------------------
[492]35BootSector_TryToLoadFromDriveDL_AndBoot:
[392]36    call    DetectPrint_TryToBootFromDL
[595]37    call    BootSector_LoadFirstSectorFromDriveDL
[521]38    jnc     SHORT .FirstSectorLoadedToESBX
39
40    ; Do not display timeout error (80h) for floppy drives since
41    ; it most likely mean no diskette in drive. This way we do not
42    ; display error code every time user intends to boot from hard disk
43    ; when A then C boot order is used.
[568]44    test    dl, dl
[521]45    js      SHORT .PrintFailedToLoadErrorCode   ; Hard Drive
46    cmp     ah, RET_HD_TIMEOUT
47    je      SHORT .ReturnWithCFclearSinceFailedToLoadBootSector
48    cmp     ah, RET_HD_NOMEDIA
49    je      SHORT .ReturnWithCFclearSinceFailedToLoadBootSector
50.PrintFailedToLoadErrorCode:
51    call    DetectPrint_FailedToLoadFirstSector
[568]52    jmp     SHORT .ReturnWithCFclearSinceFailedToLoadBootSector
[392]53
[521]54
55.FirstSectorLoadedToESBX:
[392]56    test    dl, dl
57    jns     SHORT .AlwaysBootFromFloppyDriveForBooterGames
58    cmp     WORD [es:bx+510], 0AA55h        ; Valid boot sector?
59    jne     SHORT .FirstHardDiskSectorNotBootable
60.AlwaysBootFromFloppyDriveForBooterGames:
[568]61    stc     ; Boot Sector loaded successfully
[595]62    jmp     SHORT Int19h_JumpToBootSectorOrRomBoot
[505]63
[392]64.FirstHardDiskSectorNotBootable:
65    mov     si, g_szBootSectorNotFound
[521]66    call    DetectPrint_NullTerminatedStringFromCSSI
67.ReturnWithCFclearSinceFailedToLoadBootSector:
68    clc
69    ret
[392]70
[492]71
[392]72;--------------------------------------------------------------------
[595]73; BootSector_LoadFirstSectorFromDriveDL
[392]74;   Parameters:
75;       DL:     Drive to boot from (translated, 00h or 80h)
76;   Returns:
77;       AH:     INT 13h error code
78;       ES:BX:  Ptr to boot sector (if successful)
79;       CF:     Cleared if read successful
80;               Set if any error
81;   Corrupts registers:
82;       AL, CX, DH, DI
83;--------------------------------------------------------------------
[595]84BootSector_LoadFirstSectorFromDriveDL:
[392]85    LOAD_BDA_SEGMENT_TO es, bx              ; ES:BX now points to...
86    mov     bx, BOOTVARS.rgbBootSect        ; ...boot sector location
87    mov     di, BOOT_READ_RETRY_TIMES       ; Initialize retry counter
88
89.ReadRetryLoop:
[505]90    mov     ax, 0201h                       ; Read 1 sector
91    mov     cx, 1                           ; Cylinder 0, Sector 1
92    xor     dh, dh                          ; Head 0
93    int     BIOS_DISK_INTERRUPT_13h
94    jc      SHORT .FailedToLoadFirstSector
95.Return:
96    ret
97
98.FailedToLoadFirstSector:
[428]99    dec     di                              ; Decrement retry counter (preserve CF)
100    jz      SHORT .Return                   ; Loop while retries left
[392]101
[428]102    ; Reset drive and retry
[505]103    xor     ax, ax                          ; AH=00h, Disk Controller Reset
[392]104    test    dl, dl                          ; Floppy drive?
[505]105    eCMOVS  ah, RESET_HARD_DISK             ; AH=0Dh, Reset Hard Disk (Alternate reset)
[392]106    int     BIOS_DISK_INTERRUPT_13h
[428]107    jmp     SHORT .ReadRetryLoop
[392]108
Note: See TracBrowser for help on using the repository browser.