xv6

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 3994dade649dba764fdab1b8660ef609ab373fc9
parent c000f716d78d41d94e58a08c7cb57afef65d6d6f
Author: Brian Swetland <swetland@frotz.net>
Date:   Sat, 28 Dec 2013 14:04:46 -0800

uart: provide earlyinit to allow cprintf to serial very early on

Diffstat:
Minclude/defs.h | 1+
Mkernel/main.c | 1+
Mkernel/uart.c | 17++++++++++++-----
3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/include/defs.h b/include/defs.h @@ -156,6 +156,7 @@ void tvinit(void); extern struct spinlock tickslock; // uart.c +void uartearlyinit(void); void uartinit(void); void uartintr(void); void uartputc(int); diff --git a/kernel/main.c b/kernel/main.c @@ -17,6 +17,7 @@ extern char end[]; // first address after kernel loaded from ELF file int main(void) { + uartearlyinit(); kinit1(end, P2V(4*1024*1024)); // phys page allocator kvmalloc(); // kernel page table mpinit(); // collect info about this machine diff --git a/kernel/uart.c b/kernel/uart.c @@ -16,7 +16,7 @@ static int uart; // is there a uart? void -uartinit(void) +uartearlyinit(void) { char *p; @@ -36,16 +36,23 @@ uartinit(void) return; uart = 1; + // Announce that we're here. + for(p="xv6...\n"; *p; p++) + uartputc(*p); +} + +void +uartinit(void) +{ + if (!uart) + return; + // Acknowledge pre-existing interrupt conditions; // enable interrupts. inb(COM1+2); inb(COM1+0); picenable(IRQ_COM1); ioapicenable(IRQ_COM1, 0); - - // Announce that we're here. - for(p="xv6...\n"; *p; p++) - uartputc(*p); } void