mirror of
https://git.stationery.faith/corn/corn.git
synced 2024-11-21 18:32:20 +00:00
update makefile
This commit is contained in:
parent
192a4ccd6b
commit
341c95f535
4 changed files with 49 additions and 35 deletions
22
Makefile
22
Makefile
|
@ -7,6 +7,7 @@ ISO_NAME=os_image.iso
|
|||
|
||||
CC=cc
|
||||
LD=ld
|
||||
AS=nasm
|
||||
|
||||
CFLAGS+=-std=c2x -ffreestanding -fno-stack-protector -g -Wall -Wextra -pedantic -lgcc -isystem $(INCLUDE_DIR)
|
||||
CFLAGS+=-DPAGE_SIZE=4096
|
||||
|
@ -27,29 +28,34 @@ A_OBJ=$(patsubst %.S,$(BUILD_DIR)/%.S.o,$(A_SRC))
|
|||
all: $(BUILD_DIR)/$(ISO_NAME)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)/*
|
||||
@printf "\033[31m RM \033[0m%s\n" $(BUILD_DIR)
|
||||
@rm -rf $(BUILD_DIR)/*
|
||||
|
||||
$(A_OBJ): $(BUILD_DIR)/%.S.o : %.S
|
||||
@mkdir -p $(@D)
|
||||
nasm $< -f elf64 -o $@
|
||||
@printf "\033[33m AS \033[0m%s\n" $<
|
||||
@nasm $< -f elf64 -o $@
|
||||
|
||||
$(C_OBJ): $(BUILD_DIR)/%.o : %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
@printf "\033[34m CC \033[0m%s\n" $<
|
||||
@$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/$(K_BIN_NAME): arch/amd64/linker.ld $(A_OBJ) $(C_OBJ) $(H_SRC) $(H_INCLUDE)
|
||||
@mkdir -p $(@D)
|
||||
$(LD) $(LDFLAGS) -T arch/amd64/linker.ld -o $(BUILD_DIR)/$(K_BIN_NAME) $(A_OBJ) $(C_OBJ)
|
||||
@printf "\033[32m LD \033[0m%s\n" $@
|
||||
@$(LD) $(LDFLAGS) --no-warn-rwx-segments -T arch/amd64/linker.ld -o $(BUILD_DIR)/$(K_BIN_NAME) $(A_OBJ) $(C_OBJ)
|
||||
|
||||
$(BUILD_DIR)/$(ISO_NAME): $(BUILD_DIR)/$(K_BIN_NAME) grub.cfg
|
||||
@mkdir -p $(@D)
|
||||
@mkdir -p $(BUILD_DIR)/iso/boot/grub
|
||||
cp grub.cfg $(BUILD_DIR)/iso/boot/grub
|
||||
cp $(BUILD_DIR)/$(K_BIN_NAME) $(BUILD_DIR)/iso/boot
|
||||
grub-mkrescue -o $(BUILD_DIR)/$(ISO_NAME) $(BUILD_DIR)/iso
|
||||
@cp grub.cfg $(BUILD_DIR)/iso/boot/grub
|
||||
@cp $(BUILD_DIR)/$(K_BIN_NAME) $(BUILD_DIR)/iso/boot
|
||||
@printf "\033[35m ISO \033[0m%s\n" $(BUILD_DIR)/$(ISO_NAME)
|
||||
@grub-mkrescue -o $(BUILD_DIR)/$(ISO_NAME) $(BUILD_DIR)/iso 2> /dev/null
|
||||
|
||||
run: all
|
||||
qemu-system-x86_64 \
|
||||
@qemu-system-x86_64 \
|
||||
-cdrom $(BUILD_DIR)/$(ISO_NAME) \
|
||||
-serial stdio \
|
||||
-display gtk,show-menubar=off,zoom-to-fit=on \
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
ENTRY(start)
|
||||
|
||||
SECTIONS {
|
||||
. = 1M;
|
||||
|
||||
kernel_start = .;
|
||||
. = 1M;
|
||||
|
||||
.boot BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.multiboot)
|
||||
}
|
||||
kernel_start = .;
|
||||
|
||||
.rodata BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.rodata)
|
||||
}
|
||||
.boot BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.multiboot)
|
||||
}
|
||||
|
||||
.data BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.data)
|
||||
}
|
||||
.rodata BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.rodata)
|
||||
}
|
||||
|
||||
text_start = .;
|
||||
.data BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.data)
|
||||
}
|
||||
|
||||
.text BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.text)
|
||||
}
|
||||
text_start = .;
|
||||
|
||||
text_end = .;
|
||||
.text BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.text)
|
||||
}
|
||||
|
||||
.bss BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.bss)
|
||||
}
|
||||
text_end = .;
|
||||
|
||||
kernel_end = .;
|
||||
.bss BLOCK(4K) : ALIGN(4K)
|
||||
{
|
||||
*(.bss)
|
||||
}
|
||||
|
||||
kernel_end = .;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,8 @@ load_pml4(
|
|||
void *phys
|
||||
) {
|
||||
static struct pte *pt = &paging_pt[0];
|
||||
if ((uint64_t)phys >> 12 == pt->address)
|
||||
return;
|
||||
pt->address = (uint64_t)phys >> 12;
|
||||
pt->flags = F_PRESENT | F_WRITEABLE;
|
||||
invlpg(pml4_mapped);
|
||||
|
@ -98,6 +100,8 @@ load_pdpt(
|
|||
void *phys
|
||||
) {
|
||||
static struct pte *pt = &paging_pt[1];
|
||||
if ((uint64_t)phys >> 12 == pt->address)
|
||||
return;
|
||||
pt->address = (uint64_t)phys >> 12;
|
||||
pt->flags = F_PRESENT | F_WRITEABLE;
|
||||
invlpg(pdpt_mapped);
|
||||
|
@ -108,6 +112,8 @@ load_pd(
|
|||
void *phys
|
||||
) {
|
||||
static struct pte *pt = &paging_pt[2];
|
||||
if ((uint64_t)phys >> 12 == pt->address)
|
||||
return;
|
||||
pt->address = (uint64_t)phys >> 12;
|
||||
pt->flags = F_PRESENT | F_WRITEABLE;
|
||||
invlpg(pdpt_mapped);
|
||||
|
@ -118,6 +124,8 @@ load_pt(
|
|||
void *phys
|
||||
) {
|
||||
static struct pte *pt = &paging_pt[3];
|
||||
if ((uint64_t)phys >> 12 == pt->address)
|
||||
return;
|
||||
pt->address = (uint64_t)phys >> 12;
|
||||
pt->flags = F_PRESENT | F_WRITEABLE;
|
||||
invlpg(pt_mapped);
|
||||
|
|
|
@ -16,7 +16,7 @@ void kmain(struct boot_info *info) {
|
|||
*(char*)(0xB8000 + 0x146) = 'i';
|
||||
|
||||
while (1) {
|
||||
//kprintf("ret: 0x%p\n", kalloc(2));
|
||||
//kprintf("ret: 0x%p\n", kalloc(1024));
|
||||
// loop so we dont halt
|
||||
// this allows interrupts to fire
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue