blob: e6a2284571dcfc46646582d4a5327e1797887011 [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>
John Linne44171f2010-04-08 07:08:02 +000015#include <asm/cache.h>
Michal Simek4511ec12009-03-27 14:25:37 +010016
Remis Lima Baima0a584582009-06-18 19:55:33 +020017#include <asm-generic/cmpxchg.h>
18#include <asm-generic/cmpxchg-local.h>
19
Michal Simekbf2d8092009-12-10 12:07:02 +010020#define __ARCH_WANT_INTERRUPTS_ON_CTXSW
21
Michal Simek4511ec12009-03-27 14:25:37 +010022struct task_struct;
23struct thread_info;
24
25extern struct task_struct *_switch_to(struct thread_info *prev,
26 struct thread_info *next);
27
28#define switch_to(prev, next, last) \
29 do { \
30 (last) = _switch_to(task_thread_info(prev), \
31 task_thread_info(next)); \
32 } while (0)
33
34#define smp_read_barrier_depends() do {} while (0)
35#define read_barrier_depends() do {} while (0)
36
37#define nop() asm volatile ("nop")
38#define mb() barrier()
39#define rmb() mb()
40#define wmb() mb()
41#define set_mb(var, value) do { var = value; mb(); } while (0)
42#define set_wmb(var, value) do { var = value; wmb(); } while (0)
43
44#define smp_mb() mb()
45#define smp_rmb() rmb()
46#define smp_wmb() wmb()
47
Michal Simek4511ec12009-03-27 14:25:37 +010048void __bad_xchg(volatile void *ptr, int size);
49
50static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
51 int size)
52{
53 unsigned long ret;
54 unsigned long flags;
55
56 switch (size) {
57 case 1:
58 local_irq_save(flags);
59 ret = *(volatile unsigned char *)ptr;
60 *(volatile unsigned char *)ptr = x;
61 local_irq_restore(flags);
62 break;
63
64 case 4:
65 local_irq_save(flags);
66 ret = *(volatile unsigned long *)ptr;
67 *(volatile unsigned long *)ptr = x;
68 local_irq_restore(flags);
69 break;
70 default:
71 __bad_xchg(ptr, size), ret = 0;
72 break;
73 }
74
75 return ret;
76}
77
78void disable_hlt(void);
79void enable_hlt(void);
80void default_idle(void);
81
82#define xchg(ptr, x) \
83 ((__typeof__(*(ptr))) __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
84
85void free_init_pages(char *what, unsigned long begin, unsigned long end);
86void free_initmem(void);
87extern char *klimit;
88extern void ret_from_fork(void);
89
Michal Simeka84642a2010-01-14 17:03:49 +010090extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
91extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
92
Michal Simek4511ec12009-03-27 14:25:37 +010093#ifdef CONFIG_DEBUG_FS
94extern struct dentry *of_debugfs_root;
95#endif
96
97#define arch_align_stack(x) (x)
98
David S. Millere0e33282010-05-07 02:55:33 -070099/*
100 * MicroBlaze doesn't handle unaligned accesses in hardware.
101 *
102 * Based on this we force the IP header alignment in network drivers.
David S. Millere0e33282010-05-07 02:55:33 -0700103 */
104#define NET_IP_ALIGN 2
David S. Millere0e33282010-05-07 02:55:33 -0700105
Michal Simek4511ec12009-03-27 14:25:37 +0100106#endif /* _ASM_MICROBLAZE_SYSTEM_H */