app_start.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Routines to access hardware
  3. *
  4. * Copyright (c) 2013 Realtek Semiconductor Corp.
  5. *
  6. * This module is a confidential and proprietary property of RealTek and
  7. * possession or use of this module requires written permission of RealTek.
  8. */
  9. #include "ameba_soc.h"
  10. #include "build_info.h"
  11. #include "rtthread.h"
  12. extern int rtthread_startup(void);
  13. RT_WEAK void SVC_Handler(void)
  14. {
  15. }
  16. void APP_Start(void)
  17. {
  18. #if CONFIG_SOC_PS_MODULE
  19. SOCPS_InitSYSIRQ();
  20. #endif
  21. extern void PendSV_Handler(void);
  22. extern void SysTick_Handler(void);
  23. InterruptForOSInit((VOID*)SVC_Handler,
  24. (VOID*)PendSV_Handler,
  25. (VOID*)SysTick_Handler);
  26. #if defined ( __ICCARM__ )
  27. __iar_cstart_call_ctors(NULL);
  28. #endif
  29. // force SP align to 8 byte not 4 byte (initial SP is 4 byte align)
  30. __asm(
  31. "mov r0, sp\n"
  32. "bic r0, r0, #7\n"
  33. "mov sp, r0\n"
  34. );
  35. #ifdef RT_USING_USER_MAIN
  36. /* startup RT-Thread RTOS */
  37. rtthread_startup();
  38. #else
  39. extern int main(void);
  40. extern int $Super$$main(void);
  41. /* invoke system main function */
  42. #if defined (__CC_ARM)
  43. $Super$$main(); /* for ARMCC. */
  44. #elif defined(__ICCARM__) || defined(__GNUC__)
  45. main();
  46. #endif
  47. #endif
  48. }