2 * arch/ubicom32/include/asm/processor.h
3 * Thread related definitions for Ubicom32 architecture.
5 * (C) Copyright 2009, Ubicom, Inc.
6 * Copyright (C) 1995 Hamish Macdonald
8 * This file is part of the Ubicom32 Linux Kernel Port.
10 * The Ubicom32 Linux Kernel Port is free software: you can redistribute
11 * it and/or modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation, either version 2 of the
13 * License, or (at your option) any later version.
15 * The Ubicom32 Linux Kernel Port is distributed in the hope that it
16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
18 * the GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with the Ubicom32 Linux Kernel Port. If not,
22 * see <http://www.gnu.org/licenses/>.
24 * Ubicom32 implementation derived from (with many thanks):
30 #ifndef _ASM_UBICOM32_PROCESSOR_H
31 #define _ASM_UBICOM32_PROCESSOR_H
34 * Default implementation of macro that returns current
35 * instruction pointer ("program counter").
37 #define current_text_addr() ({ __label__ _l; _l: &&_l;})
39 #include <linux/compiler.h>
40 #include <linux/threads.h>
41 #include <asm/types.h>
42 #include <asm/segment.h>
44 #include <asm/ptrace.h>
45 #include <asm/current.h>
46 #include <asm/thread_info.h>
48 #if defined(CONFIG_UBICOM32_V3)
51 #if defined(CONFIG_UBICOM32_V4)
59 * User space process size: 1st byte beyond user address space.
61 extern unsigned long memory_end
;
62 #define TASK_SIZE (memory_end)
65 * This decides where the kernel will search for a free chunk of vm
66 * space during mmap's. We won't be using it
68 #define TASK_UNMAPPED_BASE 0
71 * This is the structure where we are going to save callee-saved registers.
72 * A5 is the return address, A7 is the stack pointer, A6 is the frame
73 * pointer. This is the frame that is created because of switch_to. This
74 * is not the frame due to interrupt preemption or because of syscall entry.
77 struct thread_struct
{
78 unsigned long d10
; /* D10 */
79 unsigned long d11
; /* D11 */
80 unsigned long d12
; /* D12 */
81 unsigned long d13
; /* D13 */
82 unsigned long a1
; /* A1 */
83 unsigned long a2
; /* A2 */
84 unsigned long a5
; /* A5 return address. */
85 unsigned long a6
; /* A6 */
86 unsigned long sp
; /* A7 kernel stack pointer. */
89 #define INIT_THREAD { \
90 0, 0, 0, 0, 0, 0, 0, 0, \
91 sizeof(init_stack) + (unsigned long) init_stack - 8, \
95 * Do necessary setup to start up a newly executed thread.
97 * pass the data segment into user programs if it exists,
98 * it can't hurt anything as far as I can tell
101 * Do necessary setup to start up a newly executed thread.
103 #define start_thread(regs, new_pc, new_sp) \
105 regs->pc = new_pc & ~3; \
106 regs->an[5] = new_pc & ~3; \
107 regs->an[7] = new_sp; \
108 regs->nesting_level = -1; \
109 regs->frame_type = UBICOM32_FRAME_TYPE_NEW_THREAD; \
110 regs->thread_type = NORMAL_THREAD; \
113 /* Forward declaration, a strange C thing */
116 /* Free all resources held by a thread. */
117 static inline void release_thread(struct task_struct
*dead_task
)
121 /* Prepare to copy thread state - unlazy all lazy status */
122 #define prepare_to_copy(tsk) do { } while (0)
124 extern int kernel_thread(int (*fn
)(void *), void * arg
, unsigned long flags
);
127 * Free current thread data structures etc..
129 static inline void exit_thread(void)
133 unsigned long thread_saved_pc(struct task_struct
*tsk
);
134 unsigned long get_wchan(struct task_struct
*p
);
136 #define KSTK_EIP(tsk) (tsk->thread.a5)
137 #define KSTK_ESP(tsk) (tsk->thread.sp)
139 #define cpu_relax() barrier()
141 extern void processor_init(void);
142 extern unsigned int processor_timers(void);
143 extern unsigned int processor_threads(void);
144 extern unsigned int processor_frequency(void);
145 extern int processor_interrupts(unsigned int *int0
, unsigned int *int1
);
146 extern void processor_ocm(unsigned long *socm
, unsigned long *eocm
);
147 extern void processor_dram(unsigned long *sdram
, unsigned long *edram
);
149 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
150 #define KSTK_TOP(info) \
152 unsigned long *__ptr = (unsigned long *)(info); \
153 (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
156 #define task_pt_regs(task) \
158 struct pt_regs *__regs__; \
159 __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
163 #endif /* _ASM_UBICOM32_PROCESSOR_H */