mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-16 02:10:23 -04:00
Introduce syscalls to change preloaded app
Introduce syscalls: - TK1_SYSCALL_PRELOAD_STORE - TK1_SYSCALL_PRELOAD_STORE_FIN - TK1_SYSCALL_PRELOAD_DELETE - TK1_SYSCALL_REG_MGMT = 11 Change preload_store_finalize() not to take USS arg. Unused for preloaded apps.
This commit is contained in:
parent
970668a47b
commit
dd147657a4
4 changed files with 28 additions and 7 deletions
|
@ -75,8 +75,7 @@ int preload_store(struct partition_table *part_table, uint32_t offset,
|
||||||
return flash_write_data(address, data, size);
|
return flash_write_data(address, data, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int preload_store_finalize(struct partition_table *part_table, bool use_uss,
|
int preload_store_finalize(struct partition_table *part_table, size_t app_size, uint8_t to_slot)
|
||||||
uint8_t *uss, size_t app_size, uint8_t to_slot)
|
|
||||||
{
|
{
|
||||||
/* Check if we are allowed to store */
|
/* Check if we are allowed to store */
|
||||||
if (!mgmt_app_authenticate(&part_table->mgmt_app_data)) {
|
if (!mgmt_app_authenticate(&part_table->mgmt_app_data)) {
|
||||||
|
@ -88,8 +87,6 @@ int preload_store_finalize(struct partition_table *part_table, bool use_uss,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Maybe add the uss fields
|
|
||||||
|
|
||||||
if (app_size == 0 || app_size > SIZE_PRE_LOADED_APP) {
|
if (app_size == 0 || app_size > SIZE_PRE_LOADED_APP) {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,7 @@ bool preload_check_valid_app(struct partition_table *part_table,
|
||||||
int preload_load(struct partition_table *part_table, uint8_t from_slot);
|
int preload_load(struct partition_table *part_table, uint8_t from_slot);
|
||||||
int preload_store(struct partition_table *part_table, uint32_t offset,
|
int preload_store(struct partition_table *part_table, uint32_t offset,
|
||||||
uint8_t *data, size_t size, uint8_t to_slot);
|
uint8_t *data, size_t size, uint8_t to_slot);
|
||||||
int preload_store_finalize(struct partition_table *part_table, bool use_uss,
|
int preload_store_finalize(struct partition_table *part_table, size_t app_size, uint8_t to_slot);
|
||||||
uint8_t *uss, size_t app_size, uint8_t to_slot);
|
|
||||||
int preload_delete(struct partition_table *part_table, uint8_t slot);
|
int preload_delete(struct partition_table *part_table, uint8_t slot);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
#include <tkey/led.h>
|
#include <tkey/led.h>
|
||||||
#include <tkey/lib.h>
|
#include <tkey/lib.h>
|
||||||
|
|
||||||
|
#include "mgmt_app.h"
|
||||||
#include "partition_table.h"
|
#include "partition_table.h"
|
||||||
|
#include "preload_app.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
|
|
||||||
#include "../tk1/resetinfo.h"
|
#include "../tk1/resetinfo.h"
|
||||||
|
@ -71,6 +73,25 @@ int32_t syscall_handler(uint32_t number, uint32_t arg1, uint32_t arg2,
|
||||||
// first word. Serial is kept secret to the device
|
// first word. Serial is kept secret to the device
|
||||||
// app.
|
// app.
|
||||||
return udi[0];
|
return udi[0];
|
||||||
|
|
||||||
|
case TK1_SYSCALL_PRELOAD_DELETE:
|
||||||
|
return preload_delete(&part_table, 1);
|
||||||
|
|
||||||
|
case TK1_SYSCALL_PRELOAD_STORE:
|
||||||
|
// arg1 offset
|
||||||
|
// arg2 data
|
||||||
|
// arg3 size
|
||||||
|
// always using slot 1
|
||||||
|
return preload_store(&part_table, arg1, (uint8_t *)arg2, arg3, 1);
|
||||||
|
|
||||||
|
case TK1_SYSCALL_PRELOAD_STORE_FIN:
|
||||||
|
// arg1 app_size
|
||||||
|
// always using slot 1
|
||||||
|
return preload_store_finalize(&part_table, arg1, 1);
|
||||||
|
|
||||||
|
case TK1_SYSCALL_REG_MGMT:
|
||||||
|
return mgmt_app_register(&part_table);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(1 == 2);
|
assert(1 == 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,11 @@ enum syscall_num {
|
||||||
TK1_SYSCALL_READ_DATA = 5,
|
TK1_SYSCALL_READ_DATA = 5,
|
||||||
TK1_SYSCALL_ERASE_DATA = 6,
|
TK1_SYSCALL_ERASE_DATA = 6,
|
||||||
TK1_SYSCALL_GET_VIDPID = 7,
|
TK1_SYSCALL_GET_VIDPID = 7,
|
||||||
TK1_SYSCALL_SET_LED = 10,
|
TK1_SYSCALL_PRELOAD_STORE = 8,
|
||||||
|
TK1_SYSCALL_PRELOAD_STORE_FIN = 9,
|
||||||
|
TK1_SYSCALL_PRELOAD_DELETE = 10,
|
||||||
|
TK1_SYSCALL_REG_MGMT = 11,
|
||||||
|
TK1_SYSCALL_SET_LED = 30,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue