linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* anyone have a 16-bit x86 early_printk?
@ 2003-01-14 11:30 William Lee Irwin III
  2003-01-14 13:13 ` Brian Gerst
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: William Lee Irwin III @ 2003-01-14 11:30 UTC (permalink / raw)
  To: linux-kernel

I'm trying to get a box to boot and it appears to drop dead before
start_kernel(). Would anyone happen to have an early_printk() analogue
for 16-bit x86 code?


Thanks,
Bill

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: anyone have a 16-bit x86 early_printk?
@ 2003-01-14 15:17 Protasevich, Natalie
  0 siblings, 0 replies; 11+ messages in thread
From: Protasevich, Natalie @ 2003-01-14 15:17 UTC (permalink / raw)
  To: William Lee Irwin III; +Cc: Linux Kernel

I can share our serial tool for debugging early boot. It is actually written
for IA64 by Chuck Sluder at Unisys, and we used it even for EFI driver
debug. It saved us a lot of grief.
You can modify it for IA32. It just outputs debug messages to the serial
port directly, so you will need a serial console:

This insertion is into kernel/prink.c:
---------------------------------------------
extern void writebuf(int, const char *);

void
early_printk (const char *str)
{
	char c;
	int  i, k, j;

#ifdef CONFIG_ITANIUM_ES7000
// this is out writing to serial port routine:
	writebuf(0, str);
#endif
	while ((c = *str++) != '\0') {




==cut here io.c =======================



#include <string.h>

extern unsigned long ia64_iobase;
extern void outb_asm();
extern unsigned char inb_asm();

unsigned short
serial_port_addr[4] = {
    0x3f8,
    0x2f8,
    0x3e8,
    0x2e8
};

void
outb(unsigned short port, unsigned char data)
{
	unsigned char *addr;
	
	addr = (unsigned char *)(ia64_iobase | ((port & 0xfffc) << 10) |
(port & 0x0fff));
	outb_asm(addr, data);
	
	return;
}

unsigned char
inb(unsigned short port)
{
	unsigned char *addr, data;

	addr = (unsigned char *)(ia64_iobase | ((port & 0xfffc) << 10) |
(port & 0x0fff));

	data = inb_asm(addr);
	
	return(data);
}


#define SERIAL_REGISTER_LSR 5    /*  R/W  Line Status Register */

void
mputc(unsigned char port, unsigned char data)
{
	unsigned char status, i=0;
	unsigned short portaddr;

	portaddr = serial_port_addr[port];

	do {
		status = inb((serial_port_addr[port] +
SERIAL_REGISTER_LSR));
		i++;
		if (i == 10000){
			return;
		}
	} while ((status & 0x20) == 0);

	outb(portaddr, data);	
	
	return;
}

int
writebuf(unsigned char port, char *buf)
{
	int i;
	size_t cnt;
	unsigned char data;

	
	cnt = strlen(buf);

	for (i=0; i<cnt; i++) {
		data = buf[i];
		if (data == '\n') {
			mputc(port, 0x0d);
			mputc(port, 0x0a);
		} else {
			mputc(port, data);
		}
	}

	return((int)cnt);
}


====sample asm inb and outb for IA64========

	.text

	.global inb_asm
	.global outb_asm
	.global read_psr
	.global read_iva
	.global read_xapic
	.global write_xapic

	.align 32



	.proc inb_asm
inb_asm:

        mf                      // fence all loads/stores
        ld1.acq r8 = [r32]      // read a byte from the port
        mf.a                    // make sure the platform accepts it

        br.ret.sptk     b0
	.endp inb_asm



	.proc outb_asm
outb_asm:

        st1.rel [r32] = r33     // write one byte to a port
        mf.a                    // make sure the platform accepts it
        mf                      // fence all loads/stores

        br.ret.sptk     b0

	.endp outb_asm

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2003-01-21 23:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-14 11:30 anyone have a 16-bit x86 early_printk? William Lee Irwin III
2003-01-14 13:13 ` Brian Gerst
2003-01-14 13:43   ` William Lee Irwin III
2003-01-14 16:29     ` Dave Hansen
2003-01-14 16:07 ` Martin J. Bligh
2003-01-14 21:40   ` William Lee Irwin III
2003-01-21  2:32 ` Alan
2003-01-21  6:10   ` William Lee Irwin III
2003-01-21 17:31     ` Dave Hansen
2003-01-21 23:50       ` William Lee Irwin III
2003-01-14 15:17 Protasevich, Natalie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).