From 4d35f851ddbf1df3dd4bafac587f304d1e38808d Mon Sep 17 00:00:00 2001 From: pthierry Date: Fri, 6 Dec 2024 15:57:07 +0100 Subject: [PATCH] uapi: fix autotest and idle UAPI usage for new FFI-C API --- .../src/drivers/timer/stm32-basic-timer.c | 10 +-- autotest/src/main.c | 2 +- autotest/src/printf.c | 2 +- autotest/src/ssp.c | 2 +- autotest/src/tests/test_cycles.c | 28 ++++---- autotest/src/tests/test_dma.c | 72 +++++++++---------- autotest/src/tests/test_gpio.c | 34 ++++----- autotest/src/tests/test_handle.c | 2 +- autotest/src/tests/test_ipc.c | 20 +++--- autotest/src/tests/test_irq.c | 10 +-- autotest/src/tests/test_map.c | 14 ++-- autotest/src/tests/test_random.c | 10 +-- autotest/src/tests/test_shm.c | 64 ++++++++--------- autotest/src/tests/test_signal.c | 6 +- autotest/src/tests/test_sleep.c | 10 +-- autotest/src/tests/test_yield.c | 6 +- idle/src/main.c | 8 +-- idle/src/ssp.c | 2 +- 18 files changed, 151 insertions(+), 151 deletions(-) diff --git a/autotest/src/drivers/timer/stm32-basic-timer.c b/autotest/src/drivers/timer/stm32-basic-timer.c index 25a3b508..3e298898 100644 --- a/autotest/src/drivers/timer/stm32-basic-timer.c +++ b/autotest/src/drivers/timer/stm32-basic-timer.c @@ -47,7 +47,7 @@ int timer_init(void) /* enable interrupt update */ reg |= TIM_DIER_UIE; iowrite32(desc->base_addr + TIM_DIER_REG, reg); - sys_irq_enable(desc->irqn); + __sys_irq_enable(desc->irqn); return 0; } @@ -77,7 +77,7 @@ int timer_enable_interrupt(void) /* enable interrupt update */ reg |= TIM_DIER_UIE; iowrite32(desc->base_addr + TIM_DIER_REG, reg); - sys_irq_enable(desc->irqn); + __sys_irq_enable(desc->irqn); return 0; } @@ -133,12 +133,12 @@ Status timer_map(devh_t *handle) { stm32_timer_desc_t const *desc = stm32_timer_get_desc(); Status res; - res = sys_get_device_handle(desc->label); + res = __sys_get_device_handle(desc->label); if (res != STATUS_OK) { goto end; } copy_to_user((uint8_t*)handle, sizeof(devh_t)); - res = sys_map_dev(*handle); + res = __sys_map_dev(*handle); if (res != STATUS_OK) { goto end; } @@ -150,7 +150,7 @@ Status timer_unmap(devh_t handle) { stm32_timer_desc_t const *desc = stm32_timer_get_desc(); Status res; - res = sys_unmap_dev(handle); + res = __sys_unmap_dev(handle); if (res != STATUS_OK) { goto end; } diff --git a/autotest/src/main.c b/autotest/src/main.c index 1d68b346..b01f35b8 100644 --- a/autotest/src/main.c +++ b/autotest/src/main.c @@ -86,6 +86,6 @@ void __attribute__((no_stack_protector, used, noreturn)) autotest(uint32_t label /* all tests finished, leaving */ - sys_exit(0); + __sys_exit(0); __builtin_unreachable(); } diff --git a/autotest/src/printf.c b/autotest/src/printf.c index fbea80ba..57659612 100644 --- a/autotest/src/printf.c +++ b/autotest/src/printf.c @@ -21,7 +21,7 @@ static inline void dbgbuffer_display(void) { uint16_t len = log_get_dbgbuf_offset(); copy_from_user(log_get_dbgbuf(), len); - sys_log(len); + __sys_log(len); } diff --git a/autotest/src/ssp.c b/autotest/src/ssp.c index 3fb45c21..d739eb16 100644 --- a/autotest/src/ssp.c +++ b/autotest/src/ssp.c @@ -6,7 +6,7 @@ void __stack_chk_fail(void) { /* End of task. NOTE: stack corruption is a serious security issue */ - sys_exit(STATUS_CRITICAL); + __sys_exit(STATUS_CRITICAL); while (1) { }; } diff --git a/autotest/src/tests/test_cycles.c b/autotest/src/tests/test_cycles.c index 3483e8c0..9519ad28 100644 --- a/autotest/src/tests/test_cycles.c +++ b/autotest/src/tests/test_cycles.c @@ -13,31 +13,31 @@ void test_cycles_duration(void) uint64_t micro, start, stop; uint32_t idx; TEST_START(); - /* as svc exchange is zeroified by sys_log usage, + /* as svc exchange is zeroified by __sys_log usage, * and because logging is impacting the duration, we first * get all the values, and then assert them */ /* rearm quantum first */ - sys_yield(); - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_sched_yield(); + __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)&start, sizeof(uint64_t)); for (idx = 0; idx <= 1000; ++idx) { - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_get_cycle(PRECISION_MICROSECONDS); } - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)&stop, sizeof(uint64_t)); LOG("average get_cycle cost: %lu", (uint32_t)((stop - start) / idx)); /* rearm quantum first */ - sys_yield(); - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_sched_yield(); + __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)&start, sizeof(uint64_t)); for (idx = 0; idx <= 1000; ++idx) { - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)µ, sizeof(uint64_t)); } - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)&stop, sizeof(uint64_t)); LOG("average get_cycle+copy cost: %lu", (uint32_t)((stop - start) / idx)); @@ -52,22 +52,22 @@ void test_cycles_precision(void) Status cycle_st, milli_st, micro_st, nano_st; uint64_t milli, micro, nano, cycle; TEST_START(); - /* as svc exchange is zeroified by sys_log usage, + /* as svc exchange is zeroified by __sys_log usage, * and because logging is impacting the duration, we first * get all the values, and then assert them */ - milli_st = sys_get_cycle(PRECISION_MILLISECONDS); + milli_st = __sys_get_cycle(PRECISION_MILLISECONDS); copy_to_user((uint8_t*)&milli, sizeof(uint64_t)); - micro_st = sys_get_cycle(PRECISION_MICROSECONDS); + micro_st = __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)µ, sizeof(uint64_t)); - nano_st = sys_get_cycle(PRECISION_NANOSECONDS); + nano_st = __sys_get_cycle(PRECISION_NANOSECONDS); copy_to_user((uint8_t*)&nano, sizeof(uint64_t)); - cycle_st = sys_get_cycle(PRECISION_CYCLE); + cycle_st = __sys_get_cycle(PRECISION_CYCLE); ASSERT_EQ(milli_st, STATUS_OK); diff --git a/autotest/src/tests/test_dma.c b/autotest/src/tests/test_dma.c index 76c97168..bc1cae9b 100644 --- a/autotest/src/tests/test_dma.c +++ b/autotest/src/tests/test_dma.c @@ -17,11 +17,11 @@ static void test_dma_get_handle(dmah_t* d2mstreamh, dmah_t *m2mstreamh) { Status res; TEST_START(); - res = sys_get_dma_stream_handle(0x1); + res = __sys_get_dma_stream_handle(0x1); copy_to_user((uint8_t*)d2mstreamh, sizeof(dmah_t)); ASSERT_EQ(res, STATUS_OK); LOG("handle is %lx", *d2mstreamh); - res = sys_get_dma_stream_handle(0x2); + res = __sys_get_dma_stream_handle(0x2); copy_to_user((uint8_t*)m2mstreamh, sizeof(dmah_t)); ASSERT_EQ(res, STATUS_OK); LOG("handle is %lx", *m2mstreamh); @@ -33,7 +33,7 @@ static void test_dma_get_handle_inval(void) Status res; dmah_t stream = 0; TEST_START(); - res = sys_get_dma_stream_handle(0x42); + res = __sys_get_dma_stream_handle(0x42); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -42,16 +42,16 @@ static void test_dma_start_stream(dmah_t stream) { Status res; TEST_START(); - res = sys_dma_start_stream(stream); + res = __sys_dma_start_stream(stream); ASSERT_EQ(res, STATUS_INVALID); - res = sys_dma_assign_stream(stream); + res = __sys_dma_assign_stream(stream); ASSERT_EQ(res, STATUS_OK); /* assigned, should start */ - res = sys_dma_start_stream(stream); + res = __sys_dma_start_stream(stream); ASSERT_EQ(res, STATUS_OK); - res = sys_dma_assign_stream(stream); + res = __sys_dma_assign_stream(stream); ASSERT_EQ(res, STATUS_INVALID); - res = sys_dma_start_stream(stream); + res = __sys_dma_start_stream(stream); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -60,11 +60,11 @@ static void test_dma_manipulate_stream_badhandle(void) { Status res; TEST_START(); - res = sys_dma_start_stream(0); + res = __sys_dma_start_stream(0); ASSERT_EQ(res, STATUS_INVALID); - res = sys_dma_suspend_stream(0); + res = __sys_dma_suspend_stream(0); ASSERT_EQ(res, STATUS_INVALID); - res = sys_dma_get_stream_status(0); + res = __sys_dma_get_stream_status(0); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -73,7 +73,7 @@ static void test_dma_get_stream_status(dmah_t stream) { Status res; TEST_START(); - res = sys_dma_get_stream_status(stream); + res = __sys_dma_get_stream_status(stream); ASSERT_EQ(res, STATUS_OK); TEST_END(); } @@ -82,9 +82,9 @@ static void test_dma_stop_stream(dmah_t stream) { Status res; TEST_START(); - res = sys_dma_suspend_stream(stream); + res = __sys_dma_suspend_stream(stream); ASSERT_EQ(res, STATUS_OK); - res = sys_dma_unassign_stream(stream); + res = __sys_dma_unassign_stream(stream); ASSERT_EQ(res, STATUS_OK); TEST_END(); } @@ -93,13 +93,13 @@ static void test_dma_assign_unassign_stream(dmah_t stream) { Status res; TEST_START(); - res = sys_dma_assign_stream(stream); + res = __sys_dma_assign_stream(stream); ASSERT_EQ(res, STATUS_OK); - res = sys_dma_assign_stream(stream); + res = __sys_dma_assign_stream(stream); ASSERT_EQ(res, STATUS_INVALID); - res = sys_dma_unassign_stream(stream); + res = __sys_dma_unassign_stream(stream); ASSERT_EQ(res, STATUS_OK); - res = sys_dma_unassign_stream(stream); + res = __sys_dma_unassign_stream(stream); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -116,46 +116,46 @@ static void test_dma_start_n_wait_stream(dmah_t stream) perms |= SHM_PERMISSION_MAP; int ret_builtin; TEST_START(); - res = sys_get_process_handle(0xbabeUL); + res = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&myself, sizeof(taskh_t)); // preparing shm1 with content - res = sys_get_shm_handle(shms[0].id); + res = __sys_get_shm_handle(shms[0].id); copy_to_user((uint8_t*)&shm1, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_shm_set_credential(shm1, myself, perms); + res = __sys_shm_set_credential(shm1, myself, perms); ASSERT_EQ(res, STATUS_OK); - res = sys_map_shm(shm1); + res = __sys_map_shm(shm1); ASSERT_EQ(res, STATUS_OK); - res = sys_shm_get_infos(shm1); + res = __sys_shm_get_infos(shm1); copy_to_user((uint8_t*)&shminfos1, sizeof(shm_infos_t)); ASSERT_EQ(res, STATUS_OK); memset((void*)shminfos1.base, 0xa5, 0x100UL); // garbaging shm2 - res = sys_get_shm_handle(shms[1].id); + res = __sys_get_shm_handle(shms[1].id); copy_to_user((uint8_t*)&shm2, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_shm_set_credential(shm2, myself, perms); + res = __sys_shm_set_credential(shm2, myself, perms); ASSERT_EQ(res, STATUS_OK); - res = sys_map_shm(shm2); + res = __sys_map_shm(shm2); ASSERT_EQ(res, STATUS_OK); - res = sys_shm_get_infos(shm2); + res = __sys_shm_get_infos(shm2); copy_to_user((uint8_t*)&shminfos2, sizeof(shm_infos_t)); ASSERT_EQ(res, STATUS_OK); memset((void*)shminfos2.base, 0x42, 0x100UL); // start stream - res = sys_dma_assign_stream(stream); + res = __sys_dma_assign_stream(stream); ASSERT_EQ(res, STATUS_OK); - res = sys_dma_start_stream(stream); + res = __sys_dma_start_stream(stream); ASSERT_EQ(res, STATUS_OK); /* wait 50ms for DMA event, should rise in the meantime */ - res = sys_wait_for_event(EVENT_TYPE_DMA, -1); + res = __sys_wait_for_event(EVENT_TYPE_DMA, -1); ASSERT_EQ(res, STATUS_OK); // compare shm1 with shm2 ret_builtin = memcmp((void*)shminfos1.base, (void*)shminfos2.base, 0x100); ASSERT_EQ((uint32_t)ret_builtin, 0); - res = sys_dma_suspend_stream(stream); + res = __sys_dma_suspend_stream(stream); ASSERT_EQ(res, STATUS_OK); - res = sys_dma_unassign_stream(stream); + res = __sys_dma_unassign_stream(stream); ASSERT_EQ(res, STATUS_OK); TEST_END(); } @@ -167,15 +167,15 @@ static void test_dma_get_info(dmah_t stream) shmh_t shm; shm_infos_t infos; TEST_START(); - res = sys_get_shm_handle(shms[0].id); + res = __sys_get_shm_handle(shms[0].id); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_shm_get_infos(shm); + res = __sys_shm_get_infos(shm); copy_to_user((uint8_t*)&infos, sizeof(shm_infos_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_get_dma_stream_handle(0x1); + res = __sys_get_dma_stream_handle(0x1); ASSERT_EQ(res, STATUS_OK); - res = sys_dma_get_stream_info(stream); + res = __sys_dma_get_stream_info(stream); copy_to_user((uint8_t*)&stream_info, sizeof(gpdma_stream_cfg_t)); ASSERT_EQ(res, STATUS_OK); ASSERT_EQ((uint32_t)stream_info.stream, 112); diff --git a/autotest/src/tests/test_gpio.c b/autotest/src/tests/test_gpio.c index de9113a8..e09432de 100644 --- a/autotest/src/tests/test_gpio.c +++ b/autotest/src/tests/test_gpio.c @@ -15,13 +15,13 @@ void test_gpio_on(void) Status res; devh_t dev; TEST_START(); - res = sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); + res = __sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); copy_to_user((uint8_t*)&dev, sizeof(devh_t)); ASSERT_EQ(res, STATUS_OK); LOG("handle is %lx", dev); - res = sys_gpio_configure(dev, 0); + res = __sys_gpio_configure(dev, 0); ASSERT_EQ(res, STATUS_OK); - res = sys_gpio_set(dev, 0, 1); + res = __sys_gpio_set(dev, 0, 1); ASSERT_EQ(res, STATUS_OK); TEST_END(); } @@ -32,13 +32,13 @@ void test_gpio_off(void) devh_t dev; TEST_START(); - res = sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); + res = __sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); copy_to_user((uint8_t*)&dev, sizeof(devh_t)); ASSERT_EQ(res, STATUS_OK); LOG("handle is %lx", dev); - res = sys_gpio_configure(dev, 0); + res = __sys_gpio_configure(dev, 0); ASSERT_EQ(res, STATUS_OK); - res = sys_gpio_set(dev, 0, 0); + res = __sys_gpio_set(dev, 0, 0); ASSERT_EQ(res, STATUS_OK); TEST_END(); } @@ -52,14 +52,14 @@ void test_gpio_toggle(void) duration.tag = SLEEP_DURATION_ARBITRARY_MS; duration.arbitrary_ms = 250; /* 250 ms*/ TEST_START(); - res = sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); + res = __sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); copy_to_user((uint8_t*)&dev, sizeof(devh_t)); - res = sys_gpio_configure(dev, 0); + res = __sys_gpio_configure(dev, 0); ASSERT_EQ(res, STATUS_OK); for (uint8_t i = 0; i < 10; ++i) { - res = sys_gpio_toggle(dev, 0); + res = __sys_gpio_toggle(dev, 0); ASSERT_EQ(res, STATUS_OK); - sys_sleep(duration, SLEEP_MODE_DEEP); + __sys_sleep(duration, SLEEP_MODE_DEEP); } TEST_END(); } @@ -70,13 +70,13 @@ void test_gpio_invalid_io(void) devh_t dev; TEST_START(); - res = sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); + res = __sys_get_device_handle((uint8_t)devices[DEV_ID_LED0].id); copy_to_user((uint8_t*)&dev, sizeof(devh_t)); - res = sys_gpio_configure(dev, 4); + res = __sys_gpio_configure(dev, 4); ASSERT_EQ(res, STATUS_INVALID); - res = sys_gpio_configure(dev, 8); + res = __sys_gpio_configure(dev, 8); ASSERT_EQ(res, STATUS_INVALID); - res = sys_gpio_configure(dev, 250); + res = __sys_gpio_configure(dev, 250); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -87,7 +87,7 @@ void test_gpio_invalid_devh(void) devh_t dev = 1; TEST_START(); - res = sys_gpio_configure(dev, 1); + res = __sys_gpio_configure(dev, 1); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -107,9 +107,9 @@ void test_gpio(void) { TEST_SUITE_START("sys_gpio"); test_gpio_toggle(); test_gpio_off(); - sys_sleep(duration, SLEEP_MODE_DEEP); + __sys_sleep(duration, SLEEP_MODE_DEEP); test_gpio_on(); - sys_sleep(duration, SLEEP_MODE_DEEP); + __sys_sleep(duration, SLEEP_MODE_DEEP); test_gpio_off(); test_gpio_invalid_io(); test_gpio_invalid_devh(); diff --git a/autotest/src/tests/test_handle.c b/autotest/src/tests/test_handle.c index 64762f18..17212ff3 100644 --- a/autotest/src/tests/test_handle.c +++ b/autotest/src/tests/test_handle.c @@ -24,7 +24,7 @@ void test_gethandle(void) copy_from_user((uint8_t*)&handle, sizeof(handle)); copy_to_user((uint8_t*)&handle, sizeof(handle)); ASSERT_EQ(handle, 0); - ret = sys_get_process_handle(0xbabeUL); + ret = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&handle, sizeof(taskh_t)); ASSERT_EQ(ret, STATUS_OK); LOG("received handle: %lx", handle); diff --git a/autotest/src/tests/test_ipc.c b/autotest/src/tests/test_ipc.c index 7d1eca71..6b622922 100644 --- a/autotest/src/tests/test_ipc.c +++ b/autotest/src/tests/test_ipc.c @@ -13,16 +13,16 @@ void test_ipc_send_toobig(void) Status ret; taskh_t handle = 0; uint8_t len = CONFIG_SVC_EXCHANGE_AREA_LEN+1; - ret = sys_get_process_handle(0xbabeUL); + ret = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&handle, sizeof(taskh_t)); ASSERT_EQ(ret, STATUS_OK); TEST_START(); LOG("sending invalid IPC size %lu", (uint32_t)len); - ret = sys_send_ipc(handle, len); + ret = __sys_send_ipc(handle, len); ASSERT_EQ(ret, STATUS_INVALID); len = 255; LOG("sending invalid IPC size %lu", (uint32_t)len); - ret = sys_send_ipc(handle, len); + ret = __sys_send_ipc(handle, len); ASSERT_EQ(ret, STATUS_INVALID); TEST_END(); } @@ -32,7 +32,7 @@ void test_ipc_send_invalidtarget(void) Status ret; TEST_START(); LOG("sending IPC to invalid target"); - ret = sys_send_ipc(0xdead1001UL, 20); + ret = __sys_send_ipc(0xdead1001UL, 20); ASSERT_EQ(ret, STATUS_INVALID); TEST_END(); } @@ -46,15 +46,15 @@ void test_ipc_sendrecv(void) int32_t timeout = 100L; /* milisecond timeout */ exchange_event_t *header; - ret = sys_get_process_handle(0xbabeUL); + ret = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&handle, sizeof(taskh_t)); LOG("handle is %lx", handle); ASSERT_EQ(ret, STATUS_OK); TEST_START(); LOG("sending IPC to myself"); copy_from_user(msg, 20); - ret = sys_send_ipc(handle, 20); - ret = sys_wait_for_event(EVENT_TYPE_IPC, timeout); + ret = __sys_send_ipc(handle, 20); + ret = __sys_wait_for_event(EVENT_TYPE_IPC, timeout); copy_to_user(data, 20+sizeof(exchange_event_t)); header = (exchange_event_t*)&data[0]; uint32_t source = header->source; @@ -78,16 +78,16 @@ void test_ipc_deadlock(void) int32_t timeout = 100L; /* milisecond timeout */ exchange_event_t *header; - ret = sys_get_process_handle(0xbabeUL); + ret = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&handle, sizeof(taskh_t)); ASSERT_EQ(ret, STATUS_OK); TEST_START(); LOG("sending IPC to myself"); copy_from_user(msg, 20); - ret = sys_send_ipc(handle, 20); + ret = __sys_send_ipc(handle, 20); ASSERT_EQ(ret, STATUS_OK); LOG("sending another IPC, should lead to STATUS_DEADLK"); - ret = sys_send_ipc(handle, 20); + ret = __sys_send_ipc(handle, 20); ASSERT_EQ(ret, STATUS_DEADLK); TEST_END(); } diff --git a/autotest/src/tests/test_irq.c b/autotest/src/tests/test_irq.c index a30259ed..cf47bf32 100644 --- a/autotest/src/tests/test_irq.c +++ b/autotest/src/tests/test_irq.c @@ -22,7 +22,7 @@ static void test_irq_spawn_two_it(void) timer_enable_interrupt(); timer_enable(); /* waiting 1200ms */ - res = sys_wait_for_event(EVENT_TYPE_IRQ, 0); + res = __sys_wait_for_event(EVENT_TYPE_IRQ, 0); copy_to_user(&tab[0], sizeof(exchange_event_t) + 4); ASSERT_EQ(res, STATUS_OK); IRQn = (uint32_t*)&((exchange_event_t*)tab)->data; @@ -30,7 +30,7 @@ static void test_irq_spawn_two_it(void) timer_enable_interrupt(); timer_enable(); /* waiting 1200ms */ - res = sys_wait_for_event(EVENT_TYPE_IRQ, 0); + res = __sys_wait_for_event(EVENT_TYPE_IRQ, 0); copy_to_user(&tab[0], sizeof(exchange_event_t) + 4); ASSERT_EQ(res, STATUS_OK); IRQn = (uint32_t*)&((exchange_event_t*)tab)->data; @@ -46,7 +46,7 @@ static void test_irq_spawn_one_it(void) timer_enable_interrupt(); timer_enable(); /* waiting 1200ms */ - res = sys_wait_for_event(EVENT_TYPE_IRQ, 0); + res = __sys_wait_for_event(EVENT_TYPE_IRQ, 0); copy_to_user(&tab[0], sizeof(exchange_event_t) + 4); ASSERT_EQ(res, STATUS_OK); uint32_t *IRQn = (uint32_t*)&((exchange_event_t*)tab)->data; @@ -69,7 +69,7 @@ static void test_irq_spawn_periodic(void) for (count = 0; count < 5; ++count) { /* reeanble interrupt line (nvic unmasked)*/ LOG("interrupt count %d wait", count); - res = sys_wait_for_event(EVENT_TYPE_IRQ, 0); + res = __sys_wait_for_event(EVENT_TYPE_IRQ, 0); copy_to_user(&tab[0], sizeof(exchange_event_t) + 4); ASSERT_EQ(res, STATUS_OK); uint32_t *IRQn = (uint32_t*)&((exchange_event_t*)tab)->data; @@ -79,7 +79,7 @@ static void test_irq_spawn_periodic(void) } } /* waiting 2s, there should not have any more interrupts by now */ - res = sys_wait_for_event(EVENT_TYPE_IRQ, 2000); + res = __sys_wait_for_event(EVENT_TYPE_IRQ, 2000); ASSERT_EQ(res, STATUS_TIMEOUT); } diff --git a/autotest/src/tests/test_map.c b/autotest/src/tests/test_map.c index 03d8eb3e..3da53f8a 100644 --- a/autotest/src/tests/test_map.c +++ b/autotest/src/tests/test_map.c @@ -14,10 +14,10 @@ void test_map_unmap_notmapped(void) { Status res; devh_t dev; TEST_START(); - res = sys_get_device_handle((uint8_t)devices[DEV_ID_I2C1].id); + res = __sys_get_device_handle((uint8_t)devices[DEV_ID_I2C1].id); copy_to_user((uint8_t*)&dev, sizeof(devh_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_unmap_dev(dev); + res = __sys_unmap_dev(dev); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -26,11 +26,11 @@ void test_map_invalidmap(void) { Status res; devh_t dev; TEST_START(); - res = sys_get_device_handle((uint8_t)devices[DEV_ID_I2C1].id); + res = __sys_get_device_handle((uint8_t)devices[DEV_ID_I2C1].id); copy_to_user((uint8_t*)&dev, sizeof(devh_t)); ASSERT_EQ(res, STATUS_OK); dev += 42; - res = sys_map_dev(dev); + res = __sys_map_dev(dev); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -40,11 +40,11 @@ void test_map_mapunmap(void) { devh_t dev; TEST_START(); - res = sys_get_device_handle((uint8_t)devices[DEV_ID_I2C1].id); + res = __sys_get_device_handle((uint8_t)devices[DEV_ID_I2C1].id); copy_to_user((uint8_t*)&dev, sizeof(devh_t)); ASSERT_EQ(res, STATUS_OK); LOG("handle is %lx", dev); - res = sys_map_dev(dev); + res = __sys_map_dev(dev); ASSERT_EQ(res, STATUS_OK); if (res == STATUS_OK) { LOG("device mapped, checking registers"); @@ -60,7 +60,7 @@ void test_map_mapunmap(void) { } } LOG("unmapping"); - res = sys_unmap_dev(dev); + res = __sys_unmap_dev(dev); ASSERT_EQ(res, STATUS_OK); TEST_END(); } diff --git a/autotest/src/tests/test_random.c b/autotest/src/tests/test_random.c index c6fabd32..28334176 100644 --- a/autotest/src/tests/test_random.c +++ b/autotest/src/tests/test_random.c @@ -16,7 +16,7 @@ void test_random_sequence(void) TEST_START(); LOG("get back random value from KRNG"); for (uint32_t idx = 0; idx < 5; ++idx) { - ret = sys_get_random(); + ret = __sys_get_random(); copy_to_user((uint8_t*)&rng, sizeof(uint32_t)); ASSERT_EQ(ret, STATUS_OK); LOG("rng retreived: 0x%lx", rng); @@ -28,14 +28,14 @@ void test_random_duration(void) { uint64_t start, stop; uint32_t rng, idx; - sys_yield(); - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_sched_yield(); + __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)&start, sizeof(uint64_t)); for (idx = 0; idx <= 1000; ++idx) { - sys_get_random(); + __sys_get_random(); copy_to_user((uint8_t*)&rng, sizeof(uint32_t)); } - sys_get_cycle(PRECISION_MICROSECONDS); + __sys_get_cycle(PRECISION_MICROSECONDS); copy_to_user((uint8_t*)&stop, sizeof(uint64_t)); LOG("average get_random+copy cost: %lu", (uint32_t)((stop - start) / idx)); } diff --git a/autotest/src/tests/test_shm.c b/autotest/src/tests/test_shm.c index ca7be9d2..d13d059c 100644 --- a/autotest/src/tests/test_shm.c +++ b/autotest/src/tests/test_shm.c @@ -30,13 +30,13 @@ void test_shm_handle(void) { Status res; shmh_t shm; TEST_START(); - res = sys_get_shm_handle(SHM_MAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_DMAPOOL); ASSERT_EQ(res, STATUS_OK); - res = sys_get_shm_handle(SHM_NOMAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_NOMAP_DMAPOOL); ASSERT_EQ(res, STATUS_OK); - res = sys_get_shm_handle(SHM_MAP_NODMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_NODMAPOOL); ASSERT_EQ(res, STATUS_OK); - res = sys_get_shm_handle(0x42); + res = __sys_get_shm_handle(0x42); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -45,10 +45,10 @@ void test_shm_unmap_notmapped(void) { Status res; shmh_t shm; TEST_START(); - res = sys_get_shm_handle(SHM_MAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_DMAPOOL); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_unmap_shm(shm); + res = __sys_unmap_shm(shm); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -57,11 +57,11 @@ void test_shm_invalidmap(void) { Status res; shmh_t shm; TEST_START(); - res = sys_get_shm_handle(SHM_MAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_DMAPOOL); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); shm += 42; - res = sys_map_shm(shm); + res = __sys_map_shm(shm); ASSERT_EQ(res, STATUS_INVALID); TEST_END(); } @@ -73,12 +73,12 @@ void test_shm_mapdenied(void) { perms |= SHM_PERMISSION_WRITE; perms |= SHM_PERMISSION_MAP; TEST_START(); - res = sys_get_shm_handle(SHM_NOMAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_NOMAP_DMAPOOL); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_shm_set_credential(shm, myself, perms); + res = __sys_shm_set_credential(shm, myself, perms); ASSERT_EQ(res, STATUS_OK); - res = sys_map_shm(shm); + res = __sys_map_shm(shm); ASSERT_EQ(res, STATUS_DENIED); TEST_END(); } @@ -88,10 +88,10 @@ void test_shm_infos(void) { shmh_t shm; shm_infos_t infos; TEST_START(); - res = sys_get_shm_handle(shms[0].id); + res = __sys_get_shm_handle(shms[0].id); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); - res = sys_shm_get_infos(shm); + res = __sys_shm_get_infos(shm); copy_to_user((uint8_t*)&infos, sizeof(shm_infos_t)); ASSERT_EQ(res, STATUS_OK); @@ -108,27 +108,27 @@ void test_shm_creds_on_mapped(void) { shmh_t shm; TEST_START(); /* get own handle first */ - res = sys_get_process_handle(0xbabeUL); + res = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&myself, sizeof(taskh_t)); /* get shm handle then */ - res = sys_get_shm_handle(SHM_MAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_DMAPOOL); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); uint32_t perms = (SHM_PERMISSION_MAP | SHM_PERMISSION_WRITE); - res = sys_shm_set_credential(shm, myself, perms); + res = __sys_shm_set_credential(shm, myself, perms); ASSERT_EQ(res, STATUS_OK); /* map SHM */ - res = sys_map_shm(shm); + res = __sys_map_shm(shm); ASSERT_EQ(res, STATUS_OK); /* try to set creds on mapped SHM */ perms = (SHM_PERMISSION_WRITE); - res = sys_shm_set_credential(shm, myself, perms); + res = __sys_shm_set_credential(shm, myself, perms); ASSERT_EQ(res, STATUS_BUSY); /* unmap SHM */ - res = sys_unmap_shm(shm); + res = __sys_unmap_shm(shm); ASSERT_EQ(res, STATUS_OK); /* set creds after unmap */ - res = sys_shm_set_credential(shm, myself, perms); + res = __sys_shm_set_credential(shm, myself, perms); ASSERT_EQ(res, STATUS_OK); TEST_END(); @@ -139,14 +139,14 @@ void test_shm_allows_idle(void) { shmh_t shm; TEST_START(); /* get idle handle first */ - res = sys_get_process_handle(0xcafeUL); + res = __sys_get_process_handle(0xcafeUL); copy_to_user((uint8_t*)&idle, sizeof(taskh_t)); /* get shm handle then */ - res = sys_get_shm_handle(SHM_MAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_DMAPOOL); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); uint32_t perms = SHM_PERMISSION_TRANSFER; - res = sys_shm_set_credential(shm, idle, perms); + res = __sys_shm_set_credential(shm, idle, perms); ASSERT_EQ(res, STATUS_OK); TEST_END(); } @@ -156,21 +156,21 @@ void test_shm_map_unmappable(void) { shmh_t shm; TEST_START(); /* get own handle first */ - res = sys_get_process_handle(0xbabeUL); + res = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&myself, sizeof(taskh_t)); /* get shm handle then */ - res = sys_get_shm_handle(SHM_MAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_DMAPOOL); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); ASSERT_EQ(res, STATUS_OK); LOG("handle is %lx", shm); /* give full write to myself */ uint32_t perms = 0; perms |= SHM_PERMISSION_WRITE; - res = sys_shm_set_credential(shm, myself, perms); + res = __sys_shm_set_credential(shm, myself, perms); LOG("creds set"); ASSERT_EQ(res, STATUS_OK); /* map SHM, should fail as creds not mappable */ - res = sys_map_shm(shm); + res = __sys_map_shm(shm); ASSERT_EQ(res, STATUS_DENIED); TEST_END(); } @@ -180,10 +180,10 @@ void test_shm_mapunmap(void) { shmh_t shm; TEST_START(); /* get own handle first */ - res = sys_get_process_handle(0xbabeUL); + res = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&myself, sizeof(taskh_t)); /* get shm handle then */ - res = sys_get_shm_handle(SHM_MAP_DMAPOOL); + res = __sys_get_shm_handle(SHM_MAP_DMAPOOL); copy_to_user((uint8_t*)&shm, sizeof(shmh_t)); LOG("handle is %lx", shm); ASSERT_EQ(res, STATUS_OK); @@ -191,11 +191,11 @@ void test_shm_mapunmap(void) { uint32_t perms = 0; perms |= SHM_PERMISSION_WRITE; perms |= SHM_PERMISSION_MAP; - res = sys_shm_set_credential(shm, myself, perms); + res = __sys_shm_set_credential(shm, myself, perms); ASSERT_EQ(res, STATUS_OK); LOG("creds set"); /* map SHM */ - res = sys_map_shm(shm); + res = __sys_map_shm(shm); ASSERT_EQ(res, STATUS_OK); if (res != STATUS_OK) { goto end; @@ -208,7 +208,7 @@ void test_shm_mapunmap(void) { shmptr++; } LOG("unmapping"); - res = sys_unmap_shm(shm); + res = __sys_unmap_shm(shm); ASSERT_EQ(res, STATUS_OK); end: TEST_END(); diff --git a/autotest/src/tests/test_signal.c b/autotest/src/tests/test_signal.c index 493d58bd..daeaf8c5 100644 --- a/autotest/src/tests/test_signal.c +++ b/autotest/src/tests/test_signal.c @@ -17,7 +17,7 @@ void test_signal_sendrecv(void) uint8_t data[CONFIG_SVC_EXCHANGE_AREA_LEN] = {0}; exchange_event_t *header; - ret = sys_get_process_handle(0xbabeUL); + ret = __sys_get_process_handle(0xbabeUL); copy_to_user((uint8_t*)&handle, sizeof(taskh_t)); LOG("handle is %lx", handle); ASSERT_EQ(ret, STATUS_OK); @@ -25,8 +25,8 @@ void test_signal_sendrecv(void) Signal sig = SIGNAL_ABORT; for (sig = SIGNAL_ABORT; sig <= SIGNAL_USR2; ++sig) { LOG("sending signal %u to myself", sig); - ret = sys_send_signal(handle, sig); - ret = sys_wait_for_event(EVENT_TYPE_SIGNAL, timeout); + ret = __sys_send_signal(handle, sig); + ret = __sys_wait_for_event(EVENT_TYPE_SIGNAL, timeout); copy_to_user(data, 4+sizeof(exchange_event_t)); header = (exchange_event_t*)&data[0]; uint32_t* content = (uint32_t*)&header->data[0]; diff --git a/autotest/src/tests/test_sleep.c b/autotest/src/tests/test_sleep.c index a70562d7..bc13db3b 100644 --- a/autotest/src/tests/test_sleep.c +++ b/autotest/src/tests/test_sleep.c @@ -15,7 +15,7 @@ void test_sleep_return(void) duration.arbitrary_ms = sleep_time; TEST_START(); - ASSERT_EQ(sys_sleep(duration, SLEEP_MODE_DEEP), STATUS_TIMEOUT); + ASSERT_EQ(__sys_sleep(duration, SLEEP_MODE_DEEP), STATUS_TIMEOUT); TEST_END(); return; @@ -42,14 +42,14 @@ void test_sleep_duration(void) duration.arbitrary_ms = sleep_time; TEST_START(); - /* as svc exchange is zeroified by sys_log usage, + /* as svc exchange is zeroified by __sys_log usage, * and because logging is impacting the duration, we first * get all the values, and then assert them */ - cycle_start_st = sys_get_cycle(PRECISION_MILLISECONDS); + cycle_start_st = __sys_get_cycle(PRECISION_MILLISECONDS); copy_to_user((uint8_t*)&start, sizeof(uint64_t)); - sleep_st = sys_sleep(duration, SLEEP_MODE_DEEP); - cycle_end_st = sys_get_cycle(PRECISION_MILLISECONDS); + sleep_st = __sys_sleep(duration, SLEEP_MODE_DEEP); + cycle_end_st = __sys_get_cycle(PRECISION_MILLISECONDS); copy_to_user((uint8_t*)&stop, sizeof(uint64_t)); ASSERT_EQ(cycle_start_st, STATUS_OK); diff --git a/autotest/src/tests/test_yield.c b/autotest/src/tests/test_yield.c index 4c251d87..7acbc38c 100644 --- a/autotest/src/tests/test_yield.c +++ b/autotest/src/tests/test_yield.c @@ -13,13 +13,13 @@ void test_yield(void) Status ret; TEST_START(); LOG("yielding..."); - ret = sys_yield(); + ret = __sys_sched_yield(); ASSERT_EQ(ret, STATUS_OK); LOG("yielding..."); - ret = sys_yield(); + ret = __sys_sched_yield(); ASSERT_EQ(ret, STATUS_OK); LOG("yielding..."); - ret = sys_yield(); + ret = __sys_sched_yield(); ASSERT_EQ(ret, STATUS_OK); TEST_END(); TEST_SUITE_END("sys_yield"); diff --git a/idle/src/main.c b/idle/src/main.c index b13b53c6..7c3b5423 100644 --- a/idle/src/main.c +++ b/idle/src/main.c @@ -38,17 +38,17 @@ void __attribute__((no_stack_protector, used, noreturn)) idle(uint32_t label, ui __stack_chk_guard = seed; copy_from_user(welcommsg, 20); - sys_log(20); + __sys_log(20); copy_from_user(yieldmsg, 26); - sys_log(26); + __sys_log(26); /* TODO: yield() first, to force task scheduling */ - sys_yield(); + __sys_sched_yield(); do { /* entering LP mode */ //sys_manage_cpu_sleep(CPU_SLEEP_WAIT_FOR_INTERRUPT); /* rise from LP, force task election */ - sys_yield(); + __sys_sched_yield(); } while (1); } diff --git a/idle/src/ssp.c b/idle/src/ssp.c index 16a76352..6f4d8a4e 100644 --- a/idle/src/ssp.c +++ b/idle/src/ssp.c @@ -5,7 +5,7 @@ void __stack_chk_fail(void) { - sys_exit(STATUS_CRITICAL); + __sys_exit(STATUS_CRITICAL); while (1) { }; }