be consistent: no underscores in function names

This commit is contained in:
rsc 2009-03-08 22:07:13 +00:00
parent b7f653dc49
commit 2157576107
15 changed files with 121 additions and 136 deletions

4
bio.c
View file

@ -100,7 +100,7 @@ bread(uint dev, uint sector)
b = bget(dev, sector); b = bget(dev, sector);
if(!(b->flags & B_VALID)) if(!(b->flags & B_VALID))
ide_rw(b); iderw(b);
return b; return b;
} }
@ -111,7 +111,7 @@ bwrite(struct buf *b)
if((b->flags & B_BUSY) == 0) if((b->flags & B_BUSY) == 0)
panic("bwrite"); panic("bwrite");
b->flags |= B_DIRTY; b->flags |= B_DIRTY;
ide_rw(b); iderw(b);
} }
// Release the buffer buf. // Release the buffer buf.

View file

@ -26,7 +26,7 @@ int use_console_lock = 0;
// .bochsrc to copy to the stdout: // .bochsrc to copy to the stdout:
// parport1: enabled=1, file="/dev/stdout" // parport1: enabled=1, file="/dev/stdout"
static void static void
lpt_putc(int c) lptputc(int c)
{ {
int i; int i;
@ -40,7 +40,7 @@ lpt_putc(int c)
} }
static void static void
cga_putc(int c) cgaputc(int c)
{ {
int pos; int pos;
@ -72,7 +72,7 @@ cga_putc(int c)
} }
void void
cons_putc(int c) consputc(int c)
{ {
if(panicked){ if(panicked){
cli(); cli();
@ -80,8 +80,8 @@ cons_putc(int c)
; ;
} }
lpt_putc(c); lptputc(c);
cga_putc(c); cgaputc(c);
} }
void void
@ -106,7 +106,7 @@ printint(int xx, int base, int sgn)
buf[i++] = '-'; buf[i++] = '-';
while(--i >= 0) while(--i >= 0)
cons_putc(buf[i]); consputc(buf[i]);
} }
// Print to the console. only understands %d, %x, %p, %s. // Print to the console. only understands %d, %x, %p, %s.
@ -130,7 +130,7 @@ cprintf(char *fmt, ...)
if(c == '%') if(c == '%')
state = '%'; state = '%';
else else
cons_putc(c); consputc(c);
break; break;
case '%': case '%':
@ -147,15 +147,15 @@ cprintf(char *fmt, ...)
if(s == 0) if(s == 0)
s = "(null)"; s = "(null)";
for(; *s; s++) for(; *s; s++)
cons_putc(*s); consputc(*s);
break; break;
case '%': case '%':
cons_putc('%'); consputc('%');
break; break;
default: default:
// Print unknown % sequence to draw attention. // Print unknown % sequence to draw attention.
cons_putc('%'); consputc('%');
cons_putc(c); consputc(c);
break; break;
} }
state = 0; state = 0;
@ -168,14 +168,14 @@ cprintf(char *fmt, ...)
} }
int int
console_write(struct inode *ip, char *buf, int n) consolewrite(struct inode *ip, char *buf, int n)
{ {
int i; int i;
iunlock(ip); iunlock(ip);
acquire(&console_lock); acquire(&console_lock);
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
cons_putc(buf[i] & 0xff); consputc(buf[i] & 0xff);
release(&console_lock); release(&console_lock);
ilock(ip); ilock(ip);
@ -194,7 +194,7 @@ struct {
#define C(x) ((x)-'@') // Control-x #define C(x) ((x)-'@') // Control-x
void void
console_intr(int (*getc)(void)) consoleintr(int (*getc)(void))
{ {
int c; int c;
@ -208,19 +208,19 @@ console_intr(int (*getc)(void))
while(input.e != input.w && while(input.e != input.w &&
input.buf[(input.e-1) % INPUT_BUF] != '\n'){ input.buf[(input.e-1) % INPUT_BUF] != '\n'){
input.e--; input.e--;
cons_putc(BACKSPACE); consputc(BACKSPACE);
} }
break; break;
case C('H'): // Backspace case C('H'): // Backspace
if(input.e != input.w){ if(input.e != input.w){
input.e--; input.e--;
cons_putc(BACKSPACE); consputc(BACKSPACE);
} }
break; break;
default: default:
if(c != 0 && input.e-input.r < INPUT_BUF){ if(c != 0 && input.e-input.r < INPUT_BUF){
input.buf[input.e++ % INPUT_BUF] = c; input.buf[input.e++ % INPUT_BUF] = c;
cons_putc(c); consputc(c);
if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){
input.w = input.e; input.w = input.e;
wakeup(&input.r); wakeup(&input.r);
@ -233,7 +233,7 @@ console_intr(int (*getc)(void))
} }
int int
console_read(struct inode *ip, char *dst, int n) consoleread(struct inode *ip, char *dst, int n)
{ {
uint target; uint target;
int c; int c;
@ -271,17 +271,17 @@ console_read(struct inode *ip, char *dst, int n)
} }
void void
console_init(void) consoleinit(void)
{ {
initlock(&console_lock, "console"); initlock(&console_lock, "console");
initlock(&input.lock, "console input"); initlock(&input.lock, "console input");
devsw[CONSOLE].write = console_write; devsw[CONSOLE].write = consolewrite;
devsw[CONSOLE].read = console_read; devsw[CONSOLE].read = consoleread;
use_console_lock = 1; use_console_lock = 1;
pic_enable(IRQ_KBD); picenable(IRQ_KBD);
ioapic_enable(IRQ_KBD, 0); ioapicenable(IRQ_KBD, 0);
} }
void void

36
defs.h
View file

@ -14,9 +14,9 @@ void brelse(struct buf*);
void bwrite(struct buf*); void bwrite(struct buf*);
// console.c // console.c
void console_init(void); void consoleinit(void);
void cprintf(char*, ...); void cprintf(char*, ...);
void console_intr(int(*)(void)); void consoleintr(int(*)(void));
void panic(char*) __attribute__((noreturn)); void panic(char*) __attribute__((noreturn));
// exec.c // exec.c
@ -50,14 +50,14 @@ void stati(struct inode*, struct stat*);
int writei(struct inode*, char*, uint, uint); int writei(struct inode*, char*, uint, uint);
// ide.c // ide.c
void ide_init(void); void ideinit(void);
void ide_intr(void); void ideintr(void);
void ide_rw(struct buf *); void iderw(struct buf *);
// ioapic.c // ioapic.c
void ioapic_enable(int irq, int cpu); void ioapicenable(int irq, int cpu);
extern uchar ioapic_id; extern uchar ioapicid;
void ioapic_init(void); void ioapicinit(void);
// kalloc.c // kalloc.c
char* kalloc(int); char* kalloc(int);
@ -65,24 +65,24 @@ void kfree(char*, int);
void kinit(void); void kinit(void);
// kbd.c // kbd.c
void kbd_intr(void); void kbdintr(void);
// lapic.c // lapic.c
int cpu(void); int cpu(void);
extern volatile uint* lapic; extern volatile uint* lapic;
void lapic_eoi(void); void lapiceoi(void);
void lapic_init(int); void lapicinit(int);
void lapic_startap(uchar, uint); void lapicstartap(uchar, uint);
// mp.c // mp.c
extern int ismp; extern int ismp;
int mp_bcpu(void); int mpbcpu(void);
void mp_init(void); void mpinit(void);
void mp_startthem(void); void mpstartthem(void);
// picirq.c // picirq.c
void pic_enable(int); void picenable(int);
void pic_init(void); void picinit(void);
// pipe.c // pipe.c
int pipealloc(struct file**, struct file**); int pipealloc(struct file**, struct file**);
@ -136,7 +136,7 @@ int fetchstr(struct proc*, uint, char**);
void syscall(void); void syscall(void);
// timer.c // timer.c
void timer_init(void); void timerinit(void);
// trap.c // trap.c
void idtinit(void); void idtinit(void);

34
ide.c
View file

@ -26,11 +26,11 @@ static struct spinlock ide_lock;
static struct buf *ide_queue; static struct buf *ide_queue;
static int disk_1_present; static int disk_1_present;
static void ide_start_request(); static void idestart(struct buf*);
// Wait for IDE disk to become ready. // Wait for IDE disk to become ready.
static int static int
ide_wait_ready(int check_error) idewait(int check_error)
{ {
int r; int r;
@ -42,14 +42,14 @@ ide_wait_ready(int check_error)
} }
void void
ide_init(void) ideinit(void)
{ {
int i; int i;
initlock(&ide_lock, "ide"); initlock(&ide_lock, "ide");
pic_enable(IRQ_IDE); picenable(IRQ_IDE);
ioapic_enable(IRQ_IDE, ncpu - 1); ioapicenable(IRQ_IDE, ncpu - 1);
ide_wait_ready(0); idewait(0);
// Check if disk 1 is present // Check if disk 1 is present
outb(0x1f6, 0xe0 | (1<<4)); outb(0x1f6, 0xe0 | (1<<4));
@ -66,12 +66,12 @@ ide_init(void)
// Start the request for b. Caller must hold ide_lock. // Start the request for b. Caller must hold ide_lock.
static void static void
ide_start_request(struct buf *b) idestart(struct buf *b)
{ {
if(b == 0) if(b == 0)
panic("ide_start_request"); panic("idestart");
ide_wait_ready(0); idewait(0);
outb(0x3f6, 0); // generate interrupt outb(0x3f6, 0); // generate interrupt
outb(0x1f2, 1); // number of sectors outb(0x1f2, 1); // number of sectors
outb(0x1f3, b->sector & 0xff); outb(0x1f3, b->sector & 0xff);
@ -88,7 +88,7 @@ ide_start_request(struct buf *b)
// Interrupt handler. // Interrupt handler.
void void
ide_intr(void) ideintr(void)
{ {
struct buf *b; struct buf *b;
@ -99,7 +99,7 @@ ide_intr(void)
} }
// Read data if needed. // Read data if needed.
if(!(b->flags & B_DIRTY) && ide_wait_ready(1) >= 0) if(!(b->flags & B_DIRTY) && idewait(1) >= 0)
insl(0x1f0, b->data, 512/4); insl(0x1f0, b->data, 512/4);
// Wake process waiting for this buf. // Wake process waiting for this buf.
@ -109,7 +109,7 @@ ide_intr(void)
// Start disk on next buf in queue. // Start disk on next buf in queue.
if((ide_queue = b->qnext) != 0) if((ide_queue = b->qnext) != 0)
ide_start_request(ide_queue); idestart(ide_queue);
release(&ide_lock); release(&ide_lock);
} }
@ -119,16 +119,16 @@ ide_intr(void)
// If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. // If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID.
// Else if B_VALID is not set, read buf from disk, set B_VALID. // Else if B_VALID is not set, read buf from disk, set B_VALID.
void void
ide_rw(struct buf *b) iderw(struct buf *b)
{ {
struct buf **pp; struct buf **pp;
if(!(b->flags & B_BUSY)) if(!(b->flags & B_BUSY))
panic("ide_rw: buf not busy"); panic("iderw: buf not busy");
if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) if((b->flags & (B_VALID|B_DIRTY)) == B_VALID)
panic("ide_rw: nothing to do"); panic("iderw: nothing to do");
if(b->dev != 0 && !disk_1_present) if(b->dev != 0 && !disk_1_present)
panic("ide disk 1 not present"); panic("idrw: ide disk 1 not present");
acquire(&ide_lock); acquire(&ide_lock);
@ -140,7 +140,7 @@ ide_rw(struct buf *b)
// Start disk if necessary. // Start disk if necessary.
if(ide_queue == b) if(ide_queue == b)
ide_start_request(b); idestart(b);
// Wait for request to finish. // Wait for request to finish.
// Assuming will not sleep too long: ignore cp->killed. // Assuming will not sleep too long: ignore cp->killed.

View file

@ -32,21 +32,21 @@ struct ioapic {
}; };
static uint static uint
ioapic_read(int reg) ioapicread(int reg)
{ {
ioapic->reg = reg; ioapic->reg = reg;
return ioapic->data; return ioapic->data;
} }
static void static void
ioapic_write(int reg, uint data) ioapicwrite(int reg, uint data)
{ {
ioapic->reg = reg; ioapic->reg = reg;
ioapic->data = data; ioapic->data = data;
} }
void void
ioapic_init(void) ioapicinit(void)
{ {
int i, id, maxintr; int i, id, maxintr;
@ -54,21 +54,21 @@ ioapic_init(void)
return; return;
ioapic = (volatile struct ioapic*)IOAPIC; ioapic = (volatile struct ioapic*)IOAPIC;
maxintr = (ioapic_read(REG_VER) >> 16) & 0xFF; maxintr = (ioapicread(REG_VER) >> 16) & 0xFF;
id = ioapic_read(REG_ID) >> 24; id = ioapicread(REG_ID) >> 24;
if(id != ioapic_id) if(id != ioapicid)
cprintf("ioapic_init: id isn't equal to ioapic_id; not a MP\n"); cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n");
// Mark all interrupts edge-triggered, active high, disabled, // Mark all interrupts edge-triggered, active high, disabled,
// and not routed to any CPUs. // and not routed to any CPUs.
for(i = 0; i <= maxintr; i++){ for(i = 0; i <= maxintr; i++){
ioapic_write(REG_TABLE+2*i, INT_DISABLED | (IRQ_OFFSET + i)); ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (IRQ_OFFSET + i));
ioapic_write(REG_TABLE+2*i+1, 0); ioapicwrite(REG_TABLE+2*i+1, 0);
} }
} }
void void
ioapic_enable(int irq, int cpunum) ioapicenable(int irq, int cpunum)
{ {
if(!ismp) if(!ismp)
return; return;
@ -76,6 +76,6 @@ ioapic_enable(int irq, int cpunum)
// Mark interrupt edge-triggered, active high, // Mark interrupt edge-triggered, active high,
// enabled, and routed to the given cpunum, // enabled, and routed to the given cpunum,
// which happens to be that cpu's APIC ID. // which happens to be that cpu's APIC ID.
ioapic_write(REG_TABLE+2*irq, IRQ_OFFSET + irq); ioapicwrite(REG_TABLE+2*irq, IRQ_OFFSET + irq);
ioapic_write(REG_TABLE+2*irq+1, cpunum << 24); ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24);
} }

6
kbd.c
View file

@ -4,7 +4,7 @@
#include "kbd.h" #include "kbd.h"
int int
kbd_getc(void) kbdgetc(void)
{ {
static uint shift; static uint shift;
static uchar *charcode[4] = { static uchar *charcode[4] = {
@ -44,7 +44,7 @@ kbd_getc(void)
} }
void void
kbd_intr(void) kbdintr(void)
{ {
console_intr(kbd_getc); consoleintr(kbdgetc);
} }

10
lapic.c
View file

@ -46,7 +46,7 @@ lapicw(int index, int value)
//PAGEBREAK! //PAGEBREAK!
void void
lapic_init(int c) lapicinit(int c)
{ {
if(!lapic) if(!lapic)
return; return;
@ -99,11 +99,11 @@ cpu(void)
// Would prefer to panic but even printing is chancy here: // Would prefer to panic but even printing is chancy here:
// almost everything, including cprintf and panic, calls cpu, // almost everything, including cprintf and panic, calls cpu,
// often indirectly through acquire and release. // often indirectly through acquire and release.
if(read_eflags()&FL_IF){ if(readeflags()&FL_IF){
static int n; static int n;
if(n++ == 0) if(n++ == 0)
cprintf("cpu called from %x with interrupts enabled\n", cprintf("cpu called from %x with interrupts enabled\n",
((uint*)read_ebp())[1]); __builtin_return_address(0));
} }
if(lapic) if(lapic)
@ -113,7 +113,7 @@ cpu(void)
// Acknowledge interrupt. // Acknowledge interrupt.
void void
lapic_eoi(void) lapiceoi(void)
{ {
if(lapic) if(lapic)
lapicw(EOI, 0); lapicw(EOI, 0);
@ -136,7 +136,7 @@ microdelay(int us)
// Start additional processor running bootstrap code at addr. // Start additional processor running bootstrap code at addr.
// See Appendix B of MultiProcessor Specification. // See Appendix B of MultiProcessor Specification.
void void
lapic_startap(uchar apicid, uint addr) lapicstartap(uchar apicid, uint addr)
{ {
int i; int i;
ushort *wrv; ushort *wrv;

20
main.c
View file

@ -12,22 +12,22 @@ static void mpmain(void) __attribute__((noreturn));
int int
main(void) main(void)
{ {
mp_init(); // collect info about this machine mpinit(); // collect info about this machine
lapic_init(mp_bcpu()); lapicinit(mpbcpu());
cprintf("\ncpu%d: starting xv6\n\n", cpu()); cprintf("\ncpu%d: starting xv6\n\n", cpu());
pinit(); // process table pinit(); // process table
binit(); // buffer cache binit(); // buffer cache
pic_init(); // interrupt controller picinit(); // interrupt controller
ioapic_init(); // another interrupt controller ioapicinit(); // another interrupt controller
kinit(); // physical memory allocator kinit(); // physical memory allocator
tvinit(); // trap vectors tvinit(); // trap vectors
fileinit(); // file table fileinit(); // file table
iinit(); // inode cache iinit(); // inode cache
console_init(); // I/O devices & their interrupts consoleinit(); // I/O devices & their interrupts
ide_init(); // disk ideinit(); // disk
if(!ismp) if(!ismp)
timer_init(); // uniprocessor timer timerinit(); // uniprocessor timer
userinit(); // first user process userinit(); // first user process
bootothers(); // start other processors bootothers(); // start other processors
@ -42,8 +42,8 @@ mpmain(void)
{ {
cprintf("cpu%d: mpmain\n", cpu()); cprintf("cpu%d: mpmain\n", cpu());
idtinit(); idtinit();
if(cpu() != mp_bcpu()) if(cpu() != mpbcpu())
lapic_init(cpu()); lapicinit(cpu());
setupsegs(0); setupsegs(0);
xchg(&cpus[cpu()].booted, 1); xchg(&cpus[cpu()].booted, 1);
@ -71,7 +71,7 @@ bootothers(void)
stack = kalloc(KSTACKSIZE); stack = kalloc(KSTACKSIZE);
*(void**)(code-4) = stack + KSTACKSIZE; *(void**)(code-4) = stack + KSTACKSIZE;
*(void**)(code-8) = mpmain; *(void**)(code-8) = mpmain;
lapic_startap(c->apicid, (uint)code); lapicstartap(c->apicid, (uint)code);
// Wait for cpu to get through bootstrap. // Wait for cpu to get through bootstrap.
while(c->booted == 0) while(c->booted == 0)

28
mp.c
View file

@ -14,10 +14,10 @@ struct cpu cpus[NCPU];
static struct cpu *bcpu; static struct cpu *bcpu;
int ismp; int ismp;
int ncpu; int ncpu;
uchar ioapic_id; uchar ioapicid;
int int
mp_bcpu(void) mpbcpu(void)
{ {
return bcpu-cpus; return bcpu-cpus;
} }
@ -35,7 +35,7 @@ sum(uchar *addr, int len)
// Look for an MP structure in the len bytes at addr. // Look for an MP structure in the len bytes at addr.
static struct mp* static struct mp*
mp_search1(uchar *addr, int len) mpsearch1(uchar *addr, int len)
{ {
uchar *e, *p; uchar *e, *p;
@ -52,7 +52,7 @@ mp_search1(uchar *addr, int len)
// 2) in the last KB of system base memory; // 2) in the last KB of system base memory;
// 3) in the BIOS ROM between 0xE0000 and 0xFFFFF. // 3) in the BIOS ROM between 0xE0000 and 0xFFFFF.
static struct mp* static struct mp*
mp_search(void) mpsearch(void)
{ {
uchar *bda; uchar *bda;
uint p; uint p;
@ -60,14 +60,14 @@ mp_search(void)
bda = (uchar*)0x400; bda = (uchar*)0x400;
if((p = ((bda[0x0F]<<8)|bda[0x0E]) << 4)){ if((p = ((bda[0x0F]<<8)|bda[0x0E]) << 4)){
if((mp = mp_search1((uchar*)p, 1024))) if((mp = mpsearch1((uchar*)p, 1024)))
return mp; return mp;
} else { } else {
p = ((bda[0x14]<<8)|bda[0x13])*1024; p = ((bda[0x14]<<8)|bda[0x13])*1024;
if((mp = mp_search1((uchar*)p-1024, 1024))) if((mp = mpsearch1((uchar*)p-1024, 1024)))
return mp; return mp;
} }
return mp_search1((uchar*)0xF0000, 0x10000); return mpsearch1((uchar*)0xF0000, 0x10000);
} }
// Search for an MP configuration table. For now, // Search for an MP configuration table. For now,
@ -76,12 +76,12 @@ mp_search(void)
// if correct, check the version. // if correct, check the version.
// To do: check extended table checksum. // To do: check extended table checksum.
static struct mpconf* static struct mpconf*
mp_config(struct mp **pmp) mpconfig(struct mp **pmp)
{ {
struct mpconf *conf; struct mpconf *conf;
struct mp *mp; struct mp *mp;
if((mp = mp_search()) == 0 || mp->physaddr == 0) if((mp = mpsearch()) == 0 || mp->physaddr == 0)
return 0; return 0;
conf = (struct mpconf*)mp->physaddr; conf = (struct mpconf*)mp->physaddr;
if(memcmp(conf, "PCMP", 4) != 0) if(memcmp(conf, "PCMP", 4) != 0)
@ -95,7 +95,7 @@ mp_config(struct mp **pmp)
} }
void void
mp_init(void) mpinit(void)
{ {
uchar *p, *e; uchar *p, *e;
struct mp *mp; struct mp *mp;
@ -104,7 +104,7 @@ mp_init(void)
struct mpioapic *ioapic; struct mpioapic *ioapic;
bcpu = &cpus[ncpu]; bcpu = &cpus[ncpu];
if((conf = mp_config(&mp)) == 0) if((conf = mpconfig(&mp)) == 0)
return; return;
ismp = 1; ismp = 1;
@ -122,7 +122,7 @@ mp_init(void)
continue; continue;
case MPIOAPIC: case MPIOAPIC:
ioapic = (struct mpioapic*)p; ioapic = (struct mpioapic*)p;
ioapic_id = ioapic->apicno; ioapicid = ioapic->apicno;
p += sizeof(struct mpioapic); p += sizeof(struct mpioapic);
continue; continue;
case MPBUS: case MPBUS:
@ -131,8 +131,8 @@ mp_init(void)
p += 8; p += 8;
continue; continue;
default: default:
cprintf("mp_init: unknown config type %x\n", *p); cprintf("mpinit: unknown config type %x\n", *p);
panic("mp_init"); panic("mpinit");
} }
} }

View file

@ -15,7 +15,7 @@
static ushort irqmask = 0xFFFF & ~(1<<IRQ_SLAVE); static ushort irqmask = 0xFFFF & ~(1<<IRQ_SLAVE);
static void static void
pic_setmask(ushort mask) picsetmask(ushort mask)
{ {
irqmask = mask; irqmask = mask;
outb(IO_PIC1+1, mask); outb(IO_PIC1+1, mask);
@ -23,14 +23,14 @@ pic_setmask(ushort mask)
} }
void void
pic_enable(int irq) picenable(int irq)
{ {
pic_setmask(irqmask & ~(1<<irq)); picsetmask(irqmask & ~(1<<irq));
} }
// Initialize the 8259A interrupt controllers. // Initialize the 8259A interrupt controllers.
void void
pic_init(void) picinit(void)
{ {
// mask all interrupts // mask all interrupts
outb(IO_PIC1+1, 0xFF); outb(IO_PIC1+1, 0xFF);
@ -80,5 +80,5 @@ pic_init(void)
outb(IO_PIC2, 0x0a); // OCW3 outb(IO_PIC2, 0x0a); // OCW3
if(irqmask != 0xFFFF) if(irqmask != 0xFFFF)
pic_setmask(irqmask); picsetmask(irqmask);
} }

2
proc.c
View file

@ -242,7 +242,7 @@ sched(void)
{ {
int intena; int intena;
if(read_eflags()&FL_IF) if(readeflags()&FL_IF)
panic("sched interruptible"); panic("sched interruptible");
if(cp->state == RUNNING) if(cp->state == RUNNING)
panic("sched running"); panic("sched running");

View file

@ -100,7 +100,7 @@ pushcli(void)
{ {
int eflags; int eflags;
eflags = read_eflags(); eflags = readeflags();
cli(); cli();
if(cpus[cpu()].ncli++ == 0) if(cpus[cpu()].ncli++ == 0)
cpus[cpu()].intena = eflags & FL_IF; cpus[cpu()].intena = eflags & FL_IF;
@ -109,7 +109,7 @@ pushcli(void)
void void
popcli(void) popcli(void)
{ {
if(read_eflags()&FL_IF) if(readeflags()&FL_IF)
panic("popcli - interruptible"); panic("popcli - interruptible");
if(--cpus[cpu()].ncli < 0) if(--cpus[cpu()].ncli < 0)
panic("popcli"); panic("popcli");

View file

@ -22,13 +22,13 @@
#define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first #define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first
void void
timer_init(void) timerinit(void)
{ {
// Interrupt 100 times/sec. // Interrupt 100 times/sec.
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT); outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
outb(IO_TIMER1, TIMER_DIV(100) % 256); outb(IO_TIMER1, TIMER_DIV(100) % 256);
outb(IO_TIMER1, TIMER_DIV(100) / 256); outb(IO_TIMER1, TIMER_DIV(100) / 256);
pic_enable(IRQ_TIMER); picenable(IRQ_TIMER);
} }

12
trap.c
View file

@ -52,20 +52,20 @@ trap(struct trapframe *tf)
wakeup(&ticks); wakeup(&ticks);
release(&tickslock); release(&tickslock);
} }
lapic_eoi(); lapiceoi();
break; break;
case IRQ_OFFSET + IRQ_IDE: case IRQ_OFFSET + IRQ_IDE:
ide_intr(); ideintr();
lapic_eoi(); lapiceoi();
break; break;
case IRQ_OFFSET + IRQ_KBD: case IRQ_OFFSET + IRQ_KBD:
kbd_intr(); kbdintr();
lapic_eoi(); lapiceoi();
break; break;
case IRQ_OFFSET + IRQ_SPURIOUS: case IRQ_OFFSET + IRQ_SPURIOUS:
cprintf("cpu%d: spurious interrupt at %x:%x\n", cprintf("cpu%d: spurious interrupt at %x:%x\n",
cpu(), tf->cs, tf->eip); cpu(), tf->cs, tf->eip);
lapic_eoi(); lapiceoi();
break; break;
default: default:

17
x86.h
View file

@ -48,15 +48,6 @@ stosb(void *addr, int data, int cnt)
"memory", "cc"); "memory", "cc");
} }
static inline uint
read_ebp(void)
{
uint ebp;
asm volatile("movl %%ebp, %0" : "=a" (ebp));
return ebp;
}
struct segdesc; struct segdesc;
static inline void static inline void
@ -92,19 +83,13 @@ ltr(ushort sel)
} }
static inline uint static inline uint
read_eflags(void) readeflags(void)
{ {
uint eflags; uint eflags;
asm volatile("pushfl; popl %0" : "=r" (eflags)); asm volatile("pushfl; popl %0" : "=r" (eflags));
return eflags; return eflags;
} }
static inline void
write_eflags(uint eflags)
{
asm volatile("pushl %0; popfl" : : "r" (eflags));
}
static inline uint static inline uint
xchg(volatile uint *addr, uint newval) xchg(volatile uint *addr, uint newval)
{ {