blob: b9af5f89d532c11356b2f31f9bfe1a78e9604e98 [file] [log] [blame]
wdenk591dda52002-11-18 00:14:45 +00001/*
2 * (C) Copyright 2002
3 * Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
wdenk57b2d802003-06-27 21:31:46 +00004 *
wdenk591dda52002-11-18 00:14:45 +00005 * (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 Russ278638d2008-12-07 10:29:02 +110038#include <asm/interrupt.h>
wdenk591dda52002-11-18 00:14:45 +000039
40int cpu_init(void)
41{
wdenkabda5ca2003-05-31 18:35:21 +000042 /* initialize FPU, reset EM, set MP and NE */
43 asm ("fninit\n" \
wdenk57b2d802003-06-27 21:31:46 +000044 "movl %cr0, %eax\n" \
45 "andl $~0x4, %eax\n" \
46 "orl $0x22, %eax\n" \
47 "movl %eax, %cr0\n" );
48
wdenk591dda52002-11-18 00:14:45 +000049 return 0;
50}
51
52int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
53{
wdenk591dda52002-11-18 00:14:45 +000054 printf ("resetting ...\n");
55 udelay(50000); /* wait 50 ms */
56 disable_interrupts();
57 reset_cpu(0);
58
59 /*NOTREACHED*/
60 return 0;
61}
62
63void flush_cache (unsigned long dummy1, unsigned long dummy2)
64{
65 asm("wbinvd\n");
66 return;
67}
Graeme Russ278638d2008-12-07 10:29:02 +110068
69void __attribute__ ((regparm(0))) generate_gpf(void);
70
71/* segment 0x70 is an arbitrary segment which does not exist */
72asm(".globl generate_gpf\n"
73 "generate_gpf:\n"
74 "ljmp $0x70, $0x47114711\n");
75
76void __reset_cpu(ulong addr)
77{
78 printf("Resetting using i386 Triple Fault\n");
79 set_vector(13, generate_gpf); /* general protection fault handler */
80 set_vector(8, generate_gpf); /* double fault handler */
81 generate_gpf(); /* start the show */
82}
83void reset_cpu(ulong addr) __attribute__((weak, alias("__reset_cpu")));