^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * OpenRISC asm-offsets.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Linux architectural port borrowing liberally from similar works of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * others. All original copyrights apply as per the original source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * declaration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Modifications for the OpenRISC architecture:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is used to generate definitions needed by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * assembly language modules.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * We use the technique used in the OSF Mach kernel code:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * generate asm statements containing #defines,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * compile this file to assembler, and then extract the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * #defines from the assembly-language output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include <linux/mman.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include <linux/thread_info.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include <linux/kbuild.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int main(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) /* offsets into the task_struct */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) DEFINE(TASK_STATE, offsetof(struct task_struct, state));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) DEFINE(TASK_MM, offsetof(struct task_struct, mm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* offsets into thread_info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) DEFINE(TI_TASK, offsetof(struct thread_info, task));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) DEFINE(TI_FLAGS, offsetof(struct thread_info, flags));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) DEFINE(TI_PREEMPT, offsetof(struct thread_info, preempt_count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) DEFINE(TI_KSP, offsetof(struct thread_info, ksp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) DEFINE(PT_SIZE, sizeof(struct pt_regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* Interrupt register frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) DEFINE(INT_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) DEFINE(NUM_USER_SEGMENTS, TASK_SIZE >> 28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }