Ignore:
Timestamp:
Apr 12, 2014, 12:36:45 AM (11 years ago)
Author:
Ben Rietbroek
Message:

Now using compressed HidePartTable (auxdebug on) [2012-02-24]

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

Fixes

o HidePartTabled now uses a 6-bit compressed format

Bitfield functions are used to manipulate the table.
Modifications mostly in PARTSCAN.ASM, PART_SET.ASM and PARTMAIN.ASM.
TODO: Determine impact on upgrading from previous versions.

Changes

o Changed LVM Label behavior

If they are the same, the LVM VolumeName is synced to LVM PartitionName
so they are the same again after the edit.
If they differ, only the LVM VolumeName is updated.

o Implemented stop scanning when partition limit of 45 is exceeded

User is presented with a warning pop-up.
Pressing a key will continue and the partitions that were found
so far are displayed in the menu.
The color of the selection bar is changed to red to indicate this
overflow situation.

o New overlap macro that works correctly with JWasm and Tasm

Now uses DB n DUP (<filler>) to fill space before a new ORG.
When overlap occurs n goes negative causing assembler error.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BOOTCODE/AIR-BOOT.ASM

    r44 r45  
    6060MaxDisks                equ     64
    6161
    62 ; Only when assembled with JWasm because Tasm generates too large code.
    63 IFDEF   JWASM
    64     ; If defined then include DEBUG.ASM and output debug-info to serial-port.
    65     AUX_DEBUG       EQU
    66 ELSE
    67     ;~ AUX_DEBUG       EQU
    68 ENDIF
     62
     63
     64
     65;
     66; Include Debug Modules and enable COM-port debugging.
     67;
     68AUX_DEBUG       EQU
     69
     70
     71
    6972
    7073
     
    195198; Also, MiniLVM uses a 0-byte terminator, so the maximum length is 19d.
    196199; Same goes for LocLVM_DiskName.
     200; These offsets are relative to an LVM entry.
    197201LocLVM_VolumeName           equ     14h ; 20 bytes
    198202LocLVM_PartitionName        equ     28h ; 20 bytes (Used in menu)
     203
     204; LVM constants.
     205LocLVM_LabelLen             equ     14h ; Length of an LVM Label (Disk/Part/Vol)
     206LocLVM_DiskNameLen          equ     14h ; Length of an LVM DiskName
     207LocLVM_VolumeNameLen        equ     14h ; Length of an LVM VolumeName
     208LocLVM_PartitionNameLen     equ     14h ; Length of an LVM PartitionName
    199209
    200210
     
    216226
    217227; Hidden Partition Table
    218 LocHPT_LenOfHPT             equ     30  ; Length of an HPT-entry
     228;~ LocHPT_LenOfHPT             equ     30  ; Length of an HPT-entry
     229; Length of an HPT-entry ((45 * 6 bits-per-part) / 8) * 45
     230; Packed table !
     231LocHPT_LenOfHPT             equ     34
    219232
    220233; AiR-BOOT IPT-Flags
     
    330343; It fixes issues with huge drives and lvm and more.
    331344
    332 sos1:
    333345
    334346; ---------------------------------------------
     
    358370
    359371                ; ID String, Date (DD,MM,CC,YY), Version Number, Language ID
    360                 db      'AiRBOOT', 21h, 02h, 20h, 12h, 01h, 08h, TXT_LanguageID
     372                db      'AiRBOOT', 24h, 02h, 20h, 12h, 01h, 08h, TXT_LanguageID
    361373
    362374                ; Total Sectors Count.
     
    366378                ; Total Sectors Count,
    367379                ; Dynamic calculation.
    368                 ;~ db      (CODE_END-$)/512
     380                ;~ db      (code_end-$)/512
    369381
    370382
     
    427439MBR_HaltSys:    cli
    428440                jmp     MBR_HaltSys
    429 
     441;db 100 dup (0)
     442
     443
     444
     445                ;
     446                ; Some small space for variables.
     447                ;
     448                ORIGIN  0003Ch
    430449
    431450; Comport settings
     
    434453; It cannot be in the config-area (sector 55)
    435454; because that area is crc-protected and would not allow 'poking'.
    436 here = $
    437                 org     0003Ch
    438                 check_overlap   here
    439455BIOS_AuxParms   dw      BIOS_AUXPARMS_DEFAULT
    440456
    441457reserved        db      6   dup('X')
     458
    442459
    443460                ;
     
    449466                ; want to change the AiR-BOOT signature
    450467                ; because of Microsoft inventions...
    451 here = $
    452                 org     044h
    453                 check_overlap   here
    454 
    455 
     468                ;
     469                ORIGIN  00044h
    456470
    457471                ; Jump again...
     
    590604
    591605
    592 
    593606                ; [v1.05+]
    594607                ; Signature for IBM's LVM to detect our "powerful" features ;)
     608                ;
    595609                ; [v1.0.8+]
    596610                ; Reworked MBR code to be able to create a
     
    599613                ; MBR's created with LVM eCS v2.x have the signature at 0d0h
    600614                ; See eCS bugtracker issue #3002
     615                ;
    601616                ; Update: These are actually MOV EAX,'X31I' instructions
    602617                ; in the eCS LVM MBR-code. They are at different places in
    603618                ; the v1.x and v2.x LVM code.
    604                 ; Let's protect them with an org directive.
    605 
    606 here = $
    607                 org     00d0h
    608                 check_overlap   here
    609                 ;org     00d0h
     619                ; Let's protect their location.
     620                ORIGIN  000d0h
    610621                db      'I13X',0,'I13X',0
    611622
     
    664675
    665676
    666 here = $
    667                 org     001b8h
    668                 check_overlap   here
    669 
    670677                ; Disk Signature
    671678                ; Note that in an LVM 2.x MBR this collides
    672679                ; with the dummy PTE that it uses to look for IBM-BM
    673680                ; on the second harddisk.
     681                ORIGIN  001B8h
     682
     683                ; AiR-BOOT will merge the field from the MBR it replaces.
    674684                db      'DSIG'
    675685
    676                 ; Unused word at 01BCh
    677                 ; An LVM 2.x MBR puts 'CC33' here.
     686                ; Unused word at 01BCh.
     687                ; An LVM 2.x MBR puts 0CC33h here.
     688                ; AiR-BOOT will merge the field from the MBR it replaces.
    678689                dw      '$$'
    679690
    680691
    681 here = $
    682                 org     001beh
    683                 check_overlap   here
    684 
    685                 ; Partition Table
     692                ;
     693                ; Partition Table.
     694                ;
     695                ORIGIN  001BEh
     696
     697                ; The 4 entries just for show.
     698                ; AiR-BOOT will merge them from the MBR it replaces.
    686699                db      16  dup('0')
    687700                db      16  dup('1')
     
    693706
    694707; End of sector 1
    695 eos1a:
     708
    696709
    697710
     
    704717                ; Here starts the second sector, sector 2
    705718                ;
    706                 org     00200h
    707 ; Start of sector 2.
    708 sos2:
     719                ORIGIN  00200h
    709720
    710721;
     
    752763                         ; -> 44 Partition-Types
    753764
    754 ; End of sector 2.
    755 eos2:
    756 
    757 
    758 
    759 
    760 
    761765
    762766
     
    764768;==============================================================================
    765769                                                                    ; Sector 3
    766 here = $
    767                 org     00400h
    768                 check_overlap   here
    769 
    770 
    771 ; Start of sector 3.
    772 sos3:
     770                ;
     771                ; Sector 3
     772                ;
     773                ORIGIN  00400h
    773774
    774775
     
    811812
    812813
    813                 mov     ax, offset sobss
    814                 mov     ax,offset BeginOfVariables
    815                 mov     ax,offset [TrueSecs]
    816                 lea     ax, [TrueSecs]
    817                 mov     ax,word ptr [TrueSecs]
    818                 mov     ax,offset EndOfVariables
    819                 mov     ax, offset eobss
    820                 nop
    821                 ;~ mov     ax, offset qqqq
     814                ;~ nop
     815                ;~ mov     ax, offset sobss
     816                ;~ mov     ax,offset BeginOfVariables
     817                ;~ mov     ax,offset [TrueSecs]
     818                ;~ lea     ax, [TrueSecs]  ; Tasm generates mov here
     819                ;~ mov     ax,word ptr [TrueSecs]
     820                ;~ mov     ax,offset EndOfVariables
     821                ;~ mov     ax, offset eobss
     822                ;~ nop
     823
    822824
    823825
     
    12181220
    12191221
    1220 ; End of sector 3.
    1221 eos3:
    1222 
    1223 
    1224 
    12251222
    12261223
     
    12401237                ;org     04600h                                  ; Sector 36-37
    12411238
    1242 ; Start of sector 36.
    1243 sos36:
    1244 
    1245 
    1246 
    1247 ; End of sector 37, yes this section is 2 sectors long.
    1248 eos37:
    1249 
    1250 
    1251 
    1252 
    12531239
    12541240
     
    12621248                ;org     04A00h
    12631249
    1264 ; Start of sector 28.
    1265 sos38:
    12661250
    12671251b_txtother:
     
    12911275size_billsuxx = $-b_billsuxx
    12921276
     1277
     1278                ;
     1279                ; Critical end of code marker.
     1280                ;
     1281                db  'DEAD'
     1282                db  'FACE'
     1283
     1284;
     1285; Keep these modules here at the end of the code section.
     1286; When debugging, extra code space is used and code will move up towards
     1287; the protection image that is 'orged' and will thus overlay.
     1288; The effects are turned off in debug mode, so it does not matter much that
     1289; this code get's lost.
     1290;
    12931291b_sound:
    12941292Include SPECIAL/SOUND.ASM       ; Sound
     
    13091307Include BLDDATE.ASM                      ; Build Date generated by _build.cmd
    13101308
    1311 ; End of sector x depending on size of translatable texts.
    1312 eosx:
    1313 
    1314 
    13151309                ;
    13161310                ; End of code marker.
     
    13221316
    13231317
    1324 
    1325 here = $
    1326                 org     06800h
    1327                 ; For some reason, this overlap check does not work !!
    1328                 ; I gues it's because 'here' has no definitive value yet
    1329                 ; and since JWasm is a single pass assembler, it won't
    1330                 ; change anymore. it is off by 1dh bytes.
    1331                 ; (Changing the ORG to 6700h produces an overlap of 11dh.
    1332                 ; This 1dh is by sheer coincidence the same length as the
    1333                 ; MBR_Prot signature on my system, but it's not related.
    1334                 check_overlap   here
     1318                ;
     1319                ; AiR-BOOT Protection Image.
     1320                ;
     1321                ORIGIN  06800h
    13351322
    13361323                ;
     
    13661353                ; variables remain vaild.
    13671354                ;
    1368 here = $
    1369                 org     06C00h
    1370                 check_overlap   here
    1371 sos55:
    1372 
    1373 
     1355                ORIGIN  06C00h
    13741356
    13751357Configuration:
     
    14601442;
    14611443
    1462 ; 6cae
    1463 eoc:
    1464 
    1465 
    1466 
     1444                ;
     1445                ; Drive Letters.
     1446                ;
     1447                ORIGIN  06CB0h
     1448
     1449
     1450;
     1451; Moved here to make room for packed hiddenparttable.
     1452;
     1453DriveLetters            db  LocIPT_MaxPartitions dup (0)
     1454                        ; Format is:
     1455                        ;============
     1456                        ; Drive-Letter : BYTE (80h-C:, 81h-D:)
     1457                        ; --------------------> 1 Byte * 45
     1458
     1459                ;
    14671460                ; Allways have the name of the installation volume
    14681461                ; at this offset.
    14691462                ; So future config changes will not break auto-install.
    1470 here = $
    1471                 org     06D00h
    1472                 check_overlap   here
    1473 
    1474 soiv:
     1463                ;
     1464                ORIGIN  06D00h
    14751465
    14761466; SET(A)BOOT stores the volume name of the eCS system being installed here.
     
    14851475
    14861476
    1487 ; 6d0c
    1488 ; End of sector 55.
    1489 eos55:
    1490 
    1491 
    1492 
    1493 
    1494 
    1495 
    14961477;
    14971478; THERE IS ROOM RESERVED HERE FOR MORE VARIABLES
    14981479;
    1499 
    1500 
    15011480
    15021481                ;
     
    15041483                ; Entries allocated down from 06E00 boundary.
    15051484                ;
    1506 here = $
    1507                 org     06DABh                                  ; 427 Boundry
    1508                 check_overlap   here
    1509 sosvs:
     1485                ORIGIN  % 06DABh                                  ; 427 Boundry
    15101486
    15111487; (432 - 5 = 427)
     
    15511527;------------------------------------------------------------------------------
    15521528
    1553 eosvs:
    1554 
    1555 
    1556 
    1557 
    15581529                ;org 06E00h                                     ; Sector 56-57
    15591530
    1560 here = $
    1561                 org     image_size - 0a00h - (image_size - image_size_60secs)
    1562                 check_overlap   here
    1563 
    1564 sos56:
    1565 
    1566 
    1567 
     1531                ;
     1532                ; AiR-BOOT Internal Partition Table (IPT)
     1533                ;
     1534                ORIGIN  % (image_size - 0a00h - (image_size - image_size_60secs))
     1535
     1536
     1537;
    15681538; Rousseau: This is the start of the AiR-BOOT IPT
    1569 
    1570 PartitionTable:  ; no-partitions detected... :]
     1539;
     1540
     1541
     1542PartitionTable  db  (LocIPT_MaxPartitions * LocIPT_LenOfIPT) dup (0)
     1543; no-partitions detected... :]
    15711544;                             db    1, 0, 0, 0, 'Harddisc  1'
    15721545;                             db    0, 0FFh, Flags_BootAble
     
    15901563    ; --------------------> 34 Bytes (total maximum partition-entries = 30)
    15911564
    1592     db  (LocIPT_MaxPartitions * LocIPT_LenOfIPT) dup (0)
    1593 
    1594 
    1595 ; 73fa !!!!!!!!!!!!!!
    1596 eos56:
    1597 
    1598 
    1599 
    1600 
    1601                 ;org 071F6h
    1602 ; 73F6
     1565
    16031566
    16041567                ; No need to check overlap here because this string will
    16051568                ; be overwritten if the maximum partition count is reached.
    16061569                ; So this is not a critical boundary.
    1607                 org     image_size - 600h - (image_size - image_size_60secs) / 2 - 0ah
    1608 
    1609 soiptsig:
     1570                ORG     (image_size - 600h - (image_size - image_size_60secs) / 2 - 10)
     1571
    16101572                db 'AiRBOOTPAR' ; 1K internal partition table
    16111573
    16121574
    1613 
    1614 eoiptsig:
    1615 
    1616 
    1617 
    16181575;------------------------------------------------------------------------------
    1619                             ;org 07200h                            ; Sector 58
    1620 
    1621 here = $
    1622                 org image_size - 600h - (image_size - image_size_60secs) / 2
    1623                 check_overlap   here
    1624 soipt:
    1625 sos58:
    1626 ; 7400h
     1576                            ;org 07400h                            ; Sector 58
     1577
     1578
     1579                ;
     1580                ; Hidden Partition Table (6-bit packed as of v1.0.8)
     1581                ;
     1582                ORIGIN  % (image_size - 600h - (image_size - image_size_60secs) / 2)
     1583
    16271584HidePartitionTable      db  (LocIPT_MaxPartitions * LocHPT_LenOfHPT) dup (0FFh)
    16281585                        ; Format is:
     
    16311588                        ; --------------------> 30 Bytes * 45
    16321589
    1633 DriveLetters            db  LocIPT_MaxPartitions dup (0)
    1634                         ; Format is:
    1635                         ;============
    1636                         ; Drive-Letter : BYTE (80h-C:, 81h-D:)
    1637                         ; --------------------> 1 Byte * 45
    1638 
    1639         ;
    1640         ; There is some room here, but this is the configuration section.
    1641         ; So not available for code.
    1642         ;
    1643 
    1644 eos58:
    1645 eoipt:
    1646 
    1647 
    1648 
    1649 
    1650                 ;org 075F6h
    1651                 ; No need to check overlap here because this string will
    1652                 ; be overwritten if the maximum partition count is reached.
    1653                 ; So this is not a critical boundary.
    1654                 org     image_size - 200h -0ah
    1655                 check_overlap   here
    1656 
    1657 sohidsig:
    1658 ;
    1659                         db  'AiRBOOTHID'    ; 1K internal Hide-partition table
    1660 
    1661 
    1662 eohidsig:
    1663 
    1664 
     1590;
     1591; Driveletters were here.
     1592; Moved down to make room for packed hideparttable.
     1593;
     1594
     1595
     1596                ;
     1597                ; End of hidden partition table.
     1598                ; Check overlap here for security reasons.
     1599                ;
     1600                ORIGIN  % (image_size - 200h - 5)
     1601
     1602; 79fa - end of packed hide table
     1603                        db  'ABHID'    ; 1K internal Hide-partition table
    16651604
    16661605
     
    16681607
    16691608;------------------------------------------------------------------------------
    1670                 ;org 07600h
    1671 
    1672 here = $
    1673                 org     image_size - 200h                       ; Sector 60
    1674                 check_overlap   here
    1675 
    1676 sohid:
    1677 sos60:
     1609                ;org 07A00h
     1610                                                                ; Sector 60
     1611
     1612                ;
     1613                ; AiR-BOOT MBR Backup.
     1614                ;
     1615                ORIGIN  % (image_size - 200h)
     1616
    16781617
    16791618MBR_BackUpMBR           db  'AiR-BOOT MBR-BackUp - Just to fill this sector with something',0
    16801619AirBootRocks            db  'AiR-BOOT Rocks!',0
    16811620
    1682                         db  512-($-sohid)-2  dup(0)
    1683 
    1684 eos60:
    1685 eohid:
    1686 
    1687 
    1688 
    1689 
    1690                 ;org 077FEh
    1691 
    1692 here = $
    1693                 org     image_size - 2
    1694                 check_overlap   here
     1621                        db  (512 - ($-MBR_BackUpMBR) - 2)  dup('M')
     1622
     1623                ; End of Image signature.
     1624                ;
     1625                ORIGIN  % (image_size - 2)
    16951626                        dw      0BABEh
    16961627
    1697 eoab:
     1628
     1629                ;
     1630                ; End of Image.
     1631                ;
     1632                ORIGIN  % (image_size)
    16981633
    16991634
     
    17221657                            ; What happens before this space ??
    17231658                            ; If org 0 corruption occurs.
     1659                            ; Filling hiddenparttable goes out-of-bounds !
    17241660                            ;
    17251661                            org 02400h                         ; Uninitialized
     
    17531689NewPartitions               db  ?           ; Freshly found partitions
    17541690                                            ; Independent of SaveConfiguration
     1691TooManyPartitions           db  ?           ; Non-zero if too many partitions found
    17551692
    17561693VideoIO_Segment             dw  ?           ; Segment for Video I/O
     
    17971734SETUP_VerifyPwd             db  17 dup (?)
    17981735StartSoundPlayed            db  ?
    1799 ChangePartNameSave          db  ?
     1736ChangePartNameSave          db  ?   ; Save label after user-edit ?
     1737SyncLvmLabels               db  ?   ; Sync LVM labels after user-edit ?
    18001738
    18011739FX_UseCount                 dw  ?
     
    18981836ENDIF
    18991837
    1900             END     AIR_BOOT
    1901 
     1838            END     AiR_BOOT
     1839
Note: See TracChangeset for help on using the changeset viewer.