📄 start12.lst
字号:
ANSI-C/cC++ Compiler for HC12 V-5.0.30 Build 6157, Jun 7 2006
1: /*****************************************************
2: start12.c - standard startup code
3: The startup code may be optimized to special user requests
4: ----------------------------------------------------
5: Copyright (c) Metrowerks, Basel, Switzerland
6: All rights reserved
7:
8: Note: ROM libraries are not implemented in this startup code
9: Note: C++ destructors of global objects are NOT yet supported in the HIWARE Object File Format.
10: To use this feature, please build your application with the ELF object file format.
11:
12:
13: *MG* >>>>>>>>>>>>>>>>> 21/09/06 Martyn Gallop, MCD Applications, EKB, FSL <<<<<<<<<<<<<<<<<<<<<
14: Minor modification to move the _Startup routine to the beginning of the file so that
15: it gets built before the Init routine (added a prototype for Init). This results in the reset
16: vector being at the start of code in this module rather than in the middle. It also means that
17: the start vector does not change when using the __ONLY_INIT_SP switch.
18: .
19:
20: *****************************************************/
21: /*lint -esym(750, __NO_FLAGS_OFFSET, __NO_MAIN_OFFSET, __NO_STACKOFFSET_OFFSET) */
22: /* these macros remove some unused fields in the startup descriptor */
23: #define __NO_FLAGS_OFFSET /* we do not need the flags field in the startup data descriptor */
24: #define __NO_MAIN_OFFSET /* we do not need the main field in the startup data descriptor */
25: #define __NO_STACKOFFSET_OFFSET /* we do not need the stackOffset field in the startup data descriptor */
26:
27: /*#define __BANKED_COPY_DOWN : allow to allocate .copy in flash area */
28: #if defined(__BANKED_COPY_DOWN) && (!defined(__HCS12X__) || !defined(__ELF_OBJECT_FILE_FORMAT__))
29: #error /* the __BANKED_COPY_DOWN switch is only supported for the HCS12X with ELF */
30: /* (and not for the HC12, HCS12 or for the HIWARE object file format) */
31: #endif
32:
33: #include "hidef.h"
34: #include "start12.h"
35: #include "s12x_peripherals.h"
36:
37:
38: /***************************************************************************/
39: /* Macros to control how the startup code handles the COP: */
40: /* #define _DO_FEED_COP_ : do feed the COP */
41: /* #define _DO_ENABLE_COP_: do enable the COP */
42: /* #define _DO_DISABLE_COP_: disable the COP */
43: /* Without defining any of these, the startup code does NOT handle the COP */
44: /***************************************************************************/
45: /* __ONLY_INIT_SP define: */
46: /* This define selects an shorter version of the startup code */
47: /* which only loads the stack pointer and directly afterwards calls */
48: /* main. This version does however NOT initialized global variables */
49: /* (So this version is not ANSI compliant!) */
50: /***************************************************************************/
51: /* __FAR_DATA define: */
52: /* By default, the startup code only supports to initialize the default */
53: /* kind of memory. If some memory is allocated far in the small or banked */
54: /* memory model, then the startup code only supports to initialize this */
55: /* memory blocks if __FAR_DATA is defined. If __FAR_DATA is not defined, */
56: /* then the linker will issue a message like */
57: /* "L1128: Cutting value _Range beg data member from 0xF01000 to 0x1000" */
58: /* and this startup code writes to the cutted address */
59: /***************************************************************************/
60: /* __BANKED_COPY_DOWN define: */
61: /* by default, the startup code assumes that the startup data structure */
62: /* _startupData, the zero out areas and the .copy section are all */
63: /* allocated in NON_BANKED memory. Especially the .copy section can be */
64: /* if there are many or large RAM areas to initialize. */
65: /* for the HCS12X, which also copies the XGATE RAM located code via .copy */
66: /* section, the startup code supports to allocate .copy in a banked flash */
67: /* The placement of .copy in the prm file has to be adapted when adding or */
68: /* removing the this macro. */
69: /* Note: This macro is only supported for the HCS12X and when using ELF */
70: /***************************************************************************/
71:
72: #ifdef __cplusplus
73: #define __EXTERN_C extern "C"
74: #else
75: #define __EXTERN_C
76: #endif
77:
78: __EXTERN_C void main(void); /* prototype of main function */
79: static void Init(void); /* prototype of Init function - MG 21/09/06 */
80:
81: #ifndef __ONLY_INIT_SP
82: #pragma DATA_SEG __NEAR_SEG STARTUP_DATA /* _startupData can be accessed using 16 bit accesses. */
83: /* This is needed because it contains the stack top, and without stack, far data cannot be accessed */
84: /*lint -e1065 */
85: struct _tagStartup _startupData; /* read-only: */
86: /* _startupData is allocated in ROM and */
87: /* initialized by the linker */
88: /*lint +e1065 */
89: #pragma DATA_SEG DEFAULT
90: #endif /* __ONLY_INIT_SP */
91:
92: #if defined(FAR_DATA) && (!defined(__HCS12X__) || defined(__BANKED_COPY_DOWN))
93: #include "non_bank.sgm"
94: /* the init function must be in non banked memory if banked variables are used */
95: /* because _SET_PAGE is called, which may change any page register. */
96:
97: __EXTERN_C void _SET_PAGE(void); /* the inline assembler needs a prototype */
98: /* this is a runtime routine with a special */
99: /* calling convention, do not use it in c code! */
100: #else
101: #include "default.sgm"
102: #endif /* defined(FAR_DATA) && (!defined(__HCS12X__) || defined(__BANKED_COPY_DOWN)) */
103:
104:
105: /* define value and bits for Windef Register */
106: #ifdef HC812A4
107: #define WINDEF (*(volatile unsigned char*) 0x37)
108: #if defined( __BANKED__) || defined(__LARGE__) || defined(__PPAGE__)
109: #define __ENABLE_PPAGE__ 0x40
110: #else
111: #define __ENABLE_PPAGE__ 0x0
112: #endif
113: #if defined(__DPAGE__)
114: #define __ENABLE_DPAGE__ 0x80
115: #else
116: #define __ENABLE_DPAGE__ 0x0
117: #endif
118: #if defined(__EPAGE__)
119: #define __ENABLE_EPAGE__ 0x20
120: #else
121: #define __ENABLE_EPAGE__ 0x0
122: #endif
123: #endif /* HC812A4 */
124:
125: #ifdef _HCS12_SERIALMON
126: /* for Monitor based software remap the RAM & EEPROM to adhere
127: to EB386. Edit RAM and EEPROM sections in PRM file to match these. */
128: #define ___INITRM (*(volatile unsigned char *) 0x0010)
129: #define ___INITRG (*(volatile unsigned char *) 0x0011)
130: #define ___INITEE (*(volatile unsigned char *) 0x0012)
131: #endif
132:
133: #if defined(_DO_FEED_COP_)
134: #define __FEED_COP_IN_HLI() } __asm movb #0x55, _COP_RST_ADR; __asm movb #0xAA, _COP_RST_ADR; __asm {
135: #else
136: #define __FEED_COP_IN_HLI() /* do nothing */
137: #endif
138:
139: #include "non_bank.sgm"
140:
141: #pragma MESSAGE DISABLE C12053 /* Stack-pointer change not in debugging-information */
142: #pragma NO_FRAME
143: #pragma NO_ENTRY
144: #if !defined(__SMALL__)
145: #pragma NO_EXIT
146: #endif
147:
148: /* The function _Startup must be called in order to initialize global variables and to call main */
149: /* You can adapt this function or call it from your startup code to implement a different startup */
150: /* functionality. */
151:
152: /* You should also setup the needed IO registers as WINDEF (HC12A4 only) or the COP registers to run */
153: /* on hardware */
154:
155: /* to set the reset vector several ways are possible : */
156: /* 1. define the function with "interrupt 0" as done below in the first case */
157: /* 2. add the following line to your prm file : VECTOR ADDRESS 0xfffe _Startup */
158: /* of course, even more posibilities exists */
159: /* the reset vector must be set so that the application has a defined entry point */
160:
161: #if defined(__SET_RESET_VECTOR__)
162: __EXTERN_C void __interrupt 0 _Startup(void) {
163: #else
164: __EXTERN_C void _Startup(void) {
Function: _Startup
Source : D:\Profiles\b06321\My Documents\S12X\S12XE - Sailfish\Training\Training REV0\Solutions\Example 9\Sources\start12.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -