fpga/fw: Introduce syscall TK1_SYSCALL_GET_VIDPID

Introduce new syscall TK1_SYSCALL_GET_VIDPID to get Vendor ID and
Product ID from the protected Unique Device Identification number.

UDI is protected from device apps to protect the serial number, so
apps won't know the exact TKey they are running on other than the CDI.
It may, however, be important to know what *kind* of TKey they are
running on, so we want to expose the Vendor ID and Product ID.

- fpga: Allow UDI to be read when doing syscalls.
- Add the new syscall to firmware.
- Add test to testapp directly after negative test of reading UDI to
  read out VID/PID through a syscall.
This commit is contained in:
Michael Cardell Widerkrantz 2025-02-13 16:28:08 +01:00 committed by Mikael Ågren
parent 13f40561ab
commit df04fd56dd
No known key found for this signature in database
GPG Key ID: E02DA3D397792C46
3 changed files with 15 additions and 0 deletions

View File

@ -172,6 +172,14 @@ int main(void)
anyfailed = 1;
}
// But a syscall to get parts of UDI should be able to run
int vidpid = syscall(TK1_SYSCALL_GET_VIDPID, 0);
if (vidpid != 0x00010203) {
failmsg("Expected VID/PID to be 0x00010203");
anyfailed = 1;
}
uint32_t cdi_local[CDI_WORDS];
uint32_t cdi_local2[CDI_WORDS];
wordcpy_s(cdi_local, CDI_WORDS, (void *)cdi, CDI_WORDS);

View File

@ -10,6 +10,7 @@
// 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)
@ -21,6 +22,11 @@ int32_t syscall_handler(uint32_t number, uint32_t arg1)
case TK1_SYSCALL_SET_LED:
set_led(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);
}

View File

@ -7,6 +7,7 @@
enum syscall_num {
TK1_SYSCALL_RESET = 1,
TK1_SYSCALL_SET_LED = 10,
TK1_SYSCALL_GET_VIDPID = 12,
};
#endif