Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /*
0002  *  Milkymist shutdown routine
0003  */
0004 
0005 /*
0006  *  COPYRIGHT (c) 2010 Sebastien Bourdeauducq
0007  *
0008  *  The license and distribution terms for this file may be
0009  *  found in the file LICENSE in this distribution or at
0010  *  http://www.rtems.org/license/LICENSE.
0011  */
0012 
0013 #include <bsp.h>
0014 #include <bsp/bootcard.h>
0015 #include "../include/system_conf.h"
0016 
0017 static void reboot(void)
0018 {
0019   /* Writing to CSR_SYSTEM_ID causes a system reset */
0020   MM_WRITE(MM_SYSTEM_ID, 1);
0021 }
0022 
0023 static void icap_write(int val, unsigned int w)
0024 {
0025   while (!(MM_READ(MM_ICAP) & ICAP_READY));
0026   if (!val)
0027     w |= ICAP_CE|ICAP_WRITE;
0028   MM_WRITE(MM_ICAP, w);
0029 }
0030 
0031 static void reconf(void)
0032 {
0033   icap_write(0, 0xffff); /* dummy word */
0034   icap_write(0, 0xffff); /* dummy word */
0035   icap_write(0, 0xffff); /* dummy word */
0036   icap_write(0, 0xffff); /* dummy word */
0037   icap_write(1, 0xaa99); /* sync word part 1 */
0038   icap_write(1, 0x5566); /* sync word part 2 */
0039   icap_write(1, 0x30a1); /* write to command register */
0040   icap_write(1, 0x0000); /* null command */
0041   icap_write(1, 0x30a1); /* write to command register */
0042   icap_write(1, 0x000e); /* reboot command */
0043   icap_write(1, 0x2000); /* NOP */
0044   icap_write(1, 0x2000); /* NOP */
0045   icap_write(1, 0x2000); /* NOP */
0046   icap_write(1, 0x2000); /* NOP */
0047   icap_write(0, 0x1111); /* NULL */
0048   icap_write(0, 0xffff); /* dummy word */
0049 }
0050 
0051 void bsp_reset( rtems_fatal_source source, rtems_fatal_code code )
0052 {
0053   if (source == RTEMS_FATAL_SOURCE_EXIT && code)
0054     reconf();
0055   else
0056     reboot();
0057 
0058   RTEMS_UNREACHABLE();
0059 }