reboot command
authorlekernel <sebastien.bourdeauducq@lekernel.net>
Fri, 13 Nov 2009 19:23:36 +0000 (20:23 +0100)
committerlekernel <sebastien.bourdeauducq@lekernel.net>
Fri, 13 Nov 2009 19:23:36 +0000 (20:23 +0100)
software/bios/boot.c
software/bios/main.c
software/demo/main.c
software/demo/shell.c
software/include/system.h
software/libbase/system.c
software/libbase/uart.c

index 5c7b786..7b41b65 100644 (file)
@@ -34,7 +34,7 @@ extern const struct board_desc *brd_desc;
  * put the values we want into the good registers because it has to respect
  * the LM32 calling conventions.
  */
-static void __attribute__((noinline)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr)
+static void __attribute__((noinline)) __attribute__((noreturn)) boot(unsigned int r1, unsigned int r2, unsigned int r3, unsigned int addr)
 {
        asm volatile( /* Invalidate instruction cache */
                "wcsr ICC, r0\n"
index 1d0d172..266a076 100644 (file)
@@ -91,7 +91,7 @@ static int plltest()
 
        if(!sdram_enabled) {
                printf("E: Command disabled\n");
-               return;
+               return 0;
        }
 
        printf("I: Checking if SDRAM clocking is functional:\n");
@@ -99,7 +99,7 @@ static int plltest()
        ok2 = CSR_HPDMC_IODELAY & HPDMC_PLL2_LOCKED;
        printf("I:   PLL#1: %s\n", ok1 ? "Locked" : "Error");
        printf("I:   PLL#2: %s\n", ok2 ? "Locked" : "Error");
-       return (ok1 && ok2);
+       return(ok1 && ok2);
 }
 
 static int memtest(unsigned int div)
@@ -111,7 +111,7 @@ static int memtest(unsigned int div)
 
        if(!sdram_enabled) {
                printf("E: Command disabled\n");
-               return;
+               return 0;
        }
        
        putsnonl("I: SDRAM test...");
@@ -384,8 +384,6 @@ static void crc(char *startaddr, char *len)
 
 /* CF filesystem functions */
 
-static int cf_enabled;
-
 static int lscb(const char *filename, const char *longname, void *param)
 {
        printf("%12s [%s]\n", filename, longname);
@@ -552,7 +550,22 @@ static const char banner[] =
        "it under the terms of the GNU General Public License as published by\n"
        "the Free Software Foundation, version 3 of the License.\n\n";
 
-int main(int warm_boot, int dummy)
+static void boot_sequence()
+{
+       splash_display((void *)(SDRAM_BASE+1024*1024*(brd_desc->sdram_size-4)));
+       if(test_user_abort()) {
+               serialboot(1);
+               if(brd_desc->memory_card != MEMCARD_NONE) {
+                       if(CSR_GPIO_IN & GPIO_DIP1)
+                               cardboot(1);
+                       else
+                               cardboot(0);
+               }
+               printf("E: No boot medium found\n");
+       }
+}
+
+int main(int warm_boot, char **dummy)
 {
        char buffer[64];
 
@@ -578,19 +591,9 @@ int main(int warm_boot, int dummy)
                                ddrinit();
                                flush_bridge_cache();
 
-                               if(memtest(8)) {
-                                       splash_display((void *)(SDRAM_BASE+1024*1024*(brd_desc->sdram_size-4)));
-                                       if(test_user_abort()) {
-                                               serialboot(1);
-                                               if(brd_desc->memory_card != MEMCARD_NONE) {
-                                                       if(CSR_GPIO_IN & GPIO_DIP1)
-                                                               cardboot(1);
-                                                       else
-                                                               cardboot(0);
-                                               }
-                                               printf("E: No boot medium found\n");
-                                       }
-                               } else
+                               if(memtest(8))
+                                       boot_sequence();
+                               else
                                        printf("E: Aborted boot on memory error\n");
                        } else
                                printf("E: Faulty SDRAM clocking\n");
@@ -601,6 +604,7 @@ int main(int warm_boot, int dummy)
        } else {
                printf("I: Warm boot\n");
                sdram_enabled = 0;
+               boot_sequence();
        }
 
        splash_showerr();
index 1f04894..d064385 100644 (file)
@@ -64,12 +64,12 @@ int main()
        time_init();
        mem_init();
        vga_init();
-       snd_init();
-       pfpu_init();
-       tmu_init();
-       renderer_init();
-       apipe_init();
-       rpipe_init();
+       //snd_init();
+       //pfpu_init();
+       //tmu_init();
+       //renderer_init();
+       //apipe_init();
+       //rpipe_init();
        slowout_init();
        hdlcd_init();
        ps2_init();
index be338c9..9031a9e 100644 (file)
@@ -207,6 +207,7 @@ static void help()
        puts("stop       - stop renderer");
        puts("spam       - start/stop advertising");
        puts("stats      - print system stats");
+       puts("reboot     - warm reboot");
 }
 
 /*
@@ -427,6 +428,7 @@ static void do_command(char *c)
        else if(strcmp(command, "stop") == 0) ui_render_stop();
        else if(strcmp(command, "spam") == 0) spam();
        else if(strcmp(command, "stats") == 0) stats();
+       else if(strcmp(command, "reboot") == 0) reboot();
        else if(strcmp(command, "help") == 0) help();
 
        /* Test functions and hacks */
index ce27505..07a38e5 100644 (file)
@@ -1,16 +1,16 @@
 /*
  * Milkymist VJ SoC (Software)
  * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
- * 
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, version 3 of the License.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
@@ -19,5 +19,6 @@
 #define __SYSTEM_H
 
 void flush_bridge_cache();
+__attribute__((noreturn)) void reboot();
 
 #endif /* __SYSTEM_H */
index 04a0f2b..d0cf84c 100644 (file)
@@ -1,21 +1,24 @@
 /*
  * Milkymist VJ SoC (Software)
  * Copyright (C) 2007, 2008, 2009 Sebastien Bourdeauducq
- * 
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation, version 3 of the License.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <irq.h>
+#include <uart.h>
 #include <hw/fmlbrg.h>
+
 #include <system.h>
 
 void flush_bridge_cache()
@@ -29,3 +32,14 @@ void flush_bridge_cache()
                offset += FMLBRG_LINE_LENGTH;
        }
 }
+
+__attribute__((noreturn)) void reboot()
+{
+       uart_force_sync(1); /* flush UART buffers */
+       irq_setmask(0);
+       irq_enable(0);
+       asm volatile(
+               "ori r1, r0, 0x0100\n"
+               "call r1\n"
+       );
+}
index e6c9f34..7beaaa8 100644 (file)
@@ -44,3 +44,7 @@ int readchar_nonblock()
        else
                return 0;
 }
+
+void uart_force_sync(int f)
+{
+}