Ignore:
Timestamp:
Jan 13, 2013, 8:46:36 AM (13 years ago)
Author:
Ben Rietbroek
Message:

Fixed Win7 boot from FAT32 and HPFS zero-drive ussue [2011-11-20]

Fixes

o Fixed booting Windows 7 from FAT32

Booting Windows (NT/2K/XP/Vista/7) from FAT32 when the actual system
resides on an NTFS partition actually chainload the Windows
boot-loader in the FAT32 partition.
A bug in the handling of such a FAT32 partition with the Windows
boot-loader caused it not to find NTLDR is some cases.

o Fixed HPFS zero-drive issue

The BPB contains a field that indicates the boot-drive to the
OS2BOOT and OS2LDR programs. When creating an HPFS partition and
then restoring a system from archive (i.e. a zip-file) of course
does not set this field, since only files are restored.
This causes the boot process to halt with "...cannot operate..."
or even boot another HPFS partition. This field is now derived from
the LVM drive-letter if it contains an incorrect value.

o Corrected CRC calculations on AiR-BOOT configuration

V1.07 expanded the number of partitions from 30 to 45.
However, this was not done correctly and the configuration CRC was
still caclulated over 5 sectors. Initial v1.0.8 code corrected this
but this results in the v1.07 installer and setaboot programs
breaking on v1.0.8 code. So, for the time being the CRC caclucation
is reverted back to 5 sectors for the sake of v1.07 compatibility.
Save and restore of the configuration use 7 sectors of course.

o Corrected contact information

V1.07 shipped with the wrong contact information, causing issues
to be reported on sourceforge instead of netlabs.

Changes

o Renamed original README.TXT to README.MKW
o Added 1README.TXT
o Added COPYING (GNU License)

Note

This commit and all following commits upto and including the RC3
commit [2012-09-09] are delayed commits from a local repository.
Also, the RC (Release Candidate) naming of the corresponding commits
is a bit misleading. One would label a revision with RC when near to
a final release. Since many things have changed between RC1,RC2 & RC3,
these RC's should be interpreted as mile-stones.

WARNING!!

