Skip to content

Commit

Permalink
be consistent: no underscores in function names
Browse files Browse the repository at this point in the history
  • Loading branch information
rsc committed Mar 8, 2009
1 parent b7f653d commit 2157576
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 136 deletions.
4 changes: 2 additions & 2 deletions bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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.
Expand Down
46 changes: 23 additions & 23 deletions console.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -40,7 +40,7 @@ lpt_putc(int c)
}

static void
cga_putc(int c)
cgaputc(int c)
{
int pos;

Expand Down Expand Up @@ -72,16 +72,16 @@ cga_putc(int c)
}

void
cons_putc(int c)
consputc(int c)
{
if(panicked){
cli();
for(;;)
;
}

lpt_putc(c);
cga_putc(c);
lptputc(c);
cgaputc(c);
}

void
Expand All @@ -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.
Expand All @@ -130,7 +130,7 @@ cprintf(char *fmt, ...)
if(c == '%')
state = '%';
else
cons_putc(c);
consputc(c);
break;

case '%':
Expand All @@ -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;
Expand All @@ -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);

Expand All @@ -194,7 +194,7 @@ struct {
#define C(x) ((x)-'@') // Control-x

void
console_intr(int (*getc)(void))
consoleintr(int (*getc)(void))
{
int c;

Expand All @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
36 changes: 18 additions & 18 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,39 +50,39 @@ 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);
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**);
Expand Down Expand Up @@ -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);
Expand Down
34 changes: 17 additions & 17 deletions ide.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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));
Expand All @@ -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);
Expand All @@ -88,7 +88,7 @@ ide_start_request(struct buf *b)

// Interrupt handler.
void
ide_intr(void)
ideintr(void)
{
struct buf *b;

Expand All @@ -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.
Expand All @@ -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);
}
Expand All @@ -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);

Expand All @@ -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.
Expand Down
Loading

0 comments on commit 2157576

Please sign in to comment.