Changeset 100 in xtideuniversalbios


Ignore:
Timestamp:
Jan 31, 2011, 11:43:26 AM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to XTIDE Universal BIOS:

  • BootInfo.asm had initialization functions that were not yet inlined.
File:
1 edited

Legend:

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

    r88 r100  
    1 ; File name     :   BootInfo.asm
    21; Project name  :   XTIDE Universal BIOS
    32; Description   :   Functions for generating and accessing drive
     
    2221;       AX, BX, CX, DX
    2322;--------------------------------------------------------------------
    24 ALIGN JUMP_ALIGN
    2523BootInfo_CreateForHardDisk:
    2624    call    BootInfo_GetOffsetToBX      ; ES:BX now points to new BOOTNFO
    27     call    BootInfo_StoreSectorCount
    28     jmp     SHORT BootInfo_StoreDriveName
     25    ; Fall to .StoreSectorCount
     26
     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_GetTotalSectorCount       ; Get to BX:DX:AX
     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
     47
     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
     64
     65    push    es
     66    pop     ds
     67    add     si, BYTE ATA1.strModel      ; DS:SI now points drive name
     68    lea     di, [bx+BOOTNFO.szDrvName]  ; ES:DI now points to name destination
     69    mov     cx, LEN_BOOTNFO_DRV
     70    call    Memory_CopyCXbytesFromDSSItoESDI
     71    xor     ax, ax
     72    stosb                               ; Terminate with NULL
     73
     74    pop     di
     75    pop     si
     76    pop     ds
     77    clc
     78    ret
     79
     80
     81;--------------------------------------------------------------------
     82; Finds BOOTNFO for drive and returns total sector count.
     83;
     84; BootInfo_GetTotalSectorCount
     85;   Parameters:
     86;       DL:     Drive number
     87;       DS:     RAMVARS segment
     88;   Returns:
     89;       BX:DX:AX:   48-bit sector count
     90;   Corrupts registers:
     91;       Nothing
     92;--------------------------------------------------------------------   
     93ALIGN JUMP_ALIGN
     94BootInfo_GetTotalSectorCount:
     95    push    ds
     96    call    BootInfo_GetOffsetToBX
     97    LOAD_BDA_SEGMENT_TO ds, ax
     98    mov     ax, [bx+BOOTNFO.twSectCnt]
     99    mov     dx, [bx+BOOTNFO.twSectCnt+2]
     100    mov     bx, [bx+BOOTNFO.twSectCnt+4]
     101    pop     ds
     102    ret
    29103
    30104
     
    50124    xchg    bx, ax                      ; Copy result to BX
    51125    ret
    52 
    53 
    54 ;--------------------------------------------------------------------
    55 ; Stores total sector count to BOOTNFO.
    56 ;
    57 ; BootInfo_StoreSectorCount
    58 ;   Parameters:
    59 ;       ES:BX:  Ptr to BOOTNFO
    60 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    61 ;       DS:DI:  Ptr to Disk Parameter Table
    62 ;   Returns:
    63 ;       CF:     Cleared if variables stored succesfully
    64 ;               Set if any error
    65 ;   Corrupts registers:
    66 ;       AX, CX, DX
    67 ;--------------------------------------------------------------------
    68 ALIGN JUMP_ALIGN
    69 BootInfo_StoreSectorCount:
    70     push    bx
    71     call    AtaID_GetTotalSectorCount       ; Get to BX:DX:AX
    72     mov     cx, bx                          ; Now in CX:DX:AX
    73     pop     bx
    74     mov     [es:bx+BOOTNFO.twSectCnt], ax
    75     mov     [es:bx+BOOTNFO.twSectCnt+2], dx
    76     mov     [es:bx+BOOTNFO.twSectCnt+4], cx
    77     clc
    78     ret
    79 
    80 
    81 ;--------------------------------------------------------------------
    82 ; Stores drive name to BOOTNFO.
    83 ;
    84 ; BootInfo_StoreDriveName
    85 ;   Parameters:
    86 ;       ES:BX:  Ptr to BOOTNFO
    87 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    88 ;       DS:DI:  Ptr to Disk Parameter Table
    89 ;   Returns:
    90 ;       CF:     Cleared if variables stored succesfully
    91 ;               Set if any error
    92 ;   Corrupts registers:
    93 ;       AX, CX
    94 ;--------------------------------------------------------------------
    95 ALIGN JUMP_ALIGN
    96 BootInfo_StoreDriveName:
    97     push    ds
    98     push    si
    99     push    di
    100 
    101     ; DS:SI to ATA source string
    102     push    es
    103     pop     ds
    104     add     si, BYTE ATA1.strModel
    105 
    106     ; ES:DI to BOOTNFO destination string
    107     lea     di, [bx+BOOTNFO.szDrvName]
    108 
    109     ; Read string
    110     mov     cx, LEN_BOOTNFO_DRV>>1
    111     call    BootInfo_StoreAtaString
    112     pop     di
    113     pop     si
    114     pop     ds
    115     clc
    116     ret
    117 
    118 ;--------------------------------------------------------------------
    119 ; Stores ATA string.
    120 ; Byte ordering will be corrected and string will be STOP terminated.
    121 ;
    122 ; BootInfo_StoreAtaString
    123 ;   Parameters:
    124 ;       CX:     Maximum number of WORDs to copy (without STOP)
    125 ;       DS:SI:  Ptr to ATA string
    126 ;       ES:DI:  Ptr to destination string
    127 ;   Returns:
    128 ;       Nothing
    129 ;   Corrupts registers:
    130 ;       AX, CX, SI, DI
    131 ;--------------------------------------------------------------------
    132 ALIGN JUMP_ALIGN
    133 BootInfo_StoreAtaString:
    134     lodsw                           ; Load WORD from DS:SI to AX
    135     xchg    al, ah                  ; Change byte order
    136     call    BootInfo_StoreAtaChar
    137     jc      SHORT .Return           ; Return if invalid character
    138     mov     al, ah                  ; Write next char
    139     call    BootInfo_StoreAtaChar
    140     jc      SHORT .Return           ; Return if invalid character
    141     loop    BootInfo_StoreAtaString ; Loop while words left
    142 .Return:
    143     xor     ax, ax                  ; Terminate string with NULL
    144     stosb
    145     ret
    146 
    147 ;--------------------------------------------------------------------
    148 ; Stores ATA character.
    149 ;
    150 ; BootInfo_StoreAtaChar
    151 ;   Parameters:
    152 ;       AL:     Character to store
    153 ;       ES:DI:  Ptr to destination character
    154 ;   Returns:
    155 ;       DI:     Incremented to next character
    156 ;       CF:     Set if non writable ASCII character
    157 ;   Corrupts registers:
    158 ;       Nothing
    159 ;--------------------------------------------------------------------
    160 ALIGN JUMP_ALIGN
    161 BootInfo_StoreAtaChar:
    162     cmp     al, 20h                 ; First allowed ASCII char?
    163     jb      SHORT .SkipStoring      ;  If below, end string
    164     cmp     al, 7Eh                 ; Last allowed ASCII char?
    165     ja      SHORT .SkipStoring      ;  If above, end string
    166     stosb                           ; Store character
    167     clc                             ; Clear CF to continue with next char
    168     ret
    169 .SkipStoring:
    170     stc
    171     ret
    172 
    173 
    174 ;--------------------------------------------------------------------
    175 ; Finds BOOTNFO for drive and return total sector count.
    176 ;
    177 ; BootInfo_GetTotalSectorCount
    178 ;   Parameters:
    179 ;       DL:     Drive number
    180 ;       DS:     RAMVARS segment
    181 ;   Returns:
    182 ;       BX:DX:AX:   48-bit sector count
    183 ;   Corrupts registers:
    184 ;       Nothing
    185 ;--------------------------------------------------------------------   
    186 ALIGN JUMP_ALIGN
    187 BootInfo_GetTotalSectorCount:
    188     push    ds
    189     call    BootInfo_GetOffsetToBX
    190     LOAD_BDA_SEGMENT_TO ds, ax
    191     mov     ax, [bx+BOOTNFO.twSectCnt]
    192     mov     dx, [bx+BOOTNFO.twSectCnt+2]
    193     mov     bx, [bx+BOOTNFO.twSectCnt+4]
    194     pop     ds
    195     ret
Note: See TracChangeset for help on using the changeset viewer.