mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 13:48:21 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
CSOURCES= $(shell find -name *.c)
|
||||
ASMSOURCES= $(shell find -name *.asm)
|
||||
OBJS=$(CSOURCES:.c=.o) $(ASMSOURCES:.asm=.asmo)
|
||||
TARGET=x86-64
|
||||
INCDIR=$(shell pwd)/include
|
||||
ARCHDIR=$(shell pwd)/arch/$(TARGET)/
|
||||
LDFLAGS=-ffreestanding -nostdlib -lgcc -Wl,-T,"$(ARCHDIR)/kernel.ld" -debug
|
||||
CFLAGS=-ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -nostdlib -nostdinc -I "${INCDIR}"
|
||||
ASFLAGS=-felf64
|
||||
|
||||
astral: $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o $@ $^
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.asmo: %.asm
|
||||
nasm $(ASFLAGS) -o $@ $<
|
||||
@@ -0,0 +1,45 @@
|
||||
OUTPUT_FORMAT(elf64-x86-64)
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
||||
ENTRY(kernel_entry)
|
||||
|
||||
PHDRS
|
||||
{
|
||||
text PT_LOAD FLAGS((1 << 0) | (1 <<2)) ;
|
||||
rodata PT_LOAD FLAGS((1 << 2)) ;
|
||||
data PT_LOAD FLAGS((1 << 1) | (1 << 2));
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = 0xffffffff80000000;
|
||||
_text_start = .;
|
||||
|
||||
.text : {
|
||||
*(.text .text.*);
|
||||
} :text
|
||||
|
||||
. = ALIGN(4K);
|
||||
_text_end = .;
|
||||
_rodata_start = .;
|
||||
.rodata : {
|
||||
*(.rodata .rodata.*);
|
||||
} :rodata
|
||||
|
||||
. = ALIGN(4K);
|
||||
_rodata_end = .;
|
||||
_data_start = .;
|
||||
|
||||
data : {
|
||||
*(.data .data.*);
|
||||
} :data
|
||||
|
||||
.bss : {
|
||||
*(COMMON)
|
||||
*(.bss .bss.*)
|
||||
} :data
|
||||
|
||||
. = ALIGN(4K);
|
||||
|
||||
_data_end = .;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
void kernel_entry() {
|
||||
asm("cli");
|
||||
asm("hlt");
|
||||
}
|
||||
Reference in New Issue
Block a user