#include <config.h>
#include <arch/kernel/boot_sys.h>
#include <arch/model/statedata.h>
#include <machine/io.h>
#include <plat/machine/io.h>
#if defined(CONFIG_DEBUG_BUILD) || defined(CONFIG_PRINTING)
void
serial_init(uint16_t port)
{
while (!(in8(port + 5) & 0x60));
out8(port + 1, 0x00);
out8(port + 3, 0x80);
out8(port, 0x01);
out8(port + 1, 0x00);
out8(port + 3, 0x03);
out8(port + 4, 0x0b);
in8(port);
in8(port + 5);
in8(port + 6);
}
#endif
#ifdef CONFIG_PRINTING
void
putConsoleChar(unsigned char a)
{
while (x86KSconsolePort && !(in8(x86KSconsolePort + 5) & 0x20));
out8(x86KSconsolePort, a);
}
#endif
#ifdef CONFIG_DEBUG_BUILD
void
putDebugChar(unsigned char a)
{
while (x86KSdebugPort && (in8(x86KSdebugPort + 5) & 0x20) == 0);
out8(x86KSdebugPort, a);
}
unsigned char
getDebugChar(void)
{
while ((in8(x86KSdebugPort + 5) & 1) == 0);
return in8(x86KSdebugPort);
}
#endif