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 | SWITCH_BACK_TO_POST_STACK |
---|
58 | ; Fall to JumpToBootSector |
---|
59 | |
---|
60 | ;-------------------------------------------------------------------- |
---|
61 | ; JumpToBootSector |
---|
62 | ; Parameters: |
---|
63 | ; DL: Drive to boot from (translated, 00h or 80h) |
---|
64 | ; ES:BX: Ptr to boot sector |
---|
65 | ; Returns: |
---|
66 | ; Never returns |
---|
67 | ;-------------------------------------------------------------------- |
---|
68 | ALIGN JUMP_ALIGN |
---|
69 | JumpToBootSector: |
---|
70 | push es ; Push boot sector segment |
---|
71 | push bx ; Push boot sector offset |
---|
72 | call ClearSegmentsForBoot |
---|
73 | retf |
---|
74 | |
---|
75 | |
---|
76 | ;-------------------------------------------------------------------- |
---|
77 | ; Int19hMenu_RomBoot |
---|
78 | ; Parameters: |
---|
79 | ; DS: RAMVARS segment |
---|
80 | ; Returns: |
---|
81 | ; Never returns |
---|
82 | ;-------------------------------------------------------------------- |
---|
83 | ALIGN JUMP_ALIGN |
---|
84 | Int19hMenu_RomBoot: |
---|
85 | SWITCH_BACK_TO_POST_STACK |
---|
86 | call ClearSegmentsForBoot |
---|
87 | int BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns |
---|
88 | |
---|
89 | |
---|
90 | ;-------------------------------------------------------------------- |
---|
91 | ; ClearSegmentsForBoot |
---|
92 | ; Parameters: |
---|
93 | ; Nothing |
---|
94 | ; Returns: |
---|
95 | ; DX: Zero |
---|
96 | ; DS=ES: Zero |
---|
97 | ; Corrupts registers: |
---|
98 | ; Nothing |
---|
99 | ;-------------------------------------------------------------------- |
---|
100 | ALIGN JUMP_ALIGN |
---|
101 | ClearSegmentsForBoot: |
---|
102 | xor dx, dx ; Device supported by INT 13h |
---|
103 | mov ds, dx |
---|
104 | mov es, dx |
---|
105 | ret |
---|