Skip to content

Commit

Permalink
console: add optional registration for QEMU console
Browse files Browse the repository at this point in the history
Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Jan 25, 2022
1 parent 4f65211 commit 3763d6f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions common/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ bool_cmd("hpet", opt_hpet);
bool opt_fpu = false;
bool_cmd("fpu", opt_fpu);

bool opt_qemu_console = false;
bool_cmd("qemu_console", opt_qemu_console);

const char *kernel_cmdline;

void __text_init cmdline_parse(const char *cmdline) {
Expand Down
2 changes: 0 additions & 2 deletions common/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@

#include <smp/smp.h>

#define QEMU_CONSOLE 0x0e9

#define VPRINTK_BUF_SIZE 1024

static console_callback_entry_t console_callbacks[2];
Expand Down
6 changes: 6 additions & 0 deletions common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,19 @@ static unsigned bsp_cpu_id = 0;
unsigned get_bsp_cpu_id(void) { return bsp_cpu_id; }
void set_bsp_cpu_id(unsigned cpu_id) { bsp_cpu_id = cpu_id; }

#define QEMU_CONSOLE_PORT 0x0e9
static void __text_init init_console(void) {
get_com_ports();

uart_init(com_ports[0], DEFAULT_BAUD_SPEED);
register_console_callback(serial_console_write, _ptr(com_ports[0]));

printk("COM1: %x, COM2: %x\n", com_ports[0], com_ports[1]);

if (opt_qemu_console) {
register_console_callback(qemu_console_write, _ptr(QEMU_CONSOLE_PORT));
printk("Initialized QEMU console at port 0x%x", QEMU_CONSOLE_PORT);
}
}

static __always_inline void zero_bss(void) {
Expand Down
1 change: 1 addition & 0 deletions include/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extern bool opt_pit;
extern bool opt_apic_timer;
extern bool opt_hpet;
extern bool opt_fpu;
extern bool opt_qemu_console;
extern const char *kernel_cmdline;

extern void cmdline_parse(const char *cmdline);
Expand Down

0 comments on commit 3763d6f

Please sign in to comment.