spufs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. struct fasync_struct *ibox_fasync;
  47. struct fasync_struct *wbox_fasync;
  48. struct spu_context_ops *ops;
  49. };
  50. /* SPU context query/set operations. */
  51. struct spu_context_ops {
  52. int (*mbox_read) (struct spu_context * ctx, u32 * data);
  53. u32(*mbox_stat_read) (struct spu_context * ctx);
  54. int (*ibox_read) (struct spu_context * ctx, u32 * data);
  55. int (*wbox_write) (struct spu_context * ctx, u32 data);
  56. u32(*signal1_read) (struct spu_context * ctx);
  57. void (*signal1_write) (struct spu_context * ctx, u32 data);
  58. u32(*signal2_read) (struct spu_context * ctx);
  59. void (*signal2_write) (struct spu_context * ctx, u32 data);
  60. void (*signal1_type_set) (struct spu_context * ctx, u64 val);
  61. u64(*signal1_type_get) (struct spu_context * ctx);
  62. void (*signal2_type_set) (struct spu_context * ctx, u64 val);
  63. u64(*signal2_type_get) (struct spu_context * ctx);
  64. u32(*npc_read) (struct spu_context * ctx);
  65. void (*npc_write) (struct spu_context * ctx, u32 data);
  66. u32(*status_read) (struct spu_context * ctx);
  67. char*(*get_ls) (struct spu_context * ctx);
  68. };
  69. extern struct spu_context_ops spu_hw_ops;
  70. extern struct spu_context_ops spu_backing_ops;
  71. struct spufs_inode_info {
  72. struct spu_context *i_ctx;
  73. struct inode vfs_inode;
  74. };
  75. #define SPUFS_I(inode) \
  76. container_of(inode, struct spufs_inode_info, vfs_inode)
  77. extern struct tree_descr spufs_dir_contents[];
  78. /* system call implementation */
  79. long spufs_run_spu(struct file *file,
  80. struct spu_context *ctx, u32 *npc, u32 *status);
  81. long spufs_create_thread(struct nameidata *nd, const char *name,
  82. unsigned int flags, mode_t mode);
  83. /* context management */
  84. struct spu_context * alloc_spu_context(struct address_space *local_store);
  85. void destroy_spu_context(struct kref *kref);
  86. struct spu_context * get_spu_context(struct spu_context *ctx);
  87. int put_spu_context(struct spu_context *ctx);
  88. void spu_forget(struct spu_context *ctx);
  89. void spu_acquire(struct spu_context *ctx);
  90. void spu_release(struct spu_context *ctx);
  91. int spu_acquire_runnable(struct spu_context *ctx);
  92. void spu_acquire_saved(struct spu_context *ctx);
  93. int spu_activate(struct spu_context *ctx, u64 flags);
  94. void spu_deactivate(struct spu_context *ctx);
  95. void spu_yield(struct spu_context *ctx);
  96. int __init spu_sched_init(void);
  97. void __exit spu_sched_exit(void);
  98. size_t spu_wbox_write(struct spu_context *ctx, u32 data);
  99. size_t spu_ibox_read(struct spu_context *ctx, u32 *data);
  100. /* irq callback funcs. */
  101. void spufs_ibox_callback(struct spu *spu);
  102. void spufs_wbox_callback(struct spu *spu);
  103. #endif