aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv64/gen/asm-offsets.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2022-05-29 01:07:48 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2022-05-29 01:07:48 +0300
commit0f4a751e60a6c8ac40592ff44c74f1c9e4846d9a (patch)
tree96fb1e8479261a128f065ee493ee3a97a3b91949 /arch/riscv64/gen/asm-offsets.c
parent013a27aec9370221e8afae188a8ed08ed2d406b0 (diff)
downloadkmi-0f4a751e60a6c8ac40592ff44c74f1c9e4846d9a.tar.gz
kmi-0f4a751e60a6c8ac40592ff44c74f1c9e4846d9a.zip
continue documentation efforts.
Diffstat (limited to 'arch/riscv64/gen/asm-offsets.c')
-rw-r--r--arch/riscv64/gen/asm-offsets.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/arch/riscv64/gen/asm-offsets.c b/arch/riscv64/gen/asm-offsets.c
index fbe2726..71a1c9a 100644
--- a/arch/riscv64/gen/asm-offsets.c
+++ b/arch/riscv64/gen/asm-offsets.c
@@ -7,12 +7,36 @@
#include <apos/utils.h>
#include "../kernel/regs.h"
-/* largely based on linux */
+/**
+ * Insert assembly comment with calculated value.
+ * Largely based on linux
+ *
+ * @param sym Name of symbol.
+ * @param val Value of symbol.
+ */
#define DEFINE(sym, val) \
__asm__ volatile ("\n#-> " #sym " %0 " #val "\n" : : "i" (val))
+
+/**
+ * Insert offset of member in structure.
+ *
+ * @param m Member.
+ * @param s Structure.
+ */
#define OFFSETOF(m, s) DEFINE(offsetof_##m, offsetof(s, m))
+
+/**
+ * Insert size of structure.
+ *
+ * @param n Name of structure.
+ * @param s Structure.
+ */
#define SIZEOF(n, s) DEFINE(sizeof_##n, sizeof(s))
+/**
+ * Generate assembly with calculated offsets and sizes.
+ * See arch/riscv64/gen/source.mk for how the assembly is used.
+ */
void asm_offsets()
{
OFFSETOF(ra, struct riscv_regs);