aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDwayne Grant McConnell <decimal@us.ibm.com>2006-11-20 12:45:00 -0500
committerPaul Mackerras <paulus@samba.org>2006-12-04 04:39:49 -0500
commit69a2f00ce5d3a19a70b36f08eaf9049677277710 (patch)
tree8da40441803740458e3f25cf053004bfd7944b95 /arch
parent1182e1d351d2a910bc0fb53c00277c62235333de (diff)
[POWERPC] spufs: Implement /mbox_info, /ibox_info, and /wbox_info.
This patch implements read only access to /mbox_info - SPU Write Outbound Mailbox /ibox_info - SPU Write Outbound Interrupt Mailbox /wbox_info - SPU Read Inbound Mailbox These files are used by gdb in order to look into the current mailbox queues without changing the contents at the same time. They are not meant for general programming use, since the access requires a context save and is therefore rather slow. It would be good to complement this patch with one that adds write support as well. Signed-off-by: Dwayne Grant McConnell <decimal@us.ibm.com> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 20b2a7aed63e..2a2dd6441010 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -1552,6 +1552,93 @@ static int spufs_info_open(struct inode *inode, struct file *file)
1552 return 0; 1552 return 0;
1553} 1553}
1554 1554
1555static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
1556 size_t len, loff_t *pos)
1557{
1558 struct spu_context *ctx = file->private_data;
1559 u32 mbox_stat;
1560 u32 data;
1561
1562 if (!access_ok(VERIFY_WRITE, buf, len))
1563 return -EFAULT;
1564
1565 spu_acquire_saved(ctx);
1566 spin_lock(&ctx->csa.register_lock);
1567 mbox_stat = ctx->csa.prob.mb_stat_R;
1568 if (mbox_stat & 0x0000ff) {
1569 data = ctx->csa.prob.pu_mb_R;
1570 }
1571 spin_unlock(&ctx->csa.register_lock);
1572 spu_release(ctx);
1573
1574 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1575}
1576
1577static struct file_operations spufs_mbox_info_fops = {
1578 .open = spufs_info_open,
1579 .read = spufs_mbox_info_read,
1580 .llseek = generic_file_llseek,
1581};
1582
1583static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
1584 size_t len, loff_t *pos)
1585{
1586 struct spu_context *ctx = file->private_data;
1587 u32 ibox_stat;
1588 u32 data;
1589
1590 if (!access_ok(VERIFY_WRITE, buf, len))
1591 return -EFAULT;
1592
1593 spu_acquire_saved(ctx);
1594 spin_lock(&ctx->csa.register_lock);
1595 ibox_stat = ctx->csa.prob.mb_stat_R;
1596 if (ibox_stat & 0xff0000) {
1597 data = ctx->csa.priv2.puint_mb_R;
1598 }
1599 spin_unlock(&ctx->csa.register_lock);
1600 spu_release(ctx);
1601
1602 return simple_read_from_buffer(buf, len, pos, &data, sizeof data);
1603}
1604
1605static struct file_operations spufs_ibox_info_fops = {
1606 .open = spufs_info_open,
1607 .read = spufs_ibox_info_read,
1608 .llseek = generic_file_llseek,
1609};
1610
1611static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
1612 size_t len, loff_t *pos)
1613{
1614 struct spu_context *ctx = file->private_data;
1615 int i, cnt;
1616 u32 data[4];
1617 u32 wbox_stat;
1618
1619 if (!access_ok(VERIFY_WRITE, buf, len))
1620 return -EFAULT;
1621
1622 spu_acquire_saved(ctx);
1623 spin_lock(&ctx->csa.register_lock);
1624 wbox_stat = ctx->csa.prob.mb_stat_R;
1625 cnt = (wbox_stat & 0x00ff00) >> 8;
1626 for (i = 0; i < cnt; i++) {
1627 data[i] = ctx->csa.spu_mailbox_data[i];
1628 }
1629 spin_unlock(&ctx->csa.register_lock);
1630 spu_release(ctx);
1631
1632 return simple_read_from_buffer(buf, len, pos, &data,
1633 cnt * sizeof(u32));
1634}
1635
1636static struct file_operations spufs_wbox_info_fops = {
1637 .open = spufs_info_open,
1638 .read = spufs_wbox_info_read,
1639 .llseek = generic_file_llseek,
1640};
1641
1555static ssize_t spufs_dma_info_read(struct file *file, char __user *buf, 1642static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
1556 size_t len, loff_t *pos) 1643 size_t len, loff_t *pos)
1557{ 1644{
@@ -1661,6 +1748,9 @@ struct tree_descr spufs_dir_contents[] = {
1661 { "psmap", &spufs_psmap_fops, 0666, }, 1748 { "psmap", &spufs_psmap_fops, 0666, },
1662 { "phys-id", &spufs_id_ops, 0666, }, 1749 { "phys-id", &spufs_id_ops, 0666, },
1663 { "object-id", &spufs_object_id_ops, 0666, }, 1750 { "object-id", &spufs_object_id_ops, 0666, },
1751 { "mbox_info", &spufs_mbox_info_fops, 0444, },
1752 { "ibox_info", &spufs_ibox_info_fops, 0444, },
1753 { "wbox_info", &spufs_wbox_info_fops, 0444, },
1664 { "dma_info", &spufs_dma_info_fops, 0444, }, 1754 { "dma_info", &spufs_dma_info_fops, 0444, },
1665 { "proxydma_info", &spufs_proxydma_info_fops, 0444, }, 1755 { "proxydma_info", &spufs_proxydma_info_fops, 0444, },
1666 {}, 1756 {},