tools/testing/selftests/powerpc/nx-gzip/gunz_test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/nx-gzip/gunz_test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/nx-gzip/gunz_test.c- Extension
.c- Size
- 28085 bytes
- Lines
- 1029
- 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.hnxu.hnx.hcrb.h
Detected Declarations
function anfunction nx_touch_pages_ddefunction nx_submit_jobfunction decompress_filefunction main
Annotated Snippet
if (total > buf_sz) {
buf_len = NX_MIN(buf_len, total - buf_sz);
nxu_touch_pages((void *)buf_addr, buf_len, page_sz, wr);
NXPRT(fprintf(stderr, "touch loop break len 0x%x ",
buf_len));
NXPRT(fprintf(stderr, "ddead %p\n", (void *)buf_addr));
break;
}
nxu_touch_pages((void *)buf_addr, buf_len, page_sz, wr);
}
return ERR_NX_OK;
}
/*
* Src and dst buffers are supplied in scatter gather lists.
* NX function code and other parameters supplied in cmdp.
*/
static int nx_submit_job(struct nx_dde_t *src, struct nx_dde_t *dst,
struct nx_gzip_crb_cpb_t *cmdp, void *handle)
{
uint64_t csbaddr;
memset((void *)&cmdp->crb.csb, 0, sizeof(cmdp->crb.csb));
cmdp->crb.source_dde = *src;
cmdp->crb.target_dde = *dst;
/* Status, output byte count in tpbc */
csbaddr = ((uint64_t) &cmdp->crb.csb) & csb_address_mask;
put64(cmdp->crb, csb_address, csbaddr);
/* NX reports input bytes in spbc; cleared */
cmdp->cpb.out_spbc_comp_wrap = 0;
cmdp->cpb.out_spbc_comp_with_count = 0;
cmdp->cpb.out_spbc_decomp = 0;
/* Clear output */
put32(cmdp->cpb, out_crc, INIT_CRC);
put32(cmdp->cpb, out_adler, INIT_ADLER);
/* Submit the crb, the job descriptor, to the accelerator. */
return nxu_submit_job(cmdp, handle);
}
int decompress_file(int argc, char **argv, void *devhandle)
{
FILE *inpf = NULL;
FILE *outf = NULL;
int c, expect, i, cc, rc = 0;
char gzfname[FNAME_MAX];
/* Queuing, file ops, byte counting */
char *fifo_in, *fifo_out;
int used_in, cur_in, used_out, cur_out, read_sz, n;
int first_free, last_free, first_used, last_used;
int first_offset, last_offset;
int write_sz, free_space, source_sz;
int source_sz_estimate, target_sz_estimate;
uint64_t last_comp_ratio = 0; /* 1000 max */
uint64_t total_out = 0;
int is_final, is_eof;
/* nx hardware */
int sfbt, subc, spbc, tpbc, nx_ce, fc, resuming = 0;
int history_len = 0;
struct nx_gzip_crb_cpb_t cmd, *cmdp;
struct nx_dde_t *ddl_in;
struct nx_dde_t dde_in[6] __aligned(128);
struct nx_dde_t *ddl_out;
struct nx_dde_t dde_out[6] __aligned(128);
int pgfault_retries;
/* when using mmap'ed files */
off_t input_file_offset;
if (argc > 2) {
fprintf(stderr, "usage: %s <fname> or stdin\n", argv[0]);
fprintf(stderr, " writes to stdout or <fname>.nx.gunzip\n");
return -1;
}
if (argc == 1) {
inpf = stdin;
outf = stdout;
} else if (argc == 2) {
char w[1024];
char *wp;
inpf = fopen(argv[1], "r");
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: `function an`, `function nx_touch_pages_dde`, `function nx_submit_job`, `function decompress_file`, `function main`.
- 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.