cleanup
[rpikern] / src / main.c
index 0c8bdf5..db2ab86 100644 (file)
@@ -1,14 +1,16 @@
 #include "config.h"
 
+#include <stdio.h>
 #include <string.h>
 #include <stdint.h>
 #include <ctype.h>
 #include "asm.h"
+#include "rpi.h"
+#include "contty.h"
 #include "serial.h"
 #include "video.h"
 
 void dbgled(int x);
-void exit(int x);
 
 static void cmdrun(char *cmd);
 
@@ -18,14 +20,17 @@ int main(void)
        static char cmdbuf[256];
        static int cmdend;
 
+       rpi_init();
        init_serial(115200);
-       ser_printstr("Starting rpikern\n");
+       con_init();
+
+       printf("Detected raspberry pi %d, I/O base: %x\n", rpi_model, rpi_iobase);
 
        video_init();
 
-       ser_printstr("Going interactive\n");
+       printf("Going interactive\n");
        for(;;) {
-               int c = ser_getchar();
+               int c = getchar();
 
                switch(c) {
                case '\r':
@@ -41,7 +46,7 @@ int main(void)
 
                case -1:
                        lastnl = 0;
-                       ser_printstr("error!\n");
+                       printf("error!\n");
                        break;
 
                default:
@@ -56,12 +61,6 @@ int main(void)
        return 0;
 }
 
-void panic(void)
-{
-       ser_printstr("PANIC!\n");
-       exit(0);
-}
-
 static void cmdrun(char *cmd)
 {
        char *ptr, *args;
@@ -73,12 +72,10 @@ static void cmdrun(char *cmd)
        args = ptr + 1;
 
        if(strcmp(cmd, "help") == 0) {
-               ser_printstr("help not implemented yet\n");
+               printf("help not implemented yet\n");
        } else if(strcmp(cmd, "ver") == 0) {
-               ser_printstr("rpikern version 0.0\n");
+               printf("rpikern version 0.0\n");
        } else {
-               ser_printstr("Unknown command: ");
-               ser_printstr(cmd);
-               ser_printstr("\n");
+               printf("Unknown command: %s\n", cmd);
        }
 }