iLLD_TC29x  1.0
CompilerGnuc.c
Go to the documentation of this file.
1 /**
2  * \file CompilerGnuc.c
3  *
4  * \version iLLD_1_0_0_11_0
5  * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
6  *
7  *
8  * IMPORTANT NOTICE
9  *
10  *
11  * Infineon Technologies AG (Infineon) is supplying this file for use
12  * exclusively with Infineon's microcontroller products. This file can be freely
13  * distributed within development tools that are supporting such microcontroller
14  * products.
15  *
16  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
17  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
19  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
20  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
21  *
22  */
23 
24 #include "Cpu/Std/Ifx_Types.h"
25 #include "Compilers.h"
26 
27 #if defined(__GNUC__) && !defined(WIN32)
28 /*!
29  * \brief Data s C variables.
30  */
31 extern uint32 __clear_table[]; /**< clear table entry */
32 extern uint32 __copy_table[]; /**< copy table entry */
33 
34 typedef volatile union
35 {
36  uint8 *ucPtr;
37  uint16 *usPtr;
38  uint32 *uiPtr;
39  unsigned long long *ullPtr;
40 } IfxStart_CTablePtr;
41 
42 /*!
43  * \brief Initializes C variables.
44  *
45  * This function is called in the startup. This function initialize the all variables in .data section
46  * and clears the .bss section
47  *
48  * Parameters: Nil
49  * Return: Nil
50  */
51 void Ifx_C_Init(void)
52 {
53  IfxStart_CTablePtr pBlockDest, pBlockSrc;
54  uint32 uiLength, uiCnt;
55  uint32 *pTable;
56  /* clear table */
57  pTable = (uint32 *)&__clear_table;
58 
59  while (pTable)
60  {
61  pBlockDest.uiPtr = (uint32 *)*pTable++;
62  uiLength = *pTable++;
63 
64  /* we are finished when length == -1 */
65  if (uiLength == 0xFFFFFFFF)
66  {
67  break;
68  }
69 
70  uiCnt = uiLength / 8;
71 
72  while (uiCnt--)
73  {
74  *pBlockDest.ullPtr++ = 0;
75  }
76 
77  if (uiLength & 0x4)
78  {
79  *pBlockDest.uiPtr++ = 0;
80  }
81 
82  if (uiLength & 0x2)
83  {
84  *pBlockDest.usPtr++ = 0;
85  }
86 
87  if (uiLength & 0x1)
88  {
89  *pBlockDest.ucPtr = 0;
90  }
91  }
92 
93  /* copy table */
94  pTable = (uint32 *)&__copy_table;
95 
96  while (pTable)
97  {
98  pBlockSrc.uiPtr = (uint32 *)*pTable++;
99  pBlockDest.uiPtr = (uint32 *)*pTable++;
100  uiLength = *pTable++;
101 
102  /* we are finished when length == -1 */
103  if (uiLength == 0xFFFFFFFF)
104  {
105  break;
106  }
107 
108  uiCnt = uiLength / 8;
109 
110  while (uiCnt--)
111  {
112  *pBlockDest.ullPtr++ = *pBlockSrc.ullPtr++;
113  }
114 
115  if (uiLength & 0x4)
116  {
117  *pBlockDest.uiPtr++ = *pBlockSrc.uiPtr++;
118  }
119 
120  if (uiLength & 0x2)
121  {
122  *pBlockDest.usPtr++ = *pBlockSrc.usPtr++;
123  }
124 
125  if (uiLength & 0x1)
126  {
127  *pBlockDest.ucPtr = *pBlockSrc.ucPtr;
128  }
129  }
130 }
131 
132 
133 #endif