tools/testing/selftests/sparc64/drivers/adi-test.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/sparc64/drivers/adi-test.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/sparc64/drivers/adi-test.c- Extension
.c- Size
- 16592 bytes
- Lines
- 718
- 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
linux/kernel.herrno.hfcntl.hstdarg.hstdio.hstdlib.hstring.hsys/syscall.hsys/types.hsys/stat.hunistd.hkselftest.h
Detected Declarations
struct statsfunction debug_printfunction volatilefunction update_statsfunction print_ustatsfunction print_statsfunction build_memory_mapfunction read_adifunction pread_adifunction write_adifunction pwrite_adifunction seek_adifunction test0_prpw_aligned_1bytefunction test1_prpw_aligned_4096bytesfunction test2_prpw_aligned_10327bytesfunction test3_prpw_unaligned_12541bytesfunction test4_lseekfunction test5_rw_aligned_1bytefunction test6_rw_aligned_9434bytesfunction test7_rw_aligned_14963bytesfunction main
Annotated Snippet
struct stats {
char name[16];
unsigned long total;
unsigned long count;
unsigned long bytes;
};
static struct stats read_stats = {
.name = "read", .total = 0, .count = 0, .bytes = 0};
static struct stats pread_stats = {
.name = "pread", .total = 0, .count = 0, .bytes = 0};
static struct stats write_stats = {
.name = "write", .total = 0, .count = 0, .bytes = 0};
static struct stats pwrite_stats = {
.name = "pwrite", .total = 0, .count = 0, .bytes = 0};
static struct stats seek_stats = {
.name = "seek", .total = 0, .count = 0, .bytes = 0};
static void update_stats(struct stats * const ustats,
unsigned long measurement, unsigned long bytes)
{
ustats->total += measurement;
ustats->bytes += bytes;
ustats->count++;
}
static void print_ustats(const struct stats * const ustats)
{
DEBUG_PRINT_L1("%s\t%7d\t%7.0f\t%7.0f\n",
ustats->name, ustats->count,
(float)ustats->total / (float)ustats->count,
(float)ustats->bytes / (float)ustats->count);
}
static void print_stats(void)
{
DEBUG_PRINT_L1("\nSyscall\tCall\tAvgTime\tAvgSize\n"
"\tCount\t(ticks)\t(bytes)\n"
"-------------------------------\n");
print_ustats(&read_stats);
print_ustats(&pread_stats);
print_ustats(&write_stats);
print_ustats(&pwrite_stats);
print_ustats(&seek_stats);
}
static int build_memory_map(void)
{
char line[256];
FILE *fp;
int i;
range_count = 0;
fp = fopen("/proc/iomem", "r");
if (!fp) {
fprintf(stderr, "/proc/iomem: error %d: %s\n",
errno, strerror(errno));
return -errno;
}
while (fgets(line, sizeof(line), fp) != 0) {
if (strstr(line, system_ram_str)) {
char *dash, *end_ptr;
/* Given a line like this:
* d0400000-10ffaffff : System RAM
* replace the "-" with a space
*/
dash = strstr(line, "-");
dash[0] = 0x20;
start_addr[range_count] = strtoull(line, &end_ptr, 16);
end_addr[range_count] = strtoull(end_ptr, NULL, 16);
range_count++;
}
}
fclose(fp);
DEBUG_PRINT_L1("RAM Ranges\n");
for (i = 0; i < range_count; i++)
DEBUG_PRINT_L1("\trange %d: 0x%llx\t- 0x%llx\n",
i, start_addr[i], end_addr[i]);
if (range_count == 0) {
fprintf(stderr, "No valid address ranges found. Error.\n");
return -1;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `errno.h`, `fcntl.h`, `stdarg.h`, `stdio.h`, `stdlib.h`, `string.h`, `sys/syscall.h`.
- Detected declarations: `struct stats`, `function debug_print`, `function volatile`, `function update_stats`, `function print_ustats`, `function print_stats`, `function build_memory_map`, `function read_adi`, `function pread_adi`, `function write_adi`.
- 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.