mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-04-27 02:19:23 -04:00

Build firmware, testfw and testapp using tkey-libs: https://github.com/tillitis/tkey-libs In an effort not to have more or less identical code maintained in two places, use tkey-libs when developing firmware, testfw and the firmware testapp, too. You can place the Git directory directly under hw/application_fpga and then an ordinary make should work. Or build with: make LIBDIR=/path/to/tkey-libs Co-authored-by: Mikael Ågren <mikael@tillitis.se>
38 lines
845 B
C
38 lines
845 B
C
/*
|
|
* Copyright (C) 2025 - Tillitis AB
|
|
* SPDX-License-Identifier: GPL-2.0-only
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <tkey/assert.h>
|
|
#include <tkey/led.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;
|
|
// clang-format on
|
|
|
|
int32_t syscall_handler(uint32_t number, uint32_t arg1)
|
|
{
|
|
switch (number) {
|
|
case TK1_SYSCALL_RESET:
|
|
*system_reset = 1;
|
|
return 0;
|
|
case TK1_SYSCALL_SET_LED:
|
|
led_set(arg1);
|
|
return 0;
|
|
case TK1_SYSCALL_GET_VIDPID:
|
|
// UDI is 2 words: VID/PID & serial. Return just the
|
|
// first word. Serial is kept secret to the device
|
|
// app.
|
|
return udi[0];
|
|
default:
|
|
assert(1 == 2);
|
|
}
|
|
|
|
assert(1 == 2);
|
|
return -1; // This should never run
|
|
}
|