All commits upto and including the commit of [2012-05-13] contain
a severe bug!! Building from these sources and then disabling
the 'force LBA' feature while also using the drive-letter feature or
editing the label can destroy the MBR on all attached disks!!
DO NOT DISABLE 'FORCE LBA USAGE' WHEN BUILT FROM THE ABOVE COMMITS!!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BOOTCODE/REGULAR/DRIVEIO.ASM

    r31 r32  
    6262   xor     bx, bx
    6363
    64    ; Changed from 5 to calculated
     64   ; Changed from 5 to calculated value (not here, see compat. issue below)
    6565   ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
    66    mov     cx, (MBR_BackUpMBR - Configuration) / 2   ; Size of the ab-configuration
    67    ; TASM does not evaluate expression above corrrectly.
    68    ; Listing shows correct opcode but generated opcode has imm. word byteswapped.
    69    ; Casting to byte also does not work (overflow).
    70    ; So we swap back here -- must be removed in JWasm version !!
    71       xchg  ch,cl
     66   ; Size of the ab-configuration in 512 byte sectors
     67   ;mov     cx, (MBR_BackUpMBR - Configuration) / 200h
     68
     69   ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
     70   ; AB v1.0.8 *should* stores a 7 sector configuration with a
     71   ; 7 sector checksum.
     72   ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8
     73   ; config as corrupted, while this is not the case.
     74   ; So, for compatibility reasons, in v1.0.8, the checksum stored is over
     75   ; 5 sectors, to be compatible with v1.07.
     76   ; This may change (be corrected) in future versions !
     77   mov     cx,5
    7278
    7379   mov     dx, [CFG_CheckConfig]
     
    8389   mov     cx, 0037h
    8490
    85    ; Changed from 5 to calculated
     91   ; Changed from 5 to calculated value
    8692   ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
    87    mov     ax, (MBR_BackUpMBR - Configuration) / 2  ; sizeof(ab-configuration) to write
    88    ; TASM does not evaluate expression above corrrectly.
    89    ; Listing shows correct opcode but generated opcode has imm. word byteswapped.
    90    ; Casting to byte also does not work (overflow).
    91    ; So we swap back here -- must be removed in JWasm version !!
    92       xchg  ah,al
     93   ; Size of the ab-configuration in 512 byte sectors
     94   mov     al, (MBR_BackUpMBR - Configuration) / 200h
    9395   mov     ah,03h
    9496
     
    250252         ; Dump drive
    251253         mov      si,offset drive
    252          call     AuxIO_Print
     254;         call     AuxIO_Print
    253255         xchg     al,dl
    254          call     AuxIO_TeletypeHexByte
    255          call     AuxIO_TeletypeNL
     256;         call     AuxIO_TeletypeHexByte
     257;         call     AuxIO_TeletypeNL
    256258         xchg     dl,al
    257259
    258260         ; Dump SPT
    259261         mov      si,offset spt_used
    260          call     AuxIO_Print
     262;         call     AuxIO_Print
    261263         push     dx
    262264         push     bx
     
    271273            ;mov      [ts],ax
    272274
    273             call     AuxIO_TeletypeHexWord
    274             call     AuxIO_TeletypeNL
     275;            call     AuxIO_TeletypeHexWord
     276;            call     AuxIO_TeletypeNL
    275277         pop      bx
    276278         pop      dx
     
    281283               mov      dx,word ptr [ExtendedAbsPos+02]
    282284               mov      ax,word ptr [ExtendedAbsPos+00]
    283                call     AuxIO_TeletypeHexDWord
    284                call     AuxIO_TeletypeNL
     285;               call     AuxIO_TeletypeHexDWord
     286;               call     AuxIO_TeletypeNL
    285287            pop      dx
    286288
     
    293295
    294296            mov      ax, word ptr[bx]
    295             call     AuxIO_TeletypeHexWord
    296             call     AuxIO_TeletypeNL
     297;            call     AuxIO_TeletypeHexWord
     298;            call     AuxIO_TeletypeNL
    297299            mov      al,[ExtendedAbsPosSet]           ; if true -> 1st sector of extpart (EBR), not logpart(BPB)
    298             call     AuxIO_TeletypeHexByte
    299             call     AuxIO_TeletypeNL
     300;            call     AuxIO_TeletypeHexByte
     301;            call     AuxIO_TeletypeNL
    300302      ;      mov      si,offset PartitionSector
    301303      ;      call     AuxIO_DumpSector
     
    304306         ; LBA
    305307         mov      si,offset before_lvm_adjust
    306          call     AuxIO_Print
     308;         call     AuxIO_Print
    307309
    308310         xchg     dx,bx
    309          call     AuxIO_TeletypeHexDWord
    310          call     AuxIO_TeletypeNL
     311;         call     AuxIO_TeletypeHexDWord
     312;         call     AuxIO_TeletypeNL
    311313         xchg     bx,dx
    312314      popa
     
    322324      pusha
    323325         mov      si,offset before_lvm_adjust_log
    324          call     AuxIO_Print
     326;         call     AuxIO_Print
    325327         ; LBA
    326328         xchg     dx,bx
    327          call     AuxIO_TeletypeHexDWord
    328          call     AuxIO_TeletypeNL
     329;         call     AuxIO_TeletypeHexDWord
     330;         call     AuxIO_TeletypeNL
    329331         xchg     bx,dx
    330332      popa
     
    349351      pusha
    350352         mov      si,offset after_lvm_adjust_log
    351          call     AuxIO_Print
     353;         call     AuxIO_Print
    352354         ; LBA
    353355         xchg     dx,bx
    354          call     AuxIO_TeletypeHexDWord
    355          call     AuxIO_TeletypeNL
     356;         call     AuxIO_TeletypeHexDWord
     357;         call     AuxIO_TeletypeNL
    356358         xchg     bx,dx
    357359      popa
     
    432434      pusha
    433435         mov      si,offset after_lvm_adjust
    434          call     AuxIO_Print
     436;         call     AuxIO_Print
    435437         ; LBA
    436438         xchg     dx,bx
    437          call     AuxIO_TeletypeHexDWord
    438          call     AuxIO_TeletypeNL
     439;         call     AuxIO_TeletypeHexDWord
     440;         call     AuxIO_TeletypeNL
    439441         xchg     bx,dx
    440442      popa
     
    583585   pushf
    584586   pusha
    585       call     AuxIO_TeletypeNL
     587;      call     AuxIO_TeletypeNL
    586588      mov      si,offset db_curlvmsec
    587       call     AuxIO_Print
     589;      call     AuxIO_Print
    588590      mov      dx,bx
    589       call     AuxIO_TeletypeHexDWord
    590       call     AuxIO_TeletypeNL
     591;      call     AuxIO_TeletypeHexDWord
     592;      call     AuxIO_TeletypeNL
    591593      mov      si,offset LVMSector
    592       call     AuxIO_DumpSector
    593       call     AuxIO_TeletypeNL
     594;      call     AuxIO_DumpSector
     595;      call     AuxIO_TeletypeNL
    594596   popa
    595597   popf
     
    733735DriveIO_LoadSector              EndP
    734736
     737
     738
     739;
     740; ############################################################
     741; # Load a specified sector from a disk using LBA addressing #
     742; ############################################################
     743;
     744; In
     745; --
     746; DL     = Physical Disk
     747; BX:CX  = LBA sector
     748; DI:SI  = Target buffer
     749;
     750; Out
     751; ---
     752; AX     = Error code
     753;
     754DriveIO_LoadSectorLBA           Proc Near  Uses bx cx dx si di ds es
     755      ; Get one sector
     756      mov     cs:[DriveIO_DAP_NumBlocks], 1
     757
     758      ; Setup buffer address
     759      mov     wptr cs:[DriveIO_DAP_Transfer+0], si
     760      mov     wptr cs:[DriveIO_DAP_Transfer+2], di
     761
     762      ; Setup LBA address of requested sector
     763      mov     wptr cs:[DriveIO_DAP_Absolute+0], cx
     764      mov     wptr cs:[DriveIO_DAP_Absolute+2], bx
     765      mov     wptr cs:[DriveIO_DAP_Absolute+4], 0
     766      mov     wptr cs:[DriveIO_DAP_Absolute+6], 0
     767
     768      ; Address of packet
     769      mov     si, offset DriveIO_DAP
     770
     771      ; Do the extended read
     772      mov     ah, 42h
     773      int     13h
     774
     775      ; Looking goot so far
     776      jnc     DriveIO_LoadSectorLBA_succes1
     777
     778      ; AH should not be zero, if it is then set to undefined and set carry
     779      test    ah,ah
     780      jnz     DriveIO_LoadSectorLBA_error1
     781      mov     ah, 0bbh        ; Undefined error
     782   DriveIO_LoadSectorLBA_error1:
     783      stc
     784      jmp     DriveIO_LoadSectorLBA_exit
     785
     786      ; AL should be zero, if not then set to undefined and set carry
     787   DriveIO_LoadSectorLBA_succes1:
     788      test    ah,ah
     789      jz      DriveIO_LoadSectorLBA_exit
     790      stc
     791      jmp     DriveIO_LoadSectorLBA_exit
     792
     793      ; Return to caller
     794   DriveIO_LoadSectorLBA_exit:
     795      ret
     796DriveIO_LoadSectorLBA           EndP
     797
     798
     799
     800
    735801; #########################################################################
    736802; Routine: Writes DS:SI to a specified sector
     
    796862; See if a LVM-sector is valid.
    797863; In  : si, pointer to sector
    798 ; Out : ZF=true, not valid; ZF=false, valid
     864; Out : CY if valid LVM sector, NC if not
    799865DriveIO_LVMSectorValid           Proc  Near
    800       pusha
    801 
    802       call     LVM_CheckSectorSignature
    803       mov      al,0
    804       rcl      al,1                          ; Move CY to AL.0
    805       call     AuxIO_TeletypeHexByte
    806       call     AuxIO_TeletypeNL
    807       or       al,al                         ; Zero if not a valid sector
    808       jz       DriveIO_LVMSectorValid_End    ; Not a valid sector
    809 
    810       call     LVM_CheckSectorCRC
    811       stc
    812       mov      al,0
    813       rcl      al,1                          ; Move CY to AL.0
    814       call     AuxIO_TeletypeHexByte
    815       call     AuxIO_TeletypeNL
    816       or       al,al                         ; Zero if not a valid sector
    817 
    818    DriveIO_LVMSectorValid_End:
    819 
    820       popa
    821       ret
     866        pusha
     867
     868        call     LVM_CheckSectorSignature
     869        ; NC if no signature found
     870        jnc       DriveIO_LVMSectorValid_End
     871
     872        call     LVM_CheckSectorCRC
     873        ; Force valid !!!
     874        stc
     875
     876    DriveIO_LVMSectorValid_End:
     877        popa
     878        ret
    822879DriveIO_LVMSectorValid           EndP
    823880
     
    838895; This is also the case when no valid master LVM-sector can be found.
    839896;
    840 ; Return ZF=true if not found, ZF=false when valid master LVM-sector found.
     897; Return CF when valid master LVM sector found, NC if not.
     898; Loads sector at [LVMSector] !
    841899DriveIO_LoadMasterLVMSector      Proc  Near
    842       pusha
    843 
    844       mov      si,offset db_lmlvm
    845       ;call     AuxIO_Print
    846 
    847       mov      al,dl
    848       ;call     AuxIO_TeletypeHexByte
    849       ;call     AuxIO_TeletypeNL
    850 
    851 
    852       ; Loop over the sector-translation table,
    853       ; process the first three values from high (255) to low (bios spt, most likely 63)
    854       mov      cx,3
    855 DriveIO_LoadMasterLVMSector_NextTry:
    856       mov      bx,offset secs_per_track_table         ; sector translation table that corresponds with IsHugeDrive
    857       mov      si, offset LVMSector                   ; space to load the master LVM-sector
    858       mov      [DriveIO_DAP_NumBlocks],1              ; number of sectors to read
    859       mov      wptr [DriveIO_DAP_Transfer+0],si       ; low part of transfer address
    860       mov      ax, ds
    861       mov      wptr [DriveIO_DAP_Transfer+2],ax       ; high part of transfer address
    862       mov      ax,cx                                  ; use the counter...
    863       dec      ax                                     ; as an index into the table
    864       xlatb                                           ; translate to number of sectors
    865       dec      al                                     ; LBA is zero-based, so adjust
     900        pusha
     901
     902        mov      si,offset db_lmlvm
     903        ;call     AuxIO_Print
     904
     905        ; Physical disk
     906;        mov     al,'<'
     907;        call    VideoIO_PrintSingleChar
     908;        mov     al,dl
     909;        call    VideoIO_PrintHexByte
     910;        mov     al,'>'
     911;        call    VideoIO_PrintSingleChar
     912
     913        ;call     AuxIO_TeletypeHexByte
     914        ;call     AuxIO_TeletypeNL
     915
     916
     917        ; Loop over the sector-translation table,
     918        ; process the first three values from high (255) to low (bios spt, most likely 63)
     919        mov      cx,3
     920    DriveIO_LoadMasterLVMSector_NextTry:
     921        ; Number of sectors to read
     922        mov     [DriveIO_DAP_NumBlocks],1
     923
     924        ; Setup destination address
     925        mov     si, offset LVMSector
     926        mov     wptr [DriveIO_DAP_Transfer+0],si
     927        mov     ax, ds
     928        mov     wptr [DriveIO_DAP_Transfer+2],ax
     929
     930        ; Get the sector-number of the next possible LVM sector (255,127,63)
     931        ; using the translation table and the counter as the index
     932        mov     bx,offset secs_per_track_table
     933        mov     ax,cx
     934        dec     ax
     935        xlatb
     936        dec     al
     937
     938        ;
     939        ; AX now contains the LBA address of the sector
     940        ; that could be an LVM sector.
     941        ; This is all in track0 so the address will not exceed 64kiB sectors.
     942        ;
     943
     944;        push    ax
     945;        push    ax
     946;        mov     al,'$'
     947;        call    VideoIO_PrintSingleChar
     948;        pop     ax
     949;        call    VideoIO_PrintHexByte
     950;        mov     al,'$'
     951;        call    VideoIO_PrintSingleChar
     952;        pop     ax
    866953
    867954IFDEF AuxDebug
     
    871958ENDIF
    872959
    873       mov      wptr [DriveIO_DAP_Absolute+0],ax       ; LBA low      ;
    874       mov      wptr [DriveIO_DAP_Absolute+2],00h      ; LBA high
    875       mov      si, offset DriveIO_DAP                 ; address request packet
    876       mov      ah, 42h
    877       int      13h                                    ; do the i/o
    878       jc       DriveIO_LoadMasterLVMSector_NotFound   ; oops, there was an error
    879 
    880 IFDEF AuxDebug
    881       ; Dump title
    882       mov      si,offset db_masterlvm
    883       ;call     AuxIO_Print
    884 
    885       ; Dum sector
    886       mov      si, offset LVMSector
    887       ;call     AuxIO_DumpSector
    888       ;call     AuxIO_TeletypeNL
    889 ENDIF
    890       ; See is this is a valid LVM-sector
    891       call     DriveIO_LVMSectorValid
    892 
    893 IFDEF AuxDebug
    894       pushf
    895       ;call     AuxIO_TeletypeNL
    896       popf
    897 ENDIF
    898       ; Yep, we found the master LVM-sector
    899       jnz      DriveIO_LoadMasterLVMSector_Found
    900       ; Try next location
    901       loop     DriveIO_LoadMasterLVMSector_NextTry
    902 
    903    ; No master LVM-sector found, set ZF=true
    904    DriveIO_LoadMasterLVMSector_NotFound:
    905       xor      ax,ax
    906 
    907    ; Jump here with ZF=false if found
    908    DriveIO_LoadMasterLVMSector_Found:
    909 
    910       popa
    911       ret
     960        ; Setup the requested LBA sector number
     961        mov     wptr [DriveIO_DAP_Absolute+0],ax       ; LBA low
     962        mov     wptr [DriveIO_DAP_Absolute+2],00h      ; LBA high
     963        mov     si, offset DriveIO_DAP                 ; address request packet
     964        mov     ah, 42h
     965        int     13h                                    ; do the i/o
     966        cmc     ; Complement carry so we can exit imm. on error
     967        jnc     DriveIO_LoadMasterLVMSector_End  ; oops, return with NC
     968
     969
     970        mov     si,offset LVMSector
     971
     972        ; See if this is a valid LVM-sector
     973        call     DriveIO_LVMSectorValid
     974
     975;        pushf
     976;        mov     ah,0
     977;        rcl     ah,1
     978;        mov     al,'|'
     979;        call    VideoIO_PrintSingleChar
     980;        mov     al,ah
     981;        call    VideoIO_PrintHexByte
     982;        mov     al,'|'
     983;        call    VideoIO_PrintSingleChar
     984;        popf
     985
     986
     987        ; Yep, we found the master LVM-sector
     988        jc      DriveIO_LoadMasterLVMSector_Found
     989        ; Try next location
     990        loop     DriveIO_LoadMasterLVMSector_NextTry
     991
     992        ; No master LVM-sector found, set CF=false
     993        clc
     994
     995    DriveIO_LoadMasterLVMSector_Found:
     996    DriveIO_LoadMasterLVMSector_End:
     997        popa
     998        ret
    912999DriveIO_LoadMasterLVMSector     Endp
    9131000
Note: See TracChangeset for help on using the changeset viewer.