]> git.corax.cc Git - corax/commitdiff
Correctly check the return value of cxrecv() in vga daemon, print a message during...
authorMatthias Kruk <m@m10k.eu>
Fri, 31 Jan 2020 11:26:41 +0000 (20:26 +0900)
committerMatthias Kruk <m@m10k.eu>
Fri, 31 Jan 2020 11:26:41 +0000 (20:26 +0900)
kernel/vga/main.c

index 9b4d162055c1c64fc459a52dbd4509b63a1db94f..41f2ac4b809b3fe90da753571a429d832deb5f2a 100644 (file)
@@ -2,6 +2,7 @@
 #include <corax/ipc.h>
 #include <crxstd.h>
 #include <string.h>
+#include <stdio.h>
 
 enum vgacolor {
        BLACK = 0,
@@ -71,6 +72,7 @@ static int _puts(struct context *ctx, const char *s)
 int vga_main(int argc, char *argv[])
 {
        struct context ctx;
+       char line[80];
 
        ctx.buffer = mmap(VGA_BUFFER_ADDR, 0x1000, PROT_READ | PROT_WRITE, MAP_PHYS, 0, 0);
 
@@ -83,16 +85,22 @@ int vga_main(int argc, char *argv[])
        ctx.attrs = FG(LGRAY) | BG(BLACK);
        memset(ctx.buffer, 0, VGA_BUFFER_SIZE);
 
+       snprintf(line, sizeof(line), "VGA video memory mapped at %p\n", ctx.buffer);
+       _puts(&ctx, line);
+
        while(1) {
                struct cxmsg msg;
                int err;
+               int i;
+
+               memset(&msg, 0, sizeof(msg));
 
                err = cxrecv(PID_ANY, &msg);
 
                /* FIXME: Validate message */
                /* FIXME: Only accept messages from IO process */
 
-               if(err > 0) {
+               if(!err) {
                        err = _puts(&ctx, (const char*)msg.cm_data);
                }