Skip to content

Commit 779e2d2

Browse files
committed
Make uVisor API Documentation Great Again
1 parent 1d66097 commit 779e2d2

30 files changed

+377
-87
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

+27-10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525

2626
UVISOR_EXTERN const uint32_t __uvisor_mode;
2727

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

63-
/* Creates a global page heap with at least `minimum_number_of_pages` each of size `page_size` in bytes.
69+
/** Creates a global page heap with at least `minimum_number_of_pages` each of size `page_size` in bytes.
6470
* The total page heap size is at least `minimum_number_of_pages * page_size`. */
6571
#define UVISOR_SET_PAGE_HEAP(page_size, minimum_number_of_pages) \
6672
const uint32_t __uvisor_page_size = (page_size); \
6773
uint8_t __attribute__((section(".keep.uvisor.page_heap"))) \
6874
main_page_heap_reserved[ (page_size) * (minimum_number_of_pages) ]
6975

7076

77+
/** @cond UVISOR_INTERNAL */
7178
/* this macro selects an overloaded macro (variable number of arguments) */
7279
#define __UVISOR_BOX_MACRO(_1, _2, _3, _4, NAME, ...) NAME
7380

@@ -135,13 +142,15 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
135142
#define UVISOR_BOX_CONFIG(...) \
136143
UVISOR_BOX_CONFIG_ACL(__VA_ARGS__)
137144

138-
/* Use this macro before box defintion (for example, UVISOR_BOX_CONFIG) to
145+
/** @endcond */
146+
147+
/** Use this macro before box defintion (for example, `UVISOR_BOX_CONFIG`) to
139148
* define the name of your box. If you don't want a name, use this macro with
140-
* box_namespace as NULL. */
149+
* box_namespace as `NULL`. */
141150
#define UVISOR_BOX_NAMESPACE(box_namespace) \
142151
static const char *const __uvisor_box_namespace = box_namespace
143152

144-
/* Use this macro before UVISOR_BOX_CONFIG to define the function the main
153+
/** Use this macro before `UVISOR_BOX_CONFIG` to define the function the main
145154
* thread of your box will use for its body. If you don't want a main thread,
146155
* too bad: you have to have one. */
147156
#define UVISOR_BOX_MAIN(function, priority, stack_size) \
@@ -153,13 +162,21 @@ UVISOR_EXTERN const uint32_t __uvisor_mode;
153162

154163
#define uvisor_ctx (*__uvisor_ps)
155164

156-
/* Copy the box namespace of the specified box ID to the memory provided by
165+
/** @} */
166+
167+
/** @addtogroup box_info
168+
* @{
169+
*/
170+
171+
/** Copy the box namespace of the specified box ID to the memory provided by
157172
* box_namespace. The box_namespace's length must be at least
158-
* MAX_BOX_NAMESPACE_LENGTH bytes. Return how many bytes were copied into
159-
* box_namespace. Return UVISOR_ERROR_INVALID_BOX_ID if the provided box ID is
160-
* invalid. Return UVISOR_ERROR_BUFFER_TOO_SMALL if the provided box_namespace
161-
* is too small to hold MAX_BOX_NAMESPACE_LENGTH bytes. Return
162-
* UVISOR_ERROR_BOX_NAMESPACE_ANONYMOUS if the box is anonymous. */
173+
* `UVISOR_MAX_BOX_NAMESPACE_LENGTH` bytes. Return how many bytes were copied into
174+
* box_namespace. Return `UVISOR_ERROR_INVALID_BOX_ID` if the provided box ID is
175+
* invalid. Return `UVISOR_ERROR_BUFFER_TOO_SMALL` if the provided box_namespace
176+
* is too small to hold `MAX_BOX_NAMESPACE_LENGTH` bytes. Return
177+
* `UVISOR_ERROR_BOX_NAMESPACE_ANONYMOUS` if the box is anonymous. */
163178
UVISOR_EXTERN int uvisor_box_namespace(int box_id, char *box_namespace, size_t length);
164179

180+
/** @} */
181+
165182
#endif /* __UVISOR_API_BOX_CONFIG_H__ */

api/inc/box_id.h

+8
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@
1919

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

22+
/** @defgroup box_info Box Information
23+
*
24+
* @brief Accessing information about own box and other boxes
25+
* @{
26+
*/
27+
2228
/* Return the numeric box ID of the current box. */
2329
UVISOR_EXTERN int uvisor_box_id_self(void);
2430

