Skip to content

Update uVisor to v0.28.1 #4295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions features/FEATURE_UVISOR/AUTHORS.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
597 Alessandro Angelino
592 Milosch Meriac
554 Alessandro Angelino
105 Jaeden Amero
65 Niklas Hauser
144 Jaeden Amero
80 Niklas Hauser
5 Irit Arkin
3 JaredCJR
3 AnotherButler
Expand Down
2 changes: 1 addition & 1 deletion features/FEATURE_UVISOR/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.27.0-23-g8231ae897dadbb1c3eeb79ae2103d308d28c7e14
v0.28.1
37 changes: 0 additions & 37 deletions features/FEATURE_UVISOR/includes/uvisor-lib/rtx/process_malloc.h

This file was deleted.

12 changes: 12 additions & 0 deletions features/FEATURE_UVISOR/includes/uvisor-lib/rtx/secure_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ void * secure_malloc(
SecureAllocator allocator,
size_t size);

/** Drop-in for `aligned_alloc`. */
void * secure_aligned_alloc(
SecureAllocator allocator,
size_t alignment,
size_t size);

/** Drop-in for `calloc`. */
void * secure_calloc(
SecureAllocator allocator,
size_t nmemb,
size_t size);

/** Drop-in for `realloc`. */
void * secure_realloc(
SecureAllocator allocator,
Expand Down
1 change: 0 additions & 1 deletion features/FEATURE_UVISOR/includes/uvisor-lib/uvisor-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

/* The uVisor API main header file will use the above definitions. */
#include "uvisor/api/inc/uvisor-lib.h"
#include "uvisor-lib/rtx/process_malloc.h"
#include "uvisor-lib/rtx/rtx_box_index.h"
#include "uvisor-lib/rtx/secure_allocator.h"

Expand Down
17 changes: 12 additions & 5 deletions features/FEATURE_UVISOR/includes/uvisor/api/inc/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

#include "rt_OsEventObserver.h"
#include "api/inc/uvisor_exports.h"
#include "api/inc/unvic_exports.h"
#include "api/inc/virq_exports.h"
#include "api/inc/debug_exports.h"
#include "api/inc/halt_exports.h"
#include "api/inc/pool_queue_exports.h"
#include "api/inc/page_allocator_exports.h"
#include "api/inc/uvisor_spinlock_exports.h"
#include <stdint.h>

#define UVISOR_API_MAGIC 0x5C9411B4
Expand All @@ -37,7 +38,7 @@ typedef struct {
uint32_t magic;
uint32_t (*get_version)(uint32_t);

void (*init)(void);
void (*init)(uint32_t caller);

void (*irq_enable)(uint32_t irqn);
void (*irq_disable)(uint32_t irqn);
Expand All @@ -60,17 +61,23 @@ typedef struct {

void (*debug_init)(const TUvisorDebugDriver * const driver);
void (*error)(THaltUserError reason);
void (*start)(void);
void (*vmpu_mem_invalidate)(void);

int (*pool_init)(uvisor_pool_t *, void *, size_t, size_t, int);
int (*pool_queue_init)(uvisor_pool_queue_t *, uvisor_pool_t *, void *, size_t, size_t, int);
uvisor_pool_slot_t (*pool_allocate)(uvisor_pool_t *, uint32_t);
int (*pool_init)(uvisor_pool_t *, void *, size_t, size_t);
int (*pool_queue_init)(uvisor_pool_queue_t *, uvisor_pool_t *, void *, size_t, size_t);
uvisor_pool_slot_t (*pool_allocate)(uvisor_pool_t *);
void (*pool_queue_enqueue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_free)(uvisor_pool_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_queue_dequeue)(uvisor_pool_queue_t *, uvisor_pool_slot_t);
uvisor_pool_slot_t (*pool_queue_dequeue_first)(uvisor_pool_queue_t *);
uvisor_pool_slot_t (*pool_queue_find_first)(uvisor_pool_queue_t *, TQueryFN_Ptr, void *);

void (*spin_init)(UvisorSpinlock * spinlock);
bool (*spin_trylock)(UvisorSpinlock * spinlock);
void (*spin_lock)(UvisorSpinlock * spinlock);
void (*spin_unlock)(UvisorSpinlock * spinlock);

OsEventObserver os_event_observer;
} UVISOR_PACKED UvisorApi;

Expand Down
28 changes: 17 additions & 11 deletions features/FEATURE_UVISOR/includes/uvisor/api/inc/box_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
#include "api/inc/rpc_exports.h"
#include <stddef.h>
#include <stdint.h>
#include <sys/reent.h>

UVISOR_EXTERN const uint32_t __uvisor_mode;
UVISOR_EXTERN void const * const public_box_cfg_ptr;

typedef struct {
void (*function)(const void *);
size_t priority;
size_t stack_size;
} uvisor_box_main_t;
/* All pointers in the box index need to be 4-byte aligned.
* We therefore also need to round up all sizes to 4-byte multiples to
* provide the space to be able to align the pointers to 4-bytes. */
#define __UVISOR_BOX_ROUND_4(size) \
(((size) + 3UL) & ~3UL)

#define UVISOR_DISABLED 0
#define UVISOR_PERMISSIVE 1
Expand All @@ -53,7 +54,9 @@ typedef struct {
{ \
sizeof(RtxBoxIndex), \
0, \
0, \
sizeof(uvisor_rpc_t), \
sizeof(uvisor_ipc_t), \
0, \
}, \
0, \
Expand Down Expand Up @@ -83,12 +86,13 @@ typedef struct {
UVISOR_STACK_SIZE_ROUND( \
( \
(UVISOR_MIN_STACK(stack_size) + \
(context_size) + \
(__uvisor_box_heapsize) + \
sizeof(RtxBoxIndex) + \
sizeof(uvisor_rpc_outgoing_message_queue_t) + \
sizeof(uvisor_rpc_incoming_message_queue_t) + \
sizeof(uvisor_rpc_fn_group_queue_t) \
__UVISOR_BOX_ROUND_4(context_size) + \
__UVISOR_BOX_ROUND_4(__uvisor_box_heapsize) + \
__UVISOR_BOX_ROUND_4(sizeof(RtxBoxIndex)) + \
__UVISOR_BOX_ROUND_4(sizeof(uvisor_rpc_outgoing_message_queue_t)) + \
__UVISOR_BOX_ROUND_4(sizeof(uvisor_rpc_incoming_message_queue_t)) + \
__UVISOR_BOX_ROUND_4(sizeof(uvisor_rpc_fn_group_queue_t)) + \
__UVISOR_BOX_ROUND_4(sizeof(struct _reent)) \
) \
* 8) \
/ 6)]; \
Expand All @@ -99,7 +103,9 @@ typedef struct {
{ \
sizeof(RtxBoxIndex), \
context_size, \
sizeof(struct _reent), \
sizeof(uvisor_rpc_t), \
sizeof(uvisor_ipc_t), \
__uvisor_box_heapsize, \
}, \
UVISOR_MIN_STACK(stack_size), \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,37 @@
#define __UVISOR_API_NVIC_VIRTUAL_H__

#include "api/inc/interrupts.h"
#include "api/inc/unvic_exports.h"
#include "api/inc/virq_exports.h"

#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
#define NVIC_EnableIRQ vIRQ_EnableIRQ
#define NVIC_DisableIRQ vIRQ_DisableIRQ
#define NVIC_GetPendingIRQ vIRQ_GetPendingIRQ
#define NVIC_SetPendingIRQ vIRQ_SetPendingIRQ
#define NVIC_ClearPendingIRQ vIRQ_ClearPendingIRQ
#define NVIC_GetActive __NVIC_GetActive
#define NVIC_SetPriority vIRQ_SetPriority
#define NVIC_GetPriority vIRQ_GetPriority
#define NVIC_SystemReset() vIRQ_SystemReset(RESET_REASON_NO_REASON)
/* The NVIC APIs are only wrapped on ARMv7-M. */
#if !defined(ARCH_CORE_ARMv8M) && !defined(TARGET_M33)

#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
#define NVIC_EnableIRQ vIRQ_EnableIRQ
#define NVIC_DisableIRQ vIRQ_DisableIRQ
#define NVIC_GetPendingIRQ vIRQ_GetPendingIRQ
#define NVIC_SetPendingIRQ vIRQ_SetPendingIRQ
#define NVIC_ClearPendingIRQ vIRQ_ClearPendingIRQ
#define NVIC_GetActive __NVIC_GetActive
#define NVIC_SetPriority vIRQ_SetPriority
#define NVIC_GetPriority vIRQ_GetPriority
#define NVIC_SystemReset() vIRQ_SystemReset(RESET_REASON_NO_REASON)

#else

#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
#define NVIC_EnableIRQ __NVIC_EnableIRQ
#define NVIC_DisableIRQ __NVIC_DisableIRQ
#define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
#define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
#define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
#define NVIC_GetActive __NVIC_GetActive
#define NVIC_SetPriority __NVIC_SetPriority
#define NVIC_GetPriority __NVIC_GetPriority
#define NVIC_SystemReset() __NVIC_SystemReset()

#endif

#endif /* __UVISOR_API_NVIC_VIRTUAL_H__ */
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,17 @@

#include "api/inc/interrupts.h"

#define NVIC_SetVector vIRQ_SetVector
#define NVIC_GetVector vIRQ_GetVector
/* The NVIC APIs are only wrapped on ARMv7-M. */
#if !defined(ARCH_CORE_ARMv8M) && !defined(TARGET_M33)

#define NVIC_SetVector vIRQ_SetVector
#define NVIC_GetVector vIRQ_GetVector

#else

#define NVIC_SetVector __NVIC_SetVector
#define NVIC_GetVector __NVIC_GetVector

#endif

#endif /* __UVISOR_API_VECTAB_VIRTUAL_H__ */
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ typedef enum {
FAULT_USAGE,
FAULT_HARD,
FAULT_DEBUG,
FAULT_SECURE,
__THALTERROR_MAX /* always keep as the last element of the enum */
} THaltError;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef __UVISOR_API_INTERRUPTS_H__
#define __UVISOR_API_INTERRUPTS_H__

#include "api/inc/unvic_exports.h"
#include "api/inc/virq_exports.h"
#include "api/inc/uvisor_exports.h"
#include "api/inc/api.h"
#include <stdint.h>
Expand Down
76 changes: 76 additions & 0 deletions features/FEATURE_UVISOR/includes/uvisor/api/inc/ipc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright (c) 2017, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __UVISOR_API_IPC_H__
#define __UVISOR_API_IPC_H__

#include "api/inc/ipc_exports.h"
#include "api/inc/uvisor_exports.h"
#include <stdint.h>
#include <stddef.h>


/** Wait for any of the specified IPC operations to complete.
*
* @note This function currently spins, burning through power.
*
* @param[in] wait_tokens a bitfield of tokens to wait on
* @param[out] done_tokens a bitfield which tokens completed
* @param[in] timeout_ms how long to wait (in ms) for an IPC operation
* before returning. 0 means don't wait at all. Any
* other value means wait forever.
* @return 0 on success, non-zero error code otherwise
*/
UVISOR_EXTERN int ipc_waitforany(uint32_t wait_tokens, uint32_t * done_tokens, uint32_t timeout_ms);

/** Wait for all of the specified IPC operations to complete.
*
* @note This function currently spins, burning through power.
*
* @param[in] wait_tokens a bitfield of tokens to wait on
* @param[out] done_tokens a bitfield which tokens completed
* @param[in] timeout_ms how long to wait (in ms) for an IPC operation
* before returning. 0 means don't wait at all.
* Any other value means wait forever.
* @return 0 on success, non-zero error code otherwise
*/
UVISOR_EXTERN int ipc_waitforall(uint32_t wait_tokens, uint32_t * done_tokens, uint32_t timeout_ms);

/** Asynchronously send an IPC message
*
* @note The memory used for sending the message (pointed to by msg) must be
* valid until after the send is complete.
*
* @param[in] desc an IPC descriptor for the message
* @param[in] msg the message to send
*
* @return 0 on success, non-zero error code otherwise
* */
UVISOR_EXTERN int ipc_send(uvisor_ipc_desc_t * desc, const void * msg);

/** Asynchronously receive an IPC message
*
* @note The memory used for receiving the message (pointed to by msg) must be
* valid until after the receive is complete.
*
* @param[inout] desc an IPC descriptor for the message
* @param[out] msg the memory to copy the message to
*
* @return 0 on success, non-zero error code otherwise
*/
UVISOR_EXTERN int ipc_recv(uvisor_ipc_desc_t * desc, void * msg);

#endif /* __UVISOR_API_IPC_H__ */
Loading