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

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.  * Copyright (C) 1992 - 1997, 2000-2002 Silicon Graphics, Inc. All rights reserved.
  8.  */
  9. /*
  10.  * klgraph.c-
  11.  *      This file specifies the interface between the kernel and the PROM's
  12.  *      configuration data structures.
  13.  */
  14. #include <linux/types.h>
  15. #include <linux/config.h>
  16. #include <linux/slab.h>
  17. #include <asm/sn/sgi.h>
  18. #include <asm/sn/sn_sal.h>
  19. #include <asm/sn/io.h>
  20. #include <asm/sn/iograph.h>
  21. #include <asm/sn/invent.h>
  22. #include <asm/sn/hcl.h>
  23. #include <asm/sn/labelcl.h>
  24. #include <asm/sn/kldir.h>
  25. #include <asm/sn/gda.h> 
  26. #include <asm/sn/klconfig.h>
  27. #include <asm/sn/router.h>
  28. #include <asm/sn/xtalk/xbow.h>
  29. #include <asm/sn/hcl_util.h>
  30. /* #define KLGRAPH_DEBUG 1 */
  31. #ifdef KLGRAPH_DEBUG
  32. #define GRPRINTF(x) printk x
  33. #define CE_GRPANIC CE_PANIC
  34. #else
  35. #define GRPRINTF(x)
  36. #define CE_GRPANIC CE_PANIC
  37. #endif
  38. #include <asm/sn/sn_private.h>
  39. extern char arg_maxnodes[];
  40. extern u64 klgraph_addr[];
  41. /*
  42.  * Support for verbose inventory via hardware graph. 
  43.  * klhwg_invent_alloc allocates the necessary size of inventory information
  44.  * and fills in the generic information.
  45.  */
  46. invent_generic_t *
  47. klhwg_invent_alloc(cnodeid_t cnode, int class, int size)
  48. {
  49. invent_generic_t *invent;
  50. invent = kern_malloc(size);
  51. if (!invent) return NULL;
  52. invent->ig_module = NODE_MODULEID(cnode);
  53. invent->ig_slot = SLOTNUM_GETSLOT(NODE_SLOTID(cnode));
  54. invent->ig_invclass = class;
  55. return invent;
  56. }
  57. /* 
  58.  * Add information about the baseio prom version number
  59.  * as a part of detailed inventory info in the hwgraph.
  60.  */
  61. void
  62. klhwg_baseio_inventory_add(devfs_handle_t baseio_vhdl,cnodeid_t cnode)
  63. {
  64. invent_miscinfo_t *baseio_inventory;
  65. unsigned char version = 0,revision = 0;
  66. /* Allocate memory for the "detailed inventory" info
  67.  * for the baseio
  68.  */
  69. baseio_inventory = (invent_miscinfo_t *) 
  70. klhwg_invent_alloc(cnode, INV_PROM, sizeof(invent_miscinfo_t));
  71. baseio_inventory->im_type = INV_IO6PROM;
  72. /* Read the io6prom revision from the nvram */
  73. #ifdef LATER
  74. nvram_prom_version_get(&version,&revision);
  75. #endif
  76. /* Store the revision info  in the inventory */
  77. baseio_inventory->im_version = version;
  78. baseio_inventory->im_rev = revision;
  79. /* Put the inventory info in the hardware graph */
  80. hwgraph_info_add_LBL(baseio_vhdl, INFO_LBL_DETAIL_INVENT, 
  81.      (arbitrary_info_t) baseio_inventory);
  82. /* Make the information available to the user programs
  83.  * thru hwgfs.
  84.  */
  85.         hwgraph_info_export_LBL(baseio_vhdl, INFO_LBL_DETAIL_INVENT,
  86. sizeof(invent_miscinfo_t));
  87. }
  88. char *hub_rev[] = {
  89. "0.0",
  90. "1.0",
  91. "2.0",
  92. "2.1",
  93. "2.2",
  94. "2.3"
  95. };
  96. /*
  97.  * Add detailed cpu inventory info to the hardware graph.
  98.  */
  99. void
  100. klhwg_hub_invent_info(devfs_handle_t hubv,
  101.       cnodeid_t cnode, 
  102.       klhub_t *hub)
  103. {
  104. invent_miscinfo_t *hub_invent;
  105. hub_invent = (invent_miscinfo_t *) 
  106.     klhwg_invent_alloc(cnode, INV_MISC, sizeof(invent_miscinfo_t));
  107. if (!hub_invent)
  108.     return;
  109. if (KLCONFIG_INFO_ENABLED((klinfo_t *)hub))
  110.     hub_invent->im_gen.ig_flag = INVENT_ENABLED;
  111. hub_invent->im_type = INV_HUB;
  112. hub_invent->im_rev = hub->hub_info.revision;
  113. hub_invent->im_speed = hub->hub_speed;
  114. hwgraph_info_add_LBL(hubv, INFO_LBL_DETAIL_INVENT, 
  115.      (arbitrary_info_t) hub_invent);
  116.         hwgraph_info_export_LBL(hubv, INFO_LBL_DETAIL_INVENT,
  117. sizeof(invent_miscinfo_t));
  118. }
  119. /* ARGSUSED */
  120. void
  121. klhwg_add_hub(devfs_handle_t node_vertex, klhub_t *hub, cnodeid_t cnode)
  122. {
  123. #if defined(CONFIG_IA64_SGI_SN1)
  124. devfs_handle_t myhubv;
  125. devfs_handle_t hub_mon;
  126. devfs_handle_t synergy;
  127. devfs_handle_t fsb0;
  128. devfs_handle_t fsb1;
  129. int rc;
  130. extern struct file_operations hub_mon_fops;
  131. GRPRINTF(("klhwg_add_hub: adding %sn", EDGE_LBL_HUB));
  132. (void) hwgraph_path_add(node_vertex, EDGE_LBL_HUB, &myhubv);
  133. rc = device_master_set(myhubv, node_vertex);
  134. /*
  135.  * hub perf stats.
  136.  */
  137. rc = hwgraph_info_add_LBL(myhubv, INFO_LBL_HUB_INFO,
  138.                         (arbitrary_info_t)(&NODEPDA(cnode)->hubstats));
  139. if (rc != GRAPH_SUCCESS) {
  140. printk(KERN_WARNING  "klhwg_add_hub: Can't add hub info label 0x%p, code %d",
  141. (void *)myhubv, rc);
  142. }
  143. klhwg_hub_invent_info(myhubv, cnode, hub);
  144. hub_mon = hwgraph_register(myhubv, EDGE_LBL_PERFMON,
  145.     0, DEVFS_FL_AUTO_DEVNUM,
  146.     0, 0,
  147.     S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
  148.     &hub_mon_fops,
  149.     (void *)(long)cnode);
  150. init_hub_stats(cnode, NODEPDA(cnode));
  151. /*
  152.  * synergy perf
  153.  */
  154. (void) hwgraph_path_add(myhubv, EDGE_LBL_SYNERGY, &synergy);
  155. (void) hwgraph_path_add(synergy, "0", &fsb0);
  156. (void) hwgraph_path_add(synergy, "1", &fsb1);
  157. fsb0 = hwgraph_register(fsb0, EDGE_LBL_PERFMON,
  158.     0, DEVFS_FL_AUTO_DEVNUM,
  159.     0, 0,
  160.     S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
  161.     &synergy_mon_fops, (void *)SYNERGY_PERF_INFO(cnode, 0));
  162. fsb1 = hwgraph_register(fsb1, EDGE_LBL_PERFMON,
  163.     0, DEVFS_FL_AUTO_DEVNUM,
  164.     0, 0,
  165.     S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, 0, 0,
  166.     &synergy_mon_fops, (void *)SYNERGY_PERF_INFO(cnode, 1));
  167. #endif /* CONFIG_IA64_SGI_SN1 */
  168. }
  169. void
  170. klhwg_add_xbow(cnodeid_t cnode, nasid_t nasid)
  171. {
  172. lboard_t *brd;
  173. klxbow_t *xbow_p;
  174. nasid_t hub_nasid;
  175. cnodeid_t hub_cnode;
  176. int widgetnum;
  177. devfs_handle_t xbow_v, hubv;
  178. /*REFERENCED*/
  179. graph_error_t err;
  180. if ((brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_IOBRICK_XBOW)) == NULL)
  181. return;
  182. if (KL_CONFIG_DUPLICATE_BOARD(brd))
  183.     return;
  184. GRPRINTF(("klhwg_add_xbow: adding cnode %d nasid %d xbow edgesn",
  185. cnode, nasid));
  186. if ((xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW))
  187.     == NULL)
  188.     return;
  189. #ifdef LATER
  190. /*
  191.  * We cannot support this function in devfs .. see below where 
  192.  * we use hwgraph_path_add() to create this vertex with a known 
  193.  * name.
  194.  */
  195. err = hwgraph_vertex_create(&xbow_v);
  196. ASSERT(err == GRAPH_SUCCESS);
  197. xswitch_vertex_init(xbow_v);
  198. #endif /* LATER */
  199. for (widgetnum = HUB_WIDGET_ID_MIN; widgetnum <= HUB_WIDGET_ID_MAX; widgetnum++) {
  200. if (!XBOW_PORT_TYPE_HUB(xbow_p, widgetnum)) 
  201.     continue;
  202. hub_nasid = XBOW_PORT_NASID(xbow_p, widgetnum);
  203. if (hub_nasid == INVALID_NASID) {
  204. printk(KERN_WARNING  "hub widget %d, skipping xbow graphn", widgetnum);
  205. continue;
  206. }
  207. hub_cnode = NASID_TO_COMPACT_NODEID(hub_nasid);
  208. if (is_specified(arg_maxnodes) && hub_cnode == INVALID_CNODEID) {
  209. continue;
  210. }
  211. hubv = cnodeid_to_vertex(hub_cnode);
  212. err = hwgraph_path_add(hubv, EDGE_LBL_XTALK, &xbow_v);
  213.                 if (err != GRAPH_SUCCESS) {
  214.                         if (err == GRAPH_DUP)
  215.                                 printk(KERN_WARNING  "klhwg_add_xbow: Check for "
  216.                                         "working routers and router links!");
  217.                         PRINT_PANIC("klhwg_add_xbow: Failed to add "
  218.                                 "edge: vertex 0x%p to vertex 0x%p,"
  219.                                 "error %dn",
  220.                                 (void *)hubv, (void *)xbow_v, err);
  221.                 }
  222. xswitch_vertex_init(xbow_v); 
  223. NODEPDA(hub_cnode)->xbow_vhdl = xbow_v;
  224. /*
  225.  * XXX - This won't work is we ever hook up two hubs
  226.  * by crosstown through a crossbow.
  227.  */
  228. if (hub_nasid != nasid) {
  229. NODEPDA(hub_cnode)->xbow_peer = nasid;
  230. NODEPDA(NASID_TO_COMPACT_NODEID(nasid))->xbow_peer =
  231. hub_nasid;
  232. }
  233. GRPRINTF(("klhwg_add_xbow: adding port nasid %d %s to vertex 0x%pn",
  234. hub_nasid, EDGE_LBL_XTALK, hubv));
  235. #ifdef LATER
  236. err = hwgraph_edge_add(hubv, xbow_v, EDGE_LBL_XTALK);
  237. if (err != GRAPH_SUCCESS) {
  238. if (err == GRAPH_DUP)
  239. printk(KERN_WARNING  "klhwg_add_xbow: Check for "
  240. "working routers and router links!");
  241. PRINT_PANIC("klhwg_add_xbow: Failed to add "
  242. "edge: vertex 0x%p (0x%p) to vertex 0x%p (0x%p), "
  243. "error %dn",
  244. hubv, hubv, xbow_v, xbow_v, err);
  245. }
  246. #endif
  247. }
  248. }
  249. /* ARGSUSED */
  250. void
  251. klhwg_add_node(devfs_handle_t hwgraph_root, cnodeid_t cnode, gda_t *gdap)
  252. {
  253. nasid_t nasid;
  254. lboard_t *brd;
  255. klhub_t *hub;
  256. devfs_handle_t node_vertex = NULL;
  257. char path_buffer[100];
  258. int rv;
  259. char *s;
  260. int board_disabled = 0;
  261. nasid = COMPACT_TO_NASID_NODEID(cnode);
  262. brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
  263. GRPRINTF(("klhwg_add_node: Adding cnode %d, nasid %d, brd 0x%pn",
  264.                 cnode, nasid, brd));
  265. ASSERT(brd);
  266. do {
  267. /* Generate a hardware graph path for this board. */
  268. board_to_path(brd, path_buffer);
  269. GRPRINTF(("klhwg_add_node: adding %s to vertex 0x%pn",
  270. path_buffer, hwgraph_root));
  271. rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
  272. if (rv != GRAPH_SUCCESS)
  273. PRINT_PANIC("Node vertex creation failed.  "
  274.   "Path == %s",
  275. path_buffer);
  276. hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
  277. ASSERT(hub);
  278. if(hub->hub_info.flags & KLINFO_ENABLE)
  279. board_disabled = 0;
  280. else
  281. board_disabled = 1;
  282. if(!board_disabled) {
  283. mark_nodevertex_as_node(node_vertex,
  284.     cnode + board_disabled * numnodes);
  285. s = dev_to_name(node_vertex, path_buffer, sizeof(path_buffer));
  286. NODEPDA(cnode)->hwg_node_name =
  287. kmalloc(strlen(s) + 1,
  288. GFP_KERNEL);
  289. ASSERT_ALWAYS(NODEPDA(cnode)->hwg_node_name != NULL);
  290. strcpy(NODEPDA(cnode)->hwg_node_name, s);
  291. hubinfo_set(node_vertex, NODEPDA(cnode)->pdinfo);
  292. /* Set up node board's slot */
  293. NODEPDA(cnode)->slotdesc = brd->brd_slot;
  294. /* Set up the module we're in */
  295. NODEPDA(cnode)->module_id = brd->brd_module;
  296. NODEPDA(cnode)->module = module_lookup(brd->brd_module);
  297. }
  298. if(!board_disabled)
  299. klhwg_add_hub(node_vertex, hub, cnode);
  300. brd = KLCF_NEXT(brd);
  301. if (brd)
  302. brd = find_lboard(brd, KLTYPE_SNIA);
  303. else
  304. break;
  305. } while(brd);
  306. }
  307. /* ARGSUSED */
  308. void
  309. klhwg_add_all_routers(devfs_handle_t hwgraph_root)
  310. {
  311. nasid_t nasid;
  312. cnodeid_t cnode;
  313. lboard_t *brd;
  314. devfs_handle_t node_vertex;
  315. char path_buffer[100];
  316. int rv;
  317. for (cnode = 0; cnode < numnodes; cnode++) {
  318. nasid = COMPACT_TO_NASID_NODEID(cnode);
  319. GRPRINTF(("klhwg_add_all_routers: adding router on cnode %dn",
  320. cnode));
  321. brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),
  322. KLTYPE_ROUTER);
  323. if (!brd)
  324. /* No routers stored in this node's memory */
  325. continue;
  326. do {
  327. ASSERT(brd);
  328. GRPRINTF(("Router board struct is %pn", brd));
  329. /* Don't add duplicate boards. */
  330. if (brd->brd_flags & DUPLICATE_BOARD)
  331. continue;
  332. GRPRINTF(("Router 0x%p module number is %dn", brd, brd->brd_module));
  333. /* Generate a hardware graph path for this board. */
  334. board_to_path(brd, path_buffer);
  335. GRPRINTF(("Router path is %sn", path_buffer));
  336. /* Add the router */
  337. GRPRINTF(("klhwg_add_all_routers: adding %s to vertex 0x%pn",
  338. path_buffer, hwgraph_root));
  339. rv = hwgraph_path_add(hwgraph_root, path_buffer, &node_vertex);
  340. if (rv != GRAPH_SUCCESS)
  341. PRINT_PANIC("Router vertex creation "
  342.   "failed.  Path == %s",
  343. path_buffer);
  344. GRPRINTF(("klhwg_add_all_routers: get next board from 0x%pn",
  345. brd));
  346. /* Find the rest of the routers stored on this node. */
  347. } while ( (brd = find_lboard_class(KLCF_NEXT(brd),
  348.  KLTYPE_ROUTER)) );
  349. GRPRINTF(("klhwg_add_all_routers: Done.n"));
  350. }
  351. }
  352. /* ARGSUSED */
  353. void
  354. klhwg_connect_one_router(devfs_handle_t hwgraph_root, lboard_t *brd,
  355.  cnodeid_t cnode, nasid_t nasid)
  356. {
  357. klrou_t *router;
  358. char path_buffer[50];
  359. char dest_path[50];
  360. devfs_handle_t router_hndl;
  361. devfs_handle_t dest_hndl;
  362. int rc;
  363. int port;
  364. lboard_t *dest_brd;
  365. GRPRINTF(("klhwg_connect_one_router: Connecting router on cnode %dn",
  366. cnode));
  367. /* Don't add duplicate boards. */
  368. if (brd->brd_flags & DUPLICATE_BOARD) {
  369. GRPRINTF(("klhwg_connect_one_router: Duplicate router 0x%p on cnode %dn",
  370. brd, cnode));
  371. return;
  372. }
  373. /* Generate a hardware graph path for this board. */
  374. board_to_path(brd, path_buffer);
  375. rc = hwgraph_traverse(hwgraph_root, path_buffer, &router_hndl);
  376. if (rc != GRAPH_SUCCESS && is_specified(arg_maxnodes))
  377. return;
  378. if (rc != GRAPH_SUCCESS)
  379. printk(KERN_WARNING  "Can't find router: %s", path_buffer);
  380. /* We don't know what to do with multiple router components */
  381. if (brd->brd_numcompts != 1) {
  382. PRINT_PANIC("klhwg_connect_one_router: %d cmpts on routern",
  383. brd->brd_numcompts);
  384. return;
  385. }
  386. /* Convert component 0 to klrou_t ptr */
  387. router = (klrou_t *)NODE_OFFSET_TO_K0(NASID_GET(brd),
  388.       brd->brd_compts[0]);
  389. for (port = 1; port <= MAX_ROUTER_PORTS; port++) {
  390. /* See if the port's active */
  391. if (router->rou_port[port].port_nasid == INVALID_NASID) {
  392. GRPRINTF(("klhwg_connect_one_router: port %d inactive.n",
  393.  port));
  394. continue;
  395. }
  396. if (is_specified(arg_maxnodes) && NASID_TO_COMPACT_NODEID(router->rou_port[port].port_nasid) 
  397.     == INVALID_CNODEID) {
  398. continue;
  399. }
  400. dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(
  401. router->rou_port[port].port_nasid,
  402. router->rou_port[port].port_offset);
  403. /* Generate a hardware graph path for this board. */
  404. board_to_path(dest_brd, dest_path);
  405. rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl);
  406. if (rc != GRAPH_SUCCESS) {
  407. if (is_specified(arg_maxnodes) && KL_CONFIG_DUPLICATE_BOARD(dest_brd))
  408. continue;
  409. PRINT_PANIC("Can't find router: %s", dest_path);
  410. }
  411. GRPRINTF(("klhwg_connect_one_router: Link from %s/%d to %sn",
  412.   path_buffer, port, dest_path));
  413. sprintf(dest_path, "%d", port);
  414. rc = hwgraph_edge_add(router_hndl, dest_hndl, dest_path);
  415. if (rc == GRAPH_DUP) {
  416. GRPRINTF(("Skipping port %d. nasid %d %s/%sn",
  417.   port, router->rou_port[port].port_nasid,
  418.   path_buffer, dest_path));
  419. continue;
  420. }
  421. if (rc != GRAPH_SUCCESS && !is_specified(arg_maxnodes))
  422. PRINT_PANIC("Can't create edge: %s/%s to vertex 0x%p error 0x%xn",
  423. path_buffer, dest_path, (void *)dest_hndl, rc);
  424. }
  425. }
  426. void
  427. klhwg_connect_routers(devfs_handle_t hwgraph_root)
  428. {
  429. nasid_t nasid;
  430. cnodeid_t cnode;
  431. lboard_t *brd;
  432. for (cnode = 0; cnode < numnodes; cnode++) {
  433. nasid = COMPACT_TO_NASID_NODEID(cnode);
  434. GRPRINTF(("klhwg_connect_routers: Connecting routers on cnode %dn",
  435. cnode));
  436. brd = find_lboard_class((lboard_t *)KL_CONFIG_INFO(nasid),
  437. KLTYPE_ROUTER);
  438. if (!brd)
  439. continue;
  440. do {
  441. nasid = COMPACT_TO_NASID_NODEID(cnode);
  442. klhwg_connect_one_router(hwgraph_root, brd,
  443.  cnode, nasid);
  444. /* Find the rest of the routers stored on this node. */
  445. } while ( (brd = find_lboard_class(KLCF_NEXT(brd), KLTYPE_ROUTER)) );
  446. }
  447. }
  448. void
  449. klhwg_connect_hubs(devfs_handle_t hwgraph_root)
  450. {
  451. nasid_t nasid;
  452. cnodeid_t cnode;
  453. lboard_t *brd;
  454. klhub_t *hub;
  455. lboard_t *dest_brd;
  456. devfs_handle_t hub_hndl;
  457. devfs_handle_t dest_hndl;
  458. char path_buffer[50];
  459. char dest_path[50];
  460. graph_error_t rc;
  461. for (cnode = 0; cnode < numnodes; cnode++) {
  462. nasid = COMPACT_TO_NASID_NODEID(cnode);
  463. GRPRINTF(("klhwg_connect_hubs: Connecting hubs on cnode %dn",
  464. cnode));
  465. brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_SNIA);
  466. ASSERT(brd);
  467. hub = (klhub_t *)find_first_component(brd, KLSTRUCT_HUB);
  468. ASSERT(hub);
  469. /* See if the port's active */
  470. if (hub->hub_port.port_nasid == INVALID_NASID) {
  471. GRPRINTF(("klhwg_connect_hubs: port inactive.n"));
  472. continue;
  473. }
  474. if (is_specified(arg_maxnodes) && NASID_TO_COMPACT_NODEID(hub->hub_port.port_nasid) == INVALID_CNODEID)
  475. continue;
  476. /* Generate a hardware graph path for this board. */
  477. board_to_path(brd, path_buffer);
  478. GRPRINTF(("klhwg_connect_hubs: Hub path is %s.n", path_buffer));
  479. rc = hwgraph_traverse(hwgraph_root, path_buffer, &hub_hndl);
  480. if (rc != GRAPH_SUCCESS)
  481. printk(KERN_WARNING  "Can't find hub: %s", path_buffer);
  482. dest_brd = (lboard_t *)NODE_OFFSET_TO_K0(
  483. hub->hub_port.port_nasid,
  484. hub->hub_port.port_offset);
  485. /* Generate a hardware graph path for this board. */
  486. board_to_path(dest_brd, dest_path);
  487. rc = hwgraph_traverse(hwgraph_root, dest_path, &dest_hndl);
  488. if (rc != GRAPH_SUCCESS) {
  489. if (is_specified(arg_maxnodes) && KL_CONFIG_DUPLICATE_BOARD(dest_brd))
  490. continue;
  491. PRINT_PANIC("Can't find board: %s", dest_path);
  492. } else {
  493. GRPRINTF(("klhwg_connect_hubs: Link from %s to %s.n",
  494.   path_buffer, dest_path));
  495. rc = hwgraph_edge_add(hub_hndl, dest_hndl, EDGE_LBL_INTERCONNECT);
  496. if (rc != GRAPH_SUCCESS)
  497. PRINT_PANIC("Can't create edge: %s/%s to vertex 0x%p, error 0x%xn",
  498. path_buffer, dest_path, (void *)dest_hndl, rc);
  499. }
  500. }
  501. }
  502. /* Store the pci/vme disabled board information as extended administrative
  503.  * hints which can later be used by the drivers using the device/driver
  504.  * admin interface. 
  505.  */
  506. void
  507. klhwg_device_disable_hints_add(void)
  508. {
  509. cnodeid_t cnode;  /* node we are looking at */
  510. nasid_t nasid; /* nasid of the node */
  511. lboard_t *board; /* board we are looking at */
  512. int comp_index; /* component index */
  513. klinfo_t *component; /* component in the board we are
  514.  * looking at 
  515.  */
  516. char device_name[MAXDEVNAME];
  517. #ifdef LATER
  518. device_admin_table_init();
  519. #endif
  520. for(cnode = 0; cnode < numnodes; cnode++) {
  521. nasid = COMPACT_TO_NASID_NODEID(cnode);
  522. board = (lboard_t *)KL_CONFIG_INFO(nasid);
  523. /* Check out all the board info stored  on a node */
  524. while(board) {
  525. /* No need to look at duplicate boards or non-io 
  526.  * boards
  527.  */
  528. if (KL_CONFIG_DUPLICATE_BOARD(board) ||
  529.     KLCLASS(board->brd_type) != KLCLASS_IO) {
  530. board = KLCF_NEXT(board);
  531. continue;
  532. }
  533. /* Check out all the components of a board */
  534. for (comp_index = 0; 
  535.      comp_index < KLCF_NUM_COMPS(board);
  536.      comp_index++) {
  537. component = KLCF_COMP(board,comp_index);
  538. /* If the component is enabled move on to
  539.  * the next component
  540.  */
  541. if (KLCONFIG_INFO_ENABLED(component))
  542. continue;
  543. /* NOTE : Since the prom only supports
  544.  * the disabling of pci devices the following
  545.  * piece of code makes sense. 
  546.  * Make sure that this assumption is valid
  547.  */
  548. /* This component is disabled. Store this
  549.  * hint in the extended device admin table
  550.  */
  551. /* Get the canonical name of the pci device */
  552. device_component_canonical_name_get(board,
  553.     component,
  554.     device_name);
  555. #ifdef LATER
  556. device_admin_table_update(device_name,
  557.   ADMIN_LBL_DISABLED,
  558.   "yes");
  559. #endif
  560. #ifdef DEBUG
  561. printf("%s DISABLEDn",device_name);
  562. #endif
  563. }
  564. /* go to the next board info stored on this 
  565.  * node 
  566.  */
  567. board = KLCF_NEXT(board);
  568. }
  569. }
  570. }
  571. void
  572. klhwg_add_all_modules(devfs_handle_t hwgraph_root)
  573. {
  574. cmoduleid_t cm;
  575. char name[128];
  576. devfs_handle_t vhdl;
  577. int rc;
  578. char buffer[16];
  579. /* Add devices under each module */
  580. for (cm = 0; cm < nummodules; cm++) {
  581. /* Use module as module vertex fastinfo */
  582. #ifdef __ia64
  583. memset(buffer, 0, 16);
  584. format_module_id(buffer, modules[cm]->id, MODULE_FORMAT_BRIEF);
  585. sprintf(name, EDGE_LBL_MODULE "/%s", buffer);
  586. #else
  587. sprintf(name, EDGE_LBL_MODULE "/%x", modules[cm]->id);
  588. #endif
  589. rc = hwgraph_path_add(hwgraph_root, name, &vhdl);
  590. ASSERT(rc == GRAPH_SUCCESS);
  591. rc = rc;
  592. hwgraph_fastinfo_set(vhdl, (arbitrary_info_t) modules[cm]);
  593. /* Add system controller */
  594. #ifdef __ia64
  595. sprintf(name,
  596. EDGE_LBL_MODULE "/%s/" EDGE_LBL_L1,
  597. buffer);
  598. #else
  599. sprintf(name,
  600. EDGE_LBL_MODULE "/%x/" EDGE_LBL_L1,
  601. modules[cm]->id);
  602. #endif
  603. rc = hwgraph_path_add(hwgraph_root, name, &vhdl);
  604. ASSERT_ALWAYS(rc == GRAPH_SUCCESS); 
  605. rc = rc;
  606. hwgraph_info_add_LBL(vhdl,
  607.      INFO_LBL_ELSC,
  608.      (arbitrary_info_t) (__psint_t) 1);
  609. #ifdef LATER
  610. sndrv_attach(vhdl);
  611. #else
  612. /*
  613.  * We need to call the drivers attach routine ..
  614.  */
  615. FIXME("klhwg_add_all_modules: Need code to call driver attach.n");
  616. #endif
  617. }
  618. }
  619. void
  620. klhwg_add_all_nodes(devfs_handle_t hwgraph_root)
  621. {
  622. cnodeid_t cnode;
  623. for (cnode = 0; cnode < numnodes; cnode++) {
  624. klhwg_add_node(hwgraph_root, cnode, NULL);
  625. }
  626. for (cnode = 0; cnode < numnodes; cnode++) {
  627. klhwg_add_xbow(cnode, cnodeid_to_nasid(cnode));
  628. }
  629. /*
  630.  * As for router hardware inventory information, we set this
  631.  * up in router.c. 
  632.  */
  633. klhwg_add_all_routers(hwgraph_root);
  634. klhwg_connect_routers(hwgraph_root);
  635. klhwg_connect_hubs(hwgraph_root);
  636. /* Assign guardian nodes to each of the
  637.  * routers in the system.
  638.  */
  639. #ifdef LATER
  640. router_guardians_set(hwgraph_root);
  641. #endif
  642. /* Go through the entire system's klconfig
  643.  * to figure out which pci components have been disabled
  644.  */
  645. klhwg_device_disable_hints_add();
  646. }