diff --git a/prototypes/base/include/multiboot.hpp b/prototypes/base/include/multiboot.hpp new file mode 100644 index 0000000..186eed9 --- /dev/null +++ b/prototypes/base/include/multiboot.hpp @@ -0,0 +1,114 @@ +#pragma once + +#include + + +#define MB_MEMSIZE (1<<0) +#define MB_BOOTDEVICE (1<<1) +#define MB_COMMANDLINE (1<<2) +#define MB_MODULES (1<<3) +#define MB_SYMS_AOUT (1<<4) +#define MB_SYMS_ELF (1<<5) +#define MB_MEMORYMAP (1<<6) +#define MB_DRIVES (1<<7) +#define MB_CONFIG_TABLE (1<<8) +#define MB_BOOTLOADER_NAME (1<<9) +#define MB_APS_TABLE (1<<10) +#define MB_VBE (1<<11) + +#define MB_ASSERT_SIZE(type, len) static_assert(sizeof(type) == len, "multiboot::" #type " must be " #len " bytes large.") + +namespace multiboot +{ + struct MemoryMap + { + uint32_t entry_size; + uint64_t base; + uint64_t length; + uint32_t type; + } __attribute__((packed)); + + MB_ASSERT_SIZE(MemoryMap, 24); + + struct Module + { + uintptr_t start; + uintptr_t end; + const char * name; + uint32_t reserved; + } __attribute__((packed)); + + MB_ASSERT_SIZE(Module, 16); + + struct Drive + { + uint32_t size; + uint8_t number; + uint8_t mode; + uint16_t cylinders; + uint8_t heads; + uint8_t sectors; + uint16_t ports[0]; + // 0x10 size-0x10 drive_ports I/O-Ports, die von diesem Gerät benutzt werden + } __attribute__((packed)); + + static_assert(sizeof(Drive) >= 10, "multiboot::Drive must be at least 12 bytes large."); + + struct APMTable + { + uint16_t version; + uint16_t cseg; + uint32_t offset; + uint16_t cseg_16; + uint16_t dseg; + uint16_t flags; + uint16_t cseg_len; + uint16_t cseg_16_len; + uint16_t dseg_len; + } __attribute__((packed)); + + MB_ASSERT_SIZE(APMTable, 20); + + struct Structure + { + uint32_t flags; + uint32_t memLower; + uint32_t memUpper; + uint32_t bootDevice; + const char * commandline; + uint32_t moduleCount; + Module * modules; + union { + struct { + uint32_t tabsize; + uint32_t strsize; + uint32_t addr; + uint32_t reserved; + } __attribute__((packed)) symsAssemblerOut; + struct { + uint32_t num; + uint32_t size; + uintptr_t addr; + uintptr_t shndx; + } __attribute__((packed)) symsELF; + }; + uint32_t memoryMapLength; + const MemoryMap * memoryMap; + uint32_t drivesLength; + const Drive * drives; + uintptr_t configTable; + const char * bootLoaderName; + const APMTable * apmTable; + struct { + uint32_t ontrolInfo; + uint32_t modeInfo; + uint16_t mode; + uint16_t interfaceSegment; + uint16_t interfaceOffset; + uint16_t interfaceLength; + } __attribute__((packed)) vbe; + } __attribute__((packed)); + + MB_ASSERT_SIZE(Structure, 88); + +} \ No newline at end of file diff --git a/prototypes/base/include/pointer.hpp b/prototypes/base/include/pointer.hpp index 8b4838d..b8bd749 100644 --- a/prototypes/base/include/pointer.hpp +++ b/prototypes/base/include/pointer.hpp @@ -71,7 +71,7 @@ public: }; template -pointer pointer::invalid(uint32_t(0)); +pointer pointer::invalid(uint32_t(0xFFFFFFFF)); struct physical_t_ident; struct virtual_t_ident; @@ -86,4 +86,7 @@ using physical_t = pointer; /** * A pointer pointing to virtual memory. */ -using virtual_t = pointer; \ No newline at end of file +using virtual_t = pointer; + + +static_assert(sizeof(physical_t) == 4, "pointer is not 4 byte wide."); \ No newline at end of file diff --git a/prototypes/base/init.cpp b/prototypes/base/init.cpp index 03f4a90..7b6771f 100644 --- a/prototypes/base/init.cpp +++ b/prototypes/base/init.cpp @@ -4,6 +4,7 @@ #include "pmm.hpp" #include "numeric.hpp" #include "pointer.hpp" +#include "multiboot.hpp" #include "compat.h" extern "C" void init(void)