arch/s390/hypfs/hypfs_diag.c

Source file repositories/reference/linux-study-clean/arch/s390/hypfs/hypfs_diag.c

File Facts

System
Linux kernel
Corpus path
arch/s390/hypfs/hypfs_diag.c
Extension
.c
Size
5759 bytes
Lines
225
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: implementation source
Status
source 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

struct dbfs_d204_hdr {
	u64	len;		/* Length of d204 buffer without header */
	u16	version;	/* Version of header */
	u8	sc;		/* Used subcode */
	char	reserved[53];
} __attribute__ ((packed));

struct dbfs_d204 {
	struct dbfs_d204_hdr	hdr;	/* 64 byte header */
	char			buf[];	/* d204 buffer */
} __attribute__ ((packed));

static int dbfs_d204_create(void **data, void **data_free_ptr, size_t *size)
{
	struct dbfs_d204 *d204;
	int rc, buf_size;
	void *base;

	buf_size = PAGE_SIZE * (diag204_buf_pages + 1) + sizeof(d204->hdr);
	base = vzalloc(buf_size);
	if (!base)
		return -ENOMEM;
	d204 = PTR_ALIGN(base + sizeof(d204->hdr), PAGE_SIZE) - sizeof(d204->hdr);
	rc = diag204_store(d204->buf, diag204_buf_pages);
	if (rc) {
		vfree(base);
		return rc;
	}
	d204->hdr.version = DBFS_D204_HDR_VERSION;
	d204->hdr.len = PAGE_SIZE * diag204_buf_pages;
	d204->hdr.sc = diag204_store_sc;
	*data = d204;
	*data_free_ptr = base;
	*size = d204->hdr.len + sizeof(struct dbfs_d204_hdr);
	return 0;
}

static struct hypfs_dbfs_file dbfs_file_d204 = {
	.name		= "diag_204",
	.data_create	= dbfs_d204_create,
	.data_free	= vfree,
};

__init int hypfs_diag_init(void)
{
	int rc;

	if (diag204_probe()) {
		pr_info("The hardware system does not support hypfs\n");
		return -ENODATA;
	}

	if (diag204_get_info_type() == DIAG204_INFO_EXT)
		hypfs_dbfs_create_file(&dbfs_file_d204);

	rc = hypfs_diag_fs_init();
	if (rc)
		pr_err("The hardware system does not provide all functions required by hypfs\n");
	return rc;
}

void hypfs_diag_exit(void)
{
	hypfs_diag_fs_exit();
	diag204_free_buffer();
	hypfs_dbfs_remove_file(&dbfs_file_d204);
}

Annotation

Implementation Notes