VSF Documented
mcs51_compiler.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __USE_MCS51_COMPILER_H_PART_1__
19#define __USE_MCS51_COMPILER_H_PART_1__
20
21/*============================ INCLUDES ======================================*/
22
24
25#endif /* __USE_MCS51_COMPILER_H_PART_1__ */
26
27/*========================== Multiple-Entry Start ============================*/
28
29#if __IS_COMPILER_IAR__
30# include <intrinsics.h>
31#endif
32
33#ifndef __VSF_HEADER_ONLY_SHOW_COMPILER_INFO__
34# include "./type.h"
35#endif
36#include "../__common/__compiler.h"
37
38/*========================== Multiple-Entry End ==============================*/
39
40
41#ifndef __USE_MCS51_COMPILER_H_PART_2__
42#define __USE_MCS51_COMPILER_H_PART_2__
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/* ----------------- Start of section using anonymous unions -------------- */
49#if __IS_COMPILER_51_KEIL__
50 //#pragma push
51 //#pragma anon_unions
52#elif __IS_COMPILER_IAR__
53 #pragma language=extended
54#else
55 #warning Not supported compiler type
56#endif
57
58/*============================ MACROS ========================================*/
59
61#if __IS_COMPILER_IAR__
62# define LOW_LEVEL_INIT_RET_T char
63# define VSF_CAL_NO_INIT __no_init
64# define VSF_CAL_NO_RETURN _Pragma("object_attribute=__noreturn")
65# define VSF_CAL_ROOT __root
66# define VSF_CAL_INLINE inline
67# define VSF_CAL_NO_INLINE _Pragma("optimisze=no_inline")
68# define VSF_CAL_ALWAYS_INLINE _Pragma("inline=forced")
69# define VSF_CAL_WEAK(...) _Pragma(__VSF_STR(weak __VA_ARGS__))
70# define VSF_CAL_RAMFUNC __ramfunc
71# define __asm__ __asm
72# define __VSF_CAL_ALIGN(__N) //_Pragma("data_alignment=" __VSF_STR(__N)) //!< 8051 does not have any alignment restrictions
73# define __VSF_CAL_AT_ADDR(__ADDR) @ __ADDR
74# define __VSF_CAL_SECTION(__SEC) _Pragma(__VSF_STR(section=__SEC))
75# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS) \
76 _Pragma(__VSF_STR(weak __ORIGIN=__ALIAS))
77# define VSF_CAL_PACKED
78# define VSF_CAL_UNALIGNED
79# define VSF_CAL_TRANSPARENT_UNION
80# define __VSF_CAL_ALIGN_OF(...) __ALIGNOF__(__VA_ARGS__)
81
82#define __VSF_CAL_ISR(__VEC) \
83 _Pragma(__VSF_STR(vector=__VEC)) \
84 __interrupt void vect_##__VEC##_handler(void)
85
87# define __stackless
88
89# define __IAR_STARTUP_DATA_INIT __INIT_XDATA_Z
90
92#ifndef NOP
93 #define NOP() __no_operation()
94#endif
95
96#elif __IS_COMPILER_51_KEIL__
97
98# define VSF_CAL_NO_INIT
99# define VSF_CAL_NO_RETURN
100# define VSF_CAL_ROOT
101# define VSF_CAL_INLINE
102# define VSF_CAL_NO_INLINE
103# define VSF_CAL_ALWAYS_INLINE
104# define VSF_CAL_WEAK(__ANYTHING)
105# define VSF_CAL_RAMFUNC
106# define __asm__ __asm
107# define __VSF_CAL_ALIGN(__N) //_Pragma("data_alignment=" __STR(__N)) //!< 8051 does not have any alignment restrictions
108# define __VSF_CAL_AT_ADDR(__ADDR)
109# define __VSF_CAL_SECTION(__SEC)
110# define __VSF_CAL_WEAK_ALIAS(__ORIGIN, __ALIAS)
111# define VSF_CAL_PACKED
112# define VSF_CAL_UNALIGNED
113# define VSF_CAL_TRANSPARENT_UNION
114# define __VSF_CAL_ALIGN_OF(__ANYTHING)
115
116# define __VSF_CAL_ISR(__VEC) \
117 void vect_##__VEC##_handler(void) interrupt __VEC
118
120# define __stackless
121
122# define __IAR_STARTUP_DATA_INIT __INIT_XDATA_I
123#endif
124
125
126#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
127#define VSF_CAL_ALIGN_OF(__TYPE) __VSF_CAL_ALIGN_OF(__TYPE)
128#define VSF_CAL_ALIGN_WITH(__TYPE) VSF_CAL_ALIGN(VSF_CAL_ALIGN_OF(__TYPE))
129#define VSF_CAL_ISR(__VECT) __VSF_CAL_ISR(__VECT)
130#else
131#define VSF_CAL_ALIGN_OF(...) __VSF_CAL_ALIGN_OF(__VA_ARGS__)
132#define VSF_CAL_ALIGN_WITH(...) VSF_CAL_ALIGN(VSF_CAL_ALIGN_OF(__VA_ARGS__))
133#define VSF_CAL_ISR(...) __VSF_CAL_ISR(__VA_ARGS__)
134#endif
135
136/*----------------------------------------------------------------------------*
137 * Signal & Interrupt Definition *
138 *----------------------------------------------------------------------------*/
139
141#if __IS_COMPILER_IAR__
142# define ENABLE_GLOBAL_INTERRUPT() __enable_interrupt()
143#elif __IS_COMPILER_51_KEIL__
144# define ENABLE_GLOBAL_INTERRUPT() __enable_interrupt()
145#endif
146
148#if __IS_COMPILER_IAR__
149# define DISABLE_GLOBAL_INTERRUPT() ____disable_irq()
150
151INLINE
152static uint32_t ____disable_irq(void)
153{
154 __istate_t s = __get_interrupt_state();
155 __disable_interrupt();
156 return s;
157}
158#elif __IS_COMPILER_51_KEIL__
159# define DISABLE_GLOBAL_INTERRUPT() __disable_interrupt()
160#endif
161
162#if __IS_COMPILER_IAR__
163# define GET_GLOBAL_INTERRUPT_STATE() __get_interrupt_state()
164# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_interrupt_state(__STATE)
165typedef __istate_t vsf_gint_state_t;
166#elif __IS_COMPILER_51_KEIL__
167# define GET_GLOBAL_INTERRUPT_STATE() __get_interrupt_state()
168# define SET_GLOBAL_INTERRUPT_STATE(__STATE) __set_interrupt_state(__STATE)
170#endif
171
172
173/*============================ TYPES =========================================*/
174/*============================ PROTOTYPES ====================================*/
175extern void vsf_stdio_init(void);
176
177#ifdef __cplusplus
178}
179#endif
180
181/*============================ INCLUDES ======================================*/
182
183#include "./msc51_interrupt.h"
184
185#endif /* __USE_MCS51_COMPILER_H_PART_2__ */
186
volatile bool vsf_gint_state_t
Definition linux_generic.h:114
void vsf_stdio_init(void)
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5