Ignore:
Timestamp:
Apr 11, 2014, 8:39:07 PM (11 years ago)
Author:
Ben Rietbroek
Message:

Reworked Build Environment [2012-02-15]

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 THESE COMMITS!!

Changes

o Reworked build environment
o Start made with coding FIXCODE in C
o Moved MBR protection image
o New overlap macro
o Protect type 0x35 from edit (user popup)
o Protect type 0x35 from adding to menu (user popup)
o More...
! No LVM Label change yet

Note

o Changed license to GPL v3

See file COPYING in trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/TOOLS/INTERNAL/FIXCODE.ASM

    r31 r37  
    2121;  b) it writes totally used sectors to byte at offset 10h in the image
    2222
    23 JUMPS
    24 
    25 Include ..\..\include\asm.inc
    26 ; include ..\..\include\dos\airboot.inc
    27 
    28                 .386p
    29                 model large, basic
    30 
    31 code_seg        segment public use16
    32                 assume  cs:code_seg, ds:code_seg, es:nothing, ss:nothing
     23;JUMPS
     24
     25Include ../../INCLUDE/ASM.INC
     26
     27                .286p
     28                .model small, basic
     29
     30fixcode         group code_seg,bss_data
     31
     32code_seg        segment  use16 public 'CODE'
     33                ;assume  cs:code_seg, ds:code_seg, es:nothing, ss:nothing
     34                assume  cs:fixcode, ds:fixcode, es:nothing, ss:nothing
    3335                org     100h
    3436COM_StartUp:    jmp     COM_Init
     
    6365ShowMessage     EndP
    6466
    65 ShowError       Proc Near  Uses
     67ShowError       Proc Near
    6668   mov     ah, 09h
    6769   int     21h              ; DOS: WRITE STRING DS:DX TO CONSOLE
    68   EndProgram:
    69    mov     ax, 4C00h
    70    int     21h              ; DOS: TERMINATE PROGRAM
     70   jmp     EndProgram
     71   ret
    7172ShowError       EndP
    7273
    73 COM_Init:       mov     ax, cs
     74COM_Init:
     75                ; Setup and Copyright.
     76                mov     ax, cs
    7477                mov     ds, ax
    7578                mov     es, ax           ; CS==DS==ES
     
    7780                call    ShowMessage
    7881
    79                 ; =========================================== Load air-boot.bin
     82                ; Open AIR-BOOT.COM
    8083                mov     dx, offset COM_LoadCode
    8184                call    ShowMessage
     
    9093DoneOpenCode:   mov     bx, ax           ; BX = Filehandle
    9194
     95                ; Load AIR-BOOT.COM
    9296                mov     ah, 3Fh
    9397                mov     cx, image_size   ; Image size
     
    98102                call    ShowError
    99103
    100 DoneReadCode:   cmp     ax, image_size
     104
     105DoneReadCode:
     106                ; See if at least 'image-size' is loaded.
     107                cmp     ax, image_size
    101108                je      DoneReadCode2
    102109InvalidCode:    mov     dx, offset COM_FailedInvalidCode
    103110                call    ShowError
    104111
     112                ; Try to read again which is expected to fail.
     113                ; Otherwise image is too large.
    105114DoneReadCode2:  mov     ah, 3Fh
    106115                mov     cx, 1
     
    112121                jmp     InvalidCode
    113122
     123                ; It's loaded now, close it.
    114124DoneReadCode3:  mov     ah, 3Eh
    115125                int     21h              ; DOS: CLOSE FILE
     
    118128                call    ShowMessage
    119129
    120                 ; =================================== Load MBR-protection image
     130                ; Open MBR_PROT.COM
    121131                mov     dx, offset COM_LoadMBR
    122132                call    ShowMessage
     
    131141DoneOpenMBR:    mov     bx, ax           ; BX = Filehandle
    132142
     143                ; Load MBR_PROT.COM
    133144                mov     ah, 3Fh
    134145                mov     cx, 1024         ; Image size
     
    139150                call    ShowError
    140151
    141 DoneReadMBR:    cmp     ax, 1024
     152DoneReadMBR:
     153                ; See if at least 1kB is loaded.
     154                cmp     ax, 1024
    142155                je      DoneReadMBR2
    143156InvalidMBR:     mov     dx, offset COM_FailedInvalidMBR
    144157                call    ShowError
    145158
     159                ; Try to read again which is expected to fail.
     160                ; Otherwise image is too large.
    146161DoneReadMBR2:   mov     ah, 3Fh
    147162                mov     cx, 1
     
    153168                jmp     InvalidMBR
    154169
     170                ; It's loaded now, close file.
    155171DoneReadMBR3:   mov     ah, 3Eh
    156172                int     21h              ; DOS: CLOSE FILE
     
    159175                call    ShowMessage
    160176
     177
     178
    161179                ; ========================== Merge MBR-Protection into Bootcode
    162180                mov     dx, offset COM_MergeMBR
     
    164182
    165183                ; Search for signature in Bootcode
     184                ; Note the search is with sector granularity.
     185                ; This means the signature must be 512 bytes aligned.
    166186                mov     si, offset BootCode
    167187                mov     di, offset MBRProtectionSignature
    168188                mov     cx, MBRProtectionSignatureLen
    169                 mov     dx, 54 ; 54 sectors where signature may be (all sectors preceding config sector)
     189                ; 54 sectors where signature may be.
     190                ; (all sectors preceding config sector)
     191                mov     dx, 54
    170192COM_SignatureLoop:
    171                 push    cx si di
     193                push    cx
     194                push    si
     195                push    di
    172196                   repe    cmpsb
    173                 pop     di si cx
     197                pop     di
     198                pop     si
     199                pop     cx
    174200                je      COM_GotSignature
    175201                add     si, 512
     
    197223                mov     cx, 256
    198224                mov     dx, 53
    199 COM_CodeEndLoop:push    cx si di
     225COM_CodeEndLoop:push    cx
     226                push    si
     227                push    di
    200228COM_CodeEndLoop2:
    201229                   cmp     wptr ds:[si], 0
     
    205233                   jnz     COM_CodeEndLoop2
    206234COM_ExitCodeEndLoop:
    207                 pop     di si cx
     235                pop     di
     236                pop     si
     237                pop     cx
    208238                jne     COM_FoundCodeEnd
    209239                sub     si, 512
     
    249279                jmp     EndProgram
    250280
     281
     282EndProgram:
     283   ; DOS: TERMINATE PROGRAM
     284   mov     ax, 4C00h
     285   int     21h
     286
     287
     288
     289COM_EndOfSegment:
     290
     291code_seg        ends
     292
     293bss_data    segment  use16 public   'BSS'
    251294; Buffers for files
    252295BootCode        db  image_size dup (?)
    253296MBRProtection   db  1024 dup (?)
    254 
    255 COM_EndOfSegment:
    256 
    257 code_seg        ends
     297bss_data    ends
     298
    258299                end     COM_StartUp
Note: See TracChangeset for help on using the changeset viewer.