mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2024-10-01 01:45:38 -04:00
Wip syscall function.
PoC of how a syscall could look like.
This commit is contained in:
parent
f62930984d
commit
b602de145c
@ -94,7 +94,8 @@ FIRMWARE_DEPS = \
|
||||
$(P)/fw/tk1/htif.h \
|
||||
$(P)/fw/tk1/rng.h \
|
||||
$(P)/fw/tk1/mgmt_app.h \
|
||||
$(P)/fw/tk1/storage.h
|
||||
$(P)/fw/tk1/storage.h \
|
||||
$(P)/fw/tk1/syscall.h
|
||||
|
||||
FIRMWARE_OBJS = \
|
||||
$(P)/fw/tk1/main.o \
|
||||
@ -112,7 +113,8 @@ FIRMWARE_OBJS = \
|
||||
$(P)/fw/tk1/htif.o \
|
||||
$(P)/fw/tk1/rng.o \
|
||||
$(P)/fw/tk1/mgmt_app.o \
|
||||
$(P)/fw/tk1/storage.o
|
||||
$(P)/fw/tk1/storage.o \
|
||||
$(P)/fw/tk1/syscall.o
|
||||
|
||||
FIRMWARE_SOURCES = \
|
||||
$(P)/fw/tk1/main.c \
|
||||
@ -129,7 +131,8 @@ FIRMWARE_SOURCES = \
|
||||
$(P)/fw/tk1/htif.c \
|
||||
$(P)/fw/tk1/rng.c \
|
||||
$(P)/fw/tk1/mgmt_app.c \
|
||||
$(P)/fw/tk1/storage.c
|
||||
$(P)/fw/tk1/storage.c \
|
||||
$(P)/fw/tk1/syscall.c
|
||||
|
||||
TESTFW_OBJS = \
|
||||
$(P)/fw/testfw/main.o \
|
||||
|
58
hw/application_fpga/fw/tk1/syscall.c
Normal file
58
hw/application_fpga/fw/tk1/syscall.c
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright (C) 2024 - Tillitis AB
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
#include "syscall.h"
|
||||
#include "mgmt_app.h"
|
||||
#include "partition_table.h"
|
||||
#include "preload_app.h"
|
||||
#include "storage.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int syscall(syscall_t *ctx)
|
||||
{
|
||||
|
||||
partition_table_t part_table;
|
||||
part_table_init(&part_table);
|
||||
|
||||
switch (ctx->syscall_no) {
|
||||
case ALLOC_AREA:
|
||||
return storage_allocate_area(&part_table);
|
||||
break;
|
||||
|
||||
case DEALLOC_AREA:
|
||||
return storage_deallocate_area(&part_table);
|
||||
break;
|
||||
|
||||
case READ_DATA:
|
||||
return storage_read_data(&part_table, ctx->offset, ctx->data,
|
||||
ctx->size);
|
||||
break;
|
||||
|
||||
case WRITE_DATA:
|
||||
return storage_write_data(&part_table, ctx->offset, ctx->data,
|
||||
ctx->size);
|
||||
break;
|
||||
|
||||
case PRELOAD_STORE:
|
||||
return preload_store(&part_table);
|
||||
break;
|
||||
|
||||
case PRELOAD_DELETE:
|
||||
return preload_delete(&part_table);
|
||||
break;
|
||||
|
||||
case MGMT_APP_REGISTER:
|
||||
return mgmt_app_register(&part_table);
|
||||
break;
|
||||
|
||||
case MGMT_APP_UNREGISTER:
|
||||
return mgmt_app_unregister(&part_table);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* return -1 */
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
35
hw/application_fpga/fw/tk1/syscall.h
Normal file
35
hw/application_fpga/fw/tk1/syscall.h
Normal file
@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2024 - Tillitis AB
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
|
||||
#ifndef SYSCALL_H
|
||||
#define SYSCALL_H
|
||||
|
||||
#include "partition_table.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t syscall_no;
|
||||
uint32_t offset;
|
||||
uint8_t *data;
|
||||
size_t size;
|
||||
uint32_t *ctx;
|
||||
} syscall_t;
|
||||
|
||||
enum syscall_cmd {
|
||||
BLAKE2S = 0,
|
||||
ALLOC_AREA,
|
||||
DEALLOC_AREA,
|
||||
WRITE_DATA,
|
||||
READ_DATA,
|
||||
PRELOAD_STORE,
|
||||
PRELOAD_DELETE,
|
||||
MGMT_APP_REGISTER,
|
||||
MGMT_APP_UNREGISTER,
|
||||
};
|
||||
|
||||
int syscall(syscall_t *ctx);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user