source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm @ 170

Last change on this file since 170 was 170, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

  • Minor size optimizations
  • Commented away some ALIGN JUMP_ALIGN directives in the Int13h handler (they are either in init procedures, procedures that are rarely called or are unnecessary due to conditional assembly)
  • Fixed what appears to be a typo in EBIOS.inc
File size: 2.9 KB
RevLine 
[88]1; Project name  :   XTIDE Universal BIOS
[3]2; Description   :   Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
9;
10; AHDh_HandlerForResetHardDisk
11;   Parameters:
[148]12;       DL:     Translated Drive number
13;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]14;       SS:BP:  Ptr to IDEPACK
15;   Returns with INTPACK:
[3]16;       AH:     Int 13h return status
17;       CF:     0 if succesfull, 1 if error
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20AHDh_HandlerForResetHardDisk:
[84]21%ifndef USE_186
[3]22    call    AHDh_ResetDrive
[148]23    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[84]24%else
[148]25    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[162]26    ; Fall to AHDh_ResetDrive
[84]27%endif
[3]28
29
30;--------------------------------------------------------------------
31; Resets hard disk.
32;
33; AHDh_ResetDrive
34;   Parameters:
35;       DL:     Drive number
36;       DS:     RAMVARS segment
[150]37;       SS:BP:  Ptr to IDEPACK
[3]38;   Returns:
39;       AH:     Int 13h return status
40;       CF:     0 if succesfull, 1 if error
41;   Corrupts registers:
[150]42;       AL, CX, SI, DI
[3]43;--------------------------------------------------------------------
[170]44;ALIGN JUMP_ALIGN
[3]45AHDh_ResetDrive:
[26]46    push    dx
47    push    bx
48
[3]49    call    FindDPT_ForDriveNumber      ; DS:DI now points to DPT
[33]50    call    Interrupts_UnmaskInterruptControllerForDriveInDSDI
[150]51    call    Device_ResetMasterAndSlaveController
[3]52    ;jc     SHORT .ReturnError          ; CF would be set if slave drive present without master
53                                        ; (error register has special values after reset)
54
55    ; Initialize Master and Slave drives
[150]56    eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]
57    mov     dx, [cs:bx+IDEVARS.wPort]
58    call    InitializeMasterAndSlaveDriveFromPortInDX
[26]59
60    pop     bx
61    pop     dx
[3]62    ret
63
64
65;--------------------------------------------------------------------
[150]66; InitializeMasterAndSlaveDriveFromPortInDX
[3]67;   Parameters:
68;       DX:     IDE Base Port address
[150]69;       SS:BP:  Ptr to IDEPACK
[3]70;   Returns:
[26]71;       AH:     Error code
[3]72;       CF:     0 if initialization succesfull
73;               1 if any error
74;   Corrupts registers:
[150]75;       AL, BX, CX, DX, SI, DI
[3]76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
[150]78InitializeMasterAndSlaveDriveFromPortInDX:
[3]79    push    dx                          ; Store base port address
80    xor     cx, cx                      ; Assume no errors
[150]81    call    FindDPT_ToDSDIForIdeMasterAtPortDX
[3]82    jnc     SHORT .InitializeSlave      ; Master drive not present
83    call    AH9h_InitializeDriveForUse
84    mov     cl, ah                      ; Copy error code to CL
85.InitializeSlave:
86    pop     dx                          ; Restore base port address
[150]87    call    FindDPT_ToDSDIForIdeSlaveAtPortDX
[3]88    jnc     SHORT .CombineErrors        ; Slave drive not present
89    call    AH9h_InitializeDriveForUse
90    mov     ch, ah                      ; Copy error code to CH
91.CombineErrors:
92    or      cl, ch                      ; OR error codes, clear CF
[116]93    jz      SHORT .Return
[26]94    mov     ah, RET_HD_RESETFAIL        ; Load Reset Failed error code
[3]95    stc
[116]96.Return:
[3]97    ret
Note: See TracBrowser for help on using the repository browser.