spufs.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * SPU file system
  3. *
  4. * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
  5. *
  6. * Author: Arnd Bergmann <arndb@de.ibm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2, or (at your option)
  11. * any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #ifndef SPUFS_H
  23. #define SPUFS_H
  24. #include <linux/kref.h>
  25. #include <linux/rwsem.h>
  26. #include <linux/spinlock.h>
  27. #include <linux/fs.h>
  28. #include <asm/spu.h>
  29. #include <asm/spu_csa.h>
  30. /* The magic number for our file system */
  31. enum {
  32. SPUFS_MAGIC = 0x23c9b64e,
  33. };
  34. struct spu_context_ops;
  35. struct spu_context {
  36. struct spu *spu; /* pointer to a physical SPU */
  37. struct spu_state csa; /* SPU context save area. */
  38. spinlock_t mmio_lock; /* protects mmio access */
  39. struct address_space *local_store;/* local store backing store */
  40. enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state;
  41. struct rw_semaphore state_sema;
  42. struct mm_struct *owner;
  43. struct kref kref;
  44. wait_queue_head_t ibox_wq;
  45. wait_queue_head_t wbox_wq;
  46. wait_queue_head_t stop_wq;
  47. struct fasync_struct *ibox_fasync;
  48. struct fasync_struct *wbox_fasync;
  49. struct spu_context_ops *ops;
  50. };
  51. /* SPU context query/set operations. */
  52. struct spu_context_ops {
  53. int (*mbox_read) (struct spu_context * ctx, u32 * data);
  54. u32(*mbox_stat_read) (struct spu_context * ctx);
  55. int (*ibox_read) (struct spu_context * ctx, u32 * data);
  56. int (*wbox_write) (struct spu_context * ctx, u32 data);
  57. u32(*signal1_read) (struct spu_context * ctx);
  58. void (*signal1_write) (struct spu_context * ctx, u32 data);
  59. u32(*signal2_read) (struct spu_context * ctx);
  60. void (*signal2_write) (struct spu_context * ctx, u32 data);
  61. void (*signal1_type_set) (struct spu_context * ctx, u64 val);
  62. u64(*signal1_type_get) (struct spu_context * ctx);
  63. void (*signal2_type_set) (struct spu_context * ctx, u64 val);
  64. u64(*signal2_type_get) (struct spu_context * ctx);
  65. u32(*npc_read) (struct spu_context * ctx);
  66. void (*npc_write) (struct spu_context * ctx, u32 data);
  67. u32(*status_read) (struct spu_context * ctx);
  68. char*(*get_ls) (struct spu_context * ctx);
  69. void (*runcntl_write) (struct spu_context * ctx, u32 data);
  70. void (*runcntl_stop) (struct spu_context * ctx);
  71. };
  72. extern struct spu_context_ops spu_hw_ops;
  73. extern struct spu_context_ops spu_backing_ops;
  74. struct spufs_inode_info {
  75. struct spu_context *i_ctx;
  76. struct inode vfs_inode;
  77. };
  78. #define SPUFS_I(inode) \
  79. container_of(inode, struct spufs_inode_info, vfs_inode)
  80. extern struct tree_descr spufs_dir_contents[];
  81. /* system call implementation */
  82. long spufs_run_spu(struct file *file,
  83. struct spu_context *ctx, u32 *npc, u32 *status);
  84. long spufs_create_thread(struct nameidata *nd, const char *name,
  85. unsigned int flags, mode_t mode);
  86. /* context management */
  87. struct spu_context * alloc_spu_context(struct address_space *local_store);
  88. void destroy_spu_context(struct kref *kref);
  89. struct spu_context * get_spu_context(struct spu_context *ctx);
  90. int put_spu_context(struct spu_context *ctx);
  91. void spu_unmap_mappings(struct spu_context *ctx);
  92. void spu_forget(struct spu_context *ctx);
  93. void spu_acquire(struct spu_context *ctx);
  94. void spu_release(struct spu_context *ctx);
  95. int spu_acquire_runnable(struct spu_context *ctx);
  96. void spu_acquire_saved(struct spu_context *ctx);
  97. int spu_activate(struct spu_context *ctx, u64 flags);
  98. void spu_deactivate(struct spu_context *ctx);
  99. void spu_yield(struct spu_context *ctx);
  100. int __init spu_sched_init(void);
  101. void __exit spu_sched_exit(void);
  102. size_t spu_wbox_write(struct spu_context *ctx, u32 data);
  103. size_t spu_ibox_read(struct spu_context *ctx, u32 *data);
  104. /* irq callback funcs. */
  105. void spufs_ibox_callback(struct spu *spu);
  106. void spufs_wbox_callback(struct spu *spu);
  107. void spufs_stop_callback(struct spu *spu);
  108. #endif