cmd_cache.c 2.5 KB

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