Fix issues with ASM
This commit is contained in:
parent
f5dc9b961b
commit
81d4d93c12
|
@ -1,29 +1,31 @@
|
|||
MBOOT_ALIGN equ <<0
|
||||
MBOOT_ALIGN equ 1<<0
|
||||
MBOOT_MEMINFO equ 1<<1
|
||||
MBOOT_FLAGS equ MBOOT_ALIGN | MBOOT_MEMINFO
|
||||
MBOOT_MAGIC equ 0x1BADB002
|
||||
MBOOT_CHECKSUM equ -(MAGIC + FLAGS)
|
||||
MBOOT_CHECKSUM equ -(MBOOT_MAGIC + MBOOT_FLAGS)
|
||||
|
||||
[BITS 32]
|
||||
|
||||
[GLOBAL mboot]
|
||||
|
||||
[EXTERN code]
|
||||
[EXTERN bss]
|
||||
[EXTERN end]
|
||||
[SECTION .multiboot]
|
||||
ALIGN 4
|
||||
mboot:
|
||||
dd MBOOT_MAGIC
|
||||
dd MBOOT_FLAGS
|
||||
dd mboot
|
||||
dd code
|
||||
dd bss
|
||||
dd end
|
||||
dd start
|
||||
dd MBOOT_CHECKSUM
|
||||
|
||||
[GLOBAL start]
|
||||
SECTION .bss
|
||||
ALIGN 16
|
||||
stack_bottom:
|
||||
RESB 16384
|
||||
stack_top:
|
||||
|
||||
|
||||
SECTION .text
|
||||
[GLOBAL _start]
|
||||
[EXTERN kernel_main]
|
||||
|
||||
start:
|
||||
_start:
|
||||
push ebx
|
||||
|
||||
cli
|
||||
|
@ -31,7 +33,7 @@ start:
|
|||
jmp $
|
||||
|
||||
[GLOBAL load_gdt] ; Allows the C code to call gdt_flush().
|
||||
[EXTERN gp]
|
||||
|
||||
load_gdt:
|
||||
mov eax, [esp+4] ; Get the pointer to the GDT, passed as a parameter.
|
||||
lgdt [eax] ; Load the new GDT pointer
|
||||
|
@ -176,6 +178,7 @@ irq_common:
|
|||
add esp, 8
|
||||
iret
|
||||
|
||||
[GLOBAL idt_load]
|
||||
idt_load:
|
||||
mov eax, [esp+4]
|
||||
lidt [eax]
|
||||
|
|
|
@ -5,7 +5,5 @@ KERNEL_ARCH_LIBS=
|
|||
|
||||
KERNEL_ARCH_OBJS= \
|
||||
$(ARCHDIR)/boot.o \
|
||||
$(ARCHDIR)/gdt.o \
|
||||
$(ARCHDIR)/isr.o \
|
||||
$(ARCHDIR)/sys_clock.o \
|
||||
$(ARCHDIR)/tty.o
|
25
makefile
25
makefile
|
@ -2,7 +2,7 @@ DEFAULT_HOST:=i686-elf
|
|||
HOST?=DEFAULT_HOST
|
||||
HOSTARCH:=i386
|
||||
|
||||
CFLAGS?= -O2 -g
|
||||
CFLAGS?= -O2 -g -m32 -no-pie
|
||||
CPPFLAGS?=
|
||||
LDFLAGS?=
|
||||
LIBS?=
|
||||
|
@ -13,7 +13,7 @@ EXEC_PREFIX?=$(PREFIX)
|
|||
BOOTDIR?=$(EXEC_PREFIX)/boot
|
||||
INCLUDEDIR?=$(PREFIX)/include
|
||||
|
||||
CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra
|
||||
CFLAGS:=$(CFLAGS) -ffreestanding -Wall -Wextra -I"../include" -I"../../include"
|
||||
CPPFLAGS:=$(CPPFLAGS) -D__is_kernel -Iinclude
|
||||
LDFLAGS:=$(LDFLAGS)
|
||||
LIBS:=$(LIBS) -nostdlib -lgcc
|
||||
|
@ -36,20 +36,12 @@ kernel/idt.o \
|
|||
kernel/kernel.o
|
||||
|
||||
OBJS=\
|
||||
$(ARCHDIR)/crti.o \
|
||||
$(ARCHDIR)/crtbegin.o \
|
||||
$(KERNEL_OBJS) \
|
||||
$(ARCHDIR)/crtend.o \
|
||||
$(ARCHDIR)/crtn.o
|
||||
$(KERNEL_OBJS)
|
||||
|
||||
LINK_LIST=\
|
||||
$(LDFLAGS) \
|
||||
$(ARCHDIR)/crti.o \
|
||||
$(ARCHDIR)/crtbegin.o \
|
||||
$(KERNEL_OBJS) \
|
||||
$(LIBS) \
|
||||
$(ARCHDIR)/crtend.o \
|
||||
$(ARCHDIR)/crtn.o
|
||||
|
||||
.PHONY: all clean install install-headers install-kernel
|
||||
.SUFFIXES: .o .c .s
|
||||
|
@ -59,19 +51,10 @@ all: red.kernel
|
|||
red.kernel: $(OBJS) $(ARCHDIR)/linker.ld
|
||||
$(CC) -T $(ARCHDIR)/linker.ld -o $@ $(CFLAGS) $(LINK_LIST)
|
||||
|
||||
$(ARCHDIR)/crtbegin.o $(ARCHDIR)/crtend.o:
|
||||
OBJ=`$(CC) $(CFLAGS) $(LDFLAGS) -print-file-name=$(@F)` && cp "$$OBJ" $@
|
||||
|
||||
$(ARCHDIR)/gdt.o:
|
||||
nasm -f elf $(ARCHDIR)/gdt.s
|
||||
|
||||
$(ARCHDIR)/isr.o:
|
||||
nasm -f elf $(ARCHDIR)/isr.s
|
||||
|
||||
.c.o:
|
||||
$(CC) -MD -c $< -o $@ -std=gnu11 $(CFLAGS) $(CPPFLAGS)
|
||||
.s.o:
|
||||
$(CC) -MD -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
|
||||
nasm -f elf $< -o $@
|
||||
|
||||
clean:
|
||||
rm -f red.kernel
|
||||
|
|
Loading…
Reference in New Issue
Block a user