2 * SPU file system -- file contents
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2005
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
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)
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.
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.
26 #include <linux/ioctl.h>
27 #include <linux/module.h>
28 #include <linux/pagemap.h>
29 #include <linux/poll.h>
30 #include <linux/ptrace.h>
33 #include <asm/semaphore.h>
35 #include <asm/spu_info.h>
36 #include <asm/uaccess.h>
40 #define SPUFS_MMAP_4K (PAGE_SIZE == 0x1000)
43 spufs_mem_open(struct inode *inode, struct file *file)
45 struct spufs_inode_info *i = SPUFS_I(inode);
46 struct spu_context *ctx = i->i_ctx;
47 file->private_data = ctx;
48 ctx->local_store = inode->i_mapping;
54 __spufs_mem_read(struct spu_context *ctx, char __user *buffer,
55 size_t size, loff_t *pos)
57 char *local_store = ctx->ops->get_ls(ctx);
58 return simple_read_from_buffer(buffer, size, pos, local_store,
63 spufs_mem_read(struct file *file, char __user *buffer,
64 size_t size, loff_t *pos)
67 struct spu_context *ctx = file->private_data;
70 ret = __spufs_mem_read(ctx, buffer, size, pos);
76 spufs_mem_write(struct file *file, const char __user *buffer,
77 size_t size, loff_t *pos)
79 struct spu_context *ctx = file->private_data;
83 size = min_t(ssize_t, LS_SIZE - *pos, size);
90 local_store = ctx->ops->get_ls(ctx);
91 ret = copy_from_user(local_store + *pos - size,
92 buffer, size) ? -EFAULT : size;
98 static unsigned long spufs_mem_mmap_nopfn(struct vm_area_struct *vma,
99 unsigned long address)
101 struct spu_context *ctx = vma->vm_file->private_data;
102 unsigned long pfn, offset = address - vma->vm_start;
104 offset += vma->vm_pgoff << PAGE_SHIFT;
106 if (offset >= LS_SIZE)
111 if (ctx->state == SPU_STATE_SAVED) {
112 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
114 pfn = vmalloc_to_pfn(ctx->csa.lscsa->ls + offset);
116 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
118 pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT;
120 vm_insert_pfn(vma, address, pfn);
124 return NOPFN_REFAULT;
128 static struct vm_operations_struct spufs_mem_mmap_vmops = {
129 .nopfn = spufs_mem_mmap_nopfn,
133 spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
135 if (!(vma->vm_flags & VM_SHARED))
138 vma->vm_flags |= VM_IO | VM_PFNMAP;
139 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
142 vma->vm_ops = &spufs_mem_mmap_vmops;
146 static const struct file_operations spufs_mem_fops = {
147 .open = spufs_mem_open,
148 .read = spufs_mem_read,
149 .write = spufs_mem_write,
150 .llseek = generic_file_llseek,
151 .mmap = spufs_mem_mmap,
154 static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
155 unsigned long address,
156 unsigned long ps_offs,
157 unsigned long ps_size)
159 struct spu_context *ctx = vma->vm_file->private_data;
160 unsigned long area, offset = address - vma->vm_start;
163 offset += vma->vm_pgoff << PAGE_SHIFT;
164 if (offset >= ps_size)
167 /* error here usually means a signal.. we might want to test
168 * the error code more precisely though
170 ret = spu_acquire_runnable(ctx, 0);
172 return NOPFN_REFAULT;
174 area = ctx->spu->problem_phys + ps_offs;
175 vm_insert_pfn(vma, address, (area + offset) >> PAGE_SHIFT);
178 return NOPFN_REFAULT;
182 static unsigned long spufs_cntl_mmap_nopfn(struct vm_area_struct *vma,
183 unsigned long address)
185 return spufs_ps_nopfn(vma, address, 0x4000, 0x1000);
188 static struct vm_operations_struct spufs_cntl_mmap_vmops = {
189 .nopfn = spufs_cntl_mmap_nopfn,
193 * mmap support for problem state control area [0x4000 - 0x4fff].
195 static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
197 if (!(vma->vm_flags & VM_SHARED))
200 vma->vm_flags |= VM_IO | VM_PFNMAP;
201 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
202 | _PAGE_NO_CACHE | _PAGE_GUARDED);
204 vma->vm_ops = &spufs_cntl_mmap_vmops;
207 #else /* SPUFS_MMAP_4K */
208 #define spufs_cntl_mmap NULL
209 #endif /* !SPUFS_MMAP_4K */
211 static u64 spufs_cntl_get(void *data)
213 struct spu_context *ctx = data;
217 val = ctx->ops->status_read(ctx);
223 static void spufs_cntl_set(void *data, u64 val)
225 struct spu_context *ctx = data;
228 ctx->ops->runcntl_write(ctx, val);
232 static int spufs_cntl_open(struct inode *inode, struct file *file)
234 struct spufs_inode_info *i = SPUFS_I(inode);
235 struct spu_context *ctx = i->i_ctx;
237 file->private_data = ctx;
238 ctx->cntl = inode->i_mapping;
240 return simple_attr_open(inode, file, spufs_cntl_get,
241 spufs_cntl_set, "0x%08lx");
244 static const struct file_operations spufs_cntl_fops = {
245 .open = spufs_cntl_open,
246 .release = simple_attr_close,
247 .read = simple_attr_read,
248 .write = simple_attr_write,
249 .mmap = spufs_cntl_mmap,
253 spufs_regs_open(struct inode *inode, struct file *file)
255 struct spufs_inode_info *i = SPUFS_I(inode);
256 file->private_data = i->i_ctx;
261 __spufs_regs_read(struct spu_context *ctx, char __user *buffer,
262 size_t size, loff_t *pos)
264 struct spu_lscsa *lscsa = ctx->csa.lscsa;
265 return simple_read_from_buffer(buffer, size, pos,
266 lscsa->gprs, sizeof lscsa->gprs);
270 spufs_regs_read(struct file *file, char __user *buffer,
271 size_t size, loff_t *pos)
274 struct spu_context *ctx = file->private_data;
276 spu_acquire_saved(ctx);
277 ret = __spufs_regs_read(ctx, buffer, size, pos);
283 spufs_regs_write(struct file *file, const char __user *buffer,
284 size_t size, loff_t *pos)
286 struct spu_context *ctx = file->private_data;
287 struct spu_lscsa *lscsa = ctx->csa.lscsa;
290 size = min_t(ssize_t, sizeof lscsa->gprs - *pos, size);
295 spu_acquire_saved(ctx);
297 ret = copy_from_user(lscsa->gprs + *pos - size,
298 buffer, size) ? -EFAULT : size;
304 static const struct file_operations spufs_regs_fops = {
305 .open = spufs_regs_open,
306 .read = spufs_regs_read,
307 .write = spufs_regs_write,
308 .llseek = generic_file_llseek,
312 __spufs_fpcr_read(struct spu_context *ctx, char __user * buffer,
313 size_t size, loff_t * pos)
315 struct spu_lscsa *lscsa = ctx->csa.lscsa;
316 return simple_read_from_buffer(buffer, size, pos,
317 &lscsa->fpcr, sizeof(lscsa->fpcr));
321 spufs_fpcr_read(struct file *file, char __user * buffer,
322 size_t size, loff_t * pos)
325 struct spu_context *ctx = file->private_data;
327 spu_acquire_saved(ctx);
328 ret = __spufs_fpcr_read(ctx, buffer, size, pos);
334 spufs_fpcr_write(struct file *file, const char __user * buffer,
335 size_t size, loff_t * pos)
337 struct spu_context *ctx = file->private_data;
338 struct spu_lscsa *lscsa = ctx->csa.lscsa;
341 size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
346 spu_acquire_saved(ctx);
348 ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
349 buffer, size) ? -EFAULT : size;
355 static const struct file_operations spufs_fpcr_fops = {
356 .open = spufs_regs_open,
357 .read = spufs_fpcr_read,
358 .write = spufs_fpcr_write,
359 .llseek = generic_file_llseek,
362 /* generic open function for all pipe-like files */
363 static int spufs_pipe_open(struct inode *inode, struct file *file)
365 struct spufs_inode_info *i = SPUFS_I(inode);
366 file->private_data = i->i_ctx;
368 return nonseekable_open(inode, file);
372 * Read as many bytes from the mailbox as possible, until
373 * one of the conditions becomes true:
375 * - no more data available in the mailbox
376 * - end of the user provided buffer
377 * - end of the mapped area
379 static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
380 size_t len, loff_t *pos)
382 struct spu_context *ctx = file->private_data;
383 u32 mbox_data, __user *udata;
389 if (!access_ok(VERIFY_WRITE, buf, len))
392 udata = (void __user *)buf;
395 for (count = 0; (count + 4) <= len; count += 4, udata++) {
397 ret = ctx->ops->mbox_read(ctx, &mbox_data);
402 * at the end of the mapped area, we can fault
403 * but still need to return the data we have
404 * read successfully so far.
406 ret = __put_user(mbox_data, udata);
421 static const struct file_operations spufs_mbox_fops = {
422 .open = spufs_pipe_open,
423 .read = spufs_mbox_read,
426 static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
427 size_t len, loff_t *pos)
429 struct spu_context *ctx = file->private_data;
437 mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff;
441 if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
447 static const struct file_operations spufs_mbox_stat_fops = {
448 .open = spufs_pipe_open,
449 .read = spufs_mbox_stat_read,
452 /* low-level ibox access function */
453 size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
455 return ctx->ops->ibox_read(ctx, data);
458 static int spufs_ibox_fasync(int fd, struct file *file, int on)
460 struct spu_context *ctx = file->private_data;
462 return fasync_helper(fd, file, on, &ctx->ibox_fasync);
465 /* interrupt-level ibox callback function. */
466 void spufs_ibox_callback(struct spu *spu)
468 struct spu_context *ctx = spu->ctx;
470 wake_up_all(&ctx->ibox_wq);
471 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
475 * Read as many bytes from the interrupt mailbox as possible, until
476 * one of the conditions becomes true:
478 * - no more data available in the mailbox
479 * - end of the user provided buffer
480 * - end of the mapped area
482 * If the file is opened without O_NONBLOCK, we wait here until
483 * any data is available, but return when we have been able to
486 static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
487 size_t len, loff_t *pos)
489 struct spu_context *ctx = file->private_data;
490 u32 ibox_data, __user *udata;
496 if (!access_ok(VERIFY_WRITE, buf, len))
499 udata = (void __user *)buf;
503 /* wait only for the first element */
505 if (file->f_flags & O_NONBLOCK) {
506 if (!spu_ibox_read(ctx, &ibox_data))
509 count = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data));
514 /* if we can't write at all, return -EFAULT */
515 count = __put_user(ibox_data, udata);
519 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
521 ret = ctx->ops->ibox_read(ctx, &ibox_data);
525 * at the end of the mapped area, we can fault
526 * but still need to return the data we have
527 * read successfully so far.
529 ret = __put_user(ibox_data, udata);
540 static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
542 struct spu_context *ctx = file->private_data;
545 poll_wait(file, &ctx->ibox_wq, wait);
548 mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
554 static const struct file_operations spufs_ibox_fops = {
555 .open = spufs_pipe_open,
556 .read = spufs_ibox_read,
557 .poll = spufs_ibox_poll,
558 .fasync = spufs_ibox_fasync,
561 static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
562 size_t len, loff_t *pos)
564 struct spu_context *ctx = file->private_data;
571 ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
574 if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
580 static const struct file_operations spufs_ibox_stat_fops = {
581 .open = spufs_pipe_open,
582 .read = spufs_ibox_stat_read,
585 /* low-level mailbox write */
586 size_t spu_wbox_write(struct spu_context *ctx, u32 data)
588 return ctx->ops->wbox_write(ctx, data);
591 static int spufs_wbox_fasync(int fd, struct file *file, int on)
593 struct spu_context *ctx = file->private_data;
596 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
601 /* interrupt-level wbox callback function. */
602 void spufs_wbox_callback(struct spu *spu)
604 struct spu_context *ctx = spu->ctx;
606 wake_up_all(&ctx->wbox_wq);
607 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
611 * Write as many bytes to the interrupt mailbox as possible, until
612 * one of the conditions becomes true:
614 * - the mailbox is full
615 * - end of the user provided buffer
616 * - end of the mapped area
618 * If the file is opened without O_NONBLOCK, we wait here until
619 * space is availabyl, but return when we have been able to
622 static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
623 size_t len, loff_t *pos)
625 struct spu_context *ctx = file->private_data;
626 u32 wbox_data, __user *udata;
632 udata = (void __user *)buf;
633 if (!access_ok(VERIFY_READ, buf, len))
636 if (__get_user(wbox_data, udata))
642 * make sure we can at least write one element, by waiting
643 * in case of !O_NONBLOCK
646 if (file->f_flags & O_NONBLOCK) {
647 if (!spu_wbox_write(ctx, wbox_data))
650 count = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data));
656 /* write aѕ much as possible */
657 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
659 ret = __get_user(wbox_data, udata);
663 ret = spu_wbox_write(ctx, wbox_data);
673 static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
675 struct spu_context *ctx = file->private_data;
678 poll_wait(file, &ctx->wbox_wq, wait);
681 mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
687 static const struct file_operations spufs_wbox_fops = {
688 .open = spufs_pipe_open,
689 .write = spufs_wbox_write,
690 .poll = spufs_wbox_poll,
691 .fasync = spufs_wbox_fasync,
694 static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
695 size_t len, loff_t *pos)
697 struct spu_context *ctx = file->private_data;
704 wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
707 if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
713 static const struct file_operations spufs_wbox_stat_fops = {
714 .open = spufs_pipe_open,
715 .read = spufs_wbox_stat_read,
718 static int spufs_signal1_open(struct inode *inode, struct file *file)
720 struct spufs_inode_info *i = SPUFS_I(inode);
721 struct spu_context *ctx = i->i_ctx;
722 file->private_data = ctx;
723 ctx->signal1 = inode->i_mapping;
725 return nonseekable_open(inode, file);
728 static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf,
729 size_t len, loff_t *pos)
737 if (ctx->csa.spu_chnlcnt_RW[3]) {
738 data = ctx->csa.spu_chnldata_RW[3];
745 if (copy_to_user(buf, &data, 4))
752 static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
753 size_t len, loff_t *pos)
756 struct spu_context *ctx = file->private_data;
758 spu_acquire_saved(ctx);
759 ret = __spufs_signal1_read(ctx, buf, len, pos);
765 static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
766 size_t len, loff_t *pos)
768 struct spu_context *ctx;
771 ctx = file->private_data;
776 if (copy_from_user(&data, buf, 4))
780 ctx->ops->signal1_write(ctx, data);
786 static unsigned long spufs_signal1_mmap_nopfn(struct vm_area_struct *vma,
787 unsigned long address)
789 #if PAGE_SIZE == 0x1000
790 return spufs_ps_nopfn(vma, address, 0x14000, 0x1000);
791 #elif PAGE_SIZE == 0x10000
792 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
793 * signal 1 and 2 area
795 return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
797 #error unsupported page size
801 static struct vm_operations_struct spufs_signal1_mmap_vmops = {
802 .nopfn = spufs_signal1_mmap_nopfn,
805 static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
807 if (!(vma->vm_flags & VM_SHARED))
810 vma->vm_flags |= VM_IO | VM_PFNMAP;
811 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
812 | _PAGE_NO_CACHE | _PAGE_GUARDED);
814 vma->vm_ops = &spufs_signal1_mmap_vmops;
818 static const struct file_operations spufs_signal1_fops = {
819 .open = spufs_signal1_open,
820 .read = spufs_signal1_read,
821 .write = spufs_signal1_write,
822 .mmap = spufs_signal1_mmap,
825 static int spufs_signal2_open(struct inode *inode, struct file *file)
827 struct spufs_inode_info *i = SPUFS_I(inode);
828 struct spu_context *ctx = i->i_ctx;
829 file->private_data = ctx;
830 ctx->signal2 = inode->i_mapping;
832 return nonseekable_open(inode, file);
835 static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
836 size_t len, loff_t *pos)
844 if (ctx->csa.spu_chnlcnt_RW[4]) {
845 data = ctx->csa.spu_chnldata_RW[4];
852 if (copy_to_user(buf, &data, 4))
859 static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
860 size_t len, loff_t *pos)
862 struct spu_context *ctx = file->private_data;
865 spu_acquire_saved(ctx);
866 ret = __spufs_signal2_read(ctx, buf, len, pos);
872 static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
873 size_t len, loff_t *pos)
875 struct spu_context *ctx;
878 ctx = file->private_data;
883 if (copy_from_user(&data, buf, 4))
887 ctx->ops->signal2_write(ctx, data);
894 static unsigned long spufs_signal2_mmap_nopfn(struct vm_area_struct *vma,
895 unsigned long address)
897 #if PAGE_SIZE == 0x1000
898 return spufs_ps_nopfn(vma, address, 0x1c000, 0x1000);
899 #elif PAGE_SIZE == 0x10000
900 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
901 * signal 1 and 2 area
903 return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
905 #error unsupported page size
909 static struct vm_operations_struct spufs_signal2_mmap_vmops = {
910 .nopfn = spufs_signal2_mmap_nopfn,
913 static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
915 if (!(vma->vm_flags & VM_SHARED))
918 vma->vm_flags |= VM_IO | VM_PFNMAP;
919 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
920 | _PAGE_NO_CACHE | _PAGE_GUARDED);
922 vma->vm_ops = &spufs_signal2_mmap_vmops;
925 #else /* SPUFS_MMAP_4K */
926 #define spufs_signal2_mmap NULL
927 #endif /* !SPUFS_MMAP_4K */
929 static const struct file_operations spufs_signal2_fops = {
930 .open = spufs_signal2_open,
931 .read = spufs_signal2_read,
932 .write = spufs_signal2_write,
933 .mmap = spufs_signal2_mmap,
936 static void spufs_signal1_type_set(void *data, u64 val)
938 struct spu_context *ctx = data;
941 ctx->ops->signal1_type_set(ctx, val);
945 static u64 __spufs_signal1_type_get(void *data)
947 struct spu_context *ctx = data;
948 return ctx->ops->signal1_type_get(ctx);
951 static u64 spufs_signal1_type_get(void *data)
953 struct spu_context *ctx = data;
957 ret = __spufs_signal1_type_get(data);
962 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
963 spufs_signal1_type_set, "%llu");
965 static void spufs_signal2_type_set(void *data, u64 val)
967 struct spu_context *ctx = data;
970 ctx->ops->signal2_type_set(ctx, val);
974 static u64 __spufs_signal2_type_get(void *data)
976 struct spu_context *ctx = data;
977 return ctx->ops->signal2_type_get(ctx);
980 static u64 spufs_signal2_type_get(void *data)
982 struct spu_context *ctx = data;
986 ret = __spufs_signal2_type_get(data);
991 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
992 spufs_signal2_type_set, "%llu");
995 static unsigned long spufs_mss_mmap_nopfn(struct vm_area_struct *vma,
996 unsigned long address)
998 return spufs_ps_nopfn(vma, address, 0x0000, 0x1000);
1001 static struct vm_operations_struct spufs_mss_mmap_vmops = {
1002 .nopfn = spufs_mss_mmap_nopfn,
1006 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1008 static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
1010 if (!(vma->vm_flags & VM_SHARED))
1013 vma->vm_flags |= VM_IO | VM_PFNMAP;
1014 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1015 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1017 vma->vm_ops = &spufs_mss_mmap_vmops;
1020 #else /* SPUFS_MMAP_4K */
1021 #define spufs_mss_mmap NULL
1022 #endif /* !SPUFS_MMAP_4K */
1024 static int spufs_mss_open(struct inode *inode, struct file *file)
1026 struct spufs_inode_info *i = SPUFS_I(inode);
1027 struct spu_context *ctx = i->i_ctx;
1029 file->private_data = i->i_ctx;
1030 ctx->mss = inode->i_mapping;
1032 return nonseekable_open(inode, file);
1035 static const struct file_operations spufs_mss_fops = {
1036 .open = spufs_mss_open,
1037 .mmap = spufs_mss_mmap,
1040 static unsigned long spufs_psmap_mmap_nopfn(struct vm_area_struct *vma,
1041 unsigned long address)
1043 return spufs_ps_nopfn(vma, address, 0x0000, 0x20000);
1046 static struct vm_operations_struct spufs_psmap_mmap_vmops = {
1047 .nopfn = spufs_psmap_mmap_nopfn,
1051 * mmap support for full problem state area [0x00000 - 0x1ffff].
1053 static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
1055 if (!(vma->vm_flags & VM_SHARED))
1058 vma->vm_flags |= VM_IO | VM_PFNMAP;
1059 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1060 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1062 vma->vm_ops = &spufs_psmap_mmap_vmops;
1066 static int spufs_psmap_open(struct inode *inode, struct file *file)
1068 struct spufs_inode_info *i = SPUFS_I(inode);
1069 struct spu_context *ctx = i->i_ctx;
1071 file->private_data = i->i_ctx;
1072 ctx->psmap = inode->i_mapping;
1074 return nonseekable_open(inode, file);
1077 static const struct file_operations spufs_psmap_fops = {
1078 .open = spufs_psmap_open,
1079 .mmap = spufs_psmap_mmap,
1084 static unsigned long spufs_mfc_mmap_nopfn(struct vm_area_struct *vma,
1085 unsigned long address)
1087 return spufs_ps_nopfn(vma, address, 0x3000, 0x1000);
1090 static struct vm_operations_struct spufs_mfc_mmap_vmops = {
1091 .nopfn = spufs_mfc_mmap_nopfn,
1095 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1097 static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
1099 if (!(vma->vm_flags & VM_SHARED))
1102 vma->vm_flags |= VM_IO | VM_PFNMAP;
1103 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1104 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1106 vma->vm_ops = &spufs_mfc_mmap_vmops;
1109 #else /* SPUFS_MMAP_4K */
1110 #define spufs_mfc_mmap NULL
1111 #endif /* !SPUFS_MMAP_4K */
1113 static int spufs_mfc_open(struct inode *inode, struct file *file)
1115 struct spufs_inode_info *i = SPUFS_I(inode);
1116 struct spu_context *ctx = i->i_ctx;
1118 /* we don't want to deal with DMA into other processes */
1119 if (ctx->owner != current->mm)
1122 if (atomic_read(&inode->i_count) != 1)
1125 file->private_data = ctx;
1126 ctx->mfc = inode->i_mapping;
1128 return nonseekable_open(inode, file);
1131 /* interrupt-level mfc callback function. */
1132 void spufs_mfc_callback(struct spu *spu)
1134 struct spu_context *ctx = spu->ctx;
1136 wake_up_all(&ctx->mfc_wq);
1138 pr_debug("%s %s\n", __FUNCTION__, spu->name);
1139 if (ctx->mfc_fasync) {
1140 u32 free_elements, tagstatus;
1143 /* no need for spu_acquire in interrupt context */
1144 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1145 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1148 if (free_elements & 0xffff)
1150 if (tagstatus & ctx->tagwait)
1153 kill_fasync(&ctx->mfc_fasync, SIGIO, mask);
1157 static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
1159 /* See if there is one tag group is complete */
1160 /* FIXME we need locking around tagwait */
1161 *status = ctx->ops->read_mfc_tagstatus(ctx) & ctx->tagwait;
1162 ctx->tagwait &= ~*status;
1166 /* enable interrupt waiting for any tag group,
1167 may silently fail if interrupts are already enabled */
1168 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1172 static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
1173 size_t size, loff_t *pos)
1175 struct spu_context *ctx = file->private_data;
1183 if (file->f_flags & O_NONBLOCK) {
1184 status = ctx->ops->read_mfc_tagstatus(ctx);
1185 if (!(status & ctx->tagwait))
1188 ctx->tagwait &= ~status;
1190 ret = spufs_wait(ctx->mfc_wq,
1191 spufs_read_mfc_tagstatus(ctx, &status));
1199 if (copy_to_user(buffer, &status, 4))
1206 static int spufs_check_valid_dma(struct mfc_dma_command *cmd)
1208 pr_debug("queueing DMA %x %lx %x %x %x\n", cmd->lsa,
1209 cmd->ea, cmd->size, cmd->tag, cmd->cmd);
1220 pr_debug("invalid DMA opcode %x\n", cmd->cmd);
1224 if ((cmd->lsa & 0xf) != (cmd->ea &0xf)) {
1225 pr_debug("invalid DMA alignment, ea %lx lsa %x\n",
1230 switch (cmd->size & 0xf) {
1251 pr_debug("invalid DMA alignment %x for size %x\n",
1252 cmd->lsa & 0xf, cmd->size);
1256 if (cmd->size > 16 * 1024) {
1257 pr_debug("invalid DMA size %x\n", cmd->size);
1261 if (cmd->tag & 0xfff0) {
1262 /* we reserve the higher tag numbers for kernel use */
1263 pr_debug("invalid DMA tag\n");
1268 /* not supported in this version */
1269 pr_debug("invalid DMA class\n");
1276 static int spu_send_mfc_command(struct spu_context *ctx,
1277 struct mfc_dma_command cmd,
1280 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1281 if (*error == -EAGAIN) {
1282 /* wait for any tag group to complete
1283 so we have space for the new command */
1284 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1285 /* try again, because the queue might be
1287 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1288 if (*error == -EAGAIN)
1294 static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
1295 size_t size, loff_t *pos)
1297 struct spu_context *ctx = file->private_data;
1298 struct mfc_dma_command cmd;
1301 if (size != sizeof cmd)
1305 if (copy_from_user(&cmd, buffer, sizeof cmd))
1308 ret = spufs_check_valid_dma(&cmd);
1312 spu_acquire_runnable(ctx, 0);
1313 if (file->f_flags & O_NONBLOCK) {
1314 ret = ctx->ops->send_mfc_command(ctx, &cmd);
1317 ret = spufs_wait(ctx->mfc_wq,
1318 spu_send_mfc_command(ctx, cmd, &status));
1327 ctx->tagwait |= 1 << cmd.tag;
1334 static unsigned int spufs_mfc_poll(struct file *file,poll_table *wait)
1336 struct spu_context *ctx = file->private_data;
1337 u32 free_elements, tagstatus;
1341 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2);
1342 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1343 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1346 poll_wait(file, &ctx->mfc_wq, wait);
1349 if (free_elements & 0xffff)
1350 mask |= POLLOUT | POLLWRNORM;
1351 if (tagstatus & ctx->tagwait)
1352 mask |= POLLIN | POLLRDNORM;
1354 pr_debug("%s: free %d tagstatus %d tagwait %d\n", __FUNCTION__,
1355 free_elements, tagstatus, ctx->tagwait);
1360 static int spufs_mfc_flush(struct file *file, fl_owner_t id)
1362 struct spu_context *ctx = file->private_data;
1367 /* this currently hangs */
1368 ret = spufs_wait(ctx->mfc_wq,
1369 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2));
1372 ret = spufs_wait(ctx->mfc_wq,
1373 ctx->ops->read_mfc_tagstatus(ctx) == ctx->tagwait);
1383 static int spufs_mfc_fsync(struct file *file, struct dentry *dentry,
1386 return spufs_mfc_flush(file, NULL);
1389 static int spufs_mfc_fasync(int fd, struct file *file, int on)
1391 struct spu_context *ctx = file->private_data;
1393 return fasync_helper(fd, file, on, &ctx->mfc_fasync);
1396 static const struct file_operations spufs_mfc_fops = {
1397 .open = spufs_mfc_open,
1398 .read = spufs_mfc_read,
1399 .write = spufs_mfc_write,
1400 .poll = spufs_mfc_poll,
1401 .flush = spufs_mfc_flush,
1402 .fsync = spufs_mfc_fsync,
1403 .fasync = spufs_mfc_fasync,
1404 .mmap = spufs_mfc_mmap,
1407 static void spufs_npc_set(void *data, u64 val)
1409 struct spu_context *ctx = data;
1411 ctx->ops->npc_write(ctx, val);
1415 static u64 spufs_npc_get(void *data)
1417 struct spu_context *ctx = data;
1420 ret = ctx->ops->npc_read(ctx);
1424 DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set,
1427 static void spufs_decr_set(void *data, u64 val)
1429 struct spu_context *ctx = data;
1430 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1431 spu_acquire_saved(ctx);
1432 lscsa->decr.slot[0] = (u32) val;
1436 static u64 __spufs_decr_get(void *data)
1438 struct spu_context *ctx = data;
1439 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1440 return lscsa->decr.slot[0];
1443 static u64 spufs_decr_get(void *data)
1445 struct spu_context *ctx = data;
1447 spu_acquire_saved(ctx);
1448 ret = __spufs_decr_get(data);
1452 DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
1455 static void spufs_decr_status_set(void *data, u64 val)
1457 struct spu_context *ctx = data;
1458 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1459 spu_acquire_saved(ctx);
1460 lscsa->decr_status.slot[0] = (u32) val;
1464 static u64 __spufs_decr_status_get(void *data)
1466 struct spu_context *ctx = data;
1467 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1468 return lscsa->decr_status.slot[0];
1471 static u64 spufs_decr_status_get(void *data)
1473 struct spu_context *ctx = data;
1475 spu_acquire_saved(ctx);
1476 ret = __spufs_decr_status_get(data);
1480 DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
1481 spufs_decr_status_set, "0x%llx\n")
1483 static void spufs_event_mask_set(void *data, u64 val)
1485 struct spu_context *ctx = data;
1486 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1487 spu_acquire_saved(ctx);
1488 lscsa->event_mask.slot[0] = (u32) val;
1492 static u64 __spufs_event_mask_get(void *data)
1494 struct spu_context *ctx = data;
1495 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1496 return lscsa->event_mask.slot[0];
1499 static u64 spufs_event_mask_get(void *data)
1501 struct spu_context *ctx = data;
1503 spu_acquire_saved(ctx);
1504 ret = __spufs_event_mask_get(data);
1508 DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
1509 spufs_event_mask_set, "0x%llx\n")
1511 static u64 __spufs_event_status_get(void *data)
1513 struct spu_context *ctx = data;
1514 struct spu_state *state = &ctx->csa;
1516 stat = state->spu_chnlcnt_RW[0];
1518 return state->spu_chnldata_RW[0];
1522 static u64 spufs_event_status_get(void *data)
1524 struct spu_context *ctx = data;
1527 spu_acquire_saved(ctx);
1528 ret = __spufs_event_status_get(data);
1532 DEFINE_SIMPLE_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
1535 static void spufs_srr0_set(void *data, u64 val)
1537 struct spu_context *ctx = data;
1538 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1539 spu_acquire_saved(ctx);
1540 lscsa->srr0.slot[0] = (u32) val;
1544 static u64 spufs_srr0_get(void *data)
1546 struct spu_context *ctx = data;
1547 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1549 spu_acquire_saved(ctx);
1550 ret = lscsa->srr0.slot[0];
1554 DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
1557 static u64 spufs_id_get(void *data)
1559 struct spu_context *ctx = data;
1563 if (ctx->state == SPU_STATE_RUNNABLE)
1564 num = ctx->spu->number;
1566 num = (unsigned int)-1;
1571 DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n")
1573 static u64 __spufs_object_id_get(void *data)
1575 struct spu_context *ctx = data;
1576 return ctx->object_id;
1579 static u64 spufs_object_id_get(void *data)
1581 /* FIXME: Should there really be no locking here? */
1582 return __spufs_object_id_get(data);
1585 static void spufs_object_id_set(void *data, u64 id)
1587 struct spu_context *ctx = data;
1588 ctx->object_id = id;
1591 DEFINE_SIMPLE_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get,
1592 spufs_object_id_set, "0x%llx\n");
1594 static u64 __spufs_lslr_get(void *data)
1596 struct spu_context *ctx = data;
1597 return ctx->csa.priv2.spu_lslr_RW;
1600 static u64 spufs_lslr_get(void *data)
1602 struct spu_context *ctx = data;
1605 spu_acquire_saved(ctx);
1606 ret = __spufs_lslr_get(data);
1611 DEFINE_SIMPLE_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n")
1613 static int spufs_info_open(struct inode *inode, struct file *file)
1615 struct spufs_inode_info *i = SPUFS_I(inode);
1616 struct spu_context *ctx = i->i_ctx;
1617 file->private_data = ctx;
1621 static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
1622 char __user *buf, size_t len, loff_t *pos)
1627 mbox_stat = ctx->csa.prob.mb_stat_R;
1628 if (mbox_stat & 0x0000ff) {
1629 data = ctx->csa.prob.pu_mb_R;
1632 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1635 static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
1636 size_t len, loff_t *pos)
1639 struct spu_context *ctx = file->private_data;
1641 if (!access_ok(VERIFY_WRITE, buf, len))
1644 spu_acquire_saved(ctx);
1645 spin_lock(&ctx->csa.register_lock);
1646 ret = __spufs_mbox_info_read(ctx, buf, len, pos);
1647 spin_unlock(&ctx->csa.register_lock);
1653 static const struct file_operations spufs_mbox_info_fops = {
1654 .open = spufs_info_open,
1655 .read = spufs_mbox_info_read,
1656 .llseek = generic_file_llseek,
1659 static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,
1660 char __user *buf, size_t len, loff_t *pos)
1665 ibox_stat = ctx->csa.prob.mb_stat_R;
1666 if (ibox_stat & 0xff0000) {
1667 data = ctx->csa.priv2.puint_mb_R;
1670 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1673 static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
1674 size_t len, loff_t *pos)
1676 struct spu_context *ctx = file->private_data;
1679 if (!access_ok(VERIFY_WRITE, buf, len))
1682 spu_acquire_saved(ctx);
1683 spin_lock(&ctx->csa.register_lock);
1684 ret = __spufs_ibox_info_read(ctx, buf, len, pos);
1685 spin_unlock(&ctx->csa.register_lock);
1691 static const struct file_operations spufs_ibox_info_fops = {
1692 .open = spufs_info_open,
1693 .read = spufs_ibox_info_read,
1694 .llseek = generic_file_llseek,
1697 static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,
1698 char __user *buf, size_t len, loff_t *pos)
1704 wbox_stat = ctx->csa.prob.mb_stat_R;
1705 cnt = 4 - ((wbox_stat & 0x00ff00) >> 8);
1706 for (i = 0; i < cnt; i++) {
1707 data[i] = ctx->csa.spu_mailbox_data[i];
1710 return simple_read_from_buffer(buf, len, pos, &data,
1714 static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
1715 size_t len, loff_t *pos)
1717 struct spu_context *ctx = file->private_data;
1720 if (!access_ok(VERIFY_WRITE, buf, len))
1723 spu_acquire_saved(ctx);
1724 spin_lock(&ctx->csa.register_lock);
1725 ret = __spufs_wbox_info_read(ctx, buf, len, pos);
1726 spin_unlock(&ctx->csa.register_lock);
1732 static const struct file_operations spufs_wbox_info_fops = {
1733 .open = spufs_info_open,
1734 .read = spufs_wbox_info_read,
1735 .llseek = generic_file_llseek,
1738 static ssize_t __spufs_dma_info_read(struct spu_context *ctx,
1739 char __user *buf, size_t len, loff_t *pos)
1741 struct spu_dma_info info;
1742 struct mfc_cq_sr *qp, *spuqp;
1745 info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;
1746 info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];
1747 info.dma_info_status = ctx->csa.spu_chnldata_RW[24];
1748 info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];
1749 info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];
1750 for (i = 0; i < 16; i++) {
1751 qp = &info.dma_info_command_data[i];
1752 spuqp = &ctx->csa.priv2.spuq[i];
1754 qp->mfc_cq_data0_RW = spuqp->mfc_cq_data0_RW;
1755 qp->mfc_cq_data1_RW = spuqp->mfc_cq_data1_RW;
1756 qp->mfc_cq_data2_RW = spuqp->mfc_cq_data2_RW;
1757 qp->mfc_cq_data3_RW = spuqp->mfc_cq_data3_RW;
1760 return simple_read_from_buffer(buf, len, pos, &info,
1764 static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
1765 size_t len, loff_t *pos)
1767 struct spu_context *ctx = file->private_data;
1770 if (!access_ok(VERIFY_WRITE, buf, len))
1773 spu_acquire_saved(ctx);
1774 spin_lock(&ctx->csa.register_lock);
1775 ret = __spufs_dma_info_read(ctx, buf, len, pos);
1776 spin_unlock(&ctx->csa.register_lock);
1782 static const struct file_operations spufs_dma_info_fops = {
1783 .open = spufs_info_open,
1784 .read = spufs_dma_info_read,
1787 static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,
1788 char __user *buf, size_t len, loff_t *pos)
1790 struct spu_proxydma_info info;
1791 struct mfc_cq_sr *qp, *puqp;
1792 int ret = sizeof info;
1798 if (!access_ok(VERIFY_WRITE, buf, len))
1801 info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW;
1802 info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;
1803 info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;
1804 for (i = 0; i < 8; i++) {
1805 qp = &info.proxydma_info_command_data[i];
1806 puqp = &ctx->csa.priv2.puq[i];
1808 qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;
1809 qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;
1810 qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;
1811 qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;
1814 return simple_read_from_buffer(buf, len, pos, &info,
1818 static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
1819 size_t len, loff_t *pos)
1821 struct spu_context *ctx = file->private_data;
1824 spu_acquire_saved(ctx);
1825 spin_lock(&ctx->csa.register_lock);
1826 ret = __spufs_proxydma_info_read(ctx, buf, len, pos);
1827 spin_unlock(&ctx->csa.register_lock);
1833 static const struct file_operations spufs_proxydma_info_fops = {
1834 .open = spufs_info_open,
1835 .read = spufs_proxydma_info_read,
1838 struct tree_descr spufs_dir_contents[] = {
1839 { "mem", &spufs_mem_fops, 0666, },
1840 { "regs", &spufs_regs_fops, 0666, },
1841 { "mbox", &spufs_mbox_fops, 0444, },
1842 { "ibox", &spufs_ibox_fops, 0444, },
1843 { "wbox", &spufs_wbox_fops, 0222, },
1844 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
1845 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
1846 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
1847 { "signal1", &spufs_signal1_fops, 0666, },
1848 { "signal2", &spufs_signal2_fops, 0666, },
1849 { "signal1_type", &spufs_signal1_type, 0666, },
1850 { "signal2_type", &spufs_signal2_type, 0666, },
1851 { "cntl", &spufs_cntl_fops, 0666, },
1852 { "fpcr", &spufs_fpcr_fops, 0666, },
1853 { "lslr", &spufs_lslr_ops, 0444, },
1854 { "mfc", &spufs_mfc_fops, 0666, },
1855 { "mss", &spufs_mss_fops, 0666, },
1856 { "npc", &spufs_npc_ops, 0666, },
1857 { "srr0", &spufs_srr0_ops, 0666, },
1858 { "decr", &spufs_decr_ops, 0666, },
1859 { "decr_status", &spufs_decr_status_ops, 0666, },
1860 { "event_mask", &spufs_event_mask_ops, 0666, },
1861 { "event_status", &spufs_event_status_ops, 0444, },
1862 { "psmap", &spufs_psmap_fops, 0666, },
1863 { "phys-id", &spufs_id_ops, 0666, },
1864 { "object-id", &spufs_object_id_ops, 0666, },
1865 { "mbox_info", &spufs_mbox_info_fops, 0444, },
1866 { "ibox_info", &spufs_ibox_info_fops, 0444, },
1867 { "wbox_info", &spufs_wbox_info_fops, 0444, },
1868 { "dma_info", &spufs_dma_info_fops, 0444, },
1869 { "proxydma_info", &spufs_proxydma_info_fops, 0444, },
1873 struct tree_descr spufs_dir_nosched_contents[] = {
1874 { "mem", &spufs_mem_fops, 0666, },
1875 { "mbox", &spufs_mbox_fops, 0444, },
1876 { "ibox", &spufs_ibox_fops, 0444, },
1877 { "wbox", &spufs_wbox_fops, 0222, },
1878 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
1879 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
1880 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
1881 { "signal1", &spufs_signal1_fops, 0666, },
1882 { "signal2", &spufs_signal2_fops, 0666, },
1883 { "signal1_type", &spufs_signal1_type, 0666, },
1884 { "signal2_type", &spufs_signal2_type, 0666, },
1885 { "mss", &spufs_mss_fops, 0666, },
1886 { "mfc", &spufs_mfc_fops, 0666, },
1887 { "cntl", &spufs_cntl_fops, 0666, },
1888 { "npc", &spufs_npc_ops, 0666, },
1889 { "psmap", &spufs_psmap_fops, 0666, },
1890 { "phys-id", &spufs_id_ops, 0666, },
1891 { "object-id", &spufs_object_id_ops, 0666, },
1895 struct spufs_coredump_reader spufs_coredump_read[] = {
1896 { "regs", __spufs_regs_read, NULL, 128 * 16 },
1897 { "fpcr", __spufs_fpcr_read, NULL, 16 },
1898 { "lslr", NULL, __spufs_lslr_get, 11 },
1899 { "decr", NULL, __spufs_decr_get, 11 },
1900 { "decr_status", NULL, __spufs_decr_status_get, 11 },
1901 { "mem", __spufs_mem_read, NULL, 256 * 1024, },
1902 { "signal1", __spufs_signal1_read, NULL, 4 },
1903 { "signal1_type", NULL, __spufs_signal1_type_get, 2 },
1904 { "signal2", __spufs_signal2_read, NULL, 4 },
1905 { "signal2_type", NULL, __spufs_signal2_type_get, 2 },
1906 { "event_mask", NULL, __spufs_event_mask_get, 8 },
1907 { "event_status", NULL, __spufs_event_status_get, 8 },
1908 { "mbox_info", __spufs_mbox_info_read, NULL, 4 },
1909 { "ibox_info", __spufs_ibox_info_read, NULL, 4 },
1910 { "wbox_info", __spufs_wbox_info_read, NULL, 16 },
1911 { "dma_info", __spufs_dma_info_read, NULL, 69 * 8 },
1912 { "proxydma_info", __spufs_proxydma_info_read, NULL, 35 * 8 },
1913 { "object-id", NULL, __spufs_object_id_get, 19 },
1916 int spufs_coredump_num_notes = ARRAY_SIZE(spufs_coredump_read) - 1;