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

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

Changes to XTIDE Universal BIOS:

  • Display library now gets initialized.
  • Small optimizations.
  • Something is still broken.
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; AH: Bios function 25h
13; DL: Drive number
14; ES:BX: Ptr to buffer to receive 512-byte drive information
15; Parameters loaded by Int13h_Jump:
16; DS: RAMVARS segment
17; Returns:
18; ES:BX: Ptr to 512-byte buffer to receive drive Information
19; AH: Int 13h return status
20; CF: 0 if succesfull, 1 if error
21; IF: 1
22; Corrupts registers:
23; Flags
24;--------------------------------------------------------------------
25ALIGN JUMP_ALIGN
26AH25h_HandlerForGetDriveInformation:
27 push dx
28 push cx
29 push bx
30 push ax
31 push es
32
33 ; Wait until previously selected drive is ready
34 call FindDPT_ForDriveNumber ; DS:DI now points to DPT
35 call HDrvSel_SelectDriveAndDisableIRQ
36 jc SHORT .Return ; Return if error
37
38 ; Get drive information
39 call HPIO_NormalizeDataPointer
40 push bx
41 mov dx, [RAMVARS.wIdeBase] ; Load base port address
42 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; Load offset to IDEVARS
43 mov bl, [cs:bx+IDEVARS.bBusType]; Load bus type to BL
44 mov bh, [di+DPT.bDrvSel] ; Load drive sel byte to BH
45 pop di ; Pop buffer offset to DI
46 call AH25h_GetDriveInfo ; Get drive information
47.Return:
48 pop es
49 jmp Int13h_PopXRegsAndReturn
50
51
52;--------------------------------------------------------------------
53; Gets drive information using Identify Device command.
54;
55; AH25h_GetDriveInfo
56; Parameters:
57; BH: Drive Select byte for Drive and Head Select Register
58; BL: Bus type
59; DX: IDE Controller base port address
60; DS: Segment to RAMVARS
61; ES:DI: Ptr to buffer to receive 512 byte drive information
62; Returns:
63; AH: Int 13h return status (will be stored to BDA)
64; CF: 0 if succesfull, 1 if error
65; Corrupts registers:
66; AL, CX
67;--------------------------------------------------------------------
68ALIGN JUMP_ALIGN
69AH25h_GetDriveInfo:
70 push di
71 push dx
72 push bx
73
74 ; Select Master or Slave drive.
75 ; DO NOT WAIT UNTIL CURRENTLY SELECTED IS READY!
76 ; It makes slave drive detection impossible if master is not present.
77 mov [RAMVARS.wIdeBase], dx ; Store IDE Base port to RAMVARS
78 add dx, BYTE REG_IDE_DRVHD ; DX to Drive and Head Sel Register
79 mov al, bh ; Drive Select byte to AL
80 out dx, al ; Select Master or Slave drive
81 sub dx, BYTE REG_IDE_DRVHD ; Back to IDE Base port
82
83 ; Wait until ready to accept commands
84 xor bh, bh ; BX now contains bus type
85 mov cl, B_TIMEOUT_DRVINFO ; Load short timeout
86 cmp [RAMVARS.bDrvCnt], bh ; Detecting first drive?
87 eCMOVE cl, B_TIMEOUT_RESET ; If so, load long timeout
88 call HStatus_WaitRdy ; Wait until ready to accept commands
89 jc SHORT .Return ; Return if error
90
91 ; Output command
92 mov al, HCMD_ID_DEV ; Load Identify Device command to AL
93 out dx, al ; Output command
94 call HStatus_WaitDrqDefTime ; Wait until ready to transfer (no IRQ!)
95 jc SHORT .Return ; Return if error
96
97 ; Transfer data
98 sub dx, BYTE REGR_IDE_ST ; DX to IDE Data Reg
99 mov cx, 256 ; Transfer 256 words (single sector)
100 cld ; INSW to increment DI
101 call [cs:bx+g_rgfnPioRead] ; Read ID sector
102 call HStatus_WaitRdyDefTime ; Wait until drive ready
103
104.Return:
105 pop bx
106 pop dx
107 pop di
108 ret
Note: See TracBrowser for help on using the repository browser.