From f263bfb63f10a0c83f0df3337f9b7319d083ae80 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 27 Sep 2020 12:31:21 +0300 Subject: [PATCH] boot: use yboot2-proto instead of yboot2 itself --- .gitmodules | 3 +++ arch/amd64/boot/yboot.S | 2 +- arch/amd64/boot/yboot_data.c | 27 ++++++++++++++++++--------- arch/amd64/kernel.c | 18 ++++++++++-------- boot/yboot2-proto | 1 + include/arch/amd64/boot/yboot.h | 4 ++-- 6 files changed, 35 insertions(+), 20 deletions(-) create mode 160000 boot/yboot2-proto diff --git a/.gitmodules b/.gitmodules index e69de29..bdf80d5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "boot/yboot2-proto"] + path = boot/yboot2-proto + url = https://git.alnyan.me/yggdrasil/yboot2-proto diff --git a/arch/amd64/boot/yboot.S b/arch/amd64/boot/yboot.S index 9ff852b..8959582 100644 --- a/arch/amd64/boot/yboot.S +++ b/arch/amd64/boot/yboot.S @@ -1,6 +1,6 @@ #include // For loader magic -#include +#include .section .text .global _entry_yboot diff --git a/arch/amd64/boot/yboot_data.c b/arch/amd64/boot/yboot_data.c index 5d5f0b3..3c2a8e0 100644 --- a/arch/amd64/boot/yboot_data.c +++ b/arch/amd64/boot/yboot_data.c @@ -2,17 +2,26 @@ char yboot_memory_map_data[32768]; -struct yboot_v1 yboot_data __attribute__((section(".data.boot, \"aw\", %progbits //"))) = { - .header = { - .kernel_magic = YB_KERNEL_MAGIC_V1 +struct yb_proto_v1 yboot_data __attribute__((section(".data.boot, \"aw\", %progbits //"))) = { + .hdr = { + .kernel_magic = YB_KERNEL_MAGIC_V1A }, - + .flags = 0 #if defined(VESA_ENABLE) - .video_width = VESA_WIDTH, - .video_height = VESA_HEIGHT, - .video_format = YB_VIDEO_FORMAT_BGR32, + | YB_FLAG_VIDEO #endif + | YB_FLAG_INITRD + | YB_FLAG_UPPER, - .memory_map_data = (uint64_t) yboot_memory_map_data - 0xFFFFFF0000000000, - .memory_map_size = sizeof(yboot_memory_map_data) + .memory_map = { + .address = (uint64_t) yboot_memory_map_data - 0xFFFFFF0000000000, + .size = sizeof(yboot_memory_map_data) + }, +#if defined(VESA_ENABLE) + .video = { + .width = VESA_WIDTH, + .height = VESA_HEIGHT, + .format = YB_LFB_BGR32, + }, +#endif }; diff --git a/arch/amd64/kernel.c b/arch/amd64/kernel.c index 2808dbf..01caca8 100644 --- a/arch/amd64/kernel.c +++ b/arch/amd64/kernel.c @@ -153,12 +153,12 @@ static void entry_yboot(void) { kinfo("Provided command line: \"%s\"\n", yboot_data.cmdline); kernel_set_cmdline(yboot_data.cmdline); - if (yboot_data.video_framebuffer) { - boot_video_info.width = yboot_data.video_width; - boot_video_info.height = yboot_data.video_height; + if ((yboot_data.flags & YB_FLAG_VIDEO) && yboot_data.video.framebuffer) { + boot_video_info.width = yboot_data.video.width; + boot_video_info.height = yboot_data.video.height; boot_video_info.bpp = 32; - boot_video_info.pitch = yboot_data.video_pitch; - boot_video_info.framebuffer_phys = yboot_data.video_framebuffer; + boot_video_info.pitch = yboot_data.video.pitch; + boot_video_info.framebuffer_phys = yboot_data.video.framebuffer; } if (yboot_data.initrd_base) { @@ -168,9 +168,11 @@ static void entry_yboot(void) { } phys_memory_map.format = MM_PHYS_MMAP_FMT_YBOOT; - phys_memory_map.address = (void *) MM_VIRTUALIZE(yboot_data.memory_map_data); - phys_memory_map.entry_size = yboot_data.memory_map_entsize; - phys_memory_map.entry_count = yboot_data.memory_map_size / yboot_data.memory_map_entsize; + phys_memory_map.address = (void *) MM_VIRTUALIZE(yboot_data.memory_map.address); + extern char yboot_memory_map_data[]; + _assert((void *) MM_VIRTUALIZE(yboot_data.memory_map.address) == yboot_memory_map_data); + phys_memory_map.entry_size = yboot_data.memory_map.entsize; + phys_memory_map.entry_count = yboot_data.memory_map.size / yboot_data.memory_map.entsize; } void kernel_early_init(uint64_t entry_method) { diff --git a/boot/yboot2-proto b/boot/yboot2-proto new file mode 160000 index 0000000..f9c0ad1 --- /dev/null +++ b/boot/yboot2-proto @@ -0,0 +1 @@ +Subproject commit f9c0ad12f7d225a99b7a3c31417576fcd46d8b7a diff --git a/include/arch/amd64/boot/yboot.h b/include/arch/amd64/boot/yboot.h index e3c4eee..a557938 100644 --- a/include/arch/amd64/boot/yboot.h +++ b/include/arch/amd64/boot/yboot.h @@ -1,4 +1,4 @@ #pragma once -#include +#include -extern struct yboot_v1 yboot_data; +extern struct yb_proto_v1 yboot_data;