1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-22 05:10:56 +00:00

WIP - syscall cleanup

This commit is contained in:
cepetr 2024-10-31 10:31:07 +01:00
parent d38c2e1790
commit a25eb57069
4 changed files with 0 additions and 190 deletions

View File

@ -229,27 +229,6 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args,
args[0] = usb_hid_write__verified(iface_num, buf, len);
} break;
case SYSCALL_USB_HID_READ_SELECT: {
uint32_t timeout = args[0];
args[0] = usb_hid_read_select(timeout);
} break;
case SYSCALL_USB_HID_READ_BLOCKING: {
uint8_t iface_num = (uint8_t)args[0];
uint8_t *buf = (uint8_t *)args[1];
uint32_t len = args[2];
int timeout = (int)args[3];
args[0] = usb_hid_read_blocking__verified(iface_num, buf, len, timeout);
} break;
case SYSCALL_USB_HID_WRITE_BLOCKING: {
uint8_t iface_num = (uint8_t)args[0];
const uint8_t *buf = (const uint8_t *)args[1];
uint32_t len = args[2];
int timeout = (int)args[3];
args[0] = usb_hid_write_blocking__verified(iface_num, buf, len, timeout);
} break;
case SYSCALL_USB_VCP_ADD: {
const usb_vcp_info_t *vcp_info = (const usb_vcp_info_t *)args[0];
args[0] = usb_vcp_add(vcp_info);
@ -279,22 +258,6 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args,
args[0] = usb_vcp_write__verified(iface_num, buf, len);
} break;
case SYSCALL_USB_VCP_READ_BLOCKING: {
uint8_t iface_num = (uint8_t)args[0];
uint8_t *buf = (uint8_t *)args[1];
uint32_t len = args[2];
int timeout = (int)args[3];
args[0] = usb_vcp_read_blocking__verified(iface_num, buf, len, timeout);
} break;
case SYSCALL_USB_VCP_WRITE_BLOCKING: {
uint8_t iface_num = (uint8_t)args[0];
const uint8_t *buf = (const uint8_t *)args[1];
uint32_t len = args[2];
int timeout = (int)args[3];
args[0] = usb_vcp_write_blocking__verified(iface_num, buf, len, timeout);
} break;
case SYSCALL_USB_WEBUSB_ADD: {
const usb_webusb_info_t *webusb_info = (const usb_webusb_info_t *)args[0];
args[0] = usb_webusb_add(webusb_info);
@ -324,29 +287,6 @@ __attribute((no_stack_protector)) void syscall_handler(uint32_t *args,
args[0] = usb_webusb_write__verified(iface_num, buf, len);
} break;
case SYSCALL_USB_WEBUSB_READ_SELECT: {
uint32_t timeout = args[0];
args[0] = usb_webusb_read_select(timeout);
} break;
case SYSCALL_USB_WEBUSB_READ_BLOCKING: {
uint8_t iface_num = (uint8_t)args[0];
uint8_t *buf = (uint8_t *)args[1];
uint32_t len = args[2];
int timeout = (int)args[3];
args[0] =
usb_webusb_read_blocking__verified(iface_num, buf, len, timeout);
} break;
case SYSCALL_USB_WEBUSB_WRITE_BLOCKING: {
uint8_t iface_num = (uint8_t)args[0];
const uint8_t *buf = (const uint8_t *)args[1];
uint32_t len = args[2];
int timeout = (int)args[3];
args[0] =
usb_webusb_write_blocking__verified(iface_num, buf, len, timeout);
} break;
#ifdef USE_SD_CARD
case SYSCALL_SDCARD_POWER_ON: {
args[0] = sdcard_power_on();

View File

@ -58,24 +58,16 @@ typedef enum {
SYSCALL_USB_HID_CAN_WRITE,
SYSCALL_USB_HID_READ,
SYSCALL_USB_HID_WRITE,
SYSCALL_USB_HID_READ_SELECT,
SYSCALL_USB_HID_READ_BLOCKING,
SYSCALL_USB_HID_WRITE_BLOCKING,
SYSCALL_USB_VCP_ADD,
SYSCALL_USB_VCP_CAN_READ,
SYSCALL_USB_VCP_CAN_WRITE,
SYSCALL_USB_VCP_READ,
SYSCALL_USB_VCP_WRITE,
SYSCALL_USB_VCP_READ_BLOCKING,
SYSCALL_USB_VCP_WRITE_BLOCKING,
SYSCALL_USB_WEBUSB_ADD,
SYSCALL_USB_WEBUSB_CAN_READ,
SYSCALL_USB_WEBUSB_CAN_WRITE,
SYSCALL_USB_WEBUSB_READ,
SYSCALL_USB_WEBUSB_WRITE,
SYSCALL_USB_WEBUSB_READ_SELECT,
SYSCALL_USB_WEBUSB_READ_BLOCKING,
SYSCALL_USB_WEBUSB_WRITE_BLOCKING,
SYSCALL_SDCARD_POWER_ON,
SYSCALL_SDCARD_POWER_OFF,

View File

@ -196,22 +196,6 @@ int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
SYSCALL_USB_HID_WRITE);
}
int usb_hid_read_select(uint32_t timeout) {
return (int)syscall_invoke1(timeout, SYSCALL_USB_HID_READ_SELECT);
}
int usb_hid_read_blocking(uint8_t iface_num, uint8_t *buf, uint32_t len,
int timeout) {
return (int)syscall_invoke4((uint32_t)iface_num, (uint32_t)buf, len, timeout,
SYSCALL_USB_HID_READ_BLOCKING);
}
int usb_hid_write_blocking(uint8_t iface_num, const uint8_t *buf, uint32_t len,
int timeout) {
return (int)syscall_invoke4((uint32_t)iface_num, (uint32_t)buf, len, timeout,
SYSCALL_USB_HID_WRITE_BLOCKING);
}
// =============================================================================
// usb_vcp.h
// =============================================================================
@ -242,18 +226,6 @@ int usb_vcp_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
SYSCALL_USB_VCP_WRITE);
}
int usb_vcp_read_blocking(uint8_t iface_num, uint8_t *buf, uint32_t len,
int timeout) {
return (int)syscall_invoke4((uint32_t)iface_num, (uint32_t)buf, len, timeout,
SYSCALL_USB_VCP_READ_BLOCKING);
}
int usb_vcp_write_blocking(uint8_t iface_num, const uint8_t *buf, uint32_t len,
int timeout) {
return (int)syscall_invoke4((uint32_t)iface_num, (uint32_t)buf, len, timeout,
SYSCALL_USB_VCP_WRITE_BLOCKING);
}
// =============================================================================
// usb_webusb.h
// =============================================================================
@ -285,22 +257,6 @@ int usb_webusb_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) {
SYSCALL_USB_WEBUSB_WRITE);
}
int usb_webusb_read_select(uint32_t timeout) {
return (int)syscall_invoke1(timeout, SYSCALL_USB_WEBUSB_READ_SELECT);
}
int usb_webusb_read_blocking(uint8_t iface_num, uint8_t *buf, uint32_t len,
int timeout) {
return (int)syscall_invoke4((uint32_t)iface_num, (uint32_t)buf, len, timeout,
SYSCALL_USB_WEBUSB_READ_BLOCKING);
}
int usb_webusb_write_blocking(uint8_t iface_num, const uint8_t *buf,
uint32_t len, int timeout) {
return (int)syscall_invoke4((uint32_t)iface_num, (uint32_t)buf, len, timeout,
SYSCALL_USB_WEBUSB_WRITE_BLOCKING);
}
// =============================================================================
// sdcard.h
// =============================================================================

