blob: 37ef196e45191adb481450c8648e9e9acbb05106 [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()
Michal Simek4511ec12009-03-27 14:25:37 +010025
Michal Simek2eba3182009-04-16 11:05:26 +020026#define task_pt_regs(tsk) \
27 (((struct pt_regs *)(THREAD_SIZE + task_stack_page(tsk))) - 1)
28
Michal Simeke1c4bd02009-04-16 11:30:16 +020029/* Do necessary setup to start up a newly executed thread. */
30void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp);
31
Michal Simek0dd90aa2012-04-02 12:55:47 +020032extern void ret_from_fork(void);
Al Viro23192952012-10-06 13:52:37 -040033extern void ret_from_kernel_thread(void);
Michal Simek0dd90aa2012-04-02 12:55:47 +020034
Michal Simek52338062009-05-26 16:30:18 +020035# endif /* __ASSEMBLY__ */
36
37# ifndef CONFIG_MMU
Michal Simek4511ec12009-03-27 14:25:37 +010038/*
39 * User space process size: memory size
40 *
41 * TASK_SIZE on MMU cpu is usually 1GB. However, on no-MMU arch, both
42 * user processes and the kernel is on the same memory region. They
43 * both share the memory space and that is limited by the amount of
44 * physical memory. thus, we set TASK_SIZE == amount of total memory.
45 */
46# define TASK_SIZE (0x81000000 - 0x80000000)
47
48/*
49 * Default implementation of macro that returns current
50 * instruction pointer ("program counter").
51 */
52# define current_text_addr() ({ __label__ _l; _l: &&_l; })
53
54/*
55 * This decides where the kernel will search for a free chunk of vm
56 * space during mmap's. We won't be using it
57 */
58# define TASK_UNMAPPED_BASE 0
59
60/* definition in include/linux/sched.h */
61struct task_struct;
62
63/* thread_struct is gone. use thread_info instead. */
64struct thread_struct { };
65# define INIT_THREAD { }
66
Michal Simek4511ec12009-03-27 14:25:37 +010067/* Free all resources held by a thread. */
68static inline void release_thread(struct task_struct *dead_task)
69{
70}
71
Michal Simek4511ec12009-03-27 14:25:37 +010072extern unsigned long thread_saved_pc(struct task_struct *t);
73
74extern unsigned long get_wchan(struct task_struct *p);
75
Michal Simek4511ec12009-03-27 14:25:37 +010076# define KSTK_EIP(tsk) (0)
77# define KSTK_ESP(tsk) (0)
78
Michal Simek52338062009-05-26 16:30:18 +020079# else /* CONFIG_MMU */
80
81/*
82 * This is used to define STACK_TOP, and with MMU it must be below
83 * kernel base to select the correct PGD when handling MMU exceptions.
84 */
85# define TASK_SIZE (CONFIG_KERNEL_START)
86
87/*
88 * This decides where the kernel will search for a free chunk of vm
89 * space during mmap's.
90 */
91# define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
92
93# define THREAD_KSP 0
94
95# ifndef __ASSEMBLY__
96
97/*
98 * Default implementation of macro that returns current
99 * instruction pointer ("program counter").
100 */
101# define current_text_addr() ({ __label__ _l; _l: &&_l; })
102
103/* If you change this, you must change the associated assembly-languages
104 * constants defined below, THREAD_*.
105 */
106struct thread_struct {
107 /* kernel stack pointer (must be first field in structure) */
108 unsigned long ksp;
109 unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
110 void *pgdir; /* root of page-table tree */
111 struct pt_regs *regs; /* Pointer to saved register state */
112};
113
114# define INIT_THREAD { \
115 .ksp = sizeof init_stack + (unsigned long)init_stack, \
116 .pgdir = swapper_pg_dir, \
117}
118
Michal Simek52338062009-05-26 16:30:18 +0200119/* Free all resources held by a thread. */
Michal Simekace526e2014-02-28 14:00:11 +0100120static inline void release_thread(struct task_struct *dead_task)
Michal Simek52338062009-05-26 16:30:18 +0200121{
122}
123
Michal Simek52338062009-05-26 16:30:18 +0200124/* Return saved (kernel) PC of a blocked thread. */
125# define thread_saved_pc(tsk) \
126 ((tsk)->thread.regs ? (tsk)->thread.regs->r15 : 0)
127
128unsigned long get_wchan(struct task_struct *p);
129
130/* The size allocated for kernel stacks. This _must_ be a power of two! */
131# define KERNEL_STACK_SIZE 0x2000
132
133/* Return some info about the user process TASK. */
134# define task_tos(task) ((unsigned long)(task) + KERNEL_STACK_SIZE)
135# define task_regs(task) ((struct pt_regs *)task_tos(task) - 1)
136
137# define task_pt_regs_plus_args(tsk) \
Michal Simek6e835572011-01-31 15:10:04 +0100138 ((void *)task_pt_regs(tsk))
Michal Simek52338062009-05-26 16:30:18 +0200139
140# define task_sp(task) (task_regs(task)->r1)
141# define task_pc(task) (task_regs(task)->pc)
142/* Grotty old names for some. */
143# define KSTK_EIP(task) (task_pc(task))
144# define KSTK_ESP(task) (task_sp(task))
145
146/* FIXME */
147# define deactivate_mm(tsk, mm) do { } while (0)
148
149# define STACK_TOP TASK_SIZE
150# define STACK_TOP_MAX STACK_TOP
151
David Howellsc40d04d2012-03-28 18:30:02 +0100152#ifdef CONFIG_DEBUG_FS
153extern struct dentry *of_debugfs_root;
154#endif
155
Michal Simek52338062009-05-26 16:30:18 +0200156# endif /* __ASSEMBLY__ */
157# endif /* CONFIG_MMU */
Michal Simek4511ec12009-03-27 14:25:37 +0100158#endif /* _ASM_MICROBLAZE_PROCESSOR_H */