blob: 71fc0800f4c15662f88133f89d97d35f5760368a [file] [log] [blame]
/*
* offset.c: Calculate task_struct offsets.
*
* Copyright (C) 1996 David S. Miller
* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Ralf Baechle
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
*
* Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
* Copyright (C) 2000 MIPS Technologies, Inc.
*
* Amir Bhor : Modified for ARC defines
*/
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/mm.h>
#include <asm/ptrace.h>
#include <asm/processor.h>
#include <asm/irq.h>
#include <asm/hardirq.h>
#define text(t) __asm__("\n@@@" t)
#define _offset(type, member) (&(((type *)NULL)->member))
#define offset(string, ptr, member) \
__asm__("\n@@@" string "%0" : : "i" (_offset(ptr, member)))
#define constant(string, member) \
__asm__("\n@@@" string "%x0" : : "i" (member))
#define size(string, size) \
__asm__("\n@@@" string "%0" : : "i" (sizeof(size)))
#define linefeed text("")
text("/* DO NOT TOUCH, AUTOGENERATED BY OFFSET.C */");
linefeed;
text("#ifndef _ASM_ARC_OFFSET_H");
text("#define _ASM_ARC_OFFSET_H");
linefeed;
void output_task_defines(void)
{
text("/* ARC task_struct offsets. */");
offset("#define TASK_STATE ", struct task_struct, state);
offset("#define TASK_FLAGS ", struct task_struct, flags);
offset("#define TASK_SIGPENDING ", struct task_struct, sigpending);
offset("#define TASK_NEED_RESCHED ", struct task_struct, need_resched);
offset("#define TASK_PTRACE ", struct task_struct, ptrace);
offset("#define TASK_THREAD ", struct task_struct, thread);
offset("#define TASK_COUNTER ", struct task_struct, counter);
offset("#define TASK_NICE ", struct task_struct, nice);
offset("#define TASK_MM ", struct task_struct, mm);
offset("#define TASK_PROCESSOR ", struct task_struct, processor);
offset("#define TASK_PID ", struct task_struct, pid);
size( "#define TASK_STRUCT_SIZE ", struct task_struct);
text("/* ARC cpuinfo struct offset. */");
offset("#define CPUINFO_PROCID ", struct cpuinfo_arc, processor_id);
offset("#define CPUINFO_PROCVER ", struct cpuinfo_arc, processor_version);
linefeed;
}
void output_thread_defines(void)
{
text("/* ARC specific thread_struct offsets. */");
offset("#define THREAD_KSP ", struct thread_struct, ksp);
offset("#define THREAD_USP ", struct thread_struct, usp);
offset("#define THREAD_PC ", struct thread_struct, pc);
linefeed;
}
void output_cpustat_define(void)
{
text("/* ARC irq_cpustat_t offsets. */");
offset("#define CPUSTAT_LOCAL_IRQ_COUNT ", irq_cpustat_t, \
__local_irq_count);
offset("#define CPUSTAT_SOFTIRQ_PENDING ", irq_cpustat_t, \
__softirq_pending);
linefeed;
}
text("#endif /* !(_ASM_ARC_OFFSET_H) */");