1 | /* |
---|
2 | * Milkymist shutdown routine |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * COPYRIGHT (c) 2010 Sebastien Bourdeauducq |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.org/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | #include <bsp.h> |
---|
14 | #include <bsp/bootcard.h> |
---|
15 | #include "../include/system_conf.h" |
---|
16 | |
---|
17 | static void reboot(void) |
---|
18 | { |
---|
19 | /* Writing to CSR_SYSTEM_ID causes a system reset */ |
---|
20 | MM_WRITE(MM_SYSTEM_ID, 1); |
---|
21 | } |
---|
22 | |
---|
23 | static void icap_write(int val, unsigned int w) |
---|
24 | { |
---|
25 | while (!(MM_READ(MM_ICAP) & ICAP_READY)); |
---|
26 | if (!val) |
---|
27 | w |= ICAP_CE|ICAP_WRITE; |
---|
28 | MM_WRITE(MM_ICAP, w); |
---|
29 | } |
---|
30 | |
---|
31 | static void reconf(void) |
---|
32 | { |
---|
33 | icap_write(0, 0xffff); /* dummy word */ |
---|
34 | icap_write(0, 0xffff); /* dummy word */ |
---|
35 | icap_write(0, 0xffff); /* dummy word */ |
---|
36 | icap_write(0, 0xffff); /* dummy word */ |
---|
37 | icap_write(1, 0xaa99); /* sync word part 1 */ |
---|
38 | icap_write(1, 0x5566); /* sync word part 2 */ |
---|
39 | icap_write(1, 0x30a1); /* write to command register */ |
---|
40 | icap_write(1, 0x0000); /* null command */ |
---|
41 | icap_write(1, 0x30a1); /* write to command register */ |
---|
42 | icap_write(1, 0x000e); /* reboot command */ |
---|
43 | icap_write(1, 0x2000); /* NOP */ |
---|
44 | icap_write(1, 0x2000); /* NOP */ |
---|
45 | icap_write(1, 0x2000); /* NOP */ |
---|
46 | icap_write(1, 0x2000); /* NOP */ |
---|
47 | icap_write(0, 0x1111); /* NULL */ |
---|
48 | icap_write(0, 0xffff); /* dummy word */ |
---|
49 | } |
---|
50 | |
---|
51 | void bsp_fatal_extension( |
---|
52 | rtems_fatal_source source, |
---|
53 | bool always_set_to_false, |
---|
54 | rtems_fatal_code error |
---|
55 | ) |
---|
56 | { |
---|
57 | if (source == RTEMS_FATAL_SOURCE_EXIT && error) |
---|
58 | reconf(); |
---|
59 | else |
---|
60 | reboot(); |
---|
61 | } |
---|