xref: /haiku/src/system/kernel/arch/m68k/asm_offsets.cpp (revision 239222b2369c39dc52df52b0a7cdd6cc0a91bc92)
1 /*
2  * Copyright 2007, 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 assembler 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 assembler
9 // code.
10 
11 #include <arch_cpu.h>
12 #include <ksyscalls.h>
13 #include <thread_types.h>
14 
15 
16 #define DEFINE_MACRO(macro, value) \
17 	asm volatile("#define " #macro " %0" : : "i" (value))
18 
19 #define DEFINE_OFFSET_MACRO(prefix, structure, member) \
20     DEFINE_MACRO(prefix##_##member, offsetof(struct structure, member));
21 
22 #define DEFINE_SIZEOF_MACRO(prefix, structure) \
23     DEFINE_MACRO(prefix##_sizeof, sizeof(struct structure));
24 
25 
26 void
27 dummy()
28 {
29 	// struct thread
30 	DEFINE_OFFSET_MACRO(THREAD, thread, kernel_time);
31 	DEFINE_OFFSET_MACRO(THREAD, thread, user_time);
32 	DEFINE_OFFSET_MACRO(THREAD, thread, last_time);
33 	DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel);
34 	DEFINE_OFFSET_MACRO(THREAD, thread, flags);
35 	DEFINE_OFFSET_MACRO(THREAD, thread, kernel_stack_top);
36 	DEFINE_OFFSET_MACRO(THREAD, thread, fault_handler);
37 
38 	// struct iframe
39 	DEFINE_OFFSET_MACRO(IFRAME, iframe, fp);
40 	DEFINE_OFFSET_MACRO(IFRAME, iframe, fpc);
41 	DEFINE_OFFSET_MACRO(IFRAME, iframe, fpu);
42 	DEFINE_OFFSET_MACRO(IFRAME, iframe, d);
43 	DEFINE_OFFSET_MACRO(IFRAME, iframe, a);
44 	DEFINE_OFFSET_MACRO(IFRAME, iframe, cpu);
45 #if 0
46 	// struct iframe
47 	DEFINE_OFFSET_MACRO(IFRAME, iframe, cs);
48 	DEFINE_OFFSET_MACRO(IFRAME, iframe, eax);
49 	DEFINE_OFFSET_MACRO(IFRAME, iframe, edx);
50 	DEFINE_OFFSET_MACRO(IFRAME, iframe, orig_eax);
51 	DEFINE_OFFSET_MACRO(IFRAME, iframe, vector);
52 	DEFINE_OFFSET_MACRO(IFRAME, iframe, eip);
53 	DEFINE_OFFSET_MACRO(IFRAME, iframe, flags);
54 	DEFINE_OFFSET_MACRO(IFRAME, iframe, user_esp);
55 #endif
56 
57 	DEFINE_SIZEOF_MACRO(FPU_STATE, mc680x0_fpu_state);
58 	DEFINE_SIZEOF_MACRO(FPU_DATA_REG, mc680x0_fp_data_reg);
59 
60 	// struct syscall_info
61 	DEFINE_SIZEOF_MACRO(SYSCALL_INFO, syscall_info);
62 	DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, function);
63 	DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, parameter_size);
64 }
65