asm-offsets.c

来自「linux 内核源代码」· C语言 代码 · 共 333 行 · 第 1/2 页

C
333
字号
/* * This program is used to generate definitions needed by * assembly language modules. * * We use the technique used in the OSF Mach kernel code: * generate asm statements containing #defines, * compile this file to assembler, and then extract the * #defines from the assembly-language output. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */#include <linux/signal.h>#include <linux/sched.h>#include <linux/kernel.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/types.h>#include <linux/mman.h>#include <linux/mm.h>#include <linux/suspend.h>#ifdef CONFIG_PPC64#include <linux/time.h>#include <linux/hardirq.h>#else#include <linux/ptrace.h>#endif#include <asm/io.h>#include <asm/page.h>#include <asm/pgtable.h>#include <asm/processor.h>#include <asm/cputable.h>#include <asm/thread_info.h>#include <asm/rtas.h>#include <asm/vdso_datapage.h>#ifdef CONFIG_PPC64#include <asm/paca.h>#include <asm/lppaca.h>#include <asm/cache.h>#include <asm/compat.h>#include <asm/mmu.h>#include <asm/hvcall.h>#endif#define DEFINE(sym, val) \	asm volatile("\n->" #sym " %0 " #val : : "i" (val))#define BLANK() asm volatile("\n->" : : )int main(void){	DEFINE(THREAD, offsetof(struct task_struct, thread));	DEFINE(MM, offsetof(struct task_struct, mm));#ifdef CONFIG_PPC64	DEFINE(AUDITCONTEXT, offsetof(struct task_struct, audit_context));#else	DEFINE(THREAD_INFO, offsetof(struct task_struct, stack));	DEFINE(PTRACE, offsetof(struct task_struct, ptrace));#endif /* CONFIG_PPC64 */	DEFINE(KSP, offsetof(struct thread_struct, ksp));	DEFINE(PT_REGS, offsetof(struct thread_struct, regs));	DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));	DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0]));	DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr));#ifdef CONFIG_ALTIVEC	DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0]));	DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));	DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));	DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr));#endif /* CONFIG_ALTIVEC */#ifdef CONFIG_PPC64	DEFINE(KSP_VSID, offsetof(struct thread_struct, ksp_vsid));#else /* CONFIG_PPC64 */	DEFINE(PGDIR, offsetof(struct thread_struct, pgdir));#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)	DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0));	DEFINE(PT_PTRACED, PT_PTRACED);#endif#ifdef CONFIG_SPE	DEFINE(THREAD_EVR0, offsetof(struct thread_struct, evr[0]));	DEFINE(THREAD_ACC, offsetof(struct thread_struct, acc));	DEFINE(THREAD_SPEFSCR, offsetof(struct thread_struct, spefscr));	DEFINE(THREAD_USED_SPE, offsetof(struct thread_struct, used_spe));#endif /* CONFIG_SPE */#endif /* CONFIG_PPC64 */	DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));	DEFINE(TI_LOCAL_FLAGS, offsetof(struct thread_info, local_flags));	DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));	DEFINE(TI_TASK, offsetof(struct thread_info, task));#ifdef CONFIG_PPC32	DEFINE(TI_EXECDOMAIN, offsetof(struct thread_info, exec_domain));	DEFINE(TI_CPU, offsetof(struct thread_info, cpu));#endif /* CONFIG_PPC32 */#ifdef CONFIG_PPC64	DEFINE(DCACHEL1LINESIZE, offsetof(struct ppc64_caches, dline_size));	DEFINE(DCACHEL1LOGLINESIZE, offsetof(struct ppc64_caches, log_dline_size));	DEFINE(DCACHEL1LINESPERPAGE, offsetof(struct ppc64_caches, dlines_per_page));	DEFINE(ICACHEL1LINESIZE, offsetof(struct ppc64_caches, iline_size));	DEFINE(ICACHEL1LOGLINESIZE, offsetof(struct ppc64_caches, log_iline_size));	DEFINE(ICACHEL1LINESPERPAGE, offsetof(struct ppc64_caches, ilines_per_page));	/* paca */	DEFINE(PACA_SIZE, sizeof(struct paca_struct));	DEFINE(PACAPACAINDEX, offsetof(struct paca_struct, paca_index));	DEFINE(PACAPROCSTART, offsetof(struct paca_struct, cpu_start));	DEFINE(PACAKSAVE, offsetof(struct paca_struct, kstack));	DEFINE(PACACURRENT, offsetof(struct paca_struct, __current));	DEFINE(PACASAVEDMSR, offsetof(struct paca_struct, saved_msr));	DEFINE(PACASTABREAL, offsetof(struct paca_struct, stab_real));	DEFINE(PACASTABVIRT, offsetof(struct paca_struct, stab_addr));	DEFINE(PACASTABRR, offsetof(struct paca_struct, stab_rr));	DEFINE(PACAR1, offsetof(struct paca_struct, saved_r1));	DEFINE(PACATOC, offsetof(struct paca_struct, kernel_toc));	DEFINE(PACASOFTIRQEN, offsetof(struct paca_struct, soft_enabled));	DEFINE(PACAHARDIRQEN, offsetof(struct paca_struct, hard_enabled));	DEFINE(PACASLBCACHE, offsetof(struct paca_struct, slb_cache));	DEFINE(PACASLBCACHEPTR, offsetof(struct paca_struct, slb_cache_ptr));	DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id));	DEFINE(PACAVMALLOCSLLP, offsetof(struct paca_struct, vmalloc_sllp));#ifdef CONFIG_PPC_MM_SLICES	DEFINE(PACALOWSLICESPSIZE, offsetof(struct paca_struct,					    context.low_slices_psize));	DEFINE(PACAHIGHSLICEPSIZE, offsetof(struct paca_struct,					    context.high_slices_psize));	DEFINE(MMUPSIZEDEFSIZE, sizeof(struct mmu_psize_def));	DEFINE(MMUPSIZESLLP, offsetof(struct mmu_psize_def, sllp));#else	DEFINE(PACACONTEXTSLLP, offsetof(struct paca_struct, context.sllp));#endif /* CONFIG_PPC_MM_SLICES */	DEFINE(PACA_EXGEN, offsetof(struct paca_struct, exgen));	DEFINE(PACA_EXMC, offsetof(struct paca_struct, exmc));	DEFINE(PACA_EXSLB, offsetof(struct paca_struct, exslb));	DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp));	DEFINE(PACALPPACAPTR, offsetof(struct paca_struct, lppaca_ptr));	DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id));	DEFINE(PACA_STARTPURR, offsetof(struct paca_struct, startpurr));	DEFINE(PACA_STARTSPURR, offsetof(struct paca_struct, startspurr));	DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));	DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));	DEFINE(PACA_SLBSHADOWPTR, offsetof(struct paca_struct, slb_shadow_ptr));	DEFINE(PACA_DATA_OFFSET, offsetof(struct paca_struct, data_offset));	DEFINE(PACA_TRAP_SAVE, offsetof(struct paca_struct, trap_save));	DEFINE(SLBSHADOW_STACKVSID,	       offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].vsid));	DEFINE(SLBSHADOW_STACKESID,	       offsetof(struct slb_shadow, save_area[SLB_NUM_BOLTED - 1].esid));	DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0));	DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1));	DEFINE(LPPACAANYINT, offsetof(struct lppaca, int_dword.any_int));	DEFINE(LPPACADECRINT, offsetof(struct lppaca, int_dword.fields.decr_int));	DEFINE(SLBSHADOW_SAVEAREA, offsetof(struct slb_shadow, save_area));#endif /* CONFIG_PPC64 */	/* RTAS */	DEFINE(RTASBASE, offsetof(struct rtas_t, base));	DEFINE(RTASENTRY, offsetof(struct rtas_t, entry));	/* Interrupt register frame */	DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?