1 /*--------------------------------------------------------------------
\r
2 Copyright(c) 2015 Intel Corporation. All rights reserved.
\r
4 Redistribution and use in source and binary forms, with or without
\r
5 modification, are permitted provided that the following conditions
\r
8 * Redistributions of source code must retain the above copyright
\r
9 notice, this list of conditions and the following disclaimer.
\r
10 * Redistributions in binary form must reproduce the above copyright
\r
11 notice, this list of conditions and the following disclaimer in
\r
12 the documentation and/or other materials provided with the
\r
14 * Neither the name of Intel Corporation nor the names of its
\r
15 contributors may be used to endorse or promote products derived
\r
16 from this software without specific prior written permission.
\r
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
\r
19 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
\r
20 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
\r
21 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
\r
22 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
\r
23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
24 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
\r
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
\r
26 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
\r
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
28 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
29 --------------------------------------------------------------------*/
\r
31 #ifndef __GALILEO_GEN_DEFS_H__
\r
32 #define __GALILEO_GEN_DEFS_H__
\r
38 /*-----------------------------------------------------------------------
\r
39 * Any required includes
\r
40 *------------------------------------------------------------------------
\r
45 //---------------------------------------------------------------------
\r
47 //---------------------------------------------------------------------
\r
48 extern int printf( const char *format, ... );
\r
49 extern int print( char **out, const char *format, va_list args );
\r
50 extern int sprintf(char *out, const char *format, ...);
\r
52 //---------------------------------------------------------------------
\r
53 // Prototypes (assembly language functions in startup.S)
\r
54 //---------------------------------------------------------------------
\r
55 extern void halt( void );
\r
56 extern int32_t inb( int32_t );
\r
57 extern int32_t inw( int32_t );
\r
58 extern int32_t inl( int32_t );
\r
59 extern int32_t outb( int32_t, int32_t );
\r
60 extern int32_t outw( int32_t, int32_t );
\r
61 extern int32_t outl( int32_t, int32_t) ;
\r
63 //---------------------------------------------------------------------
\r
65 //---------------------------------------------------------------------
\r
86 //---------------------------------------------------------------------
\r
87 // General bit pattern definitions
\r
88 //---------------------------------------------------------------------
\r
89 #define BIT0 0x00000001U
\r
90 #define BIT1 0x00000002U
\r
91 #define BIT2 0x00000004U
\r
92 #define BIT3 0x00000008U
\r
93 #define BIT4 0x00000010U
\r
94 #define BIT5 0x00000020U
\r
95 #define BIT6 0x00000040U
\r
96 #define BIT7 0x00000080U
\r
97 #define BIT8 0x00000100U
\r
98 #define BIT9 0x00000200U
\r
100 //---------------------------------------------------------------------
\r
101 // MMIO support definitions
\r
102 //---------------------------------------------------------------------
\r
103 #define EC_BASE 0xE0000000 /* Base of MMConfig space */
\r
104 #define MMCONFIG_BASE EC_BASE
\r
105 #define MMIO_PCI_ADDRESS(bus,dev,fn,reg) ( \
\r
112 //---------------------------------------------------------------------
\r
113 // MMIO read/write/set/clear/modify macros
\r
114 //---------------------------------------------------------------------
\r
115 #define mem_read(base, offset, size) ({ \
\r
116 volatile uint32_t a = (base) + (offset); \
\r
117 volatile uint64_t v; \
\r
120 v = (uint8_t)(*((uint8_t *)a)); \
\r
123 v = (uint16_t)(*((uint16_t *)a)); \
\r
126 v = (uint32_t)(*((uint32_t *)a)); \
\r
129 v = (uint64_t)(*((uint64_t *)a)); \
\r
137 // No cache bypass necessary -- MTRRs should handle this
\r
138 #define mem_write(base, offset, size, value) { \
\r
139 volatile uint32_t a = (base) + (offset); \
\r
142 *((uint8_t *)a) = (uint8_t)(value); \
\r
145 *((uint16_t *)a) = (uint16_t)(value); \
\r
148 *((uint32_t *)a) = (uint32_t)(value); \
\r
151 *((uint64_t *)a) = (uint64_t)(value); \
\r
158 #define mem_set(base, offset, size, smask) { \
\r
159 volatile uint32_t a = (base) + (offset); \
\r
162 *((uint8_t *)a) = (uint8_t)((*((uint8_t *)a)) | (smask)); \
\r
165 *((uint16_t *)a) = (uint16_t)((*((uint16_t *)a)) | (smask)); \
\r
168 *((uint32_t *)a) = (uint32_t)((*((uint32_t *)a)) | (smask)); \
\r
171 *((uint64_t *)a) = (uint64_t)((*((uint64_t *)a)) | (smask)); \
\r
176 #define mem_clear(base, offset, size, cmask) { \
\r
177 volatile uint32_t a = (base) + (offset); \
\r
180 *((uint8_t *)a) = (uint8_t)((*((uint8_t *)a) & ~(cmask))); \
\r
183 *((uint16_t *)a) = (uint16_t)((*((uint16_t *)a) & ~(cmask))); \
\r
186 *((uint32_t *)a) = (uint32_t)((*((uint32_t *)a) & ~(cmask))); \
\r
189 *((uint64_t *)a) = (uint64_t)((*((uint64_t *)a) & ~(cmask))); \
\r
194 #define mem_modify(base, offset, size, cmask, smask) { \
\r
195 volatile uint32_t a = (base) + (offset); \
\r
198 *((uint8_t *)a) = (uint8_t)((*((uint8_t *)a) & ~(cmask)) | (smask)); \
\r
201 *((uint16_t *)a) = (uint16_t)((*((uint16_t *)a) & ~(cmask)) | (smask)); \
\r
204 *((uint32_t *)a) = (uint32_t)((*((uint32_t *)a) & ~(cmask)) | (smask)); \
\r
207 *((uint64_t *)a) = (uint64_t)((*((uint64_t *)a) & ~(cmask)) | (smask)); \
\r
215 #endif /* GALILEO_GEN_DEFS */
\r