Changeset 150 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
- Timestamp:
- Apr 29, 2011, 7:04:13 PM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm
r3 r150 1 ; File name : FindDPT.asm 2 ; Project name : IDE BIOS 3 ; Created date : 14.3.2010 4 ; Last update : 12.4.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for finding Disk Parameter Table. 7 3 … … 12 8 ; Finds pointer to first unused Disk Parameter Table. 13 9 ; 14 ; FindDPT_ForNewDrive 10 ; FindDPT_ForNewDriveToDSDI 15 11 ; Parameters: 16 12 ; DS: RAMVARS segment … … 18 14 ; DS:DI: Ptr to first unused DPT 19 15 ; Corrupts registers: 20 ; Nothing16 ; DL 21 17 ;-------------------------------------------------------------------- 22 18 ALIGN JUMP_ALIGN 23 FindDPT_ForNewDrive: 24 push si 25 mov si, FindDPT_ReturnWrongDPT 26 jmp SHORT FindDPT_StartIterationAndReturnAfterDone 27 28 29 ;-------------------------------------------------------------------- 30 ; Finds Disk Parameter Table for 31 ; Master or Slave drive at wanted port. 32 ; 33 ; FindDPT_ForIdeSlaveAtPort 34 ; FindDPT_ForIdeMasterAtPort 35 ; Parameters: 36 ; DX: IDE Base Port address 37 ; DS: RAMVARS segment 38 ; Returns: 39 ; DL: Drive number (if DPT found) 40 ; DS:DI: Ptr to DPT 41 ; CF: Set if wanted DPT found 42 ; Cleared if DPT not found 43 ; Corrupts registers: 44 ; Nothing 45 ;-------------------------------------------------------------------- 46 ALIGN JUMP_ALIGN 47 FindDPT_ForIdeSlaveAtPort: 48 push si 49 mov si, FindDPT_IterateToSlaveAtPortCallback 50 jmp SHORT FindDPT_StartIterationAndReturnAfterDone 51 52 ALIGN JUMP_ALIGN 53 FindDPT_ForIdeMasterAtPort: 54 push si 55 mov si, FindDPT_IterateToMasterAtPortCallback 56 jmp SHORT FindDPT_StartIterationAndReturnAfterDone 57 58 ;-------------------------------------------------------------------- 59 ; Iteration callback for finding DPT using 60 ; IDE base port for Master or Slave drive. 61 ; 62 ; FindDPT_IterateToSlaveAtPortCallback 63 ; FindDPT_IterateToMasterAtPortCallback 64 ; Parameters: 65 ; DX: IDE Base Port address 66 ; DS:DI: Ptr to DPT to examine 67 ; Returns: 68 ; DL: Drive number if correct DPT 69 ; CF: Set if wanted DPT found 70 ; Cleared if wrong DPT 71 ; Corrupts registers: 72 ; Nothing 73 ;-------------------------------------------------------------------- 74 ALIGN JUMP_ALIGN 75 FindDPT_IterateToSlaveAtPortCallback: 76 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV 77 jnz SHORT FindDPT_IterateToMasterOrSlaveAtPortCallback 78 jmp SHORT FindDPT_ReturnWrongDPT ; Return if master drive 79 80 ALIGN JUMP_ALIGN 81 FindDPT_IterateToMasterAtPortCallback: 82 test BYTE [di+DPT.bDrvSel], FLG_IDE_DRVHD_DRV 83 jnz SHORT FindDPT_ReturnWrongDPT ; Return if slave drive 84 85 ; If BIOS partitioned, ignore all but first partition 86 ALIGN JUMP_ALIGN 87 FindDPT_IterateToMasterOrSlaveAtPortCallback: 88 test BYTE [di+DPT.bFlags], FLG_DPT_PARTITION 89 jz SHORT .CompareBasePortAddress 90 test BYTE [di+DPT.bFlags], FLG_DPT_FIRSTPART 91 jz SHORT FindDPT_ReturnWrongDPT 92 ALIGN JUMP_ALIGN 93 .CompareBasePortAddress: 94 push bx 95 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; CS:BX now points to IDEVARS 96 cmp dx, [cs:bx+IDEVARS.wPort] ; Wanted port? 97 pop bx 98 jne SHORT FindDPT_ReturnWrongDPT 99 mov dl, [di+DPT.bDrvNum] ; Load drive number 100 stc ; Set CF since wanted DPT 101 ret 19 FindDPT_ForNewDriveToDSDI: 20 mov dl, [RAMVARS.bFirstDrv] 21 add dl, [RAMVARS.bDrvCnt] 22 ; Fall to FindDPT_ForDriveNumber 102 23 103 24 … … 112 33 ; Returns: 113 34 ; DS:DI: Ptr to DPT 114 ; CF: Set if wanted DPT found115 ; Cleared if DPT not found116 35 ; Corrupts registers: 117 36 ; Nothing … … 119 38 ALIGN JUMP_ALIGN 120 39 FindDPT_ForDriveNumber: 121 push si 122 mov si, FindDPT_IterateToDriveNumberCallback 123 FindDPT_StartIterationAndReturnAfterDone: 124 call FindDPT_IterateAllDPTs 125 pop si 40 push dx 41 push ax 42 43 mov al, LARGEST_DPT_SIZE 44 sub dl, [RAMVARS.bFirstDrv] 45 mul dl 46 add ax, BYTE RAMVARS_size 47 xchg di, ax 48 49 pop ax 50 pop dx 126 51 ret 127 52 53 128 54 ;-------------------------------------------------------------------- 129 ; Iteration callback for finding DPT for drive number. 55 ; Finds Disk Parameter Table for 56 ; Master or Slave drive at wanted port. 130 57 ; 131 ; FindDPT_IterateToDriveNumberCallback 58 ; FindDPT_ToDSDIForIdeMasterAtPortDX 59 ; FindDPT_ToDSDIForIdeSlaveAtPortDX 132 60 ; Parameters: 133 ; DL: Drive number to search for 61 ; DX: IDE Base Port address 62 ; DS: RAMVARS segment 63 ; Returns: 64 ; DL: Drive number (if DPT found) 65 ; DS:DI: Ptr to DPT 66 ; CF: Set if wanted DPT found 67 ; Cleared if DPT not found 68 ; Corrupts registers: 69 ; SI 70 ;-------------------------------------------------------------------- 71 ALIGN JUMP_ALIGN 72 FindDPT_ToDSDIForIdeMasterAtPortDX: 73 mov si, FindDPT_IterateToMasterAtPortCallback 74 jmp SHORT IterateAllDPTs 75 76 ALIGN JUMP_ALIGN 77 FindDPT_ToDSDIForIdeSlaveAtPortDX: 78 mov si, FindDPT_IterateToSlaveAtPortCallback 79 jmp SHORT IterateAllDPTs 80 81 ;-------------------------------------------------------------------- 82 ; Iteration callback for finding DPT using 83 ; IDE base port for Master or Slave drive. 84 ; 85 ; FindDPT_IterateToSlaveAtPortCallback 86 ; FindDPT_IterateToMasterAtPortCallback 87 ; Parameters: 88 ; CH: Drive number 89 ; DX: IDE Base Port address 134 90 ; DS:DI: Ptr to DPT to examine 135 91 ; Returns: 92 ; DL: Drive number if correct DPT 136 93 ; CF: Set if wanted DPT found 137 94 ; Cleared if wrong DPT … … 140 97 ;-------------------------------------------------------------------- 141 98 ALIGN JUMP_ALIGN 142 FindDPT_IterateToDriveNumberCallback: 143 cmp dl, [di+DPT.bDrvNum] ; Wanted DPT found? 144 je SHORT FindDPT_RightDriveNumber ; If so, return 145 FindDPT_ReturnWrongDPT: 146 clc ; Clear CF since wrong DPT 99 FindDPT_IterateToSlaveAtPortCallback: 100 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE ; Clears CF 101 jnz SHORT CompareBasePortAddress 102 ret ; Wrong DPT 103 104 ALIGN JUMP_ALIGN 105 FindDPT_IterateToMasterAtPortCallback: 106 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE 107 jnz SHORT ReturnWrongDPT ; Return if slave drive 108 109 CompareBasePortAddress: 110 push bx 111 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS 112 cmp dx, [cs:bx+IDEVARS.wPort] ; Wanted port? 113 pop bx 114 jne SHORT ReturnWrongDPT 115 mov dl, ch ; Return drive number in DL 116 stc ; Set CF since wanted DPT 147 117 ret 148 ALIGN JUMP_ALIGN 149 FindDPT_RightDriveNumber: 150 push bx 151 eMOVZX bx, BYTE [di+DPT.bIdeOff] ; CS:BX now points to IDEVARS 152 mov bx, [cs:bx+IDEVARS.wPort] ; Load IDE Base Port address... 153 mov [RAMVARS.wIdeBase], bx ; ...and store it to RAMVARS 154 pop bx 155 stc 118 ReturnWrongDPT: 119 clc ; Clear CF since wrong DPT 156 120 ret 157 121 … … 160 124 ; Iterates all Disk Parameter Tables. 161 125 ; 162 ; FindDPT_IterateAllDPTs126 ; IterateAllDPTs 163 127 ; Parameters: 164 128 ; BX,DX: Parameters to callback function … … 170 134 ; Cleared if DPT not found 171 135 ; Corrupts registers: 172 ; Nothing ,unless corrupted by callback function136 ; Nothing unless corrupted by callback function 173 137 ;-------------------------------------------------------------------- 174 138 ALIGN JUMP_ALIGN 175 FindDPT_IterateAllDPTs: 176 push ax 139 IterateAllDPTs: 177 140 push cx 141 mov cx, [RAMVARS.wDrvCntAndFirst] 142 jcxz .AllDptsIterated ; Return if no drives 178 143 call FindDPT_PointToFirstDPT ; Point DS:DI to first DPT 179 eMOVZX cx, BYTE [RAMVARS.bDrvCnt] ; Load number of drives180 xor ax, ax ; Zero AX for DPT size and clear CF181 jcxz .Return ; Return if no drives182 144 ALIGN JUMP_ALIGN 183 145 .LoopWhileDPTsLeft: 184 146 call si ; Is wanted DPT? 185 jc SHORT .Return ; If so, return 186 mov al, [di+DPT.bSize] ; Load DPT size to AX 187 add di, ax ; Point to next DPT 188 loop .LoopWhileDPTsLeft ; Check next DPT 147 jc SHORT .AllDptsIterated ; If so, return 148 inc ch ; Increment drive number 149 add di, BYTE LARGEST_DPT_SIZE ; Point to next DPT 150 dec cl ; Decrement drives left 151 jnz SHORT .LoopWhileDPTsLeft 189 152 clc ; Clear CF since DPT not found 190 153 ALIGN JUMP_ALIGN 191 . Return:154 .AllDptsIterated: 192 155 pop cx 193 pop ax194 156 ret 195 157 … … 209 171 FindDPT_PointToFirstDPT: 210 172 mov di, RAMVARS_size 211 test BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE212 jz SHORT .Return ; RAMVARS used (top of interrupt vectors)213 add di, BYTE FULLRAMVARS_size-RAMVARS_size ; FULLRAMVARS used (top of base memory)214 ALIGN JUMP_ALIGN215 .Return:216 173 ret
Note:
See TracChangeset
for help on using the changeset viewer.