summaryrefslogtreecommitdiff
path: root/src/kernel/log.c
blob: b5a96cb5b7b66b35ccf1bc1b045ec547ecfaf648 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "vga.h"
#include "serial.h"
#include "log.h"

#define LOG_COM COM1

static const uint8_t log_mode_colors[] = {
  0x30,
  0x07,
  0x4f
};

void set_log_mode(enum log_mode mode) {
  vga_set_color(log_mode_colors[mode]);
  vga_printch('\n');
  vga_printch('\n');
}

void logch(char ch) {
  if (ch == '\n') {
    sout(LOG_COM, (uint8_t)'\r');
    sout(LOG_COM, (uint8_t)'\n');
  }
  else
    sout(LOG_COM, (uint8_t)ch);

  vga_printch(ch);
}

void logsz(const char *sz) {
  while (*sz)
    logch(*sz++);
}