mirror of https://github.com/tailix/libkernaux.git
Add API <kernaux/console.h>
This commit is contained in:
parent
7f6240a42c
commit
8e7bdf9d16
|
@ -21,6 +21,10 @@
|
||||||
/include/Makefile.in
|
/include/Makefile.in
|
||||||
/install-sh
|
/install-sh
|
||||||
/missing
|
/missing
|
||||||
|
/src/config.h
|
||||||
|
/src/config.h.in
|
||||||
|
/src/config.h.in~
|
||||||
|
/src/stamp-h1
|
||||||
/test-driver
|
/test-driver
|
||||||
/test-suite.log
|
/test-suite.log
|
||||||
/tests/test*.log
|
/tests/test*.log
|
||||||
|
|
|
@ -16,6 +16,7 @@ noinst_PROGRAMS = \
|
||||||
tests/multiboot2_print2
|
tests/multiboot2_print2
|
||||||
|
|
||||||
libkernaux_a_SOURCES = \
|
libkernaux_a_SOURCES = \
|
||||||
|
src/console.c \
|
||||||
src/multiboot2/helpers.c \
|
src/multiboot2/helpers.c \
|
||||||
src/multiboot2/is_valid.c \
|
src/multiboot2/is_valid.c \
|
||||||
src/multiboot2/print.c \
|
src/multiboot2/print.c \
|
||||||
|
|
|
@ -22,7 +22,7 @@ API
|
||||||
---
|
---
|
||||||
|
|
||||||
* [Multiboot 2 (GRUB 2) information parser](/include/kernaux/multiboot2.h)
|
* [Multiboot 2 (GRUB 2) information parser](/include/kernaux/multiboot2.h)
|
||||||
* Serial console *(planned)*
|
* [Serial console](/include/kernaux/console.h)
|
||||||
* [Page Frame Allocator](/include/kernaux/pfa.h) *(work in progress)*
|
* [Page Frame Allocator](/include/kernaux/pfa.h) *(work in progress)*
|
||||||
* ELF utils *(planned)*
|
* ELF utils *(planned)*
|
||||||
* [Architecture-specific helpers](/include/kernaux/arch/)
|
* [Architecture-specific helpers](/include/kernaux/arch/)
|
||||||
|
|
|
@ -6,10 +6,14 @@ AC_INIT([libkernaux],
|
||||||
[https://github.com/kernelmq/libkernaux])
|
[https://github.com/kernelmq/libkernaux])
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([src/pfa.c])
|
AC_CONFIG_SRCDIR([src/pfa.c])
|
||||||
|
AC_CONFIG_HEADERS([src/config.h])
|
||||||
|
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
|
|
||||||
AM_CONDITIONAL(ARCH_X86, test "${host_cpu}" = "x86")
|
AS_IF([test x"${host_cpu}" = x"x86"],
|
||||||
|
[AC_DEFINE([ARCH_X86],[1],[architecture is x86])])
|
||||||
|
|
||||||
|
AM_CONDITIONAL(ARCH_X86, test x"${host_cpu}" = x"x86")
|
||||||
|
|
||||||
AM_INIT_AUTOMAKE([1.9 subdir-objects -Wall -Werror])
|
AM_INIT_AUTOMAKE([1.9 subdir-objects -Wall -Werror])
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
nobase_include_HEADERS = \
|
nobase_include_HEADERS = \
|
||||||
kernaux/arch/x86.h \
|
kernaux/arch/x86.h \
|
||||||
|
kernaux/console.h \
|
||||||
kernaux/multiboot2.h \
|
kernaux/multiboot2.h \
|
||||||
kernaux/pfa.h \
|
kernaux/pfa.h \
|
||||||
kernaux/stdlib.h
|
kernaux/stdlib.h
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
#ifndef KERNAUX_INCLUDED_CONSOLE
|
||||||
|
#define KERNAUX_INCLUDED_CONSOLE 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void kernaux_console_print(const char *s);
|
||||||
|
void kernaux_console_putc(char c);
|
||||||
|
void kernaux_console_puts(const char *s);
|
||||||
|
void kernaux_console_write(const char *data, unsigned int size);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,29 @@
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
#include <kernaux/arch/x86.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <kernaux/console.h>
|
||||||
|
#include <kernaux/stdlib.h>
|
||||||
|
|
||||||
|
void kernaux_console_print(const char *const s)
|
||||||
|
{
|
||||||
|
kernaux_console_write(s, kernaux_strlen(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
void kernaux_console_putc(const char c __attribute__((unused))) {
|
||||||
|
#ifdef ARCH_X86
|
||||||
|
kernaux_arch_x86_outportb(0x3F8, c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void kernaux_console_puts(const char *const s)
|
||||||
|
{
|
||||||
|
kernaux_console_print(s);
|
||||||
|
kernaux_console_putc('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
void kernaux_console_write(const char *const data, const unsigned int size) {
|
||||||
|
for (unsigned int i = 0; i < size; i++) {
|
||||||
|
kernaux_console_putc(data[i]);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue