mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-07-23 23:21:06 -04:00
fw: Introduce reset()
- New function reset.c:reset(). Move code from syscall handler switch to this function. - Rename resetinfo.h to reset.h.
This commit is contained in:
parent
9d1bbffbaa
commit
f373ad3f68
9 changed files with 57 additions and 36 deletions
|
@ -13,13 +13,11 @@
|
|||
#include "preload_app.h"
|
||||
#include "storage.h"
|
||||
|
||||
#include "../tk1/resetinfo.h"
|
||||
#include "../tk1/reset.h"
|
||||
#include "../tk1/syscall_num.h"
|
||||
|
||||
// clang-format off
|
||||
static volatile uint32_t *system_reset = (volatile uint32_t *)TK1_MMIO_TK1_SYSTEM_RESET;
|
||||
static volatile uint32_t *udi = (volatile uint32_t *)TK1_MMIO_TK1_UDI_FIRST;
|
||||
static volatile struct reset *resetinfo = (volatile struct reset *)TK1_MMIO_RESETINFO_BASE;
|
||||
// clang-format on
|
||||
|
||||
extern struct partition_table_storage part_table_storage;
|
||||
|
@ -29,32 +27,9 @@ int32_t syscall_handler(uint32_t number, uint32_t arg1, uint32_t arg2,
|
|||
uint32_t arg3)
|
||||
{
|
||||
switch (number) {
|
||||
case TK1_SYSCALL_RESET: {
|
||||
struct reset *userreset;
|
||||
|
||||
if (arg1 < TK1_RAM_BASE ||
|
||||
arg1 >= TK1_RAM_BASE + TK1_RAM_SIZE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
userreset = (struct reset *)arg1;
|
||||
|
||||
if (arg2 > sizeof(resetinfo->next_app_data)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
(void)memset((void *)resetinfo, 0, sizeof(*resetinfo));
|
||||
resetinfo->type = userreset->type;
|
||||
memcpy((void *)resetinfo->app_digest, userreset->app_digest,
|
||||
32);
|
||||
memcpy((void *)resetinfo->next_app_data,
|
||||
userreset->next_app_data, arg2);
|
||||
*system_reset = 1;
|
||||
|
||||
// Should not be reached.
|
||||
assert(1 == 2);
|
||||
case TK1_SYSCALL_RESET:
|
||||
reset((struct reset *)arg1, (size_t)arg2);
|
||||
break;
|
||||
}
|
||||
|
||||
case TK1_SYSCALL_ALLOC_AREA:
|
||||
if (storage_allocate_area(&part_table_storage) < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue