Skip to content

Commit

Permalink
Update to latest sDDF
Browse files Browse the repository at this point in the history
* Renaming regarding block:
  size -> capacity
  config -> storage info
* Renaming regarding serial:
  size -> capacity

Signed-off-by: Ivan-Velickovic <[email protected]>
  • Loading branch information
Ivan-Velickovic committed Oct 9, 2024
1 parent 0e81969 commit 9f0d60a
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 93 deletions.
2 changes: 1 addition & 1 deletion dep/sddf
Submodule sddf updated 73 files
+33 −0 .clang-format
+6 −8 .github/workflows/examples.yaml
+16 −2 .github/workflows/pr.yaml
+278 −0 LICENSES/LicenseRef-APACHE-2-LLVM-EXCEPTION.txt
+179 −193 blk/components/virt.c
+124 −0 build.zig
+20 −10 ci/README.md
+1 −1 ci/examples.sh
+1 −1 drivers/blk/mmc/imx/mmc_driver.mk
+13 −13 drivers/blk/mmc/imx/usdhc.c
+0 −0 drivers/blk/mmc/imx/usdhc.h
+17 −17 drivers/blk/virtio/block.c
+0 −2 drivers/blk/virtio/block.h
+5 −3 drivers/i2c/meson/driver.h
+51 −15 drivers/i2c/meson/i2c.c
+9 −8 drivers/network/imx/ethernet.c
+22 −16 drivers/network/meson/ethernet.c
+15 −6 drivers/network/virtio/ethernet.c
+3 −3 drivers/serial/arm/uart.c
+3 −3 drivers/serial/imx/uart.c
+3 −3 drivers/serial/meson/uart.c
+93 −0 drivers/serial/snps/include/uart.h
+195 −0 drivers/serial/snps/uart.c
+27 −0 drivers/serial/snps/uart_driver.mk
+445 −0 drivers/serial/virtio/console.c
+34 −0 drivers/serial/virtio/include/console.h
+29 −0 drivers/serial/virtio/serial_driver.mk
+15 −2 drivers/timer/arm/timer.c
+220 −0 drivers/timer/jh7110/timer.c
+27 −0 drivers/timer/jh7110/timer_driver.mk
+1 −1 examples/blk/README.md
+1 −1 examples/blk/basic_data.txt
+14 −21 examples/blk/blk_config.h
+16 −15 examples/blk/board/qemu_virt_aarch64/blk.system
+4 −4 examples/blk/client.c
+57 −58 examples/echo_server/include/ethernet_config/ethernet_config.h
+18 −18 examples/echo_server/include/serial_config/serial_config.h
+8 −3 examples/echo_server/lwip.c
+7 −7 examples/echo_server/tcp_echo_socket.c
+10 −3 examples/i2c/client_ds3231.c
+6 −6 examples/i2c/client_pn532.c
+25 −24 examples/mmc/board/imx8mm_evk/mmc.system
+25 −24 examples/mmc/board/maaxboard/mmc.system
+3 −3 examples/mmc/client.c
+15 −22 examples/mmc/include/configs/blk_config.h
+107 −0 examples/serial/board/star64/serial.system
+12 −2 examples/serial/build.zig
+23 −23 examples/serial/include/serial_config/serial_config.h
+21 −15 examples/serial/serial.mk
+6 −1 examples/timer/Makefile
+25 −0 examples/timer/board/star64/timer.system
+12 −1 examples/timer/build.zig
+7 −25 examples/timer/client.c
+9 −4 examples/timer/timer.mk
+4 −5 i2c/devices/ds3231/ds3231.c
+17 −26 i2c/devices/pn532/pn532.c
+2 −0 include/sddf/blk/queue.h
+2 −0 include/sddf/blk/storage_info.h
+3 −0 include/sddf/i2c/devices/pn532/pn532.h
+6 −9 include/sddf/i2c/queue.h
+15 −15 include/sddf/network/queue.h
+10 −0 include/sddf/network/util.h
+27 −23 include/sddf/serial/queue.h
+105 −0 include/sddf/util/udivmodti4.h
+1 −0 include/sddf/virtio/virtio.h
+9 −3 network/components/copy.c
+18 −7 network/components/virt_rx.c
+19 −9 network/components/virt_tx.c
+2 −2 serial/components/virt_rx.c
+2 −2 serial/components/virt_tx.c
+3 −1 shell.nix
+1 −1 util/assert.c
+29 −33 util/cache.c
32 changes: 16 additions & 16 deletions examples/virtio/board/odroidc4/virtio.system
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<map mr="rx_data_serial_vmm_1" vaddr="0x6_004_000" perms="rw" cached="true" setvar_vaddr="serial_rx_data" />

