Changeset 241 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm


Ignore:
Timestamp:
Feb 9, 2012, 11:08:59 AM (12 years ago)
Author:
gregli@…
google:author:
gregli@hotmail.com
Message:

Space optimizations in the Boot Menu and BootInfo routines, taking advantage of nested %s. Optimization in the init of RamVars to avoid writing the signature twice. Preparing for addition of serial floppy support, starting to break the assumption that our drives are always 80h or higher.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm

    r181 r241  
    1616;   Returns:
    1717;       ES:BX:  Ptr to BOOTNFO (if successful)
    18 ;       CF:     Cleared if BOOTNFO created succesfully
    19 ;               Set if any error
    2018;   Corrupts registers:
    21 ;       AX, BX, CX, DX
     19;       AX, BX, CX, DX, DI, SI
    2220;--------------------------------------------------------------------
    2321BootInfo_CreateForHardDisk:
    24     call    BootInfo_GetOffsetToBX      ; ES:BX now points to new BOOTNFO
    25     ; Fall to .StoreSectorCount
     22    call    BootInfo_ConvertDPTtoBX     ; ES:BX now points to new BOOTNFO
     23    push    bx                          ; Preserve for return
    2624
    27 ;--------------------------------------------------------------------
    28 ; .StoreSectorCount
    29 ;   Parameters:
    30 ;       ES:BX:  Ptr to BOOTNFO
    31 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    32 ;       DS:DI:  Ptr to Disk Parameter Table
    33 ;   Returns:
    34 ;       Nothing
    35 ;   Corrupts registers:
    36 ;       AX, CX, DX
    37 ;--------------------------------------------------------------------
    38 .StoreSectorCount:
    39     push    bx
    40     call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
    41     mov     cx, bx                          ; Now in CX:DX:AX
    42     pop     bx
    43     mov     [es:bx+BOOTNFO.twSectCnt], ax
    44     mov     [es:bx+BOOTNFO.twSectCnt+2], dx
    45     mov     [es:bx+BOOTNFO.twSectCnt+4], cx
    46     ; Fall to .StoreDriveName
     25    mov     di, bx                      ; Starting pointer at beginning of structure
    4726
    48 ;--------------------------------------------------------------------
    49 ; .StoreDriveName
    50 ;   Parameters:
    51 ;       ES:BX:  Ptr to BOOTNFO
    52 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    53 ;       DS:DI:  Ptr to Disk Parameter Table
    54 ;   Returns:
    55 ;       CF:     Cleared if variables stored succesfully
    56 ;               Set if any error
    57 ;   Corrupts registers:
    58 ;       AX, CX
    59 ;--------------------------------------------------------------------
    60 .StoreDriveName:
    61     push    ds
    62     push    si
    63     push    di
     27;
     28; Store Drive Name
     29;       
     30    push    ds                          ; Preserve RAMVARS
     31    push    si                          ; Preserve SI for call to GetTotalSectorCount...
    6432
    65     push    es
     33    push    es                          ; ES copied to DS
    6634    pop     ds
     35
    6736    add     si, BYTE ATA1.strModel      ; DS:SI now points drive name
    6837    lea     di, [bx+BOOTNFO.szDrvName]  ; ES:DI now points to name destination
     
    7443    loop    .CopyNextWord
    7544    xor     ax, ax                      ; Zero AX and clear CF
    76     stosb                               ; Terminate with NULL
     45    stosw                               ; Terminate with NULL
    7746
    78     pop     di
    7947    pop     si
    8048    pop     ds
     49
     50;
     51; Store Sector Count
     52;
     53    call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
     54
     55    stosw
     56    xchg    ax, dx
     57    stosw
     58    xchg    ax, bx
     59    stosw
     60
     61    pop     bx
     62       
    8163    ret
    8264
    83 
     65       
    8466;--------------------------------------------------------------------
    8567; Finds BOOTNFO for drive and returns total sector count.
     
    8769; BootInfo_GetTotalSectorCount
    8870;   Parameters:
    89 ;       DL:     Drive number
    90 ;       DS:     RAMVARS segment
     71;       DS:DI:      DPT Pointer
    9172;   Returns:
    9273;       BX:DX:AX:   48-bit sector count
     
    9778BootInfo_GetTotalSectorCount:
    9879    push    ds
    99     call    BootInfo_GetOffsetToBX
     80    call    BootInfo_ConvertDPTtoBX
    10081    LOAD_BDA_SEGMENT_TO ds, ax
    10182    mov     ax, [bx+BOOTNFO.twSectCnt]
     
    10788
    10889;--------------------------------------------------------------------
    109 ; Returns offset to BOOTNFO for wanted drive.
     90; Returns offset to BOOTNFO based on DPT pointer.
    11091;
    111 ; BootInfo_GetOffsetToBX
     92; BootInfo_ConvertDPTtoBX
    11293;   Parameters:
    113 ;       DL:     Drive number
    114 ;       DS:     RAMVARS segment
     94;       DS:DI:  DPT Pointer
    11595;   Returns:
    11696;       BX:     Offset to BOOTNFO struct
     
    11999;--------------------------------------------------------------------
    120100ALIGN JUMP_ALIGN
    121 BootInfo_GetOffsetToBX:
    122     mov     bl, dl                      ; Copy drive number to BL
    123     mov     al, BOOTNFO_size            ; Size of struct
    124     sub     bl, [RAMVARS.bFirstDrv]     ; Drive number to index
    125     mul     bl                          ; AX = Offset inside BOOTNFO array
    126     add     ax, BOOTVARS.rgBootNfo      ; Add offset to BOOTNFO array
    127     xchg    bx, ax                      ; Move result to BX
    128     ret
     101BootInfo_ConvertDPTtoBX:
     102    mov     ax, di
     103    sub     ax, RAMVARS_size                ; subtract off base of DPTs
     104    mov     bl, DPT_BOOTNFO_SIZE_MULTIPLIER ; BOOTNFO's are a whole number multiple of DPT size
     105    mul     bl                             
     106    add     ax, BOOTVARS.rgBootNfo          ; add base of BOOTNFO
     107    xchg    ax, bx
     108    ret         
Note: See TracChangeset for help on using the changeset viewer.