1 // 16bit code to load disk image and start system boot.
3 // Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4 // Copyright (C) 2002 MandrakeSoft S.A.
6 // This file may be distributed under the terms of the GNU GPLv3 license.
8 #include "types.h" // VISIBLE
9 #include "util.h" // irq_enable
10 #include "biosvar.h" // struct bregs
11 #include "farptr.h" // SET_SEG
16 asm volatile("int %0" : : "N" (nr));
20 call_irq(u8 nr, struct bregs *callregs)
24 // Save current registers
26 // Pull in calling registers.
27 "movl 0x04(%%eax), %%edi\n"
28 "movl 0x08(%%eax), %%esi\n"
29 "movl 0x0c(%%eax), %%ebp\n"
30 "movl 0x14(%%eax), %%ebx\n"
31 "movl 0x18(%%eax), %%edx\n"
32 "movl 0x1c(%%eax), %%ecx\n"
33 "movl 0x20(%%eax), %%eax\n"
41 : "=a" (flags): "N" (nr), "a" (callregs), "m" (*callregs));
48 bprintf(0, "Boot failed\n");
54 // XXX - assume floppy
60 memset(&cr, 0, sizeof(cr));
69 u32 status = call_irq(0x13, &cr);
76 u16 bootip = (bootseg & 0x0fff) << 4;
79 u32 segoff = (bootseg << 16) | bootip;
84 // Set the magic number in ax and the boot drive in dl.
85 "movw $0xaa55, %%ax\n"
86 // Zero some of the other registers.
93 : : "r" (segoff), "ri" (bootdrv));
96 // Boot Failure recovery: try the next device.
98 handle_18(struct bregs *regs)
104 // INT 19h Boot Load Service Entry Point
106 handle_19(struct bregs *regs)
112 // Callback from 32bit entry - start boot process