Skip to content

Commit

Permalink
Serial queue (#51)
Browse files Browse the repository at this point in the history
* Update mmio.h to match serial queue renaming

sharedringbuffer.h has been renamed queue.h

Signed-off-by: Peter Chubb <[email protected]>

* Update for sDDF serial queue renaming

Everywhere rename ring->queue, used->active

Signed-off-by: Peter Chubb <[email protected]>

* Updated submodule sDDF to head, to get queue renaming changes

Signed-off-by: Peter Chubb <[email protected]>

* Make the Makefile use the sDDF submodule

Signed-off-by: Peter Chubb <[email protected]>

* More virtio example fixes

Rename MUX->Virtualiser, ring->queue
Fix Makefile to track dependencies properly,
Fix printf.c name clash (the uart driver wants the sddf version, vmm.o
wants the libvmm version

Signed-off-by: Peter Chubb <[email protected]>

---------

Signed-off-by: Peter Chubb <[email protected]>
Signed-off-by: Peter Chubb <[email protected]>
  • Loading branch information
wom-bat authored Mar 19, 2024
1 parent 73c142d commit d05b03d
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 121 deletions.
63 changes: 30 additions & 33 deletions examples/virtio/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,12 @@ DTS := $(IMAGE_DIR)/linux.dts
DTB := $(BUILD_DIR)/linux.dtb
INITRD := $(IMAGE_DIR)/rootfs.cpio.gz

SDDF := sddf
SDDF_SERIAL_RINGBUFFER := $(SDDF)/serial/libserialsharedringbuffer
SDDF ?= sddf
SDDF_SERIAL_COMPONENTS := $(SDDF)/serial/components
SDDF_SERIAL_DRIVER := $(SDDF)/drivers/serial/arm
SDDF_UTIL := $(SDDF)/util

ELFS := vmm.elf serial_mux_tx.elf serial_mux_rx.elf uart_driver.elf
ELFS := vmm.elf serial_virt_tx.elf serial_virt_rx.elf uart_driver.elf

IMAGE_FILE = $(BUILD_DIR)/loader.img
REPORT_FILE = $(BUILD_DIR)/report.txt
Expand All @@ -94,14 +93,18 @@ VMM_OBJS := vmm.o \
vcpu.o \
mmio.o \
console.o \
virtio.o \
shared_ringbuffer.o
virtio.o

SERIAL_MUX_TX_OBJS := mux_tx.o shared_ringbuffer.o
SERIAL_MUX_RX_OBJS := mux_rx.o shared_ringbuffer.o
SERIAL_DRIVER_OBJS := uart.o shared_ringbuffer.o
SERIAL_VIRT_TX_OBJS := virt_tx.o
SERIAL_VIRT_RX_OBJS := virt_rx.o
SERIAL_DRIVER_OBJS := uart.o sddf_printf.o putchar_debug.o

ALL_OBJS := $(addprefix ${BUILD_DIR}/,${VMM_OBJS} ${SERIAL_VIRT_TX_OBJS} ${SERIAL_VIRT_RX_OBJS} ${SERIAL_DRIVER_OBJS})

DEPENDS := ${ALL_OBJS:.o=.d}

# Toolchain flags

# FIXME: For optimisation we should consider providing the flag -mcpu.
# FIXME: We should also consider whether -mgeneral-regs-only should be
# used to avoid the use of the FPU and therefore seL4 does not have to
Expand All @@ -115,19 +118,21 @@ CFLAGS := -mstrict-align \
-nostdlib \
-Wno-unused-command-line-argument \
-Wall -Wno-unused-function -Werror \
-I$(VMM_SRC_DIR)/arch/aarch64 -I$(VMM_SRC_DIR) -I$(VMM_SRC_DIR)/util -I$(BOARD_DIR)/include \
-I$(SDDF_SERIAL_RINGBUFFER)/include \
-I$(VMM_SRC_DIR)/arch/aarch64 \
-I$(VMM_SRC_DIR) -I$(VMM_SRC_DIR)/util \
-I$(BOARD_DIR)/include \
-I$(SDDF_SERIAL_DRIVER)/include \
-I$(SDDF) \
-I$(SDDF)/include \
-DBOARD_$(BOARD) \
-DCONFIG_$(CONFIG) \
-target aarch64-none-elf
-target aarch64-none-elf \
-MD

LDFLAGS := -L$(BOARD_DIR)/lib
LIBS := -lmicrokit -Tmicrokit.ld

all: directories $(IMAGE_FILE)
all: $(IMAGE_FILE)

qemu: all
# @ivanv: check that the amount of RAM given to QEMU is at least the number of RAM that QEMU is setup with for seL4.
Expand All @@ -139,8 +144,9 @@ qemu: all
-m size=2G \
-nographic

directories:
$(shell mkdir -p $(BUILD_DIR))
${BUILD_DIR}/directories:
mkdir -p $(BUILD_DIR)
touch $@

$(DTB): $(DTS)
if ! command -v $(DTC) &> /dev/null; then echo "Could not find dependency: Device Tree Compiler (dtc)"; exit 1; fi
Expand All @@ -155,44 +161,35 @@ $(BUILD_DIR)/package_guest_images.o: $(VMM_TOOLS)/package_guest_images.S $(IMAGE
-target aarch64-none-elf \
$< -o $@

$(BUILD_DIR)/%.o: %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/util/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@
VPATH=${VMM_SRC_DIR}:${VMM_SRC_DIR}/util:${VMM_SRC_DIR}/arch/aarch64:${SDDF_SERIAL_DRIVER}:${SDDF_UTIL}:${VMM_SRC_DIR}/arch/aarch64/vgic:${VMM_SRC_DIR}/virtio

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/arch/aarch64/%.c Makefile
$(BUILD_DIR)/%.o: %.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/arch/aarch64/vgic/%.c Makefile
${BUILD_DIR}/sddf_printf.o: ${SDDF_UTIL}/printf.c
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(VMM_SRC_DIR)/virtio/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(SDDF_SERIAL_COMPONENTS)/%.c Makefile
$(CC) -c $(CFLAGS) -DSERIAL_NUM_CLIENTS=2 -DSERIAL_TRANSFER_WITH_COLOUR=1 $< -o $@

$(BUILD_DIR)/%.o: $(SDDF_SERIAL_RINGBUFFER)/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/%.o: $(SDDF_SERIAL_DRIVER)/%.c Makefile
$(CC) -c $(CFLAGS) $< -o $@

$(BUILD_DIR)/vmm.elf: $(addprefix $(BUILD_DIR)/, $(VMM_OBJS))
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(BUILD_DIR)/serial_mux_tx.elf: $(addprefix $(BUILD_DIR)/, $(SERIAL_MUX_TX_OBJS))
$(BUILD_DIR)/serial_virt_tx.elf: $(addprefix $(BUILD_DIR)/, $(SERIAL_VIRT_TX_OBJS))
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(BUILD_DIR)/serial_mux_rx.elf: $(addprefix $(BUILD_DIR)/, $(SERIAL_MUX_RX_OBJS))
$(BUILD_DIR)/serial_virt_rx.elf: $(addprefix $(BUILD_DIR)/, $(SERIAL_VIRT_RX_OBJS))
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(BUILD_DIR)/uart_driver.elf: $(addprefix $(BUILD_DIR)/, $(SERIAL_DRIVER_OBJS))
$(LD) $(LDFLAGS) $^ $(LIBS) -o $@

$(IMAGE_FILE) $(REPORT_FILE): $(addprefix $(BUILD_DIR)/, $(ELFS)) $(SYSTEM_DESCRIPTION) $(IMAGE_DIR)
$(MICROKIT_TOOL) $(SYSTEM_DESCRIPTION) --search-path $(BUILD_DIR) $(IMAGE_DIR) --board $(BOARD) --config $(CONFIG) -o $(IMAGE_FILE) -r $(REPORT_FILE)

${ALL_OBJS}: ${BUILD_DIR}/directories ${MAKEFILE}


-include ${DEPENDS}
82 changes: 41 additions & 41 deletions examples/virtio/board/qemu_arm_virt/virtio.system
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
<program_image path="vmm.elf" />
<map mr="guest_ram_1" vaddr="0x40000000" perms="rw" setvar_vaddr="guest_ram_vaddr" />

<!-- shared memory for ring buffer mechanism -->
<!-- shared memory for sDDF queues -->
<map mr="rx_free_serial_vmm_1" vaddr="0x6_000_000" perms="rw" cached="true" setvar_vaddr="serial_rx_free" />
<map mr="rx_used_serial_vmm_1" vaddr="0x6_200_000" perms="rw" cached="true" setvar_vaddr="serial_rx_used" />
<map mr="rx_active_serial_vmm_1" vaddr="0x6_200_000" perms="rw" cached="true" setvar_vaddr="serial_rx_active" />
<map mr="tx_free_serial_vmm_1" vaddr="0x103_400_000" perms="rw" cached="true" setvar_vaddr="serial_tx_free" />
<map mr="tx_used_serial_vmm_1" vaddr="0x103_600_000" perms="rw" cached="true" setvar_vaddr="serial_tx_used" />
<map mr="tx_active_serial_vmm_1" vaddr="0x103_600_000" perms="rw" cached="true" setvar_vaddr="serial_tx_active" />
<!-- sDDF related regions for virtIO console -->
<map mr="tx_data_serial_vmm_1" vaddr="0x8_400_000" perms="rw" cached="true" setvar_vaddr="serial_tx_data" />
<map mr="rx_data_serial_vmm_1" vaddr="0x8_600_000" perms="rw" cached="true" setvar_vaddr="serial_rx_data" />
Expand All @@ -33,11 +33,11 @@
<program_image path="vmm.elf" />
<map mr="guest_ram_2" vaddr="0x40000000" perms="rw" setvar_vaddr="guest_ram_vaddr" />

<!-- shared memory for ring buffer mechanism -->
<!-- shared memory for queues -->
<map mr="rx_free_serial_vmm_2" vaddr="0x6_000_000" perms="rw" cached="true" setvar_vaddr="serial_rx_free" />
<map mr="rx_used_serial_vmm_2" vaddr="0x6_200_000" perms="rw" cached="true" setvar_vaddr="serial_rx_used" />
<map mr="rx_active_serial_vmm_2" vaddr="0x6_200_000" perms="rw" cached="true" setvar_vaddr="serial_rx_active" />
<map mr="tx_free_serial_vmm_2" vaddr="0x103_400_000" perms="rw" cached="true" setvar_vaddr="serial_tx_free" />
<map mr="tx_used_serial_vmm_2" vaddr="0x103_600_000" perms="rw" cached="true" setvar_vaddr="serial_tx_used" />
<map mr="tx_active_serial_vmm_2" vaddr="0x103_600_000" perms="rw" cached="true" setvar_vaddr="serial_tx_active" />
<!-- sDDF related regions for virtIO console -->
<map mr="tx_data_serial_vmm_2" vaddr="0x8_800_000" perms="rw" cached="true" setvar_vaddr="serial_tx_data" />
<map mr="rx_data_serial_vmm_2" vaddr="0x8_a00_000" perms="rw" cached="true" setvar_vaddr="serial_rx_data" />
Expand All @@ -55,55 +55,55 @@
<memory_region name="rx_data_serial_vmm_1" size="0x200_000" page_size="0x200_000" />
<memory_region name="tx_data_serial_vmm_2" size="0x200_000" page_size="0x200_000" />
<memory_region name="rx_data_serial_vmm_2" size="0x200_000" page_size="0x200_000" />
<!-- Regions for the shared ring buffers used by the driver and multiplexor -->
<!-- Regions for the queues used by the driver and virtualiser -->
<memory_region name="rx_free_serial_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_used_serial_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_active_serial_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="tx_free_serial_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="tx_used_serial_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="tx_active_serial_driver" size="0x200_000" page_size="0x200_000"/>
<!--
Regions for the shared ring buffers used by the multiplexor and the
Regions for the shared queues used by the virtualiser and the
client (in this case the client is the VMM)
-->
<memory_region name="tx_free_serial_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="tx_used_serial_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="tx_active_serial_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_free_serial_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_used_serial_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_active_serial_vmm_1" size="0x200_000" page_size="0x200_000"/>

<memory_region name="tx_free_serial_vmm_2" size="0x200_000" page_size="0x200_000"/>
<memory_region name="tx_used_serial_vmm_2" size="0x200_000" page_size="0x200_000"/>
<memory_region name="tx_active_serial_vmm_2" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_free_serial_vmm_2" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_used_serial_vmm_2" size="0x200_000" page_size="0x200_000"/>
<memory_region name="rx_active_serial_vmm_2" size="0x200_000" page_size="0x200_000"/>

<!-- Multiplexor for transmit (TX) serial data -->
<protection_domain name="serial_mux_tx" priority="100" pp="true">
<program_image path="serial_mux_tx.elf" />
<!-- shared memory for driver/mux ring buffer mechanism -->
<!-- Virtualiser for transmit (TX) serial data -->
<protection_domain name="serial_virt_tx" priority="100" pp="true">
<program_image path="serial_virt_tx.elf" />
<!-- shared memory for driver/virt queues -->
<map mr="tx_free_serial_driver" vaddr="0x4_400_000" perms="rw" cached="true" setvar_vaddr="tx_free_driver" />
<map mr="tx_used_serial_driver" vaddr="0x4_600_000" perms="rw" cached="true" setvar_vaddr="tx_used_driver" />
<!-- shared memory for mux/client ring buffer mechanism -->
<!-- Ring buffers between the multiplexor and VMM client -->
<map mr="tx_active_serial_driver" vaddr="0x4_600_000" perms="rw" cached="true" setvar_vaddr="tx_active_driver" />
<!-- shared memory for virt/client queues -->
<!-- Queues between the virtualiser and VMM client -->
<map mr="tx_free_serial_vmm_1" vaddr="0x103_400_000" perms="rw" cached="true" setvar_vaddr="tx_free_client" />
<map mr="tx_used_serial_vmm_1" vaddr="0x103_600_000" perms="rw" cached="true" setvar_vaddr="tx_used_client" />
<map mr="tx_active_serial_vmm_1" vaddr="0x103_600_000" perms="rw" cached="true" setvar_vaddr="tx_active_client" />
<map mr="tx_free_serial_vmm_2" vaddr="0x5_200_000" perms="rw" cached="true" setvar_vaddr="tx_free_client2" />
<map mr="tx_used_serial_vmm_2" vaddr="0x5_400_000" perms="rw" cached="true" setvar_vaddr="tx_used_client2" />
<!-- Data regions between multiplexor/driver and vmm/mulitplexor -->
<map mr="tx_active_serial_vmm_2" vaddr="0x5_400_000" perms="rw" cached="true" setvar_vaddr="tx_active_client2" />
<!-- Data regions between virtualiser/driver and vmm/virtualiser -->
<map mr="tx_data_driver" vaddr="0x2_200_000" perms="rw" cached="true" setvar_vaddr="tx_data_driver" />
<!-- @ivanv: the virtual address of the data region needs to match what it is in the client as well,
this is very fragile and should be fixed. -->
<map mr="tx_data_serial_vmm_1" vaddr="0x8_400_000" perms="rw" cached="true" setvar_vaddr="tx_data_client" />
<map mr="tx_data_serial_vmm_2" vaddr="0x8_800_000" perms="rw" cached="true" setvar_vaddr="tx_data_client2" />
</protection_domain>
<!-- Multiplexor for receive (RX) serial data -->
<protection_domain name="serial_mux_rx" priority="100" pp="true">
<program_image path="serial_mux_rx.elf" />
<!-- shared memory for driver/mux ring buffer mechanism -->
<!-- Virtualiser for receive (RX) serial data -->
<protection_domain name="serial_virt_rx" priority="100" pp="true">
<program_image path="serial_virt_rx.elf" />
<!-- shared memory for driver/virt queues -->
<map mr="rx_free_serial_driver" vaddr="0x4_000_000" perms="rw" cached="true" setvar_vaddr="rx_free_driver" />
<map mr="rx_used_serial_driver" vaddr="0x4_200_000" perms="rw" cached="true" setvar_vaddr="rx_used_driver" />
<!-- Ring buffers between the multiplexor and VMM client -->
<map mr="rx_active_serial_driver" vaddr="0x4_200_000" perms="rw" cached="true" setvar_vaddr="rx_active_driver" />
<!-- Queues between the virtualiser and VMM client -->
<map mr="rx_free_serial_vmm_1" vaddr="0x4_800_000" perms="rw" cached="true" setvar_vaddr="rx_free_client" />
<map mr="rx_used_serial_vmm_1" vaddr="0x5_000_000" perms="rw" cached="true" setvar_vaddr="rx_used_client" />
<map mr="rx_active_serial_vmm_1" vaddr="0x5_000_000" perms="rw" cached="true" setvar_vaddr="rx_active_client" />
<map mr="rx_free_serial_vmm_2" vaddr="0x5_200_000" perms="rw" cached="true" setvar_vaddr="rx_free_client2" />
<map mr="rx_used_serial_vmm_2" vaddr="0x5_400_000" perms="rw" cached="true" setvar_vaddr="rx_used_client2" />
<map mr="rx_active_serial_vmm_2" vaddr="0x5_400_000" perms="rw" cached="true" setvar_vaddr="rx_active_client2" />

<map mr="rx_data_driver" vaddr="0x2_600_000" perms="rw" cached="true" setvar_vaddr="rx_data_driver" />
<map mr="rx_data_serial_vmm_1" vaddr="0x8_600_000" perms="rw" cached="true" setvar_vaddr="rx_data_client" />
Expand All @@ -116,42 +116,42 @@
<!-- Data region -->
<map mr="tx_data_driver" vaddr="0x2_200_000" perms="rw" cached="true" />
<map mr="rx_data_driver" vaddr="0x2_600_000" perms="rw" cached="true" />
<!-- shared memory for ring buffer mechanism -->
<!-- shared memory for queues -->
<map mr="rx_free_serial_driver" vaddr="0x4_000_000" perms="rw" cached="true" setvar_vaddr="rx_free" />
<map mr="rx_used_serial_driver" vaddr="0x4_200_000" perms="rw" cached="true" setvar_vaddr="rx_used" />
<map mr="rx_active_serial_driver" vaddr="0x4_200_000" perms="rw" cached="true" setvar_vaddr="rx_active" />
<map mr="tx_free_serial_driver" vaddr="0x4_400_000" perms="rw" cached="true" setvar_vaddr="tx_free" />
<map mr="tx_used_serial_driver" vaddr="0x4_600_000" perms="rw" cached="true" setvar_vaddr="tx_used" />
<map mr="tx_active_serial_driver" vaddr="0x4_600_000" perms="rw" cached="true" setvar_vaddr="tx_active" />
<!-- UART IRQ -->
<irq irq="33" id="1" />
</protection_domain>

<channel>
<end pd="VMM-1" id="1"/>
<end pd="serial_mux_tx" id="1"/>
<end pd="serial_virt_tx" id="1"/>
</channel>

<channel>
<end pd="VMM-2" id="1"/>
<end pd="serial_mux_tx" id="2"/>
<end pd="serial_virt_tx" id="2"/>
</channel>

<channel>
<end pd="uart_driver" id="8"/>
<end pd="serial_mux_tx" id="9"/>
<end pd="serial_virt_tx" id="9"/>
</channel>

<channel>
<end pd="VMM-1" id="2"/>
<end pd="serial_mux_rx" id="1"/>
<end pd="serial_virt_rx" id="1"/>
</channel>

<channel>
<end pd="VMM-2" id="2"/>
<end pd="serial_mux_rx" id="2"/>
<end pd="serial_virt_rx" id="2"/>
</channel>

<channel>
<end pd="uart_driver" id="10"/>
<end pd="serial_mux_rx" id="11"/>
<end pd="serial_virt_rx" id="11"/>
</channel>
</system>
2 changes: 1 addition & 1 deletion examples/virtio/sddf
Submodule sddf updated 106 files
36 changes: 18 additions & 18 deletions examples/virtio/vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "vcpu.h"
#include "virtio/virtio.h"
#include "virtio/console.h"
#include <sddf/serial/shared_ringbuffer.h>
#include <sddf/serial/queue.h>

/*
* As this is just an example, for simplicity we just make the size of the
Expand Down Expand Up @@ -45,18 +45,18 @@ extern char _guest_initrd_image_end[];
uintptr_t guest_ram_vaddr;

uintptr_t serial_rx_free;
uintptr_t serial_rx_used;
uintptr_t serial_rx_active;
uintptr_t serial_tx_free;
uintptr_t serial_tx_used;
uintptr_t serial_tx_active;

uintptr_t serial_rx_data;
uintptr_t serial_tx_data;

ring_handle_t serial_rx_ring;
ring_handle_t serial_tx_ring;
serial_queue_handle_t serial_rx_queue;
serial_queue_handle_t serial_tx_queue;

#define SERIAL_MUX_TX_CH 1
#define SERIAL_MUX_RX_CH 2
#define SERIAL_VIRT_TX_CH 1
#define SERIAL_VIRT_RX_CH 2

#define VIRTIO_CONSOLE_IRQ (74)
#define VIRTIO_CONSOLE_BASE (0x130000)
Expand Down Expand Up @@ -91,39 +91,39 @@ void init(void) {
LOG_VMM_ERR("Failed to initialise emulated interrupt controller\n");
return;
}
/* Initialise our sDDF ring buffers for the serial device */
ring_init(&serial_rx_ring, (ring_buffer_t *)serial_rx_free, (ring_buffer_t *)serial_rx_used, true, NUM_BUFFERS, NUM_BUFFERS);
for (int i = 0; i < NUM_BUFFERS - 1; i++) {
int ret = enqueue_free(&serial_rx_ring, serial_rx_data + (i * BUFFER_SIZE), BUFFER_SIZE, NULL);
/* Initialise our sDDF queue for the serial device */
serial_queue_init(&serial_rx_queue, (serial_queue_t *)serial_rx_free, (serial_queue_t *)serial_rx_active, true, NUM_ENTRIES, NUM_ENTRIES);
for (int i = 0; i < NUM_ENTRIES - 1; i++) {
int ret = serial_enqueue_free(&serial_rx_queue, serial_rx_data + (i * BUFFER_SIZE), BUFFER_SIZE);
if (ret != 0) {
microkit_dbg_puts(microkit_name);
microkit_dbg_puts(": server rx buffer population, unable to enqueue buffer\n");
}
}
ring_init(&serial_tx_ring, (ring_buffer_t *)serial_tx_free, (ring_buffer_t *)serial_tx_used, true, NUM_BUFFERS, NUM_BUFFERS);
for (int i = 0; i < NUM_BUFFERS - 1; i++) {
serial_queue_init(&serial_tx_queue, (serial_queue_t *)serial_tx_free, (serial_queue_t *)serial_tx_active, true, NUM_ENTRIES, NUM_ENTRIES);
for (int i = 0; i < NUM_ENTRIES - 1; i++) {
// Have to start at the memory region left of by the rx ring
int ret = enqueue_free(&serial_tx_ring, serial_tx_data + ((i + NUM_BUFFERS) * BUFFER_SIZE), BUFFER_SIZE, NULL);
int ret = serial_enqueue_free(&serial_tx_queue, serial_tx_data + ((i + NUM_ENTRIES) * BUFFER_SIZE), BUFFER_SIZE);
assert(ret == 0);
if (ret != 0) {
microkit_dbg_puts(microkit_name);
microkit_dbg_puts(": server tx buffer population, unable to enqueue buffer\n");
}
}
/* Neither ring should be plugged and hence all buffers we send should actually end up at the driver. */
assert(!ring_plugged(serial_tx_ring.free_ring));
assert(!ring_plugged(serial_tx_ring.used_ring));
assert(!serial_queue_plugged(serial_tx_queue.free));
assert(!serial_queue_plugged(serial_tx_queue.active));
/* Initialise virtIO console device */
success = virtio_mmio_device_init(&virtio_console, CONSOLE, VIRTIO_CONSOLE_BASE, VIRTIO_CONSOLE_SIZE, VIRTIO_CONSOLE_IRQ,
&serial_rx_ring, &serial_tx_ring, SERIAL_MUX_TX_CH);
&serial_rx_queue, &serial_tx_queue, SERIAL_VIRT_TX_CH);
assert(success);
/* Finally start the guest */
guest_start(GUEST_VCPU_ID, kernel_pc, GUEST_DTB_VADDR, GUEST_INIT_RAM_DISK_VADDR);
}

void notified(microkit_channel ch) {
switch (ch) {
case SERIAL_MUX_RX_CH: {
case SERIAL_VIRT_RX_CH: {
/* We have received an event from the serial multipelxor, so we
* call the virtIO console handling */
virtio_console_handle_rx(&virtio_console);
Expand Down
Loading

0 comments on commit d05b03d

Please sign in to comment.