2531
/* Return the numeric box ID of the box that is calling through the most recent
2632
* secure gateway. Return -1 if there is no secure gateway calling box. */
2733
UVISOR_EXTERN int uvisor_box_id_caller(void) UVISOR_DEPRECATED;
2834

35+
/** @} */
36+
2937
#endif /* __UVISOR_API_BOX_ID_H__ */

api/inc/cmsis_nvic_virtual.h

+17-11
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,22 @@
2020
#include "api/inc/interrupts.h"
2121
#include "api/inc/unvic_exports.h"
2222

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

3541
#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
@@ -21,6 +21,11 @@
2121
#include "api/inc/pool_queue_exports.h"
2222
#include <stdint.h>
2323

24+
/** @cond UVISOR_INTERNAL */
25+
/** @addtogroup box_config
26+
* @{
27+
*/
28+
2429
/* If this magic doesn't match what you get in a TUvisorExportTable, then you
2530
* didn't find a TUvisorExportTable and all bets are off as to what will be
2631
* contained in what you found. */
@@ -57,4 +62,7 @@ static inline TUvisorExportTable const * uvisor_export_table(void)
5762
return (TUvisorExportTable *) (uvisor_config_addr - uvisor_export_table_size);
5863
}
5964

65+
/** @} */
66+
/** @endcond */
67+
6068
#endif

api/inc/halt_exports.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
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)
@@ -25,13 +31,19 @@
2531
#define UVISOR_ERROR_OUT_OF_STRUCTURES (-7)
2632
#define UVISOR_ERROR_INVALID_PARAMETERS (-8)
2733
#define UVISOR_ERROR_NOT_IMPLEMENTED (-9)
34+
/** @} */
2835

29-
36+
/** @name Global error classes
37+
* @{ */
3038
#define UVISOR_ERROR_CLASS_MASK (0xFFFF0000UL)
3139
#define UVISOR_ERROR_MASK (0x0000FFFFUL)
3240

3341
#define UVISOR_ERROR_CLASS_PAGE (1UL << 16)
42+
/** @} */
3443

44+
45+
/** @name Global halt errors
46+
* @{ */
3547
typedef enum {
3648
USER_NOT_ALLOWED = 1,
3749
DEBUG_BOX_HALT,
@@ -50,5 +62,8 @@ typedef enum {
5062
FAULT_DEBUG,
5163
__THALTERROR_MAX /* always keep as the last element of the enum */
5264
} THaltError;
65+
/** @} */
66+
67+
/** @} */
5368

5469
#endif /* __UVISOR_API_HALT_EXPORTS_H__ */

api/inc/interrupts.h

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

24+
/** @defgroup interrupt Interrupts
25+
*
26+
* @brief Secure interrupt management.
27+
* @{
28+
*/
29+
2430
UVISOR_EXTERN void vIRQ_SetVector(uint32_t irqn, uint32_t vector);
2531
UVISOR_EXTERN uint32_t vIRQ_GetVector(uint32_t irqn);
2632
UVISOR_EXTERN void vIRQ_EnableIRQ(uint32_t irqn);
@@ -39,26 +45,28 @@ UVISOR_EXTERN int vIRQ_GetLevel(void);
3945
*
4046
* Successive calls to this function increase an internal counter that is used
4147
* by uVisor to decide when to re-enable IRQs. The related call
42-
* ::vIRQ_EnableIRQ() decreases this counter. Only when the counter is 0 the
48+
* `::vIRQ_EnableIRQ()` decreases this counter. Only when the counter is 0 the
4349
* interrupts are re-enabled for that box.
4450
*
4551
* This guarantees that code that disables IRQs will not accidentally have them
4652
* re-enabled by a nested function that it calls before the expected call to
47-
* ::vIRQ_EnableAll(). Example:
53+
* `::vIRQ_EnableAll()`. Example:
4854
*
55+
* @code
4956
* vIRQ_DisableAll(); counter = 1; IRQs are now disabled.
5057
* some_function(); counter = 2, then counter = 1; IRQs are still disabled.
5158
* vIRQ_EnableAll(); counter = 0; IRQs are now re-enabled.
59+
* @endcode
5260
*
53-
* where some_function() also has a disable/enable pair. */
61+
* where `some_function()` also has a disable/enable pair. */
5462
UVISOR_EXTERN void vIRQ_DisableAll(void);
5563

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

6472
/** Reset the device.
@@ -67,4 +75,6 @@ UVISOR_EXTERN void vIRQ_EnableAll(void);
6775
*/
6876
UVISOR_EXTERN void vIRQ_SystemReset(TResetReason reason);
6977

78+
/** @} */
79+
7080
#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)