source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm@ 246

Last change on this file since 246 was 243, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Brought back optional "A then C" boot loader.
  • Now there is only one INT 19h handler that remains unchanged.
File size: 4.5 KB
RevLine 
[243]1; Project name : XTIDE Universal BIOS
2; Description : Int 19h Handler (Boot Loader).
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int19h_BootLoaderHandler
9; Parameters:
10; Nothing
11; Returns:
12; Never returns (loads operating system)
13;--------------------------------------------------------------------
14ALIGN JUMP_ALIGN
15Int19h_BootLoaderHandler:
16 LOAD_BDA_SEGMENT_TO es, ax
17 call Initialize_AndDetectDrives ; Installs new boot menu loader
18 ; Fall to .PrepareStackAndSelectDriveFromBootMenu
19
20;--------------------------------------------------------------------
21; .PrepareStackAndSelectDriveFromBootMenu
22; Parameters:
23; ES: BDA and interrupt vector segment (zero)
24; Returns:
25; Never returns (loads operating system)
26;--------------------------------------------------------------------
27.PrepareStackAndSelectDriveFromBootMenu:
28 STORE_POST_STACK_POINTER
29 SWITCH_TO_BOOT_MENU_STACK
30 ; Fall to .InitializeDisplay
31
32;--------------------------------------------------------------------
33; .InitializeDisplay
34; Parameters:
35; Nothing
36; Returns:
37; Never returns (loads operating system)
38;--------------------------------------------------------------------
39.InitializeDisplay:
40 ; Change display mode if necessary
41 mov ax, [cs:ROMVARS.wDisplayMode] ; AH 00h = Set Video Mode
42 cmp al, DEFAULT_TEXT_MODE
43 je SHORT .InitializeDisplayLibrary
44 int BIOS_VIDEO_INTERRUPT_10h
45.InitializeDisplayLibrary:
46 call BootMenuPrint_InitializeDisplayContext
47 ; Fall to .SelectDriveToBootFrom
48
49;--------------------------------------------------------------------
50; .SelectDriveToBootFrom
51; Parameters:
52; Nothing
53; Returns:
54; Never returns (loads operating system)
55;--------------------------------------------------------------------
56.SelectDriveToBootFrom:
57 call RamVars_GetSegmentToDS
58 cmp WORD [cs:ROMVARS.wfDisplayBootMenu], BYTE 0
59 jne SHORT ProcessBootMenuSelectionsUntilBootableDriveSelected ; Display boot menu
60 ; Fall to BootFromDriveAthenTryDriveC
61
62;--------------------------------------------------------------------
63; BootFromDriveAthenTryDriveC
64; Parameters:
65; DS: RAMVARS segment
66; Returns:
67; Never returns (loads operating system)
68;--------------------------------------------------------------------
69BootFromDriveAthenTryDriveC:
70 xor dx, dx ; DL = 00h = Floppy Drive A
71 call BootSector_TryToLoadFromDriveDL
72 jc SHORT Int19hMenu_JumpToBootSector_or_RomBoot
73 mov dl, 80h ; DL = 80h = First Hard Drive (usually C)
74 call BootSector_TryToLoadFromDriveDL
75 jmp SHORT Int19hMenu_JumpToBootSector_or_RomBoot ; ROM Boot if error
76
77
78;--------------------------------------------------------------------
79; ProcessBootMenuSelectionsUntilBootableDriveSelected
80; Parameters:
81; DS: RAMVARS segment
82; Returns:
83; Never returns
84;--------------------------------------------------------------------
85ProcessBootMenuSelectionsUntilBootableDriveSelected:
86 call BootMenu_DisplayAndReturnSelectionInDX
87 call DriveXlate_ToOrBack ; Translate drive number
88 call BootSector_TryToLoadFromDriveDL
89 jnc SHORT ProcessBootMenuSelectionsUntilBootableDriveSelected ; Boot failure, show menu again
90 ; Fall to Int19hMenu_JumpToBootSector_or_RomBoot
91 ; (CF is set or we wouldn't be here, see "jnc" immediately above)
92
93;--------------------------------------------------------------------
94; Int19hMenu_JumpToBootSector_or_RomBoot
95;
96; Switches back to the POST stack, clears the DS and ES registers,
97; and either jumps to the MBR (Master Boot Record) that was just read,
98; or calls the ROM's boot routine on interrupt 18.
99;
100; Parameters:
101; DL: Drive to boot from (translated, 00h or 80h)
102; CF: Set for Boot Sector Boot
103; Clear for Rom Boot
104; ES:BX: (if CF set) Ptr to boot sector
105;
106; Returns:
107; Never returns
108;--------------------------------------------------------------------
109ALIGN JUMP_ALIGN
110Int19hMenu_JumpToBootSector_or_RomBoot:
111 mov cx, es ; Preserve MBR segment (can't push because of stack change)
112 mov ax, 0 ; NOTE: can't use XOR (LOAD_BDA_SEGMENT_TO) as it impacts CF
113 SWITCH_BACK_TO_POST_STACK
114
115; clear segment registers before boot sector or rom call
116 mov ds, ax
117 mov es, ax
118%ifdef USE_386
119 mov fs, ax
120 mov gs, ax
121%endif
122 jnc SHORT .romboot
123
124; jump to boot sector
125 push cx ; sgment address for MBR
126 push bx ; offset address for MBR
127 retf ; NOTE: DL is set to the drive number
128
129; Boot by calling INT 18h (ROM Basic of ROM DOS)
130.romboot:
131 int BIOS_BOOT_FAILURE_INTERRUPT_18h ; Never returns
Note: See TracBrowser for help on using the repository browser.