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