Skip to content

Commit 741db4f

Browse files
committed
Make uVisor API Documentation Great Again
1 parent c780311 commit 741db4f

29 files changed

+352
-85
lines changed

api/inc/benchmark.h

+8
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@
2020
#include "api/inc/uvisor_exports.h"
2121
#include <stdint.h>
2222

23+
/** @cond UVISOR_INTERNAL */
24+
/** @defgroup benchmark Benchmark
25+
* @{
26+
*/
27+
2328
UVISOR_EXTERN void uvisor_benchmark_configure(void);
2429
UVISOR_EXTERN void uvisor_benchmark_start(void);
2530
UVISOR_EXTERN uint32_t uvisor_benchmark_stop(void);
2631

32+
/** @} */
33+
/** @endcond */
34+
2735
#endif /* __UVISOR_API_BENCHMARK_H__ */

api/inc/box_config.h

+32-13
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424

2525
UVISOR_EXTERN const uint32_t __uvisor_mode;
2626

27+
/** @defgroup box_config Box configuration
28+
*
29+
* @brief Creating and configuring secure boxes
30+
* @{
31+
*/
32+
2733
#define UVISOR_DISABLED 0
2834
#define UVISOR_PERMISSIVE 1
2935
#define UVISOR_ENABLED 2
@@ -54,14 +60,15 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
5460
\
5561
extern const __attribute__((section(".keep.uvisor.cfgtbl_ptr_first"), aligned(4))) void * const main_cfg_ptr = &main_cfg;
5662

57-
/* Creates a global page heap with at least `minimum_number_of_pages` each of size `page_size` in bytes.
63+
/** Creates a global page heap with at least `minimum_number_of_pages` each of size `page_size` in bytes.
5864
* The total page heap size is at least `minimum_number_of_pages * page_size`. */
5965
#define UVISOR_SET_PAGE_HEAP(page_size, minimum_number_of_pages) \
6066
const uint32_t __uvisor_page_size = (page_size); \
6167
uint8_t __attribute__((section(".keep.uvisor.page_heap"))) \
6268
main_page_heap_reserved[ (page_size) * (minimum_number_of_pages) ]
6369

6470

71+
/** @cond UVISOR_INTERNAL */
6572
/* this macro selects an overloaded macro (variable number of arguments) */
6673
#define __UVISOR_BOX_MACRO(_1, _2, _3, _4, NAME, ...) NAME
6774

@@ -121,13 +128,15 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
121128
#define UVISOR_BOX_CONFIG(...) \
122129
UVISOR_BOX_CONFIG_ACL(__VA_ARGS__)
123130

124-
/* Use this macro before box defintion (for example, UVISOR_BOX_CONFIG) to
131+
/** @endcond */
132+
133+
/** Use this macro before box defintion (for example, `UVISOR_BOX_CONFIG`) to
125134
* define the name of your box. If you don't want a name, use this macro with
126-
* box_namespace as NULL. */
135+
* box_namespace as `NULL`. */
127136
#define UVISOR_BOX_NAMESPACE(box_namespace) \
128137
static const char *const __uvisor_box_namespace = box_namespace
129138

130-
/* Use this macro before UVISOR_BOX_CONFIG to define the function the main
139+
/** Use this macro before `UVISOR_BOX_CONFIG` to define the function the main
131140
* thread of your box will use for its body. If you don't want a main thread,
132141
* too bad: you have to have one. */
133142
#define UVISOR_BOX_MAIN(function, priority, stack_size) \
@@ -139,20 +148,30 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
139148

140149
#define uvisor_ctx (*__uvisor_ps)
141150

142-
/* Return the numeric box ID of the current box. */
151+
/** @} */
152+
153+
/** @defgroup box_info Box Information
154+
*
155+
* @brief Accessing information about own box and other boxes
156+
* @{
157+
*/
158+
159+
/** @brief Return the numeric box ID of the current box. */
143160
UVISOR_EXTERN int uvisor_box_id_self(void);
144161

145-
/* Return the numeric box ID of the box that is calling through the most recent
146-
* secure gateway. Return -1 if there is no secure gateway calling box. */
162+
/** @brief Return the numeric box ID of the box that is calling through the most recent
163+
* secure gateway. @return -1 if there is no secure gateway calling box. */
147164
UVISOR_EXTERN int uvisor_box_id_caller(void);
148165

