- make-uefi-iso.sh: UEFI ISO image builder - test_boot.S, test_boot.ld: test boot assembly and linker script - eim_config.toml: EIM (External Interface Module) configuration - edk2-ovmf RPM for UEFI firmware - GAP_ANALYSIS_PIKEOS_PARITY.md: PikeOS parity gap analysis
68 lines
2.1 KiB
C
68 lines
2.1 KiB
C
/*
|
|
* UniversalisOS Microkernel — TrustZone Abstraction
|
|
* ARMv8-M TrustZone for Secure/Non-Secure world isolation.
|
|
*/
|
|
#ifndef UOS_TZ_H
|
|
#define UOS_TZ_H
|
|
|
|
#include "uos_types.h"
|
|
|
|
/* Region config — always available (used by both TZ and non-TZ) */
|
|
typedef struct {
|
|
uint32_t sau_regions[2];
|
|
uint32_t mpu_regions[4];
|
|
} uos_tz_region_config_t;
|
|
|
|
#if UOS_HAS_TZ
|
|
|
|
/* SAU registers */
|
|
#define UOS_TZ_SAU_CTRL (*(volatile uint32_t*)0xE000EDD0)
|
|
#define UOS_TZ_SAU_RNR (*(volatile uint32_t*)0xE000EDD8)
|
|
#define UOS_TZ_SAU_RBAR (*(volatile uint32_t*)0xE000EDDC)
|
|
#define UOS_TZ_SAU_RLAR (*(volatile uint32_t*)0xE000EDE0)
|
|
|
|
/* SAU control */
|
|
#define UOS_TZ_SAU_ENABLE (1u << 0)
|
|
#define UOS_TZ_SAU_ALLNS (1u << 1)
|
|
|
|
/* Region attributes */
|
|
#define UOS_TZ_REGION_S 0x00
|
|
#define UOS_TZ_REGION_NS 0x01
|
|
#define UOS_TZ_REGION_NSC 0x03
|
|
|
|
/* SecureFault registers */
|
|
#define UOS_TZ_SFSR (*(volatile uint32_t*)0xEDE00000)
|
|
#define UOS_TZ_SFAR (*(volatile uint32_t*)0xEDE00004)
|
|
|
|
/* Security state */
|
|
typedef enum { UOS_TZ_SECURE = 0, UOS_TZ_NON_SECURE = 1 } uos_tz_state_t;
|
|
|
|
UOS_INLINE uos_tz_state_t uos_tz_get_state(void) {
|
|
uint32_t c;
|
|
__asm__ volatile("mrs %0, control" : "=r"(c));
|
|
return (c & 1) ? UOS_TZ_NON_SECURE : UOS_TZ_SECURE;
|
|
}
|
|
|
|
void uos_tz_sau_init(void);
|
|
void uos_tz_sau_set_region(uint32_t num, uint32_t base, uint32_t limit, uint32_t attr);
|
|
void uos_tz_apply_regions(const uos_tz_region_config_t* cfg);
|
|
void uos_tz_irq_set_secure(uint32_t irq, int secure);
|
|
|
|
UOS_INLINE void uos_tz_sau_enable(void) {
|
|
UOS_TZ_SAU_CTRL |= UOS_TZ_SAU_ENABLE;
|
|
__asm__ volatile("dsb\nisb");
|
|
}
|
|
|
|
UOS_INLINE void uos_tz_sg(void) { __asm__ volatile("sg"); }
|
|
|
|
#else /* No TrustZone — no-ops */
|
|
|
|
UOS_INLINE int uos_tz_get_state(void) { return 0; }
|
|
UOS_INLINE void uos_tz_sau_init(void) {}
|
|
UOS_INLINE void uos_tz_sau_set_region(uint32_t r, uint32_t b, uint32_t l, uint32_t a) { (void)r;(void)b;(void)l;(void)a; }
|
|
UOS_INLINE void uos_tz_sg(void) {}
|
|
UOS_INLINE void uos_tz_irq_set_secure(uint32_t r, int s) { (void)r;(void)s; }
|
|
UOS_INLINE void uos_tz_apply_regions(const uos_tz_region_config_t* c) { (void)c; }
|
|
|
|
#endif /* UOS_HAS_TZ */
|
|
#endif /* UOS_TZ_H */
|