diff --git a/fuzzing/mock/custom/mocks.c b/fuzzing/mock/custom/mocks.c index 4d8b46616..89d0c8415 100644 --- a/fuzzing/mock/custom/mocks.c +++ b/fuzzing/mock/custom/mocks.c @@ -74,3 +74,10 @@ void mainExit(int exitCode) { (void) exitCode; } + +unsigned int os_sched_current_task(void); + +unsigned int os_sched_current_task(void) +{ + return TASK_USER; +} diff --git a/fuzzing/shared_libs/libnbgl_shared_apex_p.a b/fuzzing/shared_libs/libnbgl_shared_apex_p.a index c203ee40b..11c6bafb1 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_apex_p.a and b/fuzzing/shared_libs/libnbgl_shared_apex_p.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_flex.a b/fuzzing/shared_libs/libnbgl_shared_flex.a index 1e33d197a..5f205f00b 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_flex.a and b/fuzzing/shared_libs/libnbgl_shared_flex.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_nanosp.a b/fuzzing/shared_libs/libnbgl_shared_nanosp.a index ac492cdc8..17cc3bb2c 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_nanosp.a and b/fuzzing/shared_libs/libnbgl_shared_nanosp.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_nanox.a b/fuzzing/shared_libs/libnbgl_shared_nanox.a index f74a267ad..efef18444 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_nanox.a and b/fuzzing/shared_libs/libnbgl_shared_nanox.a differ diff --git a/fuzzing/shared_libs/libnbgl_shared_stax.a b/fuzzing/shared_libs/libnbgl_shared_stax.a index 15e708f2b..f7db792d4 100644 Binary files a/fuzzing/shared_libs/libnbgl_shared_stax.a and b/fuzzing/shared_libs/libnbgl_shared_stax.a differ diff --git a/include/os_task.h b/include/os_task.h index 70366a51b..b977d840d 100644 --- a/include/os_task.h +++ b/include/os_task.h @@ -10,18 +10,9 @@ typedef unsigned char bolos_task_status_t; enum task_unsecure_id_e { TASK_BOLOS = 0, // can call os TASK_SYSCALL, // can call os - TASK_USERTASKS_START, - // disabled for now // TASK_USER_UX, // must call syscalls to reach os, locked in ux ram - TASK_USER = TASK_USERTASKS_START, // must call syscalls to reach os, locked in app ram - TASK_SUBTASKS_START, - TASK_SUBTASK_0 = TASK_SUBTASKS_START, -#ifdef TARGET_NANOX - TASK_SUBTASK_1, - TASK_SUBTASK_2, - TASK_SUBTASK_3, -#endif // TARGET_NANOX - TASK_BOLOS_UX, - TASK_MAXCOUNT, // must be last in the structure + TASK_USER, // must call syscalls to reach os, locked in app ram + TASK_BOLOS_UX, // must call syscalls to reach os + TASK_MAXCOUNT // must be last in the structure }; // exit the current task @@ -31,54 +22,7 @@ SYSCALL void os_sched_exit(bolos_task_status_t exit_code); SYSCALL void __attribute__((noreturn)) os_sched_exit(bolos_task_status_t exit_code); #endif -// returns true when the given task is running, false else. -SYSCALL bolos_bool_t os_sched_is_running(unsigned int task_idx); - /** * Retrieve the last status issued by a task using either yield or exit. */ SUDOCALL bolos_task_status_t os_sched_last_status(unsigned int task_idx); - -/** - * Current task is yielding the process to another task. - * Meta call for task_switch with 'the enxt' task idx. - * @param status is the current task status - */ -SUDOCALL TASKSWITCH void os_sched_yield(bolos_task_status_t status); - -/** - * Perform task switching - * @param task_idx is the task index to switch to - * @param status of the currently executed task - * @return the status of the previously running task - */ -SUDOCALL TASKSWITCH void os_sched_switch(unsigned int task_idx, bolos_task_status_t status); - -/** - * Function that returns the currently running task identifier. - */ -SUDOCALL unsigned int os_sched_current_task(void); - -/** - * Create a new task with the given parameters and return its task identifier. - * The newly created task is chrooted in the given nvram/ram1/ram2 segments - * and its task pointer is set at the end of ram1 segment. - * The task is bound to the currently running application. - * The task identifiers are not guaranteed to be the same after a power cycle. - * At least valid main, nvram segment, ram0 segment and stack segment must be provided with. - * @param main The main function address to start the task with. - * @param nvram The nvram segment address start - * @param nvram_length The nvram segment length - * @param ram0 /ram0_length the first RAM segment description - * @param stack /stack_length the task's stack RAM segment description - */ -SYSCALL unsigned int os_sched_create(void *main PLENGTH(4), - void *nvram PLENGTH(nvram_length), - unsigned int nvram_length, - void *ram0 PLENGTH(ram0_length), - unsigned int ram0_length, - void *stack PLENGTH(stack_length), - unsigned int stack_length); - -// kill a task -SYSCALL void os_sched_kill(unsigned int taskidx); diff --git a/include/os_ux.h b/include/os_ux.h index 0ea41581b..d1e5a02f5 100644 --- a/include/os_ux.h +++ b/include/os_ux.h @@ -84,8 +84,6 @@ void bolos_test_ux_apdu(void); // is not processed. when returning !0 the application must send a general status (or continue its // command flow) SYSCALL TASKSWITCH unsigned int os_ux(bolos_ux_params_t *params PLENGTH(sizeof(bolos_ux_params_t))); -// read parameters back from the UX app. useful to read keyboard type or such -SYSCALL void os_ux_result(bolos_ux_params_t *params PLENGTH(sizeof(bolos_ux_params_t))); // process all possible messages while waiting for a ux to finish, // unprocessed messages are replied with a generic general status diff --git a/include/syscalls.h b/include/syscalls.h index b98b0339e..63045c126 100644 --- a/include/syscalls.h +++ b/include/syscalls.h @@ -182,9 +182,7 @@ #define SYSCALL_RESERVED_6_ID 0x00000125 #define SYSCALL_RESERVED_34_ID 0x01000126 #define SYSCALL_os_sched_exit_ID 0x0100009a -#define SYSCALL_os_sched_is_running_ID 0x0100009b -#define SYSCALL_os_sched_create_ID 0x0700011b -#define SYSCALL_os_sched_kill_ID 0x01000078 +#define SYSCALL_RESERVED_36_ID 0x0100009b #define SYSCALL_os_io_seph_tx_ID 0x03000082 #define SYSCALL_os_io_seph_se_rx_event_ID 0x05000083 #define SYSCALL_os_io_init_ID 0x01000084 @@ -197,9 +195,9 @@ #define SYSCALL_try_context_get_ID 0x00000087 #define SYSCALL_try_context_set_ID 0x0100010b #define SYSCALL_os_sched_last_status_ID 0x0100009c -#define SYSCALL_os_sched_yield_ID 0x0100009d +#define SYSCALL_RESERVED_38_ID 0x0100009d #define SYSCALL_os_sched_switch_ID 0x0200009e -#define SYSCALL_os_sched_current_task_ID 0x0000008b +#define SYSCALL_RESERVED_37_ID 0x0000008b #define SYSCALL_os_allow_protected_flash_ID 0x0000008e #define SYSCALL_os_deny_protected_flash_ID 0x00000091 #define SYSCALL_os_allow_protected_ram_ID 0x00000092 diff --git a/src/syscalls.c b/src/syscalls.c index 917fb89a6..cdf1ab511 100644 --- a/src/syscalls.c +++ b/src/syscalls.c @@ -1533,42 +1533,6 @@ void __attribute__((noreturn)) os_sched_exit(bolos_task_status_t exit_code) __builtin_unreachable(); } -bolos_bool_t os_sched_is_running(unsigned int task_idx) -{ - unsigned int parameters[2]; - parameters[0] = (unsigned int) task_idx; - parameters[1] = 0; - return (bolos_bool_t) SVC_Call(SYSCALL_os_sched_is_running_ID, parameters); -} - -unsigned int os_sched_create(void *main, - void *nvram, - unsigned int nvram_length, - void *ram0, - unsigned int ram0_length, - void *stack, - unsigned int stack_length) -{ - unsigned int parameters[7]; - parameters[0] = (unsigned int) main; - parameters[1] = (unsigned int) nvram; - parameters[2] = (unsigned int) nvram_length; - parameters[3] = (unsigned int) ram0; - parameters[4] = (unsigned int) ram0_length; - parameters[5] = (unsigned int) stack; - parameters[6] = (unsigned int) stack_length; - return (unsigned int) SVC_Call(SYSCALL_os_sched_create_ID, parameters); -} - -void os_sched_kill(unsigned int taskidx) -{ - unsigned int parameters[2]; - parameters[0] = (unsigned int) taskidx; - parameters[1] = 0; - SVC_Call(SYSCALL_os_sched_kill_ID, parameters); - return; -} - int os_io_seph_tx(const unsigned char *buffer, unsigned short length, unsigned int *timeout_ms) { unsigned int parameters[3]; @@ -1680,31 +1644,6 @@ bolos_task_status_t os_sched_last_status(unsigned int task_idx) return (bolos_task_status_t) SVC_Call(SYSCALL_os_sched_last_status_ID, parameters); } -void os_sched_yield(bolos_task_status_t status) -{ - unsigned int parameters[2]; - parameters[0] = (unsigned int) status; - parameters[1] = 0; - SVC_Call(SYSCALL_os_sched_yield_ID, parameters); - return; -} - -void os_sched_switch(unsigned int task_idx, bolos_task_status_t status) -{ - unsigned int parameters[2]; - parameters[0] = (unsigned int) task_idx; - parameters[1] = (unsigned int) status; - SVC_Call(SYSCALL_os_sched_switch_ID, parameters); - return; -} - -unsigned int os_sched_current_task(void) -{ - unsigned int parameters[2]; - parameters[1] = 0; - return (unsigned int) SVC_Call(SYSCALL_os_sched_current_task_ID, parameters); -} - unsigned int os_allow_protected_ram(void) { unsigned int parameters[2]; diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a index af8f8638f..2293693bb 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_apex_p.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a index e80c1732d..322a82e45 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_flex.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a index 2bc74c89e..f57e9dc7d 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanosp.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a index 627045f54..c111c319e 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_nanox.a differ diff --git a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a index 819b06da1..bd11a61d3 100644 Binary files a/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a and b/tests/screenshots/shared_libs/libnbgl_shared_screenshots_stax.a differ diff --git a/tests/screenshots/src/main/stubs.c b/tests/screenshots/src/main/stubs.c index a86c05937..b3c37d568 100644 --- a/tests/screenshots/src/main/stubs.c +++ b/tests/screenshots/src/main/stubs.c @@ -237,6 +237,8 @@ void os_sched_exit(bolos_task_status_t status_code) exit(-1); } +unsigned int os_sched_current_task(void); + unsigned int os_sched_current_task(void) { return TASK_USER;