<!-- sDDF related regions for virtIO block -->
<map mr="blk_config_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_storage_info_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_storage_info" />
<map mr="req_blk_vmm_1" vaddr="0x103_800_000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="resp_blk_vmm_1" vaddr="0x103_a00_000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
<map mr="data_blk_vmm_1" vaddr="0x30600000" perms="rw" cached="true" setvar_vaddr="blk_data" />
Expand All @@ -50,7 +50,7 @@
<map mr="rx_data_serial_vmm_2" vaddr="0x6_004_000" perms="rw" cached="true" setvar_vaddr="serial_rx_data" />

<!-- sDDF related regions for virtIO block -->
<map mr="blk_config_vmm_2" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_storage_info_vmm_2" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_storage_info" />
<map mr="req_blk_vmm_2" vaddr="0x103_800_000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="resp_blk_vmm_2" vaddr="0x103_a00_000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
<map mr="data_blk_vmm_2" vaddr="0x31600000" perms="rw" cached="true" setvar_vaddr="blk_data" />
Expand Down Expand Up @@ -165,17 +165,17 @@
</channel>

<!-- Block sDDF regions -->
<memory_region name="blk_config_driver" size="0x1000" page_size="0x1000" />
<memory_region name="blk_storage_info_driver" size="0x1000" page_size="0x1000" />
<memory_region name="req_blk_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="resp_blk_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="data_blk_driver" size="0x200_000" page_size="0x200_000" />

<memory_region name="blk_config_vmm_1" size="0x1000" page_size="0x1000" />
<memory_region name="blk_storage_info_vmm_1" size="0x1000" page_size="0x1000" />
<memory_region name="req_blk_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="resp_blk_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="data_blk_vmm_1" size="0x200_000" page_size="0x200_000" />

<memory_region name="blk_config_vmm_2" size="0x1000" page_size="0x1000" />
<memory_region name="blk_storage_info_vmm_2" size="0x1000" page_size="0x1000" />
<memory_region name="data_blk_vmm_2" size="0x200_000" page_size="0x200_000" />
<memory_region name="req_blk_vmm_2" size="0x200_000" page_size="0x200_000"/>
<memory_region name="resp_blk_vmm_2" size="0x200_000" page_size="0x200_000"/>
Expand Down Expand Up @@ -207,7 +207,7 @@
<map mr="bus3" vaddr="0xffd00000" perms="rw" cached="false" />

<!-- sDDF block -->
<map mr="blk_config_driver" vaddr="0x40000000" perms="rw" cached="false" />
<map mr="blk_storage_info_driver" vaddr="0x40000000" perms="rw" cached="false" />
<map mr="req_blk_driver" vaddr="0x40200000" perms="rw" cached="false" />
<map mr="resp_blk_driver" vaddr="0x40400000" perms="rw" cached="false" />
<map mr="data_blk_driver" vaddr="0x40800000" perms="rw" cached="true" />
Expand All @@ -221,18 +221,18 @@

<protection_domain name="BLK_VIRT" priority="150" budget="100" period="400">
<program_image path="blk_virt.elf" />
<map mr="blk_config_driver" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_config_driver" />
<map mr="req_blk_driver" vaddr="0x40200000" perms="rw" cached="false" setvar_vaddr="blk_req_queue_driver" />
<map mr="resp_blk_driver" vaddr="0x40400000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue_driver" />
<map mr="data_blk_driver" vaddr="0x40800000" perms="rw" cached="true" setvar_vaddr="blk_data_driver" />

