1/**
2 * \file
3 * \brief kprintf support
4 */
5
6/*
7 * Copyright (c) 2008, 2010, 2011, 2012 ETH Zurich
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef KERNEL_ARCH_X86_KPUTCHAR_H
16#define KERNEL_ARCH_X86_KPUTCHAR_H
17
18#include <arch/x86/conio.h>
19#include <serial.h>
20#include <arch/x86/global.h>
21
22#define kprintf_begin()  acquire_spinlock(&global->locks.print)
23#define kprintf_end()    release_spinlock(&global->locks.print)
24
25#if 0
26static void delay(uint64_t ticks)
27{
28    uint64_t start = rdtsc();
29    while (rdtsc() < start + ticks) {}
30}
31#endif
32
33/* send all output to both VGA console and serial port, for now */
34static inline int
35kputchar(int c)
36{
37    if (c == '\n') {
38        serial_console_putchar('\r');
39        //delay(200000000);
40    }
41
42    conio_putchar(c);
43    serial_console_putchar(c);
44    return c;
45}
46
47
48
49#endif // KERNEL_ARCH_X86_KPUTCHAR_H
50