source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm@ 371

Last change on this file since 371 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: 6.7 KB
RevLine 
[128]1; Project name : XTIDE Universal BIOS
[3]2; Description : Int 13h function AH=0h, Disk Controller Reset.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=0h, Disk Controller Reset.
9;
[271]10; Note: We handle all AH=0h calls, even for drives handled by other
11; BIOSes!
12;
[3]13; AH0h_HandlerForDiskControllerReset
14; Parameters:
[148]15; DL: Translated Drive number (ignored so all drives are reset)
[3]16; If bit 7 is set all hard disks and floppy disks reset.
[275]17; DS:DI: Ptr to DPT (or Null if foreign drive)
[150]18; SS:BP: Ptr to IDEPACK
19; Returns with INTPACK:
[23]20; AH: Int 13h return status (from drive requested in DL)
[294]21; CF: 0 if successful, 1 if error
[3]22;--------------------------------------------------------------------
23AH0h_HandlerForDiskControllerReset:
[23]24 eMOVZX bx, dl ; Copy requested drive to BL, zero BH to assume no errors
[26]25 call ResetFloppyDrivesWithInt40h
[259]26
27%ifdef MODULE_SERIAL_FLOPPY
28;
[294]29; "Reset" emulated serial floppy drives, if any. There is nothing to actually do for this reset,
[259]30; but record the proper error return code if one of these floppy drives is the drive requested.
31;
32 call RamVars_UnpackFlopCntAndFirstToAL
33 cbw ; Clears AH (there are flop drives) or ffh (there are not)
34 ; Either AH has success code (flop drives are present)
35 ; or it doesn't matter because we won't match drive ffh
36
37 cwd ; clears DX (there are flop drives) or ffffh (there are not)
38
39 adc dl, al ; second drive (CF set) if present
[294]40 ; If no drive is present, this will result in ffh which
[259]41 ; won't match a drive
42 call BackupErrorCodeFromTheRequestedDriveToBH
43 mov dl, al ; We may end up doing the first drive twice (if there is
44 call BackupErrorCodeFromTheRequestedDriveToBH ; only one drive), but doing it again is not harmful.
45%endif
46
47 test bl, bl ; If we were called with a floppy disk, then we are done,
48 jns SHORT .SkipHardDiskReset ; don't do hard disks.
[294]49
[26]50 call ResetForeignHardDisks
[264]51
[294]52 ; Resetting our hard disks will modify dl and bl to be idevars offset based instead of drive number based,
[275]53 ; such that this call must be the last in the list of reset routines called.
54 ;
[282]55 ; This needs to happen after ResetForeignHardDisks, as that call may have set the error code for 80h,
56 ; and we need to override that value if we are xlate'd into 80h with one of our drives.
57 ;
[294]58 call ResetHardDisksHandledByOurBIOS
[264]59
[26]60.SkipHardDiskReset:
[148]61 mov ah, bh
62 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[3]63
64
65;--------------------------------------------------------------------
[26]66; ResetFloppyDrivesWithInt40h
[3]67; Parameters:
[23]68; BL: Requested drive (DL when entering AH=00h)
69; Returns:
70; BH: Error code from requested drive (if available)
71; Corrupts registers:
[27]72; AX, DL, DI
[128]73;--------------------------------------------------------------------
[26]74ResetFloppyDrivesWithInt40h:
[271]75 call GetDriveNumberForForeignHardDiskHandlerToDL
[27]76 and dl, 7Fh ; Clear hard disk bit
[26]77 xor ah, ah ; Disk Controller Reset
[148]78 int BIOS_DISKETTE_INTERRUPT_40h
[26]79 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH
[23]80
81
82;--------------------------------------------------------------------
[26]83; ResetForeignHardDisks
[23]84; Parameters:
85; BL: Requested drive (DL when entering AH=00h)
[3]86; DS: RAMVARS segment
87; Returns:
[23]88; BH: Error code from requested drive (if available)
[3]89; Corrupts registers:
[27]90; AX, DL, DI
[128]91;--------------------------------------------------------------------
[26]92ResetForeignHardDisks:
[271]93 call GetDriveNumberForForeignHardDiskHandlerToDL
[27]94 xor ah, ah ; Disk Controller Reset
[32]95 call Int13h_CallPreviousInt13hHandler
[258]96;;; fall-through to BackupErrorCodeFromTheRequestedDriveToBH
[23]97
[26]98
[3]99;--------------------------------------------------------------------
[258]100; BackupErrorCodeFromTheRequestedDriveToBH
101; Parameters:
102; AH: Error code from the last resetted drive
103; DL: Drive last resetted
104; BL: Requested drive (DL when entering AH=00h)
105; Returns:
106; BH: Backuped error code
107; Corrupts registers:
108; Nothing
109;--------------------------------------------------------------------
110BackupErrorCodeFromTheRequestedDriveToBH:
111 cmp dl, bl ; Requested drive?
112 eCMOVE bh, ah
113 ret
114
[271]115
[258]116;--------------------------------------------------------------------
[271]117; GetDriveNumberForForeignHardDiskHandlerToDL
[27]118; Parameters:
119; BL: Requested drive (DL when entering AH=00h)
120; DS: RAMVARS segment
121; Returns:
[275]122; DS:DI: Ptr to DPT if our drive (or Null if foreign drive)
[27]123; DL: BL if foreign drive
124; 80h if our drive
[128]125;--------------------------------------------------------------------
[271]126GetDriveNumberForForeignHardDiskHandlerToDL:
[27]127 mov dl, bl
[275]128 test di, di
129 jz SHORT .Return
[271]130 mov dl, 80h ; First possible Hard Disk should be safe value
[275]131.Return:
[27]132 ret
133
[275]134AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization equ ResetHardDisksHandledByOurBIOS.ErrorCodeNotUsed
[27]135
136;--------------------------------------------------------------------
[271]137; ResetHardDisksHandledByOurBIOS
138; Parameters:
139; DS:DI: Ptr to DPT for requested drive
[294]140; If DPT pointer is not available, or error result in BH won't be used anyway,
[282]141; enter through .ErrorCodeNotUsed.
[271]142; SS:BP: Ptr to IDEPACK
143; Returns:
[23]144; BH: Error code from requested drive (if available)
145; Corrupts registers:
[275]146; AX, BX, CX, DX, SI, DI
[23]147;--------------------------------------------------------------------
[271]148ResetHardDisksHandledByOurBIOS:
[294]149 xor bl, bl ; Assume Null IdevarsOffset for now, assuming foreign drive
[282]150 test di, di
151 jz .ErrorCodeNotUsed
[264]152 mov bl, [di+DPT.bIdevarsOffset] ; replace drive number with Idevars pointer for cmp with dl
[294]153
154.ErrorCodeNotUsed: ; BH will be garbage on exit if this entry point is used,
[275]155 ; but reset of all drives will still happen
156
[264]157 mov dl, ROMVARS.ideVars0 ; starting Idevars offset
158
[316]159 ; Get count of ALL Idevars structures, not just the ones that are configured. This may seem odd,
160 ; but it catches the .ideVarsSerialAuto structure, which would not be scanned if the count from
161 ; RamVars_GetIdeControllerCountToCX was used. Unused controllers won't make a difference, since no DPT
162 ; will point to them. Performance isn't an issue, as this is a reset operation.
163 ;
164 mov cx, (ROMVARS.ideVarsEnd - ROMVARS.ideVarsBegin) / IDEVARS_size
165
[262]166.loop:
[271]167 call FindDPT_ForIdevarsOffsetInDL ; look for the first drive on this controller, if any
[262]168 jc .notFound
[264]169
[262]170 call AHDh_ResetDrive ; reset master and slave on that controller
[264]171 call BackupErrorCodeFromTheRequestedDriveToBH ; save error code if same controller as drive from entry
172
[262]173.notFound:
[264]174 add dl, IDEVARS_size ; move Idevars pointer forward
175 loop .loop
176
177.done:
[259]178 ret
Note: See TracBrowser for help on using the repository browser.