arch/powerpc/platforms/cell/spufs/file.c
Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/cell/spufs/file.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/platforms/cell/spufs/file.c- Extension
.c- Size
- 62087 bytes
- Lines
- 2605
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/coredump.hlinux/fs.hlinux/ioctl.hlinux/export.hlinux/pagemap.hlinux/poll.hlinux/ptrace.hlinux/seq_file.hlinux/slab.hasm/io.hasm/time.hasm/spu.hasm/spu_info.hlinux/uaccess.hspufs.hsputrace.h
Detected Declarations
struct spufs_attrfunction spufs_attr_openfunction spufs_attr_releasefunction spufs_attr_readfunction spufs_attr_writefunction spufs_dump_emitfunction spufs_mem_openfunction spufs_mem_releasefunction spufs_mem_dumpfunction spufs_mem_readfunction spufs_mem_writefunction spufs_mem_mmap_faultfunction spufs_mem_mmap_accessfunction spufs_mem_mmapfunction spufs_ps_faultfunction spufs_cntl_mmap_faultfunction spufs_cntl_mmapfunction spufs_cntl_getfunction spufs_cntl_setfunction spufs_cntl_openfunction spufs_cntl_releasefunction spufs_regs_openfunction spufs_regs_dumpfunction spufs_regs_readfunction spufs_regs_writefunction spufs_fpcr_dumpfunction spufs_fpcr_readfunction spufs_fpcr_writefunction spufs_pipe_openfunction spufs_mbox_readfunction spufs_mbox_stat_readfunction spu_ibox_readfunction spufs_ibox_callbackfunction spufs_ibox_readfunction spufs_ibox_pollfunction spufs_ibox_stat_readfunction spu_wbox_writefunction spufs_wbox_callbackfunction spufs_wbox_writefunction spufs_wbox_pollfunction spufs_wbox_stat_readfunction spufs_signal1_openfunction spufs_signal1_releasefunction spufs_signal1_dumpfunction __spufs_signal1_readfunction spufs_signal1_readfunction spufs_signal1_writefunction spufs_signal1_mmap_fault
Annotated Snippet
static const struct file_operations __fops = { \
.open = __fops ## _open, \
.release = spufs_attr_release, \
.read = spufs_attr_read, \
.write = spufs_attr_write, \
.llseek = generic_file_llseek, \
};
static int
spufs_mem_open(struct inode *inode, struct file *file)
{
struct spufs_inode_info *i = SPUFS_I(inode);
struct spu_context *ctx = i->i_ctx;
mutex_lock(&ctx->mapping_lock);
file->private_data = ctx;
if (!i->i_openers++)
ctx->local_store = inode->i_mapping;
mutex_unlock(&ctx->mapping_lock);
return 0;
}
static int
spufs_mem_release(struct inode *inode, struct file *file)
{
struct spufs_inode_info *i = SPUFS_I(inode);
struct spu_context *ctx = i->i_ctx;
mutex_lock(&ctx->mapping_lock);
if (!--i->i_openers)
ctx->local_store = NULL;
mutex_unlock(&ctx->mapping_lock);
return 0;
}
static ssize_t
spufs_mem_dump(struct spu_context *ctx, struct coredump_params *cprm)
{
return spufs_dump_emit(cprm, ctx->ops->get_ls(ctx), LS_SIZE);
}
static ssize_t
spufs_mem_read(struct file *file, char __user *buffer,
size_t size, loff_t *pos)
{
struct spu_context *ctx = file->private_data;
ssize_t ret;
ret = spu_acquire(ctx);
if (ret)
return ret;
ret = simple_read_from_buffer(buffer, size, pos, ctx->ops->get_ls(ctx),
LS_SIZE);
spu_release(ctx);
return ret;
}
static ssize_t
spufs_mem_write(struct file *file, const char __user *buffer,
size_t size, loff_t *ppos)
{
struct spu_context *ctx = file->private_data;
char *local_store;
loff_t pos = *ppos;
int ret;
if (pos > LS_SIZE)
return -EFBIG;
ret = spu_acquire(ctx);
if (ret)
return ret;
local_store = ctx->ops->get_ls(ctx);
size = simple_write_to_buffer(local_store, LS_SIZE, ppos, buffer, size);
spu_release(ctx);
return size;
}
static vm_fault_t
spufs_mem_mmap_fault(struct vm_fault *vmf)
{
struct vm_area_struct *vma = vmf->vma;
struct spu_context *ctx = vma->vm_file->private_data;
unsigned long pfn, offset;
vm_fault_t ret;
Annotation
- Immediate include surface: `linux/coredump.h`, `linux/fs.h`, `linux/ioctl.h`, `linux/export.h`, `linux/pagemap.h`, `linux/poll.h`, `linux/ptrace.h`, `linux/seq_file.h`.
- Detected declarations: `struct spufs_attr`, `function spufs_attr_open`, `function spufs_attr_release`, `function spufs_attr_read`, `function spufs_attr_write`, `function spufs_dump_emit`, `function spufs_mem_open`, `function spufs_mem_release`, `function spufs_mem_dump`, `function spufs_mem_read`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.