blob: 2d5fb8f60b776b5345a63fd4e2e4e5c7b352105d [file] [log] [blame]
/*****************************************************************************/
/* BOOT.C v3.2.0 - Initialize the MSP430 C runtime environment */
/* Copyright (c) 2003-2009 Texas Instruments Incorporated */
/*****************************************************************************/
#include <stdlib.h>
#include <_lock.h>
extern int _args_main();
extern int main(int argc);
extern void exit(int status);
extern void _auto_init();
extern void __interrupt _c_int00();
extern int _system_pre_init(void);
void (*_cleanup_ptr)(void);
void _DATA_ACCESS (*_dtors_ptr)(int);
/*---------------------------------------------------------------------------*/
/* Allocate the memory for the system stack. This section will be sized */
/* by the linker. */
/*---------------------------------------------------------------------------*/
__asm("\t.global __STACK_END");
#pragma DATA_SECTION (_stack, ".stack");
#if defined(__LARGE_DATA_MODEL__)
long _stack;
#else
int _stack;
#endif
/*---------------------------------------------------------------------------*/
/* Initialize reset vector to point at _c_int00 */
/* _c_int00 must always be located in low-memory on MSP430X devices. */
/*---------------------------------------------------------------------------*/
#if defined(__LARGE_CODE_MODEL__)
_Pragma("CODE_SECTION(_c_int00, \".text:_isr\")")
#endif
__asm("\t.global _reset_vector");
__asm("\t.sect \".reset\"");
__asm("\t.align 2");
__asm("_reset_vector:\n\t.field _c_int00, 16");
/*---------------------------------------------------------------------------*/
/* Macro to initialize stack pointer. Stack grows towards lower memory. */
/*---------------------------------------------------------------------------*/
#if defined(__LARGE_DATA_MODEL__)
#define STACK_INIT() __asm("\t MOVX.A\t #__STACK_END,SP")
#else
#define STACK_INIT() __asm("\t MOV.W\t #__STACK_END,SP")
#endif
/*---------------------------------------------------------------------------*/
/* Macros to initialize required global variables. */
/*---------------------------------------------------------------------------*/
#define INIT_LOCKS() _lock = _nop; _unlock = _nop
#define INIT_EXIT_PTRS() _cleanup_ptr = NULL; _dtors_ptr = NULL
/*****************************************************************************/
/* C_INT00() - C ENVIRONMENT ENTRY POINT */
/*****************************************************************************/
extern void __interrupt _c_int00()
{
STACK_INIT();
INIT_EXIT_PTRS();
/*------------------------------------------------------------------------*/
/* Allow for any application-specific low level initialization prior to */
/* initializing the C/C++ environment (global variable initialization, */
/* constructers). If _system_pre_init() returns 0, then bypass C/C++ */
/* initialization. NOTE: BYPASSING THE CALL TO THE C/C++ INITIALIZATION */
/* ROUTINE MAY RESULT IN PROGRAM FAILURE. */
/*------------------------------------------------------------------------*/
if (_system_pre_init() != 0) {
INIT_LOCKS();
_auto_init();
}
/*------------------------------------------------------------------------*/
/* Handle any argc/argv arguments if supported by an MSP430 loader. */
/*------------------------------------------------------------------------*/
_args_main();
exit(1);
}