diff options
Diffstat (limited to 'kernel/printf.c')
-rw-r--r-- | kernel/printf.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/kernel/printf.c b/kernel/printf.c index 0b51f8d..61237aa 100644 --- a/kernel/printf.c +++ b/kernel/printf.c @@ -1,13 +1,6 @@ #include "printf.h" #include "types.h" -#include "portio.h" - -void putchar(char c) { - if(c == '\n') { - outb(0x3f8, '\r'); - } - outb(0x3f8, c); -} +#include "framebuffer.h" int printf(const char* format, ...) { int32_t* argp = (int32_t*)&format; @@ -15,7 +8,7 @@ int printf(const char* format, ...) { while(*format) { if(*format != '%') { - putchar(*format++); + framebuffer_putchar(*format++); num++; continue; } @@ -36,12 +29,12 @@ int printf(const char* format, ...) { switch(*format++) { case '%': - putchar('%'); + framebuffer_putchar('%'); num++; break; case 'c': - putchar((char)*++argp); + framebuffer_putchar((char)*++argp); num++; break; @@ -49,7 +42,7 @@ int printf(const char* format, ...) { ; char* str = (char*)*++argp; while(*str) { - putchar(*str++); + framebuffer_putchar(*str++); num++; } break; @@ -63,7 +56,7 @@ int printf(const char* format, ...) { uint32_t x = (uint32_t)*(++argp); if(is_signed && (int32_t)x < 0) { x = -x; - putchar('-'); + framebuffer_putchar('-'); min_len--; } @@ -79,17 +72,20 @@ int printf(const char* format, ...) { } while(x); while(min_len > 0) { - putchar(zero_pad ? '0' : ' '); + framebuffer_putchar(zero_pad ? '0' : ' '); num++; min_len--; } while(*bufp) { - putchar(*bufp++); + framebuffer_putchar(*bufp++); num++; } break; } } + + framebuffer_move_cursor(); + return num; } |