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