#ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include "libc.h" #ifdef ASM_I386 #include #endif #ifdef ASM_X86_64 #include #endif #ifdef WITH_IO #include #endif #ifdef WITH_PRINTF #include #endif #include #if defined(WITH_IO) && defined(WITH_PRINTF) static void kernaux_console_printf_putc( const char c, void *const arg __attribute__((unused)) ) { kernaux_console_putc(c); } #endif void kernaux_console_putc(const char c __attribute__((unused))) { #ifdef ASM_I386 kernaux_asm_i386_outportb(0x3f8, c); #endif #ifdef ASM_X86_64 kernaux_asm_x86_64_outportb(0x3f8, c); #endif } void kernaux_console_print(const char *const s) { KERNAUX_ASSERT(s); for (const char *c = s; *c; ++c) { kernaux_console_putc(*c); } } #if defined(WITH_IO) && defined(WITH_PRINTF) void kernaux_console_printf(const char *format, ...) { KERNAUX_ASSERT(format); va_list va; va_start(va, format); struct KernAux_OldFile file = KernAux_OldFile_create(kernaux_console_printf_putc); kernaux_vfprintf(&file, NULL, format, va); va_end(va); } #endif void kernaux_console_puts(const char *const s) { KERNAUX_ASSERT(s); kernaux_console_print(s); kernaux_console_putc('\n'); } void kernaux_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]); } }