arch/powerpc/boot/planetcore.c
Source file repositories/reference/linux-study-clean/arch/powerpc/boot/planetcore.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/boot/planetcore.c- Extension
.c- Size
- 2554 bytes
- Lines
- 131
- 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.
Dependency Surface
stdio.hstdlib.hops.hplanetcore.hio.h
Detected Declarations
function Copyrightfunction planetcore_get_decimalfunction planetcore_get_hexfunction planetcore_set_mac_addrsfunction planetcore_set_stdout_path
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* PlanetCore configuration data support functions
*
* Author: Scott Wood <scottwood@freescale.com>
*
* Copyright (c) 2007 Freescale Semiconductor, Inc.
*/
#include "stdio.h"
#include "stdlib.h"
#include "ops.h"
#include "planetcore.h"
#include "io.h"
/* PlanetCore passes information to the OS in the form of
* a table of key=value strings, separated by newlines.
*
* The list is terminated by an empty string (i.e. two
* consecutive newlines).
*
* To make it easier to parse, we first convert all the
* newlines into null bytes.
*/
void planetcore_prepare_table(char *table)
{
do {
if (*table == '\n')
*table = 0;
table++;
} while (*(table - 1) || *table != '\n');
*table = 0;
}
const char *planetcore_get_key(const char *table, const char *key)
{
int keylen = strlen(key);
do {
if (!strncmp(table, key, keylen) && table[keylen] == '=')
return table + keylen + 1;
table += strlen(table) + 1;
} while (strlen(table) != 0);
return NULL;
}
int planetcore_get_decimal(const char *table, const char *key, u64 *val)
{
const char *str = planetcore_get_key(table, key);
if (!str)
return 0;
*val = strtoull(str, NULL, 10);
return 1;
}
int planetcore_get_hex(const char *table, const char *key, u64 *val)
{
const char *str = planetcore_get_key(table, key);
if (!str)
return 0;
*val = strtoull(str, NULL, 16);
return 1;
}
static u64 mac_table[4] = {
0x000000000000,
0x000000800000,
0x000000400000,
0x000000c00000,
};
void planetcore_set_mac_addrs(const char *table)
{
u8 addr[4][6];
u64 int_addr;
u32 i;
int j;
if (!planetcore_get_hex(table, PLANETCORE_KEY_MAC_ADDR, &int_addr))
return;
for (i = 0; i < 4; i++) {
u64 this_dev_addr = (int_addr & ~0x000000c00000) |
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `ops.h`, `planetcore.h`, `io.h`.
- Detected declarations: `function Copyright`, `function planetcore_get_decimal`, `function planetcore_get_hex`, `function planetcore_set_mac_addrs`, `function planetcore_set_stdout_path`.
- 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.