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

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. #ifndef _ASM_SN_XTALK_XTALK_H
  10. #define _ASM_SN_XTALK_XTALK_H
  11. /*
  12.  * xtalk.h -- platform-independent crosstalk interface
  13.  */
  14. /*
  15.  * User-level device driver visible types
  16.  */
  17. typedef char            xwidgetnum_t; /* xtalk widget number  (0..15) */
  18. #define XWIDGET_NONE (-1)
  19. typedef int xwidget_part_num_t; /* xtalk widget part number */
  20. #define XWIDGET_PART_NUM_NONE (-1)
  21. typedef int             xwidget_rev_num_t; /* xtalk widget revision number */
  22. #define XWIDGET_REV_NUM_NONE (-1)
  23. typedef int xwidget_mfg_num_t; /* xtalk widget manufacturing ID */
  24. #define XWIDGET_MFG_NUM_NONE (-1)
  25. typedef struct xtalk_piomap_s *xtalk_piomap_t;
  26. /* It is often convenient to fold the XIO target port
  27.  * number into the XIO address.
  28.  */
  29. #define XIO_NOWHERE (0xFFFFFFFFFFFFFFFFull)
  30. #define XIO_ADDR_BITS (0x0000FFFFFFFFFFFFull)
  31. #define XIO_PORT_BITS (0xF000000000000000ull)
  32. #define XIO_PORT_SHIFT (60)
  33. #define XIO_PACKED(x) (((x)&XIO_PORT_BITS) != 0)
  34. #define XIO_ADDR(x) ((x)&XIO_ADDR_BITS)
  35. #define XIO_PORT(x) ((xwidgetnum_t)(((x)&XIO_PORT_BITS) >> XIO_PORT_SHIFT))
  36. #define XIO_PACK(p,o) ((((uint64_t)(p))<<XIO_PORT_SHIFT) | ((o)&XIO_ADDR_BITS))
  37. /*
  38.  * Kernel/driver only definitions
  39.  */
  40. #if __KERNEL__
  41. #include <asm/types.h>
  42. #include <asm/sn/types.h>
  43. #include <asm/sn/alenlist.h>
  44. #include <asm/sn/ioerror.h>
  45. #include <asm/sn/driver.h>
  46. #include <asm/sn/dmamap.h>
  47. struct xwidget_hwid_s;
  48. /*
  49.  *    Acceptable flag bits for xtalk service calls
  50.  *
  51.  * XTALK_FIXED: require that mappings be established
  52.  * using fixed sharable resources; address
  53.  * translation results will be permanently
  54.  * available. (PIOMAP_FIXED and DMAMAP_FIXED are
  55.  * the same numeric value and are acceptable).
  56.  * XTALK_NOSLEEP: if any part of the operation would
  57.  * sleep waiting for resoruces, return an error
  58.  * instead. (PIOMAP_NOSLEEP and DMAMAP_NOSLEEP are
  59.  * the same numeric value and are acceptable).
  60.  * XTALK_INPLACE: when operating on alenlist structures,
  61.  * reuse the source alenlist rather than creating a
  62.  * new one. (PIOMAP_INPLACE and DMAMAP_INPLACE are
  63.  * the same numeric value and are acceptable).
  64.  */
  65. #define XTALK_FIXED DMAMAP_FIXED
  66. #define XTALK_NOSLEEP DMAMAP_NOSLEEP
  67. #define XTALK_INPLACE DMAMAP_INPLACE
  68. /* PIO MANAGEMENT */
  69. typedef xtalk_piomap_t
  70. xtalk_piomap_alloc_f    (devfs_handle_t dev, /* set up mapping for this device */
  71.  device_desc_t dev_desc, /* device descriptor */
  72.  iopaddr_t xtalk_addr, /* map for this xtalk_addr range */
  73.  size_t byte_count,
  74.  size_t byte_count_max, /* maximum size of a mapping */
  75.  unsigned flags); /* defined in sys/pio.h */
  76. typedef void
  77. xtalk_piomap_free_f     (xtalk_piomap_t xtalk_piomap);
  78. typedef caddr_t
  79. xtalk_piomap_addr_f     (xtalk_piomap_t xtalk_piomap, /* mapping resources */
  80.  iopaddr_t xtalk_addr, /* map for this xtalk address */
  81.  size_t byte_count); /* map this many bytes */
  82. typedef void
  83. xtalk_piomap_done_f     (xtalk_piomap_t xtalk_piomap);
  84. typedef caddr_t
  85. xtalk_piotrans_addr_f   (devfs_handle_t dev, /* translate for this device */
  86.  device_desc_t dev_desc, /* device descriptor */
  87.  iopaddr_t xtalk_addr, /* Crosstalk address */
  88.  size_t byte_count, /* map this many bytes */
  89.  unsigned flags); /* (currently unused) */
  90. extern caddr_t
  91. xtalk_pio_addr (devfs_handle_t dev, /* translate for this device */
  92.  device_desc_t dev_desc, /* device descriptor */
  93.  iopaddr_t xtalk_addr, /* Crosstalk address */
  94.  size_t byte_count, /* map this many bytes */
  95.  xtalk_piomap_t *xtalk_piomapp, /* RETURNS mapping resources */
  96.  unsigned flags); /* (currently unused) */
  97. /* DMA MANAGEMENT */
  98. typedef struct xtalk_dmamap_s *xtalk_dmamap_t;
  99. typedef xtalk_dmamap_t
  100. xtalk_dmamap_alloc_f    (devfs_handle_t dev, /* set up mappings for this device */
  101.  device_desc_t dev_desc, /* device descriptor */
  102.  size_t byte_count_max, /* max size of a mapping */
  103.  unsigned flags); /* defined in dma.h */
  104. typedef void
  105. xtalk_dmamap_free_f     (xtalk_dmamap_t dmamap);
  106. typedef iopaddr_t
  107. xtalk_dmamap_addr_f     (xtalk_dmamap_t dmamap, /* use these mapping resources */
  108.  paddr_t paddr, /* map for this address */
  109.  size_t byte_count); /* map this many bytes */
  110. typedef alenlist_t
  111. xtalk_dmamap_list_f     (xtalk_dmamap_t dmamap, /* use these mapping resources */
  112.  alenlist_t alenlist, /* map this address/length list */
  113.  unsigned flags);
  114. typedef void
  115. xtalk_dmamap_done_f     (xtalk_dmamap_t dmamap);
  116. typedef iopaddr_t
  117. xtalk_dmatrans_addr_f   (devfs_handle_t dev, /* translate for this device */
  118.  device_desc_t dev_desc, /* device descriptor */
  119.  paddr_t paddr, /* system physical address */
  120.  size_t byte_count, /* length */
  121.  unsigned flags);
  122. typedef alenlist_t
  123. xtalk_dmatrans_list_f   (devfs_handle_t dev, /* translate for this device */
  124.  device_desc_t dev_desc, /* device descriptor */
  125.  alenlist_t palenlist, /* system address/length list */
  126.  unsigned flags);
  127. typedef void
  128. xtalk_dmamap_drain_f (xtalk_dmamap_t map); /* drain this map's channel */
  129. typedef void
  130. xtalk_dmaaddr_drain_f (devfs_handle_t vhdl, /* drain channel from this device */
  131.  paddr_t addr, /* to this physical address */
  132.  size_t bytes); /* for this many bytes */
  133. typedef void
  134. xtalk_dmalist_drain_f (devfs_handle_t vhdl, /* drain channel from this device */
  135.  alenlist_t list); /* for this set of physical blocks */
  136. /* INTERRUPT MANAGEMENT */
  137. /*
  138.  * A xtalk interrupt resource handle.  When resources are allocated
  139.  * in order to satisfy a xtalk_intr_alloc request, a xtalk_intr handle
  140.  * is returned.  xtalk_intr_connect associates a software handler with
  141.  * these system resources.
  142.  */
  143. typedef struct xtalk_intr_s *xtalk_intr_t;
  144. /*
  145.  * When a crosstalk device connects an interrupt, it passes in a function
  146.  * that knows how to set its xtalk interrupt register appropriately.  The
  147.  * low-level interrupt code may invoke this function later in order to
  148.  * migrate an interrupt transparently to the device driver(s) that use this
  149.  * interrupt.
  150.  *
  151.  * The argument passed to this function contains enough information for a
  152.  * crosstalk device to (re-)target an interrupt.  A function of this type
  153.  * must be supplied by every crosstalk driver.
  154.  */
  155. typedef int
  156. xtalk_intr_setfunc_f    (xtalk_intr_t intr_hdl); /* interrupt handle */
  157. typedef xtalk_intr_t
  158. xtalk_intr_alloc_f      (devfs_handle_t dev, /* which crosstalk device */
  159.  device_desc_t dev_desc, /* device descriptor */
  160.  devfs_handle_t owner_dev); /* owner of this intr */
  161. typedef void
  162. xtalk_intr_free_f       (xtalk_intr_t intr_hdl);
  163. typedef int
  164. xtalk_intr_connect_f    (xtalk_intr_t intr_hdl, /* xtalk intr resource handle */
  165.  xtalk_intr_setfunc_f *setfunc, /* func to set intr hw */
  166.  void *setfunc_arg); /* arg to setfunc */
  167. typedef void
  168. xtalk_intr_disconnect_f (xtalk_intr_t intr_hdl);
  169. typedef devfs_handle_t
  170. xtalk_intr_cpu_get_f    (xtalk_intr_t intr_hdl); /* xtalk intr resource handle */
  171. /* CONFIGURATION MANAGEMENT */
  172. typedef void
  173. xtalk_provider_startup_f (devfs_handle_t xtalk_provider);
  174. typedef void
  175. xtalk_provider_shutdown_f (devfs_handle_t xtalk_provider);
  176. typedef void
  177. xtalk_widgetdev_enable_f (devfs_handle_t, int);
  178. typedef void
  179. xtalk_widgetdev_shutdown_f (devfs_handle_t, int);
  180. typedef int
  181. xtalk_dma_enabled_f (devfs_handle_t);
  182. /* Error Management */
  183. typedef int
  184. xtalk_error_devenable_f (devfs_handle_t xconn_vhdl,
  185.  int devnum,
  186.  int error_code);
  187. /* Early Action Support */
  188. typedef caddr_t
  189. xtalk_early_piotrans_addr_f (xwidget_part_num_t part_num,
  190.      xwidget_mfg_num_t mfg_num,
  191.      int which,
  192.      iopaddr_t xtalk_addr,
  193.      size_t byte_count,
  194.      unsigned flags);
  195. /*
  196.  * Adapters that provide a crosstalk interface adhere to this software interface.
  197.  */
  198. typedef struct xtalk_provider_s {
  199.     /* PIO MANAGEMENT */
  200.     xtalk_piomap_alloc_f   *piomap_alloc;
  201.     xtalk_piomap_free_f    *piomap_free;
  202.     xtalk_piomap_addr_f    *piomap_addr;
  203.     xtalk_piomap_done_f    *piomap_done;
  204.     xtalk_piotrans_addr_f  *piotrans_addr;
  205.     /* DMA MANAGEMENT */
  206.     xtalk_dmamap_alloc_f   *dmamap_alloc;
  207.     xtalk_dmamap_free_f    *dmamap_free;
  208.     xtalk_dmamap_addr_f    *dmamap_addr;
  209.     xtalk_dmamap_list_f    *dmamap_list;
  210.     xtalk_dmamap_done_f    *dmamap_done;
  211.     xtalk_dmatrans_addr_f  *dmatrans_addr;
  212.     xtalk_dmatrans_list_f  *dmatrans_list;
  213.     xtalk_dmamap_drain_f   *dmamap_drain;
  214.     xtalk_dmaaddr_drain_f  *dmaaddr_drain;
  215.     xtalk_dmalist_drain_f  *dmalist_drain;
  216.     /* INTERRUPT MANAGEMENT */
  217.     xtalk_intr_alloc_f     *intr_alloc;
  218.     xtalk_intr_alloc_f     *intr_alloc_nothd;
  219.     xtalk_intr_free_f      *intr_free;
  220.     xtalk_intr_connect_f   *intr_connect;
  221.     xtalk_intr_disconnect_f *intr_disconnect;
  222.     xtalk_intr_cpu_get_f   *intr_cpu_get;
  223.     /* CONFIGURATION MANAGEMENT */
  224.     xtalk_provider_startup_f *provider_startup;
  225.     xtalk_provider_shutdown_f *provider_shutdown;
  226.     /* Error Management     */
  227.     xtalk_error_devenable_f *error_devenable;
  228. } xtalk_provider_t;
  229. /* Crosstalk devices use these standard Crosstalk provider interfaces */
  230. extern xtalk_piomap_alloc_f xtalk_piomap_alloc;
  231. extern xtalk_piomap_free_f xtalk_piomap_free;
  232. extern xtalk_piomap_addr_f xtalk_piomap_addr;
  233. extern xtalk_piomap_done_f xtalk_piomap_done;
  234. extern xtalk_piotrans_addr_f xtalk_piotrans_addr;
  235. extern xtalk_dmamap_alloc_f xtalk_dmamap_alloc;
  236. extern xtalk_dmamap_free_f xtalk_dmamap_free;
  237. extern xtalk_dmamap_addr_f xtalk_dmamap_addr;
  238. extern xtalk_dmamap_list_f xtalk_dmamap_list;
  239. extern xtalk_dmamap_done_f xtalk_dmamap_done;
  240. extern xtalk_dmatrans_addr_f xtalk_dmatrans_addr;
  241. extern xtalk_dmatrans_list_f xtalk_dmatrans_list;
  242. extern xtalk_dmamap_drain_f xtalk_dmamap_drain;
  243. extern xtalk_dmaaddr_drain_f xtalk_dmaaddr_drain;
  244. extern xtalk_dmalist_drain_f xtalk_dmalist_drain;
  245. extern xtalk_intr_alloc_f xtalk_intr_alloc;
  246. extern xtalk_intr_alloc_f xtalk_intr_alloc_nothd;
  247. extern xtalk_intr_free_f xtalk_intr_free;
  248. extern xtalk_intr_connect_f xtalk_intr_connect;
  249. extern xtalk_intr_disconnect_f xtalk_intr_disconnect;
  250. extern xtalk_intr_cpu_get_f xtalk_intr_cpu_get;
  251. extern xtalk_provider_startup_f xtalk_provider_startup;
  252. extern xtalk_provider_shutdown_f xtalk_provider_shutdown;
  253. extern xtalk_widgetdev_enable_f xtalk_widgetdev_enable;
  254. extern xtalk_widgetdev_shutdown_f xtalk_widgetdev_shutdown;
  255. extern xtalk_dma_enabled_f xtalk_dma_enabled;
  256. extern xtalk_error_devenable_f xtalk_error_devenable;
  257. extern xtalk_early_piotrans_addr_f xtalk_early_piotrans_addr;
  258. /* error management */
  259. extern int              xtalk_error_handler(devfs_handle_t,
  260.     int,
  261.     ioerror_mode_t,
  262.     ioerror_t *);
  263. /*
  264.  * Generic crosstalk interface, for use with all crosstalk providers
  265.  * and all crosstalk devices.
  266.  */
  267. typedef unchar xtalk_intr_vector_t; /* crosstalk interrupt vector (0..255) */
  268. #define XTALK_INTR_VECTOR_NONE (xtalk_intr_vector_t)0
  269. /* Generic crosstalk interrupt interfaces */
  270. extern devfs_handle_t     xtalk_intr_dev_get(xtalk_intr_t xtalk_intr);
  271. extern xwidgetnum_t     xtalk_intr_target_get(xtalk_intr_t xtalk_intr);
  272. extern xtalk_intr_vector_t xtalk_intr_vector_get(xtalk_intr_t xtalk_intr);
  273. extern iopaddr_t        xtalk_intr_addr_get(xtalk_intr_t xtalk_intr);
  274. extern devfs_handle_t     xtalk_intr_cpu_get(xtalk_intr_t xtalk_intr);
  275. extern void            *xtalk_intr_sfarg_get(xtalk_intr_t xtalk_intr);
  276. /* Generic crosstalk pio interfaces */
  277. extern devfs_handle_t     xtalk_pio_dev_get(xtalk_piomap_t xtalk_piomap);
  278. extern xwidgetnum_t     xtalk_pio_target_get(xtalk_piomap_t xtalk_piomap);
  279. extern iopaddr_t        xtalk_pio_xtalk_addr_get(xtalk_piomap_t xtalk_piomap);
  280. extern size_t           xtalk_pio_mapsz_get(xtalk_piomap_t xtalk_piomap);
  281. extern caddr_t          xtalk_pio_kvaddr_get(xtalk_piomap_t xtalk_piomap);
  282. /* Generic crosstalk dma interfaces */
  283. extern devfs_handle_t     xtalk_dma_dev_get(xtalk_dmamap_t xtalk_dmamap);
  284. extern xwidgetnum_t     xtalk_dma_target_get(xtalk_dmamap_t xtalk_dmamap);
  285. /* Register/unregister Crosstalk providers and get implementation handle */
  286. extern void             xtalk_set_early_piotrans_addr(xtalk_early_piotrans_addr_f *);
  287. extern void             xtalk_provider_register(devfs_handle_t provider, xtalk_provider_t *xtalk_fns);
  288. extern void             xtalk_provider_unregister(devfs_handle_t provider);
  289. extern xtalk_provider_t *xtalk_provider_fns_get(devfs_handle_t provider);
  290. /* Crosstalk Switch generic layer, for use by initialization code */
  291. extern void             xswitch_census(devfs_handle_t xswitchv);
  292. extern void             xswitch_init_widgets(devfs_handle_t xswitchv);
  293. /* early init interrupt management */
  294. typedef void
  295. xwidget_intr_preset_f   (void *which_widget,
  296.  int which_widget_intr,
  297.  xwidgetnum_t targ,
  298.  iopaddr_t addr,
  299.  xtalk_intr_vector_t vect);
  300. typedef void
  301. xtalk_intr_prealloc_f   (void *which_xtalk,
  302.  xtalk_intr_vector_t xtalk_vector,
  303.  xwidget_intr_preset_f *preset_func,
  304.  void *which_widget,
  305.  int which_widget_intr);
  306. typedef void
  307. xtalk_intr_preconn_f    (void *which_xtalk,
  308.  xtalk_intr_vector_t xtalk_vector,
  309.  intr_func_t intr_func,
  310.  intr_arg_t intr_arg);
  311. #define XTALK_ADDR_TO_UPPER(xtalk_addr) (((iopaddr_t)(xtalk_addr) >> 32) & 0xffff)
  312. #define XTALK_ADDR_TO_LOWER(xtalk_addr) ((iopaddr_t)(xtalk_addr) & 0xffffffff)
  313. typedef xtalk_intr_setfunc_f *xtalk_intr_setfunc_t;
  314. typedef void xtalk_iter_f(devfs_handle_t vhdl);
  315. extern void xtalk_iterate(char *prefix, xtalk_iter_f *func);
  316. extern int xtalk_device_powerup(devfs_handle_t, xwidgetnum_t);
  317. extern int xtalk_device_shutdown(devfs_handle_t, xwidgetnum_t);
  318. #endif /* __KERNEL__ */
  319. #endif /* _ASM_SN_XTALK_XTALK_H */