[165] | 1 | ; Project name : XTIDE Universal BIOS |
---|
| 2 | ; Description : Int 13h function AH=48h, Get Extended Drive Parameters. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[526] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[376] | 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
[526] | 12 | ; |
---|
[376] | 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | ; GNU General Public License for more details. |
---|
[526] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 18 | ; |
---|
[376] | 19 | |
---|
[165] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; Int 13h function AH=48h, Get Extended Drive Parameters. |
---|
| 25 | ; |
---|
[533] | 26 | ; It is not completely clear what this function should return as total sector count in some cases. |
---|
| 27 | ; What is certain is that: |
---|
| 28 | ; A) Phoenix Enhanced Disk Drive Specification v3.0 says that P-CHS values |
---|
| 29 | ; are never returned for drives with more than 15,482,880 sectors (16384*15*63). |
---|
| 30 | ; For those drives we can simply return total sector count from |
---|
| 31 | ; ATA ID WORDs 60 and 61 (LBA28) or WORDs 100-103 (LBA48). |
---|
| 32 | ; B) IBM PC DOS 7.1 fdisk32 displays warning message if P-CHS values multiplied |
---|
| 33 | ; together are different than total sector count. Therefore for drives with less |
---|
| 34 | ; than or equal 15,482,880 sectors we MUST NOT return total sector count from |
---|
| 35 | ; ATA ID WORDs 60 and 61. |
---|
| 36 | ; |
---|
| 37 | ; Lets take an example. 6 GB Hitachi microdrive reports following values in ATA ID: |
---|
| 38 | ; Sector count from WORDs 60 and 61 : 12,000,556 |
---|
| 39 | ; Cylinders : 11905 |
---|
| 40 | ; Heads : 16 |
---|
| 41 | ; Sectors per track : 63 |
---|
| 42 | ; |
---|
| 43 | ; When multiplying C*H*S we get : 12,000,240 |
---|
| 44 | ; So the CHS size is a little bit less than LBA size. But we must use |
---|
| 45 | ; the smaller value since C*H*S must equal total sector count! |
---|
| 46 | ; |
---|
| 47 | ; Now we get to the uncertain area where I could not find any information. |
---|
| 48 | ; Award BIOS from 1997 Pentium motherboard returns following values: |
---|
| 49 | ; AH=08h L-CHS: 745, 255, 63 (exactly the same as what we return) |
---|
| 50 | ; => Total Sector Count: 745*255*63 = 11,968,425 |
---|
| 51 | ; AH=48h P-CHS: 11873, 16, 63 |
---|
| 52 | ; AH=48h Total Sector Count: 11873* 16*63 = 11,967,984 |
---|
| 53 | ; |
---|
| 54 | ; Notice how AH=48h returns lesser total sector count than AH=8h! The only |
---|
| 55 | ; way I could think of to get 11873 cylinders is to divide AH=08h sector |
---|
| 56 | ; count with P-CHS heads and sectors: (745*255*63) / (16*63) = 11873 |
---|
| 57 | ; |
---|
| 58 | ; I have no idea what is the reasoning behind it but at least there is one |
---|
| 59 | ; BIOS that does just that. |
---|
| 60 | ; |
---|
| 61 | ; Since I don't have any better knowledge, I decided that when RESERVE_DIAGNOSTIC_CYLINDER |
---|
| 62 | ; is defined, we do what the Award BIOS does. When it is not defined, we multiply |
---|
| 63 | ; P-CHS values together and use that as total sector count. |
---|
| 64 | ; |
---|
| 65 | ; |
---|
[165] | 66 | ; AH48h_GetExtendedDriveParameters |
---|
| 67 | ; Parameters: |
---|
| 68 | ; SI: Same as in INTPACK |
---|
| 69 | ; DL: Translated Drive number |
---|
| 70 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
| 71 | ; SS:BP: Ptr to IDEPACK |
---|
| 72 | ; Parameters on INTPACK: |
---|
| 73 | ; DS:SI: Ptr to Extended Drive Information Table to fill |
---|
| 74 | ; Returns with INTPACK: |
---|
| 75 | ; AH: Int 13h return status |
---|
| 76 | ; DS:SI: Ptr to Extended Drive Information Table |
---|
[294] | 77 | ; CF: 0 if successful, 1 if error |
---|
[165] | 78 | ;-------------------------------------------------------------------- |
---|
| 79 | AH48h_HandlerForGetExtendedDriveParameters: |
---|
[227] | 80 | call AccessDPT_GetLbaSectorCountToBXDXAX |
---|
[167] | 81 | |
---|
[227] | 82 | ; Point DS:SI to Extended Drive Information Table to fill |
---|
[421] | 83 | push ds |
---|
| 84 | pop es ; DPT now in ES:DI |
---|
[169] | 85 | mov ds, [bp+IDEPACK.intpack+INTPACK.ds] |
---|
[227] | 86 | mov cx, MINIMUM_EDRIVEINFO_SIZE |
---|
| 87 | cmp [si+EDRIVE_INFO.wSize], cx |
---|
[332] | 88 | jb Prepare_ReturnFromInt13hWithInvalidFunctionError |
---|
[167] | 89 | je SHORT .SkipEddConfigurationParameters |
---|
[165] | 90 | |
---|
[167] | 91 | ; We do not support EDD Configuration Parameters so set to FFFF:FFFFh |
---|
[421] | 92 | sub cx, BYTE MINIMUM_EDRIVEINFO_SIZE+1 ; CX => FFFFh |
---|
[227] | 93 | mov [si+EDRIVE_INFO.fpEDDparams], cx |
---|
| 94 | mov [si+EDRIVE_INFO.fpEDDparams+2], cx |
---|
| 95 | mov cx, EDRIVE_INFO_size |
---|
[167] | 96 | |
---|
[227] | 97 | ; Fill Extended Drive Information Table in DS:SI |
---|
[167] | 98 | .SkipEddConfigurationParameters: |
---|
[227] | 99 | mov [si+EDRIVE_INFO.wSize], cx |
---|
[530] | 100 | mov WORD [si+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS |
---|
[165] | 101 | |
---|
[324] | 102 | ; Store total sector count |
---|
[228] | 103 | mov [si+EDRIVE_INFO.qwTotalSectors], ax |
---|
| 104 | mov [si+EDRIVE_INFO.qwTotalSectors+2], dx |
---|
| 105 | mov [si+EDRIVE_INFO.qwTotalSectors+4], bx |
---|
[530] | 106 | xor cx, cx |
---|
| 107 | mov [si+EDRIVE_INFO.qwTotalSectors+6], cx ; Always zero |
---|
[228] | 108 | mov WORD [si+EDRIVE_INFO.wSectorSize], 512 |
---|
[169] | 109 | |
---|
[530] | 110 | ; Store P-CHS. Based on phoenix specification this is returned only if |
---|
| 111 | ; total sector count is 15,482,880 or less. |
---|
| 112 | sub ax, 4001h |
---|
| 113 | sbb dx, 0ECh |
---|
| 114 | sbb bx, cx ; Zero |
---|
| 115 | jnc SHORT .ReturnWithSuccess ; More than EC4000h |
---|
| 116 | or WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID |
---|
| 117 | |
---|
[421] | 118 | eMOVZX dx, BYTE [es:di+DPT.bPchsHeads] |
---|
| 119 | mov [si+EDRIVE_INFO.dwHeads], dx |
---|
[530] | 120 | mov [si+EDRIVE_INFO.dwHeads+2], cx |
---|
[421] | 121 | |
---|
| 122 | mov dl, [es:di+DPT.bPchsSectorsPerTrack] |
---|
| 123 | mov [si+EDRIVE_INFO.dwSectorsPerTrack], dx |
---|
[530] | 124 | mov [si+EDRIVE_INFO.dwSectorsPerTrack+2], cx |
---|
[421] | 125 | |
---|
| 126 | mov dx, [es:di+DPT.wPchsCylinders] |
---|
| 127 | mov [si+EDRIVE_INFO.dwCylinders], dx |
---|
[530] | 128 | mov [si+EDRIVE_INFO.dwCylinders+2], cx |
---|
[421] | 129 | |
---|
[530] | 130 | .ReturnWithSuccess: |
---|
| 131 | xor ax, ax |
---|
[167] | 132 | .ReturnWithError: |
---|
[165] | 133 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH |
---|