Init
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
iso_root
|
||||||
|
mop3.iso
|
||||||
|
bochs-log.txt
|
||||||
|
bochs-com1.txt
|
||||||
9
Makefile
Normal file
9
Makefile
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
platform ?= amd64
|
||||||
|
|
||||||
|
all_kernel:
|
||||||
|
make -C kernel platform=$(platform) all
|
||||||
|
|
||||||
|
clean_kernel:
|
||||||
|
make -C kernel platform=$(platform) clean
|
||||||
|
|
||||||
|
.PHONY: all_kernel clean_kernel
|
||||||
3
aux/bochs_amd64.sh
Executable file
3
aux/bochs_amd64.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
bochs -f aux/bochsrc.txt -q
|
||||||
21
aux/bochsrc.txt
Normal file
21
aux/bochsrc.txt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
cpu: model=p4_prescott_celeron_336
|
||||||
|
|
||||||
|
memory: guest=4096 host=2048
|
||||||
|
|
||||||
|
romimage: file=/usr/share/bochs/BIOS-bochs-latest, options=fastboot
|
||||||
|
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest.bin
|
||||||
|
|
||||||
|
ata0: enabled=1
|
||||||
|
ata0-master: type=cdrom, path=mop3.iso, status=inserted
|
||||||
|
com1: enabled=1, mode=file, dev=bochs-com1.txt
|
||||||
|
|
||||||
|
boot: cdrom
|
||||||
|
|
||||||
|
error: action=report
|
||||||
|
panic: action=report
|
||||||
|
info: action=report
|
||||||
|
debug: action=ignore
|
||||||
|
|
||||||
|
log: bochs-log.txt
|
||||||
|
|
||||||
|
display_library: x
|
||||||
19
aux/limine_iso_amd64.sh
Executable file
19
aux/limine_iso_amd64.sh
Executable file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
make -C boot/limine
|
||||||
|
mkdir -p iso_root/boot/limine
|
||||||
|
mkdir -p iso_root/EFI/BOOT
|
||||||
|
|
||||||
|
cp -v kernel/build/kernel.elf iso_root/boot
|
||||||
|
cp -v boot/limine/limine-bios.sys boot/limine/limine-bios-cd.bin \
|
||||||
|
boot/limine/limine-uefi-cd.bin boot/limine.conf iso_root/boot/limine
|
||||||
|
|
||||||
|
cp -v boot/limine/BOOTX64.EFI boot/limine/BOOTIA32.EFI iso_root/EFI/BOOT
|
||||||
|
|
||||||
|
xorriso -as mkisofs -R -r -J -b boot/limine/limine-bios-cd.bin \
|
||||||
|
-no-emul-boot -boot-load-size 4 -boot-info-table -hfsplus \
|
||||||
|
-apm-block-size 2048 --efi-boot boot/limine/limine-uefi-cd.bin \
|
||||||
|
-efi-boot-part --efi-boot-image --protective-msdos-label \
|
||||||
|
iso_root -o mop3.iso
|
||||||
|
|
||||||
|
boot/limine/limine bios-install mop3.iso
|
||||||
1
boot/limine
Submodule
1
boot/limine
Submodule
Submodule boot/limine added at f777d332c6
5
boot/limine.conf
Normal file
5
boot/limine.conf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
timeout: 10
|
||||||
|
|
||||||
|
/mop3
|
||||||
|
protocol: limine
|
||||||
|
path: boot():/boot/kernel.elf
|
||||||
26
kernel/Makefile
Normal file
26
kernel/Makefile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
cc := clang
|
||||||
|
o :=
|
||||||
|
c :=
|
||||||
|
ldflags :=
|
||||||
|
cflags :=
|
||||||
|
buildtype ?= release
|
||||||
|
|
||||||
|
include $(platform)/src.mk
|
||||||
|
include $(platform)/flags.mk
|
||||||
|
include generic/flags.mk
|
||||||
|
|
||||||
|
all: build/kernel.elf
|
||||||
|
|
||||||
|
build/kernel.elf: $(o)
|
||||||
|
$(cc) -o $@ $(ldflags) -T $(platform)/link.ld $^
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
$(cc) -c -o $@ $(cflags) $<
|
||||||
|
|
||||||
|
%.o: %.S
|
||||||
|
$(cc) -c -o $@ $(cflags) $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(o) build/kernel.elf
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
1
kernel/amd64/.gitignore
vendored
Normal file
1
kernel/amd64/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.o
|
||||||
4
kernel/amd64/bootmain.c
Normal file
4
kernel/amd64/bootmain.c
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
void bootmain(void) {
|
||||||
|
for (;;);
|
||||||
|
}
|
||||||
3
kernel/amd64/flags.mk
Normal file
3
kernel/amd64/flags.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
cflags += --target=x86_64-pc-none-elf
|
||||||
|
|
||||||
|
ldflags += --target=x86_64-pc-none-elf
|
||||||
51
kernel/amd64/link.ld
Normal file
51
kernel/amd64/link.ld
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
OUTPUT_FORMAT(elf64-x86-64)
|
||||||
|
|
||||||
|
ENTRY(bootmain)
|
||||||
|
|
||||||
|
PHDRS {
|
||||||
|
limine_requests PT_LOAD;
|
||||||
|
text PT_LOAD;
|
||||||
|
rodata PT_LOAD;
|
||||||
|
data PT_LOAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS {
|
||||||
|
. = 0xffffffff80000000;
|
||||||
|
|
||||||
|
.limine_requests : {
|
||||||
|
KEEP(*(.limine_requests_start))
|
||||||
|
KEEP(*(.limine_requests))
|
||||||
|
KEEP(*(.limine_requests_end))
|
||||||
|
} :limine_requests
|
||||||
|
|
||||||
|
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
|
||||||
|
.text : {
|
||||||
|
*(.text .text.*)
|
||||||
|
} :text
|
||||||
|
|
||||||
|
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
|
||||||
|
.rodata : {
|
||||||
|
*(.rodata .rodata.*)
|
||||||
|
} :rodata
|
||||||
|
|
||||||
|
.note.gnu.build-id : {
|
||||||
|
*(.note.gnu.build-id)
|
||||||
|
} :rodata
|
||||||
|
|
||||||
|
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
*(.data .data.*)
|
||||||
|
} :data
|
||||||
|
|
||||||
|
.bss : {
|
||||||
|
*(.bss .bss.*)
|
||||||
|
} :data
|
||||||
|
|
||||||
|
/DISCARD/ : {
|
||||||
|
*(.eh_frame*)
|
||||||
|
*(.note .note.*)
|
||||||
|
}
|
||||||
|
}
|
||||||
3
kernel/amd64/src.mk
Normal file
3
kernel/amd64/src.mk
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
c += amd64/bootmain.c
|
||||||
|
|
||||||
|
o += amd64/bootmain.o
|
||||||
32
kernel/generic/flags.mk
Normal file
32
kernel/generic/flags.mk
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
cflags += -nostdinc \
|
||||||
|
-nostdlib \
|
||||||
|
-ffreestanding \
|
||||||
|
-fno-builtin \
|
||||||
|
-std=c11 \
|
||||||
|
-pedantic \
|
||||||
|
-Wall \
|
||||||
|
-Wextra
|
||||||
|
|
||||||
|
ifeq ($(buildtype),debug)
|
||||||
|
cflags += -O0 -g
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(buildtype),release)
|
||||||
|
cflags += -ffunction-sections -fdata-sections -Oz
|
||||||
|
endif
|
||||||
|
|
||||||
|
ldflags += -ffreestanding \
|
||||||
|
-nostdlib \
|
||||||
|
-fno-builtin \
|
||||||
|
-fuse-ld=lld \
|
||||||
|
-static
|
||||||
|
|
||||||
|
ifeq ($(buildtype),debug)
|
||||||
|
ldflags += -g
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(buildtype),release)
|
||||||
|
ldflags += -Wl,--gc-sections \
|
||||||
|
-Wl,--strip-all \
|
||||||
|
-flto
|
||||||
|
endif
|
||||||
Reference in New Issue
Block a user