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.

Dependency Surface

Detected Declarations

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

Implementation Notes