lkml.org 
[lkml]   [2003]   [Jan]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: anyone have a 16-bit x86 early_printk?
Date
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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:32    [W:0.049 / U:2.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site