arch/powerpc/boot/oflib.c
Source file repositories/reference/linux-study-clean/arch/powerpc/boot/oflib.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/boot/oflib.c- Extension
.c- Size
- 5210 bytes
- Lines
- 220
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stddef.htypes.helf.hstring.hstdio.hpage.hops.hof.h
Detected Declarations
struct prom_argsfunction of_initfunction of_call_promfunction of_call_prom_retfunction string_matchfunction check_of_versionfunction of_claimfunction of_exitfunction of_getpropfunction of_setprop
Annotated Snippet
struct prom_args {
__be32 service; /* Address of service name string. */
__be32 nargs; /* Number of input arguments. */
__be32 nret; /* Number of output arguments. */
__be32 args[10]; /* Input/output arguments. */
};
#ifdef __powerpc64__
extern int prom(void *);
#else
static int (*prom) (void *);
#endif
void of_init(void *promptr)
{
#ifndef __powerpc64__
prom = (int (*)(void *))promptr;
#endif
}
#define ADDR(x) (u32)(unsigned long)(x)
int of_call_prom(const char *service, int nargs, int nret, ...)
{
int i;
struct prom_args args;
va_list list;
args.service = cpu_to_be32(ADDR(service));
args.nargs = cpu_to_be32(nargs);
args.nret = cpu_to_be32(nret);
va_start(list, nret);
for (i = 0; i < nargs; i++)
args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t));
va_end(list);
for (i = 0; i < nret; i++)
args.args[nargs+i] = 0;
if (prom(&args) < 0)
return PROM_ERROR;
return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0;
}
static int of_call_prom_ret(const char *service, int nargs, int nret,
prom_arg_t *rets, ...)
{
int i;
struct prom_args args;
va_list list;
args.service = cpu_to_be32(ADDR(service));
args.nargs = cpu_to_be32(nargs);
args.nret = cpu_to_be32(nret);
va_start(list, rets);
for (i = 0; i < nargs; i++)
args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t));
va_end(list);
for (i = 0; i < nret; i++)
args.args[nargs+i] = 0;
if (prom(&args) < 0)
return PROM_ERROR;
if (rets != NULL)
for (i = 1; i < nret; ++i)
rets[i-1] = be32_to_cpu(args.args[nargs+i]);
return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0;
}
/* returns true if s2 is a prefix of s1 */
static int string_match(const char *s1, const char *s2)
{
for (; *s2; ++s2)
if (*s1++ != *s2)
return 0;
return 1;
}
/*
* Older OF's require that when claiming a specific range of addresses,
* we claim the physical space in the /memory node and the virtual
* space in the chosen mmu node, and then do a map operation to
* map virtual to physical.
*/
Annotation
- Immediate include surface: `stddef.h`, `types.h`, `elf.h`, `string.h`, `stdio.h`, `page.h`, `ops.h`, `of.h`.
- Detected declarations: `struct prom_args`, `function of_init`, `function of_call_prom`, `function of_call_prom_ret`, `function string_match`, `function check_of_version`, `function of_claim`, `function of_exit`, `function of_getprop`, `function of_setprop`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.