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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.