arch/m68k/amiga/config.c

Source file repositories/reference/linux-study-clean/arch/m68k/amiga/config.c

File Facts

System
Linux kernel
Corpus path
arch/m68k/amiga/config.c
Extension
.c
Size
21003 bytes
Lines
859
Domain
Architecture Layer
Bucket
arch/m68k
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

struct savekmsg {
	unsigned long magic1;		/* SAVEKMSG_MAGIC1 */
	unsigned long magic2;		/* SAVEKMSG_MAGIC2 */
	unsigned long magicptr;		/* address of magic1 */
	unsigned long size;
	char data[];
};

static struct savekmsg *savekmsg;

static void amiga_mem_console_write(struct console *co, const char *s,
				    unsigned int count)
{
	if (savekmsg->size + count <= SAVEKMSG_MAXMEM-sizeof(struct savekmsg)) {
		memcpy(savekmsg->data + savekmsg->size, s, count);
		savekmsg->size += count;
	}
}

static int __init amiga_savekmsg_setup(char *arg)
{
	bool registered;

	if (!MACH_IS_AMIGA || strcmp(arg, "mem"))
		return 0;

	if (amiga_chip_size < SAVEKMSG_MAXMEM) {
		pr_err("Not enough chipram for debugging\n");
		return -ENOMEM;
	}

	/* Just steal the block, the chipram allocator isn't functional yet */
	amiga_chip_size -= SAVEKMSG_MAXMEM;
	savekmsg = ZTWO_VADDR(CHIP_PHYSADDR + amiga_chip_size);
	savekmsg->magic1 = SAVEKMSG_MAGIC1;
	savekmsg->magic2 = SAVEKMSG_MAGIC2;
	savekmsg->magicptr = ZTWO_PADDR(savekmsg);
	savekmsg->size = 0;

	registered = !!amiga_console_driver.write;
	amiga_console_driver.write = amiga_mem_console_write;
	if (!registered)
		register_console(&amiga_console_driver);
	return 0;
}

early_param("debug", amiga_savekmsg_setup);

static void amiga_serial_putc(char c)
{
	amiga_custom.serdat = (unsigned char)c | 0x100;
	while (!(amiga_custom.serdatr & 0x2000))
		;
}

static void amiga_serial_console_write(struct console *co, const char *s,
				       unsigned int count)
{
	while (count--) {
		if (*s == '\n')
			amiga_serial_putc('\r');
		amiga_serial_putc(*s++);
	}
}

#if 0
void amiga_serial_puts(const char *s)
{
	amiga_serial_console_write(NULL, s, strlen(s));
}

int amiga_serial_console_wait_key(struct console *co)
{
	int ch;

	while (!(amiga_custom.intreqr & IF_RBF))
		barrier();
	ch = amiga_custom.serdatr & 0xff;
	/* clear the interrupt, so that another character can be read */
	amiga_custom.intreq = IF_RBF;
	return ch;
}

void amiga_serial_gets(struct console *co, char *s, int len)
{
	int ch, cnt = 0;

	while (1) {
		ch = amiga_serial_console_wait_key(co);

Annotation

Implementation Notes