tab police

This commit is contained in:
rsc 2009-05-31 00:39:17 +00:00
parent 215738336a
commit 030a47736f
4 changed files with 42 additions and 42 deletions

2
kill.c
View File

@ -6,7 +6,7 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
int i; int i;
if(argc < 1){ if(argc < 1){
printf(2, "usage: kill pid...\n"); printf(2, "usage: kill pid...\n");
exit(); exit();

View File

@ -156,7 +156,7 @@ lapicstartap(uchar apicid, uint addr)
lapicw(ICRLO, INIT | LEVEL | ASSERT); lapicw(ICRLO, INIT | LEVEL | ASSERT);
microdelay(200); microdelay(200);
lapicw(ICRLO, INIT | LEVEL); lapicw(ICRLO, INIT | LEVEL);
microdelay(100); // should be 10ms, but too slow in Bochs! microdelay(100); // should be 10ms, but too slow in Bochs!
// Send startup IPI (twice!) to enter bootstrap code. // Send startup IPI (twice!) to enter bootstrap code.
// Regular hardware is supposed to only accept a STARTUP // Regular hardware is supposed to only accept a STARTUP

2
proc.h
View File

@ -32,7 +32,7 @@ struct proc {
uint sz; // Size of process memory (bytes) uint sz; // Size of process memory (bytes)
char *kstack; // Bottom of kernel stack for this process char *kstack; // Bottom of kernel stack for this process
enum proc_state state; // Process state enum proc_state state; // Process state
int pid; // Process ID volatile int pid; // Process ID
struct proc *parent; // Parent process struct proc *parent; // Parent process
struct trapframe *tf; // Trap frame for current syscall struct trapframe *tf; // Trap frame for current syscall
struct context *context; // Switch here to run process struct context *context; // Switch here to run process

78
uart.c
View File

@ -10,67 +10,67 @@
#include "proc.h" #include "proc.h"
#include "x86.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 void
uartinit(void) uartinit(void)
{ {
char *p; char *p;
// Turn off the FIFO // Turn off the FIFO
outb(COM1+2, 0); outb(COM1+2, 0);
// 9600 baud, 8 data bits, 1 stop bit, parity off. // 9600 baud, 8 data bits, 1 stop bit, parity off.
outb(COM1+3, 0x80); // Unlock divisor outb(COM1+3, 0x80); // Unlock divisor
outb(COM1+0, 115200/9600); outb(COM1+0, 115200/9600);
outb(COM1+1, 0); outb(COM1+1, 0);
outb(COM1+3, 0x03); // Lock divisor, 8 data bits. outb(COM1+3, 0x03); // Lock divisor, 8 data bits.
outb(COM1+4, 0); outb(COM1+4, 0);
outb(COM1+1, 0x01); // Enable receive interrupts. outb(COM1+1, 0x01); // Enable receive interrupts.
// If status is 0xFF, no serial port. // If status is 0xFF, no serial port.
if(inb(COM1+5) == 0xFF) if(inb(COM1+5) == 0xFF)
return; return;
uart = 1; uart = 1;
// Acknowledge pre-existing interrupt conditions; // Acknowledge pre-existing interrupt conditions;
// enable interrupts. // enable interrupts.
inb(COM1+2); inb(COM1+2);
inb(COM1+0); inb(COM1+0);
picenable(IRQ_COM1); picenable(IRQ_COM1);
ioapicenable(IRQ_COM1, 0); ioapicenable(IRQ_COM1, 0);
// Announce that we're here. // Announce that we're here.
for(p="xv6...\n"; *p; p++) for(p="xv6...\n"; *p; p++)
uartputc(*p); uartputc(*p);
} }
void void
uartputc(int c) uartputc(int c)
{ {
int i; int i;
if(!uart) if(!uart)
return; return;
for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++)
microdelay(10); microdelay(10);
outb(COM1+0, c); outb(COM1+0, c);
} }
static int static int
uartgetc(void) uartgetc(void)
{ {
if(!uart) if(!uart)
return -1; return -1;
if(!(inb(COM1+5) & 0x01)) if(!(inb(COM1+5) & 0x01))
return -1; return -1;
return inb(COM1+0); return inb(COM1+0);
} }
void void
uartintr(void) uartintr(void)
{ {
consoleintr(uartgetc); consoleintr(uartgetc);
} }