diff options
-rw-r--r-- | cmd/sbc_harness/main.c | 8 | ||||
-rw-r--r-- | cmd/srv9p/main.c | 14 | ||||
-rw-r--r-- | libcr/coroutine.c | 12 | ||||
-rw-r--r-- | libcr/include/libcr/coroutine.h | 4 | ||||
-rw-r--r-- | libhw/w5500.c | 2 |
5 files changed, 24 insertions, 16 deletions
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index d015259..85dfdfb 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -86,11 +86,11 @@ int main() { usb_common_lateinit(); /* set up coroutines **************************************************/ - coroutine_add(usb_common_cr, NULL); + coroutine_add("usb_common", usb_common_cr, NULL); usb_keyboard_rpc_t keyboard_chan = {0}; - coroutine_add(usb_keyboard_cr, &keyboard_chan); - //coroutine_add(hello_world_cr, &keyboard_chan); - coroutine_add_with_stack_size(4*1024, dhcp_cr, &dev_w5500); + coroutine_add("usb_keyboard", usb_keyboard_cr, &keyboard_chan); + //coroutine_add("hello_world", hello_world_cr, &keyboard_chan); + coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, &dev_w5500); /* event loop *********************************************************/ coroutine_main(); diff --git a/cmd/srv9p/main.c b/cmd/srv9p/main.c index c5a3367..076d756 100644 --- a/cmd/srv9p/main.c +++ b/cmd/srv9p/main.c @@ -99,17 +99,23 @@ static COROUTINE read_cr(void *_srv) { cr_end(); } +const char *hexdig = "0123456789abcdef"; + int main() { struct lib9p_srv srv = { .rootdir = get_root, }; - for (int i = 0; i < CONFIG_SRV9P_NUM_CONNS; i++) - if (!coroutine_add(read_cr, &srv)) + for (int i = 0; i < CONFIG_SRV9P_NUM_CONNS; i++) { + char name[] = {'r', 'e', 'a', 'd', '-', hexdig[i], '\0'}; + if (!coroutine_add(name, read_cr, &srv)) error(1, 0, "coroutine_add(read_cr, &srv)"); - for (int i = 0; i < 2*CONFIG_SRV9P_NUM_CONNS; i++) - if (!coroutine_add(lib9p_srv_write_cr, &srv)) + } + for (int i = 0; i < 2*CONFIG_SRV9P_NUM_CONNS; i++) { + char name[] = {'w', 'r', 'i', 't', 'e', '-', hexdig[i], '\0'}; + if (!coroutine_add(name, lib9p_srv_write_cr, &srv)) error(1, 0, "coroutine_add(lib9p_srv_write_cr, &srv)"); + } coroutine_main(); return 1; diff --git a/libcr/coroutine.c b/libcr/coroutine.c index 49146f1..205d0bb 100644 --- a/libcr/coroutine.c +++ b/libcr/coroutine.c @@ -405,7 +405,9 @@ static inline void assert_cid(cid_t cid) { /* coroutine_add() ************************************************************/ -cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args) { +cid_t coroutine_add_with_stack_size(size_t stack_size, + const char __attribute__((unused)) *name, + cr_fn_t fn, void *args) { static cid_t last_created = 0; cid_t parent = coroutine_running; @@ -413,8 +415,8 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args) { assert_cid_state(parent, state == CR_RUNNING); assert(stack_size); assert(fn); - debugf("coroutine_add_with_stack_size(%zu, %p, %p)...\n", - stack_size, fn, args); + debugf("coroutine_add_with_stack_size(%zu, \"%s\", %p, %p)...\n", + stack_size, name, fn, args); cid_t child; { @@ -470,9 +472,9 @@ cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args) { return child; } -cid_t coroutine_add(cr_fn_t fn, void *args) { +cid_t coroutine_add(const char *name, cr_fn_t fn, void *args) { return coroutine_add_with_stack_size( - CONFIG_COROUTINE_DEFAULT_STACK_SIZE, fn, args); + CONFIG_COROUTINE_DEFAULT_STACK_SIZE, name, fn, args); } /* coroutine_main() ***********************************************************/ diff --git a/libcr/include/libcr/coroutine.h b/libcr/include/libcr/coroutine.h index d673fb6..95f9ba0 100644 --- a/libcr/include/libcr/coroutine.h +++ b/libcr/include/libcr/coroutine.h @@ -84,13 +84,13 @@ typedef void (*cr_fn_t)(void *args); * Returns the cid of the newly-created coroutine. May return 0 if * there are already COROUTINE_NUM active coroutines. */ -cid_t coroutine_add_with_stack_size(size_t stack_size, cr_fn_t fn, void *args); +cid_t coroutine_add_with_stack_size(size_t stack_size, const char *name, cr_fn_t fn, void *args); /** * Like coroutine_add_with_stack_size(), but uses a default stack size so * you don't need to think about it. */ -cid_t coroutine_add(cr_fn_t fn, void *args); +cid_t coroutine_add(const char *name, cr_fn_t fn, void *args); /** * The main scheduler loop. diff --git a/libhw/w5500.c b/libhw/w5500.c index a998ccf..08486d4 100644 --- a/libhw/w5500.c +++ b/libhw/w5500.c @@ -348,7 +348,7 @@ void _w5500_init(struct w5500 *chip, } } cr_enable_interrupts(); - coroutine_add(w5500_irq_cr, chip); + coroutine_add("w5500_irq", w5500_irq_cr, chip); } /* chip methods ***************************************************************/ |