diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/.project b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/.project index 6edbd8183..a84ee8b46 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/.project +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/.project @@ -25,19 +25,9 @@ - board + sb 2 - CHIBIOS/os/hal/boards/ST_STM32L476_DISCOVERY - - - os - 2 - CHIBIOS/os - - - test - 2 - CHIBIOS/test + CHIBIOS/os/sb diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c index 6b6aa87fb..08c24333f 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_CLIENT/main.c @@ -16,6 +16,7 @@ #include #include +#include #include "sbuser.h" @@ -39,6 +40,9 @@ int main(void) { } #endif while (true) { - sbSleepMilliseconds(500); + msg_t msg = sbMsgWait(); + sbFileWrite(1U, (const uint8_t *)"Hello World!!\r\n", 15U); + sbMsgReply(msg); +// sbSleepMilliseconds(500); } } diff --git a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c index 23e8bc624..92083aed7 100644 --- a/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c +++ b/demos/STM32/RT-STM32L476-DISCOVERY-SB_HOST/main.c @@ -22,6 +22,9 @@ #include "chprintf.h" #include "sbhost.h" +/* SandBox object.*/ +sb_class_t sbx1; + /* * LEDs blinker thread, times are in milliseconds. */ @@ -39,6 +42,7 @@ static THD_FUNCTION(Thread1, arg) { chThdSleepMilliseconds(50); palSetLine(LINE_LED_RED); chThdSleepMilliseconds(200); + (void) sbSendMessage(&sbx1, 0xF00F55AAU); } } @@ -58,7 +62,6 @@ static THD_FUNCTION(Unprivileged1, arg) { .stdout_stream = (SandboxStream *)&SD2, .stderr_stream = (SandboxStream *)&SD2 }; - sb_class_t sbx1; (void)arg; chRegSetThreadName("unprivileged"); @@ -108,7 +111,7 @@ int main(void) { sdStart(&SD2, NULL); /* Creating the blinker thread.*/ - chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, + chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+10, Thread1, NULL); /* Creating the unprivileged thread.*/ diff --git a/os/sb/host/sbapi.h b/os/sb/host/sbapi.h index 049aaba07..e2a08d789 100644 --- a/os/sb/host/sbapi.h +++ b/os/sb/host/sbapi.h @@ -56,6 +56,10 @@ typedef void (*port_syscall_t)(struct port_extctx *ectx); * this subsystem. */ struct SandboxStreamVMT { + /** + * @brief Object instance offset. + */ + size_t instance_offset; /** * @brief Stream write buffer method. */ diff --git a/os/sb/host/sbhost.c b/os/sb/host/sbhost.c index b31d2c851..1329ef138 100644 --- a/os/sb/host/sbhost.c +++ b/os/sb/host/sbhost.c @@ -117,8 +117,9 @@ void sbStart(sb_class_t *sbcp, const sb_config_t *config) { /* Additional context information.*/ sbcp->config = config; - chThdGetSelfX()->ctx.syscall.p = (const void *)sbcp; - chThdGetSelfX()->ctx.syscall.psp = __get_PSP(); + sbcp->tp = chThdGetSelfX(); + sbcp->tp->ctx.syscall.p = (const void *)sbcp; + sbcp->tp->ctx.syscall.psp = __get_PSP(); /* Jumping to the unprivileged code.*/ port_unprivileged_jump(pc, psp);