cmd_mp.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <command.h>
  24. int
  25. cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  26. {
  27. unsigned long cpuid, val = 0;
  28. if (argc < 3) {
  29. printf ("Usage:\n%s\n", cmdtp->usage);
  30. return 1;
  31. }
  32. cpuid = simple_strtoul(argv[1], NULL, 10);
  33. if (cpuid >= CONFIG_NR_CPUS) {
  34. printf ("Core num: %d is out of range[0..%d]\n",
  35. cpuid, CONFIG_NR_CPUS - 1);
  36. return 1;
  37. }
  38. if (argc == 3) {
  39. if (strncmp(argv[2], "reset", 5) == 0) {
  40. cpu_reset(cpuid);
  41. } else if (strncmp(argv[2], "status", 6) == 0) {
  42. cpu_status(cpuid);
  43. } else {
  44. printf ("Usage:\n%s\n", cmdtp->usage);
  45. return 1;
  46. }
  47. return 0;
  48. }
  49. /* 4 or greater, make sure its release */
  50. if (strncmp(argv[2], "release", 7) != 0) {
  51. printf ("Usage:\n%s\n", cmdtp->usage);
  52. return 1;
  53. }
  54. val = simple_strtoul(argv[3], NULL, 16);
  55. if (cpu_release(cpuid, val, argc - 4, argv + 4)) {
  56. printf ("Usage:\n%s\n", cmdtp->usage);
  57. return 1;
  58. }
  59. return 0;
  60. }
  61. #ifdef CONFIG_PPC
  62. #define CPU_ARCH_HELP \
  63. " [args] : <pir> <r3> <r4> <r6> <r7>\n" \
  64. " pir - processor id (if writeable)\n" \
  65. " r3 - value for gpr 3\n" \
  66. " r4 - value for gpr 4\n" \
  67. " r6 - value for gpr 6\n" \
  68. " r7 - value for gpr 7\n" \
  69. "\n" \
  70. " Use '-' for any arg if you want the default value.\n" \
  71. " Default for r3, r4, r7 is 0, r6 is 0x65504150\n" \
  72. "\n" \
  73. " When cpu <num> is released r5 = 0 per the ePAPR spec.\n"
  74. #endif
  75. U_BOOT_CMD(
  76. cpu, CFG_MAXARGS, 1, cpu_cmd,
  77. "cpu - Multiprocessor CPU boot manipulation and release\n",
  78. "<num> reset - Reset cpu <num>\n"
  79. "cpu <num> status - Status of cpu <num>\n"
  80. "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]\n"
  81. #ifdef CPU_ARCH_HELP
  82. CPU_ARCH_HELP
  83. #endif
  84. );