^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2007-2009 PetaLogix
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2006 Atmark Techno, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/kernel_stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/hardirq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/thread_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/kbuild.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <asm/cpuinfo.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) int main(int argc, char *argv[])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) /* struct pt_regs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) DEFINE(PT_SIZE, sizeof(struct pt_regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) DEFINE(PT_MSR, offsetof(struct pt_regs, msr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) DEFINE(PT_EAR, offsetof(struct pt_regs, ear));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) DEFINE(PT_ESR, offsetof(struct pt_regs, esr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) DEFINE(PT_FSR, offsetof(struct pt_regs, fsr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) DEFINE(PT_PC, offsetof(struct pt_regs, pc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) DEFINE(PT_R0, offsetof(struct pt_regs, r0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) DEFINE(PT_R1, offsetof(struct pt_regs, r1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) DEFINE(PT_R2, offsetof(struct pt_regs, r2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) DEFINE(PT_R3, offsetof(struct pt_regs, r3));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) DEFINE(PT_R4, offsetof(struct pt_regs, r4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) DEFINE(PT_R5, offsetof(struct pt_regs, r5));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) DEFINE(PT_R6, offsetof(struct pt_regs, r6));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) DEFINE(PT_R7, offsetof(struct pt_regs, r7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) DEFINE(PT_R8, offsetof(struct pt_regs, r8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) DEFINE(PT_R9, offsetof(struct pt_regs, r9));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) DEFINE(PT_R10, offsetof(struct pt_regs, r10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) DEFINE(PT_R11, offsetof(struct pt_regs, r11));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) DEFINE(PT_R12, offsetof(struct pt_regs, r12));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) DEFINE(PT_R13, offsetof(struct pt_regs, r13));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) DEFINE(PT_R14, offsetof(struct pt_regs, r14));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) DEFINE(PT_R15, offsetof(struct pt_regs, r15));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) DEFINE(PT_R16, offsetof(struct pt_regs, r16));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) DEFINE(PT_R17, offsetof(struct pt_regs, r17));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) DEFINE(PT_R18, offsetof(struct pt_regs, r18));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) DEFINE(PT_R19, offsetof(struct pt_regs, r19));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) DEFINE(PT_R20, offsetof(struct pt_regs, r20));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) DEFINE(PT_R21, offsetof(struct pt_regs, r21));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) DEFINE(PT_R22, offsetof(struct pt_regs, r22));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) DEFINE(PT_R23, offsetof(struct pt_regs, r23));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) DEFINE(PT_R24, offsetof(struct pt_regs, r24));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) DEFINE(PT_R25, offsetof(struct pt_regs, r25));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) DEFINE(PT_R26, offsetof(struct pt_regs, r26));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) DEFINE(PT_R27, offsetof(struct pt_regs, r27));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) DEFINE(PT_R28, offsetof(struct pt_regs, r28));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) DEFINE(PT_R29, offsetof(struct pt_regs, r29));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) DEFINE(PT_R30, offsetof(struct pt_regs, r30));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) DEFINE(PT_R31, offsetof(struct pt_regs, r31));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) DEFINE(PT_MODE, offsetof(struct pt_regs, pt_mode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) BLANK();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* Magic offsets for PTRACE PEEK/POKE etc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) DEFINE(PT_TEXT_ADDR, sizeof(struct pt_regs) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) DEFINE(PT_TEXT_LEN, sizeof(struct pt_regs) + 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) DEFINE(PT_DATA_ADDR, sizeof(struct pt_regs) + 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) BLANK();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /* struct task_struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) DEFINE(TS_THREAD_INFO, offsetof(struct task_struct, stack));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #ifdef CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) DEFINE(TASK_STATE, offsetof(struct task_struct, state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) DEFINE(TASK_MM, offsetof(struct task_struct, mm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) DEFINE(TASK_PID, offsetof(struct task_struct, pid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) BLANK();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) DEFINE(PGDIR, offsetof(struct thread_struct, pgdir));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) BLANK();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* struct thread_info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) DEFINE(TI_TASK, offsetof(struct thread_info, task));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) DEFINE(TI_ADDR_LIMIT, offsetof(struct thread_info, addr_limit));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) DEFINE(TI_CPU_CONTEXT, offsetof(struct thread_info, cpu_context));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) DEFINE(TI_PREEMPT_COUNT, offsetof(struct thread_info, preempt_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) BLANK();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /* struct cpu_context */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) DEFINE(CC_R1, offsetof(struct cpu_context, r1)); /* r1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) DEFINE(CC_R2, offsetof(struct cpu_context, r2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* dedicated registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) DEFINE(CC_R13, offsetof(struct cpu_context, r13));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) DEFINE(CC_R14, offsetof(struct cpu_context, r14));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) DEFINE(CC_R15, offsetof(struct cpu_context, r15));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) DEFINE(CC_R16, offsetof(struct cpu_context, r16));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) DEFINE(CC_R17, offsetof(struct cpu_context, r17));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) DEFINE(CC_R18, offsetof(struct cpu_context, r18));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* non-volatile registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) DEFINE(CC_R19, offsetof(struct cpu_context, r19));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) DEFINE(CC_R20, offsetof(struct cpu_context, r20));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) DEFINE(CC_R21, offsetof(struct cpu_context, r21));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) DEFINE(CC_R22, offsetof(struct cpu_context, r22));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) DEFINE(CC_R23, offsetof(struct cpu_context, r23));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) DEFINE(CC_R24, offsetof(struct cpu_context, r24));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) DEFINE(CC_R25, offsetof(struct cpu_context, r25));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) DEFINE(CC_R26, offsetof(struct cpu_context, r26));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) DEFINE(CC_R27, offsetof(struct cpu_context, r27));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) DEFINE(CC_R28, offsetof(struct cpu_context, r28));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) DEFINE(CC_R29, offsetof(struct cpu_context, r29));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) DEFINE(CC_R30, offsetof(struct cpu_context, r30));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* special purpose registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) DEFINE(CC_MSR, offsetof(struct cpu_context, msr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) DEFINE(CC_EAR, offsetof(struct cpu_context, ear));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) DEFINE(CC_ESR, offsetof(struct cpu_context, esr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) DEFINE(CC_FSR, offsetof(struct cpu_context, fsr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) BLANK();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }