load some multiboot2 info after the framebuffer is initialized
This commit is contained in:
parent
db16e69d5d
commit
fa4ff5facf
@ -5,11 +5,15 @@
|
||||
|
||||
void hos_main(uint32_t mbinfo_addr)
|
||||
{
|
||||
mbinfo_init(mbinfo_addr);
|
||||
if (!mbinfo_init(mbinfo_addr))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!fb_ready())
|
||||
{
|
||||
return;
|
||||
}
|
||||
klog_init();
|
||||
klog_printf("Welcome to HOS!\n");
|
||||
mbinfo_load();
|
||||
}
|
||||
|
49
src/mbinfo.c
49
src/mbinfo.c
@ -1,10 +1,31 @@
|
||||
#include "multiboot2.h"
|
||||
#include "fb.h"
|
||||
#include "mem.h"
|
||||
#include <stdint.h>
|
||||
#include "klog.h"
|
||||
|
||||
static void mbinfo_process_tag(multiboot2_info_tag_t * tag)
|
||||
static uint32_t mbinfo[2048];
|
||||
|
||||
static void mbinfo_process_tag(const multiboot2_info_tag_t * tag)
|
||||
{
|
||||
switch (tag->type)
|
||||
{
|
||||
case MULTIBOOT2_INFO_BOOT_COMMAND_LINE:
|
||||
{
|
||||
multiboot2_info_boot_command_line_t * cl =
|
||||
(multiboot2_info_boot_command_line_t *)tag;
|
||||
klog_printf("Kernel boot command line: '%s'\n", cl->string);
|
||||
}
|
||||
break;
|
||||
|
||||
case MULTIBOOT2_INFO_BOOT_LOADER_NAME:
|
||||
{
|
||||
multiboot2_info_boot_loader_name_t * bln =
|
||||
(multiboot2_info_boot_loader_name_t *)tag;
|
||||
klog_printf("Boot loader: '%s'\n", bln->string);
|
||||
}
|
||||
break;
|
||||
|
||||
case MULTIBOOT2_INFO_FRAMEBUFFER_INFO:
|
||||
{
|
||||
multiboot2_info_framebuffer_info_t * fbinfo =
|
||||
@ -18,12 +39,34 @@ static void mbinfo_process_tag(multiboot2_info_tag_t * tag)
|
||||
}
|
||||
}
|
||||
|
||||
void mbinfo_init(uint32_t mbinfo_addr)
|
||||
static void process_tags(const multiboot2_info_tag_t * tag, bool init)
|
||||
{
|
||||
multiboot2_info_tag_t * tag = (multiboot2_info_tag_t *)(mbinfo_addr + sizeof(multiboot2_info_header_t));
|
||||
while (tag->type != 0u)
|
||||
{
|
||||
if ((init && (tag->type == MULTIBOOT2_INFO_FRAMEBUFFER_INFO)) ||
|
||||
(!init && (tag->type != MULTIBOOT2_INFO_FRAMEBUFFER_INFO)))
|
||||
{
|
||||
mbinfo_process_tag(tag);
|
||||
}
|
||||
tag = multiboot2_info_next_tag(tag);
|
||||
}
|
||||
}
|
||||
|
||||
bool mbinfo_init(uint32_t mbinfo_addr)
|
||||
{
|
||||
multiboot2_info_header_t * mbinfo_header = (multiboot2_info_header_t *)mbinfo_addr;
|
||||
if (mbinfo_header->total_size <= sizeof(mbinfo))
|
||||
{
|
||||
memcpy32(mbinfo, mbinfo_header, mbinfo_header->total_size / 4u);
|
||||
multiboot2_info_tag_t * tag = (multiboot2_info_tag_t *)(mbinfo + sizeof(multiboot2_info_header_t) / 4u);
|
||||
process_tags(tag, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void mbinfo_load(void)
|
||||
{
|
||||
multiboot2_info_tag_t * tag = (multiboot2_info_tag_t *)(mbinfo + sizeof(multiboot2_info_header_t) / 4u);
|
||||
process_tags(tag, false);
|
||||
}
|
||||
|
@ -2,7 +2,9 @@
|
||||
#define MBINFO_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
void mbinfo_init(uint32_t mbinfo_addr);
|
||||
bool mbinfo_init(uint32_t mbinfo_addr);
|
||||
void mbinfo_load(void);
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef MEM_H
|
||||
#define MEM_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
static inline void memcpy(void * dest, const void * src, size_t n)
|
||||
{
|
||||
uint32_t r0, r1, r2;
|
||||
|
@ -70,7 +70,12 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
multiboot2_info_tag_t header;
|
||||
uint8_t string[];
|
||||
char string[];
|
||||
} multiboot2_info_boot_command_line_t;
|
||||
|
||||
typedef struct {
|
||||
multiboot2_info_tag_t header;
|
||||
char string[];
|
||||
} multiboot2_info_boot_loader_name_t;
|
||||
|
||||
typedef struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user