wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2002 |
| 3 | * Daniel Engström, Omicron Ceti AB, daniel@omicron.se. |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 4 | * |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 5 | * (C) Copyright 2002 |
| 6 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 7 | * Marius Groeger <mgroeger@sysgo.de> |
| 8 | * |
| 9 | * (C) Copyright 2002 |
| 10 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 11 | * Alex Zuepke <azu@sysgo.de> |
| 12 | * |
| 13 | * See file CREDITS for list of people who contributed to this |
| 14 | * project. |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License as |
| 18 | * published by the Free Software Foundation; either version 2 of |
| 19 | * the License, or (at your option) any later version. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program; if not, write to the Free Software |
| 28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 29 | * MA 02111-1307 USA |
| 30 | */ |
| 31 | |
| 32 | /* |
| 33 | * CPU specific code |
| 34 | */ |
| 35 | |
| 36 | #include <common.h> |
| 37 | #include <command.h> |
Graeme Russ | 3f5f18d | 2008-12-07 10:29:02 +1100 | [diff] [blame] | 38 | #include <asm/interrupt.h> |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 39 | |
Graeme Russ | 1c409bc | 2009-11-24 20:04:21 +1100 | [diff] [blame] | 40 | int cpu_init_f(void) |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 41 | { |
wdenk | 7a8e9bed | 2003-05-31 18:35:21 +0000 | [diff] [blame] | 42 | /* initialize FPU, reset EM, set MP and NE */ |
| 43 | asm ("fninit\n" \ |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 44 | "movl %cr0, %eax\n" \ |
| 45 | "andl $~0x4, %eax\n" \ |
| 46 | "orl $0x22, %eax\n" \ |
| 47 | "movl %eax, %cr0\n" ); |
| 48 | |
Graeme Russ | 1c409bc | 2009-11-24 20:04:21 +1100 | [diff] [blame] | 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | int cpu_init_r(void) |
| 53 | { |
Graeme Russ | abf0cd3 | 2009-02-24 21:13:40 +1100 | [diff] [blame] | 54 | /* Initialize core interrupt and exception functionality of CPU */ |
| 55 | cpu_init_interrupts (); |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 60 | { |
wdenk | 2262cfe | 2002-11-18 00:14:45 +0000 | [diff] [blame] | 61 | printf ("resetting ...\n"); |
| 62 | udelay(50000); /* wait 50 ms */ |
| 63 | disable_interrupts(); |
| 64 | reset_cpu(0); |
| 65 | |
| 66 | /*NOTREACHED*/ |
| 67 | return 0; |
| 68 | } |
| 69 | |
| 70 | void flush_cache (unsigned long dummy1, unsigned long dummy2) |
| 71 | { |
| 72 | asm("wbinvd\n"); |
| 73 | return; |
| 74 | } |
Graeme Russ | 3f5f18d | 2008-12-07 10:29:02 +1100 | [diff] [blame] | 75 | |
| 76 | void __attribute__ ((regparm(0))) generate_gpf(void); |
| 77 | |
| 78 | /* segment 0x70 is an arbitrary segment which does not exist */ |
| 79 | asm(".globl generate_gpf\n" |
Graeme Russ | 0fc1b49 | 2009-11-24 20:04:19 +1100 | [diff] [blame] | 80 | ".hidden generate_gpf\n" |
| 81 | ".type generate_gpf, @function\n" |
Graeme Russ | 3f5f18d | 2008-12-07 10:29:02 +1100 | [diff] [blame] | 82 | "generate_gpf:\n" |
| 83 | "ljmp $0x70, $0x47114711\n"); |
| 84 | |
| 85 | void __reset_cpu(ulong addr) |
| 86 | { |
| 87 | printf("Resetting using i386 Triple Fault\n"); |
| 88 | set_vector(13, generate_gpf); /* general protection fault handler */ |
| 89 | set_vector(8, generate_gpf); /* double fault handler */ |
| 90 | generate_gpf(); /* start the show */ |
| 91 | } |
| 92 | void reset_cpu(ulong addr) __attribute__((weak, alias("__reset_cpu"))); |