blob: b1ed6159066006bd3d635f57126316a12f25962a [file] [log] [blame]
Michal Simek4511ec12009-03-27 14:25:37 +01001/*
2 * Copyright (C) 2006 Atmark Techno, Inc.
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 */
8
9#ifndef _ASM_MICROBLAZE_SYSTEM_H
10#define _ASM_MICROBLAZE_SYSTEM_H
11
12#include <asm/registers.h>
13#include <asm/setup.h>
14#include <asm/irqflags.h>
15
Remis Lima Baima0a584582009-06-18 19:55:33 +020016#include <asm-generic/cmpxchg.h>
17#include <asm-generic/cmpxchg-local.h>
18
Michal Simek4511ec12009-03-27 14:25:37 +010019struct task_struct;
20struct thread_info;
21
22extern struct task_struct *_switch_to(struct thread_info *prev,
23 struct thread_info *next);
24
25#define switch_to(prev, next, last) \
26 do { \
27 (last) = _switch_to(task_thread_info(prev), \
28 task_thread_info(next)); \
29 } while (0)
30
31#define smp_read_barrier_depends() do {} while (0)
32#define read_barrier_depends() do {} while (0)
33
34#define nop() asm volatile ("nop")
35#define mb() barrier()
36#define rmb() mb()
37#define wmb() mb()
38#define set_mb(var, value) do { var = value; mb(); } while (0)
39#define set_wmb(var, value) do { var = value; wmb(); } while (0)
40
41#define smp_mb() mb()
42#define smp_rmb() rmb()
43#define smp_wmb() wmb()
44
45void show_trace(struct task_struct *task, unsigned long *stack);
46void __bad_xchg(volatile void *ptr, int size);
47
48static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
49 int size)
50{
51 unsigned long ret;
52 unsigned long flags;
53
54 switch (size) {
55 case 1:
56 local_irq_save(flags);
57 ret = *(volatile unsigned char *)ptr;
58 *(volatile unsigned char *)ptr = x;
59 local_irq_restore(flags);
60 break;
61
62 case 4:
63 local_irq_save(flags);
64 ret = *(volatile unsigned long *)ptr;
65 *(volatile unsigned long *)ptr = x;
66 local_irq_restore(flags);
67 break;
68 default:
69 __bad_xchg(ptr, size), ret = 0;
70 break;
71 }
72
73 return ret;
74}
75
76void disable_hlt(void);
77void enable_hlt(void);
78void default_idle(void);
79
80#define xchg(ptr, x) \
81 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
82
83void free_init_pages(char *what, unsigned long begin, unsigned long end);
84void free_initmem(void);
85extern char *klimit;
86extern void ret_from_fork(void);
87
88#ifdef CONFIG_DEBUG_FS
89extern struct dentry *of_debugfs_root;
90#endif
91
92#define arch_align_stack(x) (x)
93
94#endif /* _ASM_MICROBLAZE_SYSTEM_H */