47static struct tz_api tz_api;
48static bool initialized;
49static volatile unsigned poll_wait_counter;
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) {
67 apip = cmse_check_address_range(apip,
sizeof(*apip), CMSE_NONSECURE);
68 if(apip == NULL || apip->request_poll == NULL) {
72 if(cmse_check_address_range(apip->request_poll,
sizeof(apip->request_poll),
73 CMSE_NONSECURE) == NULL) {
77 memcpy(&tz_api, apip,
sizeof(tz_api));
81 for(
size_t i = 0; autostart_processes[i] != NULL; i++) {
82 process_post(autostart_processes[i], trustzone_init_event, NULL);
89CC_TRUSTZONE_SECURE_CALL
bool
92 static bool is_poll_running;
94 if(!initialized || is_poll_running) {
97 is_poll_running =
true;
101 if(event_count > 0) {
102 LOG_DBG(
"Processing %u event%s at %lu\n", event_count,
103 event_count == 1 ?
"" :
"s", (
unsigned long)
clock_time());
106 while(event_count-- > 0) {
111 is_poll_running =
false;
112 poll_wait_counter = 0;
117CC_TRUSTZONE_SECURE_CALL
void
120 printf(
"n> %s\n", text);
129 if(poll_wait_counter > 0) {
134 poll_wait_counter = 128;
135 return tz_api.request_poll();
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.
CC_TRUSTZONE_SECURE_CALL void tz_api_println(const char *text)
Print the specified message via the secure world.
bool tz_api_request_poll_from_ns(void)
Request poll from normal world.
CC_TRUSTZONE_SECURE_CALL bool tz_api_init(struct tz_api *apip)
Initialize the TrustZone API.
CC_TRUSTZONE_SECURE_CALL bool tz_api_poll(void)
Poll the secure world and process all events in the queue.
Header file for the logging system.