summaryrefslogtreecommitdiff
path: root/uart.c
diff options
context:
space:
mode:
authorrsc <rsc>2009-05-31 00:39:17 +0000
committerrsc <rsc>2009-05-31 00:39:17 +0000
commit030a47736fbb0febddce2647e5a80b98ca409695 (patch)
treed0f3eb8b17b065f05747d198c386c8456c4111de /uart.c
parent215738336aec0d5118a90a79d380c41910f6ee4b (diff)
downloadxv6-labs-030a47736fbb0febddce2647e5a80b98ca409695.tar.gz
xv6-labs-030a47736fbb0febddce2647e5a80b98ca409695.tar.bz2
xv6-labs-030a47736fbb0febddce2647e5a80b98ca409695.zip
tab police
Diffstat (limited to 'uart.c')
-rw-r--r--uart.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/uart.c b/uart.c
index 298066f..4cd1e0f 100644
--- a/uart.c
+++ b/uart.c
@@ -10,67 +10,67 @@
#include "proc.h"
#include "x86.h"
-#define COM1 0x3f8
+#define COM1 0x3f8
-static int uart; // is there a uart?
+static int uart; // is there a uart?
void
uartinit(void)
{
- char *p;
+ char *p;
- // Turn off the FIFO
- outb(COM1+2, 0);
-
- // 9600 baud, 8 data bits, 1 stop bit, parity off.
- outb(COM1+3, 0x80); // Unlock divisor
- outb(COM1+0, 115200/9600);
- outb(COM1+1, 0);
- outb(COM1+3, 0x03); // Lock divisor, 8 data bits.
- outb(COM1+4, 0);
- outb(COM1+1, 0x01); // Enable receive interrupts.
+ // Turn off the FIFO
+ outb(COM1+2, 0);
+
+ // 9600 baud, 8 data bits, 1 stop bit, parity off.
+ outb(COM1+3, 0x80); // Unlock divisor
+ outb(COM1+0, 115200/9600);
+ outb(COM1+1, 0);
+ outb(COM1+3, 0x03); // Lock divisor, 8 data bits.
+ outb(COM1+4, 0);
+ outb(COM1+1, 0x01); // Enable receive interrupts.
- // If status is 0xFF, no serial port.
- if(inb(COM1+5) == 0xFF)
- return;
- uart = 1;
+ // If status is 0xFF, no serial port.
+ if(inb(COM1+5) == 0xFF)
+ return;
+ uart = 1;
- // 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);
+ // 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
uartputc(int c)
{
- int i;
+ int i;
- if(!uart)
- return;
- for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)
- microdelay(10);
- outb(COM1+0, c);
+ if(!uart)
+ return;
+ for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)
+ microdelay(10);
+ outb(COM1+0, c);
}
static int
uartgetc(void)
{
- if(!uart)
- return -1;
- if(!(inb(COM1+5) & 0x01))
- return -1;
- return inb(COM1+0);
+ if(!uart)
+ return -1;
+ if(!(inb(COM1+5) & 0x01))
+ return -1;
+ return inb(COM1+0);
}
void
uartintr(void)
{
- consoleintr(uartgetc);
+ consoleintr(uartgetc);
}