changed to x86

This commit is contained in:
rami 2024-06-25 21:43:07 -04:00
parent 01c693cd17
commit 34687780df
4 changed files with 10 additions and 14 deletions

View File

@ -1,8 +1,8 @@
CC = x86_64-elf-gcc CC = i686-elf-gcc
AS = nasm AS = nasm
BUILDDIR := build BUILDDIR := build
CFLAGS := -ffreestanding -Wall -Wextra -Werror -mno-red-zone CFLAGS := -ffreestanding -Wall -Wextra -Werror
LDFLAGS := -ffreestanding -nostdlib -lgcc -T kernel/kernel.ld LDFLAGS := -ffreestanding -nostdlib -lgcc -T kernel/kernel.ld
KSRC := $(wildcard kernel/*.asm kernel/*.c) KSRC := $(wildcard kernel/*.asm kernel/*.c)
@ -14,7 +14,7 @@ KIMG := kernel.bin
$(BUILDDIR)/$(KIMG): $(KOBJ) $(BUILDDIR)/$(KIMG): $(KOBJ)
$(CC) $^ -o $@ $(LDFLAGS) $(CC) $^ -o $@ $(LDFLAGS)
$(BUILDDIR)/%.o: */%.asm $(BUILDDIR)/%.o: */%.asm
$(AS) -felf64 $^ -o $@ $(AS) -felf32 $^ -o $@
$(BUILDDIR)/%.o: */%.c $(BUILDDIR)/%.o: */%.c
$(CC) $(CFLAGS) -c $^ -o $@ $(CC) $(CFLAGS) -c $^ -o $@
@ -26,7 +26,7 @@ $(BUILDDIR)/Hazel.iso: kernel
iso: $(BUILDDIR)/Hazel.iso iso: $(BUILDDIR)/Hazel.iso
qemu: iso qemu: iso
qemu-system-x86_64 -cdrom $(BUILDDIR)/Hazel.iso qemu-system-i386 -cdrom $(BUILDDIR)/Hazel.iso
clean: clean:
rm build/* boot/*.bin rm build/* boot/*.bin

View File

@ -1,5 +1,5 @@
default=0 default=0
timeout=0 timeout=0
menuentry "Hazel" { menuentry "Hazel" {
multiboot2 /boot/kernel.bin multiboot /boot/kernel.bin
} }

View File

@ -1,14 +1,10 @@
%define MAGIC 0xE85250D6 %define MAGIC 0x1BADB002
%define ARCH 0x0 %define FLAGS 0x0
%define LEN (multiboot_end - multiboot_start)
section .multiboot section .multiboot
multiboot_start:
dd MAGIC dd MAGIC
dd ARCH dd FLAGS
dd LEN dd -(MAGIC + FLAGS)
dd -(MAGIC + ARCH + LEN)
multiboot_end:
section .text section .text
global _start global _start

View File

@ -17,7 +17,7 @@ SECTIONS
memory which is verified to be available by the firmware, in order to memory which is verified to be available by the firmware, in order to
work around this issue. This does not use that feature, so 2M was work around this issue. This does not use that feature, so 2M was
chosen as a safer option than the traditional 1M. */ chosen as a safer option than the traditional 1M. */
. = 2M; . = 1M;
/* First put the multiboot header, as it is required to be put very early /* First put the multiboot header, as it is required to be put very early
in the image or the bootloader won't recognize the file format. in the image or the bootloader won't recognize the file format.