arch/powerpc/platforms/powermac/udbg_adb.c

Source file repositories/reference/linux-study-clean/arch/powerpc/platforms/powermac/udbg_adb.c

File Facts

System
Linux kernel
Corpus path
arch/powerpc/platforms/powermac/udbg_adb.c
Extension
.c
Size
5121 bytes
Lines
221
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.

Dependency Surface

Detected Declarations

Annotated Snippet

if (--t < 0) {
				on = 1 - on;
				btext_drawchar(on? 0xdb: 0x20);
				btext_drawchar('\b');
				t = 200000;
			}
			udbg_adb_poll();
			if (udbg_adb_old_getc_poll)
				k = udbg_adb_old_getc_poll();
		} while (k == -1 && xmon_adb_keycode == -1);
		if (on)
			btext_drawstring(" \b");
		if (k != -1)
			return k;
		k = xmon_adb_keycode;

		/* test for shift keys */
		if ((k & 0x7f) == 0x38 || (k & 0x7f) == 0x7b) {
			xmon_adb_shiftstate = (k & 0x80) == 0;
			continue;
		}
		if (k >= 0x80)
			continue;	/* ignore up transitions */
		k = (xmon_adb_shiftstate? xmon_shift_keytab: xmon_keytab)[k];
		if (k != 0)
			break;
	}
	xmon_wants_key = 0;
	return k;
}
#endif /* CONFIG_BOOTX_TEXT */

static int udbg_adb_getc(void)
{
#ifdef CONFIG_BOOTX_TEXT
	if (udbg_adb_use_btext && input_type != input_adb_none)
		return udbg_adb_local_getc();
#endif
	if (udbg_adb_old_getc)
		return udbg_adb_old_getc();
	return -1;
}

/* getc_poll() is not really used, unless you have the xmon-over modem
 * hack that doesn't quite concern us here, thus we just poll the low level
 * ADB driver to prevent it from timing out and call back the original poll
 * routine.
 */
static int udbg_adb_getc_poll(void)
{
	udbg_adb_poll();

	if (udbg_adb_old_getc_poll)
		return udbg_adb_old_getc_poll();
	return -1;
}

static void udbg_adb_putc(char c)
{
#ifdef CONFIG_BOOTX_TEXT
	if (udbg_adb_use_btext)
		btext_drawchar(c);
#endif
	if (udbg_adb_old_putc)
		return udbg_adb_old_putc(c);
}

void __init udbg_adb_init_early(void)
{
#ifdef CONFIG_BOOTX_TEXT
	if (btext_find_display(1) == 0) {
		udbg_adb_use_btext = 1;
		udbg_putc = udbg_adb_putc;
	}
#endif
}

int __init udbg_adb_init(int force_btext)
{
	struct device_node *np;

	/* Capture existing callbacks */
	udbg_adb_old_putc = udbg_putc;
	udbg_adb_old_getc = udbg_getc;
	udbg_adb_old_getc_poll = udbg_getc_poll;

	/* Check if our early init was already called */
	if (udbg_adb_old_putc == udbg_adb_putc)
		udbg_adb_old_putc = NULL;
#ifdef CONFIG_BOOTX_TEXT

Annotation

Implementation Notes