cmd_cache.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  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. /*
  24. * Cache support: switch on or off, get status
  25. */
  26. #include <common.h>
  27. #include <command.h>
  28. static int on_off (const char *);
  29. int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  30. {
  31. switch (argc) {
  32. case 2: /* on / off */
  33. switch (on_off(argv[1])) {
  34. #if 0 /* prevented by varargs handling; FALLTROUGH is harmless, too */
  35. default: cmd_usage(cmdtp);
  36. return;
  37. #endif
  38. case 0: icache_disable();
  39. break;
  40. case 1: icache_enable ();
  41. break;
  42. }
  43. /* FALL TROUGH */
  44. case 1: /* get status */
  45. printf ("Instruction Cache is %s\n",
  46. icache_status() ? "ON" : "OFF");
  47. return 0;
  48. default:
  49. cmd_usage(cmdtp);
  50. return 1;
  51. }
  52. return 0;
  53. }
  54. int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  55. {
  56. switch (argc) {
  57. case 2: /* on / off */
  58. switch (on_off(argv[1])) {
  59. #if 0 /* prevented by varargs handling; FALLTROUGH is harmless, too */
  60. default: cmd_usage(cmdtp);
  61. return;
  62. #endif
  63. case 0: dcache_disable();
  64. break;
  65. case 1: dcache_enable ();
  66. break;
  67. }
  68. /* FALL TROUGH */
  69. case 1: /* get status */
  70. printf ("Data (writethrough) Cache is %s\n",
  71. dcache_status() ? "ON" : "OFF");
  72. return 0;
  73. default:
  74. cmd_usage(cmdtp);
  75. return 1;
  76. }
  77. return 0;
  78. }
  79. static int on_off (const char *s)
  80. {
  81. if (strcmp(s, "on") == 0) {
  82. return (1);
  83. } else if (strcmp(s, "off") == 0) {
  84. return (0);
  85. }
  86. return (-1);
  87. }
  88. U_BOOT_CMD(
  89. icache, 2, 1, do_icache,
  90. "enable or disable instruction cache",
  91. "[on, off]\n"
  92. " - enable or disable instruction cache"
  93. );
  94. U_BOOT_CMD(
  95. dcache, 2, 1, do_dcache,
  96. "enable or disable data cache",
  97. "[on, off]\n"
  98. " - enable or disable data (writethrough) cache"
  99. );