arch/s390/kernel/debug.c

Source file repositories/reference/linux-study-clean/arch/s390/kernel/debug.c

File Facts

System
Linux kernel
Corpus path
arch/s390/kernel/debug.c
Extension
.c
Size
46434 bytes
Lines
1834
Domain
Architecture Layer
Bucket
arch/s390
Inferred role
Architecture Layer: operation-table or driver-model contract
Status
pattern 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

static const struct file_operations debug_file_ops = {
	.owner	 = THIS_MODULE,
	.read	 = debug_output,
	.write	 = debug_input,
	.open	 = debug_open,
	.release = debug_close,
};

static struct dentry *debug_debugfs_root_entry;

/* List of debug area parameters to override */
#define PARAM_UNSET	-2
#define PARAM_NUM	16
static struct debug_param_t {
	char name[DEBUG_MAX_NAME_LEN + 1];
	int level;
	int pages;
} debug_param[PARAM_NUM];
static int debug_param_num;

/* functions */
static void debug_get_param(const char *name, int *level, int *pages)
{
	struct debug_param_t *p;
	int i;

	for (i = 0; i < debug_param_num; i++) {
		p = &debug_param[i];
		if (!glob_match(p->name, name))
			continue;
		if (level && p->level != PARAM_UNSET) {
			pr_info("%s: override level to %d\n", name, p->level);
			*level = p->level;
		}
		if (pages && p->pages != PARAM_UNSET) {
			pr_info("%s: override pages to %d\n", name, p->pages);
			*pages = p->pages;
		}
	}
}

#define LVL_LEN		10
#define LVL_FMT		"%" __stringify(LVL_LEN) "[^:]"
#define NAME_FMT	"%" __stringify(DEBUG_MAX_NAME_LEN) "[^:]"

static bool __init s390dbf_parse_one(const char *arg, struct debug_param_t *param)
{
	struct debug_param_t p = { { 0 }, PARAM_UNSET, PARAM_UNSET };
	char level[LVL_LEN + 1] = { 0 };

	/* arg: <name|pattern>:[<level>|-]:[<pages>] */
	if (sscanf(arg, NAME_FMT ":" LVL_FMT ":%d", p.name, level, &p.pages) > 1) {
		if (strcmp(level, "-") == 0)
			p.level = DEBUG_OFF_LEVEL;
		else if (kstrtoint(level, 0, &p.level) != 0)
			return false;
	} else if (sscanf(arg, NAME_FMT "::%d", p.name, &p.pages) != 2) {
		return false;
	}

	if (p.level != PARAM_UNSET && p.level != DEBUG_OFF_LEVEL &&
	    (p.level < 0 || p.level > DEBUG_MAX_LEVEL))
		return false;
	if (p.pages != PARAM_UNSET && p.pages < 0)
		return false;
	*param = p;

	return true;
}

static int __init s390dbf_parse(char *arg)
{
	debug_info_t **id;
	int i, rc = 0;

	while (arg && debug_param_num < PARAM_NUM) {
		if (s390dbf_parse_one(arg, &debug_param[debug_param_num]))
			debug_param_num++;
		else
			rc = -EINVAL;
		arg = strchr(arg, ',');
		if (arg)
			arg++;
	}

	/*
	 * Apply level to static debug areas, delay buffer size changes until
	 * regular memory allocations are possible.
	 */
	for (i = 0, id = __s390dbf_info; &id[i] < __s390dbf_info_end; i++)

Annotation

Implementation Notes