cmd_cache.c 2.4 KB

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