summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Bray <ncbray@google.com>2019-05-08 12:44:15 -0700
committerNick Bray <ncbray@google.com>2019-05-08 12:49:17 -0700
commit3f208bb7680720613d0945f6c53fd1925e673ba0 (patch)
tree766b3ba19cd5c6afd1047d228a4bd7e9cd082af8
parentfd9f076e27f70c7a2e1a16301adaa5ddcde10ce0 (diff)
downloadnxp-3f208bb7680720613d0945f6c53fd1925e673ba0.tar.gz
[app][hwcrypto] Clean up libc usage
uint and addr_t are not standard types. The printf format for 64-bit values is not guarenteed - use PRI macros. Move reg.h to lk/reg.h. Bug: 110161494 Change-Id: Idcdd7fe6227349250277a2e147cbef8eee25a8e0
-rw-r--r--app/hwcrypto/caam.c2
-rw-r--r--app/hwcrypto/caam.h3
-rw-r--r--app/hwcrypto/hwkey_srv.c8
-rw-r--r--app/hwcrypto/hwkey_srv_priv.h2
-rw-r--r--app/hwcrypto/hwrng_srv.c6
-rw-r--r--app/hwcrypto/main.c7
6 files changed, 18 insertions, 10 deletions
diff --git a/app/hwcrypto/caam.c b/app/hwcrypto/caam.c
index 59ad770..eb11560 100644
--- a/app/hwcrypto/caam.c
+++ b/app/hwcrypto/caam.c
@@ -27,10 +27,10 @@
*/
#include <assert.h>
+#include <lk/reg.h>
#include <malloc.h>
#include <openssl/digest.h>
#include <openssl/hkdf.h>
-#include <reg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/app/hwcrypto/caam.h b/app/hwcrypto/caam.h
index c52a355..a2fc1d7 100644
--- a/app/hwcrypto/caam.h
+++ b/app/hwcrypto/caam.h
@@ -29,6 +29,9 @@
#ifndef _CAAM_H
#define _CAAM_H
+#include <stdbool.h>
+#include <stdint.h>
+
#define CAAM_MMIO_ID 8
#define CAAM_SEC_RAM_MMIO_ID 9
#define CCM_MMIO_ID 10
diff --git a/app/hwcrypto/hwkey_srv.c b/app/hwcrypto/hwkey_srv.c
index 4abb293..8245267 100644
--- a/app/hwcrypto/hwkey_srv.c
+++ b/app/hwcrypto/hwkey_srv.c
@@ -58,7 +58,7 @@ static uint8_t key_data[HWKEY_MAX_PAYLOAD_SIZE]
static uint8_t req_data[HWKEY_MAX_PAYLOAD_SIZE + 1]
__attribute__((aligned(HWKEY_MAX_PAYLOAD_SIZE)));
-static uint key_slot_cnt;
+static unsigned int key_slot_cnt;
static const struct hwkey_keyslot* key_slots;
#if WITH_HWCRYPTO_UNITTEST
@@ -118,14 +118,14 @@ static int hwkey_send_rsp(struct hwkey_chan_ctx* ctx,
static uint32_t _handle_slots(struct hwkey_chan_ctx* ctx,
const char* slot_id,
const struct hwkey_keyslot* slots,
- uint slot_cnt,
+ unsigned int slot_cnt,
uint8_t* kbuf,
size_t kbuf_len,
size_t* klen) {
if (!slots)
return HWKEY_ERR_NOT_FOUND;
- for (uint i = 0; i < slot_cnt; i++, slots++) {
+ for (unsigned int i = 0; i < slot_cnt; i++, slots++) {
/* check key id */
if (strcmp(slots->key_id, slot_id))
continue;
@@ -312,7 +312,7 @@ static void hwkey_port_handler(const uevent_t* ev, void* priv) {
/*
* Install Key slot provider
*/
-void hwkey_install_keys(const struct hwkey_keyslot* keys, uint kcnt) {
+void hwkey_install_keys(const struct hwkey_keyslot* keys, unsigned int kcnt) {
assert(key_slots == NULL);
assert(key_slot_cnt == 0);
assert(keys && kcnt);
diff --git a/app/hwcrypto/hwkey_srv_priv.h b/app/hwcrypto/hwkey_srv_priv.h
index ff974cd..5de94cd 100644
--- a/app/hwcrypto/hwkey_srv_priv.h
+++ b/app/hwcrypto/hwkey_srv_priv.h
@@ -33,7 +33,7 @@ __BEGIN_CDECLS
void hwkey_init_srv_provider(void);
-void hwkey_install_keys(const struct hwkey_keyslot* keys, uint kcnt);
+void hwkey_install_keys(const struct hwkey_keyslot* keys, unsigned int kcnt);
int hwkey_start_service(void);
diff --git a/app/hwcrypto/hwrng_srv.c b/app/hwcrypto/hwrng_srv.c
index accd7a2..28d2334 100644
--- a/app/hwcrypto/hwrng_srv.c
+++ b/app/hwcrypto/hwrng_srv.c
@@ -15,7 +15,9 @@
*/
#include <assert.h>
+#include <inttypes.h>
#include <lk/list.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -61,12 +63,12 @@ static struct list_node hwrng_req_list = LIST_INITIAL_VALUE(hwrng_req_list);
* Hexdump content of memory region
*/
static void _hexdump8(const void* ptr, size_t len) {
- addr_t address = (addr_t)ptr;
+ uintptr_t address = (uintptr_t)ptr;
size_t count;
size_t i;
for (count = 0; count < len; count += 16) {
- fprintf(stderr, "0x%08lx: ", address);
+ fprintf(stderr, "0x%08" PRIxPTR ": ", address);
for (i = 0; i < MIN(len - count, 16); i++) {
fprintf(stderr, "0x%02hhx ", *(const uint8_t*)(address + i));
}
diff --git a/app/hwcrypto/main.c b/app/hwcrypto/main.c
index 392f91f..7d91f1d 100644
--- a/app/hwcrypto/main.c
+++ b/app/hwcrypto/main.c
@@ -15,6 +15,9 @@
*/
#include <assert.h>
+#include <inttypes.h>
+#include <lk/macros.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <trusty_ipc.h>
@@ -33,12 +36,12 @@
* Hexdump content of memory region
*/
void _hexdump8(const void* ptr, size_t len) {
- addr_t address = (addr_t)ptr;
+ uintptr_t address = (uintptr_t)ptr;
size_t count;
size_t i;
for (count = 0; count < len; count += 16) {
- fprintf(stderr, "0x%08lx: ", address);
+ fprintf(stderr, "0x%08" PRIxPTR ": ", address);
for (i = 0; i < MIN(len - count, 16); i++) {
fprintf(stderr, "0x%02hhx ", *(const uint8_t*)(address + i));
}