[88] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 2 | ; Description : Functions for generating and accessing drive
|
---|
| 3 | ; information to be displayed on boot menu.
|
---|
| 4 |
|
---|
| 5 | ; Section containing code
|
---|
| 6 | SECTION .text
|
---|
| 7 |
|
---|
| 8 | ;--------------------------------------------------------------------
|
---|
[254] | 9 | ; Creates new BOOTMENUINFO struct for detected hard disk.
|
---|
[3] | 10 | ;
|
---|
[254] | 11 | ; BootMenuInfo_CreateForHardDisk
|
---|
[3] | 12 | ; Parameters:
|
---|
| 13 | ; DL: Drive number
|
---|
| 14 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
| 15 | ; ES:SI: Ptr to 512-byte ATA information read from the drive
|
---|
| 16 | ; Returns:
|
---|
[254] | 17 | ; ES:BX: Ptr to BOOTMENUINFO (if successful)
|
---|
[3] | 18 | ; Corrupts registers:
|
---|
[254] | 19 | ; AX, BX, CX, DX, DI
|
---|
[3] | 20 | ;--------------------------------------------------------------------
|
---|
[254] | 21 | BootMenuInfo_CreateForHardDisk:
|
---|
| 22 | call BootMenuInfo_ConvertDPTtoBX ; ES:BX now points to new BOOTMENUINFO
|
---|
| 23 | push bx ; Preserve for return
|
---|
[3] | 24 |
|
---|
[254] | 25 | mov di, bx ; Starting pointer at beginning of structure
|
---|
[3] | 26 |
|
---|
[254] | 27 | ; Store Drive Name
|
---|
| 28 | push ds ; Preserve RAMVARS
|
---|
| 29 | push si
|
---|
[3] | 30 |
|
---|
[254] | 31 | push es ; ES copied to DS
|
---|
[3] | 32 | pop ds
|
---|
[241] | 33 |
|
---|
[254] | 34 | add si, BYTE ATA1.strModel ; DS:SI now points drive name
|
---|
| 35 | lea di, [bx+BOOTMENUINFO.szDrvName] ; ES:DI now points to name destination
|
---|
| 36 | mov cx, MAX_HARD_DISK_NAME_LENGTH / 2 ; Max number of WORDs allowed
|
---|
[121] | 37 | .CopyNextWord:
|
---|
| 38 | lodsw
|
---|
[254] | 39 | xchg al, ah ; Change endianness
|
---|
[121] | 40 | stosw
|
---|
| 41 | loop .CopyNextWord
|
---|
[254] | 42 | xor ax, ax ; Zero AX and clear CF
|
---|
| 43 | stosw ; Terminate with NULL
|
---|
[3] | 44 |
|
---|
| 45 | pop si
|
---|
| 46 | pop ds
|
---|
[241] | 47 | pop bx
|
---|
| 48 |
|
---|
[3] | 49 | ret
|
---|
| 50 |
|
---|
[252] | 51 |
|
---|
[3] | 52 | ;--------------------------------------------------------------------
|
---|
[254] | 53 | ; BootMenuInfo_GetTotalSectorCount
|
---|
[3] | 54 | ; Parameters:
|
---|
[241] | 55 | ; DS:DI: DPT Pointer
|
---|
[3] | 56 | ; Returns:
|
---|
| 57 | ; BX:DX:AX: 48-bit sector count
|
---|
| 58 | ; Corrupts registers:
|
---|
[252] | 59 | ; CX
|
---|
[128] | 60 | ;--------------------------------------------------------------------
|
---|
[3] | 61 | ALIGN JUMP_ALIGN
|
---|
[254] | 62 | BootMenuInfo_GetTotalSectorCount:
|
---|
[252] | 63 | test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
|
---|
| 64 | jnz SHORT .ReturnFullCapacity
|
---|
| 65 | jmp AH15h_GetSectorCountToBXDXAX
|
---|
| 66 | .ReturnFullCapacity:
|
---|
| 67 | jmp AccessDPT_GetLbaSectorCountToBXDXAX
|
---|
[100] | 68 |
|
---|
| 69 |
|
---|
| 70 | ;--------------------------------------------------------------------
|
---|
[254] | 71 | ; Returns offset to BOOTMENUINFO based on DPT pointer.
|
---|
[100] | 72 | ;
|
---|
[254] | 73 | ; BootMenuInfo_ConvertDPTtoBX
|
---|
[100] | 74 | ; Parameters:
|
---|
[241] | 75 | ; DS:DI: DPT Pointer
|
---|
[100] | 76 | ; Returns:
|
---|
[254] | 77 | ; BX: Offset to BOOTMENUINFO struct
|
---|
[100] | 78 | ; Corrupts registers:
|
---|
| 79 | ; AX
|
---|
| 80 | ;--------------------------------------------------------------------
|
---|
| 81 | ALIGN JUMP_ALIGN
|
---|
[254] | 82 | BootMenuInfo_ConvertDPTtoBX:
|
---|
[241] | 83 | mov ax, di
|
---|
[254] | 84 | sub ax, RAMVARS_size ; subtract off base of DPTs
|
---|
| 85 | mov bl, DPT_BOOTMENUINFO_SIZE_MULTIPLIER ; BOOTMENUINFO's are a whole number multiple of DPT size
|
---|
[241] | 86 | mul bl
|
---|
[254] | 87 | add ax, BOOTVARS.rgBootNfo ; add base of BOOTMENUINFO
|
---|
[241] | 88 | xchg ax, bx
|
---|
| 89 | ret
|
---|