1 /*
2  *
3  * This file is subject to the terms and conditions of the GNU General Public
4  * License.  See the file "COPYING" in the main directory of this archive
5  * for more details.
6  *
7  * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All rights reserved.
8  */
9 
10 #ifndef _ASM_IA64_SN_FETCHOP_H
11 #define _ASM_IA64_SN_FETCHOP_H
12 
13 #include <linux/config.h>
14 
15 #define FETCHOP_BASENAME	"sgi_fetchop"
16 #define FETCHOP_FULLNAME	"/dev/sgi_fetchop"
17 
18 
19 
20 #define FETCHOP_VAR_SIZE 64 /* 64 byte per fetchop variable */
21 
22 #define FETCHOP_LOAD		0
23 #define FETCHOP_INCREMENT	8
24 #define FETCHOP_DECREMENT	16
25 #define FETCHOP_CLEAR		24
26 
27 #define FETCHOP_STORE		0
28 #define FETCHOP_AND		24
29 #define FETCHOP_OR		32
30 
31 #define FETCHOP_CLEAR_CACHE	56
32 
33 #define FETCHOP_LOAD_OP(addr, op) ( \
34          *(volatile long *)((char*) (addr) + (op)))
35 
36 #define FETCHOP_STORE_OP(addr, op, x) ( \
37          *(volatile long *)((char*) (addr) + (op)) = (long) (x))
38 
39 #ifdef __KERNEL__
40 
41 /*
42  * Convert a region 6 (kaddr) address to the address of the fetchop variable
43  */
44 #define FETCHOP_KADDR_TO_MSPEC_ADDR(kaddr)	TO_MSPEC(kaddr)
45 
46 
47 /*
48  * Each Atomic Memory Operation (AMO formerly known as fetchop)
49  * variable is 64 bytes long.  The first 8 bytes are used.  The
50  * remaining 56 bytes are unaddressable due to the operation taking
51  * that portion of the address.
52  *
53  * NOTE: The AMO_t _MUST_ be placed in either the first or second half
54  * of the cache line.  The cache line _MUST NOT_ be used for anything
55  * other than additional AMO_t entries.  This is because there are two
56  * addresses which reference the same physical cache line.  One will
57  * be a cached entry with the memory type bits all set.  This address
58  * may be loaded into processor cache.  The AMO_t will be referenced
59  * uncached via the memory special memory type.  If any portion of the
60  * cached cache-line is modified, when that line is flushed, it will
61  * overwrite the uncached value in physical memory and lead to
62  * inconsistency.
63  */
64 typedef struct {
65         u64 variable;
66         u64 unused[7];
67 } AMO_t;
68 
69 
70 /*
71  * The following APIs are externalized to the kernel to allocate/free pages of
72  * fetchop variables.
73  *	fetchop_kalloc_page	- Allocate/initialize 1 fetchop page on the
74  *				  specified cnode.
75  *	fetchop_kfree_page	- Free a previously allocated fetchop page
76  */
77 
78 unsigned long fetchop_kalloc_page(int nid);
79 void fetchop_kfree_page(unsigned long maddr);
80 
81 
82 #endif /* __KERNEL__ */
83 
84 #endif /* _ASM_IA64_SN_FETCHOP_H */
85 
86