[IO] rework dprintf to take a debug level, defined in DEBUGLEVEL

printf at the moment just calls dprintf, but soon will become
a seperate I/O queue.
diff --git a/app/console/console.c b/app/console/console.c
index 6fa4a4b..7f450b5 100644
--- a/app/console/console.c
+++ b/app/console/console.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <stdlib.h>
+#include <stdio.h>
 
 static cmd_block *command_list = NULL;
 
@@ -81,7 +82,7 @@
 		char c;
 
 		/* loop until we get a char */
-		if (dgetc(&c) < 0)
+		if (getc(&c) < 0)
 			continue;
 
 //		printf("c = 0x%hhx\n", c); 
@@ -90,16 +91,16 @@
 			switch (c) {
 				case '\r':
 				case '\n':
-					dputc(c);
+					putc(c);
 					goto done;
 
 				case 0x7f: // backspace or delete
 				case 0x8:
 					if (pos > 0) {
 						pos--;
-						dputs("\x1b[1D"); // move to the left one
-						dputc(' ');
-						dputs("\x1b[1D"); // move to the left one
+						puts("\x1b[1D"); // move to the left one
+						putc(' ');
+						puts("\x1b[1D"); // move to the left one
 					}
 					break;
 
@@ -109,7 +110,7 @@
 
 				default:
 					buffer[pos++] = c;
-					dputc(c);
+					putc(c);
 			}
 		} else if (escape_level == 1) {
 			// inside an escape, look for '['
@@ -123,14 +124,14 @@
 			switch (c) {
 				case 67: // right arrow
 					buffer[pos++] = ' ';
-					dputc(' ');
+					putc(' ');
 					break;
 				case 68: // left arrow
 					if (pos > 0) {
 						pos--;
-						dputs("\x1b[1D"); // move to the left one
-						dputc(' ');
-						dputs("\x1b[1D"); // move to the left one
+						puts("\x1b[1D"); // move to the left one
+						putc(' ');
+						puts("\x1b[1D"); // move to the left one
 					}
 					break;
 				case 65: // up arrow
@@ -145,7 +146,7 @@
 
 		/* end of line. */
 		if (pos == (len - 1)) {
-			dputs("\nerror: line too long\n");
+			puts("\nerror: line too long\n");
 			pos = 0;
 			goto done;
 		}
@@ -240,7 +241,7 @@
 	printf("entering main console loop\n");
 
 	for (;;) {
-		dputs("] ");
+		puts("] ");
 
 		int len = read_line(buffer, sizeof(buffer));
 		if (len == 0)
diff --git a/app/stringtests/string_tests.c b/app/stringtests/string_tests.c
index 6f15877..ac558b3 100644
--- a/app/stringtests/string_tests.c
+++ b/app/stringtests/string_tests.c
@@ -60,7 +60,7 @@
 	time_t null, libc, mine;
 	size_t srcalign, dstalign;
 	
-	dprintf("memcpy speed test\n");
+	printf("memcpy speed test\n");
 	thread_sleep(200); // let the debug string clear the serial port
 
 	for (srcalign = 0; srcalign < 64; ) {
@@ -70,10 +70,10 @@
 			libc = bench_memcpy_routine(&memcpy, srcalign, dstalign);
 			mine = bench_memcpy_routine(&mymemcpy, srcalign, dstalign);
 
-			dprintf("srcalign %lu, dstalign %lu\n", srcalign, dstalign);
-			dprintf("   null memcpy %u msecs\n", null);
-			dprintf("   libc memcpy %u msecs, %llu bytes/sec\n", libc, BUFFER_SIZE * ITERATIONS * 1000ULL / libc);
-			dprintf("   my   memcpy %u msecs, %llu bytes/sec\n", mine, BUFFER_SIZE * ITERATIONS * 1000ULL / mine);
+			printf("srcalign %lu, dstalign %lu\n", srcalign, dstalign);
+			printf("   null memcpy %u msecs\n", null);
+			printf("   libc memcpy %u msecs, %llu bytes/sec\n", libc, BUFFER_SIZE * ITERATIONS * 1000ULL / libc);
+			printf("   my   memcpy %u msecs, %llu bytes/sec\n", mine, BUFFER_SIZE * ITERATIONS * 1000ULL / mine);
 
 			if (dstalign == 0)
 				dstalign = 1;
@@ -102,7 +102,7 @@
 	size_t srcalign, dstalign, size;
 	const size_t maxsize = 256;
 
-	dprintf("testing memcpy for correctness\n");
+	printf("testing memcpy for correctness\n");
 
 	/*
 	 * do the simple tests to make sure that memcpy doesn't color outside
@@ -110,10 +110,10 @@
 	 */
 	for (srcalign = 0; srcalign < 64; srcalign++) {
 		for (dstalign = 0; dstalign < 64; dstalign++) {
-//			dprintf("srcalign %zu, dstalign %zu\n", srcalign, dstalign);
+//			printf("srcalign %zu, dstalign %zu\n", srcalign, dstalign);
 			for (size = 0; size < maxsize; size++) {
 
-//				dprintf("srcalign %zu, dstalign %zu, size %zu\n", srcalign, dstalign, size);
+//				printf("srcalign %zu, dstalign %zu, size %zu\n", srcalign, dstalign, size);
 
 				fillbuf(src, maxsize * 2, 567);
 				fillbuf(src2, maxsize * 2, 567);
@@ -125,7 +125,7 @@
 
 				int comp = memcmp(dst, dst2, maxsize * 2);
 				if (comp != 0) {
-					dprintf("error! srcalign %zu, dstalign %zu, size %zu\n", srcalign, dstalign, size);
+					printf("error! srcalign %zu, dstalign %zu, size %zu\n", srcalign, dstalign, size);
 				}
 			}
 		}
@@ -149,7 +149,7 @@
 	time_t libc, mine;
 	size_t dstalign;
 	
-	dprintf("memset speed test\n");
+	printf("memset speed test\n");
 	thread_sleep(200); // let the debug string clear the serial port
 
 	for (dstalign = 0; dstalign < 64; dstalign++) {
@@ -157,9 +157,9 @@
 		libc = bench_memset_routine(&memset, dstalign);
 		mine = bench_memset_routine(&mymemset, dstalign);
 
-		dprintf("dstalign %lu\n", dstalign);
-		dprintf("   libc memset %u msecs, %llu bytes/sec\n", libc, BUFFER_SIZE * ITERATIONS * 1000ULL / libc);
-		dprintf("   my   memset %u msecs, %llu bytes/sec\n", mine, BUFFER_SIZE * ITERATIONS * 1000ULL / mine);
+		printf("dstalign %lu\n", dstalign);
+		printf("   libc memset %u msecs, %llu bytes/sec\n", libc, BUFFER_SIZE * ITERATIONS * 1000ULL / libc);
+		printf("   my   memset %u msecs, %llu bytes/sec\n", mine, BUFFER_SIZE * ITERATIONS * 1000ULL / mine);
 	}
 }
 
@@ -169,10 +169,10 @@
 	int c;
 	const size_t maxsize = 256;
 
-	dprintf("testing memset for correctness\n");
+	printf("testing memset for correctness\n");
 
 	for (dstalign = 0; dstalign < 64; dstalign++) {
-		dprintf("align %zd\n", dstalign);
+		printf("align %zd\n", dstalign);
 		for (size = 0; size < maxsize; size++) {
 			for (c = 0; c < 256; c++) {
 
@@ -184,7 +184,7 @@
 
 				int comp = memcmp(dst, dst2, maxsize * 2);
 				if (comp != 0) {
-					dprintf("error! align %zu, c %d, size %zu\n", dstalign, c, size);
+					printf("error! align %zu, c %d, size %zu\n", dstalign, c, size);
 				}
 			}
 		}
@@ -201,14 +201,14 @@
 	src2 = memalign(64, BUFFER_SIZE + 256);
 	dst2 = memalign(64, BUFFER_SIZE + 256);
 
-	dprintf("src %p, dst %p\n", src, dst);
-	dprintf("src2 %p, dst2 %p\n", src2, dst2);
+	printf("src %p, dst %p\n", src, dst);
+	printf("src2 %p, dst2 %p\n", src2, dst2);
 
 	if (argc < 3) {
-		dprintf("not enough arguments:\n");
+		printf("not enough arguments:\n");
 usage:
-		dprintf("%s validate <routine>\n", argv[0].str);
-		dprintf("%s bench <routine>\n", argv[0].str);
+		printf("%s validate <routine>\n", argv[0].str);
+		printf("%s bench <routine>\n", argv[0].str);
 		goto out;
 	}
 
diff --git a/app/tests/printf_tests.c b/app/tests/printf_tests.c
index efabba8..2c3ebc0 100644
--- a/app/tests/printf_tests.c
+++ b/app/tests/printf_tests.c
@@ -25,66 +25,66 @@
 
 void printf_tests(void)
 {
-	dprintf("printf tests\n");
+	printf("printf tests\n");
 
-	dprintf("numbers:\n");
-	dprintf("int8:  %hhd %hhd %hhd\n", -12, 0, 254);
-	dprintf("uint8: %hhu %hhu %hhu\n", -12, 0, 254);
-	dprintf("int16: %hd %hd %hd\n", -1234, 0, 1234);
-	dprintf("uint16:%hu %hu %hu\n", -1234, 0, 1234);
-	dprintf("int:   %d %d %d\n", -12345678, 0, 12345678);
-	dprintf("uint:  %u %u %u\n", -12345678, 0, 12345678);
-	dprintf("long:  %ld %ld %ld\n", -12345678, 0, 12345678);
-	dprintf("ulong: %lu %lu %lu\n", -12345678, 0, 12345678);
-	dprintf("long:  %D %D %D\n", -12345678, 0, 12345678);
-	dprintf("ulong: %U %U %U\n", -12345678, 0, 12345678);
-	dprintf("longlong: %lli %lli %lli\n", -12345678LL, 0LL, 12345678LL);
-	dprintf("ulonglong: %llu %llu %llu\n", -12345678LL, 0LL, 12345678LL);
-	dprintf("size_t: %zd %zd %zd\n", -12345678, 0, 12345678);
-	dprintf("usize_t: %zu %zu %zu\n", -12345678, 0, 12345678);
+	printf("numbers:\n");
+	printf("int8:  %hhd %hhd %hhd\n", -12, 0, 254);
+	printf("uint8: %hhu %hhu %hhu\n", -12, 0, 254);
+	printf("int16: %hd %hd %hd\n", -1234, 0, 1234);
+	printf("uint16:%hu %hu %hu\n", -1234, 0, 1234);
+	printf("int:   %d %d %d\n", -12345678, 0, 12345678);
+	printf("uint:  %u %u %u\n", -12345678, 0, 12345678);
+	printf("long:  %ld %ld %ld\n", -12345678, 0, 12345678);
+	printf("ulong: %lu %lu %lu\n", -12345678, 0, 12345678);
+	printf("long:  %D %D %D\n", -12345678, 0, 12345678);
+	printf("ulong: %U %U %U\n", -12345678, 0, 12345678);
+	printf("longlong: %lli %lli %lli\n", -12345678LL, 0LL, 12345678LL);
+	printf("ulonglong: %llu %llu %llu\n", -12345678LL, 0LL, 12345678LL);
+	printf("size_t: %zd %zd %zd\n", -12345678, 0, 12345678);
+	printf("usize_t: %zu %zu %zu\n", -12345678, 0, 12345678);
 
-	dprintf("hex:\n");
-	dprintf("uint8: %hhx %hhx %hhx\n", -12, 0, 254);
-	dprintf("uint16:%hx %hx %hx\n", -1234, 0, 1234);
-	dprintf("uint:  %x %x %x\n", -12345678, 0, 12345678);
-	dprintf("ulong: %lx %lx %lx\n", -12345678, 0, 12345678);
-	dprintf("ulong: %X %X %X\n", -12345678, 0, 12345678);
-	dprintf("ulonglong: %llx %llx %llx\n", -12345678LL, 0LL, 12345678LL);
-	dprintf("usize_t: %zx %zx %zx\n", -12345678, 0, 12345678);
+	printf("hex:\n");
+	printf("uint8: %hhx %hhx %hhx\n", -12, 0, 254);
+	printf("uint16:%hx %hx %hx\n", -1234, 0, 1234);
+	printf("uint:  %x %x %x\n", -12345678, 0, 12345678);
+	printf("ulong: %lx %lx %lx\n", -12345678, 0, 12345678);
+	printf("ulong: %X %X %X\n", -12345678, 0, 12345678);
+	printf("ulonglong: %llx %llx %llx\n", -12345678LL, 0LL, 12345678LL);
+	printf("usize_t: %zx %zx %zx\n", -12345678, 0, 12345678);
 
-	dprintf("alt/sign:\n");
-	dprintf("uint: %#x %#X\n", 0xabcdef, 0xabcdef);
-	dprintf("int: %+d %+d\n", 12345678, -12345678);
+	printf("alt/sign:\n");
+	printf("uint: %#x %#X\n", 0xabcdef, 0xabcdef);
+	printf("int: %+d %+d\n", 12345678, -12345678);
 
-	dprintf("formatting\n");
-	dprintf("int: a%8da\n", 12345678);
-	dprintf("int: a%9da\n", 12345678);
-	dprintf("int: a%-9da\n", 12345678);
-	dprintf("int: a%10da\n", 12345678);
-	dprintf("int: a%-10da\n", 12345678);
-	dprintf("int: a%09da\n", 12345678);
-	dprintf("int: a%010da\n", 12345678);
-	dprintf("int: a%6da\n", 12345678);
+	printf("formatting\n");
+	printf("int: a%8da\n", 12345678);
+	printf("int: a%9da\n", 12345678);
+	printf("int: a%-9da\n", 12345678);
+	printf("int: a%10da\n", 12345678);
+	printf("int: a%-10da\n", 12345678);
+	printf("int: a%09da\n", 12345678);
+	printf("int: a%010da\n", 12345678);
+	printf("int: a%6da\n", 12345678);
 
-	dprintf("a%1sa\n", "b");
-	dprintf("a%9sa\n", "b");
-	dprintf("a%-9sa\n", "b");
-	dprintf("a%5sa\n", "thisisatest");
+	printf("a%1sa\n", "b");
+	printf("a%9sa\n", "b");
+	printf("a%-9sa\n", "b");
+	printf("a%5sa\n", "thisisatest");
 
 	int err;
 
-	err = dprintf("a");
-	dprintf(" returned %d\n", err);
-	err = dprintf("ab");
-	dprintf(" returned %d\n", err);
-	err = dprintf("abc");
-	dprintf(" returned %d\n", err);
-	err = dprintf("abcd");
-	dprintf(" returned %d\n", err);
-	err = dprintf("abcde");
-	dprintf(" returned %d\n", err);
-	err = dprintf("abcdef");
-	dprintf(" returned %d\n", err);
+	err = printf("a");
+	printf(" returned %d\n", err);
+	err = printf("ab");
+	printf(" returned %d\n", err);
+	err = printf("abc");
+	printf(" returned %d\n", err);
+	err = printf("abcd");
+	printf(" returned %d\n", err);
+	err = printf("abcde");
+	printf(" returned %d\n", err);
+	err = printf("abcdef");
+	printf(" returned %d\n", err);
 }
 
 
diff --git a/app/tests/thread_tests.c b/app/tests/thread_tests.c
index 7512726..acbdfbd 100644
--- a/app/tests/thread_tests.c
+++ b/app/tests/thread_tests.c
@@ -30,7 +30,7 @@
 static int sleep_thread(void *arg)
 {
 	for(;;) {
-		dprintf("sleeper %p\n", current_thread);
+		printf("sleeper %p\n", current_thread);
 		thread_sleep(rand() % 500);
 	}
 	return 0;
@@ -55,7 +55,7 @@
 
 	atomic_add(&mutex_thread_count, 1);
 
-	dprintf("mutex tester thread %p starting up, will go for %d iterations\n", current_thread, iterations);
+	printf("mutex tester thread %p starting up, will go for %d iterations\n", current_thread, iterations);
 
 	for (i = 0; i < iterations; i++) {
 		mutex_acquire(&m);
@@ -80,9 +80,9 @@
 	mutex_t *timeout_mutex = (mutex_t *)arg;
 	status_t err;
 
-	dprintf("mutex_timeout_thread acquiring mutex %p with 1 second timeout\n", timeout_mutex);
+	printf("mutex_timeout_thread acquiring mutex %p with 1 second timeout\n", timeout_mutex);
 	err = mutex_acquire_timeout(timeout_mutex, 1000);
-	dprintf("mutex_acquire_timeout returns %d\n", err);
+	printf("mutex_acquire_timeout returns %d\n", err);
 
 	return err;
 }
@@ -92,9 +92,9 @@
 	mutex_t *timeout_mutex = (mutex_t *)arg;
 	status_t err;
 
-	dprintf("mutex_zerotimeout_thread acquiring mutex %p with zero second timeout\n", timeout_mutex);
+	printf("mutex_zerotimeout_thread acquiring mutex %p with zero second timeout\n", timeout_mutex);
 	err = mutex_acquire_timeout(timeout_mutex, 0);
-	dprintf("mutex_acquire_timeout returns %d\n", err);
+	printf("mutex_acquire_timeout returns %d\n", err);
 
 	return err;
 }
@@ -112,9 +112,9 @@
 	while (mutex_thread_count > 0)
 		thread_yield();
 
-	dprintf("done with simple mutex tests\n");
+	printf("done with simple mutex tests\n");
 
-	dprintf("testing mutex timeout\n");
+	printf("testing mutex timeout\n");
 
 	mutex_t timeout_mutex;
 
@@ -129,7 +129,7 @@
 	thread_sleep(5000);
 	mutex_release(&timeout_mutex);
 
-	dprintf("done with mutex tests\n");
+	printf("done with mutex tests\n");
 
 	mutex_destroy(&timeout_mutex);
 
@@ -140,13 +140,13 @@
 
 static int event_signaller(void *arg)
 {
-	dprintf("event signaller pausing\n");
+	printf("event signaller pausing\n");
 	thread_sleep(1000);
 
 //	for (;;) {
-		dprintf("signalling event\n");
+		printf("signalling event\n");
 		event_signal(&e, true);
-		dprintf("done signalling event\n");
+		printf("done signalling event\n");
 		thread_yield();
 //	}
 
@@ -155,15 +155,15 @@
 
 static int event_waiter(void *arg)
 {
-	dprintf("event waiter starting\n");
+	printf("event waiter starting\n");
 
 	for (;;) {
-		dprintf("%p: waiting on event...\n", current_thread);
+		printf("%p: waiting on event...\n", current_thread);
 		if (event_wait(&e) < 0) {
-			dprintf("%p: event_wait() returned error\n", current_thread);
+			printf("%p: event_wait() returned error\n", current_thread);
 			return -1;
 		}
-		dprintf("%p: done waiting on event...\n", current_thread);
+		printf("%p: done waiting on event...\n", current_thread);
 		thread_yield();
 	}
 
@@ -196,7 +196,7 @@
 static int quantum_tester(void *arg)
 {
 	for (;;) {
-		dprintf("%p: in this thread. rq %d\n", current_thread, current_thread->remaining_quantum);
+		printf("%p: in this thread. rq %d\n", current_thread, current_thread->remaining_quantum);
 	}
 	return 0;
 }
@@ -227,7 +227,7 @@
 	}
 	total_count += debug_cycle_count() - count;
 	thread_sleep(1000);
-	dprintf("took %u cycles to yield %d times, %u per yield, %u per yield per thread\n", 
+	printf("took %u cycles to yield %d times, %u per yield, %u per yield per thread\n", 
 		total_count, iter, total_count / iter, total_count / iter / thread_count);
 
 	event_signal(&context_switch_done_event, true);
diff --git a/arch/arm/faults.c b/arch/arm/faults.c
index 487db1f..020266a 100644
--- a/arch/arm/faults.c
+++ b/arch/arm/faults.c
@@ -26,20 +26,20 @@
 
 static void dump_fault_frame(struct arm_fault_frame *frame)
 {
-	dprintf("r0  0x%08x r1  0x%08x r2  0x%08x r3  0x%08x\n", frame->r[0], frame->r[1], frame->r[2], frame->r[3]);
-	dprintf("r4  0x%08x r5  0x%08x r6  0x%08x r7  0x%08x\n", frame->r[4], frame->r[5], frame->r[6], frame->r[7]);
-	dprintf("r8  0x%08x r9  0x%08x r10 0x%08x r11 0x%08x\n", frame->r[8], frame->r[9], frame->r[10], frame->r[11]);
-	dprintf("r12 0x%08x usp 0x%08x ulr 0x%08x pc  0x%08x\n", frame->r[12], frame->usp, frame->ulr, frame->pc);
-	dprintf("spsr 0x%08x\n", frame->spsr);
+	dprintf(CRITICAL, "r0  0x%08x r1  0x%08x r2  0x%08x r3  0x%08x\n", frame->r[0], frame->r[1], frame->r[2], frame->r[3]);
+	dprintf(CRITICAL, "r4  0x%08x r5  0x%08x r6  0x%08x r7  0x%08x\n", frame->r[4], frame->r[5], frame->r[6], frame->r[7]);
+	dprintf(CRITICAL, "r8  0x%08x r9  0x%08x r10 0x%08x r11 0x%08x\n", frame->r[8], frame->r[9], frame->r[10], frame->r[11]);
+	dprintf(CRITICAL, "r12 0x%08x usp 0x%08x ulr 0x%08x pc  0x%08x\n", frame->r[12], frame->usp, frame->ulr, frame->pc);
+	dprintf(CRITICAL, "spsr 0x%08x\n", frame->spsr);
 
 	struct arm_mode_regs regs;
 	arm_save_mode_regs(&regs);
 
-	dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_FIQ) ? '*' : ' ', "fiq", regs.fiq_r13, regs.fiq_r14);
-	dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_IRQ) ? '*' : ' ', "irq", regs.irq_r13, regs.irq_r14);
-	dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SVC) ? '*' : ' ', "svc", regs.svc_r13, regs.svc_r14);
-	dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_UND) ? '*' : ' ', "und", regs.und_r13, regs.und_r14);
-	dprintf("%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SYS) ? '*' : ' ', "sys", regs.sys_r13, regs.sys_r14);
+	dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_FIQ) ? '*' : ' ', "fiq", regs.fiq_r13, regs.fiq_r14);
+	dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_IRQ) ? '*' : ' ', "irq", regs.irq_r13, regs.irq_r14);
+	dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SVC) ? '*' : ' ', "svc", regs.svc_r13, regs.svc_r14);
+	dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_UND) ? '*' : ' ', "und", regs.und_r13, regs.und_r14);
+	dprintf(CRITICAL, "%c%s r13 0x%08x r14 0x%08x\n", ((frame->spsr & MODE_MASK) == MODE_SYS) ? '*' : ' ', "sys", regs.sys_r13, regs.sys_r14);
 
 	// dump the bottom of the current stack
 	addr_t stack;
