xref: /haiku/src/system/kernel/arch/riscv64/asm_offsets.cpp (revision c237c4ce593ee823d9867fd997e51e4c447f5623)
1 /*
2  * Copyright 2007-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 // This file is used to get C structure offsets into assembly code.
7 // The build system assembles the file and processes the output to create
8 // a header file with macro definitions, that can be included from assembly
9 // code.
10 
11 
12 #include <computed_asm_macros.h>
13 
14 #include <arch_cpu.h>
15 #include <cpu.h>
16 #include <ksignal.h>
17 #include <ksyscalls.h>
18 #include <thread_types.h>
19 
20 
21 #define DEFINE_MACRO(macro, value) DEFINE_COMPUTED_ASM_MACRO(macro, value)
22 
23 #define DEFINE_OFFSET_MACRO(prefix, structure, member) \
24 	DEFINE_MACRO(prefix##_##member, offsetof(struct structure, member));
25 
26 #define DEFINE_SIZEOF_MACRO(prefix, structure) \
27 	DEFINE_MACRO(prefix##_sizeof, sizeof(struct structure));
28 
29 
30 void
31 dummy()
32 {
33 	// struct Thread
34 	DEFINE_OFFSET_MACRO(THREAD, Thread, arch_info);
35 
36 	// struct arch_thread
37 	DEFINE_OFFSET_MACRO(ARCH_THREAD, arch_thread, context);
38 	DEFINE_OFFSET_MACRO(ARCH_THREAD, arch_thread, fpuContext);
39 
40 	DEFINE_OFFSET_MACRO(ARCH_CONTEXT, arch_context, sp);
41 
42 	DEFINE_OFFSET_MACRO(ARCH_STACK, arch_stack, thread);
43 
44 	DEFINE_SIZEOF_MACRO(IFRAME, iframe);
45 	DEFINE_OFFSET_MACRO(IFRAME, iframe, status);
46 	DEFINE_OFFSET_MACRO(IFRAME, iframe, cause);
47 	DEFINE_OFFSET_MACRO(IFRAME, iframe, tval);
48 	DEFINE_OFFSET_MACRO(IFRAME, iframe, ra);
49 	DEFINE_OFFSET_MACRO(IFRAME, iframe, sp);
50 	DEFINE_OFFSET_MACRO(IFRAME, iframe, tp);
51 	DEFINE_OFFSET_MACRO(IFRAME, iframe, epc);
52 }
53