Skip to content

Commit 2d0187d

Browse files
committed
Docs: Update usage example for __uvisor_ctx
1 parent fd05c3c commit 2d0187d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/api/QUICKSTART.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ The `private_button_main_thread` function configures the push-button to trigger
233233
/* The previous code goes here. */
234234
...
235235
236+
#define uvisor_ctx ((PrivateButtonStaticMemory *) __uvisor_ctx)
237+
236238
#define PRIVATE_BUTTON_BUFFER_COUNT 8
237239
238240
static void private_button_on_press(void)
@@ -290,7 +292,7 @@ static void private_button_main_thread(const void *)
290292
A few things to note in the code above:
291293

292294
* If code is running in the context of `private_button`, then any object instantiated inside that code will belong to the `private_button` heap and stack. This means that in the example above, the `InterruptIn` object is private to the `private_button` box. The same applies to the dynamically allocated buffer `uvisor_ctx->buffer`.
293-
* You can access the content of the private memory `PrivateButtonStaticMemory` using the `PrivateButtonStaticMemory volatile * volatile uvisor_ctx` pointer, which uVisor maintains.
295+
* You can access the content of the private memory `PrivateButtonStaticMemory` using the `void * const __uvisor_ctx` pointer, which uVisor maintains. You need to cast this pointer to your own context type. In this example we used a pre-processor symbol to improve readability.
294296
* The `InterruptIn` object triggers the registration of an interrupt slot. Because that code is run in the context of the `private_button` box, then the push-button IRQ belongs to that box. If you want to use the IRQ APIs directly, read the [section](#the-nvic-apis) below.
295297
* Even if the `private_button_on_press` function runs in the context of `private_button`, we can still use the `printf` function, which accesses the `UART0` peripheral, owned by the public box. This is because all ACLs declared in the public box are by default shared with all the other secure boxes. This also means that the messages we are printing on the serial port are not secure, because other boxes have access to that peripheral.
296298

0 commit comments

Comments
 (0)