cpu.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * (C) Copyright 2002
  3. * Daniel Engström, Omicron Ceti AB, daniel@omicron.se.
  4. *
  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. * CPU specific code
  33. */
  34. #include <common.h>
  35. #include <command.h>
  36. #include <asm/interrupt.h>
  37. int cpu_init(void)
  38. {
  39. /* initialize FPU, reset EM, set MP and NE */
  40. asm ("fninit\n" \
  41. "movl %cr0, %eax\n" \
  42. "andl $~0x4, %eax\n" \
  43. "orl $0x22, %eax\n" \
  44. "movl %eax, %cr0\n" );
  45. /* Initialize core interrupt and exception functionality of CPU */
  46. cpu_init_interrupts ();
  47. cpu_init_exceptions ();
  48. return 0;
  49. }
  50. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  51. {
  52. printf ("resetting ...\n");
  53. udelay(50000); /* wait 50 ms */
  54. disable_interrupts();
  55. reset_cpu(0);
  56. /*NOTREACHED*/
  57. return 0;
  58. }
  59. void flush_cache (unsigned long dummy1, unsigned long dummy2)
  60. {
  61. asm("wbinvd\n");
  62. return;
  63. }
  64. void __attribute__ ((regparm(0))) generate_gpf(void);
  65. /* segment 0x70 is an arbitrary segment which does not exist */
  66. asm(".globl generate_gpf\n"
  67. "generate_gpf:\n"
  68. "ljmp $0x70, $0x47114711\n");
  69. void __reset_cpu(ulong addr)
  70. {
  71. printf("Resetting using i386 Triple Fault\n");
  72. set_vector(13, generate_gpf); /* general protection fault handler */
  73. set_vector(8, generate_gpf); /* double fault handler */
  74. generate_gpf(); /* start the show */
  75. }
  76. void reset_cpu(ulong addr) __attribute__((weak, alias("__reset_cpu")));