View File

@ -218,32 +218,6 @@ access_violation:
return 0;
}
int usb_hid_read_blocking__verified(uint8_t iface_num, uint8_t *buf,
uint32_t len, int timeout) {
if (!probe_write_access(buf, len)) {
goto access_violation;
}
return usb_hid_read_blocking(iface_num, buf, len, timeout);
access_violation:
apptask_access_violation();
return 0;
}
int usb_hid_write_blocking__verified(uint8_t iface_num, const uint8_t *buf,
uint32_t len, int timeout) {
if (!probe_read_access(buf, len)) {
goto access_violation;
}
return usb_hid_write_blocking(iface_num, buf, len, timeout);
access_violation:
apptask_access_violation();
return 0;
}
// ---------------------------------------------------------------------
int usb_vcp_read__verified(uint8_t iface_num, uint8_t *buf, uint32_t len) {
@ -271,32 +245,6 @@ access_violation:
return 0;
}
int usb_vcp_read_blocking__verified(uint8_t iface_num, uint8_t *buf,
uint32_t len, int timeout) {
if (!probe_write_access(buf, len)) {
goto access_violation;
}
return usb_vcp_read_blocking(iface_num, buf, len, timeout);
access_violation:
apptask_access_violation();
return 0;
}
int usb_vcp_write_blocking__verified(uint8_t iface_num, const uint8_t *buf,
uint32_t len, int timeout) {
if (!probe_read_access(buf, len)) {
goto access_violation;
}
return usb_vcp_write_blocking(iface_num, buf, len, timeout);
access_violation:
apptask_access_violation();
return 0;
}
// ---------------------------------------------------------------------
int usb_webusb_read__verified(uint8_t iface_num, uint8_t *buf, uint32_t len) {
@ -324,32 +272,6 @@ access_violation:
return 0;
}
int usb_webusb_read_blocking__verified(uint8_t iface_num, uint8_t *buf,
uint32_t len, int timeout) {
if (!probe_write_access(buf, len)) {
goto access_violation;
}
return usb_webusb_read_blocking(iface_num, buf, len, timeout);
access_violation:
apptask_access_violation();
return 0;
}
int usb_webusb_write_blocking__verified(uint8_t iface_num, const uint8_t *buf,
uint32_t len, int timeout) {
if (!probe_read_access(buf, len)) {
goto access_violation;
}
return usb_webusb_write_blocking(iface_num, buf, len, timeout);
access_violation:
apptask_access_violation();
return 0;
}
// ---------------------------------------------------------------------
secbool __wur sdcard_read_blocks__verified(uint32_t *dest, uint32_t block_num,