X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=kitten%2Farch%2Fx86_64%2Fkernel%2Fasm-offsets.c;fp=kitten%2Farch%2Fx86_64%2Fkernel%2Fasm-offsets.c;h=c159f898118ff4d5029f0faf723cb8ddbd6c97c7;hb=66a1a4c7a9edcd7d8bc207aca093d694a6e6b5b2;hp=0000000000000000000000000000000000000000;hpb=f7cf9c19ecb0a589dd45ae0d2c91814bd3c2acc2;p=palacios.git diff --git a/kitten/arch/x86_64/kernel/asm-offsets.c b/kitten/arch/x86_64/kernel/asm-offsets.c new file mode 100644 index 0000000..c159f89 --- /dev/null +++ b/kitten/arch/x86_64/kernel/asm-offsets.c @@ -0,0 +1,80 @@ +/* + * Generate definitions needed by assembly language modules. + * This code generates raw asm output which is post-processed to extract + * and format the required data. + */ + +#if 0 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +#include + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + +/** + * This is used to automatically count the number of system calls. + * A table is generated with one entry for each system call defined in + * arch/unistd.h, which contains the list of system calls. + */ +#define __NO_STUBS 1 +#undef __SYSCALL +#undef _ARCH_X86_64_UNISTD_H +#define __SYSCALL(nr, sym) [nr] = 1, +static char syscalls[] = { +#include +}; + +int main(void) +{ +#define ENTRY(entry) DEFINE(tsk_ ## entry, offsetof(struct task_struct, entry)) +#if 0 + ENTRY(state); + ENTRY(flags); + ENTRY(thread); +#endif + ENTRY(id); + BLANK(); +#undef ENTRY +#define ENTRY(entry) DEFINE(tsk_arch_ ## entry, offsetof(struct task_struct, arch) + offsetof(struct arch_task, entry)) + ENTRY(flags); + ENTRY(addr_limit); + BLANK(); +#undef ENTRY +#define ENTRY(entry) DEFINE(tsk_arch_ ## entry, offsetof(struct task_struct, arch) + offsetof(struct arch_task, thread) + offsetof(struct thread_struct, entry)) + ENTRY(rsp); + BLANK(); +#undef ENTRY +#define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry)) + ENTRY(kernelstack); + ENTRY(oldrsp); + ENTRY(pcurrent); + ENTRY(irqcount); + ENTRY(cpunumber); + ENTRY(irqstackptr); + ENTRY(data_offset); + BLANK(); +#undef ENTRY +#if 0 + DEFINE(pbe_address, offsetof(struct pbe, address)); + DEFINE(pbe_orig_address, offsetof(struct pbe, orig_address)); + DEFINE(pbe_next, offsetof(struct pbe, next)); + BLANK(); + DEFINE(TSS_ist, offsetof(struct tss_struct, ist)); +#endif + BLANK(); + DEFINE(__NR_syscall_max, sizeof(syscalls) - 1); + return 0; +}