mirror of
https://github.com/tailix/kernel.git
synced 2025-04-14 17:33:13 -04:00
Only support Multiboot 2 because of modules
This commit is contained in:
parent
c354930e2f
commit
5bfc7f3746
9 changed files with 24 additions and 48 deletions
3
Makefile
3
Makefile
|
@ -4,9 +4,6 @@ all: all-kernel all-iso
|
|||
|
||||
clean: clean-iso clean-kernel
|
||||
|
||||
run-kernel:
|
||||
make run -C arch I=$(shell pwd)/include
|
||||
|
||||
all-kernel:
|
||||
make all -C arch I=$(shell pwd)/include
|
||||
|
||||
|
|
|
@ -7,10 +7,7 @@ CCPREFIX = i686-elf-
|
|||
AS = $(CCPREFIX)as
|
||||
CC = $(CCPREFIX)gcc
|
||||
|
||||
OBJS = boot.s.o main.c.o logger.c.o console.c.o gdt.c.o gdt.asm.o idt.c.o idt.asm.o isr.c.o isr.asm.o multiboot2.c.o
|
||||
|
||||
run: kernel
|
||||
qemu-system-i386 -kernel kernel -d guest_errors
|
||||
OBJS = boot.s.o main.c.o logger.c.o console.c.o gdt.c.o gdt.asm.o idt.c.o idt.asm.o isr.c.o isr.asm.o multiboot.c.o
|
||||
|
||||
all: kernel
|
||||
|
||||
|
@ -19,7 +16,6 @@ clean:
|
|||
|
||||
kernel: $(OBJS)
|
||||
$(CC) -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $(OBJS)
|
||||
grub-file --is-x86-multiboot $@
|
||||
grub-file --is-x86-multiboot2 $@
|
||||
|
||||
%.c.o: %.c
|
||||
|
|
28
arch/boot.s
28
arch/boot.s
|
@ -1,27 +1,17 @@
|
|||
.set MULTIBOOT_1_MAGIC, 0x1BADB002
|
||||
.set MULTIBOOT_1_FLAGS, (1 << 0) | (1 << 1) // Align, meminfo
|
||||
.set MULTIBOOT_1_CHECKSUM, -(MULTIBOOT_1_MAGIC + MULTIBOOT_1_FLAGS)
|
||||
.set MULTIBOOT_MAGIC, 0xE85250D6
|
||||
.set MULTIBOOT_ARCH, 0
|
||||
.set MULTIBOOT_LENGTH, 16 + 8
|
||||
.set MULTIBOOT_CHECKSUM, -(MULTIBOOT_MAGIC + MULTIBOOT_ARCH + MULTIBOOT_LENGTH)
|
||||
|
||||
.set MULTIBOOT_2_MAGIC, 0xE85250D6
|
||||
.set MULTIBOOT_2_ARCH, 0
|
||||
.set MULTIBOOT_2_LENGTH, 16 + 8
|
||||
.set MULTIBOOT_2_CHECKSUM, -(MULTIBOOT_2_MAGIC + MULTIBOOT_2_ARCH + MULTIBOOT_2_LENGTH)
|
||||
|
||||
.section .multiboot2
|
||||
.section .multiboot
|
||||
.align 4
|
||||
.long MULTIBOOT_2_MAGIC
|
||||
.long MULTIBOOT_2_ARCH
|
||||
.long MULTIBOOT_2_LENGTH
|
||||
.long MULTIBOOT_2_CHECKSUM
|
||||
.long MULTIBOOT_MAGIC
|
||||
.long MULTIBOOT_ARCH
|
||||
.long MULTIBOOT_LENGTH
|
||||
.long MULTIBOOT_CHECKSUM
|
||||
.long 0
|
||||
.long 8
|
||||
|
||||
.section .multiboot1
|
||||
.align 4
|
||||
.long MULTIBOOT_1_MAGIC
|
||||
.long MULTIBOOT_1_FLAGS
|
||||
.long MULTIBOOT_1_CHECKSUM
|
||||
|
||||
.section .bss
|
||||
.align 16
|
||||
stack_bottom:
|
||||
|
|
|
@ -6,8 +6,7 @@ SECTIONS
|
|||
|
||||
.text BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.multiboot2)
|
||||
*(.multiboot1)
|
||||
*(.multiboot)
|
||||
*(.text)
|
||||
}
|
||||
|
||||
|
|
16
arch/main.c
16
arch/main.c
|
@ -1,7 +1,7 @@
|
|||
#include <kernelmq/multiboot.h>
|
||||
|
||||
#include "logger.h"
|
||||
#include "multiboot2.h"
|
||||
#include "multiboot.h"
|
||||
#include "gdt.h"
|
||||
#include "idt.h"
|
||||
|
||||
|
@ -9,15 +9,17 @@ void main(unsigned int multiboot_magic, unsigned long multiboot_info)
|
|||
{
|
||||
logger_initialize();
|
||||
|
||||
if (multiboot_magic == KERNELMQ_MULTIBOOT_1_MAGIC) {
|
||||
logger_info("Loaded with Multiboot-compliant bootloader, specification version 1.");
|
||||
}
|
||||
else if (multiboot_magic == KERNELMQ_MULTIBOOT_2_MAGIC) {
|
||||
if (multiboot_magic == KERNELMQ_MULTIBOOT_2_MAGIC) {
|
||||
logger_info("Loaded with Multiboot-compliant bootloader, specification version 2.");
|
||||
print_multiboot2_info(multiboot_info);
|
||||
print_multiboot_info(multiboot_info);
|
||||
}
|
||||
else if (multiboot_magic == KERNELMQ_MULTIBOOT_1_MAGIC) {
|
||||
logger_fail("Loaded with Multiboot-compliant bootloader, but specification version 1.");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
logger_warn("Loaded with no Multiboot-compliant bootloader.");
|
||||
logger_fail("Loaded with no Multiboot-compliant bootloader.");
|
||||
return;
|
||||
}
|
||||
|
||||
logger_info("Kernel initialization started.");
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "multiboot2.h"
|
||||
#include "multiboot.h"
|
||||
|
||||
#include "console.h"
|
||||
|
||||
static void itoa(char *buf, int base, int d);
|
||||
static void printf(const char *format, ...);
|
||||
|
||||
void print_multiboot2_info(unsigned long addr)
|
||||
void print_multiboot_info(unsigned long addr)
|
||||
{
|
||||
struct multiboot_tag *tag;
|
||||
unsigned size;
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef MULTIBOOT_HEADER
|
||||
#define MULTIBOOT_HEADER 1
|
||||
|
||||
void print_multiboot2_info(unsigned long addr);
|
||||
void print_multiboot_info(unsigned long addr);
|
||||
|
||||
/*
|
||||
* How many bytes from the start of the file we search for the header.
|
|
@ -2,10 +2,6 @@ ifneq (ok, $(shell test -f '$(K)' && echo 'ok'))
|
|||
$(error 'Kernel "$(K)" does not exist')
|
||||
endif
|
||||
|
||||
ifneq (ok, $(shell grub-file --is-x86-multiboot '$(K)' && echo 'ok'))
|
||||
$(error 'Kernel "$(K)" is not compliant with Multiboot 1')
|
||||
endif
|
||||
|
||||
ifneq (ok, $(shell grub-file --is-x86-multiboot2 '$(K)' && echo 'ok'))
|
||||
$(error 'Kernel "$(K)" is not compliant with Multiboot 2')
|
||||
endif
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
menuentry "KernelMQ, multiboot 1" {
|
||||
multiboot /boot/kernelmq
|
||||
}
|
||||
|
||||
menuentry "KernelMQ, multiboot 2" {
|
||||
menuentry "KernelMQ" {
|
||||
multiboot2 /boot/kernelmq
|
||||
module2 /boot/grub/grub.cfg qwe rty
|
||||
module2 /boot/kernelmq foo bar
|
||||
|
|
Loading…
Add table
Reference in a new issue