arch/powerpc/xmon/xmon.c

Source file repositories/reference/linux-study-clean/arch/powerpc/xmon/xmon.c

File Facts

System
Linux kernel
Corpus path
arch/powerpc/xmon/xmon.c
Extension
.c
Size
88178 bytes
Lines
4093
Domain
Architecture Layer
Bucket
arch/powerpc
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

device_initcall(setup_xmon_sysrq);
#endif /* CONFIG_MAGIC_SYSRQ */

static void clear_all_bpt(void)
{
	int i;

	/* clear/unpatch all breakpoints */
	remove_bpts();
	remove_cpu_bpts();

	/* Disable all breakpoints */
	for (i = 0; i < NBPTS; ++i)
		bpts[i].enabled = 0;

	/* Clear any data or iabr breakpoints */
	iabr = NULL;
	for (i = 0; i < nr_wp_slots(); i++)
		dabr[i].enabled = 0;
}

#ifdef CONFIG_DEBUG_FS
static int xmon_dbgfs_set(void *data, u64 val)
{
	xmon_on = !!val;
	xmon_init(xmon_on);

	/* make sure all breakpoints removed when disabling */
	if (!xmon_on) {
		clear_all_bpt();
		get_output_lock();
		printf("xmon: All breakpoints cleared\n");
		release_output_lock();
	}

	return 0;
}

static int xmon_dbgfs_get(void *data, u64 *val)
{
	*val = xmon_on;
	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(xmon_dbgfs_ops, xmon_dbgfs_get,
			xmon_dbgfs_set, "%llu\n");

static int __init setup_xmon_dbgfs(void)
{
	debugfs_create_file("xmon", 0600, arch_debugfs_dir, NULL,
			    &xmon_dbgfs_ops);
	return 0;
}
device_initcall(setup_xmon_dbgfs);
#endif /* CONFIG_DEBUG_FS */

static int xmon_early __initdata;

static int __init early_parse_xmon(char *p)
{
	if (xmon_is_locked_down()) {
		xmon_init(0);
		xmon_early = 0;
		xmon_on = 0;
	} else if (!p || strncmp(p, "early", 5) == 0) {
		/* just "xmon" is equivalent to "xmon=early" */
		xmon_init(1);
		xmon_early = 1;
		xmon_on = 1;
	} else if (strncmp(p, "on", 2) == 0) {
		xmon_init(1);
		xmon_on = 1;
	} else if (strncmp(p, "rw", 2) == 0) {
		xmon_init(1);
		xmon_on = 1;
		xmon_is_ro = false;
	} else if (strncmp(p, "ro", 2) == 0) {
		xmon_init(1);
		xmon_on = 1;
		xmon_is_ro = true;
	} else if (strncmp(p, "off", 3) == 0)
		xmon_on = 0;
	else
		return 1;

	return 0;
}
early_param("xmon", early_parse_xmon);

void __init xmon_setup(void)

Annotation

Implementation Notes