diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb9add26..dd76a60a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -94,6 +94,22 @@ jobs: - name: install run: sudo make install + freestanding: + runs-on: ubuntu-latest + strategy: + matrix: + debug: ['--disable-debug', '--enable-debug'] + steps: + - uses: actions/checkout@v2 + - name: dependencies + run: sudo apt-get --yes install crossbuild-essential-i386 + - 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)" + - name: make + run: make + dist: runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 668b2ef2..df7603b3 100644 --- a/.gitignore +++ b/.gitignore @@ -101,7 +101,7 @@ /include/Makefile /include/kernaux.h -/include/kernaux/console.h +/include/kernaux/drivers/console.h /include/kernaux/multiboot2.h /include/kernaux/printf.h /include/kernaux/version.h diff --git a/ChangeLog b/ChangeLog index 6851f7d1..079429af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2022-06-23 Alex Kotov + + * configure.ac: Added package "drivers" + 2022-06-22 Alex Kotov * include/kernaux/free_list.h: Finished diff --git a/Makefile.am b/Makefile.am index b1e38983..b5984990 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,6 +23,10 @@ AM_CFLAGS += -DKERNAUX_ACCESS_PRIVATE lib_LTLIBRARIES = libkernaux.la +################## +# Required files # +################## + libkernaux_la_LIBADD = libkernaux_la_SOURCES = \ src/assert.c \ @@ -30,6 +34,18 @@ libkernaux_la_SOURCES = \ src/generic/malloc.c \ src/generic/mutex.c +######## +# libc # +######## + +if WITH_LIBC +libkernaux_la_LIBADD += libc/libc.la +endif + +####### +# ASM # +####### + if ASM_I386 libkernaux_la_SOURCES += src/asm/i386.S endif @@ -39,27 +55,34 @@ endif if ASM_X86_64 libkernaux_la_SOURCES += src/asm/x86_64.S endif + +########### +# Drivers # +########### + +if WITH_DRIVERS +libkernaux_la_SOURCES += \ + src/drivers/console.c \ + src/drivers/framebuffer.c \ + src/drivers/intel_8259_pic.c +endif + +#################### +# Default packages # +#################### + if WITH_CMDLINE libkernaux_la_SOURCES += src/cmdline.c endif -if WITH_CONSOLE -libkernaux_la_SOURCES += src/console.c -endif if WITH_ELF libkernaux_la_SOURCES += src/elf.c endif -if WITH_FRAMEBUFFER -libkernaux_la_SOURCES += src/framebuffer.c -endif if WITH_FREE_LIST libkernaux_la_SOURCES += src/free_list.c endif if WITH_IO libkernaux_la_SOURCES += src/io.c endif -if WITH_LIBC -libkernaux_la_LIBADD += libc/libc.la -endif if WITH_MBR libkernaux_la_SOURCES += src/mbr.c endif diff --git a/README.md b/README.md index 38e66974..fb9f9932 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,6 @@ zero). Work-in-progress APIs can change at any time. * [Example](/examples/generic_malloc.c) * [Mutex](/include/kernaux/generic/mutex.h) (*non-breaking since* **?.?.?**) * [Example](/examples/generic_mutex.c) -* Device drivers (for debugging only) - * [Serial console](/include/kernaux/console.h) (*work in progress*) - * [Framebuffer](/include/kernaux/framebuffer.h) (*planned*) - * USB (*planned*) * Algorithms * [Free list memory allocator](/include/kernaux/free_list.h) (*non-breaking since* **?.?.?**) * [Simple command line parser](/include/kernaux/cmdline.h) (*non-breaking since* **0.2.0**) @@ -91,6 +87,11 @@ zero). Work-in-progress APIs can change at any time. * [stdlib.h](/libc/include/stdlib.h) * [string.h](/libc/include/string.h) * [sys/types.h](/libc/include/sys/types.h) +* Device drivers (for debugging only) + * [Serial console](/include/kernaux/drivers/console.h) (*work in progress*) + * [Framebuffer](/include/kernaux/drivers/framebuffer.h) (*planned*) + * [Intel 8259 PIC](/include/kernaux/drivers/intel_8259_pic.h) (*planned*) + * USB (*planned*) ### Definitions @@ -138,6 +139,7 @@ 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. @@ -200,6 +202,7 @@ 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 70ecef7c..e3ba447a 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-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc diff --git a/config/dev-cross-riscv64 b/config/dev-cross-riscv64 index 57b29fff..66e9ad3b 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-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc diff --git a/config/dev-cross-x86_64 b/config/dev-cross-x86_64 index 4a900b6d..a5460265 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-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc diff --git a/config/root-cross-i386-linux b/config/root-cross-i386-linux index 7740099b..fc579cff 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-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc diff --git a/config/root-cross-riscv64-linux b/config/root-cross-riscv64-linux index af99c56d..898dc4ee 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-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc diff --git a/config/root-cross-x86_64-linux b/config/root-cross-x86_64-linux index 5d8fd627..42532a1b 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-libc +"$REPO/configure" --host="$HOST" --prefix="$PREFIX" --enable-freestanding --with-drivers --with-libc diff --git a/configure.ac b/configure.ac index 1095946b..c3741dac 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,7 @@ AC_CONFIG_FILES([ libc/Makefile libc/include/Makefile include/kernaux.h - include/kernaux/console.h + include/kernaux/drivers/console.h include/kernaux/multiboot2.h include/kernaux/printf.h include/kernaux/version.h @@ -58,9 +58,7 @@ AC_ARG_ENABLE([tests-python], AS_HELP_STRING([--enable-tests-python], [enable te dnl Packages (enabled by default) AC_ARG_WITH( [all], AS_HELP_STRING([--without-all], [without all default packages])) AC_ARG_WITH( [cmdline], AS_HELP_STRING([--without-cmdline], [without command line parser])) -AC_ARG_WITH( [console], AS_HELP_STRING([--without-console], [without serial console])) AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [without ELF utils])) -AC_ARG_WITH( [framebuffer], AS_HELP_STRING([--without-framebuffer], [without framebuffer])) AC_ARG_WITH( [free-list], AS_HELP_STRING([--without-free-list], [without free list memory allocator])) AC_ARG_WITH( [io], AS_HELP_STRING([--without-io], [without input/output])) AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without Master Boot Record])) @@ -73,6 +71,7 @@ AC_ARG_WITH( [printf-fmt], AS_HELP_STRING([--without-printf-fmt], [without p 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])) @@ -91,9 +90,7 @@ AS_IF([test "$enable_tests_all" = yes], do_enable_tests_all) AC_DEFUN([do_without_all], [ if test -z "$with_cmdline"; then with_cmdline=no; fi -if test -z "$with_console"; then with_console=no; fi if test -z "$with_elf"; then with_elf=no; fi -if test -z "$with_framebuffer"; then with_framebuffer=no; fi if test -z "$with_free_list"; then with_free_list=no; fi if test -z "$with_io"; then with_io=no; fi if test -z "$with_mbr"; then with_mbr=no; fi @@ -128,9 +125,7 @@ AS_IF([test "$enable_tests_python" = yes], [enable_tests_python=yes], [enable_te dnl Packages (enabled by default) AS_IF([test "$with_all" = no ], [with_all=no], [with_all=yes]) AS_IF([test "$with_cmdline" = no ], [with_cmdline=no], [with_cmdline=yes]) -AS_IF([test "$with_console" = no ], [with_console=no], [with_console=yes]) AS_IF([test "$with_elf" = no ], [with_elf=no], [with_elf=yes]) -AS_IF([test "$with_framebuffer" = no ], [with_framebuffer=no], [with_framebuffer=yes]) AS_IF([test "$with_free_list" = no ], [with_free_list=no], [with_free_list=yes]) AS_IF([test "$with_io" = no ], [with_io=no], [with_io=yes]) AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes]) @@ -143,6 +138,7 @@ AS_IF([test "$with_printf_fmt" = no ], [with_printf_fmt=no], [with_prin 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]) @@ -184,9 +180,7 @@ AM_CONDITIONAL([ENABLE_TESTS_PYTHON], [test "$enable_tests_python" = yes]) dnl Packages (enabled by default) AM_CONDITIONAL([WITH_CMDLINE], [test "$with_cmdline" = yes]) -AM_CONDITIONAL([WITH_CONSOLE], [test "$with_console" = yes]) AM_CONDITIONAL([WITH_ELF], [test "$with_elf" = yes]) -AM_CONDITIONAL([WITH_FRAMEBUFFER], [test "$with_framebuffer" = yes]) AM_CONDITIONAL([WITH_FREE_LIST], [test "$with_free_list" = yes]) AM_CONDITIONAL([WITH_IO], [test "$with_io" = yes]) AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes]) @@ -199,6 +193,7 @@ 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]) @@ -225,9 +220,7 @@ AS_IF([test "$enable_tests_python" = yes], [AC_DEFINE([ENABLE_TESTS_PYTHON], [1] dnl Packages (enabled by default) AS_IF([test "$with_cmdline" = yes], [AC_DEFINE([WITH_CMDLINE], [1], [with command line parser])]) -AS_IF([test "$with_console" = yes], [AC_DEFINE([WITH_CONSOLE], [1], [with serial console])]) AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF], [1], [with ELF utils])]) -AS_IF([test "$with_framebuffer" = yes], [AC_DEFINE([WITH_FRAMEBUFFER], [1], [with framebuffer])]) AS_IF([test "$with_free_list" = yes], [AC_DEFINE([WITH_FREE_LIST], [1], [with free list memory allocator])]) AS_IF([test "$with_io" = yes], [AC_DEFINE([WITH_IO], [1], [with input/output])]) AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with Master Boot Record])]) @@ -240,6 +233,7 @@ AS_IF([test "$with_printf_fmt" = yes], [AC_DEFINE([WITH_PRINTF_FMT], [1] 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 Additional @@ -253,9 +247,7 @@ AS_IF([test "$enable_debug" = yes], [AC_DEFINE([KERNAUX_DEBUG], [1] dnl Packages (enabled by default) AS_IF([test "$with_cmdline" = no], [AC_SUBST([comment_line_cmdline], [//])]) -AS_IF([test "$with_console" = no], [AC_SUBST([comment_line_console], [//])]) AS_IF([test "$with_elf" = no], [AC_SUBST([comment_line_elf], [//])]) -AS_IF([test "$with_framebuffer" = no], [AC_SUBST([comment_line_framebuffer], [//])]) AS_IF([test "$with_free_list" = no], [AC_SUBST([comment_line_free_list], [//])]) AS_IF([test "$with_io" = no], [AC_SUBST([comment_line_io], [//])]) AS_IF([test "$with_mbr" = no], [AC_SUBST([comment_line_mbr], [//])]) diff --git a/examples/bootloader-multiboot2-grub/main.c b/examples/bootloader-multiboot2-grub/main.c index cbc4329d..b131c120 100644 --- a/examples/bootloader-multiboot2-grub/main.c +++ b/examples/bootloader-multiboot2-grub/main.c @@ -2,7 +2,7 @@ #include #include -#include +#include #include void poweroff(); @@ -18,24 +18,32 @@ void main( if (!KernAux_Multiboot2_Header_is_valid(&multiboot2_header)) { panic("Multiboot 2 header is invalid"); } else { - kernaux_console_printf("Multiboot 2 header is valid\n"); + kernaux_drivers_console_printf("Multiboot 2 header is valid\n"); } - KernAux_Multiboot2_Header_print(&multiboot2_header, kernaux_console_printf); + 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_console_printf("Multiboot 2 info magic number is valid\n"); + 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_console_printf("Multiboot 2 info is valid\n"); + kernaux_drivers_console_printf("Multiboot 2 info is valid\n"); } - KernAux_Multiboot2_Info_print(multiboot2_info, kernaux_console_printf); + KernAux_Multiboot2_Info_print( + multiboot2_info, + kernaux_drivers_console_printf + ); } void poweroff() @@ -45,6 +53,6 @@ void poweroff() void panic(const char *const str) { - kernaux_console_printf("panic: %s\n", str); + kernaux_drivers_console_printf("panic: %s\n", str); poweroff(); } diff --git a/examples/bootloader-multiboot2-limine/main.c b/examples/bootloader-multiboot2-limine/main.c index cbc4329d..b131c120 100644 --- a/examples/bootloader-multiboot2-limine/main.c +++ b/examples/bootloader-multiboot2-limine/main.c @@ -2,7 +2,7 @@ #include #include -#include +#include #include void poweroff(); @@ -18,24 +18,32 @@ void main( if (!KernAux_Multiboot2_Header_is_valid(&multiboot2_header)) { panic("Multiboot 2 header is invalid"); } else { - kernaux_console_printf("Multiboot 2 header is valid\n"); + kernaux_drivers_console_printf("Multiboot 2 header is valid\n"); } - KernAux_Multiboot2_Header_print(&multiboot2_header, kernaux_console_printf); + 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_console_printf("Multiboot 2 info magic number is valid\n"); + 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_console_printf("Multiboot 2 info is valid\n"); + kernaux_drivers_console_printf("Multiboot 2 info is valid\n"); } - KernAux_Multiboot2_Info_print(multiboot2_info, kernaux_console_printf); + KernAux_Multiboot2_Info_print( + multiboot2_info, + kernaux_drivers_console_printf + ); } void poweroff() @@ -45,6 +53,6 @@ void poweroff() void panic(const char *const str) { - kernaux_console_printf("panic: %s\n", str); + kernaux_drivers_console_printf("panic: %s\n", str); poweroff(); } diff --git a/include/Makefile.am b/include/Makefile.am index 45e9ce02..24cf1e3b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,3 +1,7 @@ +################## +# Required files # +################## + nobase_include_HEADERS = \ kernaux.h \ kernaux/arch/i386.h \ @@ -9,6 +13,10 @@ nobase_include_HEADERS = \ kernaux/generic/malloc.h \ kernaux/generic/mutex.h +####### +# ASM # +####### + if ASM_I386 nobase_include_HEADERS += kernaux/asm/i386.h endif @@ -19,18 +27,27 @@ if ASM_X86_64 nobase_include_HEADERS += kernaux/asm/x86_64.h endif +########### +# Drivers # +########### + +if WITH_DRIVERS +nobase_include_HEADERS += \ + kernaux/drivers/console.h \ + kernaux/drivers/framebuffer.h \ + kernaux/drivers/intel_8259_pic.h +endif + +#################### +# Default packages # +#################### + if WITH_CMDLINE nobase_include_HEADERS += kernaux/cmdline.h endif -if WITH_CONSOLE -nobase_include_HEADERS += kernaux/console.h -endif if WITH_ELF nobase_include_HEADERS += kernaux/elf.h endif -if WITH_FRAMEBUFFER -nobase_include_HEADERS += kernaux/framebuffer.h -endif if WITH_FREE_LIST nobase_include_HEADERS += kernaux/free_list.h endif diff --git a/include/kernaux.h.in b/include/kernaux.h.in index 92c339ce..47490224 100644 --- a/include/kernaux.h.in +++ b/include/kernaux.h.in @@ -11,9 +11,7 @@ #include @comment_line_cmdline@#include -@comment_line_console@#include @comment_line_elf@#include -@comment_line_framebuffer@#include @comment_line_free_list@#include @comment_line_io@#include @comment_line_mbr@#include diff --git a/include/kernaux/console.h.in b/include/kernaux/console.h.in deleted file mode 100644 index 4b38c3c0..00000000 --- a/include/kernaux/console.h.in +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef KERNAUX_INCLUDED_CONSOLE -#define KERNAUX_INCLUDED_CONSOLE - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -void kernaux_console_putc(char c); - -void kernaux_console_print(const char *s); -@comment_line_printf@void kernaux_console_printf(const char *format, ...) -@comment_line_printf@__attribute__((format(printf, 1, 2))); -void kernaux_console_puts(const char *s); -void kernaux_console_write(const char *data, size_t size); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/kernaux/drivers/console.h.in b/include/kernaux/drivers/console.h.in new file mode 100644 index 00000000..d8d63d1e --- /dev/null +++ b/include/kernaux/drivers/console.h.in @@ -0,0 +1,22 @@ +#ifndef KERNAUX_INCLUDED_DRIVERS_CONSOLE +#define KERNAUX_INCLUDED_DRIVERS_CONSOLE + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void kernaux_drivers_console_putc(char c); + +void kernaux_drivers_console_print(const char *s); +@comment_line_printf@void kernaux_drivers_console_printf(const char *format, ...) +@comment_line_printf@__attribute__((format(printf, 1, 2))); +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 new file mode 100644 index 00000000..ab2c901d --- /dev/null +++ b/include/kernaux/drivers/framebuffer.h @@ -0,0 +1,12 @@ +#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_8259_pic.h b/include/kernaux/drivers/intel_8259_pic.h new file mode 100644 index 00000000..9cddf1cf --- /dev/null +++ b/include/kernaux/drivers/intel_8259_pic.h @@ -0,0 +1,12 @@ +#ifndef KERNAUX_INCLUDED_DRIVERS_INTEL_8259_PIC +#define KERNAUX_INCLUDED_DRIVERS_INTEL_8259_PIC + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/kernaux/framebuffer.h b/include/kernaux/framebuffer.h deleted file mode 100644 index 7c25c624..00000000 --- a/include/kernaux/framebuffer.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef KERNAUX_INCLUDED_FRAMEBUFFER -#define KERNAUX_INCLUDED_FRAMEBUFFER - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/kernaux/version.h.in b/include/kernaux/version.h.in index 6c1cfaf7..0534d303 100644 --- a/include/kernaux/version.h.in +++ b/include/kernaux/version.h.in @@ -2,9 +2,7 @@ #define KERNAUX_INCLUDED_VERSION @comment_line_cmdline@#define KERNAUX_VERSION_WITH_CMDLINE -@comment_line_console@#define KERNAUX_VERSION_WITH_CONSOLE @comment_line_elf@#define KERNAUX_VERSION_WITH_ELF -@comment_line_framebuffer@#define KERNAUX_VERSION_WITH_FRAMEBUFFER @comment_line_io@#define KERNAUX_VERSION_WITH_IO @comment_line_mbr@#define KERNAUX_VERSION_WITH_MBR @comment_line_multiboot2@#define KERNAUX_VERSION_WITH_MULTIBOOT2 diff --git a/src/console.c b/src/drivers/console.c similarity index 57% rename from src/console.c rename to src/drivers/console.c index 69ed3147..8b72cd1e 100644 --- a/src/console.c +++ b/src/drivers/console.c @@ -3,9 +3,7 @@ #endif #include -#include - -#include "libc.h" +#include #ifdef ASM_I386 #include @@ -24,15 +22,15 @@ #include #if defined(WITH_IO) && defined(WITH_PRINTF) -static void kernaux_console_printf_putc( +static void kernaux_drivers_console_printf_putc( const char c, void *const arg __attribute__((unused)) ) { - kernaux_console_putc(c); + kernaux_drivers_console_putc(c); } #endif -void kernaux_console_putc(const char c __attribute__((unused))) +void kernaux_drivers_console_putc(const char c __attribute__((unused))) { #ifdef ASM_I386 kernaux_asm_i386_outportb(0x3f8, c); @@ -42,41 +40,42 @@ void kernaux_console_putc(const char c __attribute__((unused))) #endif } -void kernaux_console_print(const char *const s) +void kernaux_drivers_console_print(const char *const s) { KERNAUX_ASSERT(s); for (const char *c = s; *c; ++c) { - kernaux_console_putc(*c); + kernaux_drivers_console_putc(*c); } } #if defined(WITH_IO) && defined(WITH_PRINTF) -void kernaux_console_printf(const char *format, ...) +void kernaux_drivers_console_printf(const char *format, ...) { KERNAUX_ASSERT(format); va_list va; va_start(va, format); - struct KernAux_File file = KernAux_File_create(kernaux_console_printf_putc); + struct KernAux_File file = + KernAux_File_create(kernaux_drivers_console_printf_putc); kernaux_vfprintf(&file, NULL, format, va); va_end(va); } #endif -void kernaux_console_puts(const char *const s) +void kernaux_drivers_console_puts(const char *const s) { KERNAUX_ASSERT(s); - kernaux_console_print(s); - kernaux_console_putc('\n'); + kernaux_drivers_console_print(s); + kernaux_drivers_console_putc('\n'); } -void kernaux_console_write(const char *const data, const size_t size) +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_console_putc(data[i]); + kernaux_drivers_console_putc(data[i]); } } diff --git a/src/framebuffer.c b/src/drivers/framebuffer.c similarity index 71% rename from src/framebuffer.c rename to src/drivers/framebuffer.c index 7ec5b915..c25bb09f 100644 --- a/src/framebuffer.c +++ b/src/drivers/framebuffer.c @@ -2,7 +2,7 @@ #include "config.h" #endif -#include +#include __attribute__((unused)) static const int foobar = 0; diff --git a/src/drivers/intel_8259_pic.c b/src/drivers/intel_8259_pic.c new file mode 100644 index 00000000..66b9cc7b --- /dev/null +++ b/src/drivers/intel_8259_pic.c @@ -0,0 +1,8 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +__attribute__((unused)) +static const int foobar = 0;