drivers/misc/kgdbts.c

Source file repositories/reference/linux-study-clean/drivers/misc/kgdbts.c

File Facts

System
Linux kernel
Corpus path
drivers/misc/kgdbts.c
Extension
.c
Size
31377 bytes
Lines
1193
Domain
Driver Families
Bucket
drivers/misc
Inferred role
Driver Families: exported/initcall integration point
Status
integration implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

device_initcall(init_kgdbts);

static int kgdbts_get_char(void)
{
	int val = 0;

	if (ts.run_test)
		val = ts.run_test(1, 0);

	return val;
}

static void kgdbts_put_char(u8 chr)
{
	if (ts.run_test)
		ts.run_test(0, chr);
}

static int param_set_kgdbts_var(const char *kmessage,
				const struct kernel_param *kp)
{
	size_t len = strlen(kmessage);

	if (len >= MAX_CONFIG_LEN) {
		printk(KERN_ERR "kgdbts: config string too long\n");
		return -ENOSPC;
	}

	/* Only copy in the string if the init function has not run yet */
	if (configured < 0) {
		strcpy(config, kmessage);
		return 0;
	}

	if (configured == 1) {
		printk(KERN_ERR "kgdbts: ERROR: Already configured and running.\n");
		return -EBUSY;
	}

	strcpy(config, kmessage);
	/* Chop out \n char as a result of echo */
	if (len && config[len - 1] == '\n')
		config[len - 1] = '\0';

	/* Go and configure with the new params. */
	return configure_kgdbts();
}

static void kgdbts_pre_exp_handler(void)
{
	/* Increment the module count when the debugger is active */
	if (!kgdb_connected)
		try_module_get(THIS_MODULE);
}

static void kgdbts_post_exp_handler(void)
{
	/* decrement the module count when the debugger detaches */
	if (!kgdb_connected)
		module_put(THIS_MODULE);
}

static struct kgdb_io kgdbts_io_ops = {
	.name			= "kgdbts",
	.read_char		= kgdbts_get_char,
	.write_char		= kgdbts_put_char,
	.pre_exception		= kgdbts_pre_exp_handler,
	.post_exception		= kgdbts_post_exp_handler,
};

/*
 * not really modular, but the easiest way to keep compat with existing
 * bootargs behaviour is to continue using module_param here.
 */
module_param_call(kgdbts, param_set_kgdbts_var, param_get_string, &kps, 0644);
MODULE_PARM_DESC(kgdbts, "<A|V1|V2>[F#|S#][N#]");

Annotation

Implementation Notes