From 28fe545925732a5cadd1f5b55fe9324778da25e5 Mon Sep 17 00:00:00 2001 From: aqua Date: Sat, 29 Oct 2022 15:27:06 +0300 Subject: Remove meson.build files --- Makefile | 51 ++++++++++++++++++++++++--------------------------- devices/meson.build | 5 ----- i686/init.s | 9 +++++++++ i686/meson.build | 9 --------- i686/toolchain.ini | 18 ------------------ i686/toolchain.mk | 2 +- lib/Makefile | 1 - lib/meson.build | 13 ------------- meson.build | 37 ------------------------------------- scripts/mkiso.py | 27 --------------------------- src/Makefile | 6 ++++-- src/conf.h.in | 4 ++-- src/kernel.c | 10 ---------- 13 files changed, 40 insertions(+), 152 deletions(-) delete mode 100644 devices/meson.build delete mode 100644 i686/meson.build delete mode 100644 i686/toolchain.ini delete mode 100644 lib/meson.build delete mode 100644 meson.build delete mode 100755 scripts/mkiso.py diff --git a/Makefile b/Makefile index e0dba8f..d10fd2a 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,31 @@ -MAKE = make -ARCH = i686 +MAKE = make +MAKEFLAGS += --no-print-directory +ARCH = i686 include ${ARCH}/toolchain.mk info: @echo "this is the all target" - @echo "ARCH ${ARCH}" - @echo "BUILD ${BUILD}" - @echo " MAKE ${MAKE}" - @${MAKE} --version | head -n1 - @echo " CC ${CC} ${CCFLAGS}" - @${CC} --version | head -n1 - @echo " LD ${LD} ${LDFLAGS}" - @${LD} --version | head -n1 + @echo " ARCH ${ARCH}" + @echo " MAKE $(shell ${MAKE} --version | head -n1)" + @echo " CC $(shell ${CC} --version | head -n1)" + @echo " LD $(shell ${LD} --version | head -n1)" +.PHONY: all run clean purge all: lib/libk.a ${ARCH}/arch.a devices/devs.a src/kernel.a +run: glitch.iso + qemu-system-i386 -cdrom glitch.iso -accel kvm + +clean: + @${MAKE} ARCH=${ARCH} -C lib clean + @${MAKE} ARCH=${ARCH} -C ${ARCH} clean + @${MAKE} ARCH=${ARCH} -C devices clean + @${MAKE} ARCH=${ARCH} -C src clean + +purge: clean + rm -f lib/libk.a ${ARCH}/arch.a devices/devs.a src/kernel.a + rm -rf glitch.elf glitch.iso isodir + lib/libk.a: ${MAKE} ARCH=${ARCH} -C lib libk.a i686/arch.a: @@ -24,28 +35,14 @@ devices/devs.a: src/kernel.a: ${MAKE} ARCH=${ARCH} -C src kernel.a -glitch.elf: ${ARCH}/arch.a devices/devs.a lib/libk.a src/kernel.a - ${LD} ${LDFLAGS} -T ${ARCH}/linker.ld -o $@\ - $(wildcard i686/*.o) \ - src/kernel.a \ - -Llib -lk devices/devs.a +glitch.elf: ${ARCH}/arch.a src/kernel.a devices/devs.a lib/libk.a + ${LD} ${LDFLAGS} -T ${ARCH}/linker.ld -o $@ $^ glitch.iso: glitch.elf grub/grub.cfg + grub-file --is-x86-multiboot2 glitch.elf mkdir -p isodir/boot/grub mkdir -p isodir/boot/glitch cp grub/grub.cfg isodir/boot/grub/grub.cfg cp glitch.elf isodir/boot/glitch/glitch.elf grub-mkrescue -o glitch.iso isodir -run: glitch.iso - qemu-system-i386 -cdrom glitch.iso -accel kvm - -clean: - ${MAKE} ARCH=${ARCH} -C lib clean - ${MAKE} ARCH=${ARCH} -C ${ARCH} clean - ${MAKE} ARCH=${ARCH} -C devices clean - ${MAKE} ARCH=${ARCH} -C src clean -purge: clean - rm -f lib/libk.a ${ARCH}/arch.a devices/devs.a src/kernel.a - rm -rf isodir - diff --git a/devices/meson.build b/devices/meson.build deleted file mode 100644 index de0230d..0000000 --- a/devices/meson.build +++ /dev/null @@ -1,5 +0,0 @@ -devices = declare_dependency( - sources: ['vga.c', 'uart_16550.c', 'pic_8259.c'], - include_directories: '.' -) - diff --git a/i686/init.s b/i686/init.s index 92710df..c0c25c0 100644 --- a/i686/init.s +++ b/i686/init.s @@ -15,6 +15,9 @@ k_ptable0x300: .skip 1024 * 4 .section .text .global k_init .extern kmain +.extern pic_init +.extern gdt_install +.extern idt_install k_init: # kernel entry point, higher half @@ -33,6 +36,12 @@ k_init: mov $k_stack, %esp # point stack pointer to the stack + # hardware init + call pic_init # Programmable Interrupt Controller + call gdt_install # Global Descriptor Table + call idt_install # Interrupt Descriptor Table + + # jump into kernel call kmain /* If the system has nothing more to do, put it in an infinite loop */ diff --git a/i686/meson.build b/i686/meson.build deleted file mode 100644 index f6bed8e..0000000 --- a/i686/meson.build +++ /dev/null @@ -1,9 +0,0 @@ -arch = declare_dependency( - sources: ['boot.S', 'init.s', - 'gdt.c', 'lgdt.c', 'lidt.c' - ], - include_directories: 'include', - compile_args: '-mgeneral-regs-only' -) - -test('GDT', executable('gdt', ['test/gdt.c', 'gdt.c'], include_directories: 'include', native: true)) diff --git a/i686/toolchain.ini b/i686/toolchain.ini deleted file mode 100644 index 5114cfe..0000000 --- a/i686/toolchain.ini +++ /dev/null @@ -1,18 +0,0 @@ -[constants] -arch = 'i686' - -[host_machine] -system = 'none' -cpu_family = 'x86' -cpu = 'i686' -endian = 'little' - -[binaries] -c = 'i686-elf-gcc' -ar = 'i686-elf-ar' -strip = 'i686-elf-strip' - -[built-in options] -c_args = ['-ffreestanding'] -c_link_args = ['-nostdlib'] - diff --git a/i686/toolchain.mk b/i686/toolchain.mk index 5842584..7bef9bc 100644 --- a/i686/toolchain.mk +++ b/i686/toolchain.mk @@ -6,7 +6,7 @@ CCFLAGS = -Wall -Wextra -Wpedantic -fanalyzer -ffreestanding -std=gnu11 -mgenera LD = i686-elf-ld LDFLAGS = -static -nostdlib AR = i686-elf-ar -ARFLAGS = -ruv +ARFLAGS = -crus STRIP = i686-elf-strip diff --git a/lib/Makefile b/lib/Makefile index 22c090c..c34790d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -10,7 +10,6 @@ libk,OBJS = $(libk,SRCS:%.c=%.o) libk.a: ${libk,OBJS} @echo ' AR $@' @${AR} ${ARFLAGS} $@ $^ - i686-elf-ranlib $@ clean: @rm -rf ${libk,OBJS} diff --git a/lib/meson.build b/lib/meson.build deleted file mode 100644 index b83c680..0000000 --- a/lib/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -libk_srcs = ['memcpy.c', 'memset.c', 'string/itoa.c'] - -libk = static_library('k', [libk_srcs, 'stdio/printf.c'], - include_directories: ['.', '..'], - override_options: 'b_coverage=false' -) - -tk = library('tk', libk_srcs, - include_directories: ['.', '..'], - native: true -) -test('mem', executable('mem', 'test/mem.c', c_args: '-fno-builtin', link_with: tk, native: true), suite: 'libk') -test('string', executable('string', 'test/string.c', c_args: '-fno-builtin', link_with: tk, native: true), suite: 'libk') diff --git a/meson.build b/meson.build deleted file mode 100644 index 2966733..0000000 --- a/meson.build +++ /dev/null @@ -1,37 +0,0 @@ -project('glitch kernel', 'c', version: '0.0.0', default_options: ['c_std=gnu11', 'warning_level=2', 'b_coverage=true']) - -cc = meson.get_compiler('c') -if(cc.has_argument('-fanalyzer')) - add_project_arguments('-fanalyzer', language: 'c') -endif -python3 = import('python').find_installation('python3') -qemu = find_program('qemu-system-i386') - -conf = configuration_data() -conf.set_quoted('VERSION', run_command(['git', 'describe', '--long'], capture: true, check: true).stdout().strip()) -conf.set_quoted('CC', cc.get_id() + ' ' + cc.version()) -configure_file(output: 'conf.h', configuration: conf) - -subdir('arch/i686') -subdir('devices') -subdir('lib') - -kernel = executable('glitch.elf', - ['src/multiboot2.c', 'src/mmap.c', 'src/kernel.c', - 'src/isr.c', 'src/mem/vmm.c'], - link_with: [libk], - link_language: 'c', - link_args: ['-static', '-T', meson.current_source_dir()/'arch/i686/linker.ld'], - install: true, native: false, override_options: ['b_coverage=false'], - include_directories: [ - include_directories('grub/include', is_system: true), - include_directories('lib') - ], - dependencies: [arch, devices] -) - -glitch_iso = custom_target('glitch.iso', - input: 'scripts/mkiso.py', output: 'glitch.iso', depends: [kernel], - command: [python3, '@INPUT@', kernel, '@SOURCE_ROOT@/grub/grub.cfg']) - -run_target('run', depends: glitch_iso, command: [qemu, '-cdrom', 'glitch.iso', '-accel', 'kvm']) diff --git a/scripts/mkiso.py b/scripts/mkiso.py deleted file mode 100755 index b1f1dc5..0000000 --- a/scripts/mkiso.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -from os import makedirs as mkpath -from shutil import copy -from subprocess import run - -def main(): - parser = argparse.ArgumentParser(description='Build a bootable CD-ROM image using grub-mkrescue') - parser.add_argument('kernel', metavar='zcore', type=str, help='path to kernel') - parser.add_argument('grub', metavar='grub.cfg', type=str, help='path to grub.cfg') - parser.add_argument('mkrescue_args', metavar='MKRESCUE_ARGS', type=str, nargs='*', help='Additional arguments passed to grub-mkrescue') - parser.add_argument('--cache', type=str, default='isodir', help='isodir') - parser.add_argument('-o', '--output', type=str, default='glitch.iso', help='glitch.iso') - - args = parser.parse_args() - - mkpath('isodir/boot/grub', exist_ok=True) - copy(args.grub, 'isodir/boot/grub/grub.cfg') - mkpath('isodir/boot/glitch', exist_ok=True) - copy(args.kernel, 'isodir/boot/glitch/glitch.elf') - - run(['grub-mkrescue', '-o', args.output, args.cache] + args.mkrescue_args) - -if __name__ == "__main__": - main() - diff --git a/src/Makefile b/src/Makefile index 4c47e20..f9d3a28 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ include ../${ARCH}/toolchain.mk include ../rules.mk -CCFLAGS += -I. -I../grub/include -I../${ARCH} -I../lib -I.. +CCFLAGS += -I. -isystem../grub/include -I../${ARCH} -I../lib -I.. all: kernel.a @@ -12,7 +12,9 @@ kernel.a: conf.h ${kernel,OBJS} @${AR} ${ARFLAGS} $@ ${kernel,OBJS} conf.h: conf.h.in - cp conf.h.in conf.h + @cp conf.h.in conf.h + @sed -i 's/@VERSION@/$(shell git describe)/' conf.h + @sed -i 's/@CC@/$(shell ${CC} --version | head -n1)/' conf.h clean: @rm -rf ${kernel,OBJS} diff --git a/src/conf.h.in b/src/conf.h.in index 9ae9bac..52093a8 100644 --- a/src/conf.h.in +++ b/src/conf.h.in @@ -1,4 +1,4 @@ #pragma once -#define VERSION "0.0.0" -#define CC "gcc xyz" +#define VERSION "@VERSION@" +#define CC "@CC@" diff --git a/src/kernel.c b/src/kernel.c index b652c23..a9fc126 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -5,24 +5,14 @@ //===================================================================== #include "mem.h" - -#include -#include #include - #include "devices/pic.h" #include "devices/uart_16550.h" #include "devices/vga.h" - #include #include void kmain() { - pic_init(); - - gdt_install(); - idt_install(); - if (uart_init(COM1) != 0) printf("UART self-test failed.\r\n"); printf("glitch [version " VERSION "] [" CC "]\n"); -- cgit v1.2.1