15bool serial_enabled =
false;
18 return serial_enabled;
28 outb(COM1, SERIAL_BAUD_DIVISOR & 0xFF);
29 outb(COM1 + 1, SERIAL_BAUD_DIVISOR >> 8);
38 if (
inb(COM1) != 0xAE) {
40 serial_enabled =
false;
44 serial_enabled =
true;
54 if (str[index] ==
'\0') {
64 if (!serial_enabled)
return;
70 while ((
inb(COM1 + 5) & 0x20) == 0) {
78 uint64_t next = value;
91 uint64_t MAX_LENGTH = index;
92 char chars[MAX_LENGTH];
98 if (index >= MAX_LENGTH)
102 chars[index] = ((next % 10) +
'0');
113 for (
int i = index - 1; i >= 0; i--) {
122 for (
int i = digit_count; i > 0; i--)
124 address = address << 4 | (address >> (((digit_count / 2) * 8) - 4));
125 int digit = address & 0xF;
133 c =
'A' + (digit - 10);
Provides utilities for IO operations with the hardware.
uint8_t inb(uint16_t port)
Inputs a byte from the specified port.
void outb(uint16_t port, uint8_t value)
Outputs a byte to the specified port.
void serial_print_hex(uint64_t address, uint64_t digit_count)
Print a hex number to serial output.
void serial_puts(char *str)
Prints a string to the serial port.
int serial_init(void)
Initializes the serial port & output.
bool get_serial_status(void)
Returns the status of the serial output (enabled or disabled).
void serial_putc(char c)
Prints a character to serial port.
void serial_print_int(uint64_t value)
Prints a number to the serial port.
Serial utilities and configuration.