Skip to content

Commit afb2bd8

Browse files
authored
Merge pull request #403 from niklas-arm/feature/nvic_ownership
First box to call NVIC owns the interrupt
2 parents 6c0f746 + ae6c8d7 commit afb2bd8

File tree

10 files changed

+116
-159
lines changed

10 files changed

+116
-159
lines changed

api/inc/vmpu_exports.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
* terminating NULL. */
2828
#define UVISOR_MAX_BOX_NAMESPACE_LENGTH 37
2929

30+
/** Invalid box id for use in marking objects with invalid ownership. */
31+
#define UVISOR_BOX_ID_INVALID ((uint8_t) -1)
32+
3033
/* supervisor user access modes */
3134
#define UVISOR_TACL_UEXECUTE 0x0001UL
3235
#define UVISOR_TACL_UWRITE 0x0002UL

core/system/inc/page_allocator_config.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444

4545
/* The page box_id is the box id which is 8-bit large. */
4646
typedef uint8_t page_owner_t;
47-
/* Define a unused value for the page table. */
48-
#define UVISOR_PAGE_UNUSED ((page_owner_t) (-1))
4947
/* Contains the total number of available pages. */
5048
extern uint8_t g_page_count_total;
5149
/* Contains the shift of the page owner mask. */

core/system/inc/unvic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern uint32_t unvic_irq_priority_get(uint32_t irqn);
5252
extern int unvic_irq_level_get(void);
5353
extern int unvic_default(uint32_t isr_id);
5454

55-
extern void unvic_init(void);
55+
extern void unvic_init(uint32_t const * const user_vtor);
5656

5757
/** Perform a context switch-in as a result of an interrupt request.
5858
*

core/system/src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "unvic.h"
2222
#include "vmpu.h"
2323

24-
UVISOR_NOINLINE void uvisor_init_pre(void)
24+
UVISOR_NOINLINE void uvisor_init_pre(uint32_t const * const user_vtor)
2525
{
2626
/* Reset the uVisor own BSS section. */
2727
memset(&__bss_start__, 0, VMPU_REGION_SIZE(&__bss_start__, &__bss_end__));
@@ -30,7 +30,7 @@ UVISOR_NOINLINE void uvisor_init_pre(void)
3030
memcpy(&__data_start__, &__data_start_src__, VMPU_REGION_SIZE(&__data_start__, &__data_end__));
3131

3232
/* Initialize the unprivileged NVIC module. */
33-
unvic_init();
33+
unvic_init(user_vtor);
3434

3535
/* Initialize the debugging features. */
3636
DEBUG_INIT();
@@ -135,7 +135,7 @@ void main_entry(void)
135135
}
136136

137137
/* Early uVisor initialization. */
138-
uvisor_init_pre();
138+
uvisor_init_pre((uint32_t *) SCB->VTOR);
139139

140140
/* Run basic sanity checks. */
141141
if (vmpu_init_pre() == 0) {

core/system/src/page_allocator.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* SVC call, which automagically serializes access to it. */
3737
#define UVISOR_PAGE_ALLOCATOR_MUTEX_AQUIRE {}
3838
#define UVISOR_PAGE_ALLOCATOR_MUTEX_RELEASE {}
39+
#define UVISOR_PAGE_UNUSED UVISOR_BOX_ID_INVALID
3940

4041
#endif /* defined(UVISOR_PRESENT) && (UVISOR_PRESENT == 1) */
4142

@@ -73,12 +74,6 @@ uint8_t page_allocator_get_page_from_address(uint32_t address)
7374

7475
void page_allocator_init(void * const heap_start, void * const heap_end, const uint32_t * const page_size)
7576
{
76-
/* Make sure the UVISOR_PAGE_UNUSED is definitely NOT a valid box id. */
77-
if (vmpu_is_box_id_valid(UVISOR_PAGE_UNUSED)) {
78-
HALT_ERROR(SANITY_CHECK_FAILED,
79-
"UVISOR_PAGE_UNUSED (%u) must not be a valid box id!\n",
80-
UVISOR_PAGE_UNUSED);
81-
}
8277
if (!page_size || !vmpu_public_flash_addr((uint32_t) page_size)) {
8378
HALT_ERROR(SANITY_CHECK_FAILED,
8479
"Page size pointer (0x%08x) is not in flash memory.\n",

core/system/src/page_allocator_faults.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
*/
1717

1818
#include <uvisor.h>
19+
#include "api/inc/vmpu_exports.h"
1920
#include "page_allocator.h"
2021
#include "page_allocator_faults.h"
2122
#include "page_allocator_config.h"
2223
#include "context.h"
2324

2425
/* Maps the number of faults to a page. */
2526
uint32_t g_page_fault_table[UVISOR_PAGE_MAX_COUNT];
27+
#define UVISOR_PAGE_UNUSED UVISOR_BOX_ID_INVALID
2628

2729
void page_allocator_reset_faults(uint8_t page)
2830
{

0 commit comments

Comments
 (0)