mirror of
https://github.com/tailix/kernel.git
synced 2024-10-30 12:03:52 -04:00
Rewrite multiboot code according to glossary
This commit is contained in:
parent
837d2a3034
commit
c85dd61103
3 changed files with 10 additions and 10 deletions
|
@ -13,7 +13,7 @@ extern char _kernel_stack_top;
|
||||||
|
|
||||||
static struct KernelMQ_Info kinfo;
|
static struct KernelMQ_Info kinfo;
|
||||||
|
|
||||||
const struct KernelMQ_Info *init(unsigned long multiboot_magic, unsigned long multiboot_info_addr)
|
const struct KernelMQ_Info *init(unsigned long multiboot_magic, unsigned long multiboot_info_base)
|
||||||
{
|
{
|
||||||
if (multiboot_magic != MULTIBOOT_MAGIC) {
|
if (multiboot_magic != MULTIBOOT_MAGIC) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -21,7 +21,7 @@ const struct KernelMQ_Info *init(unsigned long multiboot_magic, unsigned long mu
|
||||||
|
|
||||||
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
|
kmemset(&kinfo, 0, sizeof(struct KernelMQ_Info));
|
||||||
|
|
||||||
if (!multiboot_parse(&kinfo, multiboot_info_addr)) {
|
if (!multiboot_parse(&kinfo, multiboot_info_base)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
|
|
||||||
struct multiboot_mmap_entry
|
struct multiboot_mmap_entry
|
||||||
{
|
{
|
||||||
unsigned long long addr;
|
unsigned long long base;
|
||||||
unsigned long long len;
|
unsigned long long size;
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
unsigned int zero;
|
unsigned int zero;
|
||||||
};
|
};
|
||||||
|
@ -59,19 +59,19 @@ static unsigned char print_multiboot_tag_cmdline(struct KernelMQ_Info *kinfo, co
|
||||||
static unsigned char print_multiboot_tag_module (struct KernelMQ_Info *kinfo, const struct multiboot_tag_module *tag);
|
static unsigned char print_multiboot_tag_module (struct KernelMQ_Info *kinfo, const struct multiboot_tag_module *tag);
|
||||||
static unsigned char print_multiboot_tag_mmap (struct KernelMQ_Info *kinfo, const struct multiboot_tag_mmap *tag);
|
static unsigned char print_multiboot_tag_mmap (struct KernelMQ_Info *kinfo, const struct multiboot_tag_mmap *tag);
|
||||||
|
|
||||||
unsigned char multiboot_parse(struct KernelMQ_Info *kinfo, unsigned long addr)
|
unsigned char multiboot_parse(struct KernelMQ_Info *kinfo, unsigned long base)
|
||||||
{
|
{
|
||||||
if (!kinfo) {
|
if (!kinfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unaligned address
|
// Unaligned address
|
||||||
if (addr & 7) {
|
if (base & 7) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (
|
for (
|
||||||
struct multiboot_tag *tag = (struct multiboot_tag*)(addr + 8);
|
struct multiboot_tag *tag = (struct multiboot_tag*)(base + 8);
|
||||||
tag->type != MULTIBOOT_TAG_TYPE_END;
|
tag->type != MULTIBOOT_TAG_TYPE_END;
|
||||||
tag = (struct multiboot_tag*)((unsigned char*)tag + ((tag->size + 7) & ~7))
|
tag = (struct multiboot_tag*)((unsigned char*)tag + ((tag->size + 7) & ~7))
|
||||||
) {
|
) {
|
||||||
|
@ -153,8 +153,8 @@ unsigned char print_multiboot_tag_mmap(struct KernelMQ_Info *kinfo, const struct
|
||||||
|
|
||||||
struct KernelMQ_Info_Area *area = &kinfo->areas[kinfo->areas_count];
|
struct KernelMQ_Info_Area *area = &kinfo->areas[kinfo->areas_count];
|
||||||
|
|
||||||
area->base = mmap->addr;
|
area->base = mmap->base;
|
||||||
area->size = mmap->len;
|
area->size = mmap->size;
|
||||||
area->limit = area->base + area->size - 1;
|
area->limit = area->base + area->size - 1;
|
||||||
|
|
||||||
area->is_available = mmap->type == MULTIBOOT_MEMORY_AVAILABLE;
|
area->is_available = mmap->type == MULTIBOOT_MEMORY_AVAILABLE;
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
|
|
||||||
#define MULTIBOOT_MAGIC 0x36d76289
|
#define MULTIBOOT_MAGIC 0x36d76289
|
||||||
|
|
||||||
unsigned char multiboot_parse(struct KernelMQ_Info *kinfo, unsigned long addr);
|
unsigned char multiboot_parse(struct KernelMQ_Info *kinfo, unsigned long base);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue