diff --git a/components/SerialServer/CMakeLists.txt b/components/SerialServer/CMakeLists.txt index 44e94dc..88d1cda 100644 --- a/components/SerialServer/CMakeLists.txt +++ b/components/SerialServer/CMakeLists.txt @@ -24,7 +24,12 @@ if(KernelArchARM) set(PlatPrefix "arm_common") endif() else() - set(PlatPrefix "${KernelPlatform}") + if(LibPlatSupportX86ConsoleDeviceVGA) + set(OutputDevice "vga") + else() + set(OutputDevice "com") + endif() + set(PlatPrefix "${KernelPlatform}/${OutputDevice}") endif() DeclareCAmkESComponent( diff --git a/components/SerialServer/include/plat/pc99/plat/serial.h b/components/SerialServer/include/plat/pc99/com/plat/serial.h similarity index 100% rename from components/SerialServer/include/plat/pc99/plat/serial.h rename to components/SerialServer/include/plat/pc99/com/plat/serial.h diff --git a/components/SerialServer/include/plat/pc99/vga/plat/serial.h b/components/SerialServer/include/plat/pc99/vga/plat/serial.h new file mode 100644 index 0000000..01c9357 --- /dev/null +++ b/components/SerialServer/include/plat/pc99/vga/plat/serial.h @@ -0,0 +1,20 @@ +/* + * Copyright 2024, Dornerworks + * + * SPDX-License-Identifier: BSD-2-Clause + */ +#pragma once + +#define HARDWARE_SERIAL_INTERFACES \ + dataport Buf(4096) txt_buf; + +#define HARDWARE_SERIAL_ATTRIBUTES + + +#define HARDWARE_SERIAL_COMPOSITION \ + component VGADisplay vga_hw; \ + connection seL4HardwareMMIO vga_text(from txt_buf, to vga_hw.txt_buf); + +#define HARDWARE_SERIAL_CONFIG \ + vga_hw.txt_buf_paddr = 0xb8000; \ + vga_hw.txt_buf_size = 0x1000; \ No newline at end of file diff --git a/components/SerialServer/src/plat/pc99/plat.c b/components/SerialServer/src/plat/pc99/com/plat.c similarity index 92% rename from components/SerialServer/src/plat/pc99/plat.c rename to components/SerialServer/src/plat/pc99/com/plat.c index 02397ab..2c9517b 100644 --- a/components/SerialServer/src/plat/pc99/plat.c +++ b/components/SerialServer/src/plat/pc99/com/plat.c @@ -11,8 +11,8 @@ #include #include -#include "../../plat.h" -#include "../../serial.h" +#include "../../../plat.h" +#include "../../../serial.h" void plat_post_init(ps_irq_ops_t *irq_ops) { diff --git a/components/SerialServer/src/plat/pc99/vga/plat.c b/components/SerialServer/src/plat/pc99/vga/plat.c new file mode 100644 index 0000000..287081c --- /dev/null +++ b/components/SerialServer/src/plat/pc99/vga/plat.c @@ -0,0 +1,21 @@ +/* + * Copyright 2024, Dornerworks, CSIRO (ABN 41 687 119 230) + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include +#include +#include + +#include "../../../plat.h" +#include "../../../serial.h" + +void plat_post_init(ps_irq_ops_t *irq_ops) +{ + ZF_LOGI("EGA Display registers no IRQ"); + return; +} diff --git a/components/SerialServer/src/serial.c b/components/SerialServer/src/serial.c index 0854e66..9b0cbc3 100644 --- a/components/SerialServer/src/serial.c +++ b/components/SerialServer/src/serial.c @@ -105,6 +105,16 @@ const char *all_output_colours[2][MAX_CLIENTS] = { #define COLOUR_INDEX_TO_STYLE(x) ((x) / (MAX_CLIENTS - 1)) #define COLOUR_INDEX_TO_SLOT(x) ((x) % MAX_CLIENTS) +static void retag_client_prints(int client) +{ + #if defined(CONFIG_LIB_PLAT_SUPPORT_SERIAL_TEXT_VGA) + // take 1 off to start at 0 and remove MAX_CLIENT offset we added earlier + printf("VM[%d]:", (client -1) - MAX_CLIENTS); + #else + printf("%s%s", COLOR_RESET, all_output_colours[COLOUR_INDEX_TO_STYLE(client)][COLOUR_INDEX_TO_SLOT(client)]); + #endif +} + static void flush_buffer(int b) { const char *col = all_output_colours[COLOUR_INDEX_TO_STYLE(b)][COLOUR_INDEX_TO_SLOT(b)]; @@ -113,7 +123,7 @@ static void flush_buffer(int b) return; } if (b != last_out) { - printf("%s%s", COLOR_RESET, col); + retag_client_prints(b); last_out = b; } for (i = 0; i < output_buffers_used[b]; i++) { @@ -154,7 +164,7 @@ static bool flush_buffer_line(int b) return 0; } if (b != last_out) { - printf("%s%s", COLOR_RESET, all_output_colours[COLOUR_INDEX_TO_STYLE(b)][COLOUR_INDEX_TO_SLOT(b)]); + retag_client_prints(b); last_out = b; } int i; @@ -294,7 +304,7 @@ static void internal_putchar(int b, int c) * it's probably going to overflow again, so let's avoid * that. */ if (last_out != b) { - printf("%s%s", COLOR_RESET, all_output_colours[COLOUR_INDEX_TO_STYLE(b)][COLOUR_INDEX_TO_SLOT(b)]); + retag_client_prints(b); last_out = b; } } else if ((index >= 1 && is_newline(buffer + index - 1) && coalesce_status == -1)