cpuport.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2010-07-09 Bernard first version
  9. * 2010-09-11 Bernard add CPU reset implementation
  10. * 2015-07-06 chinesebear modified for loongson 1c
  11. */
  12. #include <rtthread.h>
  13. #include "gs232.h"
  14. /**
  15. * @addtogroup Loongson GS232
  16. */
  17. /*@{*/
  18. /**
  19. * this function will reset CPU
  20. *
  21. */
  22. void rt_hw_cpu_reset(void)
  23. {
  24. /* open the watch-dog */
  25. WDT_EN = 0x01; /* watch dog enable */
  26. WDT_TIMER = 0x01; /* watch dog will be timeout after 1 tick */
  27. WDT_SET = 0x01; /* watch dog start */
  28. rt_kprintf("reboot system...\n");
  29. while (1);
  30. }
  31. #define Hit_Invalidate_I 0x10
  32. #define Hit_Invalidate_D 0x11
  33. #define CONFIG_SYS_CACHELINE_SIZE 32
  34. #define Hit_Writeback_Inv_D 0x15
  35. void flush_cache(unsigned long start_addr, unsigned long size)
  36. {
  37. unsigned long lsize = CONFIG_SYS_CACHELINE_SIZE;
  38. unsigned long addr = start_addr & ~(lsize - 1);
  39. unsigned long aend = (start_addr + size - 1) & ~(lsize - 1);
  40. while (1) {
  41. cache_op(Hit_Writeback_Inv_D, addr);
  42. cache_op(Hit_Invalidate_I, addr);
  43. if (addr == aend)
  44. break;
  45. addr += lsize;
  46. }
  47. }
  48. /*@}*/