Changeset 100 in xtideuniversalbios
- Timestamp:
- Jan 31, 2011, 11:43:26 AM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm
r88 r100 1 ; File name : BootInfo.asm2 1 ; Project name : XTIDE Universal BIOS 3 2 ; Description : Functions for generating and accessing drive … … 22 21 ; AX, BX, CX, DX 23 22 ;-------------------------------------------------------------------- 24 ALIGN JUMP_ALIGN25 23 BootInfo_CreateForHardDisk: 26 24 call BootInfo_GetOffsetToBX ; ES:BX now points to new BOOTNFO 27 call BootInfo_StoreSectorCount 28 jmp SHORT BootInfo_StoreDriveName 25 ; Fall to .StoreSectorCount 26 27 ;-------------------------------------------------------------------- 28 ; .StoreSectorCount 29 ; Parameters: 30 ; ES:BX: Ptr to BOOTNFO 31 ; ES:SI: Ptr to 512-byte ATA information read from the drive 32 ; DS:DI: Ptr to Disk Parameter Table 33 ; Returns: 34 ; Nothing 35 ; Corrupts registers: 36 ; AX, CX, DX 37 ;-------------------------------------------------------------------- 38 .StoreSectorCount: 39 push bx 40 call AtaID_GetTotalSectorCount ; Get to BX:DX:AX 41 mov cx, bx ; Now in CX:DX:AX 42 pop bx 43 mov [es:bx+BOOTNFO.twSectCnt], ax 44 mov [es:bx+BOOTNFO.twSectCnt+2], dx 45 mov [es:bx+BOOTNFO.twSectCnt+4], cx 46 ; Fall to .StoreDriveName 47 48 ;-------------------------------------------------------------------- 49 ; .StoreDriveName 50 ; Parameters: 51 ; ES:BX: Ptr to BOOTNFO 52 ; ES:SI: Ptr to 512-byte ATA information read from the drive 53 ; DS:DI: Ptr to Disk Parameter Table 54 ; Returns: 55 ; CF: Cleared if variables stored succesfully 56 ; Set if any error 57 ; Corrupts registers: 58 ; AX, CX 59 ;-------------------------------------------------------------------- 60 .StoreDriveName: 61 push ds 62 push si 63 push di 64 65 push es 66 pop ds 67 add si, BYTE ATA1.strModel ; DS:SI now points drive name 68 lea di, [bx+BOOTNFO.szDrvName] ; ES:DI now points to name destination 69 mov cx, LEN_BOOTNFO_DRV 70 call Memory_CopyCXbytesFromDSSItoESDI 71 xor ax, ax 72 stosb ; Terminate with NULL 73 74 pop di 75 pop si 76 pop ds 77 clc 78 ret 79 80 81 ;-------------------------------------------------------------------- 82 ; Finds BOOTNFO for drive and returns total sector count. 83 ; 84 ; BootInfo_GetTotalSectorCount 85 ; Parameters: 86 ; DL: Drive number 87 ; DS: RAMVARS segment 88 ; Returns: 89 ; BX:DX:AX: 48-bit sector count 90 ; Corrupts registers: 91 ; Nothing 92 ;-------------------------------------------------------------------- 93 ALIGN JUMP_ALIGN 94 BootInfo_GetTotalSectorCount: 95 push ds 96 call BootInfo_GetOffsetToBX 97 LOAD_BDA_SEGMENT_TO ds, ax 98 mov ax, [bx+BOOTNFO.twSectCnt] 99 mov dx, [bx+BOOTNFO.twSectCnt+2] 100 mov bx, [bx+BOOTNFO.twSectCnt+4] 101 pop ds 102 ret 29 103 30 104 … … 50 124 xchg bx, ax ; Copy result to BX 51 125 ret 52 53 54 ;--------------------------------------------------------------------55 ; Stores total sector count to BOOTNFO.56 ;57 ; BootInfo_StoreSectorCount58 ; Parameters:59 ; ES:BX: Ptr to BOOTNFO60 ; ES:SI: Ptr to 512-byte ATA information read from the drive61 ; DS:DI: Ptr to Disk Parameter Table62 ; Returns:63 ; CF: Cleared if variables stored succesfully64 ; Set if any error65 ; Corrupts registers:66 ; AX, CX, DX67 ;--------------------------------------------------------------------68 ALIGN JUMP_ALIGN69 BootInfo_StoreSectorCount:70 push bx71 call AtaID_GetTotalSectorCount ; Get to BX:DX:AX72 mov cx, bx ; Now in CX:DX:AX73 pop bx74 mov [es:bx+BOOTNFO.twSectCnt], ax75 mov [es:bx+BOOTNFO.twSectCnt+2], dx76 mov [es:bx+BOOTNFO.twSectCnt+4], cx77 clc78 ret79 80 81 ;--------------------------------------------------------------------82 ; Stores drive name to BOOTNFO.83 ;84 ; BootInfo_StoreDriveName85 ; Parameters:86 ; ES:BX: Ptr to BOOTNFO87 ; ES:SI: Ptr to 512-byte ATA information read from the drive88 ; DS:DI: Ptr to Disk Parameter Table89 ; Returns:90 ; CF: Cleared if variables stored succesfully91 ; Set if any error92 ; Corrupts registers:93 ; AX, CX94 ;--------------------------------------------------------------------95 ALIGN JUMP_ALIGN96 BootInfo_StoreDriveName:97 push ds98 push si99 push di100 101 ; DS:SI to ATA source string102 push es103 pop ds104 add si, BYTE ATA1.strModel105 106 ; ES:DI to BOOTNFO destination string107 lea di, [bx+BOOTNFO.szDrvName]108 109 ; Read string110 mov cx, LEN_BOOTNFO_DRV>>1111 call BootInfo_StoreAtaString112 pop di113 pop si114 pop ds115 clc116 ret117 118 ;--------------------------------------------------------------------119 ; Stores ATA string.120 ; Byte ordering will be corrected and string will be STOP terminated.121 ;122 ; BootInfo_StoreAtaString123 ; Parameters:124 ; CX: Maximum number of WORDs to copy (without STOP)125 ; DS:SI: Ptr to ATA string126 ; ES:DI: Ptr to destination string127 ; Returns:128 ; Nothing129 ; Corrupts registers:130 ; AX, CX, SI, DI131 ;--------------------------------------------------------------------132 ALIGN JUMP_ALIGN133 BootInfo_StoreAtaString:134 lodsw ; Load WORD from DS:SI to AX135 xchg al, ah ; Change byte order136 call BootInfo_StoreAtaChar137 jc SHORT .Return ; Return if invalid character138 mov al, ah ; Write next char139 call BootInfo_StoreAtaChar140 jc SHORT .Return ; Return if invalid character141 loop BootInfo_StoreAtaString ; Loop while words left142 .Return:143 xor ax, ax ; Terminate string with NULL144 stosb145 ret146 147 ;--------------------------------------------------------------------148 ; Stores ATA character.149 ;150 ; BootInfo_StoreAtaChar151 ; Parameters:152 ; AL: Character to store153 ; ES:DI: Ptr to destination character154 ; Returns:155 ; DI: Incremented to next character156 ; CF: Set if non writable ASCII character157 ; Corrupts registers:158 ; Nothing159 ;--------------------------------------------------------------------160 ALIGN JUMP_ALIGN161 BootInfo_StoreAtaChar:162 cmp al, 20h ; First allowed ASCII char?163 jb SHORT .SkipStoring ; If below, end string164 cmp al, 7Eh ; Last allowed ASCII char?165 ja SHORT .SkipStoring ; If above, end string166 stosb ; Store character167 clc ; Clear CF to continue with next char168 ret169 .SkipStoring:170 stc171 ret172 173 174 ;--------------------------------------------------------------------175 ; Finds BOOTNFO for drive and return total sector count.176 ;177 ; BootInfo_GetTotalSectorCount178 ; Parameters:179 ; DL: Drive number180 ; DS: RAMVARS segment181 ; Returns:182 ; BX:DX:AX: 48-bit sector count183 ; Corrupts registers:184 ; Nothing185 ;--------------------------------------------------------------------186 ALIGN JUMP_ALIGN187 BootInfo_GetTotalSectorCount:188 push ds189 call BootInfo_GetOffsetToBX190 LOAD_BDA_SEGMENT_TO ds, ax191 mov ax, [bx+BOOTNFO.twSectCnt]192 mov dx, [bx+BOOTNFO.twSectCnt+2]193 mov bx, [bx+BOOTNFO.twSectCnt+4]194 pop ds195 ret
Note:
See TracChangeset
for help on using the changeset viewer.