149-
/* Copy the box namespace of the specified box ID to the memory provided by
166+
/** Copy the box namespace of the specified box ID to the memory provided by
150167
* box_namespace. The box_namespace's length must be at least
151-
* MAX_BOX_NAMESPACE_LENGTH bytes. Return how many bytes were copied into
152-
* box_namespace. Return UVISOR_ERROR_INVALID_BOX_ID if the provided box ID is
153-
* invalid. Return UVISOR_ERROR_BUFFER_TOO_SMALL if the provided box_namespace
154-
* is too small to hold MAX_BOX_NAMESPACE_LENGTH bytes. Return
155-
* UVISOR_ERROR_BOX_NAMESPACE_ANONYMOUS if the box is anonymous. */
168+
* `UVISOR_MAX_BOX_NAMESPACE_LENGTH` bytes. Return how many bytes were copied into
169+
* box_namespace. Return `UVISOR_ERROR_INVALID_BOX_ID` if the provided box ID is
170+
* invalid. Return `UVISOR_ERROR_BUFFER_TOO_SMALL` if the provided box_namespace
171+
* is too small to hold `MAX_BOX_NAMESPACE_LENGTH` bytes. Return
172+
* `UVISOR_ERROR_BOX_NAMESPACE_ANONYMOUS` if the box is anonymous. */
156173
UVISOR_EXTERN int uvisor_box_namespace(int box_id, char *box_namespace, size_t length);
157174

175+
/** @} */
176+
158177
#endif /* __UVISOR_API_BOX_CONFIG_H__ */

api/inc/cmsis_nvic_virtual.h

+16-10
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919

2020
#include "api/inc/interrupts.h"
2121

22-
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
23-
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
24-
#define NVIC_EnableIRQ vIRQ_EnableIRQ
25-
#define NVIC_DisableIRQ vIRQ_DisableIRQ
26-
#define NVIC_GetPendingIRQ vIRQ_GetPendingIRQ
27-
#define NVIC_SetPendingIRQ vIRQ_SetPendingIRQ
28-
#define NVIC_ClearPendingIRQ vIRQ_ClearPendingIRQ
29-
#define NVIC_GetActive __NVIC_GetActive
30-
#define NVIC_SetPriority vIRQ_SetPriority
31-
#define NVIC_GetPriority vIRQ_GetPriority
22+
/** @addtogroup interrupt
23+
* @{
24+
*/
25+
26+
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping /**< @showinitializer */
27+
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping /**< @showinitializer */
28+
#define NVIC_EnableIRQ vIRQ_EnableIRQ /**< @showinitializer */
29+
#define NVIC_DisableIRQ vIRQ_DisableIRQ /**< @showinitializer */
30+
#define NVIC_GetPendingIRQ vIRQ_GetPendingIRQ /**< @showinitializer */
31+
#define NVIC_SetPendingIRQ vIRQ_SetPendingIRQ /**< @showinitializer */
32+
#define NVIC_ClearPendingIRQ vIRQ_ClearPendingIRQ /**< @showinitializer */
33+
#define NVIC_GetActive __NVIC_GetActive /**< @showinitializer */
34+
#define NVIC_SetPriority vIRQ_SetPriority /**< @showinitializer */
35+
#define NVIC_GetPriority vIRQ_GetPriority /**< @showinitializer */
36+
37+
/** @} */
3238

3339
#endif /* __UVISOR_API_NVIC_VIRTUAL_H__ */

api/inc/cmsis_vectab_virtual.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919

2020
#include "api/inc/interrupts.h"
2121

22-
#define NVIC_SetVector vIRQ_SetVector
23-
#define NVIC_GetVector vIRQ_GetVector
22+
/** @addtogroup interrupt
23+
* @{
24+
*/
25+
26+
#define NVIC_SetVector vIRQ_SetVector /**< @showinitializer */
27+
#define NVIC_GetVector vIRQ_GetVector /**< @showinitializer */
28+
29+
/** @} */
2430

2531
#endif /* __UVISOR_API_VECTAB_VIRTUAL_H__ */

api/inc/context_exports.h

+4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
#ifndef __UVISOR_CONTEX_EXPORTS_H__
1818
#define __UVISOR_CONTEX_EXPORTS_H__
1919

20+
/** @cond UVISOR_INTERNAL */
21+
2022
/** Maximum number of nested context switches.
2123
*
2224
* The same state stack is kept for all kinds of context switches that are bound
2325
* to a function, for which uVisor keeps an internal state. */
2426
#define UVISOR_CONTEXT_MAX_DEPTH 16
2527

28+
/** @endcond */
29+
2630
#endif /* __UVISOR_CONTEX_EXPORTS_H__ */

