mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Apply strict build.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -97,21 +97,22 @@ static uint8_t itf_num;
|
||||
static usb_buffer_t *ccid_rx = NULL, *ccid_tx = NULL;
|
||||
|
||||
int driver_process_usb_packet_ccid(uint8_t itf, uint16_t rx_read);
|
||||
void ccid_init(void);
|
||||
void ccid_task(void);
|
||||
#ifdef ENABLE_EMULATION
|
||||
void tud_vendor_rx_cb(uint8_t itf, const uint8_t *buffer, uint16_t bufsize);
|
||||
#endif
|
||||
|
||||
void ccid_write_offset(uint8_t itf, uint16_t size, uint16_t offset) {
|
||||
static void ccid_write_offset(uint8_t itf, uint16_t size, uint16_t offset) {
|
||||
ccid_tx[itf].w_ptr += size + offset;
|
||||
ccid_tx[itf].r_ptr += offset;
|
||||
}
|
||||
|
||||
void ccid_write(uint8_t itf, uint16_t size) {
|
||||
ccid_write_offset(itf, size, 0);
|
||||
}
|
||||
|
||||
ccid_header_t **ccid_response = NULL;
|
||||
ccid_header_t **ccid_resp_fast = NULL;
|
||||
ccid_header_t **ccid_header = NULL;
|
||||
|
||||
uint8_t sc_itf_to_usb_itf(uint8_t itf) {
|
||||
static uint8_t sc_itf_to_usb_itf(uint8_t itf) {
|
||||
if (itf == ITF_SC_CCID) {
|
||||
return ITF_CCID;
|
||||
}
|
||||
@@ -121,7 +122,7 @@ uint8_t sc_itf_to_usb_itf(uint8_t itf) {
|
||||
return itf;
|
||||
}
|
||||
|
||||
void ccid_init_buffers() {
|
||||
static void ccid_init_buffers(void) {
|
||||
if (ITF_SC_TOTAL == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -142,7 +143,7 @@ void ccid_init_buffers() {
|
||||
}
|
||||
}
|
||||
|
||||
int driver_init_ccid(uint8_t itf) {
|
||||
static int driver_init_ccid(uint8_t itf) {
|
||||
ccid_header[itf] = (ccid_header_t *) (ccid_rx[itf].buffer + ccid_rx[itf].r_ptr);
|
||||
ccid_resp_fast[itf] = (ccid_header_t *) (ccid_tx[itf].buffer + sizeof(ccid_tx[itf].buffer) - 64);
|
||||
// apdu.header = &ccid_header->apdu;
|
||||
@@ -157,6 +158,8 @@ int driver_init_ccid(uint8_t itf) {
|
||||
}
|
||||
|
||||
void tud_vendor_rx_cb(uint8_t itf, const uint8_t *buffer, uint16_t bufsize) {
|
||||
(void)buffer;
|
||||
(void)bufsize;
|
||||
uint32_t len = tud_vendor_n_available(itf);
|
||||
do {
|
||||
uint16_t tlen = 0;
|
||||
@@ -173,7 +176,7 @@ void tud_vendor_rx_cb(uint8_t itf, const uint8_t *buffer, uint16_t bufsize) {
|
||||
} while (len > 0);
|
||||
}
|
||||
|
||||
int driver_write_ccid(uint8_t itf, const uint8_t *tx_buffer, uint16_t buffer_size) {
|
||||
static int driver_write_ccid(uint8_t itf, const uint8_t *tx_buffer, uint16_t buffer_size) {
|
||||
if (*tx_buffer != 0x81) {
|
||||
DEBUG_PAYLOAD(tx_buffer, buffer_size);
|
||||
}
|
||||
@@ -193,7 +196,7 @@ int driver_write_ccid(uint8_t itf, const uint8_t *tx_buffer, uint16_t buffer_siz
|
||||
return (int)written;
|
||||
}
|
||||
|
||||
int ccid_write_fast(uint8_t itf, const uint8_t *buffer, uint16_t buffer_size) {
|
||||
static int ccid_write_fast(uint8_t itf, const uint8_t *buffer, uint16_t buffer_size) {
|
||||
return driver_write_ccid(itf, buffer, buffer_size);
|
||||
}
|
||||
|
||||
@@ -316,7 +319,7 @@ int driver_process_usb_packet_ccid(uint8_t itf, uint16_t rx_read) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void driver_exec_timeout_ccid(uint8_t itf) {
|
||||
static void driver_exec_timeout_ccid(uint8_t itf) {
|
||||
ccid_resp_fast[itf]->bMessageType = CCID_DATA_BLOCK_RET;
|
||||
ccid_resp_fast[itf]->dwLength = 0;
|
||||
ccid_resp_fast[itf]->bSlot = 0;
|
||||
@@ -341,7 +344,7 @@ void driver_exec_finished_cont_ccid(uint8_t itf, uint16_t size_next, uint16_t of
|
||||
ccid_write_offset(itf, size_next+10, offset);
|
||||
}
|
||||
|
||||
void ccid_task() {
|
||||
void ccid_task(void) {
|
||||
for (int itf = 0; itf < ITF_SC_TOTAL; itf++) {
|
||||
int status = card_status(sc_itf_to_usb_itf(itf));
|
||||
if (status == PICOKEY_OK) {
|
||||
@@ -358,7 +361,7 @@ void ccid_task() {
|
||||
}
|
||||
}
|
||||
|
||||
void ccid_init() {
|
||||
void ccid_init(void) {
|
||||
ccid_init_buffers();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ extern int cbor_parse(uint8_t cmd, const uint8_t *data, size_t len);
|
||||
pthread_t hcore0, hcore1;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
int msleep(long msec) {
|
||||
static int msleep(long msec) {
|
||||
struct timespec ts;
|
||||
int res;
|
||||
|
||||
@@ -80,7 +80,7 @@ int msleep(long msec) {
|
||||
}
|
||||
#endif
|
||||
|
||||
int emul_init(char *host, uint16_t port) {
|
||||
int emul_init(const char *host, uint16_t port) {
|
||||
struct sockaddr_in serv_addr;
|
||||
fprintf(stderr, "\n Starting emulation envionrment\n");
|
||||
#ifdef _MSC_VER
|
||||
@@ -167,7 +167,7 @@ int emul_init(char *host, uint16_t port) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
socket_t get_sock_itf(uint8_t itf) {
|
||||
static socket_t get_sock_itf(uint8_t itf) {
|
||||
#ifdef USB_ITF_CCID
|
||||
if (itf == ITF_CCID) {
|
||||
return ccid_sock;
|
||||
@@ -333,7 +333,7 @@ uint16_t emul_read(uint8_t itf) {
|
||||
return emul_rx_size;
|
||||
}
|
||||
|
||||
void emul_task() {
|
||||
void emul_task(void) {
|
||||
#ifdef USB_ITF_CCID
|
||||
emul_read(ITF_CCID);
|
||||
#endif
|
||||
|
||||
@@ -25,11 +25,12 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#define USB_BUFFER_SIZE 4096
|
||||
extern int emul_init(char *host, uint16_t port);
|
||||
extern int emul_init(const char *host, uint16_t port);
|
||||
extern uint8_t emul_rx[USB_BUFFER_SIZE];
|
||||
extern uint16_t emul_rx_size, emul_tx_size;
|
||||
extern uint16_t driver_write_emul(uint8_t itf, const uint8_t *buffer, uint16_t buffer_size);
|
||||
extern uint16_t emul_read(uint8_t itf);
|
||||
extern void emul_task(void);
|
||||
|
||||
#ifdef USB_ITF_HID
|
||||
typedef uint8_t hid_report_type_t;
|
||||
|
||||
@@ -158,6 +158,9 @@ typedef struct {
|
||||
|
||||
extern void add_keyboard_buffer(const uint8_t *, size_t, bool);
|
||||
extern void append_keyboard_buffer(const uint8_t *data, size_t data_len);
|
||||
extern int driver_init_hid(void);
|
||||
extern int ctap_error(uint8_t error);
|
||||
extern uint16_t *get_send_buffer_size(uint8_t itf);
|
||||
|
||||
extern bool is_nk;
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ static portMUX_TYPE mutex = portMUX_INITIALIZER_UNLOCKED;
|
||||
#include "apdu.h"
|
||||
#include "usb.h"
|
||||
|
||||
extern void init_fido();
|
||||
extern void init_fido(void);
|
||||
bool is_nk = false;
|
||||
uint8_t (*get_version_major)() = NULL;
|
||||
uint8_t (*get_version_minor)() = NULL;
|
||||
uint8_t (*get_version_major)(void) = NULL;
|
||||
uint8_t (*get_version_minor)(void) = NULL;
|
||||
|
||||
static usb_buffer_t *hid_rx = NULL, *hid_tx = NULL;
|
||||
|
||||
@@ -51,12 +51,18 @@ static uint16_t *send_buffer_size = NULL;
|
||||
static write_status_t *last_write_result = NULL;
|
||||
|
||||
CTAPHID_FRAME *ctap_req = NULL, *ctap_resp = NULL;
|
||||
void send_keepalive();
|
||||
static void send_keepalive(void);
|
||||
int driver_process_usb_packet_hid(uint16_t read);
|
||||
int driver_write_hid(uint8_t itf, const uint8_t *buffer, uint16_t buffer_size);
|
||||
int driver_process_usb_nopacket_hid();
|
||||
static int driver_process_usb_nopacket_hid(void);
|
||||
void hid_init(void);
|
||||
void hid_task(void);
|
||||
#ifdef ENABLE_EMULATION
|
||||
uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen);
|
||||
void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize);
|
||||
#endif
|
||||
|
||||
void hid_init() {
|
||||
void hid_init(void) {
|
||||
if (ITF_HID_TOTAL == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -74,7 +80,7 @@ void hid_init() {
|
||||
}
|
||||
}
|
||||
|
||||
int driver_init_hid() {
|
||||
int driver_init_hid(void) {
|
||||
#ifndef ENABLE_EMULATION
|
||||
static bool _init = false;
|
||||
if (_init == false) {
|
||||
@@ -98,10 +104,6 @@ int driver_init_hid() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t *get_send_buffer_size(uint8_t itf) {
|
||||
return &send_buffer_size[itf];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USB HID
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -127,7 +129,7 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t
|
||||
return reqlen;
|
||||
}
|
||||
|
||||
uint32_t hid_write_offset(uint16_t size, uint16_t offset) {
|
||||
static uint32_t hid_write_offset(uint16_t size, uint16_t offset) {
|
||||
if (hid_tx[ITF_HID_CTAP].buffer[offset] != 0x81) {
|
||||
DEBUG_PAYLOAD(&hid_tx[ITF_HID_CTAP].buffer[offset], size);
|
||||
}
|
||||
@@ -136,7 +138,7 @@ uint32_t hid_write_offset(uint16_t size, uint16_t offset) {
|
||||
return size;
|
||||
}
|
||||
|
||||
uint32_t hid_write(uint16_t size) {
|
||||
static uint32_t hid_write(uint16_t size) {
|
||||
return hid_write_offset(size, 0);
|
||||
}
|
||||
|
||||
@@ -309,7 +311,7 @@ uint8_t thread_type = 0; //1 is APDU, 2 is CBOR
|
||||
extern bool cancel_button;
|
||||
extern int cbor_process(uint8_t last_cmd, const uint8_t *data, size_t len);
|
||||
|
||||
int driver_process_usb_nopacket_hid() {
|
||||
int driver_process_usb_nopacket_hid(void) {
|
||||
if (last_packet_time > 0 && last_packet_time + 500 < board_millis()) {
|
||||
ctap_error(CTAP1_ERR_MSG_TIMEOUT);
|
||||
last_packet_time = 0;
|
||||
@@ -321,6 +323,10 @@ int driver_process_usb_nopacket_hid() {
|
||||
extern const uint8_t fido_aid[], u2f_aid[], oath_aid[];
|
||||
extern void *cbor_thread(void *);
|
||||
|
||||
uint16_t *get_send_buffer_size(uint8_t itf) {
|
||||
return &send_buffer_size[itf];
|
||||
}
|
||||
|
||||
int driver_process_usb_packet_hid(uint16_t read) {
|
||||
int apdu_sent = 0;
|
||||
if (read >= 5) {
|
||||
@@ -549,7 +555,7 @@ int driver_process_usb_packet_hid(uint16_t read) {
|
||||
return apdu_sent;
|
||||
}
|
||||
|
||||
void send_keepalive() {
|
||||
static void send_keepalive(void) {
|
||||
if (thread_type == 1) {
|
||||
return;
|
||||
}
|
||||
@@ -593,7 +599,7 @@ void driver_exec_finished_cont_hid(uint8_t itf, uint16_t size_next, uint16_t off
|
||||
}
|
||||
}
|
||||
|
||||
void hid_task() {
|
||||
void hid_task(void) {
|
||||
#ifdef ENABLE_EMULATION
|
||||
uint16_t rx_len = emul_read(ITF_HID);
|
||||
if (rx_len) {
|
||||
|
||||
@@ -40,7 +40,6 @@ static uint8_t card_locked_itf = 0; // no locked
|
||||
static void *(*card_locked_func)(void *) = NULL;
|
||||
#ifndef ENABLE_EMULATION
|
||||
static mutex_t mutex;
|
||||
extern void usb_desc_setup();
|
||||
#endif
|
||||
#if !defined(PICO_PLATFORM) && !defined(ENABLE_EMULATION) && !defined(ESP_PLATFORM)
|
||||
#ifdef _MSC_VER
|
||||
@@ -53,14 +52,14 @@ pthread_t hcore0, hcore1;
|
||||
uint8_t ITF_HID_CTAP = ITF_INVALID, ITF_HID_KB = ITF_INVALID;
|
||||
uint8_t ITF_HID = ITF_INVALID, ITF_KEYBOARD = ITF_INVALID;
|
||||
uint8_t ITF_HID_TOTAL = 0;
|
||||
extern void hid_init();
|
||||
extern void hid_init(void);
|
||||
#endif
|
||||
|
||||
#ifdef USB_ITF_CCID
|
||||
uint8_t ITF_SC_CCID = ITF_INVALID, ITF_SC_WCID = ITF_INVALID;
|
||||
uint8_t ITF_CCID = ITF_INVALID, ITF_WCID = ITF_INVALID;
|
||||
uint8_t ITF_SC_TOTAL = 0;
|
||||
extern void ccid_init();
|
||||
extern void ccid_init(void);
|
||||
#endif
|
||||
uint8_t ITF_TOTAL = 0;
|
||||
|
||||
@@ -75,7 +74,7 @@ queue_t card_to_usb_q = {0};
|
||||
extern tusb_desc_device_t desc_device;
|
||||
extern char *string_desc_itf[4], *string_desc_arr[];
|
||||
#endif
|
||||
void usb_init()
|
||||
void usb_init(void)
|
||||
{
|
||||
#ifndef ENABLE_EMULATION
|
||||
if (phy_data.vidpid_present) {
|
||||
@@ -158,15 +157,15 @@ void usb_init()
|
||||
}
|
||||
|
||||
uint32_t timeout = 0;
|
||||
void timeout_stop() {
|
||||
void timeout_stop(void) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
void timeout_start() {
|
||||
void timeout_start(void) {
|
||||
timeout = board_millis();
|
||||
}
|
||||
|
||||
bool is_busy() {
|
||||
bool is_busy(void) {
|
||||
return timeout > 0;
|
||||
}
|
||||
|
||||
@@ -187,8 +186,7 @@ void usb_send_event(uint32_t flag) {
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void low_flash_init();
|
||||
void card_init_core1() {
|
||||
void card_init_core1(void) {
|
||||
low_flash_init_core1();
|
||||
}
|
||||
|
||||
@@ -210,7 +208,7 @@ void card_start(uint8_t itf, void *(*func)(void *)) {
|
||||
}
|
||||
}
|
||||
|
||||
void card_exit() {
|
||||
void card_exit(void) {
|
||||
if (card_locked_itf != ITF_TOTAL || card_locked_func != NULL) {
|
||||
usb_send_event(EV_EXIT);
|
||||
uint32_t m;
|
||||
@@ -238,10 +236,10 @@ void card_exit() {
|
||||
card_locked_itf = ITF_TOTAL;
|
||||
card_locked_func = NULL;
|
||||
}
|
||||
extern void hid_task();
|
||||
extern void ccid_task();
|
||||
extern void emul_task();
|
||||
void usb_task() {
|
||||
extern void hid_task(void);
|
||||
extern void ccid_task(void);
|
||||
extern void emul_task(void);
|
||||
void usb_task(void) {
|
||||
#ifdef USB_ITF_HID
|
||||
hid_task();
|
||||
#endif
|
||||
|
||||
@@ -73,23 +73,24 @@ enum {
|
||||
#define TUSB_SMARTCARD_CCID_EPS 3
|
||||
#endif
|
||||
|
||||
extern void usb_task();
|
||||
extern void usb_task(void);
|
||||
extern queue_t usb_to_card_q;
|
||||
extern queue_t card_to_usb_q;
|
||||
|
||||
extern void card_start(uint8_t, void *(*func)(void *));
|
||||
extern void card_exit();
|
||||
extern void card_exit(void);
|
||||
extern int card_status(uint8_t itf);
|
||||
extern void usb_init();
|
||||
extern void usb_init(void);
|
||||
|
||||
extern uint16_t finished_data_size;
|
||||
extern void usb_set_timeout_counter(uint8_t itf, uint32_t v);
|
||||
extern void card_init_core1();
|
||||
extern void card_init_core1(void);
|
||||
|
||||
extern void usb_send_event(uint32_t flag);
|
||||
extern void timeout_stop();
|
||||
extern void timeout_start();
|
||||
extern bool is_busy();
|
||||
extern void timeout_stop(void);
|
||||
extern void timeout_start(void);
|
||||
extern bool is_busy(void);
|
||||
extern void usb_desc_setup(void);
|
||||
|
||||
#ifdef USB_ITF_HID
|
||||
extern void driver_exec_finished_hid(uint16_t size_next);
|
||||
|
||||
@@ -160,7 +160,7 @@ uint8_t const *tud_hid_descriptor_report_cb(uint8_t itf) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void usb_desc_setup() {
|
||||
void usb_desc_setup(void) {
|
||||
desc_config[4] = ITF_TOTAL;
|
||||
TUSB_DESC_TOTAL_LEN = TUD_CONFIG_DESC_LEN;
|
||||
uint8_t *p = desc_config + TUD_CONFIG_DESC_LEN;
|
||||
|
||||
Reference in New Issue
Block a user