arch/sparc/prom/tree_64.c

Source file repositories/reference/linux-study-clean/arch/sparc/prom/tree_64.c

File Facts

System
Linux kernel
Corpus path
arch/sparc/prom/tree_64.c
Extension
.c
Size
8143 bytes
Lines
394
Domain
Architecture Layer
Bucket
arch/sparc
Inferred role
Architecture Layer: exported/initcall integration point
Status
integration 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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/*
 * tree.c: Basic device tree traversal/scanning for the Linux
 *         prom library.
 *
 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
 * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
 */

#include <linux/string.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/module.h>

#include <asm/openprom.h>
#include <asm/oplib.h>
#include <asm/ldc.h>

static phandle prom_node_to_node(const char *type, phandle node)
{
	unsigned long args[5];

	args[0] = (unsigned long) type;
	args[1] = 1;
	args[2] = 1;
	args[3] = (unsigned int) node;
	args[4] = (unsigned long) -1;

	p1275_cmd_direct(args);

	return (phandle) args[4];
}

/* Return the child of node 'node' or zero if no this node has no
 * direct descendent.
 */
inline phandle __prom_getchild(phandle node)
{
	return prom_node_to_node("child", node);
}

phandle prom_getchild(phandle node)
{
	phandle cnode;

	if ((s32)node == -1)
		return 0;
	cnode = __prom_getchild(node);
	if ((s32)cnode == -1)
		return 0;
	return cnode;
}
EXPORT_SYMBOL(prom_getchild);

inline phandle prom_getparent(phandle node)
{
	phandle cnode;

	if ((s32)node == -1)
		return 0;
	cnode = prom_node_to_node("parent", node);
	if ((s32)cnode == -1)
		return 0;
	return cnode;
}

/* Return the next sibling of node 'node' or zero if no more siblings
 * at this level of depth in the tree.
 */
inline phandle __prom_getsibling(phandle node)
{
	return prom_node_to_node(prom_peer_name, node);
}

phandle prom_getsibling(phandle node)
{
	phandle sibnode;

	if ((s32)node == -1)
		return 0;
	sibnode = __prom_getsibling(node);
	if ((s32)sibnode == -1)
		return 0;

	return sibnode;
}
EXPORT_SYMBOL(prom_getsibling);

/* Return the length in bytes of property 'prop' at node 'node'.

Annotation

Implementation Notes