blob: 0759153e81179b7a68909b9154d52afa1c2732c7 [file] [log] [blame]
Michal Simek4511ec12009-03-27 14:25:37 +01001/*
Michal Simek52338062009-05-26 16:30:18 +02002 * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2008-2009 PetaLogix
Michal Simek4511ec12009-03-27 14:25:37 +01004 * Copyright (C) 2006 Atmark Techno, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#ifndef _ASM_MICROBLAZE_PROCESSOR_H
12#define _ASM_MICROBLAZE_PROCESSOR_H
13
14#include <asm/ptrace.h>
15#include <asm/setup.h>
16#include <asm/registers.h>
Michal Simek2921e2b2009-04-21 14:08:47 +020017#include <asm/entry.h>
18#include <asm/current.h>
Michal Simek4511ec12009-03-27 14:25:37 +010019
20# ifndef __ASSEMBLY__
21/* from kernel/cpu/mb.c */
22extern const struct seq_operations cpuinfo_op;
23
24# define cpu_relax() barrier()
25# define cpu_sleep() do {} while (0)
Michal Simek4511ec12009-03-27 14:25:37 +010026
Michal Simek2eba3182009-04-16 11:05:26 +020027#define task_pt_regs(tsk) \
28 (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1)
29
Michal Simeke1c4bd02009-04-16 11:30:16 +020030/* Do necessary setup to start up a newly executed thread. */
31void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp);
32
Michal Simek0dd90aa2012-04-02 12:55:47 +020033extern void ret_from_fork(void);
Al Viro23192952012-10-06 13:52:37 -040034extern void ret_from_kernel_thread(void);
Michal Simek0dd90aa2012-04-02 12:55:47 +020035
Michal Simek52338062009-05-26 16:30:18 +020036# endif /* __ASSEMBLY__ */
37
38# ifndef CONFIG_MMU
Michal Simek4511ec12009-03-27 14:25:37 +010039/*
40 * User space process size: memory size
41 *
42 * TASK_SIZE on MMU cpu is usually 1GB. However, on no-MMU arch, both
43 * user processes and the kernel is on the same memory region. They
44 * both share the memory space and that is limited by the amount of
45 * physical memory. thus, we set TASK_SIZE == amount of total memory.
46 */
47# define TASK_SIZE (0x81000000 - 0x80000000)
48
49/*
50 * Default implementation of macro that returns current
51 * instruction pointer ("program counter").
52 */
53# define current_text_addr() ({ __label__ _l; _l: &&_l; })
54
55/*
56 * This decides where the kernel will search for a free chunk of vm
57 * space during mmap's. We won't be using it
58 */
59# define TASK_UNMAPPED_BASE 0
60
61/* definition in include/linux/sched.h */
62struct task_struct;
63
64/* thread_struct is gone. use thread_info instead. */
65struct thread_struct { };
66# define INIT_THREAD { }
67
Michal Simek4511ec12009-03-27 14:25:37 +010068/* Free all resources held by a thread. */
69static inline void release_thread(struct task_struct *dead_task)
70{
71}
72
73/* Free all resources held by a thread. */
74static inline void exit_thread(void)
75{
76}
77
78extern unsigned long thread_saved_pc(struct task_struct *t);
79
80extern unsigned long get_wchan(struct task_struct *p);
81
Michal Simek4511ec12009-03-27 14:25:37 +010082# define KSTK_EIP(tsk) (0)
83# define KSTK_ESP(tsk) (0)
84
Michal Simek52338062009-05-26 16:30:18 +020085# else /* CONFIG_MMU */
86
87/*
88 * This is used to define STACK_TOP, and with MMU it must be below
89 * kernel base to select the correct PGD when handling MMU exceptions.
90 */
91# define TASK_SIZE (CONFIG_KERNEL_START)
92
93/*
94 * This decides where the kernel will search for a free chunk of vm
95 * space during mmap's.
96 */
97# define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
98
99# define THREAD_KSP 0
100
101# ifndef __ASSEMBLY__
102
103/*
104 * Default implementation of macro that returns current
105 * instruction pointer ("program counter").
106 */
107# define current_text_addr() ({ __label__ _l; _l: &&_l; })
108
109/* If you change this, you must change the associated assembly-languages
110 * constants defined below, THREAD_*.
111 */
112struct thread_struct {
113 /* kernel stack pointer (must be first field in structure) */
114 unsigned long ksp;
115 unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
116 void *pgdir; /* root of page-table tree */
117 struct pt_regs *regs; /* Pointer to saved register state */
118};
119
120# define INIT_THREAD { \
121 .ksp = sizeof init_stack + (unsigned long)init_stack, \
122 .pgdir = swapper_pg_dir, \
123}
124
Michal Simek52338062009-05-26 16:30:18 +0200125/* Free all resources held by a thread. */
126extern inline void release_thread(struct task_struct *dead_task)
127{
128}
129
Michal Simek52338062009-05-26 16:30:18 +0200130/* Free current thread data structures etc. */
131static inline void exit_thread(void)
132{
133}
134
135/* Return saved (kernel) PC of a blocked thread. */
136# define thread_saved_pc(tsk) \
137 ((tsk)->thread.regs ? (tsk)->thread.regs->r15 : 0)
138
139unsigned long get_wchan(struct task_struct *p);
140
141/* The size allocated for kernel stacks. This _must_ be a power of two! */
142# define KERNEL_STACK_SIZE 0x2000
143
144/* Return some info about the user process TASK. */
145# define task_tos(task) ((unsigned long)(task) + KERNEL_STACK_SIZE)
146# define task_regs(task) ((struct pt_regs *)task_tos(task) - 1)
147
148# define task_pt_regs_plus_args(tsk) \
Michal Simek6e835572011-01-31 15:10:04 +0100149 ((void *)task_pt_regs(tsk))
Michal Simek52338062009-05-26 16:30:18 +0200150
151# define task_sp(task) (task_regs(task)->r1)
152# define task_pc(task) (task_regs(task)->pc)
153/* Grotty old names for some. */
154# define KSTK_EIP(task) (task_pc(task))
155# define KSTK_ESP(task) (task_sp(task))
156
157/* FIXME */
158# define deactivate_mm(tsk, mm) do { } while (0)
159
160# define STACK_TOP TASK_SIZE
161# define STACK_TOP_MAX STACK_TOP
162
David Howellsc40d04d2012-03-28 18:30:02 +0100163void disable_hlt(void);
164void enable_hlt(void);
165void default_idle(void);
166
167#ifdef CONFIG_DEBUG_FS
168extern struct dentry *of_debugfs_root;
169#endif
170
Michal Simek52338062009-05-26 16:30:18 +0200171# endif /* __ASSEMBLY__ */
172# endif /* CONFIG_MMU */
Michal Simek4511ec12009-03-27 14:25:37 +0100173#endif /* _ASM_MICROBLAZE_PROCESSOR_H */