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)
66 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 *ppos)
79 struct spu_context *ctx = file->private_data;
88 if (size > LS_SIZE - pos)
92 local_store = ctx->ops->get_ls(ctx);
93 ret = copy_from_user(local_store + pos, buffer, size);
102 static unsigned long spufs_mem_mmap_nopfn(struct vm_area_struct *vma,
103 unsigned long address)
105 struct spu_context *ctx = vma->vm_file->private_data;
106 unsigned long pfn, offset = address - vma->vm_start;
108 offset += vma->vm_pgoff << PAGE_SHIFT;
110 if (offset >= LS_SIZE)
115 if (ctx->state == SPU_STATE_SAVED) {
116 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
118 pfn = vmalloc_to_pfn(ctx->csa.lscsa->ls + offset);
120 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
122 pfn = (ctx->spu->local_store_phys + offset) >> PAGE_SHIFT;
124 vm_insert_pfn(vma, address, pfn);
128 return NOPFN_REFAULT;
132 static struct vm_operations_struct spufs_mem_mmap_vmops = {
133 .nopfn = spufs_mem_mmap_nopfn,
137 spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
139 if (!(vma->vm_flags & VM_SHARED))
142 vma->vm_flags |= VM_IO | VM_PFNMAP;
143 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
146 vma->vm_ops = &spufs_mem_mmap_vmops;
150 static const struct file_operations spufs_mem_fops = {
151 .open = spufs_mem_open,
152 .read = spufs_mem_read,
153 .write = spufs_mem_write,
154 .llseek = generic_file_llseek,
155 .mmap = spufs_mem_mmap,
158 static unsigned long spufs_ps_nopfn(struct vm_area_struct *vma,
159 unsigned long address,
160 unsigned long ps_offs,
161 unsigned long ps_size)
163 struct spu_context *ctx = vma->vm_file->private_data;
164 unsigned long area, offset = address - vma->vm_start;
167 offset += vma->vm_pgoff << PAGE_SHIFT;
168 if (offset >= ps_size)
171 /* error here usually means a signal.. we might want to test
172 * the error code more precisely though
174 ret = spu_acquire_runnable(ctx, 0);
176 return NOPFN_REFAULT;
178 area = ctx->spu->problem_phys + ps_offs;
179 vm_insert_pfn(vma, address, (area + offset) >> PAGE_SHIFT);
182 return NOPFN_REFAULT;
186 static unsigned long spufs_cntl_mmap_nopfn(struct vm_area_struct *vma,
187 unsigned long address)
189 return spufs_ps_nopfn(vma, address, 0x4000, 0x1000);
192 static struct vm_operations_struct spufs_cntl_mmap_vmops = {
193 .nopfn = spufs_cntl_mmap_nopfn,
197 * mmap support for problem state control area [0x4000 - 0x4fff].
199 static int spufs_cntl_mmap(struct file *file, struct vm_area_struct *vma)
201 if (!(vma->vm_flags & VM_SHARED))
204 vma->vm_flags |= VM_IO | VM_PFNMAP;
205 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
206 | _PAGE_NO_CACHE | _PAGE_GUARDED);
208 vma->vm_ops = &spufs_cntl_mmap_vmops;
211 #else /* SPUFS_MMAP_4K */
212 #define spufs_cntl_mmap NULL
213 #endif /* !SPUFS_MMAP_4K */
215 static u64 spufs_cntl_get(void *data)
217 struct spu_context *ctx = data;
221 val = ctx->ops->status_read(ctx);
227 static void spufs_cntl_set(void *data, u64 val)
229 struct spu_context *ctx = data;
232 ctx->ops->runcntl_write(ctx, val);
236 static int spufs_cntl_open(struct inode *inode, struct file *file)
238 struct spufs_inode_info *i = SPUFS_I(inode);
239 struct spu_context *ctx = i->i_ctx;
241 file->private_data = ctx;
242 ctx->cntl = inode->i_mapping;
244 return simple_attr_open(inode, file, spufs_cntl_get,
245 spufs_cntl_set, "0x%08lx");
248 static const struct file_operations spufs_cntl_fops = {
249 .open = spufs_cntl_open,
250 .release = simple_attr_close,
251 .read = simple_attr_read,
252 .write = simple_attr_write,
253 .mmap = spufs_cntl_mmap,
257 spufs_regs_open(struct inode *inode, struct file *file)
259 struct spufs_inode_info *i = SPUFS_I(inode);
260 file->private_data = i->i_ctx;
265 __spufs_regs_read(struct spu_context *ctx, char __user *buffer,
266 size_t size, loff_t *pos)
268 struct spu_lscsa *lscsa = ctx->csa.lscsa;
269 return simple_read_from_buffer(buffer, size, pos,
270 lscsa->gprs, sizeof lscsa->gprs);
274 spufs_regs_read(struct file *file, char __user *buffer,
275 size_t size, loff_t *pos)
278 struct spu_context *ctx = file->private_data;
280 spu_acquire_saved(ctx);
281 ret = __spufs_regs_read(ctx, buffer, size, pos);
287 spufs_regs_write(struct file *file, const char __user *buffer,
288 size_t size, loff_t *pos)
290 struct spu_context *ctx = file->private_data;
291 struct spu_lscsa *lscsa = ctx->csa.lscsa;
294 size = min_t(ssize_t, sizeof lscsa->gprs - *pos, size);
299 spu_acquire_saved(ctx);
301 ret = copy_from_user(lscsa->gprs + *pos - size,
302 buffer, size) ? -EFAULT : size;
308 static const struct file_operations spufs_regs_fops = {
309 .open = spufs_regs_open,
310 .read = spufs_regs_read,
311 .write = spufs_regs_write,
312 .llseek = generic_file_llseek,
316 __spufs_fpcr_read(struct spu_context *ctx, char __user * buffer,
317 size_t size, loff_t * pos)
319 struct spu_lscsa *lscsa = ctx->csa.lscsa;
320 return simple_read_from_buffer(buffer, size, pos,
321 &lscsa->fpcr, sizeof(lscsa->fpcr));
325 spufs_fpcr_read(struct file *file, char __user * buffer,
326 size_t size, loff_t * pos)
329 struct spu_context *ctx = file->private_data;
331 spu_acquire_saved(ctx);
332 ret = __spufs_fpcr_read(ctx, buffer, size, pos);
338 spufs_fpcr_write(struct file *file, const char __user * buffer,
339 size_t size, loff_t * pos)
341 struct spu_context *ctx = file->private_data;
342 struct spu_lscsa *lscsa = ctx->csa.lscsa;
345 size = min_t(ssize_t, sizeof(lscsa->fpcr) - *pos, size);
350 spu_acquire_saved(ctx);
352 ret = copy_from_user((char *)&lscsa->fpcr + *pos - size,
353 buffer, size) ? -EFAULT : size;
359 static const struct file_operations spufs_fpcr_fops = {
360 .open = spufs_regs_open,
361 .read = spufs_fpcr_read,
362 .write = spufs_fpcr_write,
363 .llseek = generic_file_llseek,
366 /* generic open function for all pipe-like files */
367 static int spufs_pipe_open(struct inode *inode, struct file *file)
369 struct spufs_inode_info *i = SPUFS_I(inode);
370 file->private_data = i->i_ctx;
372 return nonseekable_open(inode, file);
376 * Read as many bytes from the mailbox as possible, until
377 * one of the conditions becomes true:
379 * - no more data available in the mailbox
380 * - end of the user provided buffer
381 * - end of the mapped area
383 static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
384 size_t len, loff_t *pos)
386 struct spu_context *ctx = file->private_data;
387 u32 mbox_data, __user *udata;
393 if (!access_ok(VERIFY_WRITE, buf, len))
396 udata = (void __user *)buf;
399 for (count = 0; (count + 4) <= len; count += 4, udata++) {
401 ret = ctx->ops->mbox_read(ctx, &mbox_data);
406 * at the end of the mapped area, we can fault
407 * but still need to return the data we have
408 * read successfully so far.
410 ret = __put_user(mbox_data, udata);
425 static const struct file_operations spufs_mbox_fops = {
426 .open = spufs_pipe_open,
427 .read = spufs_mbox_read,
430 static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
431 size_t len, loff_t *pos)
433 struct spu_context *ctx = file->private_data;
441 mbox_stat = ctx->ops->mbox_stat_read(ctx) & 0xff;
445 if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
451 static const struct file_operations spufs_mbox_stat_fops = {
452 .open = spufs_pipe_open,
453 .read = spufs_mbox_stat_read,
456 /* low-level ibox access function */
457 size_t spu_ibox_read(struct spu_context *ctx, u32 *data)
459 return ctx->ops->ibox_read(ctx, data);
462 static int spufs_ibox_fasync(int fd, struct file *file, int on)
464 struct spu_context *ctx = file->private_data;
466 return fasync_helper(fd, file, on, &ctx->ibox_fasync);
469 /* interrupt-level ibox callback function. */
470 void spufs_ibox_callback(struct spu *spu)
472 struct spu_context *ctx = spu->ctx;
474 wake_up_all(&ctx->ibox_wq);
475 kill_fasync(&ctx->ibox_fasync, SIGIO, POLLIN);
479 * Read as many bytes from the interrupt mailbox as possible, until
480 * one of the conditions becomes true:
482 * - no more data available in the mailbox
483 * - end of the user provided buffer
484 * - end of the mapped area
486 * If the file is opened without O_NONBLOCK, we wait here until
487 * any data is available, but return when we have been able to
490 static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
491 size_t len, loff_t *pos)
493 struct spu_context *ctx = file->private_data;
494 u32 ibox_data, __user *udata;
500 if (!access_ok(VERIFY_WRITE, buf, len))
503 udata = (void __user *)buf;
507 /* wait only for the first element */
509 if (file->f_flags & O_NONBLOCK) {
510 if (!spu_ibox_read(ctx, &ibox_data))
513 count = spufs_wait(ctx->ibox_wq, spu_ibox_read(ctx, &ibox_data));
518 /* if we can't write at all, return -EFAULT */
519 count = __put_user(ibox_data, udata);
523 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
525 ret = ctx->ops->ibox_read(ctx, &ibox_data);
529 * at the end of the mapped area, we can fault
530 * but still need to return the data we have
531 * read successfully so far.
533 ret = __put_user(ibox_data, udata);
544 static unsigned int spufs_ibox_poll(struct file *file, poll_table *wait)
546 struct spu_context *ctx = file->private_data;
549 poll_wait(file, &ctx->ibox_wq, wait);
552 mask = ctx->ops->mbox_stat_poll(ctx, POLLIN | POLLRDNORM);
558 static const struct file_operations spufs_ibox_fops = {
559 .open = spufs_pipe_open,
560 .read = spufs_ibox_read,
561 .poll = spufs_ibox_poll,
562 .fasync = spufs_ibox_fasync,
565 static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
566 size_t len, loff_t *pos)
568 struct spu_context *ctx = file->private_data;
575 ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
578 if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
584 static const struct file_operations spufs_ibox_stat_fops = {
585 .open = spufs_pipe_open,
586 .read = spufs_ibox_stat_read,
589 /* low-level mailbox write */
590 size_t spu_wbox_write(struct spu_context *ctx, u32 data)
592 return ctx->ops->wbox_write(ctx, data);
595 static int spufs_wbox_fasync(int fd, struct file *file, int on)
597 struct spu_context *ctx = file->private_data;
600 ret = fasync_helper(fd, file, on, &ctx->wbox_fasync);
605 /* interrupt-level wbox callback function. */
606 void spufs_wbox_callback(struct spu *spu)
608 struct spu_context *ctx = spu->ctx;
610 wake_up_all(&ctx->wbox_wq);
611 kill_fasync(&ctx->wbox_fasync, SIGIO, POLLOUT);
615 * Write as many bytes to the interrupt mailbox as possible, until
616 * one of the conditions becomes true:
618 * - the mailbox is full
619 * - end of the user provided buffer
620 * - end of the mapped area
622 * If the file is opened without O_NONBLOCK, we wait here until
623 * space is availabyl, but return when we have been able to
626 static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
627 size_t len, loff_t *pos)
629 struct spu_context *ctx = file->private_data;
630 u32 wbox_data, __user *udata;
636 udata = (void __user *)buf;
637 if (!access_ok(VERIFY_READ, buf, len))
640 if (__get_user(wbox_data, udata))
646 * make sure we can at least write one element, by waiting
647 * in case of !O_NONBLOCK
650 if (file->f_flags & O_NONBLOCK) {
651 if (!spu_wbox_write(ctx, wbox_data))
654 count = spufs_wait(ctx->wbox_wq, spu_wbox_write(ctx, wbox_data));
660 /* write aѕ much as possible */
661 for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
663 ret = __get_user(wbox_data, udata);
667 ret = spu_wbox_write(ctx, wbox_data);
677 static unsigned int spufs_wbox_poll(struct file *file, poll_table *wait)
679 struct spu_context *ctx = file->private_data;
682 poll_wait(file, &ctx->wbox_wq, wait);
685 mask = ctx->ops->mbox_stat_poll(ctx, POLLOUT | POLLWRNORM);
691 static const struct file_operations spufs_wbox_fops = {
692 .open = spufs_pipe_open,
693 .write = spufs_wbox_write,
694 .poll = spufs_wbox_poll,
695 .fasync = spufs_wbox_fasync,
698 static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
699 size_t len, loff_t *pos)
701 struct spu_context *ctx = file->private_data;
708 wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
711 if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
717 static const struct file_operations spufs_wbox_stat_fops = {
718 .open = spufs_pipe_open,
719 .read = spufs_wbox_stat_read,
722 static int spufs_signal1_open(struct inode *inode, struct file *file)
724 struct spufs_inode_info *i = SPUFS_I(inode);
725 struct spu_context *ctx = i->i_ctx;
726 file->private_data = ctx;
727 ctx->signal1 = inode->i_mapping;
729 return nonseekable_open(inode, file);
732 static ssize_t __spufs_signal1_read(struct spu_context *ctx, char __user *buf,
733 size_t len, loff_t *pos)
741 if (ctx->csa.spu_chnlcnt_RW[3]) {
742 data = ctx->csa.spu_chnldata_RW[3];
749 if (copy_to_user(buf, &data, 4))
756 static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
757 size_t len, loff_t *pos)
760 struct spu_context *ctx = file->private_data;
762 spu_acquire_saved(ctx);
763 ret = __spufs_signal1_read(ctx, buf, len, pos);
769 static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
770 size_t len, loff_t *pos)
772 struct spu_context *ctx;
775 ctx = file->private_data;
780 if (copy_from_user(&data, buf, 4))
784 ctx->ops->signal1_write(ctx, data);
790 static unsigned long spufs_signal1_mmap_nopfn(struct vm_area_struct *vma,
791 unsigned long address)
793 #if PAGE_SIZE == 0x1000
794 return spufs_ps_nopfn(vma, address, 0x14000, 0x1000);
795 #elif PAGE_SIZE == 0x10000
796 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
797 * signal 1 and 2 area
799 return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
801 #error unsupported page size
805 static struct vm_operations_struct spufs_signal1_mmap_vmops = {
806 .nopfn = spufs_signal1_mmap_nopfn,
809 static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
811 if (!(vma->vm_flags & VM_SHARED))
814 vma->vm_flags |= VM_IO | VM_PFNMAP;
815 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
816 | _PAGE_NO_CACHE | _PAGE_GUARDED);
818 vma->vm_ops = &spufs_signal1_mmap_vmops;
822 static const struct file_operations spufs_signal1_fops = {
823 .open = spufs_signal1_open,
824 .read = spufs_signal1_read,
825 .write = spufs_signal1_write,
826 .mmap = spufs_signal1_mmap,
829 static int spufs_signal2_open(struct inode *inode, struct file *file)
831 struct spufs_inode_info *i = SPUFS_I(inode);
832 struct spu_context *ctx = i->i_ctx;
833 file->private_data = ctx;
834 ctx->signal2 = inode->i_mapping;
836 return nonseekable_open(inode, file);
839 static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
840 size_t len, loff_t *pos)
848 if (ctx->csa.spu_chnlcnt_RW[4]) {
849 data = ctx->csa.spu_chnldata_RW[4];
856 if (copy_to_user(buf, &data, 4))
863 static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
864 size_t len, loff_t *pos)
866 struct spu_context *ctx = file->private_data;
869 spu_acquire_saved(ctx);
870 ret = __spufs_signal2_read(ctx, buf, len, pos);
876 static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
877 size_t len, loff_t *pos)
879 struct spu_context *ctx;
882 ctx = file->private_data;
887 if (copy_from_user(&data, buf, 4))
891 ctx->ops->signal2_write(ctx, data);
898 static unsigned long spufs_signal2_mmap_nopfn(struct vm_area_struct *vma,
899 unsigned long address)
901 #if PAGE_SIZE == 0x1000
902 return spufs_ps_nopfn(vma, address, 0x1c000, 0x1000);
903 #elif PAGE_SIZE == 0x10000
904 /* For 64k pages, both signal1 and signal2 can be used to mmap the whole
905 * signal 1 and 2 area
907 return spufs_ps_nopfn(vma, address, 0x10000, 0x10000);
909 #error unsupported page size
913 static struct vm_operations_struct spufs_signal2_mmap_vmops = {
914 .nopfn = spufs_signal2_mmap_nopfn,
917 static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
919 if (!(vma->vm_flags & VM_SHARED))
922 vma->vm_flags |= VM_IO | VM_PFNMAP;
923 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
924 | _PAGE_NO_CACHE | _PAGE_GUARDED);
926 vma->vm_ops = &spufs_signal2_mmap_vmops;
929 #else /* SPUFS_MMAP_4K */
930 #define spufs_signal2_mmap NULL
931 #endif /* !SPUFS_MMAP_4K */
933 static const struct file_operations spufs_signal2_fops = {
934 .open = spufs_signal2_open,
935 .read = spufs_signal2_read,
936 .write = spufs_signal2_write,
937 .mmap = spufs_signal2_mmap,
940 static void spufs_signal1_type_set(void *data, u64 val)
942 struct spu_context *ctx = data;
945 ctx->ops->signal1_type_set(ctx, val);
949 static u64 __spufs_signal1_type_get(void *data)
951 struct spu_context *ctx = data;
952 return ctx->ops->signal1_type_get(ctx);
955 static u64 spufs_signal1_type_get(void *data)
957 struct spu_context *ctx = data;
961 ret = __spufs_signal1_type_get(data);
966 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
967 spufs_signal1_type_set, "%llu");
969 static void spufs_signal2_type_set(void *data, u64 val)
971 struct spu_context *ctx = data;
974 ctx->ops->signal2_type_set(ctx, val);
978 static u64 __spufs_signal2_type_get(void *data)
980 struct spu_context *ctx = data;
981 return ctx->ops->signal2_type_get(ctx);
984 static u64 spufs_signal2_type_get(void *data)
986 struct spu_context *ctx = data;
990 ret = __spufs_signal2_type_get(data);
995 DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
996 spufs_signal2_type_set, "%llu");
999 static unsigned long spufs_mss_mmap_nopfn(struct vm_area_struct *vma,
1000 unsigned long address)
1002 return spufs_ps_nopfn(vma, address, 0x0000, 0x1000);
1005 static struct vm_operations_struct spufs_mss_mmap_vmops = {
1006 .nopfn = spufs_mss_mmap_nopfn,
1010 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1012 static int spufs_mss_mmap(struct file *file, struct vm_area_struct *vma)
1014 if (!(vma->vm_flags & VM_SHARED))
1017 vma->vm_flags |= VM_IO | VM_PFNMAP;
1018 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1019 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1021 vma->vm_ops = &spufs_mss_mmap_vmops;
1024 #else /* SPUFS_MMAP_4K */
1025 #define spufs_mss_mmap NULL
1026 #endif /* !SPUFS_MMAP_4K */
1028 static int spufs_mss_open(struct inode *inode, struct file *file)
1030 struct spufs_inode_info *i = SPUFS_I(inode);
1031 struct spu_context *ctx = i->i_ctx;
1033 file->private_data = i->i_ctx;
1034 ctx->mss = inode->i_mapping;
1036 return nonseekable_open(inode, file);
1039 static const struct file_operations spufs_mss_fops = {
1040 .open = spufs_mss_open,
1041 .mmap = spufs_mss_mmap,
1044 static unsigned long spufs_psmap_mmap_nopfn(struct vm_area_struct *vma,
1045 unsigned long address)
1047 return spufs_ps_nopfn(vma, address, 0x0000, 0x20000);
1050 static struct vm_operations_struct spufs_psmap_mmap_vmops = {
1051 .nopfn = spufs_psmap_mmap_nopfn,
1055 * mmap support for full problem state area [0x00000 - 0x1ffff].
1057 static int spufs_psmap_mmap(struct file *file, struct vm_area_struct *vma)
1059 if (!(vma->vm_flags & VM_SHARED))
1062 vma->vm_flags |= VM_IO | VM_PFNMAP;
1063 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1064 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1066 vma->vm_ops = &spufs_psmap_mmap_vmops;
1070 static int spufs_psmap_open(struct inode *inode, struct file *file)
1072 struct spufs_inode_info *i = SPUFS_I(inode);
1073 struct spu_context *ctx = i->i_ctx;
1075 file->private_data = i->i_ctx;
1076 ctx->psmap = inode->i_mapping;
1078 return nonseekable_open(inode, file);
1081 static const struct file_operations spufs_psmap_fops = {
1082 .open = spufs_psmap_open,
1083 .mmap = spufs_psmap_mmap,
1088 static unsigned long spufs_mfc_mmap_nopfn(struct vm_area_struct *vma,
1089 unsigned long address)
1091 return spufs_ps_nopfn(vma, address, 0x3000, 0x1000);
1094 static struct vm_operations_struct spufs_mfc_mmap_vmops = {
1095 .nopfn = spufs_mfc_mmap_nopfn,
1099 * mmap support for problem state MFC DMA area [0x0000 - 0x0fff].
1101 static int spufs_mfc_mmap(struct file *file, struct vm_area_struct *vma)
1103 if (!(vma->vm_flags & VM_SHARED))
1106 vma->vm_flags |= VM_IO | VM_PFNMAP;
1107 vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot)
1108 | _PAGE_NO_CACHE | _PAGE_GUARDED);
1110 vma->vm_ops = &spufs_mfc_mmap_vmops;
1113 #else /* SPUFS_MMAP_4K */
1114 #define spufs_mfc_mmap NULL
1115 #endif /* !SPUFS_MMAP_4K */
1117 static int spufs_mfc_open(struct inode *inode, struct file *file)
1119 struct spufs_inode_info *i = SPUFS_I(inode);
1120 struct spu_context *ctx = i->i_ctx;
1122 /* we don't want to deal with DMA into other processes */
1123 if (ctx->owner != current->mm)
1126 if (atomic_read(&inode->i_count) != 1)
1129 file->private_data = ctx;
1130 ctx->mfc = inode->i_mapping;
1132 return nonseekable_open(inode, file);
1135 /* interrupt-level mfc callback function. */
1136 void spufs_mfc_callback(struct spu *spu)
1138 struct spu_context *ctx = spu->ctx;
1140 wake_up_all(&ctx->mfc_wq);
1142 pr_debug("%s %s\n", __FUNCTION__, spu->name);
1143 if (ctx->mfc_fasync) {
1144 u32 free_elements, tagstatus;
1147 /* no need for spu_acquire in interrupt context */
1148 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1149 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1152 if (free_elements & 0xffff)
1154 if (tagstatus & ctx->tagwait)
1157 kill_fasync(&ctx->mfc_fasync, SIGIO, mask);
1161 static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
1163 /* See if there is one tag group is complete */
1164 /* FIXME we need locking around tagwait */
1165 *status = ctx->ops->read_mfc_tagstatus(ctx) & ctx->tagwait;
1166 ctx->tagwait &= ~*status;
1170 /* enable interrupt waiting for any tag group,
1171 may silently fail if interrupts are already enabled */
1172 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1176 static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
1177 size_t size, loff_t *pos)
1179 struct spu_context *ctx = file->private_data;
1187 if (file->f_flags & O_NONBLOCK) {
1188 status = ctx->ops->read_mfc_tagstatus(ctx);
1189 if (!(status & ctx->tagwait))
1192 ctx->tagwait &= ~status;
1194 ret = spufs_wait(ctx->mfc_wq,
1195 spufs_read_mfc_tagstatus(ctx, &status));
1203 if (copy_to_user(buffer, &status, 4))
1210 static int spufs_check_valid_dma(struct mfc_dma_command *cmd)
1212 pr_debug("queueing DMA %x %lx %x %x %x\n", cmd->lsa,
1213 cmd->ea, cmd->size, cmd->tag, cmd->cmd);
1224 pr_debug("invalid DMA opcode %x\n", cmd->cmd);
1228 if ((cmd->lsa & 0xf) != (cmd->ea &0xf)) {
1229 pr_debug("invalid DMA alignment, ea %lx lsa %x\n",
1234 switch (cmd->size & 0xf) {
1255 pr_debug("invalid DMA alignment %x for size %x\n",
1256 cmd->lsa & 0xf, cmd->size);
1260 if (cmd->size > 16 * 1024) {
1261 pr_debug("invalid DMA size %x\n", cmd->size);
1265 if (cmd->tag & 0xfff0) {
1266 /* we reserve the higher tag numbers for kernel use */
1267 pr_debug("invalid DMA tag\n");
1272 /* not supported in this version */
1273 pr_debug("invalid DMA class\n");
1280 static int spu_send_mfc_command(struct spu_context *ctx,
1281 struct mfc_dma_command cmd,
1284 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1285 if (*error == -EAGAIN) {
1286 /* wait for any tag group to complete
1287 so we have space for the new command */
1288 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 1);
1289 /* try again, because the queue might be
1291 *error = ctx->ops->send_mfc_command(ctx, &cmd);
1292 if (*error == -EAGAIN)
1298 static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
1299 size_t size, loff_t *pos)
1301 struct spu_context *ctx = file->private_data;
1302 struct mfc_dma_command cmd;
1305 if (size != sizeof cmd)
1309 if (copy_from_user(&cmd, buffer, sizeof cmd))
1312 ret = spufs_check_valid_dma(&cmd);
1316 spu_acquire_runnable(ctx, 0);
1317 if (file->f_flags & O_NONBLOCK) {
1318 ret = ctx->ops->send_mfc_command(ctx, &cmd);
1321 ret = spufs_wait(ctx->mfc_wq,
1322 spu_send_mfc_command(ctx, cmd, &status));
1331 ctx->tagwait |= 1 << cmd.tag;
1338 static unsigned int spufs_mfc_poll(struct file *file,poll_table *wait)
1340 struct spu_context *ctx = file->private_data;
1341 u32 free_elements, tagstatus;
1345 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2);
1346 free_elements = ctx->ops->get_mfc_free_elements(ctx);
1347 tagstatus = ctx->ops->read_mfc_tagstatus(ctx);
1350 poll_wait(file, &ctx->mfc_wq, wait);
1353 if (free_elements & 0xffff)
1354 mask |= POLLOUT | POLLWRNORM;
1355 if (tagstatus & ctx->tagwait)
1356 mask |= POLLIN | POLLRDNORM;
1358 pr_debug("%s: free %d tagstatus %d tagwait %d\n", __FUNCTION__,
1359 free_elements, tagstatus, ctx->tagwait);
1364 static int spufs_mfc_flush(struct file *file, fl_owner_t id)
1366 struct spu_context *ctx = file->private_data;
1371 /* this currently hangs */
1372 ret = spufs_wait(ctx->mfc_wq,
1373 ctx->ops->set_mfc_query(ctx, ctx->tagwait, 2));
1376 ret = spufs_wait(ctx->mfc_wq,
1377 ctx->ops->read_mfc_tagstatus(ctx) == ctx->tagwait);
1387 static int spufs_mfc_fsync(struct file *file, struct dentry *dentry,
1390 return spufs_mfc_flush(file, NULL);
1393 static int spufs_mfc_fasync(int fd, struct file *file, int on)
1395 struct spu_context *ctx = file->private_data;
1397 return fasync_helper(fd, file, on, &ctx->mfc_fasync);
1400 static const struct file_operations spufs_mfc_fops = {
1401 .open = spufs_mfc_open,
1402 .read = spufs_mfc_read,
1403 .write = spufs_mfc_write,
1404 .poll = spufs_mfc_poll,
1405 .flush = spufs_mfc_flush,
1406 .fsync = spufs_mfc_fsync,
1407 .fasync = spufs_mfc_fasync,
1408 .mmap = spufs_mfc_mmap,
1411 static void spufs_npc_set(void *data, u64 val)
1413 struct spu_context *ctx = data;
1415 ctx->ops->npc_write(ctx, val);
1419 static u64 spufs_npc_get(void *data)
1421 struct spu_context *ctx = data;
1424 ret = ctx->ops->npc_read(ctx);
1428 DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set,
1431 static void spufs_decr_set(void *data, u64 val)
1433 struct spu_context *ctx = data;
1434 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1435 spu_acquire_saved(ctx);
1436 lscsa->decr.slot[0] = (u32) val;
1440 static u64 __spufs_decr_get(void *data)
1442 struct spu_context *ctx = data;
1443 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1444 return lscsa->decr.slot[0];
1447 static u64 spufs_decr_get(void *data)
1449 struct spu_context *ctx = data;
1451 spu_acquire_saved(ctx);
1452 ret = __spufs_decr_get(data);
1456 DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
1459 static void spufs_decr_status_set(void *data, u64 val)
1461 struct spu_context *ctx = data;
1462 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1463 spu_acquire_saved(ctx);
1464 lscsa->decr_status.slot[0] = (u32) val;
1468 static u64 __spufs_decr_status_get(void *data)
1470 struct spu_context *ctx = data;
1471 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1472 return lscsa->decr_status.slot[0];
1475 static u64 spufs_decr_status_get(void *data)
1477 struct spu_context *ctx = data;
1479 spu_acquire_saved(ctx);
1480 ret = __spufs_decr_status_get(data);
1484 DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
1485 spufs_decr_status_set, "0x%llx\n")
1487 static void spufs_event_mask_set(void *data, u64 val)
1489 struct spu_context *ctx = data;
1490 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1491 spu_acquire_saved(ctx);
1492 lscsa->event_mask.slot[0] = (u32) val;
1496 static u64 __spufs_event_mask_get(void *data)
1498 struct spu_context *ctx = data;
1499 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1500 return lscsa->event_mask.slot[0];
1503 static u64 spufs_event_mask_get(void *data)
1505 struct spu_context *ctx = data;
1507 spu_acquire_saved(ctx);
1508 ret = __spufs_event_mask_get(data);
1512 DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
1513 spufs_event_mask_set, "0x%llx\n")
1515 static u64 __spufs_event_status_get(void *data)
1517 struct spu_context *ctx = data;
1518 struct spu_state *state = &ctx->csa;
1520 stat = state->spu_chnlcnt_RW[0];
1522 return state->spu_chnldata_RW[0];
1526 static u64 spufs_event_status_get(void *data)
1528 struct spu_context *ctx = data;
1531 spu_acquire_saved(ctx);
1532 ret = __spufs_event_status_get(data);
1536 DEFINE_SIMPLE_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
1539 static void spufs_srr0_set(void *data, u64 val)
1541 struct spu_context *ctx = data;
1542 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1543 spu_acquire_saved(ctx);
1544 lscsa->srr0.slot[0] = (u32) val;
1548 static u64 spufs_srr0_get(void *data)
1550 struct spu_context *ctx = data;
1551 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1553 spu_acquire_saved(ctx);
1554 ret = lscsa->srr0.slot[0];
1558 DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
1561 static u64 spufs_id_get(void *data)
1563 struct spu_context *ctx = data;
1567 if (ctx->state == SPU_STATE_RUNNABLE)
1568 num = ctx->spu->number;
1570 num = (unsigned int)-1;
1575 DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n")
1577 static u64 __spufs_object_id_get(void *data)
1579 struct spu_context *ctx = data;
1580 return ctx->object_id;
1583 static u64 spufs_object_id_get(void *data)
1585 /* FIXME: Should there really be no locking here? */
1586 return __spufs_object_id_get(data);
1589 static void spufs_object_id_set(void *data, u64 id)
1591 struct spu_context *ctx = data;
1592 ctx->object_id = id;
1595 DEFINE_SIMPLE_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get,
1596 spufs_object_id_set, "0x%llx\n");
1598 static u64 __spufs_lslr_get(void *data)
1600 struct spu_context *ctx = data;
1601 return ctx->csa.priv2.spu_lslr_RW;
1604 static u64 spufs_lslr_get(void *data)
1606 struct spu_context *ctx = data;
1609 spu_acquire_saved(ctx);
1610 ret = __spufs_lslr_get(data);
1615 DEFINE_SIMPLE_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n")
1617 static int spufs_info_open(struct inode *inode, struct file *file)
1619 struct spufs_inode_info *i = SPUFS_I(inode);
1620 struct spu_context *ctx = i->i_ctx;
1621 file->private_data = ctx;
1625 static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
1626 char __user *buf, size_t len, loff_t *pos)
1631 mbox_stat = ctx->csa.prob.mb_stat_R;
1632 if (mbox_stat & 0x0000ff) {
1633 data = ctx->csa.prob.pu_mb_R;
1636 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1639 static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
1640 size_t len, loff_t *pos)
1643 struct spu_context *ctx = file->private_data;
1645 if (!access_ok(VERIFY_WRITE, buf, len))
1648 spu_acquire_saved(ctx);
1649 spin_lock(&ctx->csa.register_lock);
1650 ret = __spufs_mbox_info_read(ctx, buf, len, pos);
1651 spin_unlock(&ctx->csa.register_lock);
1657 static const struct file_operations spufs_mbox_info_fops = {
1658 .open = spufs_info_open,
1659 .read = spufs_mbox_info_read,
1660 .llseek = generic_file_llseek,
1663 static ssize_t __spufs_ibox_info_read(struct spu_context *ctx,
1664 char __user *buf, size_t len, loff_t *pos)
1669 ibox_stat = ctx->csa.prob.mb_stat_R;
1670 if (ibox_stat & 0xff0000) {
1671 data = ctx->csa.priv2.puint_mb_R;
1674 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1677 static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
1678 size_t len, loff_t *pos)
1680 struct spu_context *ctx = file->private_data;
1683 if (!access_ok(VERIFY_WRITE, buf, len))
1686 spu_acquire_saved(ctx);
1687 spin_lock(&ctx->csa.register_lock);
1688 ret = __spufs_ibox_info_read(ctx, buf, len, pos);
1689 spin_unlock(&ctx->csa.register_lock);
1695 static const struct file_operations spufs_ibox_info_fops = {
1696 .open = spufs_info_open,
1697 .read = spufs_ibox_info_read,
1698 .llseek = generic_file_llseek,
1701 static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,
1702 char __user *buf, size_t len, loff_t *pos)
1708 wbox_stat = ctx->csa.prob.mb_stat_R;
1709 cnt = 4 - ((wbox_stat & 0x00ff00) >> 8);
1710 for (i = 0; i < cnt; i++) {
1711 data[i] = ctx->csa.spu_mailbox_data[i];
1714 return simple_read_from_buffer(buf, len, pos, &data,
1718 static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
1719 size_t len, loff_t *pos)
1721 struct spu_context *ctx = file->private_data;
1724 if (!access_ok(VERIFY_WRITE, buf, len))
1727 spu_acquire_saved(ctx);
1728 spin_lock(&ctx->csa.register_lock);
1729 ret = __spufs_wbox_info_read(ctx, buf, len, pos);
1730 spin_unlock(&ctx->csa.register_lock);
1736 static const struct file_operations spufs_wbox_info_fops = {
1737 .open = spufs_info_open,
1738 .read = spufs_wbox_info_read,
1739 .llseek = generic_file_llseek,
1742 static ssize_t __spufs_dma_info_read(struct spu_context *ctx,
1743 char __user *buf, size_t len, loff_t *pos)
1745 struct spu_dma_info info;
1746 struct mfc_cq_sr *qp, *spuqp;
1749 info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;
1750 info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];
1751 info.dma_info_status = ctx->csa.spu_chnldata_RW[24];
1752 info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];
1753 info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];
1754 for (i = 0; i < 16; i++) {
1755 qp = &info.dma_info_command_data[i];
1756 spuqp = &ctx->csa.priv2.spuq[i];
1758 qp->mfc_cq_data0_RW = spuqp->mfc_cq_data0_RW;
1759 qp->mfc_cq_data1_RW = spuqp->mfc_cq_data1_RW;
1760 qp->mfc_cq_data2_RW = spuqp->mfc_cq_data2_RW;
1761 qp->mfc_cq_data3_RW = spuqp->mfc_cq_data3_RW;
1764 return simple_read_from_buffer(buf, len, pos, &info,
1768 static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
1769 size_t len, loff_t *pos)
1771 struct spu_context *ctx = file->private_data;
1774 if (!access_ok(VERIFY_WRITE, buf, len))
1777 spu_acquire_saved(ctx);
1778 spin_lock(&ctx->csa.register_lock);
1779 ret = __spufs_dma_info_read(ctx, buf, len, pos);
1780 spin_unlock(&ctx->csa.register_lock);
1786 static const struct file_operations spufs_dma_info_fops = {
1787 .open = spufs_info_open,
1788 .read = spufs_dma_info_read,
1791 static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,
1792 char __user *buf, size_t len, loff_t *pos)
1794 struct spu_proxydma_info info;
1795 struct mfc_cq_sr *qp, *puqp;
1796 int ret = sizeof info;
1802 if (!access_ok(VERIFY_WRITE, buf, len))
1805 info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW;
1806 info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;
1807 info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;
1808 for (i = 0; i < 8; i++) {
1809 qp = &info.proxydma_info_command_data[i];
1810 puqp = &ctx->csa.priv2.puq[i];
1812 qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;
1813 qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;
1814 qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;
1815 qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;
1818 return simple_read_from_buffer(buf, len, pos, &info,
1822 static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
1823 size_t len, loff_t *pos)
1825 struct spu_context *ctx = file->private_data;
1828 spu_acquire_saved(ctx);
1829 spin_lock(&ctx->csa.register_lock);
1830 ret = __spufs_proxydma_info_read(ctx, buf, len, pos);
1831 spin_unlock(&ctx->csa.register_lock);
1837 static const struct file_operations spufs_proxydma_info_fops = {
1838 .open = spufs_info_open,
1839 .read = spufs_proxydma_info_read,
1842 struct tree_descr spufs_dir_contents[] = {
1843 { "mem", &spufs_mem_fops, 0666, },
1844 { "regs", &spufs_regs_fops, 0666, },
1845 { "mbox", &spufs_mbox_fops, 0444, },
1846 { "ibox", &spufs_ibox_fops, 0444, },
1847 { "wbox", &spufs_wbox_fops, 0222, },
1848 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
1849 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
1850 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
1851 { "signal1", &spufs_signal1_fops, 0666, },
1852 { "signal2", &spufs_signal2_fops, 0666, },
1853 { "signal1_type", &spufs_signal1_type, 0666, },
1854 { "signal2_type", &spufs_signal2_type, 0666, },
1855 { "cntl", &spufs_cntl_fops, 0666, },
1856 { "fpcr", &spufs_fpcr_fops, 0666, },
1857 { "lslr", &spufs_lslr_ops, 0444, },
1858 { "mfc", &spufs_mfc_fops, 0666, },
1859 { "mss", &spufs_mss_fops, 0666, },
1860 { "npc", &spufs_npc_ops, 0666, },
1861 { "srr0", &spufs_srr0_ops, 0666, },
1862 { "decr", &spufs_decr_ops, 0666, },
1863 { "decr_status", &spufs_decr_status_ops, 0666, },
1864 { "event_mask", &spufs_event_mask_ops, 0666, },
1865 { "event_status", &spufs_event_status_ops, 0444, },
1866 { "psmap", &spufs_psmap_fops, 0666, },
1867 { "phys-id", &spufs_id_ops, 0666, },
1868 { "object-id", &spufs_object_id_ops, 0666, },
1869 { "mbox_info", &spufs_mbox_info_fops, 0444, },
1870 { "ibox_info", &spufs_ibox_info_fops, 0444, },
1871 { "wbox_info", &spufs_wbox_info_fops, 0444, },
1872 { "dma_info", &spufs_dma_info_fops, 0444, },
1873 { "proxydma_info", &spufs_proxydma_info_fops, 0444, },
1877 struct tree_descr spufs_dir_nosched_contents[] = {
1878 { "mem", &spufs_mem_fops, 0666, },
1879 { "mbox", &spufs_mbox_fops, 0444, },
1880 { "ibox", &spufs_ibox_fops, 0444, },
1881 { "wbox", &spufs_wbox_fops, 0222, },
1882 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
1883 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
1884 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
1885 { "signal1", &spufs_signal1_fops, 0666, },
1886 { "signal2", &spufs_signal2_fops, 0666, },
1887 { "signal1_type", &spufs_signal1_type, 0666, },
1888 { "signal2_type", &spufs_signal2_type, 0666, },
1889 { "mss", &spufs_mss_fops, 0666, },
1890 { "mfc", &spufs_mfc_fops, 0666, },
1891 { "cntl", &spufs_cntl_fops, 0666, },
1892 { "npc", &spufs_npc_ops, 0666, },
1893 { "psmap", &spufs_psmap_fops, 0666, },
1894 { "phys-id", &spufs_id_ops, 0666, },
1895 { "object-id", &spufs_object_id_ops, 0666, },
1899 struct spufs_coredump_reader spufs_coredump_read[] = {
1900 { "regs", __spufs_regs_read, NULL, 128 * 16 },
1901 { "fpcr", __spufs_fpcr_read, NULL, 16 },
1902 { "lslr", NULL, __spufs_lslr_get, 11 },
1903 { "decr", NULL, __spufs_decr_get, 11 },
1904 { "decr_status", NULL, __spufs_decr_status_get, 11 },
1905 { "mem", __spufs_mem_read, NULL, 256 * 1024, },
1906 { "signal1", __spufs_signal1_read, NULL, 4 },
1907 { "signal1_type", NULL, __spufs_signal1_type_get, 2 },
1908 { "signal2", __spufs_signal2_read, NULL, 4 },
1909 { "signal2_type", NULL, __spufs_signal2_type_get, 2 },
1910 { "event_mask", NULL, __spufs_event_mask_get, 8 },
1911 { "event_status", NULL, __spufs_event_status_get, 8 },
1912 { "mbox_info", __spufs_mbox_info_read, NULL, 4 },
1913 { "ibox_info", __spufs_ibox_info_read, NULL, 4 },
1914 { "wbox_info", __spufs_wbox_info_read, NULL, 16 },
1915 { "dma_info", __spufs_dma_info_read, NULL, 69 * 8 },
1916 { "proxydma_info", __spufs_proxydma_info_read, NULL, 35 * 8 },
1917 { "object-id", NULL, __spufs_object_id_get, 19 },
1920 int spufs_coredump_num_notes = ARRAY_SIZE(spufs_coredump_read) - 1;