spufs.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. #define SPU_CONTEXT_PREEMPT_nr 0UL
  36. #define SPU_CONTEXT_PREEMPT (1UL << SPU_CONTEXT_PREEMPT_nr)
  37. struct spu_context {
  38. struct spu *spu; /* pointer to a physical SPU */
  39. struct spu_state csa; /* SPU context save area. */
  40. spinlock_t mmio_lock; /* protects mmio access */
  41. struct address_space *local_store;/* local store backing store */
  42. enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state;
  43. struct rw_semaphore state_sema;
  44. struct mm_struct *owner;
  45. struct kref kref;
  46. wait_queue_head_t ibox_wq;
  47. wait_queue_head_t wbox_wq;
  48. wait_queue_head_t stop_wq;
  49. struct fasync_struct *ibox_fasync;
  50. struct fasync_struct *wbox_fasync;
  51. struct spu_context_ops *ops;
  52. struct work_struct reap_work;
  53. u64 flags;
  54. };
  55. /* SPU context query/set operations. */
  56. struct spu_context_ops {
  57. int (*mbox_read) (struct spu_context * ctx, u32 * data);
  58. u32(*mbox_stat_read) (struct spu_context * ctx);
  59. int (*ibox_read) (struct spu_context * ctx, u32 * data);
  60. int (*wbox_write) (struct spu_context * ctx, u32 data);
  61. u32(*signal1_read) (struct spu_context * ctx);
  62. void (*signal1_write) (struct spu_context * ctx, u32 data);
  63. u32(*signal2_read) (struct spu_context * ctx);
  64. void (*signal2_write) (struct spu_context * ctx, u32 data);
  65. void (*signal1_type_set) (struct spu_context * ctx, u64 val);
  66. u64(*signal1_type_get) (struct spu_context * ctx);
  67. void (*signal2_type_set) (struct spu_context * ctx, u64 val);
  68. u64(*signal2_type_get) (struct spu_context * ctx);
  69. u32(*npc_read) (struct spu_context * ctx);
  70. void (*npc_write) (struct spu_context * ctx, u32 data);
  71. u32(*status_read) (struct spu_context * ctx);
  72. char*(*get_ls) (struct spu_context * ctx);
  73. void (*runcntl_write) (struct spu_context * ctx, u32 data);
  74. void (*runcntl_stop) (struct spu_context * ctx);
  75. };
  76. extern struct spu_context_ops spu_hw_ops;
  77. extern struct spu_context_ops spu_backing_ops;
  78. struct spufs_inode_info {
  79. struct spu_context *i_ctx;
  80. struct inode vfs_inode;
  81. };
  82. #define SPUFS_I(inode) \
  83. container_of(inode, struct spufs_inode_info, vfs_inode)
  84. extern struct tree_descr spufs_dir_contents[];
  85. /* system call implementation */
  86. long spufs_run_spu(struct file *file,
  87. struct spu_context *ctx, u32 *npc, u32 *status);
  88. long spufs_create_thread(struct nameidata *nd, const char *name,
  89. unsigned int flags, mode_t mode);
  90. /* context management */
  91. struct spu_context * alloc_spu_context(struct address_space *local_store);
  92. void destroy_spu_context(struct kref *kref);
  93. struct spu_context * get_spu_context(struct spu_context *ctx);
  94. int put_spu_context(struct spu_context *ctx);
  95. void spu_unmap_mappings(struct spu_context *ctx);
  96. void spu_forget(struct spu_context *ctx);
  97. void spu_acquire(struct spu_context *ctx);
  98. void spu_release(struct spu_context *ctx);
  99. int spu_acquire_runnable(struct spu_context *ctx);
  100. void spu_acquire_saved(struct spu_context *ctx);
  101. int spu_activate(struct spu_context *ctx, u64 flags);
  102. void spu_deactivate(struct spu_context *ctx);
  103. void spu_yield(struct spu_context *ctx);
  104. int __init spu_sched_init(void);
  105. void __exit spu_sched_exit(void);
  106. size_t spu_wbox_write(struct spu_context *ctx, u32 data);
  107. size_t spu_ibox_read(struct spu_context *ctx, u32 *data);
  108. /* irq callback funcs. */
  109. void spufs_ibox_callback(struct spu *spu);
  110. void spufs_wbox_callback(struct spu *spu);
  111. void spufs_stop_callback(struct spu *spu);
  112. #endif