Changeset 399 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS


Ignore:
Timestamp:
Apr 19, 2012, 10:39:44 PM (13 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Changes:

  • Added Power Management (Standby Timer) support to the BIOS and made it part of an optional module (MODULE_FEATURE_SETS). The total amount of ROM space used by this feature is 37 bytes. UNTESTED
  • Size optimizations (mostly inlining of procedures) and fixed a few bugs in AH9h_HInit.asm:
    1. DPT_ATA.bInitError would be cleared only if MODULE_SERIAL was not defined.
    2. The FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE flag could never be set.
    3. InitializeBlockMode could potentially loop forever if there was an error.
  • Removed some odd looking code in .PushResetStatus in BootMenuPrintCfg.asm
  • Made some changes to XTIDECFG so it can be built.
Location:
trunk/XTIDE_Universal_BIOS
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Inc/CustomDPT.inc

    r397 r399  
    44
    55;
    6 ; XTIDE Universal BIOS and Associated Tools 
     6; XTIDE Universal BIOS and Associated Tools
    77; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    88;
     
    1111; the Free Software Foundation; either version 2 of the License, or
    1212; (at your option) any later version.
    13 ; 
     13;
    1414; This program is distributed in the hope that it will be useful,
    1515; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17 ; GNU General Public License for more details.     
     17; GNU General Public License for more details.
    1818; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    1919;
     
    2626    ; General Disk Parameter Table related
    2727    .wFlags:
    28     .bFlagsLow                  resb    1
    29     .bFlagsHigh                 resb    1
    30     .bIdevarsOffset             resb    1   ; Offset to IDEVARS for this drive
     28    .bFlagsLow              resb    1
     29    .bFlagsHigh             resb    1
     30    .bIdevarsOffset         resb    1   ; Offset to IDEVARS for this drive
    3131
    3232    ; IDE Drive related
    3333    ; .bLbaHeads and .twLbaSectors are used for LBA addressing only.
    34     .bLbaHeads:                 resb    1   ; Number of LBA assisted heads (1...255)
    35     .twLbaSectors               resb    2   ; 48-bit sector count for LBA addressing
     34    .bLbaHeads:             resb    1   ; Number of LBA assisted heads (1...255)
     35    .twLbaSectors           resb    2   ; 48-bit sector count for LBA addressing
    3636
    3737    ; .wPchsCylinders and .bPchsSectors are used for CHS addressing only.
    38     .wPchsCylinders             resb    2   ; Number of P-CHS Cylinders (1...16383)
     38    .wPchsCylinders         resb    2   ; Number of P-CHS Cylinders (1...16383)
    3939    .wPchsHeadsAndSectors:
    40     .bPchsHeads                 resb    1   ; Number of P-CHS heads (1...16)
    41     .bPchsSectors               resb    1   ; Number of P-CHS Sectors per Track (1...63)
     40    .bPchsHeads             resb    1   ; Number of P-CHS heads (1...16)
     41    .bPchsSectors           resb    1   ; Number of P-CHS Sectors per Track (1...63)
    4242endstruc
    4343
    44 ; Bit definitions for DPT.bFlagsLow
    45 MASKL_DPT_CHS_SHIFT_COUNT       EQU (7<<0)  ; Bits 0...3, P-CHS to L-CHS bit shift count (0...4)
    46 FLGL_DPT_SLAVE                  EQU FLG_DRVNHEAD_DRV    ; (1<<4), Drive is slave drive
    47 MASKL_DPT_ADDRESSING_MODE       EQU (3<<5)  ; Bits 5..6, Addressing Mode (bit 6 == FLG_DRVNHEAD_LBA)
    48 FLGL_DPT_ENABLE_IRQ             EQU (1<<7)
     44    ; Bit definitions for DPT.bFlagsLow
     45    MASKL_DPT_CHS_SHIFT_COUNT                   EQU (7<<0)  ; Bits 0...2, P-CHS to L-CHS bit shift count (0...4)
     46    FLGL_DPT_SLAVE                              EQU FLG_DRVNHEAD_DRV    ; (1<<4), Drive is slave drive
     47    MASKL_DPT_ADDRESSING_MODE                   EQU (3<<5)  ; Bits 5..6, Addressing Mode (bit 6 == FLG_DRVNHEAD_LBA)
     48    FLGL_DPT_ENABLE_IRQ                         EQU (1<<7)
    4949
    50 ; Bit definitions for DPT.bFlagsHigh
    51 FLGH_DPT_REVERSED_A0_AND_A3     EQU (1<<0)  ; XTIDE mod, Address lines 0 and 3 reversed
    52 FLGH_DPT_BLOCK_MODE_SUPPORTED   EQU (1<<1)  ; Use block transfer commands (must be bit 1!)
    53 %ifdef MODULE_SERIAL
    54 FLGH_DPT_SERIAL_DEVICE          EQU (1<<2)  ; Serial Port Device
    55 %endif
    56 FLGH_DPT_INTERRUPT_IN_SERVICE   EQU (1<<3)  ; Set when waiting for IRQ
     50    ; Bit definitions for DPT.bFlagsHigh
     51    FLGH_DPT_REVERSED_A0_AND_A3                 EQU (1<<0)  ; XTIDE mod, Address lines 0 and 3 reversed
     52    FLGH_DPT_BLOCK_MODE_SUPPORTED               EQU (1<<1)  ; Use block transfer commands (must be bit 1!)
     53    FLGH_DPT_SERIAL_DEVICE                      EQU (1<<2)  ; Serial Port Device
     54    FLGH_DPT_INTERRUPT_IN_SERVICE               EQU (1<<3)  ; Set when waiting for IRQ
     55    FLGH_DPT_POWER_MANAGEMENT_SUPPORTED         EQU (1<<5)
    5756
    58 ; IDE device only
    59 %ifdef MODULE_ADVANCED_ATA
    60 FLGH_DPT_IORDY                  EQU (1<<7)  ; Controller and Drive supports IORDY
    61 %endif
     57    ; IDE device only
     58    FLGH_DPT_IORDY                              EQU (1<<7)  ; Controller and Drive supports IORDY
    6259
    63 ; Serial device only
    64 FLGH_DPT_SERIAL_FLOPPY                      EQU (1<<4)
    65 FLGH_DPT_SERIAL_FLOPPY_TYPE_MASK            EQU 0e0h
    66 FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION  EQU 5
     60    ; Serial device only
     61    FLGH_DPT_SERIAL_FLOPPY                      EQU (1<<4)
     62    FLGH_DPT_SERIAL_FLOPPY_TYPE_MASK            EQU 0e0h
     63    FLGH_DPT_SERIAL_FLOPPY_TYPE_FIELD_POSITION  EQU 5
    6764
    68 ; Addressing modes for DPT.wFlags
    69 ADDRESSING_MODE_FIELD_POSITION  EQU     5
    70 ADDRESSING_MODE_LCHS            EQU     0   ; L-CHS Addressing Mode (NORMAL in many other BIOSes)
    71 ADDRESSING_MODE_PCHS            EQU     1   ; P-CHS Addressing Mode (LARGE in many other BIOSes)
    72 ADDRESSING_MODE_LBA28           EQU     2   ; 28-bit LBA Addressing Mode
    73 ADDRESSING_MODE_LBA48           EQU     3   ; 48-bit LBA Addressing Mode
     65    ; Addressing modes for DPT.wFlags
     66    ADDRESSING_MODE_FIELD_POSITION              EQU     5
     67    ADDRESSING_MODE_LCHS                        EQU     0   ; L-CHS Addressing Mode (NORMAL in many other BIOSes)
     68    ADDRESSING_MODE_PCHS                        EQU     1   ; P-CHS Addressing Mode (LARGE in many other BIOSes)
     69    ADDRESSING_MODE_LBA28                       EQU     2   ; 28-bit LBA Addressing Mode
     70    ADDRESSING_MODE_LBA48                       EQU     3   ; 48-bit LBA Addressing Mode
    7471
    7572
    7673; DPT for ATA devices
    7774struc DPT_ATA   ; 10 + 2 bytes = 12 bytes
    78     .dpt                        resb    DPT_size
    79     .bBlockSize                 resb    1   ; Current block size in sectors (do not set to zero!)
    80     .bInitError                 resb    1
     75    .dpt                    resb    DPT_size
     76    .bBlockSize             resb    1   ; Current block size in sectors (do not set to zero!)
     77    .bInitError             resb    1
    8178endstruc
    8279
    83 ; Flags for DPT_ATA.bInitError
    84 FLG_INITERROR_FAILED_TO_SELECT_DRIVE                EQU     (1<<0)
    85 FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS   EQU     (1<<1)
    86 FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE             EQU     (1<<2)
    87 FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE           EQU     (1<<3)
    88 FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE              EQU     (1<<4)
    89 FLG_INITERROR_FAILED_TO_SET_PIO_MODE                EQU     (1<<5)
    9080
     81    ; Flags for DPT_ATA.bInitError
     82    FLG_INITERROR_FAILED_TO_SELECT_DRIVE                EQU (1<<0)
     83    FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS   EQU (1<<1)
     84    FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE             EQU (1<<2)
     85    FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE           EQU (1<<3)
     86    FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE              EQU (1<<4)
     87    FLG_INITERROR_FAILED_TO_SET_PIO_MODE                EQU (1<<5)
     88    FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER    EQU (1<<6)
    9189
    9290; Additional variables needed to initialize and reset Advanced IDE Controllers.
     
    107105%ifdef MODULE_SERIAL
    108106struc DPT_SERIAL
    109     .dpt                        resb    DPT_size
     107    .dpt                    resb    DPT_size
    110108    .wSerialPortAndBaud:
    111     .bSerialPort                resb    1   ; Serial connection I/O port address, divided by 4
    112     .bSerialBaud                resb    1   ; Serial connection baud rate divisor
     109    .bSerialPort            resb    1   ; Serial connection I/O port address, divided by 4
     110    .bSerialBaud            resb    1   ; Serial connection baud rate divisor
    113111endstruc
    114112%endif
     
    117115; This is the common size for all DPTs. All DPTs must be equal size.
    118116%ifdef MODULE_ADVANCED_ATA
    119 LARGEST_DPT_SIZE                EQU     DPT_ADVANCED_ATA_size
     117    LARGEST_DPT_SIZE            EQU     DPT_ADVANCED_ATA_size
    120118%else
    121 LARGEST_DPT_SIZE                EQU     DPT_ATA_size
     119    LARGEST_DPT_SIZE            EQU     DPT_ATA_size
    122120%endif
    123121
    124122
    125 ; Number of Sectors per Track is fixed to 63 for LBA assist calculation.
    126 ; 1024 cylinders, 256 heads, 63 sectors = 8.4 GB limit (but DOS does not support more than 255 heads)
    127 MAX_LCHS_CYLINDERS              EQU     1024
    128 LBA_ASSIST_SPT                  EQU     63
     123    ; Number of Sectors per Track is fixed to 63 for LBA assist calculation.
     124    ; 1024 cylinders, 256 heads, 63 sectors = 8.4 GB limit (but DOS does not support more than 255 heads)
     125    MAX_LCHS_CYLINDERS          EQU     1024
     126    LBA_ASSIST_SPT              EQU     63
    129127
    130128
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm

    r376 r399  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616; GNU General Public License for more details.
    17 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html               
    18 ;       
     17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18;
    1919
    2020; Section containing code
     
    3434IdeDPT_Finalize:
    3535
     36%ifdef MODULE_FEATURE_SETS
     37;--------------------------------------------------------------------
     38; .DetectPowerManagementSupport
     39;   Parameters:
     40;       DS:DI:  Ptr to Disk Parameter Table
     41;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     42;   Returns:
     43;       Nothing
     44;   Corrupts registers:
     45;       Nothing
     46;--------------------------------------------------------------------
     47.DetectPowerManagementSupport:
     48    test    BYTE [es:si+ATA6.wSetSup82], A6_wSetSup82_POWERMAN
     49    jz      .NoPowerManagementSupport
     50    or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_POWER_MANAGEMENT_SUPPORTED
     51.NoPowerManagementSupport:
     52%endif ; MODULE_FEATURE_SETS
     53
    3654;--------------------------------------------------------------------
    3755; .StoreBlockMode
    3856;   Parameters:
    3957;       DS:DI:  Ptr to Disk Parameter Table
    40 ;       ES:SI:  Ptr to 512-byte ATA information read from the drive
    41 ;       CS:BP:  Ptr to IDEVARS for the controller
    4258;   Returns:
    4359;       Nothing
    4460;   Corrupts registers:
    45 ;       AX
     61;       Nothing
    4662;--------------------------------------------------------------------
    4763.StoreBlockMode:
     
    7894    mov     [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx
    7995    mov     [di+DPT_ADVANCED_ATA.bPioMode], al
    80     or      [di+DPT.bFlagsHigh], ah 
     96    or      [di+DPT.bFlagsHigh], ah
    8197
    8298;--------------------------------------------------------------------
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r376 r399  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    16 ; GNU General Public License for more details.     
     16; GNU General Public License for more details.
    1717; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    18 ;       
     18;
    1919
    2020; Section containing code
     
    4444
    4545;--------------------------------------------------------------------
    46 ; Initialized drive to be ready for use.
     46; Initialize drive to be ready for use.
    4747;
    4848; AH9h_InitializeDriveForUse
     
    5757;--------------------------------------------------------------------
    5858AH9h_InitializeDriveForUse:
     59    xor     ax, ax
     60
     61    ; Clear Initialization Error flags from DPT
     62    mov     [di+DPT_ATA.bInitError], al
     63
     64%ifdef MODULE_SERIAL
     65    ; No need to do this for serial devices
     66    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE    ; Clears CF
     67    jz      SHORT .ContinueInitialization
     68    ret     ; With AH and CF cleared
     69    .ContinueInitialization:
     70%endif
     71
    5972    push    es
    6073    push    si
    6174
    62 %ifdef MODULE_SERIAL
    63     ; no need to do this for serial devices
    64     xor     ah, ah
    65     test    byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE    ; Clears CF
    66     jnz     .ReturnWithErrorCodeInAH
    67 
    68 %else
    69     ; Clear Initialization Error flags from DPT
    70     mov     BYTE [di+DPT_ATA.bInitError], 0
    71 %endif
    72 
     75;;; SelectDrive
    7376    ; Try to select drive and wait until ready
    7477    call    AccessDPT_GetDriveSelectByteToAL
    7578    mov     [bp+IDEPACK.bDrvAndHead], al
    7679    call    Device_SelectDrive
     80
    7781    mov     al, FLG_INITERROR_FAILED_TO_SELECT_DRIVE
    78     call    SetErrorFlagFromALwithErrorCodeInAH
    79     jc      SHORT .ReturnWithErrorCodeInAH
    80 
     82    call    .SetErrorFlagFromALwithErrorCodeInAH
     83    jc      .ReturnWithErrorCodeInAH
     84
     85;;; InitializeDeviceParameters
    8186    ; Initialize CHS parameters if LBA is not used
    82     call    InitializeDeviceParameters
    83     mov     al, FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS
    84     call    SetErrorFlagFromALwithErrorCodeInAH
    85 
    86     ; Enable or Disable Write Cache
    87     call    SetWriteCache
    88     mov     al, FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE
    89     call    SetErrorFlagFromALwithErrorCodeInAH
    90 
    91     ; Recalibrate drive by seeking to cylinder 0
    92 .RecalibrateDrive:
    93     call    AH11h_RecalibrateDrive
    94     mov     al, FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE
    95     call    SetErrorFlagFromALwithErrorCodeInAH
    96 
    97     ; Initialize block mode transfers
    98 .InitializeBlockMode:
    99     call    InitializeBlockMode
    100     mov     al, FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE
    101     call    SetErrorFlagFromALwithErrorCodeInAH
    102 
    103 %ifdef MODULE_ADVANCED_ATA
    104 ; Initialize fastest supported PIO mode
    105 .InitializePioMode:
    106     call    InitializePioMode
    107     mov     al, FLG_INITERROR_FAILED_TO_SET_PIO_MODE
    108     call    SetErrorFlagFromALwithErrorCodeInAH
    109 %endif
    110 
    111     ; There might have been several errors so just return
    112     ; one error code for them all
    113     cmp     BYTE [di+DPT_ATA.bInitError], 0
    114     je      SHORT .ReturnWithErrorCodeInAH
    115     mov     ah, RET_HD_RESETFAIL
    116     stc
    117 
    118 .ReturnWithErrorCodeInAH:
    119     pop     si
    120     pop     es
    121     ret
    122 
    123 
    124 ;--------------------------------------------------------------------
    125 ; InitializeDeviceParameters
    126 ;   Parameters:
    127 ;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    128 ;       SS:BP:  Ptr to IDEPACK
    129 ;   Returns:
    130 ;       AH:     BIOS Error code
    131 ;       CF:     Cleared if successful
    132 ;               Set if any error
    133 ;   Corrupts registers:
    134 ;       AL, BX, CX, DX
    135 ;--------------------------------------------------------------------
    136 InitializeDeviceParameters:
    137     ; No need to initialize CHS parameters if LBA mode enabled
    138     test    BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA   ; Clear CF
    139     jnz     SHORT ReturnSuccessSinceInitializationNotNeeded
     87    test    BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
     88    jnz     SHORT .SkipInitializeDeviceParameters       ; No need to initialize CHS parameters if LBA mode enabled
    14089
    14190    ; Initialize Logical Sectors per Track and Max Head number
     
    14594    mov     al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
    14695    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
    147     jmp     Idepack_StoreNonExtParametersAndIssueCommandFromAL
    148 
    149 
    150 ;--------------------------------------------------------------------
    151 ; SetWriteCache
    152 ;   Parameters:
    153 ;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    154 ;   Returns:
    155 ;       AH:     BIOS Error code
    156 ;       CF:     Cleared if successful
    157 ;               Set if any error
    158 ;   Corrupts registers:
    159 ;       AL, BX, CX, DX, SI
    160 ;--------------------------------------------------------------------
    161 SetWriteCache:
     96    call    Idepack_StoreNonExtParametersAndIssueCommandFromAL
     97
     98    mov     al, FLG_INITERROR_FAILED_TO_INITIALIZE_CHS_PARAMETERS
     99    call    .SetErrorFlagFromALwithErrorCodeInAH
     100.SkipInitializeDeviceParameters:
     101
     102;;; SetWriteCache
     103    ; Enable or Disable Write Cache
    162104    call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    163105    mov     bl, [cs:bx+DRVPARAMS.wFlags]
     106    push    bx  ; Save .wFlags for later use in InitializeBlockMode
    164107    and     bx, BYTE MASK_DRVPARAMS_WRITECACHE
    165     jz      SHORT ReturnSuccessSinceInitializationNotNeeded     ; DEFAULT_WRITE_CACHE
     108    jz      SHORT .SkipSetWriteCache        ; DEFAULT_WRITE_CACHE
    166109    mov     si, [cs:bx+.rgbWriteCacheCommands]
    167     jmp     AH23h_SetControllerFeatures
    168 
    169 .rgbWriteCacheCommands:
    170     db      0                               ; DEFAULT_WRITE_CACHE
    171     db      FEATURE_DISABLE_WRITE_CACHE     ; DISABLE_WRITE_CACHE
    172     db      FEATURE_ENABLE_WRITE_CACHE      ; ENABLE_WRITE_CACHE
    173 
    174 
    175 %ifdef MODULE_ADVANCED_ATA
    176 ;--------------------------------------------------------------------
    177 ; InitializePioMode
    178 ;   Parameters:
    179 ;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    180 ;   Returns:
    181 ;       AH:     BIOS Error code
    182 ;       CF:     Cleared if successful
    183 ;               Set if any error
    184 ;   Corrupts registers:
    185 ;       AL, BX, CX, DX
    186 ;--------------------------------------------------------------------
    187 InitializePioMode:
    188     mov     dl, PIO_DEFAULT_MODE_DISABLE_IORDY
    189     test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_IORDY
    190     jz      SHORT .IordyNotSupported
    191 
    192     ; Advanced PIO mode 3 and above
    193     mov     dl, [di+DPT_ADVANCED_ATA.bPioMode]
    194     or      dl, PIO_FLOW_CONTROL_MODE_xxx
    195 
    196 .IordyNotSupported:
    197     mov     si, FEATURE_SET_TRANSFER_MODE
    198     jmp     AH23h_SetControllerFeatures
    199 %endif
    200 
    201 
    202 ;--------------------------------------------------------------------
    203 ; InitializeBlockMode
    204 ;   Parameters:
    205 ;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    206 ;   Returns:
    207 ;       AH:     BIOS Error code
    208 ;       CF:     Cleared if successful
    209 ;               Set if any error
    210 ;   Corrupts registers:
    211 ;       AL, BX, CX, DX
    212 ;--------------------------------------------------------------------
    213 InitializeBlockMode:
    214     test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED ; Clear CF
     110    call    AH23h_SetControllerFeatures
     111
     112    mov     al, FLG_INITERROR_FAILED_TO_SET_WRITE_CACHE
     113    call    .SetErrorFlagFromALwithErrorCodeInAH
     114.SkipSetWriteCache:
     115
     116;;; RecalibrateDrive
     117    ; Recalibrate drive by seeking to cylinder 0
     118    call    AH11h_RecalibrateDrive
     119
     120    mov     al, FLG_INITERROR_FAILED_TO_RECALIBRATE_DRIVE
     121    call    .SetErrorFlagFromALwithErrorCodeInAH
     122
     123;;; InitializeBlockMode
     124    ; Initialize block mode transfers
     125    pop     ax  ; Restore .wFlags saved in SetWriteCache
     126    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_BLOCK_MODE_SUPPORTED
    215127    jz      SHORT .BlockModeNotSupportedOrDisabled
    216     call    AccessDPT_GetPointerToDRVPARAMStoCSBX
    217     test    BYTE [cs:bx+DRVPARAMS.wFlags], FLG_DRVPARAMS_BLOCKMODE
     128    test    al, FLG_DRVPARAMS_BLOCKMODE
    218129    jz      SHORT .BlockModeNotSupportedOrDisabled
    219130
     
    222133.TryNextBlockSize:
    223134    mov     al, bl
    224     call    AH24h_SetBlockSize
     135    call    AH24h_SetBlockSize  ; Stores block size to DPT
    225136    jnc     SHORT .SupportedBlockSizeFound
    226     shr     bl, 1                       ; Try next size
    227     jmp     SHORT .TryNextBlockSize
     137    shr     bl, 1
     138    jnc     SHORT .TryNextBlockSize
     139
     140    mov     al, FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE
     141    call    .SetErrorFlagFromALwithErrorCodeInAH
     142.BlockModeNotSupportedOrDisabled:
    228143.SupportedBlockSizeFound:
    229     mov     [di+DPT_ATA.bBlockSize], bl
    230 .BlockModeNotSupportedOrDisabled:
    231 ReturnSuccessSinceInitializationNotNeeded:
     144
     145%ifdef MODULE_ADVANCED_ATA
     146;;; InitializePioMode
     147    ; Initialize fastest supported PIO mode
     148    mov     dl, PIO_DEFAULT_MODE_DISABLE_IORDY
     149    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_IORDY
     150    jz      SHORT .IordyNotSupported
     151
     152    ; Advanced PIO mode 3 and above
     153    mov     dl, [di+DPT_ADVANCED_ATA.bPioMode]
     154    or      dl, PIO_FLOW_CONTROL_MODE_xxx
     155
     156.IordyNotSupported:
     157    mov     si, FEATURE_SET_TRANSFER_MODE
     158    call    AH23h_SetControllerFeatures
     159
     160    mov     al, FLG_INITERROR_FAILED_TO_SET_PIO_MODE
     161    call    .SetErrorFlagFromALwithErrorCodeInAH
     162%endif ; MODULE_ADVANCED_ATA
     163
     164%ifdef MODULE_FEATURE_SETS
     165;;; InitStandbyTimer
     166    ; Initialize the standby timer (if supported)
     167    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_POWER_MANAGEMENT_SUPPORTED
     168    jz      .NoPowerManagementSupport
     169
     170    mov     al, COMMAND_IDLE
     171    mov     dl, [cs:ROMVARS.bIdleTimeout]
     172    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
     173    call    Idepack_StoreNonExtParametersAndIssueCommandFromAL
     174
     175    mov     al, FLG_INITERROR_FAILED_TO_INITIALIZE_STANDBY_TIMER
     176    call    .SetErrorFlagFromALwithErrorCodeInAH
     177.NoPowerManagementSupport:
     178%endif ; MODULE_FEATURE_SETS
     179
     180    ; There might have been several errors so just return one error code for them all
     181    mov     ah, [di+DPT_ATA.bInitError]
     182    test    ah, ah  ; Clears CF
     183    jz      SHORT .ReturnWithErrorCodeInAH
     184    mov     ah, RET_HD_RESETFAIL
     185    stc
     186
     187.ReturnWithErrorCodeInAH:
     188    pop     si
     189    pop     es
    232190    ret
    233191
    234192
    235193;--------------------------------------------------------------------
    236 ; SetErrorFlagFromALwithErrorCodeInAH
     194; .SetErrorFlagFromALwithErrorCodeInAH
    237195;   Parameters:
    238196;       AH:     BIOS Error Code
     
    245203;       Nothing
    246204;--------------------------------------------------------------------
    247 SetErrorFlagFromALwithErrorCodeInAH:
     205.IgnoreInvalidCommandError:
     206    xor     ah, ah  ; Clears CF
     207
     208.SetErrorFlagFromALwithErrorCodeInAH:
    248209    jnc     SHORT .NoErrorFlagToSet
    249210    cmp     ah, RET_HD_INVALID
     
    252213    or      [di+DPT_ATA.bInitError], al
    253214    stc
    254     ret
    255 .IgnoreInvalidCommandError:
    256     xor     ah, ah
    257215.NoErrorFlagToSet:
    258216    ret
     217
     218
     219.rgbWriteCacheCommands:
     220    db      0                               ; DEFAULT_WRITE_CACHE
     221    db      FEATURE_DISABLE_WRITE_CACHE     ; DISABLE_WRITE_CACHE
     222    db      FEATURE_ENABLE_WRITE_CACHE      ; ENABLE_WRITE_CACHE
     223
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm

    r392 r399  
    44
    55;
    6 ; XTIDE Universal BIOS and Associated Tools 
     6; XTIDE Universal BIOS and Associated Tools
    77; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    88;
     
    1111; the Free Software Foundation; either version 2 of the License, or
    1212; (at your option) any later version.
    13 ; 
     13;
    1414; This program is distributed in the hope that it will be useful,
    1515; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17 ; GNU General Public License for more details.     
     17; GNU General Public License for more details.
    1818; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    19 ;       
     19;
    2020
    2121; Section containing code
     
    7575;--------------------------------------------------------------------
    7676AdvAtaInit_InitializeControllerForDPTinDSDI:
    77     push    bp
    78     push    si
    79 
    8077    ; Call Controller Specific initialization function
    8178    mov     ax, [di+DPT_ADVANCED_ATA.wControllerID]
     
    8380    jz      SHORT .NoAdvancedController ; Return with CF cleared
    8481
     82    push    bp
     83    push    si
     84
    8585    ; We only support Vision at the moment so no need to identify ID
    8686    call    AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
    8787    call    Vision_InitializeWithIDinAHandConfigInAL
    8888
    89 .NoAdvancedController:
    9089    pop     si
    9190    pop     bp
     91
     92.NoAdvancedController:
    9293    ret
    9394
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r398 r399  
    181181    %include "Interrupts.asm"       ; For Interrupt initialization
    182182    %include "RamVars.asm"          ; For RAMVARS initialization and access
    183     %include "BootVars.asm"         ; For initializing variabled used during init and boot
     183    %include "BootVars.asm"         ; For initializing variables used during init and boot
    184184    %include "FloppyDrive.asm"      ; Floppy Drive related functions
    185185    %include "CreateDPT.asm"        ; For creating DPTs
  • trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrint.asm

    r397 r399  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616; GNU General Public License for more details.
    17 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html               
    18 ;       
     17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18;
    1919
    2020; Section containing code
     
    145145;   5  3.5" ED on some BIOSes      3 1/2   2.88M
    146146;   6  FLOPPY_TYPE_35_ED           3 1/2   2.88M
    147 ;   >6 Unknwon, handled above
     147;   >6 Unknown, handled above
    148148;
    149149;--------------------------------------------------------------------
     
    159159    push    ax                                          ; "5 1/4" or "3 1/2"
    160160
     161    xor     bh, bh
    161162    mov     al,FloppyTypes.rgbCapacityMultiplier
    162     mov     bh, 0
    163     mul     byte [cs:bx+FloppyTypes.rgbCapacity - 1]    ; -1 since 0 is handled above and not in the table
     163    mul     BYTE [cs:bx+FloppyTypes.rgbCapacity - 1]    ; -1 since 0 is handled above and not in the table
    164164
    165165.PushAXAndOutput:
     
    202202    push    dx                      ; Magnitude character
    203203
    204     test    di,di
     204    test    di, di
    205205    jz      SHORT BootMenuPrint_RefreshInformation.FormatRelay
    206206
  • trunk/XTIDE_Universal_BIOS/Src/Menus/BootMenu/BootMenuPrintCfg.asm

    r392 r399  
    22; Description   :   Functions for printing drive configuration
    33;                   information on Boot Menu.
    4 ; 
     4;
    55; Included by BootMenuPrint.asm, this routine is to be inserted into
    66; BootMenuPrint_HardDiskRefreshInformation.
     
    88
    99;
    10 ; XTIDE Universal BIOS and Associated Tools 
     10; XTIDE Universal BIOS and Associated Tools
    1111; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    1212;
     
    1515; the Free Software Foundation; either version 2 of the License, or
    1616; (at your option) any later version.
    17 ; 
     17;
    1818; This program is distributed in the hope that it will be useful,
    1919; but WITHOUT ANY WARRANTY; without even the implied warranty of
    2020; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2121; GNU General Public License for more details.
    22 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html               
     22; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    2323;
    24                
     24
    2525; Section containing code
    2626SECTION .text
     
    131131;--------------------------------------------------------------------
    132132.PushResetStatus:
    133     xor     ax, ax
    134 %ifdef MODULE_SERIAL
    135     test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE
    136     jnz     SHORT .AlwaysSuccess
    137133    mov     al, [di+DPT_ATA.bInitError]
    138 .AlwaysSuccess:
    139 %endif
    140134    push    ax
    141135
  • trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm

    r395 r399  
    33
    44;
    5 ; XTIDE Universal BIOS and Associated Tools 
     5; XTIDE Universal BIOS and Associated Tools
    66; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    77;
     
    1010; the Free Software Foundation; either version 2 of the License, or
    1111; (at your option) any later version.
    12 ; 
     12;
    1313; This program is distributed in the hope that it will be useful,
    1414; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616; GNU General Public License for more details.
    17 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html       
    18 ;       
     17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
     18;
    1919
    2020; Section containing code
     
    382382
    383383.StoreDriveLetter:
    384     adc     di, BYTE 0          ; Add 1 if Floppy Drive
     384    adc     di, BYTE 1          ; Add CF if Floppy Drive
    385385    xchg    ax, cx
    386     mov     [es:di+1], al       ; AH = zero to clear function hotkey
     386    mov     [es:di], al         ; AH = zero to clear function hotkey
    387387
    388388.StoreFunctionHotkeyFromAH:
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/DrvDetectInfo.asm

    r397 r399  
    44
    55;
    6 ; XTIDE Universal BIOS and Associated Tools 
     6; XTIDE Universal BIOS and Associated Tools
    77; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
    88;
     
    1111; the Free Software Foundation; either version 2 of the License, or
    1212; (at your option) any later version.
    13 ; 
     13;
    1414; This program is distributed in the hope that it will be useful,
    1515; but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717; GNU General Public License for more details.
    18 ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html               
     18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    1919;
    20                
     20
    2121; Section containing code
    2222SECTION .text
     
    4545    pop     ds
    4646
    47     add     si, BYTE ATA1.strModel              ; DS:SI now points drive name
    48     lea     di, [bx+DRVDETECTINFO.szDrvName]        ; ES:DI now points to name destination
     47    add     si, BYTE ATA1.strModel              ; DS:SI now points drive name (Clears CF)
     48    lea     di, [bx+DRVDETECTINFO.szDrvName]    ; ES:DI now points to name destination
    4949    mov     cx, MAX_HARD_DISK_NAME_LENGTH / 2   ; Max number of WORDs allowed
    5050.CopyNextWord:
     
    5353    stosw
    5454    loop    .CopyNextWord
    55     xor     ax, ax                              ; Zero AX and clear CF
     55    xchg    cx, ax                              ; Zero AX (CF already cleared from the ADD above)
    5656    stosw                                       ; Terminate with NULL
    5757
    5858    pop     si
    5959    pop     ds
    60        
     60
    6161    ret
    6262
     
    7474;--------------------------------------------------------------------
    7575DriveDetectInfo_ConvertDPTtoBX:
    76     mov     ax, di
    77     sub     ax, BYTE RAMVARS_size                   ; subtract off base of DPTs
     76    lea     ax, [di-RAMVARS_size]                   ; subtract off base of DPTs
    7877    mov     bl, DPT_DRVDETECTINFO_SIZE_MULTIPLIER   ; DRVDETECTINFO are a whole number multiple of DPT size
    79     mul     bl                             
     78    mul     bl
    8079    add     ax, BOOTVARS.rgDrvDetectInfo            ; add base of DRVDETECTINFO
    81     xchg    ax, bx
    82     ret 
     80    xchg    bx, ax
     81    ret
  • trunk/XTIDE_Universal_BIOS/makefile

    r398 r399  
    2424# MODULE_SERIAL_FLOPPY      Virtual floppy drives using serial port (requires MODULE_SERIAL)     #
    2525# MODULE_STRINGS_COMPRESSED Use compressed strings to save space                                 #
     26# MODULE_FEATURE_SETS       Power Management support                                             #
    2627#                                                                                                #
    2728# Not modules but these affect the assembly:                                                     #
     
    9192# Assembler preprocessor defines.                               #
    9293#################################################################
    93 DEFINES_COMMON = MODULE_STRINGS_COMPRESSED MODULE_HOTKEYS MODULE_EBIOS
     94DEFINES_COMMON = MODULE_STRINGS_COMPRESSED MODULE_HOTKEYS MODULE_EBIOS MODULE_FEATURE_SETS
    9495DEFINES_COMMON_LARGE = MODULE_BOOT_MENU MODULE_JRIDE MODULE_SERIAL MODULE_SERIAL_FLOPPY
    9596
Note: See TracChangeset for help on using the changeset viewer.