<map mr="blk_config_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_config_vmm_2" vaddr="0x30200000" perms="rw" cached="false" />
<map mr="req_blk_vmm_1" vaddr="0x31000000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="blk_storage_info_driver" vaddr="0x40000000" perms="rw" cached="false" setvar_vaddr="blk_driver_storage_info" />
<map mr="req_blk_driver" vaddr="0x40200000" perms="rw" cached="false" setvar_vaddr="blk_driver_req_queue" />
<map mr="resp_blk_driver" vaddr="0x40400000" perms="rw" cached="false" setvar_vaddr="blk_driver_resp_queue" />
<map mr="data_blk_driver" vaddr="0x40800000" perms="rw" cached="true" setvar_vaddr="blk_driver_data" />

<map mr="blk_storage_info_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_client_storage_info" />
<map mr="blk_storage_info_vmm_2" vaddr="0x30200000" perms="rw" cached="false" />
<map mr="req_blk_vmm_1" vaddr="0x31000000" perms="rw" cached="false" setvar_vaddr="blk_client_req_queue" />
<map mr="req_blk_vmm_2" vaddr="0x31200000" perms="rw" cached="false" />
<map mr="resp_blk_vmm_1" vaddr="0x32000000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
<map mr="resp_blk_vmm_1" vaddr="0x32000000" perms="rw" cached="false" setvar_vaddr="blk_client_resp_queue" />
<map mr="resp_blk_vmm_2" vaddr="0x32200000" perms="rw" cached="false" />
<map mr="data_blk_vmm_1" vaddr="0x33000000" perms="rw" cached="true" setvar_vaddr="blk_client_data_start"/>
<map mr="data_blk_vmm_1" vaddr="0x33000000" perms="rw" cached="true" setvar_vaddr="blk_client_data"/>
<map mr="data_blk_vmm_2" vaddr="0x33200000" perms="rw" cached="true" />
</protection_domain>

Expand Down
32 changes: 16 additions & 16 deletions examples/virtio/board/qemu_virt_aarch64/virtio.system
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<map mr="rx_data_serial_vmm_1" vaddr="0x6_004_000" perms="rw" cached="true" setvar_vaddr="serial_rx_data" />

<!-- sDDF related regions for virtIO block -->
<map mr="blk_config_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_storage_info_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_storage_info" />
<map mr="req_blk_vmm_1" vaddr="0x103_800_000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="resp_blk_vmm_1" vaddr="0x103_a00_000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
<map mr="data_blk_vmm_1" vaddr="0x30600000" perms="rw" cached="true" setvar_vaddr="blk_data" />
Expand All @@ -47,7 +47,7 @@

<!-- sDDF related regions for virtIO block -->
<!-- blk config region -->
<map mr="blk_config_vmm_2" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_storage_info_vmm_2" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_storage_info" />
<!-- shared memory for queues -->
<map mr="req_blk_vmm_2" vaddr="0x103_800_000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="resp_blk_vmm_2" vaddr="0x103_a00_000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
Expand Down Expand Up @@ -164,17 +164,17 @@
</channel>

<!-- Block sDDF regions -->
<memory_region name="blk_config_driver" size="0x1000" page_size="0x1000" />
<memory_region name="blk_storage_info_driver" size="0x1000" page_size="0x1000" />
<memory_region name="req_blk_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="resp_blk_driver" size="0x200_000" page_size="0x200_000"/>
<memory_region name="data_blk_driver" size="0x200_000" page_size="0x200_000" />

<memory_region name="blk_config_vmm_1" size="0x1000" page_size="0x1000" />
<memory_region name="blk_storage_info_vmm_1" size="0x1000" page_size="0x1000" />
<memory_region name="req_blk_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="resp_blk_vmm_1" size="0x200_000" page_size="0x200_000"/>
<memory_region name="data_blk_vmm_1" size="0x200_000" page_size="0x200_000" />

<memory_region name="blk_config_vmm_2" size="0x1000" page_size="0x1000" />
<memory_region name="blk_storage_info_vmm_2" size="0x1000" page_size="0x1000" />
<memory_region name="data_blk_vmm_2" size="0x200_000" page_size="0x200_000" />
<memory_region name="req_blk_vmm_2" size="0x200_000" page_size="0x200_000"/>
<memory_region name="resp_blk_vmm_2" size="0x200_000" page_size="0x200_000"/>
Expand All @@ -200,7 +200,7 @@
<map mr="uart" vaddr="0x9000000" perms="rw" cached="false" />