api/inc/debug.h

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#include "api/inc/debug_exports.h"
2121
#include "api/inc/uvisor_exports.h"
2222

23+
/** @defgroup debug Debug Box
24+
* @{
25+
*/
26+
2327
UVISOR_EXTERN void uvisor_debug_init(const TUvisorDebugDriver * const driver);
2428

29+
/** @} */
30+
2531
#endif /* __UVISOR_API_DEBUG_H__ */

api/inc/debug_exports.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919

2020
#include <stdint.h>
2121

22-
/* Debug box driver -- Version 0
22+
/** @addtogroup debug
23+
* @{
24+
*/
25+
26+
/** @brief Debug box driver -- Version 0
2327
* A constant instance of this struct must be instantiated by the unprivileged
2428
* code to setup a debug box.*/
2529
typedef struct TUvisorDebugDriver {
2630
uint32_t (*get_version)(void);
2731
void (*halt_error)(int);
2832
} TUvisorDebugDriver;
2933

30-
/* Number of handlers in the debug box driver */
34+
/** @brief Number of handlers in the debug box driver */
3135
#define DEBUG_BOX_HANDLERS_NUMBER (sizeof(TUvisorDebugDriver) / sizeof(void *))
3236

37+
/** @} */
38+
3339
#endif /* __UVISOR_API_DEBUG_EXPORTS_H__ */

api/inc/disabled.h

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "api/inc/uvisor_exports.h"
2121
#include <stdint.h>
2222

23+
/** @cond UVISOR_INTERNAL */
24+
2325
UVISOR_EXTERN void uvisor_disabled_switch_in(const uint32_t *dst_box_cfgtbl_ptr);
2426
UVISOR_EXTERN void uvisor_disabled_switch_out(void);
2527

@@ -28,4 +30,6 @@ UVISOR_EXTERN void uvisor_disabled_switch_out(void);
2830
UVISOR_EXTERN void uvisor_disabled_set_vector(uint32_t irqn, uint32_t vector);
2931
UVISOR_EXTERN uint32_t uvisor_disabled_get_vector(uint32_t irqn);
3032

33+
/** @endcond */
34+
3135
#endif /* __UVISOR_API_DISABLED_H__ */

api/inc/error.h

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#include "api/inc/halt_exports.h"
2121
#include "api/inc/uvisor_exports.h"
2222

23+
/** @defgroup error Error
24+
* @{
25+
*/
26+
2327
UVISOR_EXTERN void uvisor_error(THaltUserError reason);
2428

29+
/** @} */
30+
2531
#endif /* __UVISOR_API_ERROR_H__ */

api/inc/export_table_exports.h

+8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
#include "rt_OsEventObserver.h"
2121
#include <stdint.h>
2222

23+
/** @cond UVISOR_INTERNAL */
24+
/** @addtogroup box_config
25+
* @{
26+
*/
27+
2328
/* If this magic doesn't match what you get in a TUvisorExportTable, then you
2429
* didn't find a TUvisorExportTable and all bets are off as to what will be
2530
* contained in what you found. */
@@ -44,4 +49,7 @@ typedef struct {
4449
uint32_t size;
4550
} TUvisorExportTable;
4651

52+
/** @} */
53+
/** @endcond */
54+
4755
#endif

api/inc/halt_exports.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,28 @@
1717
#ifndef __UVISOR_API_HALT_EXPORTS_H__
1818
#define __UVISOR_API_HALT_EXPORTS_H__
1919

20+
/** @addtogroup error
21+
* @{
22+
*/
23+
24+
/** @name Global errors
25+
* @{ */
2026
#define UVISOR_ERROR_INVALID_BOX_ID (-2)
2127
#define UVISOR_ERROR_BUFFER_TOO_SMALL (-3)
2228
#define UVISOR_ERROR_BOX_NAMESPACE_ANONYMOUS (-4)
29+
/** @} */
2330

24-
31+
/** @name Global error classes
32+
* @{ */
2533
#define UVISOR_ERROR_CLASS_MASK (0xFFFF0000UL)
2634
#define UVISOR_ERROR_MASK (0x0000FFFFUL)
2735

2836
#define UVISOR_ERROR_CLASS_PAGE (1UL << 16)
37+
/** @} */
2938

39+
40+
/** @name Global halt errors
41+
* @{ */
3042
typedef enum {
3143
USER_NOT_ALLOWED = 1,
3244
} THaltUserError;
@@ -44,5 +56,8 @@ typedef enum {
4456
FAULT_DEBUG,
4557
__THALTERROR_MAX /* always keep as the last element of the enum */
4658
} THaltError;
59+
/** @} */
60+
61+
/** @} */
4762

