klconfig.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:34k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

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