mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-04-21 15:46:31 -04:00
testapp: Call storage syscalls
Calls - TK1_SYSCALL_ALLOC_AREA - TK1_SYSCALL_WRITE_DATA - TK1_SYSCALL_READ_DATA - TK1_SYSCALL_DEALLOC_AREA
This commit is contained in:
parent
e9ddf29ce9
commit
50966f010d
@ -11,6 +11,7 @@
|
||||
#include <tkey/tk1_mem.h>
|
||||
|
||||
#include "../tk1/proto.h"
|
||||
#include "../tk1/resetinfo.h"
|
||||
#include "../tk1/syscall_num.h"
|
||||
#include "syscall.h"
|
||||
|
||||
@ -128,6 +129,42 @@ int main(void)
|
||||
anyfailed = 1;
|
||||
}
|
||||
|
||||
puts(IO_CDC, "\r\nAllocating storage area...");
|
||||
|
||||
if (syscall(TK1_SYSCALL_ALLOC_AREA, 0, 0, 0) != 0) {
|
||||
failmsg("Failed to allocate storage area");
|
||||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
puts(IO_CDC, "\r\nWriting to storage area...");
|
||||
|
||||
uint8_t out_data[14] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
|
||||
if (syscall(TK1_SYSCALL_WRITE_DATA, 0, (uint32_t)out_data,
|
||||
sizeof(out_data)) != 0) {
|
||||
failmsg("Failed to write to storage area");
|
||||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
puts(IO_CDC, "\r\nReading from storage area...");
|
||||
|
||||
uint8_t in_data[14] = {0};
|
||||
if (syscall(TK1_SYSCALL_READ_DATA, 0, (uint32_t)in_data,
|
||||
sizeof(in_data)) != 0) {
|
||||
failmsg("Failed to write to storage area");
|
||||
}
|
||||
if (!memeq(in_data, out_data, sizeof(in_data))) {
|
||||
failmsg("Failed to read back data from storage area");
|
||||
anyfailed = 1;
|
||||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
puts(IO_CDC, "\r\nDeallocating storage area...");
|
||||
|
||||
if (syscall(TK1_SYSCALL_DEALLOC_AREA, 0, 0, 0) != 0) {
|
||||
failmsg("Failed to deallocate storage area");
|
||||
}
|
||||
puts(IO_CDC, "done.\r\n");
|
||||
|
||||
uint32_t cdi_local[CDI_WORDS];
|
||||
uint32_t cdi_local2[CDI_WORDS];
|
||||
wordcpy_s(cdi_local, CDI_WORDS, (void *)cdi, CDI_WORDS);
|
||||
@ -223,7 +260,10 @@ int main(void)
|
||||
}
|
||||
|
||||
if (in == '+') {
|
||||
syscall(TK1_SYSCALL_RESET, 0, 0, 0);
|
||||
struct reset rst;
|
||||
memset(&rst, 0, sizeof(rst));
|
||||
rst.type = START_DEFAULT;
|
||||
syscall(TK1_SYSCALL_RESET, (uint32_t)&rst, 0, 0);
|
||||
}
|
||||
|
||||
write(IO_CDC, &in, 1);
|
||||
|
@ -6,7 +6,6 @@
|
||||
#ifndef TKEY_APP_SYSCALL_H
|
||||
#define TKEY_APP_SYSCALL_H
|
||||
|
||||
int syscall(uint32_t number, uint32_t arg1, uint32_t arg2,
|
||||
uint32_t arg3);
|
||||
int syscall(uint32_t number, uint32_t arg1, uint32_t arg2, uint32_t arg3);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user