source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm@ 149

Last change on this file since 149 was 148, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • INT 13h optimizations to save almost 100 bytes.
File size: 3.4 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Int 13h function AH=25h, Get Drive Information.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=25h, Get Drive Information.
9;
10; AH25h_HandlerForGetDriveInformation
11; Parameters:
12; ES: Same as in INTPACK
13; DL: Translated Drive number
14; DS:DI: Ptr to DPT (in RAMVARS segment)
15; SS:BP: Ptr to INTPACK
16; Parameters on INTPACK in SS:BP:
17; ES:BX: Ptr to buffer to receive 512-byte drive information
18; Returns with INTPACK in SS:BP:
19; AH: Int 13h return status
20; CF: 0 if succesfull, 1 if error
21;--------------------------------------------------------------------
22ALIGN JUMP_ALIGN
23AH25h_HandlerForGetDriveInformation:
24 ; Wait until previously selected drive is ready
25 call HDrvSel_SelectDriveAndDisableIRQ
26 jc SHORT .ReturnWithErrorCodeInAH ; Return if error
27
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:
39 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;--------------------------------------------------------------------
58ALIGN JUMP_ALIGN
59AH25h_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 TracBrowser for help on using the repository browser.