<!-- sDDF block -->
<map mr="blk_config_driver" vaddr="0x20000000" perms="rw" cached="false" />
<map mr="blk_storage_info_driver" vaddr="0x20000000" perms="rw" cached="false" />
<map mr="req_blk_driver" vaddr="0x20200000" perms="rw" cached="false" />
<map mr="resp_blk_driver" vaddr="0x20400000" perms="rw" cached="false" />
<map mr="data_blk_driver" vaddr="0x20800000" perms="rw" cached="true" />
Expand All @@ -214,18 +214,18 @@

<protection_domain name="BLK_VIRT" priority="150" budget="100" period="400">
<program_image path="blk_virt.elf" />
<map mr="blk_config_driver" vaddr="0x20000000" perms="rw" cached="false" setvar_vaddr="blk_config_driver" />
<map mr="req_blk_driver" vaddr="0x20200000" perms="rw" cached="false" setvar_vaddr="blk_req_queue_driver" />
<map mr="resp_blk_driver" vaddr="0x20400000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue_driver" />
<map mr="data_blk_driver" vaddr="0x20800000" perms="rw" cached="true" setvar_vaddr="blk_data_driver" />

<map mr="blk_config_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_config" />
<map mr="blk_config_vmm_2" vaddr="0x30200000" perms="rw" cached="false" />
<map mr="req_blk_vmm_1" vaddr="0x31000000" perms="rw" cached="false" setvar_vaddr="blk_req_queue" />
<map mr="blk_storage_info_driver" vaddr="0x20000000" perms="rw" cached="false" setvar_vaddr="blk_driver_storage_info" />
<map mr="req_blk_driver" vaddr="0x20200000" perms="rw" cached="false" setvar_vaddr="blk_driver_req_queue" />
<map mr="resp_blk_driver" vaddr="0x20400000" perms="rw" cached="false" setvar_vaddr="blk_driver_resp_queue" />
<map mr="data_blk_driver" vaddr="0x20800000" perms="rw" cached="true" setvar_vaddr="blk_driver_data" />

<map mr="blk_storage_info_vmm_1" vaddr="0x30000000" perms="rw" cached="false" setvar_vaddr="blk_client_storage_info" />
<map mr="blk_storage_info_vmm_2" vaddr="0x30200000" perms="rw" cached="false" />
<map mr="req_blk_vmm_1" vaddr="0x31000000" perms="rw" cached="false" setvar_vaddr="blk_client_req_queue" />
<map mr="req_blk_vmm_2" vaddr="0x31200000" perms="rw" cached="false" />
<map mr="resp_blk_vmm_1" vaddr="0x32000000" perms="rw" cached="false" setvar_vaddr="blk_resp_queue" />
<map mr="resp_blk_vmm_1" vaddr="0x32000000" perms="rw" cached="false" setvar_vaddr="blk_client_resp_queue" />
<map mr="resp_blk_vmm_2" vaddr="0x32200000" perms="rw" cached="false" />
<map mr="data_blk_vmm_1" vaddr="0x33000000" perms="rw" cached="true" setvar_vaddr="blk_client_data_start"/>
<map mr="data_blk_vmm_1" vaddr="0x33000000" perms="rw" cached="true" setvar_vaddr="blk_client_data"/>
<map mr="data_blk_vmm_2" vaddr="0x33200000" perms="rw" cached="true" />
</protection_domain>

Expand Down
18 changes: 8 additions & 10 deletions examples/virtio/client_vmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,17 @@ static struct virtio_console_device virtio_console;
#define VIRTIO_BLK_BASE (0x150000)
#define VIRTIO_BLK_SIZE (0x1000)

uintptr_t blk_req_queue;
uintptr_t blk_resp_queue;
blk_req_queue_t *blk_req_queue;
blk_resp_queue_t *blk_resp_queue;
uintptr_t blk_data;
uintptr_t blk_config;
blk_storage_info_t *blk_storage_info;

static struct virtio_blk_device virtio_blk;

