aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm-powerpc/btext.h (renamed from include/asm-ppc64/btext.h)0
-rw-r--r--include/asm-powerpc/delay.h (renamed from include/asm-ppc64/delay.h)19
-rw-r--r--include/asm-powerpc/eeh.h (renamed from include/asm-ppc64/eeh.h)0
-rw-r--r--include/asm-powerpc/floppy.h (renamed from include/asm-ppc64/floppy.h)25
-rw-r--r--include/asm-powerpc/hvconsole.h (renamed from include/asm-ppc64/hvconsole.h)0
-rw-r--r--include/asm-powerpc/hvcserver.h (renamed from include/asm-ppc64/hvcserver.h)0
-rw-r--r--include/asm-powerpc/nvram.h (renamed from include/asm-ppc64/nvram.h)16
-rw-r--r--include/asm-powerpc/serial.h (renamed from include/asm-ppc64/serial.h)19
-rw-r--r--include/asm-ppc/nvram.h73
-rw-r--r--include/asm-ppc64/prom.h220
-rw-r--r--include/asm-ppc64/system.h310
11 files changed, 42 insertions, 640 deletions
diff --git a/include/asm-ppc64/btext.h b/include/asm-powerpc/btext.h
index 71cce36bc630..71cce36bc630 100644
--- a/include/asm-ppc64/btext.h
+++ b/include/asm-powerpc/btext.h
diff --git a/include/asm-ppc64/delay.h b/include/asm-powerpc/delay.h
index 05f198cf73d9..1492aa9ab716 100644
--- a/include/asm-ppc64/delay.h
+++ b/include/asm-powerpc/delay.h
@@ -1,5 +1,5 @@
1#ifndef _PPC64_DELAY_H 1#ifndef _ASM_POWERPC_DELAY_H
2#define _PPC64_DELAY_H 2#define _ASM_POWERPC_DELAY_H
3 3
4/* 4/*
5 * Copyright 1996, Paul Mackerras. 5 * Copyright 1996, Paul Mackerras.
@@ -15,10 +15,17 @@
15 15
16extern unsigned long tb_ticks_per_usec; 16extern unsigned long tb_ticks_per_usec;
17 17
18/* define these here to prevent circular dependencies */ 18#ifdef CONFIG_PPC64
19/* define these here to prevent circular dependencies */
20/* these instructions control the thread priority on multi-threaded cpus */
19#define __HMT_low() asm volatile("or 1,1,1") 21#define __HMT_low() asm volatile("or 1,1,1")
20#define __HMT_medium() asm volatile("or 2,2,2") 22#define __HMT_medium() asm volatile("or 2,2,2")
21#define __barrier() asm volatile("":::"memory") 23#else
24#define __HMT_low()
25#define __HMT_medium()
26#endif
27
28#define __barrier() asm volatile("" ::: "memory")
22 29
23static inline unsigned long __get_tb(void) 30static inline unsigned long __get_tb(void)
24{ 31{
@@ -32,7 +39,7 @@ static inline void __delay(unsigned long loops)
32{ 39{
33 unsigned long start = __get_tb(); 40 unsigned long start = __get_tb();
34 41
35 while((__get_tb()-start) < loops) 42 while((__get_tb() - start) < loops)
36 __HMT_low(); 43 __HMT_low();
37 __HMT_medium(); 44 __HMT_medium();
38 __barrier(); 45 __barrier();
@@ -45,4 +52,4 @@ static inline void udelay(unsigned long usecs)
45 __delay(loops); 52 __delay(loops);
46} 53}
47 54
48#endif /* _PPC64_DELAY_H */ 55#endif /* _ASM_POWERPC_DELAY_H */
diff --git a/include/asm-ppc64/eeh.h b/include/asm-powerpc/eeh.h
index 89f26ab31908..89f26ab31908 100644
--- a/include/asm-ppc64/eeh.h
+++ b/include/asm-powerpc/eeh.h
diff --git a/include/asm-ppc64/floppy.h b/include/asm-powerpc/floppy.h
index 5c497b588e54..64276a3f6153 100644
--- a/include/asm-ppc64/floppy.h
+++ b/include/asm-powerpc/floppy.h
@@ -7,22 +7,22 @@
7 * 7 *
8 * Copyright (C) 1995 8 * Copyright (C) 1995
9 */ 9 */
10#ifndef __ASM_PPC64_FLOPPY_H 10#ifndef __ASM_POWERPC_FLOPPY_H
11#define __ASM_PPC64_FLOPPY_H 11#define __ASM_POWERPC_FLOPPY_H
12 12
13#include <linux/config.h> 13#include <linux/config.h>
14#include <asm/machdep.h> 14#include <asm/machdep.h>
15 15
16#define fd_inb(port) inb_p(port) 16#define fd_inb(port) inb_p(port)
17#define fd_outb(value,port) outb_p(value,port) 17#define fd_outb(value,port) outb_p(value,port)
18 18
19#define fd_enable_dma() enable_dma(FLOPPY_DMA) 19#define fd_enable_dma() enable_dma(FLOPPY_DMA)
20#define fd_disable_dma() disable_dma(FLOPPY_DMA) 20#define fd_disable_dma() disable_dma(FLOPPY_DMA)
21#define fd_request_dma() request_dma(FLOPPY_DMA,"floppy") 21#define fd_request_dma() request_dma(FLOPPY_DMA, "floppy")
22#define fd_free_dma() free_dma(FLOPPY_DMA) 22#define fd_free_dma() free_dma(FLOPPY_DMA)
23#define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA) 23#define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA)
24#define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA,mode) 24#define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA, mode)
25#define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA,count) 25#define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA, count)
26#define fd_enable_irq() enable_irq(FLOPPY_IRQ) 26#define fd_enable_irq() enable_irq(FLOPPY_IRQ)
27#define fd_disable_irq() disable_irq(FLOPPY_IRQ) 27#define fd_disable_irq() disable_irq(FLOPPY_IRQ)
28#define fd_cacheflush(addr,size) /* nothing */ 28#define fd_cacheflush(addr,size) /* nothing */
@@ -35,10 +35,10 @@
35 35
36#include <linux/pci.h> 36#include <linux/pci.h>
37 37
38#define fd_dma_setup(addr,size,mode,io) ppc64_fd_dma_setup(addr,size,mode,io) 38#define fd_dma_setup(addr,size,mode,io) powerpc_fd_dma_setup(addr,size,mode,io)
39 39
40static __inline__ int 40static __inline__ int powerpc_fd_dma_setup(char *addr, unsigned long size,
41ppc64_fd_dma_setup(char *addr, unsigned long size, int mode, int io) 41 int mode, int io)
42{ 42{
43 static unsigned long prev_size; 43 static unsigned long prev_size;
44 static dma_addr_t bus_addr = 0; 44 static dma_addr_t bus_addr = 0;
@@ -55,9 +55,8 @@ ppc64_fd_dma_setup(char *addr, unsigned long size, int mode, int io)
55 bus_addr = 0; 55 bus_addr = 0;
56 } 56 }
57 57
58 if (!bus_addr) /* need to map it */ { 58 if (!bus_addr) /* need to map it */
59 bus_addr = pci_map_single(NULL, addr, size, dir); 59 bus_addr = pci_map_single(NULL, addr, size, dir);
60 }
61 60
62 /* remember this one as prev */ 61 /* remember this one as prev */
63 prev_addr = addr; 62 prev_addr = addr;
@@ -103,4 +102,4 @@ static int FDC2 = -1;
103 102
104#define EXTRA_FLOPPY_PARAMS 103#define EXTRA_FLOPPY_PARAMS
105 104
106#endif /* __ASM_PPC64_FLOPPY_H */ 105#endif /* __ASM_POWERPC_FLOPPY_H */
diff --git a/include/asm-ppc64/hvconsole.h b/include/asm-powerpc/hvconsole.h
index 6da93ce74dc0..6da93ce74dc0 100644
--- a/include/asm-ppc64/hvconsole.h
+++ b/include/asm-powerpc/hvconsole.h
diff --git a/include/asm-ppc64/hvcserver.h b/include/asm-powerpc/hvcserver.h
index aecba9665796..aecba9665796 100644
--- a/include/asm-ppc64/hvcserver.h
+++ b/include/asm-powerpc/hvcserver.h
diff --git a/include/asm-ppc64/nvram.h b/include/asm-powerpc/nvram.h
index def47d720d3d..1858244ced32 100644
--- a/include/asm-ppc64/nvram.h
+++ b/include/asm-powerpc/nvram.h
@@ -1,6 +1,5 @@
1/* 1/*
2 * PreP compliant NVRAM access 2 * NVRAM definitions and access functions.
3 * This needs to be updated for PPC64
4 * 3 *
5 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 5 * modify it under the terms of the GNU General Public License
@@ -8,8 +7,8 @@
8 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
9 */ 8 */
10 9
11#ifndef _PPC64_NVRAM_H 10#ifndef _ASM_POWERPC_NVRAM_H
12#define _PPC64_NVRAM_H 11#define _ASM_POWERPC_NVRAM_H
13 12
14#define NVRW_CNT 0x20 13#define NVRW_CNT 0x20
15#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */ 14#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
@@ -88,7 +87,11 @@ extern u8 pmac_xpram_read(int xpaddr);
88extern void pmac_xpram_write(int xpaddr, u8 data); 87extern void pmac_xpram_write(int xpaddr, u8 data);
89 88
90/* Synchronize NVRAM */ 89/* Synchronize NVRAM */
91extern int nvram_sync(void); 90extern void nvram_sync(void);
91
92/* Normal access to NVRAM */
93extern unsigned char nvram_read_byte(int i);
94extern void nvram_write_byte(unsigned char c, int i);
92 95
93/* Some offsets in XPRAM */ 96/* Some offsets in XPRAM */
94#define PMAC_XPRAM_MACHINE_LOC 0xe4 97#define PMAC_XPRAM_MACHINE_LOC 0xe4
@@ -112,5 +115,6 @@ struct pmac_machine_location {
112 _IOWR('p', 0x40, int) 115 _IOWR('p', 0x40, int)
113 116
114#define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */ 117#define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
118#define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
115 119
116#endif /* _PPC64_NVRAM_H */ 120#endif /* _ASM_POWERPC_NVRAM_H */
diff --git a/include/asm-ppc64/serial.h b/include/asm-powerpc/serial.h
index d6bcb79b7d7b..b273d630b32f 100644
--- a/include/asm-ppc64/serial.h
+++ b/include/asm-powerpc/serial.h
@@ -1,21 +1,16 @@
1/* 1/*
2 * include/asm-ppc64/serial.h
3 */
4#ifndef _PPC64_SERIAL_H
5#define _PPC64_SERIAL_H
6
7/*
8 * This assumes you have a 1.8432 MHz clock for your UART.
9 *
10 * It'd be nice if someone built a serial card with a 24.576 MHz
11 * clock, since the 16550A is capable of handling a top speed of 1.5
12 * megabits/second; but this requires the faster clock.
13 *
14 * This program is free software; you can redistribute it and/or 2 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License 3 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 4 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version. 5 * 2 of the License, or (at your option) any later version.
18 */ 6 */
7#ifndef _ASM_POWERPC_SERIAL_H
8#define _ASM_POWERPC_SERIAL_H
9
10/*
11 * Serial ports are not listed here, because they are discovered
12 * through the device tree.
13 */
19 14
20/* Default baud base if not found in device-tree */ 15/* Default baud base if not found in device-tree */
21#define BASE_BAUD ( 1843200 / 16 ) 16#define BASE_BAUD ( 1843200 / 16 )
diff --git a/include/asm-ppc/nvram.h b/include/asm-ppc/nvram.h
deleted file mode 100644
index 31ef16e3fc4f..000000000000
--- a/include/asm-ppc/nvram.h
+++ /dev/null
@@ -1,73 +0,0 @@
1/*
2 * PreP compliant NVRAM access
3 */
4
5#ifdef __KERNEL__
6#ifndef _PPC_NVRAM_H
7#define _PPC_NVRAM_H
8
9#define NVRAM_AS0 0x74
10#define NVRAM_AS1 0x75
11#define NVRAM_DATA 0x77
12
13
14/* RTC Offsets */
15
16#define MOTO_RTC_SECONDS 0x1FF9
17#define MOTO_RTC_MINUTES 0x1FFA
18#define MOTO_RTC_HOURS 0x1FFB
19#define MOTO_RTC_DAY_OF_WEEK 0x1FFC
20#define MOTO_RTC_DAY_OF_MONTH 0x1FFD
21#define MOTO_RTC_MONTH 0x1FFE
22#define MOTO_RTC_YEAR 0x1FFF
23#define MOTO_RTC_CONTROLA 0x1FF8
24#define MOTO_RTC_CONTROLB 0x1FF9
25
26/* PowerMac specific nvram stuffs */
27
28enum {
29 pmac_nvram_OF, /* Open Firmware partition */
30 pmac_nvram_XPRAM, /* MacOS XPRAM partition */
31 pmac_nvram_NR /* MacOS Name Registry partition */
32};
33
34/* Return partition offset in nvram */
35extern int pmac_get_partition(int partition);
36
37/* Direct access to XPRAM on PowerMacs */
38extern u8 pmac_xpram_read(int xpaddr);
39extern void pmac_xpram_write(int xpaddr, u8 data);
40
41/* Synchronize NVRAM */
42extern void nvram_sync(void);
43
44/* Normal access to NVRAM */
45extern unsigned char nvram_read_byte(int i);
46extern void nvram_write_byte(unsigned char c, int i);
47
48/* Some offsets in XPRAM */
49#define PMAC_XPRAM_MACHINE_LOC 0xe4
50#define PMAC_XPRAM_SOUND_VOLUME 0x08
51
52/* Machine location structure in PowerMac XPRAM */
53struct pmac_machine_location {
54 unsigned int latitude; /* 2+30 bit Fractional number */
55 unsigned int longitude; /* 2+30 bit Fractional number */
56 unsigned int delta; /* mix of GMT delta and DLS */
57};
58
59/*
60 * /dev/nvram ioctls
61 *
62 * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
63 * definitely obsolete. Do not use it if you can avoid it
64 */
65
66#define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
67 _IOWR('p', 0x40, int)
68
69#define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
70#define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
71
72#endif
73#endif /* __KERNEL__ */
diff --git a/include/asm-ppc64/prom.h b/include/asm-ppc64/prom.h
deleted file mode 100644
index ddfe186589fa..000000000000
--- a/include/asm-ppc64/prom.h
+++ /dev/null
@@ -1,220 +0,0 @@
1#ifndef _PPC64_PROM_H
2#define _PPC64_PROM_H
3
4/*
5 * Definitions for talking to the Open Firmware PROM on
6 * Power Macintosh computers.
7 *
8 * Copyright (C) 1996 Paul Mackerras.
9 *
10 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17#include <linux/config.h>
18#include <linux/proc_fs.h>
19#include <asm/atomic.h>
20
21#define PTRRELOC(x) ((typeof(x))((unsigned long)(x) - offset))
22#define PTRUNRELOC(x) ((typeof(x))((unsigned long)(x) + offset))
23#define RELOC(x) (*PTRRELOC(&(x)))
24
25/* Definitions used by the flattened device tree */
26#define OF_DT_HEADER 0xd00dfeed /* marker */
27#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
28#define OF_DT_END_NODE 0x2 /* End node */
29#define OF_DT_PROP 0x3 /* Property: name off, size,
30 * content */
31#define OF_DT_NOP 0x4 /* nop */
32#define OF_DT_END 0x9
33
34#define OF_DT_VERSION 0x10
35
36/*
37 * This is what gets passed to the kernel by prom_init or kexec
38 *
39 * The dt struct contains the device tree structure, full pathes and
40 * property contents. The dt strings contain a separate block with just
41 * the strings for the property names, and is fully page aligned and
42 * self contained in a page, so that it can be kept around by the kernel,
43 * each property name appears only once in this page (cheap compression)
44 *
45 * the mem_rsvmap contains a map of reserved ranges of physical memory,
46 * passing it here instead of in the device-tree itself greatly simplifies
47 * the job of everybody. It's just a list of u64 pairs (base/size) that
48 * ends when size is 0
49 */
50struct boot_param_header
51{
52 u32 magic; /* magic word OF_DT_HEADER */
53 u32 totalsize; /* total size of DT block */
54 u32 off_dt_struct; /* offset to structure */
55 u32 off_dt_strings; /* offset to strings */
56 u32 off_mem_rsvmap; /* offset to memory reserve map */
57 u32 version; /* format version */
58 u32 last_comp_version; /* last compatible version */
59 /* version 2 fields below */
60 u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
61 /* version 3 fields below */
62 u32 dt_strings_size; /* size of the DT strings block */
63};
64
65
66
67typedef u32 phandle;
68typedef u32 ihandle;
69
70struct address_range {
71 unsigned long space;
72 unsigned long address;
73 unsigned long size;
74};
75
76struct interrupt_info {
77 int line;
78 int sense; /* +ve/-ve logic, edge or level, etc. */
79};
80
81struct pci_address {
82 u32 a_hi;
83 u32 a_mid;
84 u32 a_lo;
85};
86
87struct isa_address {
88 u32 a_hi;
89 u32 a_lo;
90};
91
92struct isa_range {
93 struct isa_address isa_addr;
94 struct pci_address pci_addr;
95 unsigned int size;
96};
97
98struct reg_property {
99 unsigned long address;
100 unsigned long size;
101};
102
103struct reg_property32 {
104 unsigned int address;
105 unsigned int size;
106};
107
108struct reg_property64 {
109 unsigned long address;
110 unsigned long size;
111};
112
113struct property {
114 char *name;
115 int length;
116 unsigned char *value;
117 struct property *next;
118};
119
120struct device_node {
121 char *name;
122 char *type;
123 phandle node;
124 phandle linux_phandle;
125 int n_addrs;
126 struct address_range *addrs;
127 int n_intrs;
128 struct interrupt_info *intrs;
129 char *full_name;
130
131 struct property *properties;
132 struct device_node *parent;
133 struct device_node *child;
134 struct device_node *sibling;
135 struct device_node *next; /* next device of same type */
136 struct device_node *allnext; /* next in list of all nodes */
137 struct proc_dir_entry *pde; /* this node's proc directory */
138 struct kref kref;
139 unsigned long _flags;
140 void *data;
141#ifdef CONFIG_PPC_ISERIES
142 struct list_head Device_List;
143#endif
144};
145
146extern struct device_node *of_chosen;
147
148/* flag descriptions */
149#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
150
151#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
152#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
153
154/*
155 * Until 32-bit ppc can add proc_dir_entries to its device_node
156 * definition, we cannot refer to pde, name_link, and addr_link
157 * in arch-independent code.
158 */
159#define HAVE_ARCH_DEVTREE_FIXUPS
160
161static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
162{
163 dn->pde = de;
164}
165
166
167/* OBSOLETE: Old stlye node lookup */
168extern struct device_node *find_devices(const char *name);
169extern struct device_node *find_type_devices(const char *type);
170extern struct device_node *find_path_device(const char *path);
171extern struct device_node *find_compatible_devices(const char *type,
172 const char *compat);
173extern struct device_node *find_all_nodes(void);
174
175/* New style node lookup */
176extern struct device_node *of_find_node_by_name(struct device_node *from,
177 const char *name);
178extern struct device_node *of_find_node_by_type(struct device_node *from,
179 const char *type);
180extern struct device_node *of_find_compatible_node(struct device_node *from,
181 const char *type, const char *compat);
182extern struct device_node *of_find_node_by_path(const char *path);
183extern struct device_node *of_find_node_by_phandle(phandle handle);
184extern struct device_node *of_find_all_nodes(struct device_node *prev);
185extern struct device_node *of_get_parent(const struct device_node *node);
186extern struct device_node *of_get_next_child(const struct device_node *node,
187 struct device_node *prev);
188extern struct device_node *of_node_get(struct device_node *node);
189extern void of_node_put(struct device_node *node);
190
191/* For scanning the flat device-tree at boot time */
192int __init of_scan_flat_dt(int (*it)(unsigned long node,
193 const char *uname, int depth,
194 void *data),
195 void *data);
196void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
197 unsigned long *size);
198
199/* For updating the device tree at runtime */
200extern void of_attach_node(struct device_node *);
201extern void of_detach_node(const struct device_node *);
202
203/* Other Prototypes */
204extern unsigned long prom_init(unsigned long, unsigned long, unsigned long,
205 unsigned long, unsigned long);
206extern void finish_device_tree(void);
207extern void unflatten_device_tree(void);
208extern void early_init_devtree(void *);
209extern int device_is_compatible(struct device_node *device, const char *);
210extern int machine_is_compatible(const char *compat);
211extern unsigned char *get_property(struct device_node *node, const char *name,
212 int *lenp);
213extern void print_properties(struct device_node *node);
214extern int prom_n_addr_cells(struct device_node* np);
215extern int prom_n_size_cells(struct device_node* np);
216extern int prom_n_intr_cells(struct device_node* np);
217extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
218extern int prom_add_property(struct device_node* np, struct property* prop);
219
220#endif /* _PPC64_PROM_H */
diff --git a/include/asm-ppc64/system.h b/include/asm-ppc64/system.h
deleted file mode 100644
index bf9a6aba19c9..000000000000
--- a/include/asm-ppc64/system.h
+++ /dev/null
@@ -1,310 +0,0 @@
1#ifndef __PPC64_SYSTEM_H
2#define __PPC64_SYSTEM_H
3
4/*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#include <linux/config.h>
12#include <linux/compiler.h>
13#include <asm/page.h>
14#include <asm/processor.h>
15#include <asm/hw_irq.h>
16#include <asm/synch.h>
17
18/*
19 * Memory barrier.
20 * The sync instruction guarantees that all memory accesses initiated
21 * by this processor have been performed (with respect to all other
22 * mechanisms that access memory). The eieio instruction is a barrier
23 * providing an ordering (separately) for (a) cacheable stores and (b)
24 * loads and stores to non-cacheable memory (e.g. I/O devices).
25 *
26 * mb() prevents loads and stores being reordered across this point.
27 * rmb() prevents loads being reordered across this point.
28 * wmb() prevents stores being reordered across this point.
29 * read_barrier_depends() prevents data-dependent loads being reordered
30 * across this point (nop on PPC).
31 *
32 * We have to use the sync instructions for mb(), since lwsync doesn't
33 * order loads with respect to previous stores. Lwsync is fine for
34 * rmb(), though.
35 * For wmb(), we use sync since wmb is used in drivers to order
36 * stores to system memory with respect to writes to the device.
37 * However, smp_wmb() can be a lighter-weight eieio barrier on
38 * SMP since it is only used to order updates to system memory.
39 */
40#define mb() __asm__ __volatile__ ("sync" : : : "memory")
41#define rmb() __asm__ __volatile__ ("lwsync" : : : "memory")
42#define wmb() __asm__ __volatile__ ("sync" : : : "memory")
43#define read_barrier_depends() do { } while(0)
44
45#define set_mb(var, value) do { var = value; smp_mb(); } while (0)
46#define set_wmb(var, value) do { var = value; smp_wmb(); } while (0)
47
48#ifdef CONFIG_SMP
49#define smp_mb() mb()
50#define smp_rmb() rmb()
51#define smp_wmb() eieio()
52#define smp_read_barrier_depends() read_barrier_depends()
53#else
54#define smp_mb() __asm__ __volatile__("": : :"memory")
55#define smp_rmb() __asm__ __volatile__("": : :"memory")
56#define smp_wmb() __asm__ __volatile__("": : :"memory")
57#define smp_read_barrier_depends() do { } while(0)
58#endif /* CONFIG_SMP */
59
60#ifdef __KERNEL__
61struct task_struct;
62struct pt_regs;
63
64#ifdef CONFIG_DEBUGGER
65
66extern int (*__debugger)(struct pt_regs *regs);
67extern int (*__debugger_ipi)(struct pt_regs *regs);
68extern int (*__debugger_bpt)(struct pt_regs *regs);
69extern int (*__debugger_sstep)(struct pt_regs *regs);
70extern int (*__debugger_iabr_match)(struct pt_regs *regs);
71extern int (*__debugger_dabr_match)(struct pt_regs *regs);
72extern int (*__debugger_fault_handler)(struct pt_regs *regs);
73
74#define DEBUGGER_BOILERPLATE(__NAME) \
75static inline int __NAME(struct pt_regs *regs) \
76{ \
77 if (unlikely(__ ## __NAME)) \
78 return __ ## __NAME(regs); \
79 return 0; \
80}
81
82DEBUGGER_BOILERPLATE(debugger)
83DEBUGGER_BOILERPLATE(debugger_ipi)
84DEBUGGER_BOILERPLATE(debugger_bpt)
85DEBUGGER_BOILERPLATE(debugger_sstep)
86DEBUGGER_BOILERPLATE(debugger_iabr_match)
87DEBUGGER_BOILERPLATE(debugger_dabr_match)
88DEBUGGER_BOILERPLATE(debugger_fault_handler)
89
90#ifdef CONFIG_XMON
91extern void xmon_init(int enable);
92#endif
93
94#else
95static inline int debugger(struct pt_regs *regs) { return 0; }
96static inline int debugger_ipi(struct pt_regs *regs) { return 0; }
97static inline int debugger_bpt(struct pt_regs *regs) { return 0; }
98static inline int debugger_sstep(struct pt_regs *regs) { return 0; }
99static inline int debugger_iabr_match(struct pt_regs *regs) { return 0; }
100static inline int debugger_dabr_match(struct pt_regs *regs) { return 0; }
101static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
102#endif
103
104extern int set_dabr(unsigned long dabr);
105extern void _exception(int signr, struct pt_regs *regs, int code,
106 unsigned long addr);
107extern int fix_alignment(struct pt_regs *regs);
108extern void bad_page_fault(struct pt_regs *regs, unsigned long address,
109 int sig);
110extern void show_regs(struct pt_regs * regs);
111extern void low_hash_fault(struct pt_regs *regs, unsigned long address);
112extern int die(const char *str, struct pt_regs *regs, long err);
113
114extern int _get_PVR(void);
115extern void giveup_fpu(struct task_struct *);
116extern void disable_kernel_fp(void);
117extern void flush_fp_to_thread(struct task_struct *);
118extern void enable_kernel_fp(void);
119extern void giveup_altivec(struct task_struct *);
120extern void disable_kernel_altivec(void);
121extern void enable_kernel_altivec(void);
122extern int emulate_altivec(struct pt_regs *);
123extern void cvt_fd(float *from, double *to, struct thread_struct *thread);
124extern void cvt_df(double *from, float *to, struct thread_struct *thread);
125
126#ifdef CONFIG_ALTIVEC
127extern void flush_altivec_to_thread(struct task_struct *);
128#else
129static inline void flush_altivec_to_thread(struct task_struct *t)
130{
131}
132#endif
133
134static inline void flush_spe_to_thread(struct task_struct *t)
135{
136}
137
138extern int mem_init_done; /* set on boot once kmalloc can be called */
139extern unsigned long memory_limit;
140
141/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */
142extern unsigned char e2a(unsigned char);
143
144extern struct task_struct *__switch_to(struct task_struct *,
145 struct task_struct *);
146#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
147
148struct thread_struct;
149extern struct task_struct * _switch(struct thread_struct *prev,
150 struct thread_struct *next);
151
152extern unsigned long klimit;
153
154extern int powersave_nap; /* set if nap mode can be used in idle loop */
155
156/*
157 * Atomic exchange
158 *
159 * Changes the memory location '*ptr' to be val and returns
160 * the previous value stored there.
161 *
162 * Inline asm pulled from arch/ppc/kernel/misc.S so ppc64
163 * is more like most of the other architectures.
164 */
165static __inline__ unsigned long
166__xchg_u32(volatile unsigned int *m, unsigned long val)
167{
168 unsigned long dummy;
169
170 __asm__ __volatile__(
171 EIEIO_ON_SMP
172"1: lwarx %0,0,%3 # __xchg_u32\n\
173 stwcx. %2,0,%3\n\
1742: bne- 1b"
175 ISYNC_ON_SMP
176 : "=&r" (dummy), "=m" (*m)
177 : "r" (val), "r" (m)
178 : "cc", "memory");
179
180 return (dummy);
181}
182
183static __inline__ unsigned long
184__xchg_u64(volatile long *m, unsigned long val)
185{
186 unsigned long dummy;
187
188 __asm__ __volatile__(
189 EIEIO_ON_SMP
190"1: ldarx %0,0,%3 # __xchg_u64\n\
191 stdcx. %2,0,%3\n\
1922: bne- 1b"
193 ISYNC_ON_SMP
194 : "=&r" (dummy), "=m" (*m)
195 : "r" (val), "r" (m)
196 : "cc", "memory");
197
198 return (dummy);
199}
200
201/*
202 * This function doesn't exist, so you'll get a linker error
203 * if something tries to do an invalid xchg().
204 */
205extern void __xchg_called_with_bad_pointer(void);
206
207static __inline__ unsigned long
208__xchg(volatile void *ptr, unsigned long x, unsigned int size)
209{
210 switch (size) {
211 case 4:
212 return __xchg_u32(ptr, x);
213 case 8:
214 return __xchg_u64(ptr, x);
215 }
216 __xchg_called_with_bad_pointer();
217 return x;
218}
219
220#define xchg(ptr,x) \
221 ({ \
222 __typeof__(*(ptr)) _x_ = (x); \
223 (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \
224 })
225
226#define tas(ptr) (xchg((ptr),1))
227
228#define __HAVE_ARCH_CMPXCHG 1
229
230static __inline__ unsigned long
231__cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new)
232{
233 unsigned int prev;
234
235 __asm__ __volatile__ (
236 EIEIO_ON_SMP
237"1: lwarx %0,0,%2 # __cmpxchg_u32\n\
238 cmpw 0,%0,%3\n\
239 bne- 2f\n\
240 stwcx. %4,0,%2\n\
241 bne- 1b"
242 ISYNC_ON_SMP
243 "\n\
2442:"
245 : "=&r" (prev), "=m" (*p)
246 : "r" (p), "r" (old), "r" (new), "m" (*p)
247 : "cc", "memory");
248
249 return prev;
250}
251
252static __inline__ unsigned long
253__cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new)
254{
255 unsigned long prev;
256
257 __asm__ __volatile__ (
258 EIEIO_ON_SMP
259"1: ldarx %0,0,%2 # __cmpxchg_u64\n\
260 cmpd 0,%0,%3\n\
261 bne- 2f\n\
262 stdcx. %4,0,%2\n\
263 bne- 1b"
264 ISYNC_ON_SMP
265 "\n\
2662:"
267 : "=&r" (prev), "=m" (*p)
268 : "r" (p), "r" (old), "r" (new), "m" (*p)
269 : "cc", "memory");
270
271 return prev;
272}
273
274/* This function doesn't exist, so you'll get a linker error
275 if something tries to do an invalid cmpxchg(). */
276extern void __cmpxchg_called_with_bad_pointer(void);
277
278static __inline__ unsigned long
279__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,
280 unsigned int size)
281{
282 switch (size) {
283 case 4:
284 return __cmpxchg_u32(ptr, old, new);
285 case 8:
286 return __cmpxchg_u64(ptr, old, new);
287 }
288 __cmpxchg_called_with_bad_pointer();
289 return old;
290}
291
292#define cmpxchg(ptr,o,n)\
293 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
294 (unsigned long)(n),sizeof(*(ptr))))
295
296/*
297 * We handle most unaligned accesses in hardware. On the other hand
298 * unaligned DMA can be very expensive on some ppc64 IO chips (it does
299 * powers of 2 writes until it reaches sufficient alignment).
300 *
301 * Based on this we disable the IP header alignment in network drivers.
302 */
303#define NET_IP_ALIGN 0
304
305#define arch_align_stack(x) (x)
306
307extern unsigned long reloc_offset(void);
308
309#endif /* __KERNEL__ */
310#endif