@@ -54,7 +54,7 @@
 	}
 
 	if (stack != 0) {
-		dprintf("bottom of stack at 0x%08x:\n", (unsigned int)stack);
+		dprintf(CRITICAL, "bottom of stack at 0x%08x:\n", (unsigned int)stack);
 		hexdump((void *)stack, 128);
 	}
 }
@@ -63,9 +63,10 @@
 {
 	inc_critical_section();
 	frame->pc += pc_off;
-	dprintf(msg);
+	dprintf(CRITICAL, msg);
 	dump_fault_frame(frame);
-	debug_halt();
+	
+	halt();
 	for(;;);
 }
 
diff --git a/include/assert.h b/include/assert.h
index db58611..332dfdb 100644
--- a/include/assert.h
+++ b/include/assert.h
@@ -24,14 +24,14 @@
 #define __ASSERT_H
 
 #include <compiler.h>
-#include <platform/debug.h>
+#include <debug.h>
 
 #define ASSERT(x) \
-	do { if (unlikely(!(x))) { dprintf("ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); debug_halt(); } } while (0)
+	do { if (unlikely(!(x))) { panic("ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); } } while (0)
 
-#if DEBUG
+#if DEBUGLEVEL > 1
 #define DEBUG_ASSERT(x) \
-	do { if (unlikely(!(x))) { dprintf("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); debug_halt(); } } while (0)
+	do { if (unlikely(!(x))) { panic("DEBUG ASSERT FAILED at (%s:%d): %s\n", __FILE__, __LINE__, #x); } } while (0)
 #else
 #define DEBUG_ASSERT(x) \
 	do { } while(0)
diff --git a/include/debug.h b/include/debug.h
index 1013e87..e5ebc19 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -24,6 +24,8 @@
 #define __DEBUG_H
 
 #include <assert.h>
+#include <stdarg.h>
+#include <compiler.h>
 #include <platform/debug.h>
 #include <printf.h>
 
@@ -37,6 +39,26 @@
 #define DEBUGLEVEL 2
 #endif
 
+/* debug levels */
+#define CRITICAL 0
+#define ALWAYS 0
+#define INFO 1
+#define SPEW 2
+
+/* output */
+void _dputc(char c); // XXX for now, platform implements
+int _dputs(const char *str);
+int _dprintf(const char *fmt, ...) __PRINTFLIKE(1, 2);
+int _dvprintf(const char *fmt, va_list ap);
+
+#define dputc(level, str) do { if ((level) <= DEBUGLEVEL) { _dputc(str); } } while (0)
+#define dputs(level, str) do { if ((level) <= DEBUGLEVEL) { _dputs(str); } } while (0)
+#define dprintf(level, x...) do { if ((level) <= DEBUGLEVEL) { _dprintf(x); } } while (0)
+#define dvprintf(level, x...) do { if ((level) <= DEBUGLEVEL) { _dvprintf(x); } } while (0)
+
+/* input */
+int dgetc(char *c);
+
 /* systemwide halts */
 void halt(void) __NO_RETURN;
 
diff --git a/include/platform/debug.h b/include/platform/debug.h
index 2a48006..4ab460a 100644
--- a/include/platform/debug.h
+++ b/include/platform/debug.h
@@ -31,11 +31,6 @@
 extern "C" {
 #endif
 
-void dputc(char c);
-int dgetc(char *c);
-int dputs(const char *str);
-int dprintf(const char *fmt, ...) __PRINTFLIKE(1, 2);
-int dvprintf(const char *fmt, va_list ap);
 void debug_dump_regs(void);
 uint32_t debug_cycle_count(void);
 
@@ -45,7 +40,7 @@
 
 void debug_set_trace_level(int trace_type, int level);
 
-void debug_halt(void) __NO_RETURN;
+void platform_halt(void) __NO_RETURN;
 
 #if defined(__cplusplus)
 }
diff --git a/include/stdio.h b/include/stdio.h
new file mode 100644
index 0000000..ebabfca
--- /dev/null
+++ b/include/stdio.h
@@ -0,0 +1,12 @@
+#ifndef __STDIO_H
+#define __STDIO_H
+
+#include <debug.h>
+#include <printf.h>
+
+void putc(char c);
+int puts(const char *str);
+int getc(char *c); // XXX not really getc
+
+#endif
+
diff --git a/kernel/main.c b/kernel/main.c
index cfe39b2..7fa8d59 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -67,30 +67,30 @@
 	// do any super early target initialization
 	target_early_init();
 
-	dprintf("welcome to lk\n\n");
+	dprintf(INFO, "welcome to lk\n\n");
 	
 	// deal with any static constructors
-	dprintf("calling constructors\n");
+	dprintf(SPEW, "calling constructors\n");
 	call_constructors();
 
 	// bring up the kernel heap
-	dprintf("initializing heap\n");
+	dprintf(SPEW, "initializing heap\n");
 	heap_init();
 
 	// initialize the threading system
-	dprintf("initializing threads\n");
+	dprintf(SPEW, "initializing threads\n");
 	thread_init();
 
 	// initialize the dpc system
-	dprintf("initializing dpc\n");
+	dprintf(SPEW, "initializing dpc\n");
 	dpc_init();
 
 	// initialize kernel timers
-	dprintf("initializing timers\n");
+	dprintf(SPEW, "initializing timers\n");
 	timer_init();
 
 	// create a thread to complete system initialization
-	dprintf("creating bootstrap completion thread\n");
+	dprintf(SPEW, "creating bootstrap completion thread\n");
 	thread_resume(thread_create("bootstrap2", &bootstrap2, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
 
 	// enable interrupts
@@ -104,19 +104,19 @@
 
 static int bootstrap2(void *arg)
 {
-	dprintf("top of bootstrap2()\n");
+	dprintf(SPEW, "top of bootstrap2()\n");
 
 	arch_init();
 
 	// initialize the rest of the platform
-	dprintf("initializing rest of platform\n");
+	dprintf(SPEW, "initializing platform\n");
 	platform_init();
-
-	// initialize the rest of the target
-	dprintf("initializing rest of target\n");
+	
+	// initialize the target
+	dprintf(SPEW, "initializing target\n");
 	target_init();
 
-	dprintf("calling project_init()\n");
+	dprintf(SPEW, "calling sys_init()\n");
 	project_init();
 
 	return 0;
diff --git a/kernel/thread.c b/kernel/thread.c
index 6de7d6b..fc9d9ca 100644
--- a/kernel/thread.c
+++ b/kernel/thread.c
@@ -156,7 +156,7 @@
 {
 	thread_t *t = (thread_t *)thread;
 
-//	dprintf("thread_cleanup_dpc: thread %p (%s)\n", t, t->name);
+//	dprintf(SPEW, "thread_cleanup_dpc: thread %p (%s)\n", t, t->name);
 
 #if THREAD_CHECKS
 	ASSERT(t->state == THREAD_DEATH);
@@ -238,7 +238,7 @@
 #endif
 
 	int next_queue = HIGHEST_PRIORITY - __builtin_clz(run_queue_bitmap) - (32 - NUM_PRIORITIES);
-//	dprintf("bitmap 0x%x, next %d\n", run_queue_bitmap, next_queue);
+	//dprintf(SPEW, "bitmap 0x%x, next %d\n", run_queue_bitmap, next_queue);
 
 	newthread = list_remove_head_type(&run_queue[next_queue], thread_t, queue_node);
 
@@ -451,11 +451,11 @@
 
 void dump_thread(thread_t *t)
 {
-	dprintf("dump_thread: t %p (%s)\n", t, t->name);
-	dprintf("\tstate %d, priority %d, remaining quantum %d, critical section %d\n", t->state, t->priority, t->remaining_quantum, t->saved_critical_section_count);
-	dprintf("\tstack %p, stack_size %zd\n", t->stack, t->stack_size);
-	dprintf("\tentry %p, arg %p\n", t->entry, t->arg);
-	dprintf("\twait queue %p, wait queue ret %d\n", t->blocking_wait_queue, t->wait_queue_block_ret);
+	dprintf(INFO, "dump_thread: t %p (%s)\n", t, t->name);
+	dprintf(INFO, "\tstate %d, priority %d, remaining quantum %d, critical section %d\n", t->state, t->priority, t->remaining_quantum, t->saved_critical_section_count);
+	dprintf(INFO, "\tstack %p, stack_size %zd\n", t->stack, t->stack_size);
+	dprintf(INFO, "\tentry %p, arg %p\n", t->entry, t->arg);
+	dprintf(INFO, "\twait queue %p, wait queue ret %d\n", t->blocking_wait_queue, t->wait_queue_block_ret);
 }
 
 void dump_all_threads(void)
diff --git a/lib/debug/debug.c b/lib/debug/debug.c
index a7a717c..10b25a7 100644
--- a/lib/debug/debug.c
+++ b/lib/debug/debug.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <arch/ops.h>
 #include <platform.h>
+#include <platform/debug.h>
 #include <kernel/thread.h>
 
 void spin(uint32_t usecs)
@@ -42,31 +43,31 @@
 void halt(void)
 {
 	enter_critical_section(); // disable ints
-	for(;;);
+	platform_halt();
 }
 
 void _panic(void *caller, const char *fmt, ...)
 {
-	dprintf("panic (caller %p): ", caller);
+	dprintf(ALWAYS, "panic (caller %p): ", caller);
 
 	va_list ap;
 	va_start(ap, fmt);
-	dvprintf(fmt, ap);
+	_dvprintf(fmt, ap);
 	va_end(ap);
 
 	halt();
 }
 
-int dputs(const char *str)
+int _dputs(const char *str)
 {
 	while(*str != 0) {
-		dputc(*str++);
+		_dputc(*str++);
 	}
 
 	return 0;
 }
 
-int dprintf(const char *fmt, ...)
+int _dprintf(const char *fmt, ...)
 {
 	char buf[256];
 	int err;
@@ -76,19 +77,19 @@
 	err = vsprintf(buf, fmt, ap);
 	va_end(ap);
 
-	dputs(buf);
+	dputs(ALWAYS, buf);
 
 	return err;
 }
 
-int dvprintf(const char *fmt, va_list ap)
+int _dvprintf(const char *fmt, va_list ap)
 {
 	char buf[256];
 	int err;
 
 	err = vsprintf(buf, fmt, ap);
 
-	dputs(buf);
+	dputs(ALWAYS, buf);
 
 	return err;
 }
diff --git a/lib/heap/heap.c b/lib/heap/heap.c
index 575c6b8..2ed35c4 100644
--- a/lib/heap/heap.c
+++ b/lib/heap/heap.c
@@ -24,19 +24,33 @@
 #include <err.h>
 #include <list.h>
 #include <rand.h>
-#include <lib/heap.h>
+#include <string.h>
 #include <kernel/thread.h>
+#include <lib/heap.h>
+
+#define LOCAL_TRACE 0
 
 #define ROUNDUP(a, b) (((a) + ((b)-1)) & ~((b)-1))
 
 #define HEAP_MAGIC 'HEAP'
 
+#if WITH_STATIC_HEAP
+
+#if !defined(HEAP_START) || !defined(HEAP_LEN)
+#error WITH_STATIC_HEAP set but no HEAP_START or HEAP_LEN defined
+#endif
+
+#else
 // end of the binary
 extern int _end;
 
 // end of memory
 extern int _end_of_ram;
 
+#define HEAP_START ((unsigned long)&_end)
+#define HEAP_LEN ((size_t)&_end_of_ram - (size_t)&_end)
+#endif
+
 struct free_heap_chunk {
 	struct list_node node;
 	size_t len;
@@ -60,14 +74,14 @@
 
 static void dump_free_chunk(struct free_heap_chunk *chunk)
 {
-	dprintf("\t\tbase %p, end 0x%lx, len 0x%lx\n", chunk, (vaddr_t)chunk + chunk->len, chunk->len);
+	dprintf(INFO, "\t\tbase %p, end 0x%lx, len 0x%zx\n", chunk, (vaddr_t)chunk + chunk->len, chunk->len);
 }
 
 static void heap_dump(void)
 {
-	dprintf("Heap dump:\n");
-	dprintf("\tbase %p, len 0x%lx\n", theheap.base, theheap.len);
-	dprintf("\tfree list:\n");
+	dprintf(INFO, "Heap dump:\n");
+	dprintf(INFO, "\tbase %p, len 0x%zx\n", theheap.base, theheap.len);
+	dprintf(INFO, "\tfree list:\n");
 
 	struct free_heap_chunk *chunk;
 	list_for_every_entry(&theheap.free_list, chunk, struct free_heap_chunk, node) {
@@ -103,17 +117,17 @@
 		unsigned int index = (unsigned int)rand() % 16;
 		
 		if ((i % (16*1024)) == 0)
-			dprintf("pass %d\n", i);
+			printf("pass %d\n", i);
 
-//		dprintf("index 0x%x\n", index);
+//		printf("index 0x%x\n", index);
 		if (ptr[index]) {
-//			dprintf("freeing ptr[0x%x] = %p\n", index, ptr[index]);
+//			printf("freeing ptr[0x%x] = %p\n", index, ptr[index]);
 			heap_free(ptr[index]);
 			ptr[index] = 0;
 		}
 		unsigned int align = 1 << ((unsigned int)rand() % 8);
 		ptr[index] = heap_alloc((unsigned int)rand() % 32768, align);
-//		dprintf("ptr[0x%x] = %p, align 0x%x\n", index, ptr[index], align);
+//		printf("ptr[0x%x] = %p, align 0x%x\n", index, ptr[index], align);
 
 		DEBUG_ASSERT(((addr_t)ptr[index] % align) == 0);
 //		heap_dump();
@@ -131,7 +145,7 @@
 // nearby ones if possible. Returns base of whatever chunk it became in the list.
 static struct free_heap_chunk *heap_insert_free_chunk(struct free_heap_chunk *chunk)
 {
-#if DEBUG
+#if DEBUGLEVEL > INFO
 	vaddr_t chunk_end = (vaddr_t)chunk + chunk->len;
 #endif
 
@@ -199,7 +213,7 @@
 {
 	void *ptr;
 	
-//	dprintf("%s: size %zd, align %d\n", __PRETTY_FUNCTION__, size, alignment);
+	LTRACEF("size %zd, align %d\n", size, alignment);
 
 	// alignment must be power of 2
 	if (alignment & (alignment - 1))
@@ -278,7 +292,7 @@
 		}
 	}
 
-//	dprintf("%s: returning ptr %p\n", __PRETTY_FUNCTION__, ptr);
+	LTRACEF("returning ptr %p\n", ptr);
 
 //	heap_dump();
 
@@ -292,7 +306,7 @@
 	if (ptr == 0)
 		return;
 
-//	dprintf("%s: ptr %p\n", __PRETTY_FUNCTION__, ptr);
+	LTRACEF("ptr %p\n", ptr);
 
 	// check for the old allocation structure
 	struct alloc_struct_begin *as = (struct alloc_struct_begin *)ptr;
@@ -300,7 +314,7 @@
 	
 	DEBUG_ASSERT(as->magic == HEAP_MAGIC);
 
-//	dprintf("%s: allocation was %d bytes long at ptr %p\n", __FUNCTION__, as->size, as->ptr);
+	LTRACEF("allocation was %zd bytes long at ptr %p\n", as->size, as->ptr);
 
 	// looks good, create a free chunk and add it to the pool
 	enter_critical_section();
@@ -312,13 +326,13 @@
 
 void heap_init(void)
 {
-	dprintf("%s: entry\n", __PRETTY_FUNCTION__);
+	LTRACE_ENTRY;
 
 	// set the heap range
-	theheap.base = (void *)&_end;
-	theheap.len = ((unsigned) &_end_of_ram) - ((unsigned) &_end);
+	theheap.base = (void *)HEAP_START;
+	theheap.len = HEAP_LEN;
 
-	dprintf("%s: heap size %ld bytes\n", __PRETTY_FUNCTION__, theheap.len);
+	LTRACEF("base %p size %zd bytes\n", theheap.base, theheap.len);
 
 	// initialize the free list
 	list_initialize(&theheap.free_list);
@@ -327,10 +341,40 @@
 	heap_insert_free_chunk(heap_create_free_chunk(theheap.base, theheap.len));
 
 	// dump heap info
-	// heap_dump();
+//	heap_dump();
 
-//	dprintf("running heap tests\n");
+//	dprintf(INFO, "running heap tests\n");
 //	heap_test();
 }
 
+#if DEBUGLEVEL > 1
+#if WITH_APP_CONSOLE
+
+#include <app/console.h>
+
+static int cmd_heap(int argc, const cmd_args *argv);
+
+STATIC_COMMAND_START
+	{ "heap", "heap debug commands", &cmd_heap },
+STATIC_COMMAND_END(heap);
+
+static int cmd_heap(int argc, const cmd_args *argv)
+{
+	if (argc < 2) {
+		printf("not enough arguments\n");
+		return -1;
+	}
+
+	if (strcmp(argv[1].str, "info") == 0) {
+		heap_dump();
+	} else {
+		printf("unrecognized command\n");
+		return -1;
+	}
+
+	return 0;
+}
+
+#endif
+#endif
 
diff --git a/lib/libc/printf.c b/lib/libc/printf.c
index 806d5a9..af9379e 100644
--- a/lib/libc/printf.c
+++ b/lib/libc/printf.c
@@ -20,19 +20,35 @@
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+#include <debug.h>
 #include <limits.h>
 #include <stdarg.h>
 #include <sys/types.h>
 #include <printf.h>
 #include <string.h>
 
+void putc(char c)
+{
+	return _dputc(c);
+}
+
+int puts(const char *str)
+{
+	return _dputs(str);
+}
+
+int getc(char *c)
+{
+	return dgetc(c);
+}
+
 int printf(const char *fmt, ...)
 {
 	int err;
 
 	va_list ap;
 	va_start(ap, fmt);
-	err = dvprintf(fmt, ap);
+	err = _dvprintf(fmt, ap);
 	va_end(ap);
 
 	return err;
diff --git a/makefile b/makefile
index a40bda0..fe533da 100644
--- a/makefile
+++ b/makefile
@@ -2,7 +2,7 @@
 include macros.mk
 
 PROJECT ?= beagle-test
-DEBUG ?= 1
+DEBUG ?= 2
 
 BUILDDIR := build-$(PROJECT)
 OUTBIN := $(BUILDDIR)/lk.bin
diff --git a/platform/armemu/debug.c b/platform/armemu/debug.c
index aca3931..09aabd5 100644
--- a/platform/armemu/debug.c
+++ b/platform/armemu/debug.c
@@ -27,7 +27,7 @@
 #include <platform/armemu/memmap.h>
 #include <platform/debug.h>
 
-void dputc(char c)
+void _dputc(char c)
 {
 	*REG8(DEBUG_STDOUT) = c;
 }
@@ -48,7 +48,7 @@
 	*REG32(DEBUG_REGDUMP) = 1;
 }
 
-void debug_halt(void)
+void platform_halt(void)
 {
 	*REG32(DEBUG_HALT) = 1;
 	for(;;);
diff --git a/platform/at91sam7/debug.c b/platform/at91sam7/debug.c
index 2cca7b3..ad8f262 100644
--- a/platform/at91sam7/debug.c
+++ b/platform/at91sam7/debug.c
@@ -64,12 +64,12 @@
     }
 }
 
-void dputc(char c)
+void _dputc(char c)
 {
 	ser_putc(c);
 }
 
-void debug_halt()
+void platform_halt()
 {
 	arch_disable_ints();
     for(;;);
diff --git a/platform/at91sam7/emac_dev.c b/platform/at91sam7/emac_dev.c
index d042ef6..03a3237 100644
--- a/platform/at91sam7/emac_dev.c
+++ b/platform/at91sam7/emac_dev.c
@@ -20,6 +20,7 @@
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
+#include <debug.h>
 #include <kernel/thread.h>
 #include <kernel/mutex.h>
 #include <platform/at91sam7.h>
@@ -98,7 +99,7 @@
     AT91PMC *pmc = AT91PMC_ADDR;
     AT91RSTC *rstc = AT91RSTC_ADDR;
 
-    dprintf("emac_init()\n");
+    dprintf(INFO, "emac_init()\n");
     
         /* enable clock to EMAC */
     pmc->PCER = (1 << PID_EMAC);
@@ -119,7 +120,7 @@
 
     thread_sleep(30);
     
-    dprintf("emac_init() - reset phy\n");
+    dprintf(INFO, "emac_init() - reset phy\n");
 
         /* assert the RST line and wait until the it deasserts */
     rstc->CR = RSTC_KEY | RSTC_EXTRST;
@@ -135,14 +136,14 @@
     
     thread_sleep(1000);
     
-    dprintf("emac_init() - read state\n");
+    dprintf(INFO, "emac_init() - read state\n");
     
     emac->NCR = NCR_MPE;
     emac->NCFG = NCFG_CLK_d64;
 
-    dprintf("bcr = %x\n", mi_rd(emac, MII_REG_BCR));
-    dprintf("id1 = %x\n", mi_rd(emac, MII_REG_PHY_ID1));
-    dprintf("id2 = %x\n", mi_rd(emac, MII_REG_PHY_ID2));
+    dprintf(INFO, "bcr = %x\n", mi_rd(emac, MII_REG_BCR));
+    dprintf(INFO, "id1 = %x\n", mi_rd(emac, MII_REG_PHY_ID1));
+    dprintf(INFO, "id2 = %x\n", mi_rd(emac, MII_REG_PHY_ID2));
 
 #if 0
     unsigned state, last;
@@ -175,7 +176,7 @@
             default:
                 name = "unknown";
             }
-            dprintf("link state: %s\n", name);
+            dprintf(INFO, "link state: %s\n", name);
         }
         thread_sleep(100);
     } 
@@ -225,7 +226,7 @@
         waited++;
     }
 
-    if(waited) dprintf("W%d\n",waited);
+    if(waited) dprintf(INFO, "W%d\n",waited);
     
     if(xe->addr != 0) {
         free((void*) xe->addr);
diff --git a/platform/at91sam7/timer.c b/platform/at91sam7/timer.c
index 52224c5..be65e9c 100644
--- a/platform/at91sam7/timer.c
+++ b/platform/at91sam7/timer.c
@@ -21,6 +21,7 @@
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #include <err.h>
+#include <debug.h>
 #include <sys/types.h>
 
 #include <kernel/thread.h>
@@ -76,7 +77,7 @@
     AT91PIT *pit = AT91PIT_ADDR;
 
     n = AT91_MCK_MHZ / 16 / 1000;
-    dprintf("timer: MCK=%dKHz, n=%d\n", AT91_MCK_MHZ / 1000, n);
+    dprintf(INFO, "timer: MCK=%dKHz, n=%d\n", AT91_MCK_MHZ / 1000, n);
 
     enter_critical_section();
     
diff --git a/platform/integrator/debug.c b/platform/integrator/debug.c
index ab9f901..0a2e058 100644
--- a/platform/integrator/debug.c
+++ b/platform/integrator/debug.c
@@ -93,7 +93,7 @@
 	return -1;
 }
 
-void dputc(char c)
+void _dputc(char c)
 {
 	uart_putc(0, c);
 }
@@ -114,9 +114,9 @@
 	PANIC_UNIMPLEMENTED;
 }
 
-void debug_halt(void)
+void platform_halt(void)
 {
-	dprintf("HALT: spinning forever...\n");
+	dprintf(ALWAYS, "HALT: spinning forever...\n");
 	for(;;);
 }
 
diff --git a/platform/omap3/debug.c b/platform/omap3/debug.c
index 973287b..ac6300d 100644
--- a/platform/omap3/debug.c
+++ b/platform/omap3/debug.c
@@ -30,7 +30,7 @@
 #include <dev/uart.h>
 #include <target/debugconfig.h>
 
-void dputc(char c)
+void _dputc(char c)
 {
 	if (c == '\n')
 		uart_putc(DEBUG_UART, '\r');
@@ -53,9 +53,9 @@
 	PANIC_UNIMPLEMENTED;
 }
 
-void debug_halt(void)
+void platform_halt(void)
 {
-	dprintf("HALT: spinning forever...\n");
+	dprintf(ALWAYS, "HALT: spinning forever...\n");
 	for(;;);
 }
 
diff --git a/platform/omap5912/debug.c b/platform/omap5912/debug.c
index cb3ea29..d190fa0 100644
--- a/platform/omap5912/debug.c
+++ b/platform/omap5912/debug.c
@@ -87,7 +87,7 @@
 	return read_uart_reg(port, UART_RHR);
 }
 
-void dputc(char c)
+void _dputc(char c)
 {
 	if (c == '\n')
 		uart_putc(0, '\r');
@@ -110,9 +110,9 @@
 	PANIC_UNIMPLEMENTED;
 }
 
-void debug_halt(void)
+void platform_halt(void)
 {
-	dprintf("HALT: spinning forever...\n");
+	dprintf(ALWAYS, "HALT: spinning forever...\n");
 	for(;;);
 }