void init(void)
{
blk_storage_info_t *storage_info = (blk_storage_info_t *)blk_config;

/* Busy wait until blk device is ready */
while (!blk_storage_is_ready(storage_info));
while (!blk_storage_is_ready(blk_storage_info));

/* Initialise the VMM, the VCPU(s), and start the guest */
LOG_VMM("starting \"%s\"\n", microkit_name);
Expand Down Expand Up @@ -125,16 +123,16 @@ void init(void)
/* Initialise our sDDF queues for the block device */
blk_queue_handle_t blk_queue_h;
blk_queue_init(&blk_queue_h,
(blk_req_queue_t *)blk_req_queue,
(blk_resp_queue_t *)blk_resp_queue,
blk_cli_queue_size(microkit_name));
blk_req_queue,
blk_resp_queue,
blk_cli_queue_capacity(microkit_name));

/* Initialise virtIO block device */
success = virtio_mmio_blk_init(&virtio_blk,
VIRTIO_BLK_BASE, VIRTIO_BLK_SIZE, VIRTIO_BLK_IRQ,
blk_data,
BLK_DATA_SIZE,
storage_info,
blk_storage_info,
&blk_queue_h,
BLK_CH);
assert(success);
Expand Down
24 changes: 11 additions & 13 deletions examples/virtio/include/blk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
#define BLK_NAME_CLI0 "CLIENT_VMM-1"
#define BLK_NAME_CLI1 "CLIENT_VMM-2"

#define BLK_QUEUE_SIZE_CLI0 1024
#define BLK_QUEUE_SIZE_CLI1 1024
#define BLK_QUEUE_SIZE_DRIV (BLK_QUEUE_SIZE_CLI0 + BLK_QUEUE_SIZE_CLI1)
#define BLK_QUEUE_CAPACITY_CLI0 1024
#define BLK_QUEUE_CAPACITY_CLI1 1024
#define BLK_QUEUE_CAPACITY_DRIV (BLK_QUEUE_CAPACITY_CLI0 + BLK_QUEUE_CAPACITY_CLI1)

#define BLK_REGION_SIZE 0x200000
#define BLK_CONFIG_REGION_SIZE_CLI0 BLK_REGION_SIZE
#define BLK_CONFIG_REGION_SIZE_CLI1 BLK_REGION_SIZE

#define BLK_DATA_REGION_SIZE_CLI0 BLK_REGION_SIZE
#define BLK_DATA_REGION_SIZE_CLI1 BLK_REGION_SIZE
Expand All @@ -40,13 +38,13 @@ _Static_assert(BLK_DATA_REGION_SIZE_DRIV >= BLK_TRANSFER_SIZE &&BLK_DATA_REGION_

static const int blk_partition_mapping[BLK_NUM_CLIENTS] = { 0, 1 };

static inline blk_storage_info_t *blk_virt_cli_config_info(blk_storage_info_t *info, unsigned int id)
static inline blk_storage_info_t *blk_virt_cli_storage_info(blk_storage_info_t *info, unsigned int id)
{
switch (id) {
case 0:
return info;
case 1:
return (blk_storage_info_t *)((uintptr_t)info + BLK_CONFIG_REGION_SIZE_CLI0);
return (blk_storage_info_t *)((uintptr_t)info + BLK_STORAGE_INFO_REGION_SIZE);
default:
return NULL;
}
Expand Down Expand Up @@ -100,24 +98,24 @@ static inline blk_resp_queue_t *blk_virt_cli_resp_queue(blk_resp_queue_t *resp,
}
}

static inline uint32_t blk_virt_cli_queue_size(unsigned int id)
static inline uint32_t blk_virt_cli_queue_capacity(unsigned int id)
{
switch (id) {
case 0:
return BLK_QUEUE_SIZE_CLI0;
return BLK_QUEUE_CAPACITY_CLI0;
case 1:
return BLK_QUEUE_SIZE_CLI1;
return BLK_QUEUE_CAPACITY_CLI1;
default:
return 0;
}
}

static inline uint32_t blk_cli_queue_size(char *pd_name)
static inline uint32_t blk_cli_queue_capacity(char *pd_name)
{
if (!sddf_strcmp(pd_name, BLK_NAME_CLI0)) {
return BLK_QUEUE_SIZE_CLI0;
return BLK_QUEUE_CAPACITY_CLI0;
} else if (!sddf_strcmp(pd_name, BLK_NAME_CLI1)) {
return BLK_QUEUE_SIZE_CLI1;
return BLK_QUEUE_CAPACITY_CLI1;
} else {
return 0;
}
Expand Down
Loading

0 comments on commit 9f0d60a

Please sign in to comment.