Let's use asm offset instead of hardcoded values...

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26070 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2008-06-21 23:41:36 +00:00
parent b409283372
commit ffa2f65116
@@ -0,0 +1,60 @@
/*
* Copyright 2007, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
// This file is used to get C structure offsets into assembler code.
// The build system assembles the file and processes the output to create
// a header file with macro definitions, that can be included from assembler
// code.
#include <arch_cpu.h>
#include <ksyscalls.h>
#include <thread_types.h>
#define DEFINE_MACRO(macro, value) \
asm volatile("#define " #macro " %0" : : "i" (value))
#define DEFINE_OFFSET_MACRO(prefix, structure, member) \
DEFINE_MACRO(prefix##_##member, offsetof(struct structure, member));
#define DEFINE_SIZEOF_MACRO(prefix, structure) \
DEFINE_MACRO(prefix##_sizeof, sizeof(struct structure));
void
dummy()
{
// struct thread
DEFINE_OFFSET_MACRO(THREAD, thread, kernel_time);
DEFINE_OFFSET_MACRO(THREAD, thread, user_time);
DEFINE_OFFSET_MACRO(THREAD, thread, last_time);
DEFINE_OFFSET_MACRO(THREAD, thread, in_kernel);
DEFINE_OFFSET_MACRO(THREAD, thread, flags);
DEFINE_OFFSET_MACRO(THREAD, thread, kernel_stack_top);
DEFINE_OFFSET_MACRO(THREAD, thread, fault_handler);
// struct iframe
DEFINE_OFFSET_MACRO(IFRAME, iframe, cs);
DEFINE_OFFSET_MACRO(IFRAME, iframe, eax);
DEFINE_OFFSET_MACRO(IFRAME, iframe, edx);
DEFINE_OFFSET_MACRO(IFRAME, iframe, orig_eax);
DEFINE_OFFSET_MACRO(IFRAME, iframe, vector);
DEFINE_OFFSET_MACRO(IFRAME, iframe, eip);
DEFINE_OFFSET_MACRO(IFRAME, iframe, flags);
DEFINE_OFFSET_MACRO(IFRAME, iframe, user_esp);
// struct vm86_iframe
DEFINE_SIZEOF_MACRO(VM86_IFRAME, vm86_iframe);
DEFINE_OFFSET_MACRO(VM86_IFRAME, vm86_iframe, flags);
// struct syscall_info
DEFINE_SIZEOF_MACRO(SYSCALL_INFO, syscall_info);
DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, function);
DEFINE_OFFSET_MACRO(SYSCALL_INFO, syscall_info, parameter_size);
// struct x86_optimized_functions
DEFINE_OFFSET_MACRO(X86_OPTIMIZED_FUNCTIONS, x86_optimized_functions,
memcpy);
}