1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : Int 19h BIOS functions for Boot Menu. |
---|
3 | |
---|
4 | ; Section containing code |
---|
5 | SECTION .text |
---|
6 | |
---|
7 | ;-------------------------------------------------------------------- |
---|
8 | ; Boot Menu Loader. |
---|
9 | ; |
---|
10 | ; Int19hMenu_BootLoader |
---|
11 | ; Parameters: |
---|
12 | ; Nothing |
---|
13 | ; Returns: |
---|
14 | ; Jumps to Int19hMenu_Display, then never returns |
---|
15 | ;-------------------------------------------------------------------- |
---|
16 | ALIGN JUMP_ALIGN |
---|
17 | Int19hMenu_BootLoader: |
---|
18 | ; Store POST stack pointer |
---|
19 | LOAD_BDA_SEGMENT_TO ds, ax |
---|
20 | STORE_POST_STACK_POINTER |
---|
21 | SWITCH_TO_BOOT_MENU_STACK |
---|
22 | call RamVars_GetSegmentToDS |
---|
23 | ; Fall to .InitializeDisplayForBootMenu |
---|
24 | |
---|
25 | ;-------------------------------------------------------------------- |
---|
26 | ; .InitializeDisplayForBootMenu |
---|
27 | ; Parameters: |
---|
28 | ; Nothing |
---|
29 | ; Returns: |
---|
30 | ; Nothing |
---|
31 | ; Corrupts registers: |
---|
32 | ; AX, DI |
---|
33 | ;-------------------------------------------------------------------- |
---|
34 | .InitializeDisplayForBootMenu: |
---|
35 | ; Change display mode if necessary |
---|
36 | mov ax, [cs:ROMVARS.wDisplayMode] ; AH 00h = Set Video Mode |
---|
37 | cmp al, DEFAULT_TEXT_MODE |
---|
38 | je SHORT .InitializeDisplayLibrary |
---|
39 | int BIOS_VIDEO_INTERRUPT_10h |
---|
40 | .InitializeDisplayLibrary: |
---|
41 | call BootMenuPrint_InitializeDisplayContext |
---|
42 | ; Fall to .ProcessMenuSelectionsUntilBootable |
---|
43 | |
---|
44 | ;-------------------------------------------------------------------- |
---|
45 | ; .ProcessMenuSelectionsUntilBootable |
---|
46 | ; Parameters: |
---|
47 | ; DS: RAMVARS segment |
---|
48 | ; Returns: |
---|
49 | ; Never returns |
---|
50 | ;-------------------------------------------------------------------- |
---|
51 | ALIGN JUMP_ALIGN |
---|
52 | .ProcessMenuSelectionsUntilBootable: |
---|
53 | call BootMenu_DisplayAndReturnSelection |
---|
54 | call DriveXlate_ToOrBack ; Translate drive number |
---|
55 | call BootSector_TryToLoadFromDriveDL |
---|
56 | jnc SHORT .ProcessMenuSelectionsUntilBootable ; Boot failure, show menu again |
---|
57 | ; Fall to Int19hMenu_JumpToBootSector_or_RomBoot |
---|
58 | ; (CF is set or we wouldn't be here, see "jnc" immediately above) |
---|
59 | |
---|
60 | ;-------------------------------------------------------------------- |
---|
61 | ; Int19hMenu_JumpToBootSector_or_RomBoot |
---|
62 | ; |
---|
63 | ; Switches back to the POST stack, clears the DS and ES registers, |
---|
64 | ; and either jumps to the MBR (Master Boot Record) that was just read, |
---|
65 | ; or calls the ROM's boot routine on interrupt 18. |
---|
66 | ; |
---|
67 | ; Parameters: |
---|
68 | ; DL: Drive to boot from (translated, 00h or 80h) |
---|
69 | ; CF: Set for Boot Sector Boot |
---|
70 | ; Clear for Rom Boot |
---|
71 | ; ES:BX: (if CF set) Ptr to boot sector |
---|
72 | ; |
---|
73 | ; Returns: |
---|
74 | ; Never returns |
---|
75 | ;-------------------------------------------------------------------- |
---|
76 | ALIGN JUMP_ALIGN |
---|
77 | Int19hMenu_JumpToBootSector_or_RomBoot: |
---|
78 | mov cx,es ; preserve MBR segment |
---|
79 | ; |
---|
80 | ; inline of SWITCH_BACK_TO_POST_STACK macro, so that we can preserve CF |
---|
81 | ; and reuse zero value in ax for clearing segment registers |
---|
82 | ; |
---|
83 | mov ax,0 ; NOTE: can't use XOR as it impacts CF |
---|
84 | %ifndef USE_386 |
---|
85 | cli |
---|
86 | mov ss,ax |
---|
87 | mov sp,[ss:BOOTVARS.dwPostStack] |
---|
88 | mov ss,[ss:BOOTVARS.dwPostStack+2] |
---|
89 | sti |
---|
90 | %else |
---|
91 | mov ss,ax |
---|
92 | lss sp,[ss:BOOTVARS.dwPostStack] |
---|
93 | %endif |
---|
94 | ; |
---|
95 | ; end inline of SWITCH_BACK_TO_POST_STACK |
---|
96 | ; |
---|
97 | |
---|
98 | ; clear segment registers before boot sector or rom call |
---|
99 | ; (old ClearSegmentsForBoot routine) |
---|
100 | ; |
---|
101 | mov ds,ax |
---|
102 | mov es,ax |
---|
103 | |
---|
104 | jnc .romboot |
---|
105 | |
---|
106 | ; jump to boot sector |
---|
107 | ; (old JumpToBootSector routine) |
---|
108 | ; |
---|
109 | push cx ; sgment address for MBR |
---|
110 | push bx ; offset address for MBR |
---|
111 | retf ; NOTE: DL is set to the drive number |
---|
112 | |
---|
113 | ; (old Int19hMenu_RomBoot routine) |
---|
114 | ; |
---|
115 | .romboot: |
---|
116 | int BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns |
---|