Changeset 77


Ignore:
Timestamp:
Apr 8, 2017, 12:26:14 AM (8 years ago)
Author:
Ben Rietbroek
Message:

Removed hard-coded '80h' from the MBR loader code [v1.1.1-testing]

The initial MBR loader code always assumed 80h was the boot-disk.
However, some BIOSses can directly boot from a secundairy disk, which
will have disk-numer 81h or above. Now the value passed in DL is used,
so AirBoot can load its remaining code and config sectors from the
correct disk.

A VirtualBox test scenario would be:

  • Connect an empty drive on IDE MASTER
  • Connect an AirBoot drive on IDE SLAVE
  • Start the VM and press F12
  • Boot directly from the SLAVE

Previous builds would hang and this build makes it to the menu.

Don't do this test with valuable disks attached coz stray writes may
still be present. These will be fixed in upcoming commits.

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bootcode/airboot.asm

    r76 r77  
    120120BIOS_AUXPARMS_DEFAULT   EQU     (AUX_INIT_PARMS SHL 8) OR BIOS_COM_PORT
    121121
     122; Default byte value for BIOS_BootDisk variabls
     123BIOS_BOOTDISK_DEFAULT   EQU     80h
    122124
    123125
     
    492494                                ; =MICROSOFT JUMP DEPARTMENT=
    493495
    494 
    495496                ; Push all registers with values provided by the BIOS
    496497                ; on the stack.
    497498                pusha
    498                 ; Temporary save SS and SP so we still have access to this
    499                 ; stack after we have setup our own.
    500                 mov     dx,ss
    501                 mov     bx,sp
    502499
    503500                ;
     
    539536                rep     movsw
    540537
     538                ; Temporary save SS and SP so we still have access to this
     539                ; stack after we have setup our own.
     540                mov     cx,ss
     541                mov     bx,sp
     542
    541543                ; Code an intersegment jump to the new location.
    542544                ; jmp    BootBaseSeg:BootBaseExec
     
    570572
    571573
    572                 ;
    573                 ; Some small space for variables.
    574                 ;
     574                ; Base of some MBR variables
    575575                ORIGIN  0003Ch
     576
     577MBR_Variables:
    576578
    577579; Comport settings.
     
    581583BIOS_AuxParms   dw      BIOS_AUXPARMS_DEFAULT
    582584
    583 
     585; When the BIOS turns over control to the MBR, DL holds the BIOS disk-number
     586; from which the boot was initiated. This would normally be 80h, corresponding
     587; to the first physical disk. However, some modern BIOSses can directly boot
     588; from other disks, so AirBoot cannot assume being loaded from 80h anymore.
     589; So here we store the BIOS disk-number passed in DL when AirBoot got control.
     590BIOS_BootDisk   db      BIOS_BOOTDISK_DEFAULT   ; Get overwritten with 'DL'
     591
     592; Reserved space for future variables.
    584593IFDEF   AUX_DEBUG
    585 reserved        db      6   dup('X')
     594reserved        db      5   dup('X')
    586595ELSE
    587 reserved        db      6   dup(0)
     596reserved        db      5   dup(0)
    588597ENDIF
    589598
     
    594603;                                                           SECOND ENTRY-POINT
    595604; -----------------------------------------------------------------------------
     605
    596606                ;
    597607                ; We arrive here after the first jump using the 'A' of the
     
    685695;
    686696; When we arrive here we are running at 8000:0000.
    687 ; DX:BX contains the SS:SP of the old stack.
     697; CX:BX contains the SS:SP of the old stack.
    688698;
    689699
     
    704714
    705715                ;
    706                 ; Push the old SS:SP which was saved in DX:BX on the new stack.
    707                 ;
    708                 push    dx      ; Old SS
     716                ; Push the old SS:SP which was saved in CX:BX on the new stack.
     717                ;
     718                push    cx      ; Old SS
    709719                push    bx      ; Old SP
    710720
     721                ;
     722                ; Store the BIOS disk-number AirBoot was loaded from.
     723                ;
     724                mov     [BIOS_BootDisk], dl
    711725
    712726                ; Load the configuration-sectors from disk.
    713727                ; These are the main configuration sector and the various
    714728                ; tables that follow it upto but not including the MBR backup.
    715                 mov     bx, offset Configuration
    716                 mov     dx, 0080h       ; First harddrive
    717                 mov     cx, 0037h       ; Config sector is at 55d (CHS)
    718 
    719                 ; Call the i/o-part
    720                 call    MBR_LoadConfig
     729                mov     bx, offset Configuration    ; Location in RAM
     730                mov     cx, 0037h                   ; Config sector is at 55d
     731                mov     al, (MBR_BackUpMBR - Configuration) / 200h
     732                mov     ah, 02h
     733                ; DL is already loaded with BIOS disk-number
     734                int     13h                             ; Call BIOS service
    721735                jnc     MBR_ConfigCopy_NoError
    722736
    723737                ; Some error occured
    724738    MBR_ConfigCopy_LoadError:
    725                 call    MBR_LoadError               ; Will Abort BootUp
    726 
    727                 ; Load the code sectors
     739                jmp     MBR_LoadError                   ; Will Abort BootUp
     740
     741                ; Load the code-sectors from disk.
     742                ; [MBR_CodeSecs] is filled in by the FIXCODE helper that post
     743                ; processes the AIRBOOT loader image after it has been built.
    728744    MBR_ConfigCopy_NoError:
    729                 mov     bx, offset FurtherMoreLoad  ; Directly after MBR in mem
    730                 mov     dx, 0080h                   ; First harddrive
    731                 mov     cx, 0002h                   ; Start at second sector
    732                 mov     ah, 02h                     ; Read sectors
    733 
    734                 ; This location is in the MBR.
    735                 ; It is filled in by the FIXCODE helper that post processes
    736                 ; the AIRBOOT loader image after it has been built.
    737                 ; FIXCODE also embeds the MBR protection-image.
    738                 mov     al, ds:[10h]                ; Number of code sectors
    739                 int     13h                         ; Call BIOS service
     745                mov     bx, offset  FurtherMoreLoad     ; Directly after MBR
     746                mov     cx, 0002h                       ; Start at 2nd sector
     747                mov     al, [MBR_CodeSecs]              ; Number of code sectors
     748                mov     ah, 02h                         ; Read sectors
     749                ; DL is already loaded with BIOS disk-number
     750                int     13h                             ; Call BIOS service
    740751                jnc     MBR_RealStart_NoError
    741                 jmp     MBR_ConfigCopy_LoadError
    742 
     752
     753                ; Some error occured
     754                jmp     MBR_LoadError                   ; Will Abort BootUp
     755
     756
     757                ; I13X Signatures
     758                ORIGIN  000d0h
    743759
    744760                ; [v1.05+]
     
    756772                ; the v1.x and v2.x LVM MBR-code. Other code might depend on
    757773                ; their presence. Let's protect their location.
    758                 ORIGIN  000d0h
    759774                db      'I13X',0,'I13X',0
    760775
     
    805820;------------------------------------------------------------------------------
    806821
    807 
    808 
    809 ; This is an ugly kludge function to create space for the
    810 ; double 'I13X' signature.
    811 ; It loads the configuration sectors, but bx,cx and dx are not initialized
    812 ; in this function. That's done around line 500.
    813 ; Putting this few bytes here creates just enough room.
    814 MBR_LoadConfig  Proc Near
    815         ; Changed from conditional assembler to calculated value
    816         ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
    817         ; Size of the ab-configuration in 512 byte sectors
    818         mov     al, (MBR_BackUpMBR - Configuration) / 200h
    819         mov     ah,02h
    820         int     13h
    821         ret
    822 MBR_LoadConfig  EndP
     822                ; Disk Signature
     823                ORIGIN  001B8h
    823824
    824825
     
    827828                ; with the dummy PTE that it uses to look for IBM-BM
    828829                ; on the second harddisk.
    829                 ORIGIN  001B8h
    830 
    831830                ; AiR-BOOT installer will merge the field
    832831                ; from the MBR it replaces.
     
    840839
    841840
    842                 ;
    843841                ; Partition Table.
    844                 ;
    845842                ORIGIN  001BEh
    846843
     
    870867; -----------------------------------------------------------------------------
    871868
    872 
     869                ; First sector the rest of the loader image
    873870                ORIGIN  00200h
    874871
     
    930927; -----------------------------------------------------------------------------
    931928
     929                ; The entry-point jumped to from the MBR code
    932930                ORIGIN  00400h
    933931
    934932
    935 ; ############################################
    936 ; # ENTRY-POINT AFTER ALL THE INITIAL HASSLE #
    937 ; ############################################
     933;##############################################################################
     934;# AiR_BOOT_Start :: This is where the real work begins                       #
     935;# -------------------------------------------------------------------------- #
     936;# At this point, all of AirBoot is loaded, including its configuration.      #
     937;# First, some setup is done, which includes the initialization of variables  #
     938;# in the BSS. After that, disks are scanned for partitions and the required  #
     939;# house keeping is done to incorporate changes from the previous boot. Then  #
     940;# the partition list is prepared and the menu is presented.                  #
     941;##############################################################################
    938942; BOOKMARK: AiR_BOOT_Start (AiR-BOOT now completely loaded)
    939943AiR_BOOT_Start:
     
    954958        pop     [OldSS]
    955959
     960
     961        ; Verify we still got the BIOS disk in DL
     962        IFDEF   AUX_DEBUG
     963            mov     ax, dx
     964            call    AuxIO_TeletypeHexWord
     965            call    AuxIO_TeletypeNL
     966            mov     ax, bx
     967            call    AuxIO_TeletypeHexWord
     968            call    AuxIO_TeletypeNL
     969            xor     ah, ah
     970            mov     al, [BIOS_BootDisk]
     971            call    AuxIO_TeletypeHexWord
     972            call    AuxIO_TeletypeNL
     973        ENDIF
    956974
    957975; -----------------------------------------------------------------------------
     
    10391057
    10401058
    1041 
    1042 
    10431059            ;!
    10441060            ;! DEBUG_BLOCK
     
    10581074;                                                               PARTITION SCAN
    10591075; -----------------------------------------------------------------------------
     1076
     1077
     1078
     1079
     1080
     1081
    10601082                ;
    10611083                ; BOOKMARK: Scan all partitions
Note: See TracChangeset for help on using the changeset viewer.