mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-06 05:34:25 -04:00
fw: Add syscall TK1_SYSCALL_GET_APP_DATA
Add a new syscall to enable an app to get the data left for it by the previous app in chain. - Change testloadapp to leave some data for the next app to read. - Call system call with: uint8_t next_app_data[RESET_DATA_SIZE]; syscall(TK1_SYSCALL_GET_APP_DATA, (uint32_t)next_app_data, 0, 0);
This commit is contained in:
parent
14e4cd09c9
commit
e935195846
8 changed files with 51 additions and 11 deletions
|
@ -154,7 +154,10 @@ void reset_from_client(void)
|
|||
|
||||
rst.type = START_CLIENT;
|
||||
|
||||
syscall(TK1_SYSCALL_RESET, (uint32_t)&rst, 0, 0);
|
||||
// Give the next in chain something to look at.
|
||||
memset(rst.next_app_data, 17, sizeof(rst.next_app_data));
|
||||
|
||||
syscall(TK1_SYSCALL_RESET, (uint32_t)&rst, sizeof(rst.next_app_data), 0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
|
|
@ -444,7 +444,19 @@ static enum state start_where(struct context *ctx)
|
|||
{
|
||||
assert(ctx != NULL);
|
||||
|
||||
// Where do we start? Read resetinfo 'startfrom'
|
||||
debug_puts("resetinfo->type: ");
|
||||
debug_putinthex(resetinfo->type);
|
||||
debug_lf();
|
||||
|
||||
debug_puts(" ->app_digest: \n");
|
||||
debug_hexdump(resetinfo->app_digest, RESET_DIGEST_SIZE);
|
||||
debug_lf();
|
||||
|
||||
debug_puts(" ->next_app_data: \n");
|
||||
debug_hexdump(resetinfo->next_app_data, RESET_DATA_SIZE);
|
||||
debug_lf();
|
||||
|
||||
// Where do we start?
|
||||
switch (resetinfo->type) {
|
||||
case START_DEFAULT:
|
||||
// fallthrough
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
//
|
||||
// To update this, compute the BLAKE2s digest of the app.bin
|
||||
static const uint8_t allowed_app_digest[32] = {
|
||||
0xf8, 0x90, 0x34, 0x31, 0xe0, 0xed, 0xab, 0x8b, 0x91, 0xe5, 0x63,
|
||||
0xe6, 0xea, 0x6a, 0x49, 0xe6, 0x53, 0x1e, 0xc7, 0x47, 0xca, 0x2f,
|
||||
0x2b, 0x8f, 0xf3, 0x5e, 0x67, 0x13, 0x0f, 0xfa, 0x93, 0x36,
|
||||
0x85, 0x29, 0xe3, 0x25, 0xf5, 0x8d, 0x53, 0x5f, 0xe1, 0x2a, 0x77,
|
||||
0x92, 0xe7, 0xdc, 0x4b, 0x4d, 0x1, 0x85, 0x17, 0xca, 0xfd, 0x54,
|
||||
0x83, 0xb3, 0xbb, 0x28, 0x4f, 0xa1, 0x98, 0x5f, 0x9e, 0x56,
|
||||
};
|
||||
|
||||
static uint8_t current_app_digest[32];
|
||||
|
|
|
@ -38,3 +38,21 @@ int reset(struct reset *userreset, size_t nextlen)
|
|||
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
int reset_data(uint8_t *next_app_data)
|
||||
{
|
||||
if ((uint32_t)next_app_data < TK1_RAM_BASE ||
|
||||
(uint32_t)next_app_data >= TK1_RAM_BASE + TK1_RAM_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((uint32_t)next_app_data + RESET_DATA_SIZE >
|
||||
TK1_RAM_BASE + TK1_RAM_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(next_app_data, (void *)resetinfo->next_app_data,
|
||||
RESET_DATA_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#define TK1_MMIO_RESETINFO_BASE 0xd0000f00
|
||||
#define TK1_MMIO_RESETINFO_SIZE 0x100
|
||||
#define RESET_DIGEST_SIZE 32
|
||||
#define RESET_DATA_SIZE 220
|
||||
|
||||
enum reset_start {
|
||||
START_DEFAULT = 0, // Probably cold boot
|
||||
|
@ -21,10 +23,11 @@ enum reset_start {
|
|||
};
|
||||
|
||||
struct reset {
|
||||
uint32_t type; // Reset type
|
||||
uint8_t app_digest[32]; // Program digest
|
||||
uint8_t next_app_data[220]; // Data to leave around for next app
|
||||
enum reset_start type;
|
||||
uint8_t app_digest[RESET_DIGEST_SIZE];
|
||||
uint8_t next_app_data[RESET_DATA_SIZE];
|
||||
};
|
||||
|
||||
int reset(struct reset *userreset, size_t nextlen);
|
||||
int reset_data(uint8_t *next_app_data);
|
||||
#endif
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
|
||||
#include "partition_table.h"
|
||||
#include "preload_app.h"
|
||||
#include "reset.h"
|
||||
#include "storage.h"
|
||||
|
||||
#include "../tk1/reset.h"
|
||||
#include "../tk1/syscall_num.h"
|
||||
#include "syscall_num.h"
|
||||
|
||||
// clang-format off
|
||||
static volatile uint32_t *udi = (volatile uint32_t *)TK1_MMIO_TK1_UDI_FIRST;
|
||||
|
@ -100,6 +99,10 @@ int32_t syscall_handler(uint32_t number, uint32_t arg1, uint32_t arg2,
|
|||
case TK1_SYSCALL_STATUS:
|
||||
return part_get_status();
|
||||
|
||||
case TK1_SYSCALL_GET_APP_DATA:
|
||||
// arg1 next_app_data
|
||||
return reset_data((uint8_t *)arg1);
|
||||
|
||||
default:
|
||||
assert(1 == 2);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ enum syscall_num {
|
|||
TK1_SYSCALL_PRELOAD_GET_DIGSIG = 11,
|
||||
TK1_SYSCALL_REG_MGMT = 12,
|
||||
TK1_SYSCALL_STATUS = 13,
|
||||
TK1_SYSCALL_GET_APP_DATA = 14,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue