From 081318c2c70144dfab89737222debedca3991133 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 3 Dec 2022 14:44:22 +0400 Subject: [PATCH] Remove drivers (#127) --- .github/workflows/main.yml | 2 +- .gitignore | 1 - .gitmodules | 9 -- Makefile.am | 24 ---- README.md | 8 -- config/dev-cross-i386 | 2 +- config/dev-cross-riscv64 | 2 +- config/dev-cross-x86_64 | 2 +- config/root-cross-i386-linux | 2 +- config/root-cross-riscv64-linux | 2 +- config/root-cross-x86_64-linux | 2 +- configure.ac | 5 - examples/full/i386-multiboot2-grub/.gitignore | 3 - examples/full/i386-multiboot2-grub/Makefile | 62 ---------- .../full/i386-multiboot2-grub/expected.txt | 109 ----------------- examples/full/i386-multiboot2-grub/linker.ld | 38 ------ examples/full/i386-multiboot2-grub/main.c | 51 -------- .../full/i386-multiboot2-grub/multiboot2.c | 33 ----- .../rootfs/boot/grub/grub.cfg | 5 - examples/full/i386-multiboot2-grub/start.S | 27 ----- .../full/i386-multiboot2-limine/.gitignore | 6 - examples/full/i386-multiboot2-limine/Makefile | 87 -------------- .../full/i386-multiboot2-limine/expected.txt | 80 ------------- .../full/i386-multiboot2-limine/linker.ld | 38 ------ examples/full/i386-multiboot2-limine/main.c | 51 -------- .../full/i386-multiboot2-limine/multiboot2.c | 33 ----- .../rootfs/boot/limine.cfg | 8 -- examples/full/i386-multiboot2-limine/start.S | 27 ----- examples/full/riscv64/.gitignore | 1 - examples/full/riscv64/Makefile | 46 ------- examples/full/riscv64/linker.ld | 33 ----- examples/full/riscv64/main.c | 22 ---- examples/full/riscv64/start.S | 37 ------ include/Makefile.am | 24 ---- include/kernaux/drivers/console.h.in | 24 ---- include/kernaux/drivers/framebuffer.h | 12 -- include/kernaux/drivers/intel_8253_pit.h | 21 ---- include/kernaux/drivers/intel_8259_pic.h | 57 --------- include/kernaux/drivers/shutdown.h | 17 --- src/drivers/console.c | 78 ------------ src/drivers/framebuffer.c | 9 -- src/drivers/intel_8253_pit.c | 26 ---- src/drivers/intel_8259_pic.c | 113 ------------------ src/drivers/shutdown.c | 33 ----- vendor/limine | 1 - vendor/opensbi | 1 - vendor/u-boot | 1 - 47 files changed, 7 insertions(+), 1268 deletions(-) delete mode 100644 examples/full/i386-multiboot2-grub/.gitignore delete mode 100644 examples/full/i386-multiboot2-grub/Makefile delete mode 100644 examples/full/i386-multiboot2-grub/expected.txt delete mode 100644 examples/full/i386-multiboot2-grub/linker.ld delete mode 100644 examples/full/i386-multiboot2-grub/main.c delete mode 100644 examples/full/i386-multiboot2-grub/multiboot2.c delete mode 100644 examples/full/i386-multiboot2-grub/rootfs/boot/grub/grub.cfg delete mode 100644 examples/full/i386-multiboot2-grub/start.S delete mode 100644 examples/full/i386-multiboot2-limine/.gitignore delete mode 100644 examples/full/i386-multiboot2-limine/Makefile delete mode 100644 examples/full/i386-multiboot2-limine/expected.txt delete mode 100644 examples/full/i386-multiboot2-limine/linker.ld delete mode 100644 examples/full/i386-multiboot2-limine/main.c delete mode 100644 examples/full/i386-multiboot2-limine/multiboot2.c delete mode 100644 examples/full/i386-multiboot2-limine/rootfs/boot/limine.cfg delete mode 100644 examples/full/i386-multiboot2-limine/start.S delete mode 100644 examples/full/riscv64/.gitignore delete mode 100644 examples/full/riscv64/Makefile delete mode 100644 examples/full/riscv64/linker.ld delete mode 100644 examples/full/riscv64/main.c delete mode 100644 examples/full/riscv64/start.S delete mode 100644 include/kernaux/drivers/console.h.in delete mode 100644 include/kernaux/drivers/framebuffer.h delete mode 100644 include/kernaux/drivers/intel_8253_pit.h delete mode 100644 include/kernaux/drivers/intel_8259_pic.h delete mode 100644 include/kernaux/drivers/shutdown.h delete mode 100644 src/drivers/console.c delete mode 100644 src/drivers/framebuffer.c delete mode 100644 src/drivers/intel_8253_pit.c delete mode 100644 src/drivers/intel_8259_pic.c delete mode 100644 src/drivers/shutdown.c delete mode 160000 vendor/limine delete mode 160000 vendor/opensbi delete mode 160000 vendor/u-boot diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cc4a955f..13a36616 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -119,7 +119,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --host='i386-elf' ${{matrix.debug}} --enable-freestanding --with-drivers --with-libc AR="$(which i686-linux-gnu-ar)" CC="$(which i686-linux-gnu-gcc)" LD="$(which i686-linux-gnu-ld)" RANLIB="$(which i686-linux-gnu-ranlib)" + run: ./configure --host='i386-elf' ${{matrix.debug}} --enable-freestanding --with-libc AR="$(which i686-linux-gnu-ar)" CC="$(which i686-linux-gnu-gcc)" LD="$(which i686-linux-gnu-ld)" RANLIB="$(which i686-linux-gnu-ranlib)" - name: make run: make diff --git a/.gitignore b/.gitignore index ef926c41..2e470b9d 100644 --- a/.gitignore +++ b/.gitignore @@ -101,7 +101,6 @@ /include/Makefile /include/kernaux.h -/include/kernaux/drivers/console.h /include/kernaux/multiboot2.h /include/kernaux/version.h diff --git a/.gitmodules b/.gitmodules index 2d175788..1bbbb8cc 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,15 +2,6 @@ path = vendor/cross url = https://github.com/tailix/cross.git ignore = dirty -[submodule "vendor/limine"] - path = vendor/limine - url = https://github.com/limine-bootloader/limine.git -[submodule "vendor/opensbi"] - path = vendor/opensbi - url = https://github.com/riscv-software-src/opensbi.git -[submodule "vendor/u-boot"] - path = vendor/u-boot - url = https://source.denx.de/u-boot/u-boot.git [submodule "vendor/mruby"] path = vendor/mruby url = https://github.com/mruby/mruby.git diff --git a/Makefile.am b/Makefile.am index 3067a82c..6a26bbf1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -111,27 +111,3 @@ endif if WITH_UNITS libkernaux_la_SOURCES += src/units.c endif - -########### -# Drivers # -########### - -if WITH_DRIVERS -libkernaux_la_SOURCES += \ - src/drivers/console.c \ - src/drivers/framebuffer.c \ - src/drivers/shutdown.c - -# Intel 8253-compatible programmable interval timer - -if ASM_I386 -libkernaux_la_SOURCES += src/drivers/intel_8253_pit.c -endif - -# Intel 8259-compatible programmable interrupt controller - -if ASM_I386 -libkernaux_la_SOURCES += src/drivers/intel_8259_pic.c -endif - -endif # WITH_DRIVERS diff --git a/README.md b/README.md index 0613dbda..3e6b635a 100644 --- a/README.md +++ b/README.md @@ -90,12 +90,6 @@ zero). Work-in-progress APIs can change at any time. * Architecture-specific code (*work in progress*) * [Declarations](/include/kernaux/arch/) * [Functions](/include/kernaux/asm/) -* Device drivers (for debugging only) - * [Serial console](/include/kernaux/drivers/console.h) (*work in progress*) - * [Framebuffer](/include/kernaux/drivers/framebuffer.h) (*planned*) - * [Intel 8253-compatible PIT](/include/kernaux/drivers/intel_8253_pit.h) (*work in progress*) - * [Intel 8259-compatible PIC](/include/kernaux/drivers/intel_8259_pic.h) (*work in progress*) - * USB (*planned*) ### Definitions @@ -144,7 +138,6 @@ stable options. #### Packages -* `--with-drivers` - device drivers * `--with-libc` - provides the replacement for some standard C functions. Useful in freestanding environment, where no libc is present. @@ -211,7 +204,6 @@ without it in `$PATH`: ./configure \ --host='i386-elf' \ --enable-freestanding \ - --with-drivers \ --with-libc \ AR="$(which i386-elf-ar)" \ CC="$(which i386-elf-gcc)" \ diff --git a/config/dev-cross-i386 b/config/dev-cross-i386 index e3ba447a..70ecef7c 100755 --- a/config/dev-cross-i386 +++ b/config/dev-cross-i386 @@ -14,4 +14,4 @@ export AR="$CROSS-ar" export CC="$CROSS-gcc" export RANLIB="$CROSS-ranlib" -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc diff --git a/config/dev-cross-riscv64 b/config/dev-cross-riscv64 index 66e9ad3b..57b29fff 100755 --- a/config/dev-cross-riscv64 +++ b/config/dev-cross-riscv64 @@ -14,4 +14,4 @@ export AR="$CROSS-ar" export CC="$CROSS-gcc" export RANLIB="$CROSS-ranlib" -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc diff --git a/config/dev-cross-x86_64 b/config/dev-cross-x86_64 index a5460265..4a900b6d 100755 --- a/config/dev-cross-x86_64 +++ b/config/dev-cross-x86_64 @@ -16,4 +16,4 @@ export RANLIB="$CROSS-ranlib" export CFLAGS='-mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone' -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc diff --git a/config/root-cross-i386-linux b/config/root-cross-i386-linux index fc579cff..7740099b 100755 --- a/config/root-cross-i386-linux +++ b/config/root-cross-i386-linux @@ -14,4 +14,4 @@ export AR="$TARGET-ar" export CC="$TARGET-gcc" export RANLIB="$TARGET-ranlib" -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc diff --git a/config/root-cross-riscv64-linux b/config/root-cross-riscv64-linux index 898dc4ee..af99c56d 100755 --- a/config/root-cross-riscv64-linux +++ b/config/root-cross-riscv64-linux @@ -14,4 +14,4 @@ export AR="$TARGET-ar" export CC="$TARGET-gcc" export RANLIB="$TARGET-ranlib" -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc diff --git a/config/root-cross-x86_64-linux b/config/root-cross-x86_64-linux index 42532a1b..5d8fd627 100755 --- a/config/root-cross-x86_64-linux +++ b/config/root-cross-x86_64-linux @@ -16,4 +16,4 @@ export RANLIB="$TARGET-ranlib" export CFLAGS='-mabi=sysv -mcmodel=kernel -mno-80387 -mno-red-zone' -"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-libc diff --git a/configure.ac b/configure.ac index 2769ad08..2a5371a1 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,6 @@ AC_CONFIG_FILES([ libc/Makefile libc/include/Makefile include/kernaux.h - include/kernaux/drivers/console.h include/kernaux/multiboot2.h include/kernaux/version.h tests/Makefile @@ -77,7 +76,6 @@ AC_ARG_WITH( [printf-fmt], AS_HELP_STRING([--without-printf-fmt], [wit AC_ARG_WITH( [units], AS_HELP_STRING([--without-units], [without measurement units utils])) dnl Packages (disabled by default) -AC_ARG_WITH( [drivers], AS_HELP_STRING([--with-drivers], [with drivers])) AC_ARG_WITH( [libc], AS_HELP_STRING([--with-libc], [with libc replacement])) @@ -161,7 +159,6 @@ AS_IF([test "$with_printf_fmt" = no ], [with_printf_fmt=no], [wit AS_IF([test "$with_units" = no ], [with_units=no], [with_units=yes]) dnl Packages (disabled by default) -AS_IF([test "$with_drivers" = yes], [with_drivers=yes], [with_drivers=no]) AS_IF([test "$with_libc" = yes], [with_libc=yes], [with_libc=no]) @@ -223,7 +220,6 @@ AM_CONDITIONAL([WITH_PRINTF_FMT], [test "$with_printf_fmt" = yes]) AM_CONDITIONAL([WITH_UNITS], [test "$with_units" = yes]) dnl Packages (disabled by default) -AM_CONDITIONAL([WITH_DRIVERS], [test "$with_drivers" = yes]) AM_CONDITIONAL([WITH_LIBC], [test "$with_libc" = yes]) dnl Packages (virtual) @@ -274,7 +270,6 @@ AS_IF([test "$with_printf_fmt" = yes], [AC_DEFINE([WITH_PRINTF_FMT], AS_IF([test "$with_units", = yes], [AC_DEFINE([WITH_UNITS], [1], [with measurement units utils])]) dnl Packages (disabled by default) -AS_IF([test "$with_drivers" = yes], [AC_DEFINE([WITH_DRIVERS], [1], [with drivers])]) AS_IF([test "$with_libc" = yes], [AC_DEFINE([WITH_LIBC], [1], [with libc replacement])]) dnl Packages (virtual) diff --git a/examples/full/i386-multiboot2-grub/.gitignore b/examples/full/i386-multiboot2-grub/.gitignore deleted file mode 100644 index 6631cd5f..00000000 --- a/examples/full/i386-multiboot2-grub/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/image.iso -/output.txt -/rootfs/boot/kernel diff --git a/examples/full/i386-multiboot2-grub/Makefile b/examples/full/i386-multiboot2-grub/Makefile deleted file mode 100644 index daf80a28..00000000 --- a/examples/full/i386-multiboot2-grub/Makefile +++ /dev/null @@ -1,62 +0,0 @@ -all: test - -REPO = ../../.. - -CCPREFIX = $(REPO)/vendor/cross/root/bin/i386-elf- - -AS = $(CCPREFIX)as -CC = $(CCPREFIX)gcc - -LIBKERNAUX_BUILD = $(REPO)/build/dev-cross-i386 -LIBKERNAUX_DEST = $(REPO)/dest/dev-cross-i386 - -DIFF = diff -GRUB_FILE = grub-file -GRUB_MKRESCUE = grub-mkrescue -QEMU = qemu-system-i386 -serial stdio -display none - -EXPECTED = expected.txt -IMAGE = image.iso -LINKERSCR = linker.ld -OUTPUT = output.txt -ROOTFS = rootfs - -GRUBCFG = $(ROOTFS)/boot/grub/grub.cfg -KERNEL = $(ROOTFS)/boot/kernel - -CFLAGS = \ - -std=c99 \ - -pedantic \ - -Wall \ - -Wextra \ - -Werror \ - -ffreestanding \ - -fno-stack-protector \ - -I$(LIBKERNAUX_DEST)/include - -OBJS = main.c.o multiboot2.c.o start.S.o - -test: run - $(DIFF) -a -Z $(EXPECTED) $(OUTPUT) - -run: $(IMAGE) - $(QEMU) -cdrom $< | tee $(OUTPUT) - -clean: - rm -f $(OUTPUT) $(IMAGE) $(KERNEL) $(OBJS) - -$(IMAGE): $(GRUBCFG) $(KERNEL) - $(GRUB_MKRESCUE) $(ROOTFS) -o $@ - -$(KERNEL): $(LINKERSCR) build-libkernaux.a $(OBJS) - $(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lkernaux -lgcc -Wl,-L$(LIBKERNAUX_DEST)/lib - $(GRUB_FILE) --is-x86-multiboot2 $@ - -build-libkernaux.a: - cd $(LIBKERNAUX_BUILD) && ./config && make install - -%.c.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) - -%.S.o: %.S - $(AS) $< -o $@ diff --git a/examples/full/i386-multiboot2-grub/expected.txt b/examples/full/i386-multiboot2-grub/expected.txt deleted file mode 100644 index 227456ed..00000000 --- a/examples/full/i386-multiboot2-grub/expected.txt +++ /dev/null @@ -1,109 +0,0 @@ -Multiboot 2 header is valid -Multiboot 2 header - magic: 3897708758 - arch: 0 (i386) - size: 24 - checksum: 397258514 -Multiboot 2 header tag - type: 0 (none) - flags: 0 - size: 8 -Multiboot 2 info magic number is valid -Multiboot 2 info is valid -Multiboot 2 info - size: 1088 - reserved1: 0 -Multiboot 2 info tag - type: 21 (image load base phys addr) - size: 12 - load base addr: 4194304 -Multiboot 2 info tag - type: 1 (boot cmd line) - size: 21 - cmdline: hello kernel -Multiboot 2 info tag - type: 2 (boot loader name) - size: 31 - name: GRUB 2.04-1ubuntu26.15 -Multiboot 2 info tag - type: 10 (APM table) - size: 28 - version: 258 - cseg: 61440 - offset: 53676 - cseg 16: 61440 - dseg: 61440 - flags: 3 - cseg len: 65520 - cseg 16 len: 65520 - dseg len: 65520 -Multiboot 2 info tag - type: 6 (memory map) - size: 160 - entry size: 24 - entry version: 0 - entries: - entry 0 - base addr: 0 - length: 654336 - type: 1 - reserved1: 0 - entry 1 - base addr: 654336 - length: 1024 - type: 2 - reserved1: 0 - entry 2 - base addr: 983040 - length: 65536 - type: 2 - reserved1: 0 - entry 3 - base addr: 1048576 - length: 133038080 - type: 1 - reserved1: 0 - entry 4 - base addr: 134086656 - length: 131072 - type: 2 - reserved1: 0 - entry 5 - base addr: 4294705152 - length: 262144 - type: 2 - reserved1: 0 -Multiboot 2 info tag - type: 9 (ELF symbols) - size: 700 - num: 17 - entsize: 0 - shndx: 40 - reserved1: 0 -Multiboot 2 info tag - type: 4 (basic memory info) - size: 16 - mem lower: 639 - mem upper: 129920 -Multiboot 2 info tag - type: 5 (BIOS boot device) - size: 20 - bios dev: 224 - partition: 4294967295 - sub_partition: 4294967295 -Multiboot 2 info tag - type: 8 (framebuffer info) - size: 32 - framebuffer addr: 753664 - framebuffer pitch: 160 - framebuffer width: 80 - framebuffer height: 25 - framebuffer bpp: 16 - framebuffer type: 2 - reserved1: 0 -Multiboot 2 info tag - type: 14 (ACPI old RSDP) - size: 28 -Multiboot 2 info tag - type: 0 (none) - size: 8 diff --git a/examples/full/i386-multiboot2-grub/linker.ld b/examples/full/i386-multiboot2-grub/linker.ld deleted file mode 100644 index a85f5e41..00000000 --- a/examples/full/i386-multiboot2-grub/linker.ld +++ /dev/null @@ -1,38 +0,0 @@ -OUTPUT_ARCH("i386") -ENTRY(_start) - -_kernel_offset = 0xc0000000; /* 3 GiB */ - -_kernel_phys_base = 4M; -_kernel_virt_base = (_kernel_phys_base + _kernel_offset); - -_kernel_stack_size = _kernel_stack_end - _kernel_stack_start; - -SECTIONS -{ - . = _kernel_phys_base; - - .text BLOCK(4K) : ALIGN(4K) - { - *(.multiboot2); - *(.text); - } - - .rodata BLOCK(4K) : ALIGN(4K) - { - *(.rodata); - } - - .data BLOCK(4K) : ALIGN(4K) - { - *(.data); - } - - .bss BLOCK(4K) : ALIGN(4K) - { - *(COMMON); - *(.bss); - } - - _kernel_size = . - _kernel_phys_base; -} diff --git a/examples/full/i386-multiboot2-grub/main.c b/examples/full/i386-multiboot2-grub/main.c deleted file mode 100644 index 223b314d..00000000 --- a/examples/full/i386-multiboot2-grub/main.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -#include -#include -#include - -extern const struct KernAux_Multiboot2_Header multiboot2_header; - -static void panic(const char *str); - -void main( - const uint32_t multiboot2_info_magic, - const struct KernAux_Multiboot2_Info *const multiboot2_info -) { - if (!KernAux_Multiboot2_Header_is_valid(&multiboot2_header)) { - panic("Multiboot 2 header is invalid"); - } else { - kernaux_drivers_console_printf("Multiboot 2 header is valid\n"); - } - - KernAux_Multiboot2_Header_print( - &multiboot2_header, - kernaux_drivers_console_printf - ); - - if (multiboot2_info_magic != KERNAUX_MULTIBOOT2_INFO_MAGIC) { - panic("Multiboot 2 info magic number is invalid"); - } else { - kernaux_drivers_console_printf( - "Multiboot 2 info magic number is valid\n" - ); - } - - if (!KernAux_Multiboot2_Info_is_valid(multiboot2_info)) { - panic("Multiboot 2 info is invalid"); - } else { - kernaux_drivers_console_printf("Multiboot 2 info is valid\n"); - } - - KernAux_Multiboot2_Info_print( - multiboot2_info, - kernaux_drivers_console_printf - ); -} - -void panic(const char *const str) -{ - kernaux_drivers_console_printf("panic: %s\n", str); - kernaux_drivers_shutdown_poweroff(); -} diff --git a/examples/full/i386-multiboot2-grub/multiboot2.c b/examples/full/i386-multiboot2-grub/multiboot2.c deleted file mode 100644 index 919967e5..00000000 --- a/examples/full/i386-multiboot2-grub/multiboot2.c +++ /dev/null @@ -1,33 +0,0 @@ -#include - -#include - -// TODO: add more tags -KERNAUX_SECTION(".multiboot2") -KERNAUX_USED -KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_HEADER_ALIGN) -const struct { - struct KernAux_Multiboot2_Header multiboot2_header; - struct KernAux_Multiboot2_HTag_None tag_none; -} -KERNAUX_PACKED -multiboot2_header = { - .multiboot2_header = { - .magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC, - .arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386, - .total_size = sizeof(multiboot2_header), - .checksum = KERNAUX_MULTIBOOT2_HEADER_CHECKSUM( - KERNAUX_MULTIBOOT2_HEADER_ARCH_I386, - sizeof(multiboot2_header) - ), - }, - .tag_none = { - .base = { - .type = KERNAUX_MULTIBOOT2_HTAG_NONE, - .flags = 0, - .size = sizeof(multiboot2_header.tag_none), - }, - }, -}; - -#include diff --git a/examples/full/i386-multiboot2-grub/rootfs/boot/grub/grub.cfg b/examples/full/i386-multiboot2-grub/rootfs/boot/grub/grub.cfg deleted file mode 100644 index 41056916..00000000 --- a/examples/full/i386-multiboot2-grub/rootfs/boot/grub/grub.cfg +++ /dev/null @@ -1,5 +0,0 @@ -set timeout=0 - -menuentry "Kernel" { - multiboot2 /boot/kernel hello kernel -} diff --git a/examples/full/i386-multiboot2-grub/start.S b/examples/full/i386-multiboot2-grub/start.S deleted file mode 100644 index 713cdd09..00000000 --- a/examples/full/i386-multiboot2-grub/start.S +++ /dev/null @@ -1,27 +0,0 @@ -.section .bss - -.global _kernel_stack_start -.global _kernel_stack_end - -.align 16 -_kernel_stack_start: -.skip 16384 # 16 KiB -_kernel_stack_end: - - - -.section .text - -.global _start - -.type _start, @function - -_start: - mov $_kernel_stack_end, %esp // Initialize stack - - push %ebx // Multiboot information pointer - push %eax // Multiboot magic number - call main - call kernaux_drivers_shutdown_poweroff - -.size _start, . - _start diff --git a/examples/full/i386-multiboot2-limine/.gitignore b/examples/full/i386-multiboot2-limine/.gitignore deleted file mode 100644 index e59723f5..00000000 --- a/examples/full/i386-multiboot2-limine/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/image.iso -/output.txt -/rootfs/boot/kernel -/rootfs/boot/limine-cd.bin -/rootfs/boot/limine-eltorito-efi.bin -/rootfs/boot/limine.sys diff --git a/examples/full/i386-multiboot2-limine/Makefile b/examples/full/i386-multiboot2-limine/Makefile deleted file mode 100644 index 3f81acf9..00000000 --- a/examples/full/i386-multiboot2-limine/Makefile +++ /dev/null @@ -1,87 +0,0 @@ -all: test - -REPO = ../../.. - -CCPREFIX = $(REPO)/vendor/cross/root/bin/i386-elf- - -AS = $(CCPREFIX)as -CC = $(CCPREFIX)gcc - -LIBKERNAUX_BUILD = $(REPO)/build/dev-cross-i386 -LIBKERNAUX_DEST = $(REPO)/dest/dev-cross-i386 - -DIFF = diff -GRUB_FILE = grub-file -LIMINE = $(REPO)/vendor/limine/build/bin -QEMU = qemu-system-x86_64 -serial stdio -display none -XORRISO = xorriso - -EXPECTED = expected.txt -IMAGE = image.iso -LINKERSCR = linker.ld -OUTPUT = output.txt -ROOTFS = rootfs - -LIMINE_CD = $(LIMINE)/limine-cd.bin -LIMINE_ELTORITO = $(LIMINE)/limine-eltorito-efi.bin -LIMINE_INSTALL = $(LIMINE)/limine-install -LIMINE_SYS = $(LIMINE)/limine.sys - -REL_KERNEL = boot/kernel -REL_LIMINE_CD = boot/limine-cd.bin -REL_LIMINE_CFG = boot/limine.cfg -REL_LIMINE_ELTORITO = boot/limine-eltorito-efi.bin -REL_LIMINE_SYS = boot/limine.sys - -FULL_KERNEL = $(ROOTFS)/$(REL_KERNEL) -FULL_LIMINE_CD = $(ROOTFS)/$(REL_LIMINE_CD) -FULL_LIMINE_CFG = $(ROOTFS)/$(REL_LIMINE_CFG) -FULL_LIMINE_ELTORITO = $(ROOTFS)/$(REL_LIMINE_ELTORITO) -FULL_LIMINE_SYS = $(ROOTFS)/$(REL_LIMINE_SYS) - -CFLAGS = \ - -std=c99 \ - -pedantic \ - -Wall \ - -Wextra \ - -Werror \ - -ffreestanding \ - -fno-stack-protector \ - -I$(LIBKERNAUX_DEST)/include - -OBJS = main.c.o multiboot2.c.o start.S.o - -test: run - $(DIFF) -a -Z $(EXPECTED) $(OUTPUT) - -run: $(IMAGE) - $(QEMU) -cdrom $< | tee $(OUTPUT) - -clean: - rm -f $(OUTPUT) $(IMAGE) $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS) $(OBJS) - -$(IMAGE): $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS) - $(XORRISO) -as mkisofs -b $(REL_LIMINE_CD) -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot $(REL_LIMINE_ELTORITO) -efi-boot-part --efi-boot-image --protective-msdos-label $(ROOTFS) -o $@ - $(LIMINE_INSTALL) $@ - -$(FULL_KERNEL): $(LINKERSCR) build-libkernaux.a $(OBJS) - $(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lkernaux -lgcc -Wl,-L$(LIBKERNAUX_DEST)/lib - $(GRUB_FILE) --is-x86-multiboot2 $@ - -$(FULL_LIMINE_CD): - cp -f $(LIMINE_CD) $(FULL_LIMINE_CD) - -$(FULL_LIMINE_ELTORITO): - cp -f $(LIMINE_ELTORITO) $(FULL_LIMINE_ELTORITO) - -$(FULL_LIMINE_SYS): - cp -f $(LIMINE_SYS) $(FULL_LIMINE_SYS) - -build-libkernaux.a: - cd $(LIBKERNAUX_BUILD) && ./config && make install - -%.c.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) - -%.S.o: %.S - $(AS) $< -o $@ diff --git a/examples/full/i386-multiboot2-limine/expected.txt b/examples/full/i386-multiboot2-limine/expected.txt deleted file mode 100644 index 6e4cbb1f..00000000 --- a/examples/full/i386-multiboot2-limine/expected.txt +++ /dev/null @@ -1,80 +0,0 @@ -Multiboot 2 header is valid -Multiboot 2 header - magic: 3897708758 - arch: 0 (i386) - size: 24 - checksum: 397258514 -Multiboot 2 header tag - type: 0 (none) - flags: 0 - size: 8 -Multiboot 2 info magic number is valid -Multiboot 2 info is valid -Multiboot 2 info - size: 952 - reserved1: 0 -Multiboot 2 info tag - type: 1 (boot cmd line) - size: 21 - cmdline: hello kernel -Multiboot 2 info tag - type: 2 (boot loader name) - size: 15 - name: Limine -Multiboot 2 info tag - type: 13 (SMBIOS tables) - size: 16 - major: 2 - minor: 8 - reserved1: {0, 0, 0, 0, 0, 0} -Multiboot 2 info tag - type: 9 (ELF symbols) - size: 700 - num: 17 - entsize: 0 - shndx: 40 - reserved1: 0 -Multiboot 2 info tag - type: 6 (memory map) - size: 160 - entry size: 24 - entry version: 0 - entries: - entry 0 - base addr: 0 - length: 654336 - type: 1 - reserved1: 0 - entry 1 - base addr: 654336 - length: 1024 - type: 2 - reserved1: 0 - entry 2 - base addr: 983040 - length: 65536 - type: 2 - reserved1: 0 - entry 3 - base addr: 1048576 - length: 133038080 - type: 1 - reserved1: 0 - entry 4 - base addr: 134086656 - length: 131072 - type: 2 - reserved1: 0 - entry 5 - base addr: 4294705152 - length: 262144 - type: 2 - reserved1: 0 -Multiboot 2 info tag - type: 4 (basic memory info) - size: 16 - mem lower: 639 - mem upper: 129920 -Multiboot 2 info tag - type: 0 (none) - size: 8 diff --git a/examples/full/i386-multiboot2-limine/linker.ld b/examples/full/i386-multiboot2-limine/linker.ld deleted file mode 100644 index a85f5e41..00000000 --- a/examples/full/i386-multiboot2-limine/linker.ld +++ /dev/null @@ -1,38 +0,0 @@ -OUTPUT_ARCH("i386") -ENTRY(_start) - -_kernel_offset = 0xc0000000; /* 3 GiB */ - -_kernel_phys_base = 4M; -_kernel_virt_base = (_kernel_phys_base + _kernel_offset); - -_kernel_stack_size = _kernel_stack_end - _kernel_stack_start; - -SECTIONS -{ - . = _kernel_phys_base; - - .text BLOCK(4K) : ALIGN(4K) - { - *(.multiboot2); - *(.text); - } - - .rodata BLOCK(4K) : ALIGN(4K) - { - *(.rodata); - } - - .data BLOCK(4K) : ALIGN(4K) - { - *(.data); - } - - .bss BLOCK(4K) : ALIGN(4K) - { - *(COMMON); - *(.bss); - } - - _kernel_size = . - _kernel_phys_base; -} diff --git a/examples/full/i386-multiboot2-limine/main.c b/examples/full/i386-multiboot2-limine/main.c deleted file mode 100644 index 223b314d..00000000 --- a/examples/full/i386-multiboot2-limine/main.c +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -#include -#include -#include - -extern const struct KernAux_Multiboot2_Header multiboot2_header; - -static void panic(const char *str); - -void main( - const uint32_t multiboot2_info_magic, - const struct KernAux_Multiboot2_Info *const multiboot2_info -) { - if (!KernAux_Multiboot2_Header_is_valid(&multiboot2_header)) { - panic("Multiboot 2 header is invalid"); - } else { - kernaux_drivers_console_printf("Multiboot 2 header is valid\n"); - } - - KernAux_Multiboot2_Header_print( - &multiboot2_header, - kernaux_drivers_console_printf - ); - - if (multiboot2_info_magic != KERNAUX_MULTIBOOT2_INFO_MAGIC) { - panic("Multiboot 2 info magic number is invalid"); - } else { - kernaux_drivers_console_printf( - "Multiboot 2 info magic number is valid\n" - ); - } - - if (!KernAux_Multiboot2_Info_is_valid(multiboot2_info)) { - panic("Multiboot 2 info is invalid"); - } else { - kernaux_drivers_console_printf("Multiboot 2 info is valid\n"); - } - - KernAux_Multiboot2_Info_print( - multiboot2_info, - kernaux_drivers_console_printf - ); -} - -void panic(const char *const str) -{ - kernaux_drivers_console_printf("panic: %s\n", str); - kernaux_drivers_shutdown_poweroff(); -} diff --git a/examples/full/i386-multiboot2-limine/multiboot2.c b/examples/full/i386-multiboot2-limine/multiboot2.c deleted file mode 100644 index 919967e5..00000000 --- a/examples/full/i386-multiboot2-limine/multiboot2.c +++ /dev/null @@ -1,33 +0,0 @@ -#include - -#include - -// TODO: add more tags -KERNAUX_SECTION(".multiboot2") -KERNAUX_USED -KERNAUX_ALIGNED(KERNAUX_MULTIBOOT2_HEADER_ALIGN) -const struct { - struct KernAux_Multiboot2_Header multiboot2_header; - struct KernAux_Multiboot2_HTag_None tag_none; -} -KERNAUX_PACKED -multiboot2_header = { - .multiboot2_header = { - .magic = KERNAUX_MULTIBOOT2_HEADER_MAGIC, - .arch = KERNAUX_MULTIBOOT2_HEADER_ARCH_I386, - .total_size = sizeof(multiboot2_header), - .checksum = KERNAUX_MULTIBOOT2_HEADER_CHECKSUM( - KERNAUX_MULTIBOOT2_HEADER_ARCH_I386, - sizeof(multiboot2_header) - ), - }, - .tag_none = { - .base = { - .type = KERNAUX_MULTIBOOT2_HTAG_NONE, - .flags = 0, - .size = sizeof(multiboot2_header.tag_none), - }, - }, -}; - -#include diff --git a/examples/full/i386-multiboot2-limine/rootfs/boot/limine.cfg b/examples/full/i386-multiboot2-limine/rootfs/boot/limine.cfg deleted file mode 100644 index 51ddf389..00000000 --- a/examples/full/i386-multiboot2-limine/rootfs/boot/limine.cfg +++ /dev/null @@ -1,8 +0,0 @@ -DEFAULT_ENTRY=1 -TIMEOUT=0 - -:Kernel - -PROTOCOL=multiboot2 -KERNEL_PATH=boot:///boot/kernel -KERNEL_CMDLINE=hello kernel diff --git a/examples/full/i386-multiboot2-limine/start.S b/examples/full/i386-multiboot2-limine/start.S deleted file mode 100644 index 713cdd09..00000000 --- a/examples/full/i386-multiboot2-limine/start.S +++ /dev/null @@ -1,27 +0,0 @@ -.section .bss - -.global _kernel_stack_start -.global _kernel_stack_end - -.align 16 -_kernel_stack_start: -.skip 16384 # 16 KiB -_kernel_stack_end: - - - -.section .text - -.global _start - -.type _start, @function - -_start: - mov $_kernel_stack_end, %esp // Initialize stack - - push %ebx // Multiboot information pointer - push %eax // Multiboot magic number - call main - call kernaux_drivers_shutdown_poweroff - -.size _start, . - _start diff --git a/examples/full/riscv64/.gitignore b/examples/full/riscv64/.gitignore deleted file mode 100644 index 96302b73..00000000 --- a/examples/full/riscv64/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/kernel.elf diff --git a/examples/full/riscv64/Makefile b/examples/full/riscv64/Makefile deleted file mode 100644 index f3ba7381..00000000 --- a/examples/full/riscv64/Makefile +++ /dev/null @@ -1,46 +0,0 @@ -all: run - -REPO = ../../.. - -CCPREFIX = $(REPO)/vendor/cross/root/bin/riscv64-elf- - -AS = $(CCPREFIX)as -CC = $(CCPREFIX)gcc - -LIBKERNAUX_BUILD = $(REPO)/build/dev-cross-riscv64 -LIBKERNAUX_DEST = $(REPO)/dest/dev-cross-riscv64 - -QEMU = qemu-system-riscv64 -serial stdio -display none - -KERNEL = kernel.elf -LINKERSCR = linker.ld - -CFLAGS = \ - -std=c99 \ - -pedantic \ - -Wall \ - -Wextra \ - -Werror \ - -ffreestanding \ - -mcmodel=medany \ - -I$(LIBKERNAUX_DEST)/include - -OBJS = main.c.o start.S.o - -run: $(KERNEL) - $(QEMU) -machine virt -bios $< - -clean: - rm -f $(KERNEL) $(OBJS) - -$(KERNEL): $(LINKERSCR) build-libkernaux.a $(OBJS) - $(CC) -T $(LINKERSCR) -o $@ $(OBJS) -nostdlib -lkernaux -lgcc -Wl,-L$(LIBKERNAUX_DEST)/lib - -build-libkernaux.a: - cd $(LIBKERNAUX_BUILD) && ./config && make install - -%.c.o: %.c - $(CC) -c $< -o $@ $(CFLAGS) - -%.S.o: %.S - $(AS) $< -o $@ diff --git a/examples/full/riscv64/linker.ld b/examples/full/riscv64/linker.ld deleted file mode 100644 index f4da9c15..00000000 --- a/examples/full/riscv64/linker.ld +++ /dev/null @@ -1,33 +0,0 @@ -ENTRY(_start); - -SECTIONS -{ - . = 0x80000000; - - .text : ALIGN(4K) - { - *(.init); - *(.text); - } - - .rodata : ALIGN(4K) - { - *(.rodata); - } - - .data : ALIGN(4K) - { - *(.data); - } - - .bss : ALIGN(4K) - { - PROVIDE(bss_start = .); - *(.bss); - . += 4096; - PROVIDE(stack_top = .); - . += 4096; - PROVIDE(global_pointer = .); - PROVIDE(bss_end = .); - } -} diff --git a/examples/full/riscv64/main.c b/examples/full/riscv64/main.c deleted file mode 100644 index 9c5826a3..00000000 --- a/examples/full/riscv64/main.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#include - -static unsigned char *const uart = (unsigned char*)0x10000000; - -static void putchar(char c) { - *uart = c; -} - -static void print(const char * str) { - while (*str != '\0') { - putchar(*str); - str++; - } -} - -void main() { - print("Hello world!\r\n"); - kernaux_drivers_shutdown_poweroff(); -} diff --git a/examples/full/riscv64/start.S b/examples/full/riscv64/start.S deleted file mode 100644 index 82c64e96..00000000 --- a/examples/full/riscv64/start.S +++ /dev/null @@ -1,37 +0,0 @@ -.section .init - -.option norvc - -.type _start, @function -.global _start -_start: - .cfi_startproc - -.option push -.option norelax - la gp, global_pointer -.option pop - - /* Reset satp */ - csrw satp, zero - - /* Setup stack */ - la sp, stack_top - - /* Clear the BSS section */ - la t5, bss_start - la t6, bss_end -bss_clear: - sd zero, (t5) - addi t5, t5, 8 - bgeu t5, t6, bss_clear - - la t0, main - csrw mepc, t0 - - /* Jump to kernel! */ - tail main - - .cfi_endproc - -.end diff --git a/include/Makefile.am b/include/Makefile.am index ba0be6cf..64eba2d8 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -89,27 +89,3 @@ endif if WITH_UNITS nobase_include_HEADERS += kernaux/units.h endif - -########### -# Drivers # -########### - -if WITH_DRIVERS -nobase_include_HEADERS += \ - kernaux/drivers/console.h \ - kernaux/drivers/framebuffer.h \ - kernaux/drivers/shutdown.h - -# Intel 8253-compatible programmable interval timer - -if ASM_I386 -nobase_include_HEADERS += kernaux/drivers/intel_8253_pit.h -endif - -# Intel 8259-compatible programmable interrupt controller - -if ASM_I386 -nobase_include_HEADERS += kernaux/drivers/intel_8259_pic.h -endif - -endif # WITH_DRIVERS diff --git a/include/kernaux/drivers/console.h.in b/include/kernaux/drivers/console.h.in deleted file mode 100644 index 491ac5f7..00000000 --- a/include/kernaux/drivers/console.h.in +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef KERNAUX_INCLUDED_DRIVERS_CONSOLE -#define KERNAUX_INCLUDED_DRIVERS_CONSOLE - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -void kernaux_drivers_console_putc(char c); - -void kernaux_drivers_console_print(const char *s); -@comment_line_printf@KERNAUX_PRINTF(1, 2) -@comment_line_printf@void kernaux_drivers_console_printf(const char *format, ...); -void kernaux_drivers_console_puts(const char *s); -void kernaux_drivers_console_write(const char *data, size_t size); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/kernaux/drivers/framebuffer.h b/include/kernaux/drivers/framebuffer.h deleted file mode 100644 index ab2c901d..00000000 --- a/include/kernaux/drivers/framebuffer.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef KERNAUX_INCLUDED_DRIVERS_FRAMEBUFFER -#define KERNAUX_INCLUDED_DRIVERS_FRAMEBUFFER - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/kernaux/drivers/intel_8253_pit.h b/include/kernaux/drivers/intel_8253_pit.h deleted file mode 100644 index 1f0bdce8..00000000 --- a/include/kernaux/drivers/intel_8253_pit.h +++ /dev/null @@ -1,21 +0,0 @@ -/** - * @brief A driver for Intel 8253-compatible programmable interval timer - * - * @see https://en.wikipedia.org/wiki/Intel_8253 - * @see https://wiki.osdev.org/PIT - */ - -#ifndef KERNAUX_INCLUDED_DRIVERS_INTEL_8253_PIT -#define KERNAUX_INCLUDED_DRIVERS_INTEL_8253_PIT - -#ifdef __cplusplus -extern "C" { -#endif - -void kernaux_drivers_intel_8253_pit_initialize(unsigned int freq); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/kernaux/drivers/intel_8259_pic.h b/include/kernaux/drivers/intel_8259_pic.h deleted file mode 100644 index d58e2dc6..00000000 --- a/include/kernaux/drivers/intel_8259_pic.h +++ /dev/null @@ -1,57 +0,0 @@ -/** - * @brief A driver for Intel 8259-compatible programmable interrupt controller - * - * @details - * This is not a driver for a random Intel 8259-compatible PIC, but only for a - * typical configuration of it that can be found in most PCs. - * - * @see https://en.wikipedia.org/wiki/Intel_8259 - * @see https://wiki.osdev.org/8259_PIC - * @see https://pdos.csail.mit.edu/6.828/2005/readings/hardware/8259A.pdf - */ - -#ifndef KERNAUX_INCLUDED_DRIVERS_INTEL_8259_PIC -#define KERNAUX_INCLUDED_DRIVERS_INTEL_8259_PIC - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Enable PIC - */ -void kernaux_drivers_intel_8259_pic_enable_all(); - -/** - * @brief Disable PIC - */ -void kernaux_drivers_intel_8259_pic_disable_all(); - -/** - * @brief Enable single IRQ line - */ -void kernaux_drivers_intel_8259_pic_enable(unsigned char number); - -/** - * @brief Disable single IRQ line - */ -void kernaux_drivers_intel_8259_pic_disable(unsigned char number); - -/** - * @brief Remap PIC - */ -void kernaux_drivers_intel_8259_pic_remap( - unsigned char new_master_start, - unsigned char new_slave_start -); - -/** - * @brief Signal end of interrupt - */ -void kernaux_drivers_intel_8259_pic_eoi(unsigned char number); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/kernaux/drivers/shutdown.h b/include/kernaux/drivers/shutdown.h deleted file mode 100644 index b3d83470..00000000 --- a/include/kernaux/drivers/shutdown.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef KERNAUX_INCLUDED_DRIVERS_SHUTDOWN -#define KERNAUX_INCLUDED_DRIVERS_SHUTDOWN - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -KERNAUX_NORETURN void kernaux_drivers_shutdown_halt(); -KERNAUX_NORETURN void kernaux_drivers_shutdown_poweroff(); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/drivers/console.c b/src/drivers/console.c deleted file mode 100644 index 7a53f5e9..00000000 --- a/src/drivers/console.c +++ /dev/null @@ -1,78 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#ifdef ASM_I386 -#include -#endif -#ifdef ASM_X86_64 -#include -#endif - -#ifdef WITH_PRINTF -#include -#endif - -#include - -#ifdef WITH_PRINTF -static void file_putc(char c, void *arg); -#endif - -void kernaux_drivers_console_putc(const char c) -{ -#if defined(ASM_X86) - kernaux_asm_x86_outportb(0x3f8, c); -#else - (void)c; -#endif -} - -void kernaux_drivers_console_print(const char *const s) -{ - KERNAUX_ASSERT(s); - - for (const char *c = s; *c; ++c) { - kernaux_drivers_console_putc(*c); - } -} - -#ifdef WITH_PRINTF -void kernaux_drivers_console_printf(const char *format, ...) -{ - KERNAUX_ASSERT(format); - - va_list va; - va_start(va, format); - kernaux_vfprintf(file_putc, NULL, format, va); - va_end(va); -} -#endif - -void kernaux_drivers_console_puts(const char *const s) -{ - KERNAUX_ASSERT(s); - - kernaux_drivers_console_print(s); - kernaux_drivers_console_putc('\n'); -} - -void kernaux_drivers_console_write(const char *const data, const size_t size) -{ - KERNAUX_ASSERT(data); - - for (size_t i = 0; i < size; i++) { - kernaux_drivers_console_putc(data[i]); - } -} - -#ifdef WITH_PRINTF -void file_putc(char c, void *arg KERNAUX_UNUSED) -{ - kernaux_drivers_console_putc(c); -} -#endif diff --git a/src/drivers/framebuffer.c b/src/drivers/framebuffer.c deleted file mode 100644 index 106863bf..00000000 --- a/src/drivers/framebuffer.c +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -KERNAUX_UNUSED -static const int foobar = 0; diff --git a/src/drivers/intel_8253_pit.c b/src/drivers/intel_8253_pit.c deleted file mode 100644 index cdc2fec8..00000000 --- a/src/drivers/intel_8253_pit.c +++ /dev/null @@ -1,26 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#ifdef ASM_I386 -#include -#endif - -#include - -void kernaux_drivers_intel_8253_pit_initialize(const unsigned int freq) -{ - KERNAUX_ASSERT(freq); - - const unsigned int divisor = 1193180 / freq; - - const uint8_t l = divisor & 0xff; - const uint8_t h = (divisor >> 8) & 0xff; - - kernaux_asm_x86_outportb(0x43, 0x36); - kernaux_asm_x86_outportb(0x40, l); - kernaux_asm_x86_outportb(0x40, h); -} diff --git a/src/drivers/intel_8259_pic.c b/src/drivers/intel_8259_pic.c deleted file mode 100644 index ce824ddc..00000000 --- a/src/drivers/intel_8259_pic.c +++ /dev/null @@ -1,113 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include - -#ifdef ASM_I386 -#include -#endif - -#include -#include - -#define MASTER_COMMAND_PORT 0x20 -#define SLAVE_COMMAND_PORT 0xA0 - -#define MASTER_DATA_PORT 0x21 -#define SLAVE_DATA_PORT 0xA1 - -#define IRQS_COUNT 8 -#define IRQS_TOTAL 16 - -static unsigned char master_start = 0; -static unsigned char slave_start = 8; - -void kernaux_drivers_intel_8259_pic_enable_all() -{ - kernaux_asm_x86_outportb(MASTER_DATA_PORT, 0); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, 0); -} - -void kernaux_drivers_intel_8259_pic_disable_all() -{ - kernaux_asm_x86_outportb(MASTER_DATA_PORT, 0xFF); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, 0xFF); -} - -void kernaux_drivers_intel_8259_pic_enable(const unsigned char number) -{ - KERNAUX_ASSERT(number < IRQS_TOTAL); - - if (number < IRQS_COUNT) { - const uint8_t mask = kernaux_asm_x86_inportb(MASTER_DATA_PORT); - kernaux_asm_x86_outportb(MASTER_DATA_PORT, - mask & ~KERNAUX_BITS8(number)); - } else { - const uint8_t mask = kernaux_asm_x86_inportb(SLAVE_DATA_PORT); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, - mask & ~KERNAUX_BITS8((number - IRQS_COUNT))); - } -} - -void kernaux_drivers_intel_8259_pic_disable(const unsigned char number) -{ - KERNAUX_ASSERT(number < IRQS_TOTAL); - - if (number < IRQS_COUNT) { - const uint8_t mask = kernaux_asm_x86_inportb(MASTER_DATA_PORT); - kernaux_asm_x86_outportb(MASTER_DATA_PORT, - mask | KERNAUX_BITS8(number)); - } else { - const uint8_t mask = kernaux_asm_x86_inportb(SLAVE_DATA_PORT); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, - mask | KERNAUX_BITS8((number - IRQS_COUNT))); - } -} - -void kernaux_drivers_intel_8259_pic_remap( - const unsigned char new_master_start, - const unsigned char new_slave_start -) { - master_start = new_master_start; - slave_start = new_slave_start; - - // Save masks - const uint8_t master_mask = kernaux_asm_x86_inportb(MASTER_DATA_PORT); - const uint8_t slave_mask = kernaux_asm_x86_inportb(SLAVE_DATA_PORT); - - // Start the initialization sequence - kernaux_asm_x86_outportb(MASTER_COMMAND_PORT, 0x11); - kernaux_asm_x86_outportb(SLAVE_COMMAND_PORT, 0x11); - - // Set IRQ vectors - kernaux_asm_x86_outportb(MASTER_DATA_PORT, new_master_start); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, new_slave_start); - - // Connect master and slave with each other - kernaux_asm_x86_outportb(MASTER_DATA_PORT, 0x04); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, 0x02); - - // 8086/88 (MCS-80/85) mode - kernaux_asm_x86_outportb(MASTER_DATA_PORT, 0x01); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, 0x01); - - // Restore masks - kernaux_asm_x86_outportb(MASTER_DATA_PORT, master_mask); - kernaux_asm_x86_outportb(SLAVE_DATA_PORT, slave_mask); -} - -void kernaux_drivers_intel_8259_pic_eoi(const unsigned char number) -{ - KERNAUX_ASSERT(number < IRQS_TOTAL); - - const bool to_slave = - number >= slave_start && number < slave_start + IRQS_COUNT; - const bool to_master = to_slave || - (number >= master_start && number < master_start + IRQS_COUNT); - - if (to_slave) kernaux_asm_x86_outportb(SLAVE_COMMAND_PORT, 0x20); - if (to_master) kernaux_asm_x86_outportb(MASTER_COMMAND_PORT, 0x20); -} diff --git a/src/drivers/shutdown.c b/src/drivers/shutdown.c deleted file mode 100644 index 881de2f9..00000000 --- a/src/drivers/shutdown.c +++ /dev/null @@ -1,33 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#ifdef ASM_X86 -#include -#endif - -void kernaux_drivers_shutdown_halt() -{ -#ifdef ASM_X86 - // Disable interrupts - KERNAUX_ASM("cli"); -#endif - - volatile int x = 0; - for (;;) ++x; -} - -void kernaux_drivers_shutdown_poweroff() -{ -#ifdef ASM_X86 - // QEMU >= 2.0 - kernaux_asm_x86_outportw(0x604, 0x2000); - // QEMU < 2.0 - kernaux_asm_x86_outportw(0xB004, 0x2000); -#endif - - // If we can't poweroff then we halt - kernaux_drivers_shutdown_halt(); -} diff --git a/vendor/limine b/vendor/limine deleted file mode 160000 index 3277ad25..00000000 --- a/vendor/limine +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3277ad25cfbe5150daeae2de61d2c0b6613b8a0b diff --git a/vendor/opensbi b/vendor/opensbi deleted file mode 160000 index 4489876e..00000000 --- a/vendor/opensbi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4489876e933d8ba0d8bc6c64bae71e295d45faac diff --git a/vendor/u-boot b/vendor/u-boot deleted file mode 160000 index 4debc57a..00000000 --- a/vendor/u-boot +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4debc57a3da6c3f4d3f89a637e99206f4cea0a96