diff options
-rw-r--r-- | Makefile | 29 | ||||
-rw-r--r-- | meson.build | 45 | ||||
-rw-r--r-- | src/asm/boot.asm (renamed from asm/boot.asm) | 0 | ||||
-rw-r--r-- | src/asm/long.asm (renamed from asm/long.asm) | 0 | ||||
-rw-r--r-- | src/nrvn.c | 10 | ||||
-rw-r--r-- | toolchain.txt | 13 | ||||
-rwxr-xr-x | util/build_iso.sh | 6 | ||||
-rw-r--r-- | util/grub.cfg | 3 | ||||
-rw-r--r-- | util/linker.ld (renamed from linker.ld) | 0 |
9 files changed, 71 insertions, 35 deletions
diff --git a/Makefile b/Makefile deleted file mode 100644 index b6abe96..0000000 --- a/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -all: outdir out/nrvn.bin - -out/nrvn.bin: out/boot.o out/nrvn.o out/long.o out/vga.o out/idt.o out/mem.o out/acpi.o out/ps2.o out/pic.o out/memory.o - x86_64-pc-elf-gcc -T linker.ld -o $@ -ffreestanding -nostdlib -lgcc $^ -g - -out/boot.o: asm/boot.asm - nasm -felf64 $^ -o $@ - -out/long.o: asm/long.asm - nasm -felf64 $^ -o $@ - -out/%.o: src/%.c - x86_64-pc-elf-gcc -c $^ -o $@ -I include -ffreestanding -Wall -Wextra -g - -iso: all - cp out/nrvn.bin grub/boot/nrvn.bin - grub-mkrescue -o out/nrvn.iso grub - -run: iso - qemu-system-x86_64 -cdrom out/nrvn.iso - -debug: all - qemu-system-x86_64 -kernel out/nrvn.bin -s -S - -outdir: - mkdir -p out - -clean: - rm -rf out diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..76539ce --- /dev/null +++ b/meson.build @@ -0,0 +1,45 @@ +project('nrvn', ['c', 'nasm'], + version : '0.1', + default_options : [ + 'warning_level=3', + 'b_pie=false', + 'b_staticpic=false' + ]) + +if not meson.is_cross_build() + error('must be invoked with "meson setup --cross-file=toolchain.txt"') +endif + +files = [ + 'src/asm/boot.asm', + 'src/asm/long.asm', + 'src/nrvn.c', + 'src/vga.c', + 'src/idt.c', + 'src/mem.c', + 'src/acpi.c', + 'src/ps2.c', + 'src/pic.c', + 'src/memory.c' +] + +ld_args = [ + '-ffreestanding', + '-nostdlib', + '-T', + join_paths(meson.current_source_dir(), 'util', 'linker.ld') +] + +kernel = executable('nrvn', files, + c_args: ['-ffreestanding'], + nasm_args: ['-felf64'], + link_args: ld_args, + include_directories: 'include/') + + +iso = custom_target('iso', + input: [import('fs').copyfile('util/grub.cfg'), kernel], + output: 'nrvn.iso', + command: ['util/build_iso.sh', '@PRIVATE_DIR@', '@INPUT@', '@OUTPUT@']) + +run_target('run', command: [find_program('qemu'), '-cdrom', iso, '-m', '2G']) diff --git a/asm/boot.asm b/src/asm/boot.asm index ae68761..ae68761 100644 --- a/asm/boot.asm +++ b/src/asm/boot.asm diff --git a/asm/long.asm b/src/asm/long.asm index 829d582..829d582 100644 --- a/asm/long.asm +++ b/src/asm/long.asm @@ -14,13 +14,13 @@ /* Check if the compiler thinks you are targeting the wrong operating system. */ #if defined(__linux__) -#error "You are not using a cross-compiler, you will most certainly run into trouble" +# error "You are not using a cross-compiler, you will most certainly run into trouble" #endif /* This tutorial will only work for the 32-bit ix86 targets. */ -//#if !defined(__i386__) | !defined(__x86_64__) -//#error "This tutorial needs to be compiled with a ix86-elf compiler" -//#endif +#if !defined(__x86_64__) +# error "This tutorial needs to be compiled with a ix86-elf compiler" +#endif void kernel_main(void) { vga_init(); @@ -45,8 +45,6 @@ void kernel_main(void) { asm volatile ("hlt"); } - // TODO -- fix acpi - vga_puts("initializing ps/2...\n"); if (ps2_init(NULL)) vga_puts("ps/2 initialized.\n"); diff --git a/toolchain.txt b/toolchain.txt new file mode 100644 index 0000000..a1dc80a --- /dev/null +++ b/toolchain.txt @@ -0,0 +1,13 @@ +[binaries] +c = 'x86_64-pc-elf-gcc' +cpp = 'x86_64-pc-elf-g++' +ar = 'x86_64-pc-elf-ar' +strip = 'x86_64-pc-elf-strip' +nasm = 'nasm' +qemu = 'qemu-system-x86_64' + +[host_machine] +system = 'linux' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' diff --git a/util/build_iso.sh b/util/build_iso.sh new file mode 100755 index 0000000..0ca346f --- /dev/null +++ b/util/build_iso.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +mkdir -p "${1}/iso/boot/grub" +cp "$2" "${1}/iso/boot/grub" +cp "$3" "${1}/iso/boot/nrvn.bin" +grub-mkrescue -o "$4" "${1}/iso" diff --git a/util/grub.cfg b/util/grub.cfg new file mode 100644 index 0000000..e1d7e5c --- /dev/null +++ b/util/grub.cfg @@ -0,0 +1,3 @@ +menuentry "nrvn" { + multiboot /boot/nrvn.bin +} diff --git a/linker.ld b/util/linker.ld index 87fb6c4..87fb6c4 100644 --- a/linker.ld +++ b/util/linker.ld |