]> git.corax.cc Git - corax/commitdiff
Disable output from dbg_printf() once the init process has been spawned
authorMatthias Kruk <m@m10k.eu>
Tue, 31 Dec 2019 06:00:34 +0000 (15:00 +0900)
committerMatthias Kruk <m@m10k.eu>
Tue, 31 Dec 2019 06:00:34 +0000 (15:00 +0900)
kernel/arch/debug.c
kernel/core/main.c
kernel/include/debug.h

index 57750068d055973522e265e88c935fb8c7a6ebf3..68cf0f2525c7d970fbbb59e45029f217d24f538e 100644 (file)
@@ -58,6 +58,7 @@ static const char nullstr[] = "(null)";
 static u16_t* const vga_buffer = VGA_BUFFER_ADDR;
 static u16_t vga_attrs = VGA_FONT(VGA_LIGHT_GRAY) | VGA_BACKGROUND(VGA_BLACK);
 static i32_t vga_offset = VGA_BUFFER_SIZE;
+static int _early_printf_disable = 0;
 
 #define VGA_SET_FONT(c)         vga_attrs = (vga_attrs & 0xf0ff) | VGA_FONT(c)
 #define VGA_SET_BACKGROUND(c)   vga_attrs = (vga_attrs & 0x0fff) | VGA_BACKGROUND(c)
@@ -158,6 +159,12 @@ static void _putchar(int c)
     return;
 }
 
+void dbg_printf_disable(void)
+{
+       _early_printf_disable = 1;
+       return;
+}
+
 int dbg_printf(const char *format, ...)
 {
     int n;
@@ -169,6 +176,10 @@ int dbg_printf(const char *format, ...)
     int pad;
     const char *fmt;
 
+       if(_early_printf_disable) {
+               return(-1);
+       }
+
     #define MODE_NORMAL 0
     #define MODE_CONV   1
     #define FLAG_SIGN   (1 << 31)
index 96a016bd2d8ad257a21ea305e7643866ea9fcfa9..8bf0c9db55ad00964ec20a2d92eece8c3cf17642 100644 (file)
@@ -141,12 +141,13 @@ static void _init(void)
                /* FIXME: Handle error */
        }
 
+       #if 0
        struct cxmsg msg;
     char *hw = "Hello, world\n";
 
        memcpy(msg.cm_data, hw, 13);
        cxsendrecv(vgapid, &msg);
-
+       #endif
        wait(NULL);
 
        return;
@@ -240,6 +241,13 @@ int corax(void *mb_info, u32_t magic)
                PANIC("Could not spawn init process\n");
        }
 
+       /*
+        * Disable early printf - all further output should
+        * be printed through the VGA process that is spawned
+        * by init.
+        */
+       dbg_printf_disable();
+
        sched_tick();
 
        dbg_printf("This should not get printed\n");
index d642963c288eb87a2f134a994ec76480b4cff6d9..b03c3dc2a97c5626779f2d97a3b4937f8c19cf24 100644 (file)
@@ -30,5 +30,6 @@ i64_t _i64mod(i64_t, i64_t);
 
 int dbg_printf(const char*, ...);
 void dbg_panic(const char*, const char*, i32_t, const char*);
+void dbg_printf_disable(void);
 
 #endif /* __DEBUG_H */