mirror of
https://github.com/tailix/libkernaux.git
synced 2025-03-17 17:14:00 -04:00
Move drivers to separate subdirectory (#91)
This commit is contained in:
parent
2ad235f319
commit
c331e6dafd
25 changed files with 193 additions and 107 deletions
.github/workflows
.gitignoreChangeLogMakefile.amREADME.mdconfig
dev-cross-i386dev-cross-riscv64dev-cross-x86_64root-cross-i386-linuxroot-cross-riscv64-linuxroot-cross-x86_64-linux
configure.acexamples
include
src/drivers
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
|
@ -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:
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -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
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2022-06-23 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* configure.ac: Added package "drivers"
|
||||
|
||||
2022-06-22 Alex Kotov <kotovalexarian@gmail.com>
|
||||
|
||||
* include/kernaux/free_list.h: Finished
|
||||
|
|
41
Makefile.am
41
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
|
||||
|
|
11
README.md
11
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)" \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
18
configure.ac
18
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], [//])])
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include <kernaux/asm/i386.h>
|
||||
#include <kernaux/console.h>
|
||||
#include <kernaux/drivers/console.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include <kernaux/asm/i386.h>
|
||||
#include <kernaux/console.h>
|
||||
#include <kernaux/drivers/console.h>
|
||||
#include <kernaux/multiboot2.h>
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
#include <kernaux/generic/mutex.h>
|
||||
|
||||
@comment_line_cmdline@#include <kernaux/cmdline.h>
|
||||
@comment_line_console@#include <kernaux/console.h>
|
||||
@comment_line_elf@#include <kernaux/elf.h>
|
||||
@comment_line_framebuffer@#include <kernaux/framebuffer.h>
|
||||
@comment_line_free_list@#include <kernaux/free_list.h>
|
||||
@comment_line_io@#include <kernaux/io.h>
|
||||
@comment_line_mbr@#include <kernaux/mbr.h>
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_CONSOLE
|
||||
#define KERNAUX_INCLUDED_CONSOLE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
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
|
22
include/kernaux/drivers/console.h.in
Normal file
22
include/kernaux/drivers/console.h.in
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef KERNAUX_INCLUDED_DRIVERS_CONSOLE
|
||||
#define KERNAUX_INCLUDED_DRIVERS_CONSOLE
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
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
|
12
include/kernaux/drivers/framebuffer.h
Normal file
12
include/kernaux/drivers/framebuffer.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef KERNAUX_INCLUDED_DRIVERS_FRAMEBUFFER
|
||||
#define KERNAUX_INCLUDED_DRIVERS_FRAMEBUFFER
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
12
include/kernaux/drivers/intel_8259_pic.h
Normal file
12
include/kernaux/drivers/intel_8259_pic.h
Normal file
|
@ -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
|
|
@ -1,12 +0,0 @@
|
|||
#ifndef KERNAUX_INCLUDED_FRAMEBUFFER
|
||||
#define KERNAUX_INCLUDED_FRAMEBUFFER
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -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
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
#endif
|
||||
|
||||
#include <kernaux/assert.h>
|
||||
#include <kernaux/console.h>
|
||||
|
||||
#include "libc.h"
|
||||
#include <kernaux/drivers/console.h>
|
||||
|
||||
#ifdef ASM_I386
|
||||
#include <kernaux/asm/i386.h>
|
||||
|
@ -24,15 +22,15 @@
|
|||
#include <stddef.h>
|
||||
|
||||
#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]);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <kernaux/framebuffer.h>
|
||||
#include <kernaux/drivers/framebuffer.h>
|
||||
|
||||
__attribute__((unused))
|
||||
static const int foobar = 0;
|
8
src/drivers/intel_8259_pic.c
Normal file
8
src/drivers/intel_8259_pic.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <kernaux/drivers/intel_8259_pic.h>
|
||||
|
||||
__attribute__((unused))
|
||||
static const int foobar = 0;
|
Loading…
Add table
Reference in a new issue