Ignore:
Timestamp:
Jun 25, 2018, 10:29:27 PM (6 years ago)
Author:
krille_n_
Message:

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AtaGeometry.asm

    r580 r592  
    114114    ; slower. The speed difference doesn't matter on AT systems.
    115115.UseAssistedLBA:
    116     call    GetSectorCountToDXAXfromCHSinAXBLBH
    117     call    ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
    118     xor     cx, cx      ; No bits to shift
     116    ; Fall to GetSectorCountToDXAXfromCHSinAXBLBH
     117
     118
     119;--------------------------------------------------------------------
     120; GetSectorCountToDXAXfromCHSinAXBLBH
     121;   Parameters:
     122;       AX:     Number of cylinders (1...16383)
     123;       BL:     Number of heads (1...255)
     124;       BH:     Number of sectors per track (1...63)
     125;   Returns:
     126;       DX:AX:  Total number of CHS addressable sectors
     127;   Corrupts registers:
     128;       BX
     129;--------------------------------------------------------------------
     130GetSectorCountToDXAXfromCHSinAXBLBH:
     131    xchg    ax, bx
     132    mul     ah          ; AX = Heads * Sectors per track
     133    mul     bx
     134    ; Fall to ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH
     135
     136
     137;--------------------------------------------------------------------
     138; LBA assist calculation (or Assisted LBA)
     139;
     140; This algorithm translates P-CHS sector count up to largest possible
     141; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows
     142; 256 heads but DOS supports up to 255 head. That is why BIOSes never
     143; use 256 heads.
     144;
     145; L-CHS parameters generated here require the drive to use LBA addressing.
     146;
     147; Here is the algorithm:
     148; If cylinders > 8192
     149;  Variable CH = Total CHS Sectors / 63
     150;  Divide (CH - 1) by 1024 and add 1
     151;  Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads.
     152;  Divide CH by the number of heads. This is the value to be used for the number of cylinders.
     153;
     154; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
     155;   Parameters:
     156;       DX:AX:  Total number of P-CHS sectors for CHS addressing
     157;               (max = 16383 * 16 * 63 = 16,514,064)
     158;   Returns:
     159;       AX:     Number of cylinders (?...1027)
     160;       BL:     Number of heads (16, 32, 64, 128 or 255)
     161;       BH:     Number of sectors per track (always 63)
     162;       CX:     Number of bits shifted (0)
     163;       DL:     TRANSLATEMODE_ASSISTED_LBA
     164;   Corrupts registers:
     165;       DH
     166;--------------------------------------------------------------------
     167ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
     168    ; Value CH = Total sector count / 63
     169    ; Max = 16,514,064 / 63 = 262128
     170    mov     cx, LBA_ASSIST_SPT          ; CX = 63
     171
     172    ; --- Math_DivDXAXbyCX inlined (and slightly modified) since it's only used here
     173    xor     bx, bx
     174    xchg    bx, ax
     175    xchg    dx, ax
     176    div     cx
     177    xchg    ax, bx
     178    div     cx
     179    mov     dx, bx
     180    ; ---
     181
     182    push    ax
     183    push    dx                          ; Value CH stored for later use
     184
     185    ; BX:DX:AX = Value CH - 1
     186    ; Max = 262128 - 1 = 262127
     187    xor     bx, bx
     188    sub     ax, BYTE 1
     189    sbb     dx, bx
     190
     191    ; AX = Number of heads = ((Value CH - 1) / 1024) + 1
     192    ; Max = (262127 / 1024) + 1 = 256
     193    call    Size_DivideSizeInBXDXAXby1024   ; Preserves CX and returns with BH cleared
     194    pop     dx
     195    inc     ax                          ; + 1
     196
     197    ; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest)
     198    ; Max = 255
     199    mov     bl, 16                      ; Min number of heads
     200.CompareNextValidNumberOfHeads:
     201    cmp     ax, bx
     202    jbe     SHORT .NumberOfHeadsNowInBX
     203    eSHL_IM bx, 1                       ; Double number of heads
     204    jpo     SHORT .CompareNextValidNumberOfHeads    ; Reached 256 heads?
     205    dec     bx                          ;  If so, limit heads to 255
     206.NumberOfHeadsNowInBX:
     207
     208    ; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads
     209    ; Max = 262128 / 255 = 1027
     210    pop     ax                          ; Value CH back to DX:AX
     211    div     bx
     212
     213    xchg    bh, cl                      ; Sectors per Track to BH, zero to CL (CX)
    119214    mov     dl, TRANSLATEMODE_ASSISTED_LBA
     215ReturnLCHSinAXBLBH:
    120216    ret
    121217
     
    136232    mov     bl, [es:si+ATA1.wHeadCnt]   ; Heads (1...16)
    137233    mov     bh, [es:si+ATA1.wSPT]       ; Sectors per Track (1...63)
    138     ret
    139 
    140 
    141 ;--------------------------------------------------------------------
    142 ; GetSectorCountToDXAXfromCHSinAXBLBH
    143 ;   Parameters:
    144 ;       AX:     Number of cylinders (1...16383)
    145 ;       BL:     Number of heads (1...255)
    146 ;       BH:     Number of sectors per track (1...63)
    147 ;   Returns:
    148 ;       DX:AX:  Total number of CHS addressable sectors
    149 ;   Corrupts registers:
    150 ;       BX
    151 ;--------------------------------------------------------------------
    152 GetSectorCountToDXAXfromCHSinAXBLBH:
    153     xchg    ax, bx
    154     mul     ah          ; AX = Heads * Sectors per track
    155     mul     bx
    156234    ret
    157235
     
    175253;  Do a standard ECHS translation
    176254;
     255; *FIXME* The above algorithm seems to be conflicting with info found here
     256; https://web.archive.org/web/20000817071418/http://www.firmware.com:80/support/bios/over4gb.htm
     257; which says that Revised ECHS is used when the cylinder count is > 8191.
     258;
    177259; ConvertPCHfromAXBLtoRevisedEnhancedCHinAXBL:
    178260;   Parameters:
     
    183265;       BL:     Number of L-CHS heads (?...240)
    184266;       CX:     Number of bits shifted (0...3)
    185 ;       DX:     ADDRESSING_MODE_NORMAL or ADDRESSING_MODE_LARGE
     267;       DX:     TRANSLATEMODE_NORMAL or TRANSLATEMODE_LARGE
    186268;   Corrupts registers:
    187269;       Nothing
     
    271353    ret
    272354
    273 
    274 ;--------------------------------------------------------------------
    275 ; LBA assist calculation (or Assisted LBA)
    276 ;
    277 ; This algorithm translates P-CHS sector count up to largest possible
    278 ; L-CHS sector count (1024, 255, 63). Note that INT 13h interface allows
    279 ; 256 heads but DOS supports up to 255 head. That is why BIOSes never
    280 ; use 256 heads.
    281 ;
    282 ; L-CHS parameters generated here require the drive to use LBA addressing.
    283 ;
    284 ; Here is the algorithm:
    285 ; If cylinders > 8192
    286 ;  Variable CH = Total CHS Sectors / 63
    287 ;  Divide (CH – 1) by 1024 and add 1
    288 ;  Round the result up to the nearest of 16, 32, 64, 128 and 255. This is the value to be used for the number of heads.
    289 ;  Divide CH by the number of heads. This is the value to be used for the number of cylinders.
    290 ;
    291 ; ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
    292 ;   Parameters:
    293 ;       DX:AX:  Total number of P-CHS sectors for CHS addressing
    294 ;               (max = 16383 * 16 * 63 = 16,514,064)
    295 ;   Returns:
    296 ;       AX:     Number of cylinders (?...1027)
    297 ;       BL:     Number of heads (16, 32, 64, 128 or 255)
    298 ;       BH:     Number of sectors per track (always 63)
    299 ;   Corrupts registers:
    300 ;       CX, DX
    301 ;--------------------------------------------------------------------
    302 ConvertChsSectorCountFromDXAXtoLbaAssistedLCHSinAXBLBH:
    303     ; Value CH = Total sector count / 63
    304     ; Max = 16,514,064 / 63 = 262128
    305     mov     cx, LBA_ASSIST_SPT          ; CX = 63
    306     call    Math_DivDXAXbyCX            ; Preserves CX
    307     push    dx
    308     push    ax                          ; Value CH stored for later use
    309 
    310     ; BX:DX:AX = Value CH - 1
    311     ; Max = 262128 - 1 = 262127
    312     xor     bx, bx
    313     sub     ax, BYTE 1
    314     sbb     dx, bx
    315 
    316     ; AX = Number of heads = ((Value CH - 1) / 1024) + 1
    317     ; Max = (262127 / 1024) + 1 = 256
    318     call    Size_DivideSizeInBXDXAXby1024   ; Preserves CX
    319     inc     ax                          ; + 1
    320 
    321     ; Heads must be 16, 32, 64, 128 or 255 (round up to the nearest)
    322     ; Max = 255
    323     mov     cl, 16                      ; Min number of heads
    324 .CompareNextValidNumberOfHeads:
    325     cmp     ax, cx
    326     jbe     SHORT .NumberOfHeadsNowInCX
    327     eSHL_IM cx, 1                       ; Double number of heads
    328     jpo     SHORT .CompareNextValidNumberOfHeads    ; Reached 256 heads?
    329     dec     cx                          ;  If so, limit heads to 255
    330 .NumberOfHeadsNowInCX:
    331     mov     bx, cx                      ; Number of heads are returned in BL
    332     mov     bh, LBA_ASSIST_SPT          ; Sectors per Track
    333 
    334     ; DX:AX = Number of cylinders = Value CH (without - 1) / number of heads
    335     ; Max = 262128 / 255 = 1027
    336     pop     ax
    337     pop     dx                          ; Value CH back to DX:AX
    338     div     cx
    339 
    340     ; Return L-CHS
    341 ReturnLCHSinAXBLBH:
    342     ret
Note: See TracChangeset for help on using the changeset viewer.