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 file->f_mapping = inode->i_mapping;
49 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;
99 spufs_mem_mmap_nopage(struct vm_area_struct *vma,
100 unsigned long address, int *type)
102 struct page *page = NOPAGE_SIGBUS;
104 struct spu_context *ctx = vma->vm_file->private_data;
105 unsigned long offset = address - vma->vm_start;
106 offset += vma->vm_pgoff << PAGE_SHIFT;
110 if (ctx->state == SPU_STATE_SAVED) {
111 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
113 page = vmalloc_to_page(ctx->csa.lscsa->ls + offset);
115 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
117 page = pfn_to_page((ctx->spu->local_store_phys + offset)
123 *type = VM_FAULT_MINOR;
125 page_cache_get(page);
129 static struct vm_operations_struct spufs_mem_mmap_vmops = {
130 .nopage = spufs_mem_mmap_nopage,
134 spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
136 if (!(vma->vm_flags & VM_SHARED))
139 vma->vm_flags |= VM_IO;
140 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
143 vma->vm_ops = &spufs_mem_mmap_vmops;
147 static struct file_operations spufs_mem_fops = {
148 .open = spufs_mem_open,
149 .read = spufs_mem_read,
150 .write = spufs_mem_write,
151 .llseek = generic_file_llseek,
152 .mmap = spufs_mem_mmap,
155 static struct page *spufs_ps_nopage(struct vm_area_struct *vma,
156 unsigned long address,
157 int *type, unsigned long ps_offs,
158 unsigned long ps_size)
160 struct page *page = NOPAGE_SIGBUS;
161 int fault_type = VM_FAULT_SIGBUS;
162 struct spu_context *ctx = vma->vm_file->private_data;
163 unsigned long offset = address - vma->vm_start;
167 offset += vma->vm_pgoff << PAGE_SHIFT;
168 if (offset >= ps_size)
171 ret = spu_acquire_runnable(ctx);
175 area = ctx->spu->problem_phys + ps_offs;
176 page = pfn_to_page((area + offset) >> PAGE_SHIFT);
177 fault_type = VM_FAULT_MINOR;
178 page_cache_get(page);
190 static struct page *spufs_cntl_mmap_nopage(struct vm_area_struct *vma,
191 unsigned long address, int *type)
193 return spufs_ps_nopage(vma, address, type, 0x4000, 0x1000);
196 static struct vm_operations_struct spufs_cntl_mmap_vmops = {
197 .nopage = spufs_cntl_mmap_nopage,
201 * mmap support for problem state control area [0x4000 - 0x4fff].
203 static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
205 if (!(vma->vm_flags & VM_SHARED))
208 vma->vm_flags |= VM_IO;
209 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
210 | _PAGE_NO_CACHE | _PAGE_GUARDED);
212 vma->vm_ops = &spufs_cntl_mmap_vmops;
215 #else /* SPUFS_MMAP_4K */
216 #define spufs_cntl_mmap NULL
217 #endif /* !SPUFS_MMAP_4K */
219 static u64 spufs_cntl_get(void *data)
221 struct spu_context *ctx = data;
225 val = ctx->ops->status_read(ctx);
231 static void spufs_cntl_set(void *data, u64 val)
233 struct spu_context *ctx = data;
236 ctx->ops->runcntl_write(ctx, val);
240 static int spufs_cntl_open(struct inode *inode, struct file *file)
242 struct spufs_inode_info *i = SPUFS_I(inode);
243 struct spu_context *ctx = i->i_ctx;
245 file->private_data = ctx;
246 file->f_mapping = inode->i_mapping;
247 ctx->cntl = inode->i_mapping;
248 return simple_attr_open(inode, file, spufs_cntl_get,
249 spufs_cntl_set, "0x%08lx");
252 static struct file_operations spufs_cntl_fops = {
253 .open = spufs_cntl_open,
254 .release = simple_attr_close,
255 .read = simple_attr_read,
256 .write = simple_attr_write,
257 .mmap = spufs_cntl_mmap,
261 spufs_regs_open(struct inode *inode, struct file *file)
263 struct spufs_inode_info *i = SPUFS_I(inode);
264 file->private_data = i->i_ctx;
269 __spufs_regs_read(struct spu_context *ctx, char __user *buffer,
270 size_t size, loff_t *pos)
272 struct spu_lscsa *lscsa = ctx->csa.lscsa;
273 return simple_read_from_buffer(buffer, size, pos,
274 lscsa->gprs, sizeof lscsa->gprs);
278 spufs_regs_read(struct file *file, char __user *buffer,
279 size_t size, loff_t *pos)
282 struct spu_context *ctx = file->private_data;
284 spu_acquire_saved(ctx);
285 ret = __spufs_regs_read(ctx, buffer, size, pos);
291 spufs_regs_write(struct file *file, const char __user *buffer,
292 size_t size, loff_t *pos)
294 struct spu_context *ctx = file->private_data;
295 struct spu_lscsa *lscsa = ctx->csa.lscsa;
298 size = min_t(ssize_t, sizeof lscsa->gprs - *pos, size);
303 spu_acquire_saved(ctx);
305 ret = copy_from_user(lscsa->gprs + *pos - size,
306 buffer, size) ? -EFAULT : size;
312 static struct file_operations spufs_regs_fops = {
313 .open = spufs_regs_open,
314 .read = spufs_regs_read,
315 .write = spufs_regs_write,
316 .llseek = generic_file_llseek,
320 __spufs_fpcr_read(struct spu_context *ctx, char __user * buffer,
321 size_t size, loff_t * pos)
323 struct spu_lscsa *lscsa = ctx->csa.lscsa;
324 return simple_read_from_buffer(buffer, size, pos,
325 &lscsa->fpcr, sizeof(lscsa->fpcr));
329 spufs_fpcr_read(struct file *file, char __user * buffer,
330 size_t size, loff_t * pos)
333 struct spu_context *ctx = file->private_data;
335 spu_acquire_saved(ctx);
336 ret = __spufs_fpcr_read(ctx, buffer, size, pos);
342 spufs_fpcr_write(struct file *file, const char __user * buffer,
343 size_t size, loff_t * pos)
345 struct spu_context *ctx = file->private_data;
346 struct spu_lscsa *lscsa = ctx->csa.lscsa;
349 size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
354 spu_acquire_saved(ctx);
356 ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
357 buffer, size) ? -EFAULT : size;
363 static struct file_operations spufs_fpcr_fops = {
364 .open = spufs_regs_open,
365 .read = spufs_fpcr_read,
366 .write = spufs_fpcr_write,
367 .llseek = generic_file_llseek,
370 /* generic open function for all pipe-like files */
371 static int spufs_pipe_open(struct inode *inode, struct file *file)
373 struct spufs_inode_info *i = SPUFS_I(inode);
374 file->private_data = i->i_ctx;
376 return nonseekable_open(inode, file);
380 * Read as many bytes from the mailbox as possible, until
381 * one of the conditions becomes true:
383 * - no more data available in the mailbox
384 * - end of the user provided buffer
385 * - end of the mapped area
387 static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
388 size_t len, loff_t *pos)
390 struct spu_context *ctx = file->private_data;
391 u32 mbox_data, __user *udata;
397 if (!access_ok(VERIFY_WRITE, buf, len))
400 udata = (void __user *)buf;
403 for (count = 0; (count + 4) <= len; count += 4, udata++) {
405 ret = ctx->ops->mbox_read(ctx, &mbox_data);
410 * at the end of the mapped area, we can fault
411 * but still need to return the data we have
412 * read successfully so far.
414 ret = __put_user(mbox_data, udata);
429 static struct file_operations spufs_mbox_fops = {
430 .open = spufs_pipe_open,
431 .read = spufs_mbox_read,
434 static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
435 size_t len, loff_t *pos)
437 struct spu_context *ctx = file->private_data;
445 mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff;
449 if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
455 static struct file_operations spufs_mbox_stat_fops = {
456 .open = spufs_pipe_open,
457 .read = spufs_mbox_stat_read,
460 /* low-level ibox access function */
461 size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
463 return ctx->ops->ibox_read(ctx, data);
466 static int spufs_ibox_fasync(int fd, struct file *file, int on)
468 struct spu_context *ctx = file->private_data;
470 return fasync_helper(fd, file, on, &ctx->ibox_fasync);
473 /* interrupt-level ibox callback function. */
474 void spufs_ibox_callback(struct spu *spu)
476 struct spu_context *ctx = spu->ctx;
478 wake_up_all(&ctx->ibox_wq);
479 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
483 * Read as many bytes from the interrupt mailbox as possible, until
484 * one of the conditions becomes true:
486 * - no more data available in the mailbox
487 * - end of the user provided buffer
488 * - end of the mapped area
490 * If the file is opened without O_NONBLOCK, we wait here until
491 * any data is available, but return when we have been able to
494 static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
495 size_t len, loff_t *pos)
497 struct spu_context *ctx = file->private_data;
498 u32 ibox_data, __user *udata;
504 if (!access_ok(VERIFY_WRITE, buf, len))
507 udata = (void __user *)buf;
511 /* wait only for the first element */
513 if (file->f_flags & O_NONBLOCK) {
514 if (!spu_ibox_read(ctx, &ibox_data))
517 count = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data));
522 /* if we can't write at all, return -EFAULT */
523 count = __put_user(ibox_data, udata);
527 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
529 ret = ctx->ops->ibox_read(ctx, &ibox_data);
533 * at the end of the mapped area, we can fault
534 * but still need to return the data we have
535 * read successfully so far.
537 ret = __put_user(ibox_data, udata);
548 static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
550 struct spu_context *ctx = file->private_data;
553 poll_wait(file, &ctx->ibox_wq, wait);
556 mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
562 static struct file_operations spufs_ibox_fops = {
563 .open = spufs_pipe_open,
564 .read = spufs_ibox_read,
565 .poll = spufs_ibox_poll,
566 .fasync = spufs_ibox_fasync,
569 static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
570 size_t len, loff_t *pos)
572 struct spu_context *ctx = file->private_data;
579 ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
582 if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
588 static struct file_operations spufs_ibox_stat_fops = {
589 .open = spufs_pipe_open,
590 .read = spufs_ibox_stat_read,
593 /* low-level mailbox write */
594 size_t spu_wbox_write(struct spu_context *ctx, u32 data)
596 return ctx->ops->wbox_write(ctx, data);
599 static int spufs_wbox_fasync(int fd, struct file *file, int on)
601 struct spu_context *ctx = file->private_data;
604 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
609 /* interrupt-level wbox callback function. */
610 void spufs_wbox_callback(struct spu *spu)
612 struct spu_context *ctx = spu->ctx;
614 wake_up_all(&ctx->wbox_wq);
615 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
619 * Write as many bytes to the interrupt mailbox as possible, until
620 * one of the conditions becomes true:
622 * - the mailbox is full
623 * - end of the user provided buffer
624 * - end of the mapped area
626 * If the file is opened without O_NONBLOCK, we wait here until
627 * space is availabyl, but return when we have been able to
630 static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
631 size_t len, loff_t *pos)
633 struct spu_context *ctx = file->private_data;
634 u32 wbox_data, __user *udata;
640 udata = (void __user *)buf;
641 if (!access_ok(VERIFY_READ, buf, len))
644 if (__get_user(wbox_data, udata))
650 * make sure we can at least write one element, by waiting
651 * in case of !O_NONBLOCK
654 if (file->f_flags & O_NONBLOCK) {
655 if (!spu_wbox_write(ctx, wbox_data))
658 count = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data));
664 /* write aѕ much as possible */
665 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
667 ret = __get_user(wbox_data, udata);
671 ret = spu_wbox_write(ctx, wbox_data);
681 static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
683 struct spu_context *ctx = file->private_data;
686 poll_wait(file, &ctx->wbox_wq, wait);
689 mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
695 static struct file_operations spufs_wbox_fops = {
696 .open = spufs_pipe_open,
697 .write = spufs_wbox_write,
698 .poll = spufs_wbox_poll,
699 .fasync = spufs_wbox_fasync,
702 static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
703 size_t len, loff_t *pos)
705 struct spu_context *ctx = file->private_data;
712 wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
715 if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
721 static struct file_operations spufs_wbox_stat_fops = {
722 .open = spufs_pipe_open,
723 .read = spufs_wbox_stat_read,
726 static int spufs_signal1_open(struct inode *inode, struct file *file)
728 struct spufs_inode_info *i = SPUFS_I(inode);
729 struct spu_context *ctx = i->i_ctx;
730 file->private_data = ctx;
731 file->f_mapping = inode->i_mapping;
732 ctx->signal1 = inode->i_mapping;
733 return nonseekable_open(inode, file);
736 static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf,
737 size_t len, loff_t *pos)
745 if (ctx->csa.spu_chnlcnt_RW[3]) {
746 data = ctx->csa.spu_chnldata_RW[3];
753 if (copy_to_user(buf, &data, 4))
760 static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
761 size_t len, loff_t *pos)
764 struct spu_context *ctx = file->private_data;
766 spu_acquire_saved(ctx);
767 ret = __spufs_signal1_read(ctx, buf, len, pos);
773 static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
774 size_t len, loff_t *pos)
776 struct spu_context *ctx;
779 ctx = file->private_data;
784 if (copy_from_user(&data, buf, 4))
788 ctx->ops->signal1_write(ctx, data);
794 static struct page *spufs_signal1_mmap_nopage(struct vm_area_struct *vma,
795 unsigned long address, int *type)
797 #if PAGE_SIZE == 0x1000
798 return spufs_ps_nopage(vma, address, type, 0x14000, 0x1000);
799 #elif PAGE_SIZE == 0x10000
800 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
801 * signal 1 and 2 area
803 return spufs_ps_nopage(vma, address, type, 0x10000, 0x10000);
805 #error unsupported page size
809 static struct vm_operations_struct spufs_signal1_mmap_vmops = {
810 .nopage = spufs_signal1_mmap_nopage,
813 static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
815 if (!(vma->vm_flags & VM_SHARED))
818 vma->vm_flags |= VM_IO;
819 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
820 | _PAGE_NO_CACHE | _PAGE_GUARDED);
822 vma->vm_ops = &spufs_signal1_mmap_vmops;
826 static struct file_operations spufs_signal1_fops = {
827 .open = spufs_signal1_open,
828 .read = spufs_signal1_read,
829 .write = spufs_signal1_write,
830 .mmap = spufs_signal1_mmap,
833 static int spufs_signal2_open(struct inode *inode, struct file *file)
835 struct spufs_inode_info *i = SPUFS_I(inode);
836 struct spu_context *ctx = i->i_ctx;
837 file->private_data = ctx;
838 file->f_mapping = inode->i_mapping;
839 ctx->signal2 = inode->i_mapping;
840 return nonseekable_open(inode, file);
843 static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
844 size_t len, loff_t *pos)
852 if (ctx->csa.spu_chnlcnt_RW[4]) {
853 data = ctx->csa.spu_chnldata_RW[4];
860 if (copy_to_user(buf, &data, 4))
867 static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
868 size_t len, loff_t *pos)
870 struct spu_context *ctx = file->private_data;
873 spu_acquire_saved(ctx);
874 ret = __spufs_signal2_read(ctx, buf, len, pos);
880 static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
881 size_t len, loff_t *pos)
883 struct spu_context *ctx;
886 ctx = file->private_data;
891 if (copy_from_user(&data, buf, 4))
895 ctx->ops->signal2_write(ctx, data);
902 static struct page *spufs_signal2_mmap_nopage(struct vm_area_struct *vma,
903 unsigned long address, int *type)
905 #if PAGE_SIZE == 0x1000
906 return spufs_ps_nopage(vma, address, type, 0x1c000, 0x1000);
907 #elif PAGE_SIZE == 0x10000
908 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
909 * signal 1 and 2 area
911 return spufs_ps_nopage(vma, address, type, 0x10000, 0x10000);
913 #error unsupported page size
917 static struct vm_operations_struct spufs_signal2_mmap_vmops = {
918 .nopage = spufs_signal2_mmap_nopage,
921 static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
923 if (!(vma->vm_flags & VM_SHARED))
926 vma->vm_flags |= VM_IO;
927 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
928 | _PAGE_NO_CACHE | _PAGE_GUARDED);
930 vma->vm_ops = &spufs_signal2_mmap_vmops;
933 #else /* SPUFS_MMAP_4K */
934 #define spufs_signal2_mmap NULL
935 #endif /* !SPUFS_MMAP_4K */
937 static struct file_operations spufs_signal2_fops = {
938 .open = spufs_signal2_open,
939 .read = spufs_signal2_read,
940 .write = spufs_signal2_write,
941 .mmap = spufs_signal2_mmap,
944 static void spufs_signal1_type_set(void *data, u64 val)
946 struct spu_context *ctx = data;
949 ctx->ops->signal1_type_set(ctx, val);
953 static u64 __spufs_signal1_type_get(void *data)
955 struct spu_context *ctx = data;
956 return ctx->ops->signal1_type_get(ctx);
959 static u64 spufs_signal1_type_get(void *data)
961 struct spu_context *ctx = data;
965 ret = __spufs_signal1_type_get(data);
970 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
971 spufs_signal1_type_set, "%llu");
973 static void spufs_signal2_type_set(void *data, u64 val)
975 struct spu_context *ctx = data;
978 ctx->ops->signal2_type_set(ctx, val);
982 static u64 __spufs_signal2_type_get(void *data)
984 struct spu_context *ctx = data;
985 return ctx->ops->signal2_type_get(ctx);
988 static u64 spufs_signal2_type_get(void *data)
990 struct spu_context *ctx = data;
994 ret = __spufs_signal2_type_get(data);
999 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
1000 spufs_signal2_type_set, "%llu");
1003 static struct page *spufs_mss_mmap_nopage(struct vm_area_struct *vma,
1004 unsigned long address, int *type)
1006 return spufs_ps_nopage(vma, address, type, 0x0000, 0x1000);
1009 static struct vm_operations_struct spufs_mss_mmap_vmops = {
1010 .nopage = spufs_mss_mmap_nopage,
1014 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1016 static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
1018 if (!(vma->vm_flags & VM_SHARED))
1021 vma->vm_flags |= VM_IO;
1022 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1023 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1025 vma->vm_ops = &spufs_mss_mmap_vmops;
1028 #else /* SPUFS_MMAP_4K */
1029 #define spufs_mss_mmap NULL
1030 #endif /* !SPUFS_MMAP_4K */
1032 static int spufs_mss_open(struct inode *inode, struct file *file)
1034 struct spufs_inode_info *i = SPUFS_I(inode);
1036 file->private_data = i->i_ctx;
1037 return nonseekable_open(inode, file);
1040 static struct file_operations spufs_mss_fops = {
1041 .open = spufs_mss_open,
1042 .mmap = spufs_mss_mmap,
1045 static struct page *spufs_psmap_mmap_nopage(struct vm_area_struct *vma,
1046 unsigned long address, int *type)
1048 return spufs_ps_nopage(vma, address, type, 0x0000, 0x20000);
1051 static struct vm_operations_struct spufs_psmap_mmap_vmops = {
1052 .nopage = spufs_psmap_mmap_nopage,
1056 * mmap support for full problem state area [0x00000 - 0x1ffff].
1058 static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
1060 if (!(vma->vm_flags & VM_SHARED))
1063 vma->vm_flags |= VM_IO;
1064 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1065 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1067 vma->vm_ops = &spufs_psmap_mmap_vmops;
1071 static int spufs_psmap_open(struct inode *inode, struct file *file)
1073 struct spufs_inode_info *i = SPUFS_I(inode);
1075 file->private_data = i->i_ctx;
1076 return nonseekable_open(inode, file);
1079 static struct file_operations spufs_psmap_fops = {
1080 .open = spufs_psmap_open,
1081 .mmap = spufs_psmap_mmap,
1086 static struct page *spufs_mfc_mmap_nopage(struct vm_area_struct *vma,
1087 unsigned long address, int *type)
1089 return spufs_ps_nopage(vma, address, type, 0x3000, 0x1000);
1092 static struct vm_operations_struct spufs_mfc_mmap_vmops = {
1093 .nopage = spufs_mfc_mmap_nopage,
1097 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1099 static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
1101 if (!(vma->vm_flags & VM_SHARED))
1104 vma->vm_flags |= VM_IO;
1105 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1106 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1108 vma->vm_ops = &spufs_mfc_mmap_vmops;
1111 #else /* SPUFS_MMAP_4K */
1112 #define spufs_mfc_mmap NULL
1113 #endif /* !SPUFS_MMAP_4K */
1115 static int spufs_mfc_open(struct inode *inode, struct file *file)
1117 struct spufs_inode_info *i = SPUFS_I(inode);
1118 struct spu_context *ctx = i->i_ctx;
1120 /* we don't want to deal with DMA into other processes */
1121 if (ctx->owner != current->mm)
1124 if (atomic_read(&inode->i_count) != 1)
1127 file->private_data = ctx;
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);
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 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 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 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 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 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 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;