Changes pointer::invalid to uint32-ammax. Adds multiboot structure.

This commit is contained in:
Felix Queißner 2016-05-04 10:17:56 +02:00
parent d557bedaa9
commit 9c768bb5b5
3 changed files with 120 additions and 2 deletions

View file

@ -0,0 +1,114 @@
#pragma once
#include <inttypes.h>
#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);
}

View file

@ -71,7 +71,7 @@ public:
};
template <class T>
pointer<T> pointer<T>::invalid(uint32_t(0));
pointer<T> pointer<T>::invalid(uint32_t(0xFFFFFFFF));
struct physical_t_ident;
struct virtual_t_ident;
@ -86,4 +86,7 @@ using physical_t = pointer<physical_t_ident>;
/**
* A pointer pointing to virtual memory.
*/
using virtual_t = pointer<virtual_t_ident>;
using virtual_t = pointer<virtual_t_ident>;
static_assert(sizeof(physical_t) == 4, "pointer is not 4 byte wide.");

View file

@ -4,6 +4,7 @@
#include "pmm.hpp"
#include "numeric.hpp"
#include "pointer.hpp"
#include "multiboot.hpp"
#include "compat.h"
extern "C" void init(void)