20 #include "pedigree/kernel/machine/x86_common/Bios.h" 21 #include "pedigree/kernel/Log.h" 22 #include "pedigree/kernel/debugger/commands/../../core/BootIO.h" 23 #include "pedigree/kernel/panic.h" 24 #include "pedigree/kernel/processor/Processor.h" 25 #include "pedigree/kernel/processor/ProcessorInformation.h" 26 #include "pedigree/kernel/processor/VirtualAddressSpace.h" 27 #include "pedigree/kernel/utilities/StaticString.h" 28 #include "pedigree/kernel/utilities/utility.h" 29 #include "x86emu/x86emu.h" 36 extern "C" int abs(
int i);
37 extern "C" void sscanf(
void);
41 return *
reinterpret_cast<u8 *
>(addr);
45 return *
reinterpret_cast<u16 *
>(addr);
49 return *
reinterpret_cast<u32 *
>(addr);
51 void wrb(u32 addr, u8 val)
53 *
reinterpret_cast<u8 *
>(addr) = val;
55 void wrw(u32 addr, u16 val)
57 *
reinterpret_cast<u16 *
>(addr) = val;
59 void wrl(u32 addr, u32 val)
61 *
reinterpret_cast<u32 *
>(addr) = val;
64 static u8 inb(X86EMU_pioAddr addr)
67 asm volatile(
"inb %1, %0" :
"=a"(ret) :
"dN"(addr));
70 static u16 inw(X86EMU_pioAddr addr)
73 asm volatile(
"inw %1, %0" :
"=a"(ret) :
"dN"(addr));
76 static u32 inl(X86EMU_pioAddr addr)
79 asm volatile(
"inl %1, %0" :
"=a"(ret) :
"dN"(addr));
82 static void outb(X86EMU_pioAddr addr, u8 val)
84 asm volatile(
"outb %1, %0" : :
"dN"(addr),
"a"(val));
86 static void outw(X86EMU_pioAddr addr, u16 val)
88 asm volatile(
"outw %1, %0" : :
"dN"(addr),
"a"(val));
90 static void outl(X86EMU_pioAddr addr, u32 val)
92 asm volatile(
"outl %1, %0" : :
"dN"(addr),
"a"(val));
95 extern "C" int abs(
int i)
97 return (i > 0) ? i : -i;
100 extern "C" int exit(
int code)
NORETURN;
103 panic(
"bios: exit()");
106 extern "C" void sscanf()
110 extern "C" void printk(
const char *fmt, ...)
USED;
111 extern "C"
void printk(const
char *fmt, ...)
120 i = VStringFormat(buf, fmt, args);
127 bootIO.
write(buf2, BootIO::White, BootIO::Black);
147 ByteSet(&M, 0,
sizeof(M));
150 ByteSet(reinterpret_cast<void *>(0x7C00), 0xF4, 0x100);
152 X86EMU_setupMemFuncs(&mf);
153 X86EMU_setupPioFuncs(&iof);
191 for (physical_uintptr_t i = 0; i < 0x100; i++)
194 i * 0x1000, reinterpret_cast<void *>(i * 0x1000),
197 ERROR(
"BIOS: Map failed at " <<
Hex << i * 0x1000 <<
"!");
201 X86EMU_prepareForInt(interrupt);
static bool getInterrupts()
EXPORTED_PUBLIC void write(T &str, Colour foreColour, Colour backColour)
virtual bool isMapped(void *virtualAddress)=0
virtual bool map(physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags)=0
static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace()
void executeInterrupt(int interrupt)
static ProcessorInformation & information()
static void switchAddressSpace(VirtualAddressSpace &AddressSpace)
static const size_t Write
static const size_t KernelMode
static void setInterrupts(bool bEnable)
void EXPORTED_PUBLIC panic(const char *msg) NORETURN