fixed a few formatting and string bugs, kprintf() working when called during bootstrapping!

git-svn-id: svn://anubis/hos/trunk@47 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh 2009-07-13 21:54:27 +00:00
parent a4d497544e
commit 5b9651299e
3 changed files with 12 additions and 5 deletions

View File

@ -48,6 +48,7 @@ u32_t k_bootstrap(mb_info_t * mb_info, u32_t mb_magic)
mm_bootstrap(); mm_bootstrap();
kio_bootstrap(); kio_bootstrap();
kprintf("Hello from kprintf()! %d, %x, %u, %l\n", 42, 0xabcd0123, 0xFFFFFFFF, -1234567891234ll);
return 0; return 0;
} }

View File

@ -21,7 +21,7 @@ extern "C" {
void kio_bootstrap() void kio_bootstrap()
{ {
cursor_x = 0; cursor_x = 0;
cursor_y = 8; cursor_y = 9;
} }
void kprintf(char * fmt, ...) void kprintf(char * fmt, ...)
@ -91,7 +91,7 @@ void kvprintf(char * fmt, va_list args)
void kputc(char c) void kputc(char c)
{ {
u16_t * console_memory = (u16_t *) CONSOLE_MEMORY; u16_t * console_memory = (u16_t *) (CONSOLE_MEMORY + KERNEL_OFFSET);
console_memory += 80 * cursor_y + cursor_x; console_memory += 80 * cursor_y + cursor_x;
switch (c) switch (c)
{ {
@ -110,6 +110,7 @@ void kputc(char c)
break; break;
default: default:
*console_memory = 0x0700 | (c & 0xFF); *console_memory = 0x0700 | (c & 0xFF);
cursor_x++;
break; break;
} }
if (cursor_x >= 80) if (cursor_x >= 80)
@ -166,10 +167,11 @@ static void fmt_u2a(char * buf, unsigned int val)
} }
if (printing) if (printing)
{ {
*buf++ = '0' + (val % div); *buf++ = '0' + n;
} }
val -= n * div; val -= n * div;
} }
*buf = '\0';
} }
static void fmt_ll2a(char * buf, long long val) static void fmt_ll2a(char * buf, long long val)
@ -201,10 +203,11 @@ static void fmt_ull2a(char * buf, unsigned long long val)
} }
if (printing) if (printing)
{ {
*buf++ = '0' + (val % div); *buf++ = '0' + n;
} }
val -= n * div; val -= n * div;
} }
*buf = '\0';
} }
static void fmt_x2a(char * buf, unsigned int val) static void fmt_x2a(char * buf, unsigned int val)
@ -219,9 +222,10 @@ static void fmt_x2a(char * buf, unsigned int val)
} }
if (printing) if (printing)
{ {
*buf++ = "0123456789ABCDEF"[n]; *buf++ = "0123456789abcdef"[n];
} }
} }
*buf = '\0';
} }
static void fmt_o2a(char * buf, unsigned int val) static void fmt_o2a(char * buf, unsigned int val)
@ -239,4 +243,5 @@ static void fmt_o2a(char * buf, unsigned int val)
*buf++ = "01234567"[n]; *buf++ = "01234567"[n];
} }
} }
*buf = '\0';
} }

View File

@ -9,6 +9,7 @@ void strcpy(char * dst, const char * src)
{ {
*dst++ = *src++; *dst++ = *src++;
} }
*dst = '\0';
} }
void memcpy(u8_t * dst, u8_t * src, u32_t size) void memcpy(u8_t * dst, u8_t * src, u32_t size)