tools/testing/selftests/powerpc/alignment/alignment_handler.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/alignment/alignment_handler.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/alignment/alignment_handler.c- Extension
.c- Size
- 16437 bytes
- Lines
- 681
- 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
sys/mman.hsys/types.hsys/stat.hfcntl.hunistd.hstdbool.hstdio.hstdlib.hstring.hassert.hgetopt.hsetjmp.hsignal.hutils.hinstructions.h
Detected Declarations
function sighandlerfunction preload_datafunction test_memcpyfunction dumpdatafunction test_memcmpfunction do_testfunction can_open_cifilefunction test_alignment_handler_vsx_206function test_alignment_handler_vsx_207function test_alignment_handler_vsx_300function test_alignment_handler_vsx_prefixfunction test_alignment_handler_integerfunction test_alignment_handler_integer_206function test_alignment_handler_integer_prefixfunction test_alignment_handler_vmxfunction test_alignment_handler_fpfunction test_alignment_handler_fp_205function test_alignment_handler_fp_206function test_alignment_handler_fp_prefixfunction usagefunction main
Annotated Snippet
if (debug) {
printf("\n Compare failed. Offset:%i length:%i\n",
offset, n);
dumpdata(s1c, s2c, n, test_name);
}
return 1;
}
return 0;
}
/*
* Do two memcpy tests using the same instructions. One cachable
* memory and the other doesn't.
*/
int do_test(char *test_name, void (*test_func)(char *, char *))
{
int offset, width, fd, rc, r;
void *mem0, *mem1, *ci0, *ci1;
printf("\tDoing %s:\t", test_name);
fd = open(cipath, O_RDWR);
if (fd < 0) {
printf("\n");
perror("Can't open ci file now?");
return 1;
}
ci0 = mmap(NULL, bufsize, PROT_WRITE | PROT_READ, MAP_SHARED,
fd, cioffset);
ci1 = mmap(NULL, bufsize, PROT_WRITE | PROT_READ, MAP_SHARED,
fd, cioffset + bufsize);
if ((ci0 == MAP_FAILED) || (ci1 == MAP_FAILED)) {
printf("\n");
perror("mmap failed");
SKIP_IF(1);
}
rc = posix_memalign(&mem0, bufsize, bufsize);
if (rc) {
printf("\n");
return rc;
}
rc = posix_memalign(&mem1, bufsize, bufsize);
if (rc) {
printf("\n");
free(mem0);
return rc;
}
rc = 0;
/*
* offset = 0 is aligned but tests the workaround for the P9N
* DD2.1 vector CI load issue (see 5080332c2c89 "powerpc/64s:
* Add workaround for P9 vector CI load issue")
*/
for (offset = 0; offset < 16; offset++) {
width = 16; /* vsx == 16 bytes */
r = 0;
/* load pattern into memory byte by byte */
preload_data(ci0, offset, width);
preload_data(mem0, offset, width); // FIXME: remove??
memcpy(ci0, mem0, bufsize);
memcpy(ci1, mem1, bufsize); /* initialise output to the same */
/* sanity check */
test_memcmp(mem0, ci0, width, offset, test_name);
r |= test_memcpy(ci1, ci0, width, offset, test_func);
r |= test_memcpy(mem1, mem0, width, offset, test_func);
if (r && !debug) {
printf("FAILED: Got signal");
rc = 1;
break;
}
r |= test_memcmp(mem1, ci1, width, offset, test_name);
if (r && !debug) {
printf("FAILED: Wrong Data");
rc = 1;
break;
}
}
if (rc == 0)
printf("PASSED");
Annotation
- Immediate include surface: `sys/mman.h`, `sys/types.h`, `sys/stat.h`, `fcntl.h`, `unistd.h`, `stdbool.h`, `stdio.h`, `stdlib.h`.
- Detected declarations: `function sighandler`, `function preload_data`, `function test_memcpy`, `function dumpdata`, `function test_memcmp`, `function do_test`, `function can_open_cifile`, `function test_alignment_handler_vsx_206`, `function test_alignment_handler_vsx_207`, `function test_alignment_handler_vsx_300`.
- 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.