diff --git a/hw/application_fpga/fw/testapp/main.c b/hw/application_fpga/fw/testapp/main.c index a5e4fba..f85902b 100644 --- a/hw/application_fpga/fw/testapp/main.c +++ b/hw/application_fpga/fw/testapp/main.c @@ -11,6 +11,7 @@ #include #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); diff --git a/hw/application_fpga/fw/testapp/syscall.h b/hw/application_fpga/fw/testapp/syscall.h index 42b76e3..8f1b7c1 100644 --- a/hw/application_fpga/fw/testapp/syscall.h +++ b/hw/application_fpga/fw/testapp/syscall.h @@ -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