Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 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 | |
| 25 | #include <linux/kref.h> |
| 26 | #include <linux/rwsem.h> |
| 27 | #include <linux/spinlock.h> |
| 28 | #include <linux/fs.h> |
| 29 | |
| 30 | #include <asm/spu.h> |
Mark Nutter | 5473af0 | 2005-11-15 15:53:49 -0500 | [diff] [blame] | 31 | #include <asm/spu_csa.h> |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 32 | |
| 33 | /* The magic number for our file system */ |
| 34 | enum { |
| 35 | SPUFS_MAGIC = 0x23c9b64e, |
| 36 | }; |
| 37 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 38 | struct spu_context_ops; |
| 39 | |
Arnd Bergmann | 8837d92 | 2006-01-04 20:31:28 +0100 | [diff] [blame^] | 40 | #define SPU_CONTEXT_PREEMPT 0UL |
Arnd Bergmann | 2a911f0 | 2005-12-05 22:52:26 -0500 | [diff] [blame] | 41 | |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 42 | struct spu_context { |
| 43 | struct spu *spu; /* pointer to a physical SPU */ |
Mark Nutter | 5473af0 | 2005-11-15 15:53:49 -0500 | [diff] [blame] | 44 | struct spu_state csa; /* SPU context save area. */ |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 45 | spinlock_t mmio_lock; /* protects mmio access */ |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 46 | struct address_space *local_store;/* local store backing store */ |
| 47 | |
| 48 | enum { SPU_STATE_RUNNABLE, SPU_STATE_SAVED } state; |
| 49 | struct rw_semaphore state_sema; |
Arnd Bergmann | 5ef8224 | 2006-01-04 20:31:24 +0100 | [diff] [blame] | 50 | struct semaphore run_sema; |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 51 | |
| 52 | struct mm_struct *owner; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 53 | |
| 54 | struct kref kref; |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 55 | wait_queue_head_t ibox_wq; |
| 56 | wait_queue_head_t wbox_wq; |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 57 | wait_queue_head_t stop_wq; |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 58 | struct fasync_struct *ibox_fasync; |
| 59 | struct fasync_struct *wbox_fasync; |
| 60 | struct spu_context_ops *ops; |
Arnd Bergmann | 2a911f0 | 2005-12-05 22:52:26 -0500 | [diff] [blame] | 61 | struct work_struct reap_work; |
| 62 | u64 flags; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 63 | }; |
| 64 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 65 | /* SPU context query/set operations. */ |
| 66 | struct spu_context_ops { |
| 67 | int (*mbox_read) (struct spu_context * ctx, u32 * data); |
| 68 | u32(*mbox_stat_read) (struct spu_context * ctx); |
Arnd Bergmann | 3a843d7 | 2005-12-05 22:52:27 -0500 | [diff] [blame] | 69 | unsigned int (*mbox_stat_poll)(struct spu_context *ctx, |
| 70 | unsigned int events); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 71 | int (*ibox_read) (struct spu_context * ctx, u32 * data); |
| 72 | int (*wbox_write) (struct spu_context * ctx, u32 data); |
| 73 | u32(*signal1_read) (struct spu_context * ctx); |
| 74 | void (*signal1_write) (struct spu_context * ctx, u32 data); |
| 75 | u32(*signal2_read) (struct spu_context * ctx); |
| 76 | void (*signal2_write) (struct spu_context * ctx, u32 data); |
| 77 | void (*signal1_type_set) (struct spu_context * ctx, u64 val); |
| 78 | u64(*signal1_type_get) (struct spu_context * ctx); |
| 79 | void (*signal2_type_set) (struct spu_context * ctx, u64 val); |
| 80 | u64(*signal2_type_get) (struct spu_context * ctx); |
| 81 | u32(*npc_read) (struct spu_context * ctx); |
| 82 | void (*npc_write) (struct spu_context * ctx, u32 data); |
| 83 | u32(*status_read) (struct spu_context * ctx); |
| 84 | char*(*get_ls) (struct spu_context * ctx); |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 85 | void (*runcntl_write) (struct spu_context * ctx, u32 data); |
| 86 | void (*runcntl_stop) (struct spu_context * ctx); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | extern struct spu_context_ops spu_hw_ops; |
| 90 | extern struct spu_context_ops spu_backing_ops; |
| 91 | |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 92 | struct spufs_inode_info { |
| 93 | struct spu_context *i_ctx; |
| 94 | struct inode vfs_inode; |
| 95 | }; |
| 96 | #define SPUFS_I(inode) \ |
| 97 | container_of(inode, struct spufs_inode_info, vfs_inode) |
| 98 | |
| 99 | extern struct tree_descr spufs_dir_contents[]; |
| 100 | |
| 101 | /* system call implementation */ |
| 102 | long spufs_run_spu(struct file *file, |
| 103 | struct spu_context *ctx, u32 *npc, u32 *status); |
| 104 | long spufs_create_thread(struct nameidata *nd, const char *name, |
| 105 | unsigned int flags, mode_t mode); |
Arnd Bergmann | e80358a | 2006-01-04 20:31:23 +0100 | [diff] [blame] | 106 | extern struct file_operations spufs_context_fops; |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 107 | |
| 108 | /* context management */ |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 109 | struct spu_context * alloc_spu_context(struct address_space *local_store); |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 110 | void destroy_spu_context(struct kref *kref); |
| 111 | struct spu_context * get_spu_context(struct spu_context *ctx); |
| 112 | int put_spu_context(struct spu_context *ctx); |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 113 | void spu_unmap_mappings(struct spu_context *ctx); |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 114 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 115 | void spu_forget(struct spu_context *ctx); |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 116 | void spu_acquire(struct spu_context *ctx); |
| 117 | void spu_release(struct spu_context *ctx); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 118 | int spu_acquire_runnable(struct spu_context *ctx); |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 119 | void spu_acquire_saved(struct spu_context *ctx); |
| 120 | |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 121 | int spu_activate(struct spu_context *ctx, u64 flags); |
| 122 | void spu_deactivate(struct spu_context *ctx); |
| 123 | void spu_yield(struct spu_context *ctx); |
| 124 | int __init spu_sched_init(void); |
| 125 | void __exit spu_sched_exit(void); |
| 126 | |
| 127 | size_t spu_wbox_write(struct spu_context *ctx, u32 data); |
| 128 | size_t spu_ibox_read(struct spu_context *ctx, u32 *data); |
| 129 | |
| 130 | /* irq callback funcs. */ |
| 131 | void spufs_ibox_callback(struct spu *spu); |
| 132 | void spufs_wbox_callback(struct spu *spu); |
Arnd Bergmann | 5110459 | 2005-12-05 22:52:25 -0500 | [diff] [blame] | 133 | void spufs_stop_callback(struct spu *spu); |
Arnd Bergmann | 8b3d666 | 2005-11-15 15:53:52 -0500 | [diff] [blame] | 134 | |
Arnd Bergmann | 67207b9 | 2005-11-15 15:53:48 -0500 | [diff] [blame] | 135 | #endif |