board.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * File : board.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #include "board.h"
  17. #include <stdlib.h>
  18. #include <windows.h>
  19. /**
  20. * @addtogroup simulator on win32
  21. */
  22. rt_uint8_t *heap;
  23. rt_uint8_t *rt_hw_sram_init(void)
  24. {
  25. rt_uint8_t *heap;
  26. heap = malloc(HEAP_SIZE);
  27. if (heap == RT_NULL)
  28. {
  29. rt_kprintf("there is no memory in pc.");
  30. _exit(1);
  31. }
  32. return heap;
  33. }
  34. void rt_hw_win32_low_cpu(void)
  35. {
  36. Sleep(1000);
  37. }
  38. #if defined(RT_USING_FINSH)
  39. #ifndef _CRT_TERMINATE_DEFINED
  40. #define _CRT_TERMINATE_DEFINED
  41. _CRTIMP __declspec(noreturn) void __cdecl exit(__in int _Code);
  42. _CRTIMP __declspec(noreturn) void __cdecl _exit(__in int _Code);
  43. _CRTIMP void __cdecl abort(void);
  44. #endif
  45. #include <finsh.h>
  46. void rt_hw_exit(void)
  47. {
  48. rt_kprintf("RT-Thread, bye\n");
  49. exit(0);
  50. }
  51. FINSH_FUNCTION_EXPORT_ALIAS(rt_hw_exit, exit, exit rt - thread);
  52. #endif /* RT_USING_FINSH */
  53. /**
  54. * This function will initial win32
  55. */
  56. void rt_hw_board_init()
  57. {
  58. /* init system memory */
  59. heap = rt_hw_sram_init();
  60. #if defined(RT_USING_CONSOLE)
  61. rt_hw_usart_init();
  62. rt_hw_serial_init();
  63. rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
  64. #endif
  65. }
  66. /*@}*/