Changeset 150 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers


Ignore:
Timestamp:
Apr 29, 2011, 7:04:13 PM (13 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to XTIDE Universal BIOS:

  • Redesigned Disk Parameter Tables.
  • Code generalizations for supporting non-IDE devices in the future.
Location:
trunk/XTIDE_Universal_BIOS/Src/Handlers
Files:
7 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r148 r150  
    2222Int13h_DiskFunctionsHandler:
    2323    sti                                 ; Enable interrupts
    24     SAVE_AND_GET_INTPACK_TO_SSBP
     24    cld                                 ; String instructions to increment pointers
     25    SAVE_AND_GET_INTPACK_WITH_EXTRA_WORDS_TO_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
    2526
    2627    call    RamVars_GetSegmentToDS
     
    4647;       DL:     Translated drive number
    4748;       DS:     RAMVARS segment
    48 ;       SS:BP:  Ptr to INTPACK
     49;       SS:BP:  Ptr to IDEPACK
    4950;       BX, DI: Corrupted on Int13h_DiskFunctionsHandler
    5051;       Other:  Function specific INT 13h parameters
     
    5859Int13h_DirectCallToAnotherBios:
    5960    call    ExchangeCurrentInt13hHandlerWithOldInt13hHandler
    60     mov     bx, [bp+INTPACK.bx]
    61     mov     di, [bp+INTPACK.di]
    62     mov     ds, [bp+INTPACK.ds]
    63     push    WORD [bp+INTPACK.flags]
     61    mov     bx, [bp+IDEPACK.intpack+INTPACK.bx]
     62    mov     di, [bp+IDEPACK.intpack+INTPACK.di]
     63    mov     ds, [bp+IDEPACK.intpack+INTPACK.ds]
     64    push    WORD [bp+IDEPACK.intpack+INTPACK.flags]
    6465    popf
    6566    push    bp
    66     mov     bp, [bp+INTPACK.bp]
     67    mov     bp, [bp+IDEPACK.intpack+INTPACK.bp]
    6768    int     BIOS_DISK_INTERRUPT_13h ; Can safely do as much recursion as it wants
    6869
     
    7071    pop     bp  ; Standard INT 13h functions never uses BP as return register
    7172%ifdef USE_386
    72     mov     [bp+INTPACK.gs], gs
    73     mov     [bp+INTPACK.fs], fs
     73    mov     [bp+IDEPACK.intpack+INTPACK.gs], gs
     74    mov     [bp+IDEPACK.intpack+INTPACK.fs], fs
    7475%endif
    75     mov     [bp+INTPACK.es], es
    76     mov     [bp+INTPACK.ds], ds
    77     mov     [bp+INTPACK.di], di
    78     mov     [bp+INTPACK.si], si
    79     mov     [bp+INTPACK.bx], bx
    80     mov     [bp+INTPACK.dh], dh
    81     mov     [bp+INTPACK.cx], cx
    82     mov     [bp+INTPACK.ax], ax
     76    mov     [bp+IDEPACK.intpack+INTPACK.es], es
     77    mov     [bp+IDEPACK.intpack+INTPACK.ds], ds
     78    mov     [bp+IDEPACK.intpack+INTPACK.di], di
     79    mov     [bp+IDEPACK.intpack+INTPACK.si], si
     80    mov     [bp+IDEPACK.intpack+INTPACK.bx], bx
     81    mov     [bp+IDEPACK.intpack+INTPACK.dh], dh
     82    mov     [bp+IDEPACK.intpack+INTPACK.cx], cx
     83    mov     [bp+IDEPACK.intpack+INTPACK.ax], ax
    8384    pushf
    84     pop     WORD [bp+INTPACK.flags]
     85    pop     WORD [bp+IDEPACK.intpack+INTPACK.flags]
    8586    call    RamVars_GetSegmentToDS
    8687    cmp     dl, [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv]
    8788    je      SHORT .ExchangeInt13hHandlers
    88     mov     [bp+INTPACK.dl], dl     ; Something is returned in DL
     89    mov     [bp+IDEPACK.intpack+INTPACK.dl], dl     ; Something is returned in DL
    8990ALIGN JUMP_ALIGN
    9091.ExchangeInt13hHandlers:
     
    9899;   Parameters:
    99100;       AH:     BIOS Error code
    100 ;       SS:BP:  Ptr to INTPACK
     101;       SS:BP:  Ptr to IDEPACK
    101102;   Returns:
    102103;       All registers are loaded from INTPACK
     
    104105ALIGN JUMP_ALIGN
    105106Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH:
    106     call    HError_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
     107    call    Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
    107108Int13h_ReturnFromHandlerWithoutStoringErrorCode:
    108     or      WORD [bp+INTPACK.flags], FLG_FLAGS_IF   ; Return with interrupts enabled
     109    or      WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF   ; Return with interrupts enabled
    109110    mov     sp, bp                                  ; Now we can exit anytime
    110     RESTORE_INTPACK_FROM_SSBP
     111    RESTORE_INTPACK_WITH_EXTRA_WORDS_FROM_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
    111112
    112113
     
    146147    LOAD_BDA_SEGMENT_TO es, di
    147148    mov     di, [RAMVARS.fpOldI13h]
     149    cli
    148150    xchg    di, [es:BIOS_DISK_INTERRUPT_13h*4]
    149151    mov     [RAMVARS.fpOldI13h], di
     
    152154    mov     [RAMVARS.fpOldI13h+2], di
    153155    pop     es
     156    sti
     157    ret
     158
     159
     160;--------------------------------------------------------------------
     161; Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
     162; Int13h_SetErrorCodeToIntpackInSSBPfromAH
     163;   Parameters:
     164;       AH:     BIOS error code (00h = no error)
     165;       SS:BP:  Ptr to IDEPACK
     166;   Returns:
     167;       SS:BP:  Ptr to IDEPACK with error condition set
     168;   Corrupts registers:
     169;       DS, DI
     170;--------------------------------------------------------------------
     171ALIGN JUMP_ALIGN
     172Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH:
     173    ; Store error code to BDA
     174    LOAD_BDA_SEGMENT_TO ds, di
     175    mov     [BDA.bHDLastSt], ah
     176
     177    ; Store error code to INTPACK
     178Int13h_SetErrorCodeToIntpackInSSBPfromAH:
     179    mov     [bp+IDEPACK.intpack+INTPACK.ah], ah
     180    test    ah, ah
     181    jnz     SHORT .SetCFtoIntpack
     182    and     BYTE [bp+IDEPACK.intpack+INTPACK.flags], ~FLG_FLAGS_CF
     183    ret
     184.SetCFtoIntpack:
     185    or      BYTE [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_CF
    154186    ret
    155187
     
    224256;   dw  Int13h_UnsupportedFunction                      ; 3Fh,
    225257;   dw  Int13h_UnsupportedFunction                      ; 40h,
    226 ;   dw  Int13h_UnsupportedFunction                      ; 41h, Check if Extensions Present (EBIOS)
    227 ;   dw  Int13h_UnsupportedFunction                      ; 42h, Extended Read Sectors (EBIOS)
    228 ;   dw  Int13h_UnsupportedFunction                      ; 43h, Extended Write Sectors (EBIOS)
    229 ;   dw  Int13h_UnsupportedFunction                      ; 44h, Extended Verify Sectors (EBIOS)
    230 ;   dw  Int13h_UnsupportedFunction                      ; 45h, Lock and Unlock Drive (EBIOS)
    231 ;   dw  Int13h_UnsupportedFunction                      ; 46h, Eject Media Request (EBIOS)
    232 ;   dw  Int13h_UnsupportedFunction                      ; 47h, Extended Seek (EBIOS)
    233 ;   dw  Int13h_UnsupportedFunction                      ; 48h, Get Extended Drive Parameters (EBIOS)
    234 ;   dw  Int13h_UnsupportedFunction                      ; 49h, Get Extended Disk Change Status (EBIOS)
     258;   dw  Int13h_UnsupportedFunction                      ; 41h, Check if Extensions Present (EBIOS)*
     259;   dw  Int13h_UnsupportedFunction                      ; 42h, Extended Read Sectors (EBIOS)*
     260;   dw  Int13h_UnsupportedFunction                      ; 43h, Extended Write Sectors (EBIOS)*
     261;   dw  Int13h_UnsupportedFunction                      ; 44h, Extended Verify Sectors (EBIOS)*
     262;   dw  Int13h_UnsupportedFunction                      ; 45h, Lock and Unlock Drive (EBIOS)***
     263;   dw  Int13h_UnsupportedFunction                      ; 46h, Eject Media Request (EBIOS)***
     264;   dw  Int13h_UnsupportedFunction                      ; 47h, Extended Seek (EBIOS)*
     265;   dw  Int13h_UnsupportedFunction                      ; 48h, Get Extended Drive Parameters (EBIOS)*
     266;   dw  Int13h_UnsupportedFunction                      ; 49h, Get Extended Disk Change Status (EBIOS)***
    235267;   dw  Int13h_UnsupportedFunction                      ; 4Ah, Initiate Disk Emulation (Bootable CD-ROM)
    236268;   dw  Int13h_UnsupportedFunction                      ; 4Bh, Terminate Disk Emulation (Bootable CD-ROM)
    237269;   dw  Int13h_UnsupportedFunction                      ; 4Ch, Initiate Disk Emulation and Boot (Bootable CD-ROM)
    238270;   dw  Int13h_UnsupportedFunction                      ; 4Dh, Return Boot Catalog (Bootable CD-ROM)
    239 ;   dw  Int13h_UnsupportedFunction                      ; 4Eh, Set Hardware Configuration (EBIOS)
     271;   dw  Int13h_UnsupportedFunction                      ; 4Eh, Set Hardware Configuration (EBIOS)**
     272;
     273;   * = Enhanced Drive Access Support (minimum required EBIOS functions)
     274;  ** = Enhanced Disk Drive (EDD) Support
     275; *** = Drive Locking and Ejecting Support
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm

    r148 r150  
    1313;               If bit 7 is set all hard disks and floppy disks reset.
    1414;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    15 ;       SS:BP:  Ptr to INTPACK
    16 ;   Returns with INTPACK in SS:BP:
     15;       SS:BP:  Ptr to IDEPACK
     16;   Returns with INTPACK:
    1717;       AH:     Int 13h return status (from drive requested in DL)
    1818;       CF:     0 if succesfull, 1 if error
     
    8989
    9090;--------------------------------------------------------------------
    91 ; ResetHardDisksHandledByOurBIOS
     91; AH0h_ResetHardDisksHandledByOurBIOS
    9292;   Parameters:
    9393;       BL:     Requested drive (DL when entering AH=00h)
    9494;       DS:     RAMVARS segment
     95;       SS:BP:  Ptr to IDEPACK
    9596;   Returns:
    9697;       BH:     Error code from requested drive (if available)
    9798;   Corrupts registers:
    98 ;       AX, CX, DX, DI
     99;       AX, CX, DX, SI, DI
    99100;--------------------------------------------------------------------
    100101ALIGN JUMP_ALIGN
     
    103104    test    dh, dh
    104105    jz      SHORT .AllDrivesReset       ; Return if no drives
    105     mov     dl, [RAMVARS.bFirstDrv]     ; Load number of first our drive
     106    mov     dl, [RAMVARS.bFirstDrv]     ; Load number of our first drive
    106107    add     dh, dl                      ; DH = one past last drive to reset
    107108ALIGN JUMP_ALIGN
     
    132133.BackupErrorCodeFromMasterOrSlaveToBH:
    133134    call    BackupErrorCodeFromTheRequestedDriveToBH
    134     mov     cx, [RAMVARS.wIdeBase]      ; Load base port for resetted drive
    135 
     135    call    GetBasePortToCX             ; Load base port for resetted drive
     136    push    cx
    136137    inc     dx                          ; DL to next drive
    137     call    FindDPT_ForDriveNumber      ; Get DPT to DS:DI, store port to RAMVARS
    138     jnc     SHORT .NoMoreDrivesOrNoSlaveDrive
    139     cmp     cx, [RAMVARS.wIdeBase]      ; Next drive is from same controller?
     138    call    GetBasePortToCX
     139    pop     di
     140    cmp     cx, di                      ; Next drive is from same controller?
    140141    je      SHORT BackupErrorCodeFromTheRequestedDriveToBH
    141142.NoMoreDrivesOrNoSlaveDrive:
    142143    dec     dx
     144    ret
     145
     146;--------------------------------------------------------------------
     147; GetBasePortToCX
     148;   Parameters:
     149;       DL:     Drive number
     150;       DS:     RAMVARS segment
     151;   Returns:
     152;       CX:     Base port address
     153;       CF:     Set if valid drive number
     154;               Cleared if invalid drive number
     155;   Corrupts registers:
     156;       DI
     157;--------------------------------------------------------------------
     158ALIGN JUMP_ALIGN
     159GetBasePortToCX:
     160    xchg    cx, bx
     161    xor     bx, bx
     162    call    FindDPT_ForDriveNumber
     163    jnc     SHORT .DptNotFound
     164    mov     bl, [di+DPT.bIdevarsOffset]
     165    mov     bx, [cs:bx+IDEVARS.wPort]
     166.DptNotFound:
     167    xchg    bx, cx
    143168    ret
    144169
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH10h_HReady.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
     15;   Returns with INTPACK:
    1616;       AH:     Int 13h return status
    1717;       CF:     0 if succesfull, 1 if error
     
    1919ALIGN JUMP_ALIGN
    2020AH10h_HandlerForCheckDriveReady:
    21     call    HStatus_WaitRdyDefTime
    22     xor     ah, ah
     21%ifdef USE_186
     22    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     23    jmp     Device_SelectDrive
     24%else
     25    call    Device_SelectDrive
    2326    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     27%endif
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
     15;   Returns with INTPACK:
    1616;       AH:     BIOS Error code
    1717;       CF:     0 if succesfull, 1 if error
     
    3232;   Parameters:
    3333;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     34;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
    3435;   Returns:
    3536;       AH:     BIOS Error code
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEPACK
     15;   Returns with INTPACK:
    1616;       If succesfull:
    1717;           AH:     3 (Hard disk accessible)
     
    2525ALIGN JUMP_ALIGN
    2626AH15h_HandlerForReadDiskDriveSize:
    27     call    HCapacity_GetSectorCountFromOurAH08h        ; Sector count to DX:AX
    28     mov     [bp+INTPACK.cx], dx                         ; HIWORD to CX
    29     mov     [bp+INTPACK.dx], ax                         ; LOWORD to DX
     27    call    AH15h_GetSectorCountToDXAX
     28    mov     [bp+IDEPACK.intpack+INTPACK.cx], dx         ; HIWORD to CX
     29    mov     [bp+IDEPACK.intpack+INTPACK.dx], ax         ; LOWORD to DX
    3030
    3131    xor     ah, ah
    32     call    HError_SetErrorCodeToIntpackInSSBPfromAH    ; Store success to BDA and CF
    33     mov     BYTE [bp+INTPACK.ah], 3                     ; Type code = Hard disk
     32    call    Int13h_SetErrorCodeToIntpackInSSBPfromAH    ; Store success to BDA and CF
     33    mov     BYTE [bp+IDEPACK.intpack+INTPACK.ah], 3     ; Type code = Hard disk
    3434    jmp     Int13h_ReturnFromHandlerWithoutStoringErrorCode
     35
     36
     37;--------------------------------------------------------------------
     38; AH15h_GetSectorCountFromForeignDriveToDXAX:
     39; AH15h_GetSectorCountToDXAX:
     40;   Parameters:
     41;       DL:     Drive number
     42;       DS:     RAMVARS segment
     43;       DS:DI:  Ptr to DPT (AH15h_GetSectorCount only)
     44;   Returns:
     45;       DX:AX:  Total sector count
     46;       BX:     Zero
     47;   Corrupts registers:
     48;       CX
     49;--------------------------------------------------------------------
     50AH15h_GetSectorCountFromForeignDriveToDXAX:
     51    mov     ah, GET_DRIVE_PARAMETERS
     52    call    Int13h_CallPreviousInt13hHandler
     53    jmp     SHORT ConvertAH08hReturnValuesToSectorCount
     54
     55ALIGN JUMP_ALIGN
     56AH15h_GetSectorCountToDXAX:
     57    call    AH8h_GetDriveParameters
     58    ; Fall to ConvertAH08hReturnValuesToSectorCount
     59
     60ConvertAH08hReturnValuesToSectorCount:
     61    call    HAddress_ExtractLCHSparametersFromOldInt13hAddress
     62    xor     ax, ax          ; Zero AX
     63    inc     cx              ; Max cylinder number to cylinder count
     64    xchg    al, bh          ; AX=Max head number, BX=Sectors per track
     65    inc     ax              ; AX=Head count
     66    mul     bx              ; AX=Head count * Sectors per track
     67    mul     cx              ; DX:AX = Total sector count
     68    xor     bx, bx          ; Zero BX for 48-bit sector count (and clear CF)
     69    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
     15;   Returns with INTPACK:
    1616;       AH:     Int 13h floppy return status
    1717;       CF:     0 if AH = RET_HD_SUCCESS, 1 otherwise (error)
     
    2121    LOAD_BDA_SEGMENT_TO ds, ax, !
    2222    xchg    ah, [BDA.bHDLastSt]     ; Load and clear last error
    23     call    HError_SetErrorCodeToIntpackInSSBPfromAH
     23    call    Int13h_SetErrorCodeToIntpackInSSBPfromAH
    2424    jmp     Int13h_ReturnFromHandlerWithoutStoringErrorCode
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH23h_HFeatures.asm

    r148 r150  
    1414;       DL:     Translated Drive number
    1515;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    16 ;       SS:BP:  Ptr to INTPACK
    17 ;   Parameters on INTPACK in SS:BP:
     16;       SS:BP:  Ptr to IDEPACK
     17;   Parameters on INTPACK:
    1818;       AL:     Feature Number (parameter to Features Register = subcommand)
    19 ;   (Parameter registers are undocumented, there are specific for this BIOS):
    20 ;       BH:     Parameter to Sector Count Register (subcommand specific)
    21 ;       BL:     Parameter to Sector Number Register (subcommand specific)
    22 ;       CL:     Parameter to Low Cylinder Register (subcommand specific)
    23 ;       CH:     Parameter to High Cylinder Register (subcommand specific)
    24 ;   Returns with INTPACK in SS:BP:
     19;   (Parameter registers are undocumented, these are specific for this BIOS):
     20;       BL:     Parameter to Sector Count Register (subcommand specific)
     21;       BH:     Parameter to LBA Low / Sector Number Register (subcommand specific)
     22;       CL:     Parameter to LBA Middle / Cylinder Low Register (subcommand specific)
     23;       CH:     Parameter to LBA High / Cylinder High Register (subcommand specific)
     24;   Returns with INTPACK:
    2525;       AH:     Int 13h return status
    2626;       CF:     0 if succesfull, 1 if error
     
    2828ALIGN JUMP_ALIGN
    2929AH23h_HandlerForSetControllerFeatures:
     30    xchg    si, ax      ; SI = Feature Number
     31    mov     dx, [bp+IDEPACK.intpack+INTPACK.bx]
    3032%ifndef USE_186
    3133    call    AH23h_SetControllerFeatures
     
    4042; AH23h_SetControllerFeatures
    4143;   Parameters:
    42 ;       AL:     Feature Number (parameter to Features Register = subcommand)
    43 ;       BH:     Parameter to Sector Count Register (subcommand specific)
    44 ;       BL:     Parameter to Sector Number Register (subcommand specific)
    45 ;       CL:     Parameter to Low Cylinder Register (subcommand specific)
    46 ;       CH:     Parameter to High Cylinder Register (subcommand specific)
     44;       DL:     Parameter to Sector Count Register (subcommand specific)
     45;       DH:     Parameter to LBA Low / Sector Number Register (subcommand specific)
     46;       CL:     Parameter to LBA Middle / Cylinder Low Register (subcommand specific)
     47;       CH:     Parameter to LBA High / Cylinder High Register (subcommand specific)
     48;       SI:     Feature Number (parameter to Features Register = subcommand)
    4749;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     50;       SS:BP:  Ptr to IDEPACK
    4851;   Returns:
    4952;       AH:     Int 13h return status
    5053;       CF:     0 if succesfull, 1 if error
    5154;   Corrupts registers:
    52 ;       AX, BX, CX, DX, SI
     55;       AL, BX, CX, DX
    5356;--------------------------------------------------------------------
    5457ALIGN JUMP_ALIGN
    5558AH23h_SetControllerFeatures:
    56     ; Backup AL and BH to SI
    57     mov     ah, bh
    58     xchg    si, ax
    59 
    60     ; Select Master or Slave and wait until ready
    61     call    HDrvSel_SelectDriveAndDisableIRQ
    62     jc      SHORT .ReturnWithErrorCodeInAH
    63 
    64     ; Output Feature Number
    65     mov     ax, si                      ; Feature number to AL
    66     mov     dx, [RAMVARS.wIdeBase]      ; Load base port address
    67     inc     dx                          ; REGW_IDE_FEAT
    68     out     dx, al
    69 
    70     ; Output parameters to Sector Number Register and Cylinder Registers
    71     xor     bh, bh                      ; Zero head number
    72     dec     dx                          ; Back to base port address
    73     call    HCommand_OutputTranslatedLCHSaddress
    74 
    75     ; Output parameter to Sector Count Register and command
    76     xchg    ax, si                      ; Sector Count Reg param to AH
    77     mov     al, ah                      ; Sector Count Reg param to AL
    78     mov     ah, HCMD_SET_FEAT           ; Load Set Features command to AH
    79     call    HCommand_OutputSectorCountAndCommand
    80 
    81     jmp     HStatus_WaitBsyDefTime      ; Wait until drive ready
    82 .ReturnWithErrorCodeInAH:
    83     ret
     59    mov     al, COMMAND_SET_FEATURES
     60    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
     61    jmp     Idepack_StoreNonExtParametersAndIssueCommandFromAL
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm

    r148 r150  
    1313;       DL:     Translated Drive number
    1414;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    15 ;       SS:BP:  Ptr to INTPACK
    16 ;   Parameters on INTPACK in SS:BP:
     15;       SS:BP:  Ptr to IDEPACK
     16;   Parameters on INTPACK:
    1717;       AL:     Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128)
    18 ;   Returns with INTPACK in SS:BP:
     18;   Returns with INTPACK:
    1919;       AH:     Int 13h return status
    2020;       CF:     0 if succesfull, 1 if error
     
    2222ALIGN JUMP_ALIGN
    2323AH24h_HandlerForSetMultipleBlocks:
     24    test    WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
     25    jnz     SHORT .TryToSetBlockMode
     26    stc
     27    mov     ah, RET_HD_INVALID
     28    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     29
     30ALIGN JUMP_ALIGN
     31.TryToSetBlockMode:
    2432%ifndef USE_186
    2533    call    AH24h_SetBlockSize
     
    3240
    3341;--------------------------------------------------------------------
    34 ; Sets block size for block mode transfers.
    35 ;
    3642; AH24h_SetBlockSize
    3743;   Parameters:
    3844;       AL:     Number of Sectors per Block (1, 2, 4, 8, 16, 32, 64 or 128)
    3945;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     46;       SS:BP:  Ptr to IDEPACK
    4047;   Returns:
    4148;       AH:     Int 13h return status
     
    4653ALIGN JUMP_ALIGN
    4754AH24h_SetBlockSize:
    48     ; Select Master or Slave and wait until ready
    49     mov     bl, al                              ; Backup block size
    50     call    HDrvSel_SelectDriveAndDisableIRQ    ; Select drive and wait until ready
    51     jc      SHORT .ReturnWithErrorCodeInAH      ; Return if error
    52 
    53     ; Output block size and command
    54     mov     al, bl                              ; Restore block size to AL
    55     mov     ah, HCMD_SET_MUL                    ; Load command to AH
    56     mov     dx, [RAMVARS.wIdeBase]              ; Load base port address
    57     add     dx, BYTE REG_IDE_CNT
    58     call    HCommand_OutputSectorCountAndCommand
    59     call    HStatus_WaitBsyDefTime              ; Wait until drive not busy
     55    MIN_U   al, MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS
     56    push    ax
     57    xchg    dx, ax          ; DL = Block size (Sector Count Register)
     58    mov     al, COMMAND_SET_MULTIPLE_MODE
     59    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY)
     60    call    Idepack_StoreNonExtParametersAndIssueCommandFromAL
     61    pop     bx
    6062    jc      SHORT .DisableBlockMode
    6163
    6264    ; Store new block size to DPT and return
    63     mov     [di+DPT.bSetBlock], bl              ; Store new block size
    64     xor     ah, ah                              ; Zero AH and CF since success
     65    mov     [di+DPT_ATA.bSetBlock], bl              ; Store new block size
    6566    ret
    6667.DisableBlockMode:
    67     mov     BYTE [di+DPT.bSetBlock], 1          ; Disable block mode
    68 .ReturnWithErrorCodeInAH:
     68    mov     BYTE [di+DPT_ATA.bSetBlock], 1          ; Disable block mode
    6969    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm

    r148 r150  
    1313;       DL:     Translated Drive number
    1414;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    15 ;       SS:BP:  Ptr to INTPACK
    16 ;   Parameters on INTPACK in SS:BP:
     15;       SS:BP:  Ptr to IDEPACK
     16;   Parameters on INTPACK:
    1717;       ES:BX:  Ptr to buffer to receive 512-byte drive information
    18 ;   Returns with INTPACK in SS:BP:
     18;   Returns with INTPACK:
    1919;       AH:     Int 13h return status
    2020;       CF:     0 if succesfull, 1 if error
     
    2222ALIGN JUMP_ALIGN
    2323AH25h_HandlerForGetDriveInformation:
    24     ; Wait until previously selected drive is ready
    25     call    HDrvSel_SelectDriveAndDisableIRQ
    26     jc      SHORT .ReturnWithErrorCodeInAH      ; Return if error
     24    push    bp
    2725
    28     ; Get drive information
    29     mov     bx, [bp+INTPACK.bx]
    30     call    HPIO_NormalizeDataPointer
    31     push    bx
    32     mov     dx, [RAMVARS.wIdeBase]      ; Load base port address
    33     eMOVZX  bx, BYTE [di+DPT.bIdeOff]   ; Load offset to IDEVARS
    34     mov     bl, [cs:bx+IDEVARS.bBusType]; Load bus type to BL
    35     mov     bh, [di+DPT.bDrvSel]        ; Load drive sel byte to BH
    36     pop     di                          ; Pop buffer offset to DI
    37     call    AH25h_GetDriveInfo          ; Get drive information
    38 .ReturnWithErrorCodeInAH:
     26    mov     si, [bp+IDEPACK.intpack+INTPACK.bx]
     27    call    AccessDPT_GetDriveSelectByteToAL
     28    mov     bh, al
     29    eMOVZX  ax, BYTE [di+DPT.bIdevarsOffset]
     30    xchg    bp, ax
     31    call    Device_IdentifyToBufferInESSIwithDriveSelectByteInBH
     32
     33    pop     bp
    3934    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    40 
    41 
    42 ;--------------------------------------------------------------------
    43 ; Gets drive information using Identify Device command.
    44 ;
    45 ; AH25h_GetDriveInfo
    46 ;   Parameters:
    47 ;       BH:     Drive Select byte for Drive and Head Select Register
    48 ;       BL:     Bus type
    49 ;       DX:     IDE Controller base port address
    50 ;       DS:     Segment to RAMVARS
    51 ;       ES:DI:  Ptr to buffer to receive 512 byte drive information
    52 ;   Returns:
    53 ;       AH:     Int 13h return status (will be stored to BDA)
    54 ;       CF:     0 if succesfull, 1 if error
    55 ;   Corrupts registers:
    56 ;       AL, CX
    57 ;--------------------------------------------------------------------
    58 ALIGN JUMP_ALIGN
    59 AH25h_GetDriveInfo:
    60     push    di
    61     push    dx
    62     push    bx
    63 
    64     ; Select Master or Slave drive.
    65     ; DO NOT WAIT UNTIL CURRENTLY SELECTED IS READY!
    66     ; It makes slave drive detection impossible if master is not present.
    67     mov     [RAMVARS.wIdeBase], dx      ; Store IDE Base port to RAMVARS
    68     add     dx, BYTE REG_IDE_DRVHD      ; DX to Drive and Head Sel Register
    69     mov     al, bh                      ; Drive Select byte to AL
    70     out     dx, al                      ; Select Master or Slave drive
    71     sub     dx, BYTE REG_IDE_DRVHD      ; Back to IDE Base port
    72 
    73     ; Wait until ready to accept commands
    74     xor     bh, bh                      ; BX now contains bus type
    75     mov     cl, B_TIMEOUT_DRVINFO       ; Load short timeout
    76     cmp     [RAMVARS.bDrvCnt], bh       ; Detecting first drive?
    77     eCMOVE  cl, B_TIMEOUT_RESET         ;  If so, load long timeout
    78     call    HStatus_WaitRdy             ; Wait until ready to accept commands
    79     jc      SHORT .ReturnWithErrorCodeInAH
    80 
    81     ; Output command
    82     mov     al, HCMD_ID_DEV             ; Load Identify Device command to AL
    83     out     dx, al                      ; Output command
    84     call    HStatus_WaitDrqDefTime      ; Wait until ready to transfer (no IRQ!)
    85     jc      SHORT .ReturnWithErrorCodeInAH
    86 
    87     ; Transfer data
    88     sub     dx, BYTE REGR_IDE_ST        ; DX to IDE Data Reg
    89     mov     cx, 256                     ; Transfer 256 words (single sector)
    90     cld                                 ; INSW to increment DI
    91     call    [cs:bx+g_rgfnPioRead]       ; Read ID sector
    92     call    HStatus_WaitRdyDefTime      ; Wait until drive ready
    93 
    94 .ReturnWithErrorCodeInAH:
    95     pop     bx
    96     pop     dx
    97     pop     di
    98     ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm

    r148 r150  
    1313;       DL:     Translated Drive number
    1414;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    15 ;       SS:BP:  Ptr to INTPACK
    16 ;   Parameters on INTPACK in SS:BP:
    17 ;       AL:     Number of sectors to read (1...255)
     15;       SS:BP:  Ptr to IDEPACK
     16;   Parameters on INTPACK:
     17;       AL:     Number of sectors to read (1...255, 0=256)
    1818;       CH:     Cylinder number, bits 7...0
    1919;       CL:     Bits 7...6: Cylinder number bits 9 and 8
     
    2121;       DH:     Starting head number (0...255)
    2222;       ES:BX:  Pointer to buffer recieving data
    23 ;   Returns with INTPACK in SS:BP:
     23;   Returns with INTPACK:
    2424;       AH:     Int 13h/40h floppy return status
    2525;       AL:     Burst error length if AH returns 11h, undefined otherwise
     
    2828ALIGN JUMP_ALIGN
    2929AH2h_HandlerForReadDiskSectors:
    30     test    al, al                      ; Invalid sector count?
    31     jz      SHORT AH2h_ZeroCntErr       ;  If so, return with error
    32 
    33     ; Select sector or block mode command
    34     mov     ah, HCMD_READ_SECT          ; Load sector mode command
    35     cmp     BYTE [di+DPT.bSetBlock], 1  ; Block mode enabled?
    36     eCMOVA  ah, HCMD_READ_MUL           ; Load block mode command
    37 
    38     ; Transfer data
    39     call    HCommand_OutputCountAndLCHSandCommand
    40     jc      SHORT .ReturnWithErrorCodeInAH
    41     mov     bx, [bp+INTPACK.bx]
    42     call    HPIO_ReadBlock              ; Read data from IDE-controller
    43 .ReturnWithErrorCodeInAH:
     30    mov     ah, COMMAND_READ_SECTORS    ; Load sector mode command
     31    test    WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
     32    eCMOVNZ ah, COMMAND_READ_MULTIPLE   ; Load block mode command
     33    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
     34    mov     si, [bp+IDEPACK.intpack+INTPACK.bx]
     35%ifdef USE_186
     36    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     37    jmp     Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
     38%else
     39    call    Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
    4440    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    45 
    46 ; Invalid sector count (also for AH=3h and AH=4h)
    47 AH2h_ZeroCntErr:
    48     mov     ah, RET_HD_INVALID          ; Invalid value passed
    49     jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     41%endif
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm

    r148 r150  
    1313;       DL:     Translated Drive number
    1414;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    15 ;       SS:BP:  Ptr to INTPACK
    16 ;   Parameters on INTPACK in SS:BP:
     15;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
     16;   Parameters on INTPACK:
    1717;       AL:     Number of sectors to write
    1818;       CH:     Cylinder number, bits 7...0
     
    2121;       DH:     Starting head number (0...255)
    2222;       ES:BX:  Pointer to source data
    23 ;   Returns with INTPACK in SS:BP:
     23;   Returns with INTPACK:
    2424;       AH:     Int 13h/40h floppy return status
    2525;       CF:     0 if successfull, 1 if error
     
    2727ALIGN JUMP_ALIGN
    2828AH3h_HandlerForWriteDiskSectors:
    29     test    al, al                      ; Invalid sector count?
    30     jz      SHORT AH2h_ZeroCntErr       ;  If so, return with error
    31 
    32     ; Select sector or block mode command
    33     mov     ah, HCMD_WRITE_SECT         ; Load sector mode command
    34     cmp     BYTE [di+DPT.bSetBlock], 1  ; Block mode enabled?
    35     eCMOVA  ah, HCMD_WRITE_MUL          ; Load block mode command
    36 
    37     ; Transfer data
    38     call    HCommand_OutputCountAndLCHSandCommand
    39     jc      SHORT .ReturnWithErrorCodeInAH
    40     mov     bx, [bp+INTPACK.bx]
    41     call    HPIO_WriteBlock             ; Write data to IDE-controller
    42 .ReturnWithErrorCodeInAH:
     29    ; Prepare parameters
     30    mov     ah, COMMAND_WRITE_SECTORS   ; Load sector mode command
     31    test    WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
     32    eCMOVNZ ah, COMMAND_WRITE_MULTIPLE  ; Load block mode command
     33    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
     34    mov     si, [bp+IDEPACK.intpack+INTPACK.bx]
     35%ifdef USE_186
     36    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     37    jmp     Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
     38%else
     39    call    Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
    4340    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     41%endif
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm

    r148 r150  
    2626ALIGN JUMP_ALIGN
    2727AH4h_HandlerForVerifyDiskSectors:
    28     test    al, al                      ; Invalid sector count?
    29     jz      SHORT AH2h_ZeroCntErr       ;  If so, return with error
    30 
    31     mov     ah, HCMD_VERIFY_SECT        ; Load command to AH
    32     call    HCommand_OutputCountAndLCHSandCommand
    33     jc      SHORT .ReturnWithErrorCodeInAH
    34     mov     bx, di                      ; DS:BX now points to DPT
    35     call    HStatus_WaitIrqOrRdy        ; Wait for IRQ or RDY
    36 .ReturnWithErrorCodeInAH:
     28    mov     ah, COMMAND_WRITE_SECTORS
     29    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
     30%ifdef USE_186
     31    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     32    jmp     Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
     33%else
     34    call    Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
    3735    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     36%endif
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEPACK
     15;   Returns with INTPACK:
    1616;       CH:     Maximum cylinder number, bits 7...0
    1717;       CL:     Bits 7...6: Cylinder number bits 9...8
     
    3434    call    RamVars_GetCountOfKnownDrivesToDL
    3535.ReturnAfterStoringValuesToIntpack:
    36     mov     [bp+INTPACK.cx], cx
    37     mov     [bp+INTPACK.dx], dx
     36    mov     [bp+IDEPACK.intpack+INTPACK.cx], cx
     37    mov     [bp+IDEPACK.intpack+INTPACK.dx], dx
    3838    xor     ah, ah
    3939.ReturnErrorFromPreviousInt13hHandler:
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEPACK
     15;   Returns with INTPACK:
    1616;       AH:     Int 13h return status
    1717;       CF:     0 if succesfull, 1 if error
     
    3434;   Parameters:
    3535;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     36;       SS:BP:  Ptr to IDEPACK
    3637;   Returns:
    3738;       AH:     Int 13h return status
     
    4546
    4647    ; Try to select drive and wait until ready
    47     or      BYTE [di+DPT.bReset], MASK_RESET_ALL        ; Everything uninitialized
    48     call    HDrvSel_SelectDriveAndDisableIRQ
     48    or      WORD [di+DPT.wFlags], MASK_DPT_RESET        ; Everything uninitialized
     49    call    AccessDPT_GetDriveSelectByteToAL
     50    mov     [bp+IDEPACK.bDrvAndHead], al
     51    call    Device_SelectDrive
    4952    jc      SHORT .ReturnNotSuccessfull
    50     and     BYTE [di+DPT.bReset], ~FLG_RESET_nDRDY      ; Clear since success
     53    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nDRDY  ; Clear since success
    5154
    5255    ; Initialize CHS parameters if LBA is not used
    53     call    AH9h_InitializeDeviceParameters
     56    call    InitializeDeviceParameters
    5457    jc      SHORT .RecalibrateDrive
    55     and     BYTE [di+DPT.bReset], ~FLG_RESET_nINITPRMS
     58    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nINITPRMS
    5659
    5760    ; Recalibrate drive by seeking to cylinder 0
    58 ALIGN JUMP_ALIGN
    5961.RecalibrateDrive:
    6062    call    AH11h_RecalibrateDrive
    6163    jc      SHORT .InitializeBlockMode
    62     and     BYTE [di+DPT.bReset], ~FLG_RESET_nRECALIBRATE
     64    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nRECALIBRATE
    6365
    6466    ; Initialize block mode transfers
    6567.InitializeBlockMode:
    66     call    AH9h_InitializeBlockMode
     68    call    InitializeBlockMode
    6769    jc      SHORT .ReturnNotSuccessfull
    68     and     BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK  ; Keeps CF clear
     70    and     WORD [di+DPT.wFlags], ~FLG_DPT_RESET_nSETBLOCK  ; Keeps CF clear
    6971
    7072.ReturnNotSuccessfull:
     
    7476
    7577;--------------------------------------------------------------------
    76 ; Sends Initialize Device Parameters command to IDE Hard Disk.
    77 ; Initialization is used to initialize logical CHS parameters. Drives
    78 ; may not support all CHS values.
    79 ; This command is only supported by drives that supports CHS addressing.
    80 ;
    81 ; AH9h_InitializeDeviceParameters
     78; InitializeDeviceParameters
    8279;   Parameters:
    83 ;       DS:DI:  Ptr to DPT
    84 ;   Returns:
    85 ;       AH:     BIOS Error code
    86 ;       CF:     Cleared if succesfull
    87 ;               Set if any error
    88 ;   Corrupts registers:
    89 ;       AL, BX, CX
    90 ;--------------------------------------------------------------------
    91 ALIGN JUMP_ALIGN
    92 AH9h_InitializeDeviceParameters:
    93     ; No need to initialize CHS parameters if LBA mode enabled
    94     test    BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_LBA    ; Clears CF
    95     jnz     SHORT .Return
    96 
    97     push    dx
    98     mov     bh, [di+DPT.bPHeads]
    99     dec     bh                      ; Max head number
    100     mov     dx, [RAMVARS.wIdeBase]
    101     call    HCommand_OutputTranslatedLCHSaddress
    102     mov     ah, HCMD_INIT_DEV
    103     mov     al, [di+DPT.bPSect]     ; Sectors per track
    104     call    HCommand_OutputSectorCountAndCommand
    105     call    HStatus_WaitBsyDefTime  ; Wait until drive ready (DRDY won't be set!)
    106     pop     dx
    107 .Return:
    108     ret
    109 
    110 
    111 ;--------------------------------------------------------------------
    112 ; Initializes block mode transfers.
    113 ;
    114 ; AH9h_InitializeBlockMode
    115 ;   Parameters:
    116 ;       DS:DI:  Ptr to DPT
     80;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     81;       SS:BP:  Ptr to IDEPACK
    11782;   Returns:
    11883;       AH:     BIOS Error code
     
    12388;--------------------------------------------------------------------
    12489ALIGN JUMP_ALIGN
    125 AH9h_InitializeBlockMode:
    126     mov     ax, FLG_DRVPARAMS_BLOCKMODE
    127     call    AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
    128     jz      SHORT .Return               ; Block mode disabled (CF cleared)
    129     eMOVZX  ax, BYTE [di+DPT.bMaxBlock] ; Load max block size, zero AH
    130     test    al, al                      ; Block mode supported? (clears CF)
    131     jz      SHORT .Return               ;  If not, return
     90InitializeDeviceParameters:
     91    ; No need to initialize CHS parameters if LBA mode enabled
     92    test    BYTE [di+DPT.wFlags], FLG_DRVNHEAD_LBA  ; Clear CF
     93    jnz     SHORT ReturnSuccessSinceInitializationNotNeeded
     94
     95    ; Initialize Locigal Sectors per Track and Max Head number
     96    mov     ah, [di+DPT.bPchsHeads]
     97    dec     ah                          ; Max Head number
     98    mov     dl, [di+DPT.bPchsSectors]   ; Sectors per Track
     99    mov     al, COMMAND_INITIALIZE_DEVICE_PARAMETERS
     100    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
     101    jmp     Idepack_StoreNonExtParametersAndIssueCommandFromAL
     102
     103
     104;--------------------------------------------------------------------
     105; InitializeBlockMode
     106;   Parameters:
     107;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     108;   Returns:
     109;       AH:     BIOS Error code
     110;       CF:     Cleared if succesfull
     111;               Set if any error
     112;   Corrupts registers:
     113;       AL, BX, CX, DX
     114;--------------------------------------------------------------------
     115ALIGN JUMP_ALIGN
     116InitializeBlockMode:
     117    test    WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED  ; Clear CF
     118    jz      SHORT ReturnSuccessSinceInitializationNotNeeded
     119
     120    mov     al, [di+DPT_ATA.bMaxBlock]  ; Load max block size, zero AH
    132121    jmp     AH24h_SetBlockSize
    133 .Return:
     122ReturnSuccessSinceInitializationNotNeeded:
    134123    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHCh_HSeek.asm

    r148 r150  
    1313;       DL:     Translated Drive number
    1414;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    15 ;       SS:BP:  Ptr to INTPACK
    16 ;   Parameters on INTPACK in SS:BP:
     15;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
     16;   Parameters on INTPACK:
    1717;       CH:     Cylinder number, bits 7...0
    1818;       CL:     Bits 7...6: Cylinder number bits 9 and 8
    1919;               Bits 5...0: Starting sector number (1...63)
    2020;       DH:     Starting head number (0...255)
    21 ;   Returns with INTPACK in SS:BP:
     21;   Returns with INTPACK:
    2222;       AH:     BIOS Error code
    2323;       CF:     0 if succesfull, 1 if error
     
    3333%endif
    3434
    35 
    3635;--------------------------------------------------------------------
    3736; AHCh_SeekToCylinder
     
    4241;       DH:     Starting head number (0...255)
    4342;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     43;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
    4444;   Returns:
    4545;       AH:     BIOS Error code
     
    4949;--------------------------------------------------------------------
    5050AHCh_SeekToCylinder:
    51     mov     ax, HCMD_SEEK<<8            ; Load cmd to AH, AL=zero sector cnt
    52     call    HCommand_OutputCountAndLCHSandCommand
    53     jc      SHORT .ReturnWithErrorCodeInAH
    54     mov     bx, di                      ; DS:BX now points to DPT
    55     jmp     HStatus_WaitIrqOrRdy        ; Wait for IRQ or RDY
    56 .ReturnWithErrorCodeInAH:
    57     ret
     51    mov     ah, COMMAND_SEEK
     52    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
     53    jmp     Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm

    r148 r150  
    1212;       DL:     Translated Drive number
    1313;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    14 ;       SS:BP:  Ptr to INTPACK
    15 ;   Returns with INTPACK in SS:BP:
     14;       SS:BP:  Ptr to IDEPACK
     15;   Returns with INTPACK:
    1616;       AH:     Int 13h return status
    1717;       CF:     0 if succesfull, 1 if error
     
    3535;       DL:     Drive number
    3636;       DS:     RAMVARS segment
     37;       SS:BP:  Ptr to IDEPACK
    3738;   Returns:
    3839;       AH:     Int 13h return status
    3940;       CF:     0 if succesfull, 1 if error
    4041;   Corrupts registers:
    41 ;       AL, CX, DI
     42;       AL, CX, SI, DI
    4243;--------------------------------------------------------------------
    4344ALIGN JUMP_ALIGN
     
    4849    call    FindDPT_ForDriveNumber      ; DS:DI now points to DPT
    4950    call    Interrupts_UnmaskInterruptControllerForDriveInDSDI
    50     call    AHDh_ResetMasterAndSlave
     51    call    Device_ResetMasterAndSlaveController
    5152    ;jc     SHORT .ReturnError          ; CF would be set if slave drive present without master
    5253                                        ; (error register has special values after reset)
    5354
    5455    ; Initialize Master and Slave drives
    55     mov     dx, [RAMVARS.wIdeBase]      ; Load base port address
    56     call    AHDh_InitializeMasterAndSlave
     56    eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]
     57    mov     dx, [cs:bx+IDEVARS.wPort]
     58    call    InitializeMasterAndSlaveDriveFromPortInDX
    5759
    5860    pop     bx
     
    6264
    6365;--------------------------------------------------------------------
    64 ; Resets Master and Slave drives at wanted port.
    65 ; Both IDE drives will be reset. It is not possible to reset
    66 ; Master or Slave only.
    67 ;
    68 ; AHDh_ResetMasterAndSlave
    69 ;   Parameters:
    70 ;       DS:DI:  Ptr to DPT for Master or Slave drive
    71 ;   Returns:
    72 ;       CF:     0 if reset succesfull
    73 ;               1 if any error
    74 ;   Corrupts registers:
    75 ;       AX, BX, CX, DX
    76 ;--------------------------------------------------------------------
    77 ALIGN JUMP_ALIGN
    78 AHDh_ResetMasterAndSlave:
    79     ; Reset controller
    80     ; HSR0: Set_SRST
    81     mov     al, [di+DPT.bDrvCtrl]       ; Load value for ACR
    82     or      al, FLG_IDE_CTRL_SRST       ; Set Reset bit
    83     call    HDrvSel_OutputDeviceControlByte
    84     mov     ax, 5                       ; Delay at least 5us
    85     call    HTimer_DelayMicrosecondsFromAX
    86 
    87     ; HSR1: Clear_wait
    88     mov     al, [di+DPT.bDrvCtrl]       ; Load value for ACR
    89     out     dx, al                      ; End Reset
    90     mov     ax, 2000                    ; Delay at least 2ms
    91     call    HTimer_DelayMicrosecondsFromAX
    92 
    93     ; HSR2: Check_status
    94     mov     cl, B_TIMEOUT_RESET         ; Reset timeout delay
    95     jmp     HStatus_WaitBsy
    96 
    97 
    98 ;--------------------------------------------------------------------
    99 ; Initializes Master and Slave drive.
    100 ;
    101 ; AHDh_InitializeMasterAndSlave
     66; InitializeMasterAndSlaveDriveFromPortInDX
    10267;   Parameters:
    10368;       DX:     IDE Base Port address
     69;       SS:BP:  Ptr to IDEPACK
    10470;   Returns:
    10571;       AH:     Error code
     
    10773;               1 if any error
    10874;   Corrupts registers:
    109 ;       AL, BX, CX, DX, DI
     75;       AL, BX, CX, DX, SI, DI
    11076;--------------------------------------------------------------------
    11177ALIGN JUMP_ALIGN
    112 AHDh_InitializeMasterAndSlave:
     78InitializeMasterAndSlaveDriveFromPortInDX:
    11379    push    dx                          ; Store base port address
    11480    xor     cx, cx                      ; Assume no errors
    115     call    FindDPT_ForIdeMasterAtPort
     81    call    FindDPT_ToDSDIForIdeMasterAtPortDX
    11682    jnc     SHORT .InitializeSlave      ; Master drive not present
    11783    call    AH9h_InitializeDriveForUse
     
    11985.InitializeSlave:
    12086    pop     dx                          ; Restore base port address
    121     call    FindDPT_ForIdeSlaveAtPort
     87    call    FindDPT_ToDSDIForIdeSlaveAtPortDX
    12288    jnc     SHORT .CombineErrors        ; Slave drive not present
    12389    call    AH9h_InitializeDriveForUse
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HAddress.asm

    r3 r150  
    1 ; File name     :   HAddress.asm
    2 ; Project name  :   IDE BIOS
    3 ; Created date  :   11.3.2010
    4 ; Last update   :   4.4.2010
    5 ; Author        :   Tomi Tilli
     1; Project name  :   XTIDE Universal BIOS
    62; Description   :   Functions for address translations.
    73
     
    95SECTION .text
    106
     7; Jump table for conversion functions
     8ALIGN WORD_ALIGN
     9g_rgfnAddressTranslation:
     10    dw      DoNotConvertLCHS                    ; 0, ADDR_DPT_LCHS
     11    dw      ConvertLCHStoPCHS                   ; 1, ADDR_DPT_PCHS
     12    dw      ConvertLCHStoLBARegisterValues      ; 2, ADDR_DPT_LBA28
     13    dw      ConvertLCHStoLBARegisterValues      ; 3, ADDR_DPT_LBA48
     14
     15
    1116;--------------------------------------------------------------------
    12 ; Outputs sector count, L-CHS address and command to IDE registers.
    13 ; This function does not wait until command has been completed.
    14 ;
    15 ; HAddress_ConvertParamsFromBiosLCHStoIDE
     17; HAddress_OldInt13hAddressToIdeAddress
    1618;   Parameters:
    1719;       CH:     Cylinder number, bits 7...0
     
    2830;       AX, DX
    2931;--------------------------------------------------------------------
    30 ALIGN WORD_ALIGN
    31 g_rgfnAddressTranslation:
    32     dw      HAddress_DoNotConvertLCHS                   ; 0, ADDR_DPT_LCHS
    33     dw      HAddress_ConvertLCHStoPCHS                  ; 1, ADDR_DPT_PCHS
    34     dw      HAddress_ConvertLCHStoLBARegisterValues     ; 2, ADDR_DPT_LBA28
    35     dw      HAddress_ConvertLCHStoLBARegisterValues     ; 3, ADDR_DPT_LBA48
    36 
    3732ALIGN JUMP_ALIGN
    38 HAddress_ConvertParamsFromBiosLCHStoIDE:
    39     mov     bl, [di+DPT.bFlags]
    40     and     bx, BYTE MASK_DPT_ADDR                      ; Addressing mode to BX
     33HAddress_OldInt13hAddressToIdeAddress:
     34    call    AccessDPT_GetAddressingModeForWordLookToBX
    4135    push    WORD [cs:bx+g_rgfnAddressTranslation]       ; Push return address
    42     ; Fall to HAddress_ExtractLCHSFromBiosParams
     36    ; Fall to HAddress_ExtractLCHSparametersFromOldInt13hAddress
    4337
    4438;---------------------------------------------------------------------
    45 ; Extracts L-CHS parameters from BIOS function parameters.
    46 ;
    47 ; HAddress_ExtractLCHSFromBiosParams:
     39; HAddress_ExtractLCHSparametersFromOldInt13hAddress
    4840;   Parameters:
    4941;       CH:     Cylinder number, bits 7...0
     
    5850;       Nothing
    5951;--------------------------------------------------------------------
    60 ALIGN JUMP_ALIGN
    61 HAddress_ExtractLCHSFromBiosParams:
     52HAddress_ExtractLCHSparametersFromOldInt13hAddress:
    6253    mov     bl, cl              ; Copy sector number...
    6354    and     bl, 3Fh             ; ...and limit to 1...63
     
    7061
    7162;---------------------------------------------------------------------
    72 ; Converts BIOS LCHS parameters to IDE P-CHS parameters.
     63; Converts LCHS parameters to IDE P-CHS parameters.
    7364; PCylinder = (LCylinder << n) + (LHead / PHeadCount)
    7465; PHead     = LHead % PHeadCount
     
    8980;--------------------------------------------------------------------
    9081ALIGN JUMP_ALIGN
    91 HAddress_ConvertLCHStoPCHS:
     82ConvertLCHStoPCHS:
    9283    ; LHead / PHeadCount and LHead % PHeadCount
    9384    eMOVZX  ax, bh                  ; Copy L-CHS Head number to AX
    94     div     BYTE [di+DPT.bPHeads]   ; AL = LHead / PHeadCount, AH = LHead % PHeadCount
     85    div     BYTE [di+DPT.bPchsHeads]; AL = LHead / PHeadCount, AH = LHead % PHeadCount
    9586    mov     bh, ah                  ; Copy P-CHS Head number to BH
    9687    xor     ah, ah                  ; AX = LHead / PHeadCount
     
    9889    ; (LCylinder << n) + (LHead / PHeadCount)
    9990    mov     dx, cx                  ; Copy L-CHS Cylinder number to DX
    100     mov     cl, [di+DPT.bShLtoP]    ; Load shift count
     91    mov     cl, [di+DPT.wFlags]     ; Load shift count
     92    and     cl, MASK_DPT_CHS_SHIFT_COUNT
    10193    shl     dx, cl                  ; DX = LCylinder << n
    10294    add     ax, dx                  ; AX = P-CHS Cylinder number
    10395    mov     cx, ax                  ; Copy P-CHS Cylinder number to CX
    104 ALIGN JUMP_ALIGN
    105 HAddress_DoNotConvertLCHS:
     96DoNotConvertLCHS:
    10697    ret
    10798
     
    109100;---------------------------------------------------------------------
    110101; Converts LCHS parameters to 28-bit LBA address.
     102; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit.
     103; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1
     104;
    111105; Returned address is in same registers that
    112106; HAddress_DoNotConvertLCHS and HAddress_ConvertLCHStoPCHS returns.
    113107;
    114 ; HAddress_ConvertLCHStoLBARegisterValues:
     108; ConvertLCHStoLBARegisterValues:
    115109;   Parameters:
    116110;       BL:     Sector number (1...63)
     
    127121;--------------------------------------------------------------------
    128122ALIGN JUMP_ALIGN
    129 HAddress_ConvertLCHStoLBARegisterValues:
    130     call    HAddress_ConvertLCHStoLBA28
    131     mov     bl, al                  ; Sector Number Register (LBA 7...0)
    132     mov     cl, ah                  ; Low Cylinder Register (LBA 15...8)
    133     mov     ch, dl                  ; High Cylinder Register (LBA 23...16)
    134     mov     bh, dh                  ; Drive and Head Register (LBA 27...24)
    135     ret
    136 
    137 ;---------------------------------------------------------------------
    138 ; Converts LCHS parameters to 28-bit LBA address.
    139 ; Only 24-bits are used since LHCS to LBA28 conversion has 8.4GB limit.
    140 ; LBA = ((cylToSeek*headsPerCyl+headToSeek)*sectPerTrack)+sectToSeek-1
    141 ;
    142 ; HAddress_ConvertLCHStoLBA28:
    143 ;   Parameters:
    144 ;       BL:     Sector number (1...63)
    145 ;       BH:     Head number (0...255)
    146 ;       CX:     Cylinder number (0...1023)
    147 ;       DS:DI:  Ptr to Disk Parameter Table
    148 ;   Returns:
    149 ;       DX:AX:  28-bit LBA address (DH is always zero)
    150 ;   Corrupts registers:
    151 ;       BX, CX
    152 ;--------------------------------------------------------------------
    153 ALIGN JUMP_ALIGN
    154 HAddress_ConvertLCHStoLBA28:
     123ConvertLCHStoLBARegisterValues:
    155124    ; cylToSeek*headsPerCyl (18-bit result)
    156125    mov     ax, cx                  ; Copy Cylinder number to AX
    157     mul     WORD [di+DPT.wLHeads]   ; DX:AX = cylToSeek*headsPerCyl
     126    eMOVZX  dx, BYTE [di+DPT.bLchsHeads]
     127    mul     dx                      ; DX:AX = cylToSeek*headsPerCyl
    158128
    159129    ; +=headToSeek (18-bit result)
     
    163133
    164134    ; *=sectPerTrack (18-bit by 6-bit multiplication with 24-bit result)
    165     eMOVZX  cx, BYTE [di+DPT.bPSect]; Load Sectors per Track
     135    eMOVZX  cx, BYTE [di+DPT.bPchsSectors]  ; Load Sectors per Track
    166136    xchg    ax, dx                  ; Hiword to AX, loword to DX
    167137    mul     cl                      ; AX = hiword * Sectors per Track
     
    176146    add     ax, bx                  ; Add to loword
    177147    adc     dl, bh                  ; Add possible carry to byte2, BH=zero
     148
     149    ; Copy DX:AX to proper return registers
     150    xchg    bx, ax                  ; BL = Sector Number Register (LBA 7...0)
     151    mov     cl, bh                  ; Low Cylinder Register (LBA 15...8)
     152    mov     ch, dl                  ; High Cylinder Register (LBA 23...16)
     153    mov     bh, dh                  ; Drive and Head Register (LBA 27...24)
    178154    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HTimer.asm

    r148 r150  
    66
    77;--------------------------------------------------------------------
    8 ; HTimer_InitializeTimeoutWithTicksInCL
     8; HTimer_InitializeTimeoutWithTicksInCX
    99;   Parameters:
    10 ;       CL:     Timeout value in system timer ticks
     10;       CX:     Timeout value in system timer ticks
    1111;       DS:     Segment to RAMVARS
    1212;   Returns:
     
    1616;--------------------------------------------------------------------
    1717ALIGN JUMP_ALIGN
    18 HTimer_InitializeTimeoutWithTicksInCL:
    19     xor     ch, ch                          ; Timeout ticks now in CX
     18HTimer_InitializeTimeoutWithTicksInCX:
    2019    mov     [RAMVARS.wTimeoutCounter], cx   ; Store timeout ticks
    2120    call    ReadTimeFromBdaToCX
     
    5554HTimer_DelayMicrosecondsFromAX:
    5655%ifndef USE_AT
    57     mov     ax, 1
     56    mov     ax, 2
    5857    ; Fall to Delay_TimerTicksFromAX
    5958%else
Note: See TracChangeset for help on using the changeset viewer.