summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/sbc_harness/CMakeLists.txt1
-rw-r--r--cmd/sbc_harness/main.c29
2 files changed, 27 insertions, 3 deletions
diff --git a/cmd/sbc_harness/CMakeLists.txt b/cmd/sbc_harness/CMakeLists.txt
index b3aa610..f1b1be2 100644
--- a/cmd/sbc_harness/CMakeLists.txt
+++ b/cmd/sbc_harness/CMakeLists.txt
@@ -24,6 +24,7 @@ target_link_libraries(sbc_harness_objs
libusb
libdhcp
libhw
+ lib9p
)
pico_minimize_runtime(sbc_harness_objs
INCLUDE PRINTF PRINTF_MINIMAL PRINTF_LONG_LONG PRINTF_PTRDIFF_T
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c
index fb4b696..bbefe92 100644
--- a/cmd/sbc_harness/main.c
+++ b/cmd/sbc_harness/main.c
@@ -13,17 +13,21 @@
#include <libhw/rp2040_hwspi.h>
#include <libhw/w5500.h>
#include <libmisc/hash.h>
+#include <libmisc/vcall.h>
#include <libusb/usb_common.h>
#include <libdhcp/client.h>
+#include <lib9p/srv.h>
#define LOG_NAME MAIN
#include <libmisc/log.h>
#include "usb_keyboard.h"
+#include "config.h"
+
#define ARRAY_LEN(arr) (sizeof(arr)/sizeof((arr)[0]))
-COROUTINE hello_world_cr(void *_chan) {
+static COROUTINE hello_world_cr(void *_chan) {
const char *msg = "Hello world!\n";
usb_keyboard_rpc_t *chan = _chan;
cr_begin();
@@ -39,7 +43,7 @@ COROUTINE hello_world_cr(void *_chan) {
cr_end();
}
-COROUTINE dhcp_cr(void *_chip) {
+static COROUTINE dhcp_cr(void *_chip) {
struct w5500 *chip = _chip;
cr_begin();
@@ -53,9 +57,20 @@ struct {
struct w5500 dev_w5500;
usb_keyboard_rpc_t keyboard_chan;
uint16_t usb_serial[sizeof(uint64_t)*2]; /* UTF-16 */
+ struct lib9p_srv srv;
} globals;
+static COROUTINE read9p_cr(void *) {
+ cr_begin();
+
+ lib9p_srv_read_cr(&globals.srv,
+ VCALL(&globals.dev_w5500, tcp_listen, CONFIG_9P_PORT));
+
+ cr_end();
+}
+
const char *hexdig = "0123456789ABCDEF";
+static_assert(CONFIG_9P_MAX_REQS*_CONFIG_9P_NUM_SOCKS <= 16);
COROUTINE init_cr(void *) {
cr_begin();
@@ -103,8 +118,16 @@ 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, &keyboard_chan);
+ coroutine_add("hello_world", hello_world_cr, &globals.keyboard_chan);
coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, &globals.dev_w5500);
+ 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);
+ }
+ for (int i = 0; i < CONFIG_9P_MAX_REQS*_CONFIG_9P_NUM_SOCKS; i++) {
+ char name[] = {'w', 'r', 'i', 't', 'e', '-', hexdig[i], '\0'};
+ coroutine_add(name, lib9p_srv_write_cr, &globals.srv);
+ }
cr_exit();
}