multiboot work
This commit is contained in:
parent
8e742181d8
commit
e5917a40e4
|
@ -42,7 +42,7 @@ typedef struct Terminal_t Terminal_t;
|
||||||
typedef struct ListHead_t ListHead_t;
|
typedef struct ListHead_t ListHead_t;
|
||||||
typedef struct ListNode_t ListNode_t;
|
typedef struct ListNode_t ListNode_t;
|
||||||
typedef struct Processor_t Processor_t;
|
typedef struct Processor_t Processor_t;
|
||||||
typedef struct MemoryMap_t MemoryMap_t;
|
typedef struct BootInfo_t BootInfo_t;
|
||||||
|
|
||||||
typedef enum ProcState_t ProcState_t;
|
typedef enum ProcState_t ProcState_t;
|
||||||
typedef enum TermColor_t TermColor_t;
|
typedef enum TermColor_t TermColor_t;
|
||||||
|
@ -63,6 +63,8 @@ typedef enum TermColor_t TermColor_t;
|
||||||
#define GetCurCPU() (cpuTable[_GetCurCPU()])
|
#define GetCurCPU() (cpuTable[_GetCurCPU()])
|
||||||
#define PANICSTR_SIZE 1024
|
#define PANICSTR_SIZE 1024
|
||||||
|
|
||||||
|
//Get the BootInfo_t structure
|
||||||
|
#define GetBootInfo() (bootTab)
|
||||||
//------------------------------------------//
|
//------------------------------------------//
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -96,17 +98,66 @@ struct Processor_t
|
||||||
ListHead_t *timeCritProcs;
|
ListHead_t *timeCritProcs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MemoryMap_t
|
#define FB_EGA_TEXT 2
|
||||||
|
#define FB_INDEXED 0
|
||||||
|
#define FB_RGB 1
|
||||||
|
|
||||||
|
struct BootInfo_t
|
||||||
{
|
{
|
||||||
void *addr;
|
// The Bootloader infos (GRUB in our case)
|
||||||
int length;
|
struct {
|
||||||
|
uint grubFlags; //flags
|
||||||
|
uint modulesCount; //mods_count
|
||||||
|
uint modulesAddr; //mods_addr
|
||||||
|
uint grubName; //boot_loader_name
|
||||||
|
} btldr;
|
||||||
|
|
||||||
|
// Informations about drives
|
||||||
|
struct {
|
||||||
|
uint bootDrv; //boot_device
|
||||||
|
uint bufferLength; //drives_length
|
||||||
|
uint bufferAddr; //drives_addr
|
||||||
|
} drives;
|
||||||
|
|
||||||
|
// Informations about memory
|
||||||
|
struct {
|
||||||
|
//BIOS provided low and up memory
|
||||||
|
uint lowMemory; //mem_lower
|
||||||
|
uint upMemory; //mem_upper
|
||||||
|
|
||||||
|
//GRUB provided memory map
|
||||||
|
uint mapLength; //mmap_length
|
||||||
|
uint mapAddr; //mmap_addr
|
||||||
|
} memory;
|
||||||
|
|
||||||
|
// Informations about the video drive
|
||||||
|
struct {
|
||||||
|
uint vbeControl; //vbe_control_info
|
||||||
|
uint vbeModeInfo; //vbe_mode_info
|
||||||
|
ushort vbeMode; //vbe_mode
|
||||||
|
ushort vbeInterfaceSeg; //vbe_interface_seg
|
||||||
|
ushort vbeInterfaceOff; //vbe_interface_off
|
||||||
|
ushort vbeInterfaceLen; //vbe_interface_len
|
||||||
|
ullong framebufferAddr; //framebuffer_addr
|
||||||
|
uint framebufferPitch; //framebuffer_pitch
|
||||||
|
uint framebufferWidth; //framebuffer_width
|
||||||
|
uint framebufferHeight; //framebuffer_height
|
||||||
|
uchar framebufferBpp; //framebuffer_bpp
|
||||||
|
uchar framebufferType; //framebuffer_type
|
||||||
|
} video;
|
||||||
|
|
||||||
|
// Informations about the microcode firmware (BIOS/EFI)
|
||||||
|
struct {
|
||||||
|
uint apmTable; //apm_table
|
||||||
|
uint romTable; //config_table
|
||||||
|
} firmware;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------//
|
//------------------------------------------//
|
||||||
|
|
||||||
extern int cpuCount;
|
extern int cpuCount;
|
||||||
extern Processor_t cpuTable[NCPUS];
|
extern Processor_t cpuTable[NCPUS];
|
||||||
extern MemoryMap_t memTab;
|
extern BootInfo_t bootTab;
|
||||||
//------------------------------------------//
|
//------------------------------------------//
|
||||||
|
|
||||||
#define DEC_PER_CPU(name, field, type) \
|
#define DEC_PER_CPU(name, field, type) \
|
||||||
|
|
|
@ -25,8 +25,6 @@
|
||||||
#include <multiboot/multiboot.h>
|
#include <multiboot/multiboot.h>
|
||||||
#include <kernel/base.h>
|
#include <kernel/base.h>
|
||||||
|
|
||||||
#define GetCurMemMap() (memTab)
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Returns a pointer to the first entry of the memory map
|
// Returns a pointer to the first entry of the memory map
|
||||||
//
|
//
|
||||||
|
@ -35,6 +33,6 @@ void *GetMemoryMap(void);
|
||||||
//
|
//
|
||||||
// Initializes the memory map structure
|
// Initializes the memory map structure
|
||||||
//
|
//
|
||||||
void InitMemoryMap(multiboot_info_t *mbInfo);
|
void InitMemoryMap(void);
|
||||||
|
|
||||||
// -------------------------------------------------------------------------- //
|
// -------------------------------------------------------------------------- //
|
||||||
|
|
|
@ -93,74 +93,74 @@
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
typedef unsigned char multiboot_uint8_t;
|
typedef unsigned char uchar;
|
||||||
typedef unsigned short multiboot_uint16_t;
|
typedef unsigned short ushort;
|
||||||
typedef unsigned int multiboot_uint32_t;
|
typedef unsigned int uint;
|
||||||
typedef unsigned long long multiboot_uint64_t;
|
typedef unsigned long long ullong;
|
||||||
|
|
||||||
struct multiboot_header
|
struct multiboot_header
|
||||||
{
|
{
|
||||||
/* Must be MULTIBOOT_MAGIC - see above. */
|
/* Must be MULTIBOOT_MAGIC - see above. */
|
||||||
multiboot_uint32_t magic;
|
uint magic;
|
||||||
|
|
||||||
/* Feature flags. */
|
/* Feature flags. */
|
||||||
multiboot_uint32_t flags;
|
uint flags;
|
||||||
|
|
||||||
/* The above fields plus this one must equal 0 mod 2^32. */
|
/* The above fields plus this one must equal 0 mod 2^32. */
|
||||||
multiboot_uint32_t checksum;
|
uint checksum;
|
||||||
|
|
||||||
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
|
/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
|
||||||
multiboot_uint32_t header_addr;
|
uint header_addr;
|
||||||
multiboot_uint32_t load_addr;
|
uint load_addr;
|
||||||
multiboot_uint32_t load_end_addr;
|
uint load_end_addr;
|
||||||
multiboot_uint32_t bss_end_addr;
|
uint bss_end_addr;
|
||||||
multiboot_uint32_t entry_addr;
|
uint entry_addr;
|
||||||
|
|
||||||
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
|
/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
|
||||||
multiboot_uint32_t mode_type;
|
uint mode_type;
|
||||||
multiboot_uint32_t width;
|
uint width;
|
||||||
multiboot_uint32_t height;
|
uint height;
|
||||||
multiboot_uint32_t depth;
|
uint depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The symbol table for a.out. */
|
/* The symbol table for a.out. */
|
||||||
struct multiboot_aout_symbol_table
|
struct multiboot_aout_symbol_table
|
||||||
{
|
{
|
||||||
multiboot_uint32_t tabsize;
|
uint tabsize;
|
||||||
multiboot_uint32_t strsize;
|
uint strsize;
|
||||||
multiboot_uint32_t addr;
|
uint addr;
|
||||||
multiboot_uint32_t reserved;
|
uint reserved;
|
||||||
};
|
};
|
||||||
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
|
||||||
|
|
||||||
/* The section header table for ELF. */
|
/* The section header table for ELF. */
|
||||||
struct multiboot_elf_section_header_table
|
struct multiboot_elf_section_header_table
|
||||||
{
|
{
|
||||||
multiboot_uint32_t num;
|
uint num;
|
||||||
multiboot_uint32_t size;
|
uint size;
|
||||||
multiboot_uint32_t addr;
|
uint addr;
|
||||||
multiboot_uint32_t shndx;
|
uint shndx;
|
||||||
};
|
};
|
||||||
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
|
||||||
|
|
||||||
struct multiboot_info
|
struct multiboot_info
|
||||||
{
|
{
|
||||||
/* Multiboot info version number */
|
/* Multiboot info version number */
|
||||||
multiboot_uint32_t flags;
|
uint flags;
|
||||||
|
|
||||||
/* Available memory from BIOS */
|
/* Available memory from BIOS */
|
||||||
multiboot_uint32_t mem_lower;
|
uint mem_lower;
|
||||||
multiboot_uint32_t mem_upper;
|
uint mem_upper;
|
||||||
|
|
||||||
/* "root" partition */
|
/* "root" partition */
|
||||||
multiboot_uint32_t boot_device;
|
uint boot_device;
|
||||||
|
|
||||||
/* Kernel command line */
|
/* Kernel command line */
|
||||||
multiboot_uint32_t cmdline;
|
uint cmdline;
|
||||||
|
|
||||||
/* Boot-Module list */
|
/* Boot-Module list */
|
||||||
multiboot_uint32_t mods_count;
|
uint mods_count;
|
||||||
multiboot_uint32_t mods_addr;
|
uint mods_addr;
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -169,54 +169,54 @@ struct multiboot_info
|
||||||
} u;
|
} u;
|
||||||
|
|
||||||
/* Memory Mapping buffer */
|
/* Memory Mapping buffer */
|
||||||
multiboot_uint32_t mmap_length;
|
uint mmap_length;
|
||||||
multiboot_uint32_t mmap_addr;
|
uint mmap_addr;
|
||||||
|
|
||||||
/* Drive Info buffer */
|
/* Drive Info buffer */
|
||||||
multiboot_uint32_t drives_length;
|
uint drives_length;
|
||||||
multiboot_uint32_t drives_addr;
|
uint drives_addr;
|
||||||
|
|
||||||
/* ROM configuration table */
|
/* ROM configuration table */
|
||||||
multiboot_uint32_t config_table;
|
uint config_table;
|
||||||
|
|
||||||
/* Boot Loader Name */
|
/* Boot Loader Name */
|
||||||
multiboot_uint32_t boot_loader_name;
|
uint boot_loader_name;
|
||||||
|
|
||||||
/* APM table */
|
/* APM table */
|
||||||
multiboot_uint32_t apm_table;
|
uint apm_table;
|
||||||
|
|
||||||
/* Video */
|
/* Video */
|
||||||
multiboot_uint32_t vbe_control_info;
|
uint vbe_control_info;
|
||||||
multiboot_uint32_t vbe_mode_info;
|
uint vbe_mode_info;
|
||||||
multiboot_uint16_t vbe_mode;
|
ushort vbe_mode;
|
||||||
multiboot_uint16_t vbe_interface_seg;
|
ushort vbe_interface_seg;
|
||||||
multiboot_uint16_t vbe_interface_off;
|
ushort vbe_interface_off;
|
||||||
multiboot_uint16_t vbe_interface_len;
|
ushort vbe_interface_len;
|
||||||
|
|
||||||
multiboot_uint64_t framebuffer_addr;
|
ullong framebuffer_addr;
|
||||||
multiboot_uint32_t framebuffer_pitch;
|
uint framebuffer_pitch;
|
||||||
multiboot_uint32_t framebuffer_width;
|
uint framebuffer_width;
|
||||||
multiboot_uint32_t framebuffer_height;
|
uint framebuffer_height;
|
||||||
multiboot_uint8_t framebuffer_bpp;
|
uchar framebuffer_bpp;
|
||||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
|
#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
|
||||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
|
||||||
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
#define MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT 2
|
||||||
multiboot_uint8_t framebuffer_type;
|
uchar framebuffer_type;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
multiboot_uint32_t framebuffer_palette_addr;
|
uint framebuffer_palette_addr;
|
||||||
multiboot_uint16_t framebuffer_palette_num_colors;
|
ushort framebuffer_palette_num_colors;
|
||||||
};
|
};
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
multiboot_uint8_t framebuffer_red_field_position;
|
uchar framebuffer_red_field_position;
|
||||||
multiboot_uint8_t framebuffer_red_mask_size;
|
uchar framebuffer_red_mask_size;
|
||||||
multiboot_uint8_t framebuffer_green_field_position;
|
uchar framebuffer_green_field_position;
|
||||||
multiboot_uint8_t framebuffer_green_mask_size;
|
uchar framebuffer_green_mask_size;
|
||||||
multiboot_uint8_t framebuffer_blue_field_position;
|
uchar framebuffer_blue_field_position;
|
||||||
multiboot_uint8_t framebuffer_blue_mask_size;
|
uchar framebuffer_blue_mask_size;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -224,51 +224,51 @@ typedef struct multiboot_info multiboot_info_t;
|
||||||
|
|
||||||
struct multiboot_color
|
struct multiboot_color
|
||||||
{
|
{
|
||||||
multiboot_uint8_t red;
|
uchar red;
|
||||||
multiboot_uint8_t green;
|
uchar green;
|
||||||
multiboot_uint8_t blue;
|
uchar blue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct multiboot_mmap_entry
|
struct multiboot_mmap_entry
|
||||||
{
|
{
|
||||||
multiboot_uint32_t size;
|
uint size;
|
||||||
multiboot_uint64_t addr;
|
ullong addr;
|
||||||
multiboot_uint64_t len;
|
ullong len;
|
||||||
#define MULTIBOOT_MEMORY_AVAILABLE 1
|
#define MULTIBOOT_MEMORY_AVAILABLE 1
|
||||||
#define MULTIBOOT_MEMORY_RESERVED 2
|
#define MULTIBOOT_MEMORY_RESERVED 2
|
||||||
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
|
#define MULTIBOOT_MEMORY_ACPI_RECLAIMABLE 3
|
||||||
#define MULTIBOOT_MEMORY_NVS 4
|
#define MULTIBOOT_MEMORY_NVS 4
|
||||||
#define MULTIBOOT_MEMORY_BADRAM 5
|
#define MULTIBOOT_MEMORY_BADRAM 5
|
||||||
multiboot_uint32_t type;
|
uint type;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
typedef struct multiboot_mmap_entry multiboot_memory_map_t;
|
||||||
|
|
||||||
struct multiboot_mod_list
|
struct multiboot_mod_list
|
||||||
{
|
{
|
||||||
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
|
||||||
multiboot_uint32_t mod_start;
|
uint mod_start;
|
||||||
multiboot_uint32_t mod_end;
|
uint mod_end;
|
||||||
|
|
||||||
/* Module command line */
|
/* Module command line */
|
||||||
multiboot_uint32_t cmdline;
|
uint cmdline;
|
||||||
|
|
||||||
/* padding to take it to 16 bytes (must be zero) */
|
/* padding to take it to 16 bytes (must be zero) */
|
||||||
multiboot_uint32_t pad;
|
uint pad;
|
||||||
};
|
};
|
||||||
typedef struct multiboot_mod_list multiboot_module_t;
|
typedef struct multiboot_mod_list multiboot_module_t;
|
||||||
|
|
||||||
/* APM BIOS info. */
|
/* APM BIOS info. */
|
||||||
struct multiboot_apm_info
|
struct multiboot_apm_info
|
||||||
{
|
{
|
||||||
multiboot_uint16_t version;
|
ushort version;
|
||||||
multiboot_uint16_t cseg;
|
ushort cseg;
|
||||||
multiboot_uint32_t offset;
|
uint offset;
|
||||||
multiboot_uint16_t cseg_16;
|
ushort cseg_16;
|
||||||
multiboot_uint16_t dseg;
|
ushort dseg;
|
||||||
multiboot_uint16_t flags;
|
ushort flags;
|
||||||
multiboot_uint16_t cseg_len;
|
ushort cseg_len;
|
||||||
multiboot_uint16_t cseg_16_len;
|
ushort cseg_16_len;
|
||||||
multiboot_uint16_t dseg_len;
|
ushort dseg_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* ! ASM_FILE */
|
#endif /* ! ASM_FILE */
|
||||||
|
|
|
@ -27,6 +27,28 @@
|
||||||
#include <kernel/panic.h>
|
#include <kernel/panic.h>
|
||||||
#include <kernel/mm.h>
|
#include <kernel/mm.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// BootInfo_t initialization. It is necessary because grub will potentially be
|
||||||
|
// wiped since it is below 1MB....
|
||||||
|
//
|
||||||
|
void InitBootInfo(multiboot_info_t *mbi)
|
||||||
|
{
|
||||||
|
//Retrieves the bootloader informations
|
||||||
|
GetBootInfo().btldr.grubFlags = mbi->flags;
|
||||||
|
GetBootInfo().btldr.grubName = mbi->boot_loader_name;
|
||||||
|
GetBootInfo().btldr.modulesCount = mbi->mods_count;
|
||||||
|
GetBootInfo().btldr.modulesAddr = mbi->mods_addr;
|
||||||
|
DebugLog("[InitBootInfo] %s\n", GetBootInfo().btldr.grubName);
|
||||||
|
|
||||||
|
//Retrieves the drives informations
|
||||||
|
GetBootInfo().drives.bootDrv = mbi->boot_device;
|
||||||
|
GetBootInfo().drives.bufferLength = mbi->drives_length;
|
||||||
|
GetBootInfo().drives.bufferAddr = mbi->drives_addr;
|
||||||
|
DebugLog("[InitBootInfo] Root drive : %x\n",
|
||||||
|
GetBootInfo().drives.bootDrv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Entry point of the Kaleid kernel
|
// Entry point of the Kaleid kernel
|
||||||
//
|
//
|
||||||
|
@ -42,11 +64,13 @@ noreturn void StartKern(multiboot_info_t *mbInfo, int mbMagic)
|
||||||
KernLog("%c%c%c OS/K\n\n", 219, 219, 219);
|
KernLog("%c%c%c OS/K\n\n", 219, 219, 219);
|
||||||
KernLog("[Init] We have magic : %x\n", mbMagic);
|
KernLog("[Init] We have magic : %x\n", mbMagic);
|
||||||
|
|
||||||
|
//Initialize the BootInfo_t structure
|
||||||
|
InitBootInfo(mbInfo);
|
||||||
|
|
||||||
//Memory mapping
|
//Memory mapping
|
||||||
InitMemoryMap(mbInfo);
|
InitMemoryMap();
|
||||||
|
|
||||||
// We're out
|
// We're out
|
||||||
KernLog("\n[Init] Evil never dies");
|
KernLog("\n[Init] Evil never dies");
|
||||||
CrashSystem(); //yay
|
CrashSystem(); //yay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,6 @@
|
||||||
int cpuCount = 1;
|
int cpuCount = 1;
|
||||||
Processor_t cpuTable[NCPUS] = {0};
|
Processor_t cpuTable[NCPUS] = {0};
|
||||||
|
|
||||||
MemoryMap_t memTab = {0};
|
BootInfo_t bootTab = {0};
|
||||||
|
|
||||||
Terminal_t *stdOut = 0, *stdDbg = 0;
|
Terminal_t *stdOut = 0, *stdDbg = 0;
|
||||||
|
|
|
@ -26,15 +26,14 @@
|
||||||
#include <multiboot/multiboot.h>
|
#include <multiboot/multiboot.h>
|
||||||
#include <kernel/term.h>
|
#include <kernel/term.h>
|
||||||
|
|
||||||
void InitMemoryMap(multiboot_info_t *mbInfo)
|
void InitMemoryMap(void)
|
||||||
{
|
{
|
||||||
memTab.addr = (void*)mbInfo->mmap_addr;
|
return;
|
||||||
memTab.length = (int)mbInfo->mmap_length;
|
|
||||||
|
|
||||||
KernLog("[InitMemoryMap] Address: %p, Length: %d\n", GetCurMemMap().addr, GetCurMemMap().length );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *GetMemoryMap(void)
|
void *GetMemoryMap(void)
|
||||||
{
|
{
|
||||||
return (void*)GetCurMemMap().addr;
|
return (void*)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue