summaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
Diffstat (limited to 'console.c')
-rw-r--r--console.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/console.c b/console.c
index 8f89b49..6834c6a 100644
--- a/console.c
+++ b/console.c
@@ -17,9 +17,12 @@
static ushort *crt = (ushort*)0xb8000; // CGA memory
-static struct spinlock console_lock;
-int panicked = 0;
-volatile int use_console_lock = 0;
+static struct {
+ struct spinlock lock;
+ int locking;
+} cons;
+
+static int panicked = 0;
static void
cgaputc(int c)
@@ -99,9 +102,9 @@ cprintf(char *fmt, ...)
uint *argp;
char *s;
- locking = use_console_lock;
+ locking = cons.locking;
if(locking)
- acquire(&console_lock);
+ acquire(&cons.lock);
argp = (uint*)(void*)&fmt + 1;
state = 0;
@@ -146,7 +149,7 @@ cprintf(char *fmt, ...)
}
if(locking)
- release(&console_lock);
+ release(&cons.lock);
}
int
@@ -155,10 +158,10 @@ consolewrite(struct inode *ip, char *buf, int n)
int i;
iunlock(ip);
- acquire(&console_lock);
+ acquire(&cons.lock);
for(i = 0; i < n; i++)
consputc(buf[i] & 0xff);
- release(&console_lock);
+ release(&cons.lock);
ilock(ip);
return n;
@@ -255,12 +258,12 @@ consoleread(struct inode *ip, char *dst, int n)
void
consoleinit(void)
{
- initlock(&console_lock, "console");
- initlock(&input.lock, "console input");
+ initlock(&cons.lock, "console");
+ initlock(&input.lock, "input");
devsw[CONSOLE].write = consolewrite;
devsw[CONSOLE].read = consoleread;
- use_console_lock = 1;
+ cons.locking = 1;
picenable(IRQ_KBD);
ioapicenable(IRQ_KBD, 0);
@@ -273,7 +276,7 @@ panic(char *s)
uint pcs[10];
cli();
- use_console_lock = 0;
+ cons.locking = 0;
cprintf("cpu%d: panic: ", cpu());
cprintf(s);
cprintf("\n");