2026-02-19 18:54:48 +00:00
|
|
|
#include <kernel/compiler.h>
|
2026-03-12 20:29:36 +00:00
|
|
|
#include <kernel/sched.h>
|
|
|
|
|
#include <kernel/thread.h>
|
2023-04-30 14:26:37 +01:00
|
|
|
|
2026-03-12 20:29:36 +00:00
|
|
|
// size_t THREAD_sp = offsetof(struct thread, tr_sp);
|
2023-04-30 14:26:37 +01:00
|
|
|
|
2026-03-12 20:29:36 +00:00
|
|
|
/* Use %a0 instead of %0 to prevent gcc from emitting a $ before the symbol
|
|
|
|
|
value in the generated assembly.
|
2023-04-30 14:26:37 +01:00
|
|
|
|
|
|
|
|
emitting
|
|
|
|
|
.set TASK_sp, $56
|
|
|
|
|
|
|
|
|
|
instead of
|
|
|
|
|
.set TASK_sp, 56
|
|
|
|
|
|
|
|
|
|
causes garbage symbols to be generated.
|
|
|
|
|
*/
|
|
|
|
|
|
2026-03-12 20:34:31 +00:00
|
|
|
#define DEFINE(sym, val) \
|
|
|
|
|
asm volatile("\n.global " #sym "\n.type " #sym \
|
|
|
|
|
", @object" \
|
|
|
|
|
"\n.set " #sym ", %a0" \
|
|
|
|
|
: \
|
|
|
|
|
: "i"(val))
|
|
|
|
|
|
|
|
|
|
#define OFFSET(sym, str, mem) DEFINE(sym, offsetof(str, mem))
|
2023-04-30 14:26:37 +01:00
|
|
|
|
|
|
|
|
static void __used common(void)
|
|
|
|
|
{
|
|
|
|
|
OFFSET(THREAD_sp, struct thread, tr_sp);
|
|
|
|
|
}
|