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);
if(!(b->flags & B_VALID))
ide_rw(b);
iderw(b);
return b;
}
@ -111,7 +111,7 @@ bwrite(struct buf *b)
if((b->flags & B_BUSY) == 0)
panic("bwrite");
b->flags |= B_DIRTY;
ide_rw(b);
iderw(b);
}
// Release the buffer buf.

View file

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

36
defs.h
View file

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

34
ide.c
View file

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

View file

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

6
kbd.c
View file

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

20
main.c
View file

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

28
mp.c
View file

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

View file

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

2
proc.c
View file

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

View file

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

View file

@ -22,13 +22,13 @@
#define TIMER_16BIT 0x30 // r/w counter 16 bits, LSB first
void
timer_init(void)
timerinit(void)
{
// Interrupt 100 times/sec.
outb(TIMER_MODE, TIMER_SEL0 | TIMER_RATEGEN | TIMER_16BIT);
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);
release(&tickslock);
}
lapic_eoi();
lapiceoi();
break;
case IRQ_OFFSET + IRQ_IDE:
ide_intr();
lapic_eoi();
ideintr();
lapiceoi();
break;
case IRQ_OFFSET + IRQ_KBD:
kbd_intr();
lapic_eoi();
kbdintr();
lapiceoi();
break;
case IRQ_OFFSET + IRQ_SPURIOUS:
cprintf("cpu%d: spurious interrupt at %x:%x\n",
cpu(), tf->cs, tf->eip);
lapic_eoi();
lapiceoi();
break;
default:

17
x86.h
View file

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