tools/testing/selftests/powerpc/syscalls/rtas_filter.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/syscalls/rtas_filter.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/syscalls/rtas_filter.c- Extension
.c- Size
- 5557 bytes
- Lines
- 225
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: syscall or user/kernel boundary
- Status
- core 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 participates in a user/kernel boundary; inspect argument validation, copy_from_user/copy_to_user, credentials, and dispatch target.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
byteswap.hstdint.hinttypes.hlinux/limits.hstdio.hstring.hsys/syscall.hsys/types.hunistd.hstdarg.hstdlib.hfcntl.herrno.hutils.h
Detected Declarations
struct rtas_argsstruct regionfunction get_propertyfunction rtas_tokenfunction read_kregion_boundsfunction rtas_callfunction testfunction main
Annotated Snippet
struct rtas_args {
__be32 token;
__be32 nargs;
__be32 nret;
__be32 args[16];
__be32 *rets; /* Pointer to return values in args[]. */
};
struct region {
uint64_t addr;
uint32_t size;
struct region *next;
};
static int get_property(const char *prop_path, const char *prop_name,
char **prop_val, size_t *prop_len)
{
char path[PATH_MAX];
int len = snprintf(path, sizeof(path), "%s/%s", prop_path, prop_name);
if (len < 0 || len >= sizeof(path))
return -ENOMEM;
return read_file_alloc(path, prop_val, prop_len);
}
int rtas_token(const char *call_name)
{
char *prop_buf = NULL;
size_t len;
int rc;
rc = get_property(ofdt_rtas_path, call_name, &prop_buf, &len);
if (rc < 0) {
rc = RTAS_UNKNOWN_OP;
goto err;
}
rc = be32_to_cpu(*(int *)prop_buf);
err:
free(prop_buf);
return rc;
}
static int read_kregion_bounds(struct region *kregion)
{
char *buf;
int err;
err = read_file_alloc("/proc/ppc64/rtas/rmo_buffer", &buf, NULL);
if (err) {
perror("Could not open rmo_buffer file");
return RTAS_IO_ASSERT;
}
sscanf(buf, "%" SCNx64 " %x", &kregion->addr, &kregion->size);
free(buf);
if (!(kregion->size && kregion->addr) ||
(kregion->size > (PAGE_SIZE * MAX_PAGES))) {
printf("Unexpected kregion bounds\n");
return RTAS_IO_ASSERT;
}
return 0;
}
static int rtas_call(const char *name, int nargs,
int nrets, ...)
{
struct rtas_args args;
__be32 *rets[16];
int i, rc, token;
va_list ap;
va_start(ap, nrets);
token = rtas_token(name);
if (token == RTAS_UNKNOWN_OP) {
// We don't care if the call doesn't exist
printf("call '%s' not available, skipping...", name);
rc = RTAS_UNKNOWN_OP;
goto err;
}
args.token = cpu_to_be32(token);
args.nargs = cpu_to_be32(nargs);
args.nret = cpu_to_be32(nrets);
Annotation
- Immediate include surface: `byteswap.h`, `stdint.h`, `inttypes.h`, `linux/limits.h`, `stdio.h`, `string.h`, `sys/syscall.h`, `sys/types.h`.
- Detected declarations: `struct rtas_args`, `struct region`, `function get_property`, `function rtas_token`, `function read_kregion_bounds`, `function rtas_call`, `function test`, `function main`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: core 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.