revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / include / asm-mips / sn / klconfig.h
blob39ddb19104d6431fd7ec628822c996d928d2e8e7
1 /*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
6 * Derived from IRIX <sys/SN/klconfig.h>.
8 * Copyright (C) 1992 - 1997, 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 1999, 2000 by Ralf Baechle
11 #ifndef _ASM_SN_KLCONFIG_H
12 #define _ASM_SN_KLCONFIG_H
15 * The KLCONFIG structures store info about the various BOARDs found
16 * during Hardware Discovery. In addition, it stores info about the
17 * components found on the BOARDs.
21 * WARNING:
22 * Certain assembly language routines (notably xxxxx.s) in the IP27PROM
23 * will depend on the format of the data structures in this file. In
24 * most cases, rearranging the fields can seriously break things.
25 * Adding fields in the beginning or middle can also break things.
26 * Add fields if necessary, to the end of a struct in such a way
27 * that offsets of existing fields do not change.
30 #include <linux/types.h>
31 #include <asm/sn/types.h>
33 #if defined(CONFIG_SGI_IP27)
35 #include <asm/sn/sn0/addrs.h>
36 //#include <sys/SN/router.h>
37 // XXX Stolen from <sys/SN/router.h>:
38 #define MAX_ROUTER_PORTS (6) /* Max. number of ports on a router */
39 #include <asm/sn/fru.h>
40 //#include <sys/graph.h>
41 //#include <sys/xtalk/xbow.h>
43 #include <asm/sn/agent.h>
44 #include <asm/fw/arc/types.h>
45 #include <asm/fw/arc/hinv.h>
46 #endif /* CONFIG_SGI_IP27 */
48 typedef u64 nic_t;
50 #define KLCFGINFO_MAGIC 0xbeedbabe
52 typedef s32 klconf_off_t;
55 * Some IMPORTANT OFFSETS. These are the offsets on all NODES.
57 #define MAX_MODULE_ID 255
58 #define SIZE_PAD 4096 /* 4k padding for structures */
60 * 1 NODE brd, 2 Router brd (1 8p, 1 meta), 6 Widgets,
61 * 2 Midplanes assuming no pci card cages
63 #define MAX_SLOTS_PER_NODE (1 + 2 + 6 + 2)
65 /* XXX if each node is guranteed to have some memory */
67 #define MAX_PCI_DEVS 8
69 /* lboard_t->brd_flags fields */
70 /* All bits in this field are currently used. Try the pad fields if
71 you need more flag bits */
73 #define ENABLE_BOARD 0x01
74 #define FAILED_BOARD 0x02
75 #define DUPLICATE_BOARD 0x04 /* Boards like midplanes/routers which
76 are discovered twice. Use one of them */
77 #define VISITED_BOARD 0x08 /* Used for compact hub numbering. */
78 #define LOCAL_MASTER_IO6 0x10 /* master io6 for that node */
79 #define GLOBAL_MASTER_IO6 0x20
80 #define THIRD_NIC_PRESENT 0x40 /* for future use */
81 #define SECOND_NIC_PRESENT 0x80 /* addons like MIO are present */
83 /* klinfo->flags fields */
85 #define KLINFO_ENABLE 0x01 /* This component is enabled */
86 #define KLINFO_FAILED 0x02 /* This component failed */
87 #define KLINFO_DEVICE 0x04 /* This component is a device */
88 #define KLINFO_VISITED 0x08 /* This component has been visited */
89 #define KLINFO_CONTROLLER 0x10 /* This component is a device controller */
90 #define KLINFO_INSTALL 0x20 /* Install a driver */
91 #define KLINFO_HEADLESS 0x40 /* Headless (or hubless) component */
92 #define IS_CONSOLE_IOC3(i) ((((klinfo_t *)i)->flags) & KLINFO_INSTALL)
94 #define GB2 0x80000000
96 #define MAX_RSV_PTRS 32
98 /* Structures to manage various data storage areas */
99 /* The numbers must be contiguous since the array index i
100 is used in the code to allocate various areas.
103 #define BOARD_STRUCT 0
104 #define COMPONENT_STRUCT 1
105 #define ERRINFO_STRUCT 2
106 #define KLMALLOC_TYPE_MAX (ERRINFO_STRUCT + 1)
107 #define DEVICE_STRUCT 3
110 typedef struct console_s {
111 unsigned long uart_base;
112 unsigned long config_base;
113 unsigned long memory_base;
114 short baud;
115 short flag;
116 int type;
117 nasid_t nasid;
118 char wid;
119 char npci;
120 nic_t baseio_nic;
121 } console_t;
123 typedef struct klc_malloc_hdr {
124 klconf_off_t km_base;
125 klconf_off_t km_limit;
126 klconf_off_t km_current;
127 } klc_malloc_hdr_t;
129 /* Functions/macros needed to use this structure */
131 typedef struct kl_config_hdr {
132 u64 ch_magic; /* set this to KLCFGINFO_MAGIC */
133 u32 ch_version; /* structure version number */
134 klconf_off_t ch_malloc_hdr_off; /* offset of ch_malloc_hdr */
135 klconf_off_t ch_cons_off; /* offset of ch_cons */
136 klconf_off_t ch_board_info; /* the link list of boards */
137 console_t ch_cons_info; /* address info of the console */
138 klc_malloc_hdr_t ch_malloc_hdr[KLMALLOC_TYPE_MAX];
139 confidence_t ch_sw_belief; /* confidence that software is bad*/
140 confidence_t ch_sn0net_belief; /* confidence that sn0net is bad */
141 } kl_config_hdr_t;
144 #define KL_CONFIG_HDR(_nasid) ((kl_config_hdr_t *)(KLCONFIG_ADDR(_nasid)))
145 #define KL_CONFIG_INFO_OFFSET(_nasid) \
146 (KL_CONFIG_HDR(_nasid)->ch_board_info)
147 #define KL_CONFIG_INFO_SET_OFFSET(_nasid, _off) \
148 (KL_CONFIG_HDR(_nasid)->ch_board_info = (_off))
150 #define KL_CONFIG_INFO(_nasid) \
151 (lboard_t *)((KL_CONFIG_HDR(_nasid)->ch_board_info) ? \
152 NODE_OFFSET_TO_K1((_nasid), KL_CONFIG_HDR(_nasid)->ch_board_info) : \
154 #define KL_CONFIG_MAGIC(_nasid) (KL_CONFIG_HDR(_nasid)->ch_magic)
156 #define KL_CONFIG_CHECK_MAGIC(_nasid) \
157 (KL_CONFIG_HDR(_nasid)->ch_magic == KLCFGINFO_MAGIC)
159 #define KL_CONFIG_HDR_INIT_MAGIC(_nasid) \
160 (KL_CONFIG_HDR(_nasid)->ch_magic = KLCFGINFO_MAGIC)
162 /* --- New Macros for the changed kl_config_hdr_t structure --- */
164 #define PTR_CH_MALLOC_HDR(_k) ((klc_malloc_hdr_t *)\
165 ((unsigned long)_k + (_k->ch_malloc_hdr_off)))
167 #define KL_CONFIG_CH_MALLOC_HDR(_n) PTR_CH_MALLOC_HDR(KL_CONFIG_HDR(_n))
169 #define PTR_CH_CONS_INFO(_k) ((console_t *)\
170 ((unsigned long)_k + (_k->ch_cons_off)))
172 #define KL_CONFIG_CH_CONS_INFO(_n) PTR_CH_CONS_INFO(KL_CONFIG_HDR(_n))
174 /* ------------------------------------------------------------- */
176 #define KL_CONFIG_INFO_START(_nasid) \
177 (klconf_off_t)(KLCONFIG_OFFSET(_nasid) + sizeof(kl_config_hdr_t))
179 #define KL_CONFIG_BOARD_NASID(_brd) ((_brd)->brd_nasid)
180 #define KL_CONFIG_BOARD_SET_NEXT(_brd, _off) ((_brd)->brd_next = (_off))
182 #define KL_CONFIG_DUPLICATE_BOARD(_brd) ((_brd)->brd_flags & DUPLICATE_BOARD)
184 #define XBOW_PORT_TYPE_HUB(_xbowp, _link) \
185 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_HUB)
186 #define XBOW_PORT_TYPE_IO(_xbowp, _link) \
187 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_IO)
189 #define XBOW_PORT_IS_ENABLED(_xbowp, _link) \
190 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_flag & XBOW_PORT_ENABLE)
191 #define XBOW_PORT_NASID(_xbowp, _link) \
192 ((_xbowp)->xbow_port_info[(_link) - BASE_XBOW_PORT].port_nasid)
194 #define XBOW_PORT_IO 0x1
195 #define XBOW_PORT_HUB 0x2
196 #define XBOW_PORT_ENABLE 0x4
198 #define SN0_PORT_FENCE_SHFT 0
199 #define SN0_PORT_FENCE_MASK (1 << SN0_PORT_FENCE_SHFT)
202 * The KLCONFIG area is organized as a LINKED LIST of BOARDs. A BOARD
203 * can be either 'LOCAL' or 'REMOTE'. LOCAL means it is attached to
204 * the LOCAL/current NODE. REMOTE means it is attached to a different
205 * node.(TBD - Need a way to treat ROUTER boards.)
207 * There are 2 different structures to represent these boards -
208 * lboard - Local board, rboard - remote board. These 2 structures
209 * can be arbitrarily mixed in the LINKED LIST of BOARDs. (Refer
210 * Figure below). The first byte of the rboard or lboard structure
211 * is used to find out its type - no unions are used.
212 * If it is a lboard, then the config info of this board will be found
213 * on the local node. (LOCAL NODE BASE + offset value gives pointer to
214 * the structure.
215 * If it is a rboard, the local structure contains the node number
216 * and the offset of the beginning of the LINKED LIST on the remote node.
217 * The details of the hardware on a remote node can be built locally,
218 * if required, by reading the LINKED LIST on the remote node and
219 * ignoring all the rboards on that node.
221 * The local node uses the REMOTE NODE NUMBER + OFFSET to point to the
222 * First board info on the remote node. The remote node list is
223 * traversed as the local list, using the REMOTE BASE ADDRESS and not
224 * the local base address and ignoring all rboard values.
227 KLCONFIG
229 +------------+ +------------+ +------------+ +------------+
230 | lboard | +-->| lboard | +-->| rboard | +-->| lboard |
231 +------------+ | +------------+ | +------------+ | +------------+
232 | board info | | | board info | | |errinfo,bptr| | | board info |
233 +------------+ | +------------+ | +------------+ | +------------+
234 | offset |--+ | offset |--+ | offset |--+ |offset=NULL |
235 +------------+ +------------+ +------------+ +------------+
238 +------------+
239 | board info |
240 +------------+ +--------------------------------+
241 | compt 1 |------>| type, rev, diaginfo, size ... | (CPU)
242 +------------+ +--------------------------------+
243 | compt 2 |--+
244 +------------+ | +--------------------------------+
245 | ... | +--->| type, rev, diaginfo, size ... | (MEM_BANK)
246 +------------+ +--------------------------------+
247 | errinfo |--+
248 +------------+ | +--------------------------------+
249 +--->|r/l brd errinfo,compt err flags |
250 +--------------------------------+
253 * Each BOARD consists of COMPONENTs and the BOARD structure has
254 * pointers (offsets) to its COMPONENT structure.
255 * The COMPONENT structure has version info, size and speed info, revision,
256 * error info and the NIC info. This structure can accommodate any
257 * BOARD with arbitrary COMPONENT composition.
259 * The ERRORINFO part of each BOARD has error information
260 * that describes errors about the BOARD itself. It also has flags to
261 * indicate the COMPONENT(s) on the board that have errors. The error
262 * information specific to the COMPONENT is present in the respective
263 * COMPONENT structure.
265 * The ERRORINFO structure is also treated like a COMPONENT, ie. the
266 * BOARD has pointers(offset) to the ERRORINFO structure. The rboard
267 * structure also has a pointer to the ERRORINFO structure. This is
268 * the place to store ERRORINFO about a REMOTE NODE, if the HUB on
269 * that NODE is not working or if the REMOTE MEMORY is BAD. In cases where
270 * only the CPU of the REMOTE NODE is disabled, the ERRORINFO pointer can
271 * be a NODE NUMBER, REMOTE OFFSET combination, pointing to error info
272 * which is present on the REMOTE NODE.(TBD)
273 * REMOTE ERRINFO can be stored on any of the nearest nodes
274 * or on all the nearest nodes.(TBD)
275 * Like BOARD structures, REMOTE ERRINFO structures can be built locally
276 * using the rboard errinfo pointer.
278 * In order to get useful information from this Data organization, a set of
279 * interface routines are provided (TBD). The important thing to remember while
280 * manipulating the structures, is that, the NODE number information should
281 * be used. If the NODE is non-zero (remote) then each offset should
282 * be added to the REMOTE BASE ADDR else it should be added to the LOCAL BASE ADDR.
283 * This includes offsets for BOARDS, COMPONENTS and ERRORINFO.
285 * Note that these structures do not provide much info about connectivity.
286 * That info will be part of HWGRAPH, which is an extension of the cfg_t
287 * data structure. (ref IP27prom/cfg.h) It has to be extended to include
288 * the IO part of the Network(TBD).
290 * The data structures below define the above concepts.
294 * Values for CPU types
296 #define KL_CPU_R4000 0x1 /* Standard R4000 */
297 #define KL_CPU_TFP 0x2 /* TFP processor */
298 #define KL_CPU_R10000 0x3 /* R10000 (T5) */
299 #define KL_CPU_NONE (-1) /* no cpu present in slot */
302 * IP27 BOARD classes
305 #define KLCLASS_MASK 0xf0
306 #define KLCLASS_NONE 0x00
307 #define KLCLASS_NODE 0x10 /* CPU, Memory and HUB board */
308 #define KLCLASS_CPU KLCLASS_NODE
309 #define KLCLASS_IO 0x20 /* BaseIO, 4 ch SCSI, ethernet, FDDI
310 and the non-graphics widget boards */
311 #define KLCLASS_ROUTER 0x30 /* Router board */
312 #define KLCLASS_MIDPLANE 0x40 /* We need to treat this as a board
313 so that we can record error info */
314 #define KLCLASS_GFX 0x50 /* graphics boards */
316 #define KLCLASS_PSEUDO_GFX 0x60 /* HDTV type cards that use a gfx
317 * hw ifc to xtalk and are not gfx
318 * class for sw purposes */
320 #define KLCLASS_MAX 7 /* Bump this if a new CLASS is added */
321 #define KLTYPE_MAX 10 /* Bump this if a new CLASS is added */
323 #define KLCLASS_UNKNOWN 0xf0
325 #define KLCLASS(_x) ((_x) & KLCLASS_MASK)
328 * IP27 board types
331 #define KLTYPE_MASK 0x0f
332 #define KLTYPE_NONE 0x00
333 #define KLTYPE_EMPTY 0x00
335 #define KLTYPE_WEIRDCPU (KLCLASS_CPU | 0x0)
336 #define KLTYPE_IP27 (KLCLASS_CPU | 0x1) /* 2 CPUs(R10K) per board */
338 #define KLTYPE_WEIRDIO (KLCLASS_IO | 0x0)
339 #define KLTYPE_BASEIO (KLCLASS_IO | 0x1) /* IOC3, SuperIO, Bridge, SCSI */
340 #define KLTYPE_IO6 KLTYPE_BASEIO /* Additional name */
341 #define KLTYPE_4CHSCSI (KLCLASS_IO | 0x2)
342 #define KLTYPE_MSCSI KLTYPE_4CHSCSI /* Additional name */
343 #define KLTYPE_ETHERNET (KLCLASS_IO | 0x3)
344 #define KLTYPE_MENET KLTYPE_ETHERNET /* Additional name */
345 #define KLTYPE_FDDI (KLCLASS_IO | 0x4)
346 #define KLTYPE_UNUSED (KLCLASS_IO | 0x5) /* XXX UNUSED */
347 #define KLTYPE_HAROLD (KLCLASS_IO | 0x6) /* PCI SHOE BOX */
348 #define KLTYPE_PCI KLTYPE_HAROLD
349 #define KLTYPE_VME (KLCLASS_IO | 0x7) /* Any 3rd party VME card */
350 #define KLTYPE_MIO (KLCLASS_IO | 0x8)
351 #define KLTYPE_FC (KLCLASS_IO | 0x9)
352 #define KLTYPE_LINC (KLCLASS_IO | 0xA)
353 #define KLTYPE_TPU (KLCLASS_IO | 0xB) /* Tensor Processing Unit */
354 #define KLTYPE_GSN_A (KLCLASS_IO | 0xC) /* Main GSN board */
355 #define KLTYPE_GSN_B (KLCLASS_IO | 0xD) /* Auxiliary GSN board */
357 #define KLTYPE_GFX (KLCLASS_GFX | 0x0) /* unknown graphics type */
358 #define KLTYPE_GFX_KONA (KLCLASS_GFX | 0x1) /* KONA graphics on IP27 */
359 #define KLTYPE_GFX_MGRA (KLCLASS_GFX | 0x3) /* MGRAS graphics on IP27 */
361 #define KLTYPE_WEIRDROUTER (KLCLASS_ROUTER | 0x0)
362 #define KLTYPE_ROUTER (KLCLASS_ROUTER | 0x1)
363 #define KLTYPE_ROUTER2 KLTYPE_ROUTER /* Obsolete! */
364 #define KLTYPE_NULL_ROUTER (KLCLASS_ROUTER | 0x2)
365 #define KLTYPE_META_ROUTER (KLCLASS_ROUTER | 0x3)
367 #define KLTYPE_WEIRDMIDPLANE (KLCLASS_MIDPLANE | 0x0)
368 #define KLTYPE_MIDPLANE8 (KLCLASS_MIDPLANE | 0x1) /* 8 slot backplane */
369 #define KLTYPE_MIDPLANE KLTYPE_MIDPLANE8
370 #define KLTYPE_PBRICK_XBOW (KLCLASS_MIDPLANE | 0x2)
372 #define KLTYPE_IOBRICK (KLCLASS_IOBRICK | 0x0)
373 #define KLTYPE_IBRICK (KLCLASS_IOBRICK | 0x1)
374 #define KLTYPE_PBRICK (KLCLASS_IOBRICK | 0x2)
375 #define KLTYPE_XBRICK (KLCLASS_IOBRICK | 0x3)
377 #define KLTYPE_PBRICK_BRIDGE KLTYPE_PBRICK
379 /* The value of type should be more than 8 so that hinv prints
380 * out the board name from the NIC string. For values less than
381 * 8 the name of the board needs to be hard coded in a few places.
382 * When bringup started nic names had not standardized and so we
383 * had to hard code. (For people interested in history.)
385 #define KLTYPE_XTHD (KLCLASS_PSEUDO_GFX | 0x9)
387 #define KLTYPE_UNKNOWN (KLCLASS_UNKNOWN | 0xf)
389 #define KLTYPE(_x) ((_x) & KLTYPE_MASK)
390 #define IS_MIO_PRESENT(l) ((l->brd_type == KLTYPE_BASEIO) && \
391 (l->brd_flags & SECOND_NIC_PRESENT))
392 #define IS_MIO_IOC3(l, n) (IS_MIO_PRESENT(l) && (n > 2))
395 * board structures
398 #define MAX_COMPTS_PER_BRD 24
400 #define LOCAL_BOARD 1
401 #define REMOTE_BOARD 2
403 #define LBOARD_STRUCT_VERSION 2
405 typedef struct lboard_s {
406 klconf_off_t brd_next; /* Next BOARD */
407 unsigned char struct_type; /* type of structure, local or remote */
408 unsigned char brd_type; /* type+class */
409 unsigned char brd_sversion; /* version of this structure */
410 unsigned char brd_brevision; /* board revision */
411 unsigned char brd_promver; /* board prom version, if any */
412 unsigned char brd_flags; /* Enabled, Disabled etc */
413 unsigned char brd_slot; /* slot number */
414 unsigned short brd_debugsw; /* Debug switches */
415 moduleid_t brd_module; /* module to which it belongs */
416 partid_t brd_partition; /* Partition number */
417 unsigned short brd_diagval; /* diagnostic value */
418 unsigned short brd_diagparm; /* diagnostic parameter */
419 unsigned char brd_inventory; /* inventory history */
420 unsigned char brd_numcompts; /* Number of components */
421 nic_t brd_nic; /* Number in CAN */
422 nasid_t brd_nasid; /* passed parameter */
423 klconf_off_t brd_compts[MAX_COMPTS_PER_BRD]; /* pointers to COMPONENTS */
424 klconf_off_t brd_errinfo; /* Board's error information */
425 struct lboard_s *brd_parent; /* Logical parent for this brd */
426 vertex_hdl_t brd_graph_link; /* vertex hdl to connect extern compts */
427 confidence_t brd_confidence; /* confidence that the board is bad */
428 nasid_t brd_owner; /* who owns this board */
429 unsigned char brd_nic_flags; /* To handle 8 more NICs */
430 char brd_name[32];
431 } lboard_t;
435 * Make sure we pass back the calias space address for local boards.
436 * klconfig board traversal and error structure extraction defines.
439 #define BOARD_SLOT(_brd) ((_brd)->brd_slot)
441 #define KLCF_CLASS(_brd) KLCLASS((_brd)->brd_type)
442 #define KLCF_TYPE(_brd) KLTYPE((_brd)->brd_type)
443 #define KLCF_REMOTE(_brd) (((_brd)->struct_type & LOCAL_BOARD) ? 0 : 1)
444 #define KLCF_NUM_COMPS(_brd) ((_brd)->brd_numcompts)
445 #define KLCF_MODULE_ID(_brd) ((_brd)->brd_module)
447 #define KLCF_NEXT(_brd) \
448 ((_brd)->brd_next ? \
449 (lboard_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), (_brd)->brd_next)):\
450 NULL)
451 #define KLCF_COMP(_brd, _ndx) \
452 (klinfo_t *)(NODE_OFFSET_TO_K1(NASID_GET(_brd), \
453 (_brd)->brd_compts[(_ndx)]))
455 #define KLCF_COMP_ERROR(_brd, _comp) \
456 (NODE_OFFSET_TO_K1(NASID_GET(_brd), (_comp)->errinfo))
458 #define KLCF_COMP_TYPE(_comp) ((_comp)->struct_type)
459 #define KLCF_BRIDGE_W_ID(_comp) ((_comp)->physid) /* Widget ID */
464 * Generic info structure. This stores common info about a
465 * component.
468 typedef struct klinfo_s { /* Generic info */
469 unsigned char struct_type; /* type of this structure */
470 unsigned char struct_version; /* version of this structure */
471 unsigned char flags; /* Enabled, disabled etc */
472 unsigned char revision; /* component revision */
473 unsigned short diagval; /* result of diagnostics */
474 unsigned short diagparm; /* diagnostic parameter */
475 unsigned char inventory; /* previous inventory status */
476 nic_t nic; /* MUst be aligned properly */
477 unsigned char physid; /* physical id of component */
478 unsigned int virtid; /* virtual id as seen by system */
479 unsigned char widid; /* Widget id - if applicable */
480 nasid_t nasid; /* node number - from parent */
481 char pad1; /* pad out structure. */
482 char pad2; /* pad out structure. */
483 COMPONENT *arcs_compt; /* ptr to the arcs struct for ease*/
484 klconf_off_t errinfo; /* component specific errors */
485 unsigned short pad3; /* pci fields have moved over to */
486 unsigned short pad4; /* klbri_t */
487 } klinfo_t ;
489 #define KLCONFIG_INFO_ENABLED(_i) ((_i)->flags & KLINFO_ENABLE)
491 * Component structures.
492 * Following are the currently identified components:
493 * CPU, HUB, MEM_BANK,
494 * XBOW(consists of 16 WIDGETs, each of which can be HUB or GRAPHICS or BRIDGE)
495 * BRIDGE, IOC3, SuperIO, SCSI, FDDI
496 * ROUTER
497 * GRAPHICS
499 #define KLSTRUCT_UNKNOWN 0
500 #define KLSTRUCT_CPU 1
501 #define KLSTRUCT_HUB 2
502 #define KLSTRUCT_MEMBNK 3
503 #define KLSTRUCT_XBOW 4
504 #define KLSTRUCT_BRI 5
505 #define KLSTRUCT_IOC3 6
506 #define KLSTRUCT_PCI 7
507 #define KLSTRUCT_VME 8
508 #define KLSTRUCT_ROU 9
509 #define KLSTRUCT_GFX 10
510 #define KLSTRUCT_SCSI 11
511 #define KLSTRUCT_FDDI 12
512 #define KLSTRUCT_MIO 13
513 #define KLSTRUCT_DISK 14
514 #define KLSTRUCT_TAPE 15
515 #define KLSTRUCT_CDROM 16
516 #define KLSTRUCT_HUB_UART 17
517 #define KLSTRUCT_IOC3ENET 18
518 #define KLSTRUCT_IOC3UART 19
519 #define KLSTRUCT_UNUSED 20 /* XXX UNUSED */
520 #define KLSTRUCT_IOC3PCKM 21
521 #define KLSTRUCT_RAD 22
522 #define KLSTRUCT_HUB_TTY 23
523 #define KLSTRUCT_IOC3_TTY 24
525 /* Early Access IO proms are compatible
526 only with KLSTRUCT values upto 24. */
528 #define KLSTRUCT_FIBERCHANNEL 25
529 #define KLSTRUCT_MOD_SERIAL_NUM 26
530 #define KLSTRUCT_IOC3MS 27
531 #define KLSTRUCT_TPU 28
532 #define KLSTRUCT_GSN_A 29
533 #define KLSTRUCT_GSN_B 30
534 #define KLSTRUCT_XTHD 31
537 * These are the indices of various components within a lboard structure.
540 #define IP27_CPU0_INDEX 0
541 #define IP27_CPU1_INDEX 1
542 #define IP27_HUB_INDEX 2
543 #define IP27_MEM_INDEX 3
545 #define BASEIO_BRIDGE_INDEX 0
546 #define BASEIO_IOC3_INDEX 1
547 #define BASEIO_SCSI1_INDEX 2
548 #define BASEIO_SCSI2_INDEX 3
550 #define MIDPLANE_XBOW_INDEX 0
551 #define ROUTER_COMPONENT_INDEX 0
553 #define CH4SCSI_BRIDGE_INDEX 0
555 /* Info holders for various hardware components */
557 typedef u64 *pci_t;
558 typedef u64 *vmeb_t;
559 typedef u64 *vmed_t;
560 typedef u64 *fddi_t;
561 typedef u64 *scsi_t;
562 typedef u64 *mio_t;
563 typedef u64 *graphics_t;
564 typedef u64 *router_t;
567 * The port info in ip27_cfg area translates to a lboart_t in the
568 * KLCONFIG area. But since KLCONFIG does not use pointers, lboart_t
569 * is stored in terms of a nasid and a offset from start of KLCONFIG
570 * area on that nasid.
572 typedef struct klport_s {
573 nasid_t port_nasid;
574 unsigned char port_flag;
575 klconf_off_t port_offset;
576 } klport_t;
578 typedef struct klcpu_s { /* CPU */
579 klinfo_t cpu_info;
580 unsigned short cpu_prid; /* Processor PRID value */
581 unsigned short cpu_fpirr; /* FPU IRR value */
582 unsigned short cpu_speed; /* Speed in MHZ */
583 unsigned short cpu_scachesz; /* secondary cache size in MB */
584 unsigned short cpu_scachespeed;/* secondary cache speed in MHz */
585 } klcpu_t ;
587 #define CPU_STRUCT_VERSION 2
589 typedef struct klhub_s { /* HUB */
590 klinfo_t hub_info;
591 unsigned int hub_flags; /* PCFG_HUB_xxx flags */
592 klport_t hub_port; /* hub is connected to this */
593 nic_t hub_box_nic; /* nic of containing box */
594 klconf_off_t hub_mfg_nic; /* MFG NIC string */
595 u64 hub_speed; /* Speed of hub in HZ */
596 } klhub_t ;
598 typedef struct klhub_uart_s { /* HUB */
599 klinfo_t hubuart_info;
600 unsigned int hubuart_flags; /* PCFG_HUB_xxx flags */
601 nic_t hubuart_box_nic; /* nic of containing box */
602 } klhub_uart_t ;
604 #define MEMORY_STRUCT_VERSION 2
606 typedef struct klmembnk_s { /* MEMORY BANK */
607 klinfo_t membnk_info;
608 short membnk_memsz; /* Total memory in megabytes */
609 short membnk_dimm_select; /* bank to physical addr mapping*/
610 short membnk_bnksz[MD_MEM_BANKS]; /* Memory bank sizes */
611 short membnk_attr;
612 } klmembnk_t ;
614 #define KLCONFIG_MEMBNK_SIZE(_info, _bank) \
615 ((_info)->membnk_bnksz[(_bank)])
618 #define MEMBNK_PREMIUM 1
619 #define KLCONFIG_MEMBNK_PREMIUM(_info, _bank) \
620 ((_info)->membnk_attr & (MEMBNK_PREMIUM << (_bank)))
622 #define MAX_SERIAL_NUM_SIZE 10
624 typedef struct klmod_serial_num_s {
625 klinfo_t snum_info;
626 union {
627 char snum_str[MAX_SERIAL_NUM_SIZE];
628 unsigned long long snum_int;
629 } snum;
630 } klmod_serial_num_t;
632 /* Macros needed to access serial number structure in lboard_t.
633 Hard coded values are necessary since we cannot treat
634 serial number struct as a component without losing compatibility
635 between prom versions. */
637 #define GET_SNUM_COMP(_l) ((klmod_serial_num_t *)\
638 KLCF_COMP(_l, _l->brd_numcompts))
640 #define MAX_XBOW_LINKS 16
642 typedef struct klxbow_s { /* XBOW */
643 klinfo_t xbow_info ;
644 klport_t xbow_port_info[MAX_XBOW_LINKS] ; /* Module number */
645 int xbow_master_hub_link;
646 /* type of brd connected+component struct ptr+flags */
647 } klxbow_t ;
649 #define MAX_PCI_SLOTS 8
651 typedef struct klpci_device_s {
652 s32 pci_device_id; /* 32 bits of vendor/device ID. */
653 s32 pci_device_pad; /* 32 bits of padding. */
654 } klpci_device_t;
656 #define BRIDGE_STRUCT_VERSION 2
658 typedef struct klbri_s { /* BRIDGE */
659 klinfo_t bri_info ;
660 unsigned char bri_eprominfo ; /* IO6prom connected to bridge */
661 unsigned char bri_bustype ; /* PCI/VME BUS bridge/GIO */
662 pci_t pci_specific ; /* PCI Board config info */
663 klpci_device_t bri_devices[MAX_PCI_DEVS] ; /* PCI IDs */
664 klconf_off_t bri_mfg_nic ;
665 } klbri_t ;
667 #define MAX_IOC3_TTY 2
669 typedef struct klioc3_s { /* IOC3 */
670 klinfo_t ioc3_info ;
671 unsigned char ioc3_ssram ; /* Info about ssram */
672 unsigned char ioc3_nvram ; /* Info about nvram */
673 klinfo_t ioc3_superio ; /* Info about superio */
674 klconf_off_t ioc3_tty_off ;
675 klinfo_t ioc3_enet ;
676 klconf_off_t ioc3_enet_off ;
677 klconf_off_t ioc3_kbd_off ;
678 } klioc3_t ;
680 #define MAX_VME_SLOTS 8
682 typedef struct klvmeb_s { /* VME BRIDGE - PCI CTLR */
683 klinfo_t vmeb_info ;
684 vmeb_t vmeb_specific ;
685 klconf_off_t vmeb_brdinfo[MAX_VME_SLOTS] ; /* VME Board config info */
686 } klvmeb_t ;
688 typedef struct klvmed_s { /* VME DEVICE - VME BOARD */
689 klinfo_t vmed_info ;
690 vmed_t vmed_specific ;
691 klconf_off_t vmed_brdinfo[MAX_VME_SLOTS] ; /* VME Board config info */
692 } klvmed_t ;
694 #define ROUTER_VECTOR_VERS 2
696 /* XXX - Don't we need the number of ports here?!? */
697 typedef struct klrou_s { /* ROUTER */
698 klinfo_t rou_info ;
699 unsigned int rou_flags ; /* PCFG_ROUTER_xxx flags */
700 nic_t rou_box_nic ; /* nic of the containing module */
701 klport_t rou_port[MAX_ROUTER_PORTS + 1] ; /* array index 1 to 6 */
702 klconf_off_t rou_mfg_nic ; /* MFG NIC string */
703 u64 rou_vector; /* vector from master node */
704 } klrou_t ;
707 * Graphics Controller/Device
709 * (IP27/IO6) Prom versions 6.13 (and 6.5.1 kernels) and earlier
710 * used a couple different structures to store graphics information.
711 * For compatibility reasons, the newer data structure preserves some
712 * of the layout so that fields that are used in the old versions remain
713 * in the same place (with the same info). Determination of what version
714 * of this structure we have is done by checking the cookie field.
716 #define KLGFX_COOKIE 0x0c0de000
718 typedef struct klgfx_s { /* GRAPHICS Device */
719 klinfo_t gfx_info;
720 klconf_off_t old_gndevs; /* for compatibility with older proms */
721 klconf_off_t old_gdoff0; /* for compatibility with older proms */
722 unsigned int cookie; /* for compatibility with older proms */
723 unsigned int moduleslot;
724 struct klgfx_s *gfx_next_pipe;
725 graphics_t gfx_specific;
726 klconf_off_t pad0; /* for compatibility with older proms */
727 klconf_off_t gfx_mfg_nic;
728 } klgfx_t;
730 typedef struct klxthd_s {
731 klinfo_t xthd_info ;
732 klconf_off_t xthd_mfg_nic ; /* MFG NIC string */
733 } klxthd_t ;
735 typedef struct kltpu_s { /* TPU board */
736 klinfo_t tpu_info ;
737 klconf_off_t tpu_mfg_nic ; /* MFG NIC string */
738 } kltpu_t ;
740 typedef struct klgsn_s { /* GSN board */
741 klinfo_t gsn_info ;
742 klconf_off_t gsn_mfg_nic ; /* MFG NIC string */
743 } klgsn_t ;
745 #define MAX_SCSI_DEVS 16
748 * NOTE: THis is the max sized kl* structure and is used in klmalloc.c
749 * to allocate space of type COMPONENT. Make sure that if the size of
750 * any other component struct becomes more than this, then redefine
751 * that as the size to be klmalloced.
754 typedef struct klscsi_s { /* SCSI Controller */
755 klinfo_t scsi_info ;
756 scsi_t scsi_specific ;
757 unsigned char scsi_numdevs ;
758 klconf_off_t scsi_devinfo[MAX_SCSI_DEVS] ;
759 } klscsi_t ;
761 typedef struct klscdev_s { /* SCSI device */
762 klinfo_t scdev_info ;
763 struct scsidisk_data *scdev_cfg ; /* driver fills up this */
764 } klscdev_t ;
766 typedef struct klttydev_s { /* TTY device */
767 klinfo_t ttydev_info ;
768 struct terminal_data *ttydev_cfg ; /* driver fills up this */
769 } klttydev_t ;
771 typedef struct klenetdev_s { /* ENET device */
772 klinfo_t enetdev_info ;
773 struct net_data *enetdev_cfg ; /* driver fills up this */
774 } klenetdev_t ;
776 typedef struct klkbddev_s { /* KBD device */
777 klinfo_t kbddev_info ;
778 struct keyboard_data *kbddev_cfg ; /* driver fills up this */
779 } klkbddev_t ;
781 typedef struct klmsdev_s { /* mouse device */
782 klinfo_t msdev_info ;
783 void *msdev_cfg ;
784 } klmsdev_t ;
786 #define MAX_FDDI_DEVS 10 /* XXX Is this true */
788 typedef struct klfddi_s { /* FDDI */
789 klinfo_t fddi_info ;
790 fddi_t fddi_specific ;
791 klconf_off_t fddi_devinfo[MAX_FDDI_DEVS] ;
792 } klfddi_t ;
794 typedef struct klmio_s { /* MIO */
795 klinfo_t mio_info ;
796 mio_t mio_specific ;
797 } klmio_t ;
800 typedef union klcomp_s {
801 klcpu_t kc_cpu;
802 klhub_t kc_hub;
803 klmembnk_t kc_mem;
804 klxbow_t kc_xbow;
805 klbri_t kc_bri;
806 klioc3_t kc_ioc3;
807 klvmeb_t kc_vmeb;
808 klvmed_t kc_vmed;
809 klrou_t kc_rou;
810 klgfx_t kc_gfx;
811 klscsi_t kc_scsi;
812 klscdev_t kc_scsi_dev;
813 klfddi_t kc_fddi;
814 klmio_t kc_mio;
815 klmod_serial_num_t kc_snum ;
816 } klcomp_t;
818 typedef union kldev_s { /* for device structure allocation */
819 klscdev_t kc_scsi_dev ;
820 klttydev_t kc_tty_dev ;
821 klenetdev_t kc_enet_dev ;
822 klkbddev_t kc_kbd_dev ;
823 } kldev_t ;
825 /* Data structure interface routines. TBD */
827 /* Include launch info in this file itself? TBD */
830 * TBD - Can the ARCS and device driver related info also be included in the
831 * KLCONFIG area. On the IO4PROM, prom device driver info is part of cfgnode_t
832 * structure, viz private to the IO4prom.
836 * TBD - Allocation issues.
838 * Do we need to Mark off sepatate heaps for lboard_t, rboard_t, component,
839 * errinfo and allocate from them, or have a single heap and allocate all
840 * structures from it. Debug is easier in the former method since we can
841 * dump all similar structs in one command, but there will be lots of holes,
842 * in memory and max limits are needed for number of structures.
843 * Another way to make it organized, is to have a union of all components
844 * and allocate a aligned chunk of memory greater than the biggest
845 * component.
848 typedef union {
849 lboard_t *lbinfo ;
850 } biptr_t ;
853 #define BRI_PER_XBOW 6
854 #define PCI_PER_BRI 8
855 #define DEV_PER_PCI 16
858 /* Virtual dipswitch values (starting from switch "7"): */
860 #define VDS_NOGFX 0x8000 /* Don't enable gfx and autoboot */
861 #define VDS_NOMP 0x100 /* Don't start slave processors */
862 #define VDS_MANUMODE 0x80 /* Manufacturing mode */
863 #define VDS_NOARB 0x40 /* No bootmaster arbitration */
864 #define VDS_PODMODE 0x20 /* Go straight to POD mode */
865 #define VDS_NO_DIAGS 0x10 /* Don't run any diags after BM arb */
866 #define VDS_DEFAULTS 0x08 /* Use default environment values */
867 #define VDS_NOMEMCLEAR 0x04 /* Don't run mem cfg code */
868 #define VDS_2ND_IO4 0x02 /* Boot from the second IO4 */
869 #define VDS_DEBUG_PROM 0x01 /* Print PROM debugging messages */
871 /* external declarations of Linux kernel functions. */
873 extern lboard_t *find_lboard(lboard_t *start, unsigned char type);
874 extern klinfo_t *find_component(lboard_t *brd, klinfo_t *kli, unsigned char type);
875 extern klinfo_t *find_first_component(lboard_t *brd, unsigned char type);
876 extern klcpu_t *nasid_slice_to_cpuinfo(nasid_t, int);
877 extern lboard_t *find_lboard_class(lboard_t *start, unsigned char brd_class);
880 extern klcpu_t *sn_get_cpuinfo(cpuid_t cpu);
882 #endif /* _ASM_SN_KLCONFIG_H */