mem_process.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * This file is part of FH8620 BSP for RT-Thread distribution.
  3. *
  4. * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd.
  5. * All rights reserved
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (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 along
  18. * with this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. *
  21. * Visit http://www.fullhan.com to get contact with Fullhan.
  22. *
  23. * Change Logs:
  24. * Date Author Notes
  25. */
  26. #include <rtthread.h>
  27. #include <rtdevice.h>
  28. #include "mmu.h"
  29. #define CHANGLINE_SIZE (1)
  30. //#define FH_DBG_MEM_PROCESS
  31. #ifdef FH_DBG_MEM_PROCESS
  32. void mem_input(rt_uint32_t t_addr, rt_uint32_t t_size, rt_uint8_t t_value) {
  33. rt_kprintf("mem process add:%x \tsize:%x\tvalue:%x\n", t_addr, t_size,
  34. t_value);
  35. rt_memset((void *) t_addr, t_value, t_size);
  36. mmu_clean_invalidated_dcache(t_addr, t_size);
  37. }
  38. void mem_output(rt_uint32_t t_addr, rt_uint32_t t_size) {
  39. rt_uint32_t i;
  40. rt_uint32_t cnt = 0;
  41. rt_uint32_t value;
  42. rt_uint32_t addr, size;
  43. addr = t_addr;
  44. if (t_size % 4) {
  45. rt_kprintf("mem must be alligned\n");
  46. }
  47. size = t_size / 4;
  48. rt_int32_t *p = (rt_uint32_t *) t_addr;
  49. //mmu_clean_invalidated_dcache(addr,t_size);
  50. rt_kprintf("mem process add:0x%x \tsize:0x%x\n", addr, t_size);
  51. rt_kprintf("0x%08x:", addr);
  52. for (i = 0; i < size; i++) {
  53. value = *p++;
  54. if ((cnt / CHANGLINE_SIZE) && (cnt % CHANGLINE_SIZE == 0)) {
  55. rt_kprintf("\n");
  56. }
  57. if (cnt / CHANGLINE_SIZE && (cnt % CHANGLINE_SIZE) == 0) {
  58. rt_kprintf("0x%08x:", addr + i * 4);
  59. }
  60. rt_kprintf("\t%08x", value);
  61. cnt++;
  62. }
  63. rt_kprintf("\n");
  64. }
  65. #endif
  66. #ifdef RT_USING_FINSH
  67. #include <finsh.h>
  68. #ifdef FH_DBG_MEM_PROCESS
  69. FINSH_FUNCTION_EXPORT(mem_input, mem_input(addr,size,value));
  70. FINSH_FUNCTION_EXPORT(mem_output, mem_output(add,size));
  71. #endif
  72. #endif