From b17aeb2f120be00e6f218aeb2c3da07d49df939a Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 12 Feb 2025 21:37:34 -0700 Subject: Start linting against global variables --- cmd/sbc_harness/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/sbc_harness/main.c') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index ce80711..157f51e 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -67,7 +67,7 @@ static COROUTINE read9p_cr(void *) { cr_end(); } -const char *hexdig = "0123456789ABCDEF"; +const char *const hexdig = "0123456789ABCDEF"; static_assert(CONFIG_9P_SRV_MAX_REQS*_CONFIG_9P_NUM_SOCKS <= 16); COROUTINE init_cr(void *) { -- cgit v1.2.3-2-g168b From a5ee9c593544bedb328df4d4ea7fcbf9517c3caa Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Thu, 20 Feb 2025 23:23:18 -0700 Subject: cmd/sbc_harness: main.c: Tidy #includes --- cmd/sbc_harness/main.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'cmd/sbc_harness/main.c') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 157f51e..93c2f1c 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -4,26 +4,35 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include /* libc: for strlen() */ +/* libc */ +#include /* libc: for strlen() */ +/* pico-sdk */ #include /* pico-sdk:pico_stdio_uart: for stdio_uart_init() */ #include /* pico-sdk:hardware_flash: for flash_get_unique_id() */ +/* our OS */ #include #include /* so we can set `bootclock` */ #include #include #include -#include -#include + +/* our application libraries */ #include +#include #include +/* our utility libraries */ +#include #define LOG_NAME MAIN #include +/* local headers */ #include "usb_keyboard.h" +/* configuration **************************************************************/ + #include "config.h" static COROUTINE hello_world_cr(void *_chan) { -- cgit v1.2.3-2-g168b From bec776463f76e0cc3f38df8571c32984a47e8b74 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Thu, 20 Feb 2025 23:24:01 -0700 Subject: cmd/sbc_harness: Wire in the parts of the file tree that exist --- cmd/sbc_harness/main.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'cmd/sbc_harness/main.c') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 93c2f1c..c45054b 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -22,6 +22,7 @@ #include #include #include +#include /* our utility libraries */ #include @@ -30,11 +31,100 @@ /* local headers */ #include "usb_keyboard.h" +#include "static.h" /* configuration **************************************************************/ #include "config.h" +/* file tree ******************************************************************/ + +#define _box(nam, obj) \ + ((struct lib9p_srv_file){ \ + .self = obj, \ + .vtable = (void*)&_lo_##nam##_lib9p_srv_file_vtable, \ + }) +#define lo_box_util9p_static_file_as_lib9p_srv_file(obj) _box(util9p_static_file, obj) +#define lo_box_util9p_static_dir_as_lib9p_srv_file(obj) _box(util9p_static_dir, obj) +#define lo_box_api_as_lib9p_srv_file(obj) _box(api, obj) + +enum { PATH_BASE = __COUNTER__ }; +#define PATH_COUNTER __COUNTER__ - PATH_BASE + +#define STATIC_COMMON(STRNAME, MODE) \ + { \ + .u_name = "root", .u_num = 0, /* owner user */ \ + .g_name = "root", .g_num = 0, /* owner group */ \ + .m_name = "root", .m_num = 0, /* last-modified-by user */ \ + \ + .pathnum = PATH_COUNTER, \ + .name = STRNAME, \ + .perm = MODE, \ + .atime = 1728337905, \ + .mtime = 1728337904, \ + } + +#define STATIC_FILE(STRNAME, ...) \ + lo_box_util9p_static_file_as_lib9p_srv_file(&((struct util9p_static_file){ \ + ._util9p_static_common = STATIC_COMMON(STRNAME, 0444), \ + __VA_ARGS__ \ + })) + +#define STATIC_DIR(STRNAME, ...) \ + lo_box_util9p_static_dir_as_lib9p_srv_file(&((struct util9p_static_dir){ \ + ._util9p_static_common = STATIC_COMMON(STRNAME, 0555), \ + .members = { __VA_ARGS__ LO_NULL(lib9p_srv_file) }, \ + })) + +struct lib9p_srv_file root = + STATIC_DIR("", + STATIC_DIR("Documentation", + STATIC_FILE("YOUR_RIGHTS_AND_OBLIGATIONS.md", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_md_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_md_end), + STATIC_DIR("YOUR_RIGHTS_AND_OBLIGATIONS", + STATIC_FILE("agpl-3.0.txt", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_agpl_3_0_txt_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_agpl_3_0_txt_end), + STATIC_FILE("pico-sdk.bsd3.txt", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_pico_sdk_bsd3_txt_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_pico_sdk_bsd3_txt_end), + STATIC_FILE("printf.mit.txt", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_printf_mit_txt_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_printf_mit_txt_end), + STATIC_FILE("tinyusb.mit.txt", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_tinyusb_mit_txt_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_tinyusb_mit_txt_end), + STATIC_FILE("newlib.txt", + .data_start = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_newlib_txt_start, + .data_end = _binary_static_Documentation_YOUR_RIGHTS_AND_OBLIGATIONS_newlib_txt_end), + ), + ), + STATIC_DIR("harness", + STATIC_FILE("rom.bin", + .data_start = (void*)0x00000000, + .data_size = 16*1024), + // TODO: Make flash.bin writable. + STATIC_FILE("flash.bin", + .data_start = (void*)0x10000000, + .data_size = PICO_FLASH_SIZE_BYTES), + // TODO: system.log + // TODO: proc.txt + // TODO: ctl + ), + STATIC_DIR("dut", + // TODO: hdmi.nut + // TODO: uart.txt + // TODO: usb-keyboard.txt + ), + ); + +static lo_interface lib9p_srv_file get_root(struct lib9p_srv_ctx *LM_UNUSED(ctx), struct lib9p_s LM_UNUSED(treename)) { + return root; +} + +/* Code ***********************************************************************/ + static COROUTINE hello_world_cr(void *_chan) { const char *msg = "Hello world!\n"; usb_keyboard_rpc_t *chan = _chan; @@ -123,6 +213,8 @@ COROUTINE init_cr(void *) { globals.keyboard_chan = (usb_keyboard_rpc_t){0}; + globals.srv.rootdir = get_root; + /* set up coroutines **************************************************/ coroutine_add("usb_common", usb_common_cr, NULL); coroutine_add("usb_keyboard", usb_keyboard_cr, &globals.keyboard_chan); -- cgit v1.2.3-2-g168b From 3d5cb59006cf393a97ad3f87ef64fb258fd79ce9 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Thu, 20 Feb 2025 23:59:09 -0700 Subject: cmd/sbc_harness: Comment out the hello-world keyboard generator --- cmd/sbc_harness/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'cmd/sbc_harness/main.c') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index c45054b..69df077 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -125,6 +125,7 @@ static lo_interface lib9p_srv_file get_root(struct lib9p_srv_ctx *LM_UNUSED(ctx) /* Code ***********************************************************************/ +/* static COROUTINE hello_world_cr(void *_chan) { const char *msg = "Hello world!\n"; usb_keyboard_rpc_t *chan = _chan; @@ -140,6 +141,7 @@ static COROUTINE hello_world_cr(void *_chan) { cr_end(); } +*/ struct { struct rp2040_hwspi dev_spi; @@ -218,7 +220,7 @@ COROUTINE init_cr(void *) { /* set up coroutines **************************************************/ coroutine_add("usb_common", usb_common_cr, NULL); coroutine_add("usb_keyboard", usb_keyboard_cr, &globals.keyboard_chan); - coroutine_add("hello_world", hello_world_cr, &globals.keyboard_chan); + //coroutine_add("hello_world", hello_world_cr, &globals.keyboard_chan); coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, NULL); for (int i = 0; i < _CONFIG_9P_NUM_SOCKS; i++) { char name[] = {'r', 'e', 'a', 'd', '-', hexdig[i], '\0'}; -- cgit v1.2.3-2-g168b From 5dab625d981e0039a5d874f5d8a6f795472785bc Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Fri, 21 Feb 2025 09:02:22 -0700 Subject: Make use of the generated stack.c --- cmd/sbc_harness/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/sbc_harness/main.c') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 69df077..2e83476 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -221,7 +221,7 @@ COROUTINE init_cr(void *) { coroutine_add("usb_common", usb_common_cr, NULL); coroutine_add("usb_keyboard", usb_keyboard_cr, &globals.keyboard_chan); //coroutine_add("hello_world", hello_world_cr, &globals.keyboard_chan); - coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, NULL); + coroutine_add("dhcp", dhcp_cr, NULL); for (int i = 0; i < _CONFIG_9P_NUM_SOCKS; i++) { char name[] = {'r', 'e', 'a', 'd', '-', hexdig[i], '\0'}; coroutine_add(name, read9p_cr, NULL); -- cgit v1.2.3-2-g168b