Browse Source

Allow secure to be slightly more optional

zvecr 4 years ago
parent
commit
79db2df228
2 changed files with 11 additions and 1 deletions
  1. 5 1
      quantum/xap/xap.c
  2. 6 0
      quantum/xap/xap_handlers.c

+ 5 - 1
quantum/xap/xap.c

@@ -69,7 +69,7 @@ struct __attribute__((packed)) xap_route_t {
 
         // XAP_VALUE / XAP_CONST_MEM
         struct {
-            const void *  const_data;
+            const void   *const_data;
             const uint8_t const_data_len;
         };
     };
@@ -85,6 +85,7 @@ void xap_execute_route(xap_token_t token, const xap_route_t *routes, size_t max_
         xap_route_t route;
         memcpy_P(&route, &routes[id], sizeof(xap_route_t));
 
+#ifdef SECURE_ENABLE
         if (route.flags.is_secure && secure_get_status() != SECURE_UNLOCKED) {
             xap_respond_failure(token, XAP_RESPONSE_FLAG_SECURE_FAILURE);
             return;
@@ -96,6 +97,7 @@ void xap_execute_route(xap_token_t token, const xap_route_t *routes, size_t max_
         //     xap_respond_failure(token, XAP_RESPONSE_FLAG_UNLOCK_IN_PROGRESS);
         //     return;
         // }
+#endif
 
         switch (route.flags.type) {
             case XAP_ROUTE:
@@ -142,6 +144,7 @@ void xap_receive(xap_token_t token, const uint8_t *data, size_t length) {
 }
 
 void xap_event_task(void) {
+#ifdef SECURE_ENABLE
     static secure_status_t last_status = -1;
 
     secure_status_t status = secure_get_status();
@@ -149,4 +152,5 @@ void xap_event_task(void) {
         last_status = status;
         xap_broadcast_secure_status(status);
     }
+#endif
 }

+ 6 - 0
quantum/xap/xap_handlers.c

@@ -16,7 +16,13 @@
 
 #include <quantum.h>
 #include <xap.h>
+
 #include "secure.h"
+#ifndef SECURE_ENABLE
+#    define secure_get_status() SECURE_UNLOCKED
+#    define secure_request_unlock()
+#    define secure_lock()
+#endif
 
 void xap_respond_success(xap_token_t token) {
     xap_send(token, XAP_RESPONSE_FLAG_SUCCESS, NULL, 0);