cpu.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
  3. * Scott McNutt <smcnutt@psyent.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <nios.h>
  25. int checkcpu (void)
  26. {
  27. unsigned val;
  28. unsigned rev_major;
  29. unsigned rev_minor;
  30. short nregs, hi_limit, lo_limit;
  31. /* Get cpu version info */
  32. val = rdctl (CTL_CPU_ID);
  33. puts ("CPU: ");
  34. printf ("%s", (val & 0x00008000) ? "Nios-16 " : "Nios-32 ");
  35. rev_major = (val>>12) & 0x07;
  36. rev_minor = (val>>4) & 0x0ff;
  37. printf ("Rev. %d.%d (0x%04x)", rev_major, rev_minor,
  38. val & 0xffff);
  39. if (rev_major == 0x08)
  40. printf (" [OpenCore (R) Plus]");
  41. printf ("\n");
  42. /* Check register file */
  43. val = rdctl (CTL_WVALID);
  44. lo_limit = val & 0x01f;
  45. hi_limit = (val>>5) & 0x1f;
  46. nregs = (hi_limit + 2) * 16;
  47. printf ("Reg file size: %d LO_LIMIT/HI_LIMIT: %d/%d\n",
  48. nregs, lo_limit, hi_limit);
  49. return (0);
  50. }
  51. int do_reset (void)
  52. {
  53. /* trap 0 does the trick ... at least with the OCI debug
  54. * present -- haven't tested without it yet (stm).
  55. */
  56. disable_interrupts ();
  57. ipri (1);
  58. asm volatile ("trap 0\n");
  59. /* No return ;-) */
  60. return(0);
  61. }
  62. #if defined(CONFIG_WATCHDOG)
  63. void watchdog_reset (void)
  64. {
  65. }
  66. #endif /* CONFIG_WATCHDOG */