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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  *
  3.  * This file is subject to the terms and conditions of the GNU General Public
  4.  * License.  See the file "COPYING" in the main directory of this archive
  5.  * for more details.
  6.  *
  7.  * Copyright (C) 2001-2002 Silicon Graphics, Inc. All rights reserved.
  8.  */
  9. #include <linux/types.h>
  10. #include <linux/slab.h>
  11. #include <linux/module.h>
  12. #include <asm/sn/sgi.h>
  13. #include <asm/sn/sn_cpuid.h>
  14. #include <asm/sn/addrs.h>
  15. #include <asm/sn/arch.h>
  16. #include <asm/sn/iograph.h>
  17. #include <asm/sn/invent.h>
  18. #include <asm/sn/hcl.h>
  19. #include <asm/sn/labelcl.h>
  20. #include <asm/sn/xtalk/xwidget.h>
  21. #include <asm/sn/pci/bridge.h>
  22. #include <asm/sn/pci/pciio.h>
  23. #include <asm/sn/pci/pcibr.h>
  24. #include <asm/sn/pci/pcibr_private.h>
  25. #include <asm/sn/pci/pci_defs.h>
  26. #include <asm/sn/prio.h>
  27. #include <asm/sn/xtalk/xbow.h>
  28. #include <asm/sn/ioc3.h>
  29. #include <asm/sn/eeprom.h>
  30. #include <asm/sn/io.h>
  31. #include <asm/sn/sn_private.h>
  32. pcibr_hints_t           pcibr_hints_get(devfs_handle_t, int);
  33. void                    pcibr_hints_fix_rrbs(devfs_handle_t);
  34. void                    pcibr_hints_dualslot(devfs_handle_t, pciio_slot_t, pciio_slot_t);
  35. void pcibr_hints_intr_bits(devfs_handle_t, pcibr_intr_bits_f *);
  36. void                    pcibr_set_rrb_callback(devfs_handle_t, rrb_alloc_funct_t);
  37. void                    pcibr_hints_handsoff(devfs_handle_t);
  38. void                    pcibr_hints_subdevs(devfs_handle_t, pciio_slot_t, uint64_t);
  39. pcibr_hints_t
  40. pcibr_hints_get(devfs_handle_t xconn_vhdl, int alloc)
  41. {
  42.     arbitrary_info_t        ainfo = 0;
  43.     graph_error_t     rv;
  44.     pcibr_hints_t           hint;
  45.     rv = hwgraph_info_get_LBL(xconn_vhdl, INFO_LBL_PCIBR_HINTS, &ainfo);
  46.     if (alloc && (rv != GRAPH_SUCCESS)) {
  47. NEW(hint);
  48. hint->rrb_alloc_funct = NULL;
  49. hint->ph_intr_bits = NULL;
  50. rv = hwgraph_info_add_LBL(xconn_vhdl, 
  51.   INFO_LBL_PCIBR_HINTS, 
  52.   (arbitrary_info_t) hint);
  53. if (rv != GRAPH_SUCCESS)
  54.     goto abnormal_exit;
  55. rv = hwgraph_info_get_LBL(xconn_vhdl, INFO_LBL_PCIBR_HINTS, &ainfo);
  56. if (rv != GRAPH_SUCCESS)
  57.     goto abnormal_exit;
  58. if (ainfo != (arbitrary_info_t) hint)
  59.     goto abnormal_exit;
  60.     }
  61.     return (pcibr_hints_t) ainfo;
  62. abnormal_exit:
  63. #ifdef LATER
  64.     printf("SHOULD NOT BE HEREn");
  65. #endif
  66.     DEL(hint);
  67.     return(NULL);
  68. }
  69. void
  70. pcibr_hints_fix_some_rrbs(devfs_handle_t xconn_vhdl, unsigned mask)
  71. {
  72.     pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
  73.     if (hint)
  74. hint->ph_rrb_fixed = mask;
  75. #if DEBUG
  76.     else
  77. printk("pcibr_hints_fix_rrbs: pcibr_hints_get failed atn"
  78. "t%pn", xconn_vhdl);
  79. #endif
  80. }
  81. void
  82. pcibr_hints_fix_rrbs(devfs_handle_t xconn_vhdl)
  83. {
  84.     pcibr_hints_fix_some_rrbs(xconn_vhdl, 0xFF);
  85. }
  86. void
  87. pcibr_hints_dualslot(devfs_handle_t xconn_vhdl,
  88.      pciio_slot_t host,
  89.      pciio_slot_t guest)
  90. {
  91.     pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
  92.     if (hint)
  93. hint->ph_host_slot[guest] = host + 1;
  94. #if DEBUG
  95.     else
  96. printk("pcibr_hints_dualslot: pcibr_hints_get failed atn"
  97. "t%pn", xconn_vhdl);
  98. #endif
  99. }
  100. void
  101. pcibr_hints_intr_bits(devfs_handle_t xconn_vhdl,
  102.       pcibr_intr_bits_f *xxx_intr_bits)
  103. {
  104.     pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
  105.     if (hint)
  106. hint->ph_intr_bits = xxx_intr_bits;
  107. #if DEBUG
  108.     else
  109. printk("pcibr_hints_intr_bits: pcibr_hints_get failed atn"
  110.        "t%pn", xconn_vhdl);
  111. #endif
  112. }
  113. void
  114. pcibr_set_rrb_callback(devfs_handle_t xconn_vhdl, rrb_alloc_funct_t rrb_alloc_funct)
  115. {
  116.     pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
  117.     if (hint)
  118. hint->rrb_alloc_funct = rrb_alloc_funct;
  119. }
  120. void
  121. pcibr_hints_handsoff(devfs_handle_t xconn_vhdl)
  122. {
  123.     pcibr_hints_t           hint = pcibr_hints_get(xconn_vhdl, 1);
  124.     if (hint)
  125. hint->ph_hands_off = 1;
  126. #if DEBUG
  127.     else
  128. printk("pcibr_hints_handsoff: pcibr_hints_get failed atn"
  129. "t%pn", xconn_vhdl);
  130. #endif
  131. }
  132. void
  133. pcibr_hints_subdevs(devfs_handle_t xconn_vhdl,
  134.     pciio_slot_t slot,
  135.     uint64_t subdevs)
  136. {
  137.     arbitrary_info_t        ainfo = 0;
  138.     char                    sdname[16];
  139.     devfs_handle_t            pconn_vhdl = GRAPH_VERTEX_NONE;
  140.     sprintf(sdname, "pci/%d", slot);
  141.     (void) hwgraph_path_add(xconn_vhdl, sdname, &pconn_vhdl);
  142.     if (pconn_vhdl == GRAPH_VERTEX_NONE) {
  143. #if DEBUG
  144. printk("pcibr_hints_subdevs: hwgraph_path_create failed atn"
  145. "t%p (seeking %s)n", xconn_vhdl, sdname);
  146. #endif
  147. return;
  148.     }
  149.     hwgraph_info_get_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, &ainfo);
  150.     if (ainfo == 0) {
  151. uint64_t                *subdevp;
  152. NEW(subdevp);
  153. if (!subdevp) {
  154. #if DEBUG
  155.     printk("pcibr_hints_subdevs: subdev ptr alloc failed atn"
  156.     "t%pn", pconn_vhdl);
  157. #endif
  158.     return;
  159. }
  160. *subdevp = subdevs;
  161. hwgraph_info_add_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, (arbitrary_info_t) subdevp);
  162. hwgraph_info_get_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, &ainfo);
  163. if (ainfo == (arbitrary_info_t) subdevp)
  164.     return;
  165. DEL(subdevp);
  166. if (ainfo == (arbitrary_info_t) NULL) {
  167. #if DEBUG
  168.     printk("pcibr_hints_subdevs: null subdevs ptr atn"
  169.     "t%pn", pconn_vhdl);
  170. #endif
  171.     return;
  172. }
  173. #if DEBUG
  174. printk("pcibr_subdevs_get: dup subdev add_LBL atn"
  175. "t%pn", pconn_vhdl);
  176. #endif
  177.     }
  178.     *(uint64_t *) ainfo = subdevs;
  179. }