app_start.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "rtcompiler.h"
  12. #include "rtthread.h"
  13. extern int rtthread_startup(void);
  14. rt_weak void SVC_Handler(void)
  15. {
  16. }
  17. void APP_Start(void)
  18. {
  19. #if CONFIG_SOC_PS_MODULE
  20. SOCPS_InitSYSIRQ();
  21. #endif
  22. extern void PendSV_Handler(void);
  23. extern void SysTick_Handler(void);
  24. InterruptForOSInit((VOID*)SVC_Handler,
  25. (VOID*)PendSV_Handler,
  26. (VOID*)SysTick_Handler);
  27. #if defined ( __ICCARM__ )
  28. __iar_cstart_call_ctors(NULL);
  29. #endif
  30. // force SP align to 8 byte not 4 byte (initial SP is 4 byte align)
  31. __asm(
  32. "mov r0, sp\n"
  33. "bic r0, r0, #7\n"
  34. "mov sp, r0\n"
  35. );
  36. #ifdef RT_USING_USER_MAIN
  37. /* startup RT-Thread RTOS */
  38. rtthread_startup();
  39. #else
  40. extern int main(void);
  41. extern int $Super$$main(void);
  42. /* invoke system main function */
  43. #if defined (__CC_ARM)
  44. $Super$$main(); /* for ARMCC. */
  45. #elif defined(__ICCARM__) || defined(__GNUC__)
  46. main();
  47. #endif
  48. #endif
  49. }