source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootInfo.asm@ 245

Last change on this file since 245 was 241, checked in by gregli@…, 13 years ago

Space optimizations in the Boot Menu and BootInfo routines, taking advantage of nested %s. Optimization in the init of RamVars to avoid writing the signature twice. Preparing for addition of serial floppy support, starting to break the assumption that our drives are always 80h or higher.

File size: 2.8 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for generating and accessing drive
3; information to be displayed on boot menu.
4
5; Section containing code
6SECTION .text
7
8;--------------------------------------------------------------------
9; Creates new BOOTNFO struct for detected hard disk.
10;
11; BootInfo_CreateForHardDisk
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:
17; ES:BX: Ptr to BOOTNFO (if successful)
18; Corrupts registers:
19; AX, BX, CX, DX, DI, SI
20;--------------------------------------------------------------------
21BootInfo_CreateForHardDisk:
22 call BootInfo_ConvertDPTtoBX ; ES:BX now points to new BOOTNFO
23 push bx ; Preserve for return
24
25 mov di, bx ; Starting pointer at beginning of structure
26
27;
28; Store Drive Name
29;
30 push ds ; Preserve RAMVARS
31 push si ; Preserve SI for call to GetTotalSectorCount...
32
33 push es ; ES copied to DS
34 pop ds
35
36 add si, BYTE ATA1.strModel ; DS:SI now points drive name
37 lea di, [bx+BOOTNFO.szDrvName] ; ES:DI now points to name destination
38 mov cx, LEN_BOOTNFO_DRV / 2 ; Max number of WORDs allowed
39.CopyNextWord:
40 lodsw
41 xchg al, ah ; Change endianness
42 stosw
43 loop .CopyNextWord
44 xor ax, ax ; Zero AX and clear CF
45 stosw ; Terminate with NULL
46
47 pop si
48 pop ds
49
50;
51; Store Sector Count
52;
53 call AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
54
55 stosw
56 xchg ax, dx
57 stosw
58 xchg ax, bx
59 stosw
60
61 pop bx
62
63 ret
64
65
66;--------------------------------------------------------------------
67; Finds BOOTNFO for drive and returns total sector count.
68;
69; BootInfo_GetTotalSectorCount
70; Parameters:
71; DS:DI: DPT Pointer
72; Returns:
73; BX:DX:AX: 48-bit sector count
74; Corrupts registers:
75; Nothing
76;--------------------------------------------------------------------
77ALIGN JUMP_ALIGN
78BootInfo_GetTotalSectorCount:
79 push ds
80 call BootInfo_ConvertDPTtoBX
81 LOAD_BDA_SEGMENT_TO ds, ax
82 mov ax, [bx+BOOTNFO.twSectCnt]
83 mov dx, [bx+BOOTNFO.twSectCnt+2]
84 mov bx, [bx+BOOTNFO.twSectCnt+4]
85 pop ds
86 ret
87
88
89;--------------------------------------------------------------------
90; Returns offset to BOOTNFO based on DPT pointer.
91;
92; BootInfo_ConvertDPTtoBX
93; Parameters:
94; DS:DI: DPT Pointer
95; Returns:
96; BX: Offset to BOOTNFO struct
97; Corrupts registers:
98; AX
99;--------------------------------------------------------------------
100ALIGN JUMP_ALIGN
101BootInfo_ConvertDPTtoBX:
102 mov ax, di
103 sub ax, RAMVARS_size ; subtract off base of DPTs
104 mov bl, DPT_BOOTNFO_SIZE_MULTIPLIER ; BOOTNFO's are a whole number multiple of DPT size
105 mul bl
106 add ax, BOOTVARS.rgBootNfo ; add base of BOOTNFO
107 xchg ax, bx
108 ret
Note: See TracBrowser for help on using the repository browser.