File: /usr/src/linux/include/asm-ia64/sn/sgi.h
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) 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2000 by Jack Steiner (steiner@sgi.com)
9 */
10
11
12 #ifndef _ASM_SN_SGI_H
13 #define _ASM_SN_SGI_H
14
15 #include <linux/config.h>
16
17 #include <asm/sn/types.h>
18 #include <asm/uaccess.h> /* for copy_??_user */
19 #include <linux/mm.h>
20 #include <linux/devfs_fs_kernel.h>
21
22 // This devfs stuff needs a better home .....
23
24 struct directory_type
25 {
26 struct devfs_entry *first;
27 struct devfs_entry *last;
28 unsigned int num_removable;
29 };
30
31 struct file_type
32 {
33 unsigned long size;
34 };
35
36 struct device_type
37 {
38 unsigned short major;
39 unsigned short minor;
40 };
41
42 struct fcb_type /* File, char, block type */
43 {
44 uid_t default_uid;
45 gid_t default_gid;
46 void *ops;
47 union
48 {
49 struct file_type file;
50 struct device_type device;
51 }
52 u;
53 unsigned char auto_owner:1;
54 unsigned char aopen_notify:1;
55 unsigned char removable:1; /* Belongs in device_type, but save space */
56 unsigned char open:1; /* Not entirely correct */
57 };
58
59 struct symlink_type
60 {
61 unsigned int length; /* Not including the NULL-termimator */
62 char *linkname; /* This is NULL-terminated */
63 };
64
65 struct fifo_type
66 {
67 uid_t uid;
68 gid_t gid;
69 };
70
71 struct devfs_entry
72 {
73 void *info;
74 union
75 {
76 struct directory_type dir;
77 struct fcb_type fcb;
78 struct symlink_type symlink;
79 struct fifo_type fifo;
80 }
81 u;
82 struct devfs_entry *prev; /* Previous entry in the parent directory */
83 struct devfs_entry *next; /* Next entry in the parent directory */
84 struct devfs_entry *parent; /* The parent directory */
85 struct devfs_entry *slave; /* Another entry to unregister */
86 struct devfs_inode *first_inode;
87 struct devfs_inode *last_inode;
88 umode_t mode;
89 unsigned short namelen; /* I think 64k+ filenames are a way off... */
90 unsigned char registered:1;
91 unsigned char show_unreg:1;
92 unsigned char hide:1;
93 unsigned char no_persistence /*:1*/;
94 char name[1]; /* This is just a dummy: the allocated array is
95 bigger. This is NULL-terminated */
96 };
97
98 #define MIN(_a,_b) ((_a)<(_b)?(_a):(_b))
99
100 typedef uint32_t app32_ptr_t; /* needed by edt.h */
101 typedef int64_t __psint_t; /* needed by klgraph.c */
102
103 typedef enum { B_FALSE, B_TRUE } boolean_t;
104
105 #define ctob(x) ((uint64_t)(x)*NBPC)
106 #define btoc(x) (((uint64_t)(x)+(NBPC-1))/NBPC)
107
108 typedef __psunsigned_t nic_data_t;
109
110
111 /*
112 ** Possible return values from graph routines.
113 */
114 typedef enum graph_error_e {
115 GRAPH_SUCCESS, /* 0 */
116 GRAPH_DUP, /* 1 */
117 GRAPH_NOT_FOUND, /* 2 */
118 GRAPH_BAD_PARAM, /* 3 */
119 GRAPH_HIT_LIMIT, /* 4 */
120 GRAPH_CANNOT_ALLOC, /* 5 */
121 GRAPH_ILLEGAL_REQUEST, /* 6 */
122 GRAPH_IN_USE /* 7 */
123 } graph_error_t;
124
125 #define KM_SLEEP 0x0000
126 #define KM_NOSLEEP 0x0001 /* needed by kmem_alloc_node(), kmem_zalloc()
127 * calls */
128 #define VM_NOSLEEP 0x0001 /* needed kmem_alloc_node(), kmem_zalloc_node
129 * calls */
130 #define XG_WIDGET_PART_NUM 0xC102 /* KONA/xt_regs.h XG_XT_PART_NUM_VALUE */
131
132 #ifndef TO_PHYS_MASK
133 #define TO_PHYS_MASK 0x0000000fffffffff
134 #endif
135
136 typedef uint64_t vhandl_t;
137
138
139 #ifndef NBPP
140 #define NBPP 4096
141 #endif
142
143 #ifndef D_MP
144 #define D_MP 1
145 #endif
146
147 #ifndef MAXDEVNAME
148 #define MAXDEVNAME 256
149 #endif
150
151 #ifndef NBPC
152 #define NBPC 0
153 #endif
154
155 #ifndef _PAGESZ
156 #define _PAGESZ 4096
157 #endif
158
159 typedef uint64_t mrlock_t; /* needed by devsupport.c */
160
161 #define HUB_PIO_CONVEYOR 0x1
162 #define CNODEID_NONE (cnodeid_t)-1
163 #define XTALK_PCI_PART_NUM "030-1275-"
164 #define kdebug 0
165
166
167 #define COPYIN(a, b, c) copy_from_user(b,a,c)
168 #define COPYOUT(a, b, c) copy_to_user(b,a,c)
169
170 #define kvtophys(x) (alenaddr_t) (x)
171 #define POFFMASK (NBPP - 1)
172 #define poff(X) ((__psunsigned_t)(X) & POFFMASK)
173
174 #define BZERO(a,b) memset(a, 0, b)
175
176 #define kern_malloc(x) kmalloc(x, GFP_KERNEL)
177 #define kern_free(x) kfree(x)
178
179 typedef cpuid_t cpu_cookie_t;
180 #define CPU_NONE -1
181
182 /*
183 * mutext support mapping
184 */
185
186 #define mutex_spinlock_init(s) spin_lock_init(s)
187 inline static unsigned long
188 mutex_spinlock(spinlock_t *sem) {
189 unsigned long flags = 0;
190 // spin_lock_irqsave(sem, flags);
191 spin_lock(sem);
192 return(flags);
193 }
194 // #define mutex_spinunlock(s,t) spin_unlock_irqrestore(s,t)
195 #define mutex_spinunlock(s,t) spin_unlock(s)
196
197
198 #define mutex_t struct semaphore
199 #define mutex_init(s) init_MUTEX(s)
200 #define mutex_init_locked(s) init_MUTEX_LOCKED(s)
201 #define mutex_lock(s) down(s)
202 #define mutex_unlock(s) up(s)
203
204 #define io_splock(s) mutex_spinlock(s)
205 #define io_spunlock(s,t) spin_unlock(s)
206
207 #define spin_lock_destroy(s)
208
209 #if defined(DISABLE_ASSERT)
210 #define ASSERT(expr)
211 #define ASSERT_ALWAYS(expr)
212 #else
213 #define ASSERT(expr) do { \
214 if(!(expr)) { \
215 printk( "Assertion [%s] failed! %s:%s(line=%d)\n",\
216 #expr,__FILE__,__FUNCTION__,__LINE__); \
217 panic("Assertion panic\n"); \
218 } } while(0)
219
220 #define ASSERT_ALWAYS(expr) do {\
221 if(!(expr)) { \
222 printk( "Assertion [%s] failed! %s:%s(line=%d)\n",\
223 #expr,__FILE__,__FUNCTION__,__LINE__); \
224 panic("Assertion always panic\n"); \
225 } } while(0)
226 #endif /* DISABLE_ASSERT */
227
228 #define PRINT_WARNING(x...) do { printk("WARNING : "); printk(x); } while(0)
229 #define PRINT_NOTICE(x...) do { printk("NOTICE : "); printk(x); } while(0)
230 #define PRINT_ALERT(x...) do { printk("ALERT : "); printk(x); } while(0)
231 #define PRINT_PANIC panic
232
233 #ifdef CONFIG_SMP
234 #define cpu_enabled(cpu) (test_bit(cpu, &cpu_online_map))
235 #else
236 #define cpu_enabled(cpu) (1)
237 #endif
238
239 #include <asm/sn/hack.h> /* for now */
240
241 #endif /* _ASM_SN_SGI_H */
242