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

Last change on this file since 369 was 369, checked in by gregli@…, 12 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

File size: 4.4 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
[294]17;       CF:     0 if successful, 1 if error
[3]18;--------------------------------------------------------------------
19AHDh_HandlerForResetHardDisk:
[84]20%ifndef USE_186
[3]21    call    AHDh_ResetDrive
[148]22    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[84]23%else
[148]24    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[162]25    ; Fall to AHDh_ResetDrive
[84]26%endif
[3]27
28
29;--------------------------------------------------------------------
30; Resets hard disk.
31;
32; AHDh_ResetDrive
33;   Parameters:
[271]34;       DS:DI:  Ptr to DPT
[150]35;       SS:BP:  Ptr to IDEPACK
[3]36;   Returns:
37;       AH:     Int 13h return status
[294]38;       CF:     0 if successful, 1 if error
[3]39;   Corrupts registers:
[271]40;       AL, SI
[3]41;--------------------------------------------------------------------
42AHDh_ResetDrive:
[26]43    push    dx
[271]44    push    cx
[26]45    push    bx
[262]46    push    di
[26]47
[33]48    call    Interrupts_UnmaskInterruptControllerForDriveInDSDI
[150]49    call    Device_ResetMasterAndSlaveController
[262]50    ;jc     SHORT .ReturnError                  ; CF would be set if slave drive present without master
51                                                ; (error register has special values after reset)
[3]52
53    ; Initialize Master and Slave drives
[363]54    eMOVZX  ax, BYTE [di+DPT.bIdevarsOffset]    ; (AL) pointer to controller we are looking to reset
[294]55                                                ; (AH) initialize error code, assume success
56
[363]57    mov     si, IterateAndResetDrives           ; Callback function for FindDPT_IterateAllDPTs
[271]58    call    FindDPT_IterateAllDPTs
[26]59
[262]60    shr     ah, 1                               ; Move error code and CF into proper position
61
62    pop     di
[26]63    pop     bx
[271]64    pop     cx
[26]65    pop     dx
[3]66    ret
67
68;--------------------------------------------------------------------
[262]69; IterateAndResetDrives: Iteration routine for use with IterateAllDPTs.
70;
[294]71; When a drive on the controller is found, it is reset, and the error code
[262]72; merged into overall error code for this controller.  Master will be reset
73; first.  Note that the iteration will go until the end of the DPT list.
[363]74;
75;   Parameters:
76;       AL:     Offset to IDEVARS for drives to initialize
77;       AH:     Error status from previous initialization
78;       DS:DI:  Ptr to DPT to examine
79;   Returns:
80;       AH:     Error status from initialization
81;       CF:     Set to iterate all DPTs
82;   Corrupts registers:
83;       AL, BX, DX
[3]84;--------------------------------------------------------------------
[262]85IterateAndResetDrives:
86    cmp     al, [di+DPT.bIdevarsOffset]         ; The right controller?
[271]87    jne     .done
[262]88    push    ax
[363]89    push    cx
[262]90    call    AH9h_InitializeDriveForUse          ; Reset Master and Slave (Master will come first in DPT list)
[363]91
92%ifdef MODULE_ADVANCED_ATA
93    jc      SHORT .SkipControllerInitSinceError
94    call    InitializeAdvancedIdeControllers    ; Done after drive init so drives are first set to advanced PIO mode, then the controller
95.SkipControllerInitSinceError:
96%endif
97
98    pop     cx
[294]99    pop     ax
[282]100    jnc     .done
[262]101    or      ah, (RET_HD_RESETFAIL << 1) | 1     ; OR in Reset Failed error code and CF, will SHR into position later
102.done:
[271]103    stc                                         ; From IterateAllDPTs perspective, the DPT is never found (continue iteration)
[3]104    ret
[363]105
106
107%ifdef MODULE_ADVANCED_ATA
108;--------------------------------------------------------------------
109; Here we initialize the more advanced controllers (VLB and PCI)
110; to get better performance for systems with 32-bit bus.
111;
112; This step is optional since the controllers use slowest possible
113; settings by default if they are not initialized.
114;
115; InitializeAdvancedIdeController
116;   Parameters:
117;       DS:DI:  Ptr to DPT
118;   Returns:
119;       CF:     Cleared if success or no controller to initialize
120;               Set if error
121;   Corrupts registers:
122;       AX, BX, CX, DX
123;--------------------------------------------------------------------
124InitializeAdvancedIdeControllers:
125    ; We want to initialize the advanced controller only after both
126    ; Master and Slave drive are initialized to correct PIO mode.
127    ; We check if next DPT is for the same IDE controller. If it is,
128    ; we skip the initialization.
129    mov     al, [di+DPT.bIdevarsOffset]
130    cmp     al, [di++LARGEST_DPT_SIZE+DPT.bIdevarsOffset]
131    je      SHORT .SkipInitializationUntilNextDrive ; CF cleared
132
133    jmp     AdvAtaInit_InitializeControllerForDPTinDSDI
134.SkipInitializationUntilNextDrive:
135    clc
136    ret
137
138%endif  ; MODULE_ADVANCED_ATA
Note: See TracBrowser for help on using the repository browser.