tools/testing/selftests/powerpc/nx-gzip/gzip_vas.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/nx-gzip/gzip_vas.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/nx-gzip/gzip_vas.c- Extension
.c- Size
- 6416 bytes
- Lines
- 317
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstring.hunistd.hstdint.hsys/types.hsys/stat.hsys/time.hsys/fcntl.hsys/mman.hendian.hbits/endian.hsys/ioctl.hassert.herrno.hsignal.hvas-api.hnx.hcopy-paste.hnxu.hnx_dbg.hsys/platform/ppc.h
Detected Declarations
struct nx_handlefunction open_device_nodesfunction nx_function_endfunction nx_wait_for_csbfunction nxu_run_jobfunction nxu_submit_jobfunction nxu_sigsegv_handlerfunction nxu_touch_pages
Annotated Snippet
struct nx_handle {
int fd;
int function;
void *paste_addr;
};
static int open_device_nodes(char *devname, int pri, struct nx_handle *handle)
{
int rc, fd;
void *addr;
struct vas_tx_win_open_attr txattr;
fd = open(devname, O_RDWR);
if (fd < 0) {
fprintf(stderr, " open device name %s\n", devname);
return -errno;
}
memset(&txattr, 0, sizeof(txattr));
txattr.version = 1;
txattr.vas_id = pri;
rc = ioctl(fd, VAS_TX_WIN_OPEN, (unsigned long)&txattr);
if (rc < 0) {
fprintf(stderr, "ioctl() n %d, error %d\n", rc, errno);
rc = -errno;
goto out;
}
addr = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0ULL);
if (addr == MAP_FAILED) {
fprintf(stderr, "mmap() failed, errno %d\n", errno);
rc = -errno;
goto out;
}
handle->fd = fd;
handle->paste_addr = (void *)((char *)addr + 0x400);
rc = 0;
out:
close(fd);
return rc;
}
void *nx_function_begin(int function, int pri)
{
int rc;
char *devname = "/dev/crypto/nx-gzip";
struct nx_handle *nxhandle;
if (function != NX_FUNC_COMP_GZIP) {
errno = EINVAL;
fprintf(stderr, " NX_FUNC_COMP_GZIP not found\n");
return NULL;
}
nxhandle = malloc(sizeof(*nxhandle));
if (!nxhandle) {
errno = ENOMEM;
fprintf(stderr, " No memory\n");
return NULL;
}
nxhandle->function = function;
rc = open_device_nodes(devname, pri, nxhandle);
if (rc < 0) {
errno = -rc;
fprintf(stderr, " open_device_nodes failed\n");
return NULL;
}
return nxhandle;
}
int nx_function_end(void *handle)
{
int rc = 0;
struct nx_handle *nxhandle = handle;
rc = munmap(nxhandle->paste_addr - 0x400, 4096);
if (rc < 0) {
fprintf(stderr, "munmap() failed, errno %d\n", errno);
return rc;
}
close(nxhandle->fd);
free(nxhandle);
return rc;
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `string.h`, `unistd.h`, `stdint.h`, `sys/types.h`, `sys/stat.h`, `sys/time.h`.
- Detected declarations: `struct nx_handle`, `function open_device_nodes`, `function nx_function_end`, `function nx_wait_for_csb`, `function nxu_run_job`, `function nxu_submit_job`, `function nxu_sigsegv_handler`, `function nxu_touch_pages`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
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.