4863
#endif /* __UVISOR_API_HALT_EXPORTS_H__ */

api/inc/interrupts.h

+14-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
#include "api/inc/uvisor_exports.h"
2121
#include <stdint.h>
2222

23+
/** @defgroup interrupt Interrupts
24+
*
25+
* @brief Secure interrupt management.
26+
* @{
27+
*/
28+
2329
UVISOR_EXTERN void vIRQ_SetVector(uint32_t irqn, uint32_t vector);
2430
UVISOR_EXTERN uint32_t vIRQ_GetVector(uint32_t irqn);
2531
UVISOR_EXTERN void vIRQ_EnableIRQ(uint32_t irqn);
@@ -38,26 +44,30 @@ UVISOR_EXTERN int vIRQ_GetLevel(void);
3844
*
3945
* Successive calls to this function increase an internal counter that is used
4046
* by uVisor to decide when to re-enable IRQs. The related call
41-
* ::vIRQ_EnableIRQ() decreases this counter. Only when the counter is 0 the
47+
* `::vIRQ_EnableIRQ()` decreases this counter. Only when the counter is 0 the
4248
* interrupts are re-enabled for that box.
4349
*
4450
* This guarantees that code that disables IRQs will not accidentally have them
4551
* re-enabled by a nested function that it calls before the expected call to
46-
* ::vIRQ_EnableAll(). Example:
52+
* `::vIRQ_EnableAll()`. Example:
4753
*
54+
* @code
4855
* vIRQ_DisableAll(); counter = 1; IRQs are now disabled.
4956
* some_function(); counter = 2, then counter = 1; IRQs are still disabled.
5057
* vIRQ_EnableAll(); counter = 0; IRQs are now re-enabled.
58+
* @endcode
5159
*
52-
* where some_function() also has a disable/enable pair. */
60+
* where `some_function()` also has a disable/enable pair. */
5361
UVISOR_EXTERN void vIRQ_DisableAll(void);
5462

5563
/** Re-enable all interrupts that were previously disabled for the currently
5664
* active box.
5765
*
5866
* This function only re-enables interrupt if the uVisor internal counter is set
5967
* to 0, to make sure that nested disabling of IRQs is still effective. See
60-
* ::vIRQ_DisableAll for more information. */
68+
* `::vIRQ_DisableAll()` for more information. */
6169
UVISOR_EXTERN void vIRQ_EnableAll(void);
6270

71+
/** @} */
72+
6373
#endif /* __UVISOR_API_INTERRUPTS_H__ */

api/inc/page_allocator.h

+16-3
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,33 @@
2121
#include "api/inc/page_allocator_exports.h"
2222
#include <stdint.h>
2323

24-
/* Allocate a number of requested pages with the requested page size.
24+
/** @defgroup page_allocator Page allocator
25+
*
26+
* @brief Allocate and free memory on the page heap.
27+
* @{
28+
*/
29+
30+
/** @brief Allocate a number of requested pages with the requested page size.
31+
*
2532
* @param table.page_size[in] Must be equal to the current page size
2633
* @param table.page_count[in] The number of pages to be allocated
2734
* @param table.page_origins[out] Pointers to the page origins. The table must be large enough to hold page_count entries.
2835
* @returns Non-zero on failure with failure class `UVISOR_ERROR_CLASS_PAGE`. See `UVISOR_ERROR_PAGE_*`.
2936
*/
3037
UVISOR_EXTERN int uvisor_page_malloc(UvisorPageTable * const table);
3138

32-
/* Free the pages associated with the table, only if it passes validation.
39+
/** @brief Free the pages associated with the table, only if it passes validation.
40+
*
3341
* @returns Non-zero on failure with failure class `UVISOR_ERROR_CLASS_PAGE`. See `UVISOR_ERROR_PAGE_*`.
3442
*/
3543
UVISOR_EXTERN int uvisor_page_free(const UvisorPageTable * const table);
3644

37-
/* @returns the active page size for one page. */
45+
/** @brief Retrieve the active page size for one page.
46+
*
47+
* @returns active page size for one page.
48+
*/
3849
UVISOR_EXTERN uint32_t uvisor_get_page_size(void);
3950

51+
/** @} */
52+
4053
#endif /* __UVISOR_API_PAGE_ALLOCATOR_H__ */

0 commit comments

Comments
 (0)