47static struct tz_api tz_api;
48static bool initialized;
49static volatile bool ns_poll_pending;
53#define LOG_MODULE "TZAPI"
54#define LOG_LEVEL LOG_LEVEL_INFO
56process_event_t trustzone_init_event;
58CC_TRUSTZONE_SECURE_CALL
bool
61 if(initialized || apip == NULL) {
65 apip = cmse_check_address_range(apip,
sizeof(*apip), CMSE_NONSECURE);
66 if(apip == NULL || apip->request_poll == NULL) {
70 ns_poll_t poll_fn = cmse_nsfptr_create(apip->request_poll);
71 if(!cmse_is_nsfptr(poll_fn)) {
76 tz_api.request_poll = poll_fn;
80 for(
size_t i = 0; autostart_processes[i] != NULL; i++) {
81 process_post(autostart_processes[i], trustzone_init_event, NULL);
87CC_TRUSTZONE_SECURE_CALL
bool
90 static bool is_poll_running;
100 if(__get_IPSR() != 0) {
103 if(!initialized || is_poll_running) {
106 is_poll_running =
true;
114 ns_poll_pending =
false;
118 if(event_count > 0) {
119 LOG_DBG(
"Processing %u event%s at %" CLOCK_PRI
"\n", event_count,
123 while(event_count-- > 0) {
128 is_poll_running =
false;
133#define TZ_API_PRINTLN_MAX_LEN 256
135CC_TRUSTZONE_SECURE_CALL
void
138 if(len > TZ_API_PRINTLN_MAX_LEN) {
139 len = TZ_API_PRINTLN_MAX_LEN;
141 if(text == NULL || len == 0 ||
142 cmse_check_address_range((
void *)text, len,
143 CMSE_NONSECURE) == NULL) {
146 printf(
"n> %.*s\n", (
int)len, text);
149__attribute__((weak))
void
150tz_arch_signal_ns(
void)
160 ns_poll_pending =
true;
Header file for module for automatically starting and exiting a list of processes.
clock_time_t clock_time(void)
Get the current clock time.
void watchdog_periodic(void)
Writes the WDT clear sequence.
process_num_events_t process_run(void)
Run the system once - call poll handlers and process one event.
int process_post(struct process *p, process_event_t ev, process_data_t data)
Post an asynchronous event.
process_event_t process_alloc_event(void)
Allocate a global event number.
process_num_events_t process_nevents(void)
Number of events waiting to be processed.
void tz_api_println(const char *text, size_t len)
Print the specified message via the secure world.
bool tz_api_request_ns_poll(void)
Mark the normal world as needing another poll cycle.
bool tz_api_init(struct tz_api *apip)
Initialize the TrustZone API.
bool tz_api_poll(void)
Poll the secure world and process all events in the queue.
Header file for the logging system.