]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/IA32_flat_GCC_Galileo_Gen_2/Support_Files/galileo_support.h
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / IA32_flat_GCC_Galileo_Gen_2 / Support_Files / galileo_support.h
1 /*--------------------------------------------------------------------\r
2  Copyright(c) 2015 Intel Corporation. All rights reserved.\r
3 \r
4  Redistribution and use in source and binary forms, with or without\r
5  modification, are permitted provided that the following conditions\r
6  are met:\r
7 \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
13  distribution.\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
17 \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
30 \r
31 #ifndef __GALILEO_SUPPORT_H__\r
32 #define __GALILEO_SUPPORT_H__\r
33 \r
34 #ifdef __cplusplus\r
35         extern "C" {\r
36 #endif\r
37 \r
38 //---------------------------------------------------------------------\r
39 // Any required includes\r
40 //---------------------------------------------------------------------\r
41 #include "FreeRTOS.h"\r
42 #include "semphr.h"\r
43 #include "galileo_gen_defs.h"\r
44 #include "GPIO_I2C.h"\r
45 #include "HPET.h"\r
46 \r
47 //---------------------------------------------------------------------\r
48 // Application main entry point\r
49 //---------------------------------------------------------------------\r
50 extern int main( void );\r
51 \r
52 //---------------------------------------------------------------------\r
53 // Defines for GDT\r
54 //---------------------------------------------------------------------\r
55 #define NGDE                            8               /* Number of global descriptor entries  */\r
56 #define FLAGS_GRANULARITY       0x80\r
57 #define FLAGS_SIZE                      0x40\r
58 #define FLAGS_SETTINGS          ( FLAGS_GRANULARITY | FLAGS_SIZE )\r
59 #define PAGE_SIZE                       4096\r
60 \r
61 struct __attribute__ ((__packed__)) sd\r
62 {\r
63         unsigned short  sd_lolimit;\r
64         unsigned short  sd_lobase;\r
65         unsigned char   sd_midbase;\r
66         unsigned char   sd_access;\r
67         unsigned char   sd_hilim_fl;\r
68         unsigned char   sd_hibase;\r
69 };\r
70 \r
71 void setsegs();\r
72 \r
73 //---------------------------------------------------------------------\r
74 // Debug serial port display update definitions\r
75 //---------------------------------------------------------------------\r
76 #define ANSI_CLEAR_SB                   "\e[3J"\r
77 #define ANSI_CLEAR_LINE                 "\x1b[2K"\r
78 #define ANSI_CLEAR_SCREEN               "\x1b[2J"\r
79 #define ANSI_COLOR_RED                  "\x1b[31m"\r
80 #define ANSI_COLOR_GREEN                "\x1b[32m"\r
81 #define ANSI_COLOR_YELLOW               "\x1b[33m"\r
82 #define ANSI_COLOR_BLUE                 "\x1b[34m"\r
83 #define ANSI_COLOR_MAGENTA              "\x1b[35m"\r
84 #define ANSI_COLOR_CYAN                 "\x1b[36m"\r
85 #define ANSI_COLOR_RESET                "\x1b[0m"\r
86 #define ANSI_COLOR_WHITE                ANSI_COLOR_RESET\r
87 \r
88 #define DEFAULT_SCREEN_COLOR    ANSI_COLOR_YELLOW\r
89 #define DEFAULT_BANNER_COLOR    ANSI_COLOR_CYAN\r
90 \r
91 #define ANSI_HIDE_CURSOR                "\x1b[?25l"\r
92 #define ANSI_SHOW_CURSOR                "\x1b[?25h"\r
93 \r
94 void ClearScreen(void);\r
95 void MoveToScreenPosition(uint8_t row, uint8_t col);\r
96 void UngatedMoveToScreenPosition(uint8_t row, uint8_t col);\r
97 void SetScreenColor(const char *);\r
98 void g_printf(const char *format, ...);\r
99 void g_printf_rcc(uint8_t row, uint8_t col, const char *color, const char *format, ...);\r
100 void vPrintBanner( void );\r
101 \r
102 //---------------------------------------------------------------------\r
103 // 8259 PIC (programmable interrupt controller) definitions\r
104 //---------------------------------------------------------------------\r
105 #define IMR1 (0x21)       /* Interrupt Mask Register #1           */\r
106 #define IMR2 (0xA1)       /* Interrupt Mask Register #2           */\r
107 #define ICU1 (0x20)\r
108 #define ICU2 (0xA0)\r
109 #define EOI  (0x20)\r
110 \r
111 void vInitialize8259Chips(void);\r
112 void vClearIRQMask(uint8_t IRQNumber);\r
113 void vSetIRQMask(uint8_t IRQNumber);\r
114 \r
115 //---------------------------------------------------------------------\r
116 // 82C54 PIT (programmable interval timer) definitions\r
117 //---------------------------------------------------------------------\r
118 #define GATE_CONTROL    0x61\r
119 #define CHANNEL2_DATA   0x42\r
120 #define MODE_REGISTER   0x43\r
121 #define ONESHOT_MODE    0xB2\r
122 #define CLKBASE                 0x40\r
123 #define CLKCNTL                 MODE_REGISTER\r
124 \r
125 void vInitializePIT(void);\r
126 \r
127 //---------------------------------------------------------------------\r
128 // LED support for main_blinky()\r
129 //---------------------------------------------------------------------\r
130 #define LED_ON                  ( 1 )\r
131 #define LED_OFF                 ( 0 )\r
132 \r
133 uint32_t ulBlinkLED(void); /* Blink the LED and return the LED status. */\r
134 \r
135 //---------------------------------------------------------------------\r
136 // Serial port support definitions\r
137 //---------------------------------------------------------------------\r
138 #define CLIENT_SERIAL_PORT                              0\r
139 #define DEBUG_SERIAL_PORT                               1\r
140 \r
141 #define R_UART_THR                      0\r
142 #define R_UART_IER                      0x04\r
143 #define R_UART_BAUD_THR                 R_UART_THR\r
144 #define R_UART_BAUD_LOW                 R_UART_BAUD_THR\r
145 #define R_UART_BAUD_HIGH                R_UART_IER\r
146 #define R_UART_FCR                      0x08\r
147 #define B_UARY_FCR_TRFIFIE              BIT0\r
148 #define B_UARY_FCR_RESETRF              BIT1\r
149 #define B_UARY_FCR_RESETTF              BIT2\r
150 #define R_UART_LCR                      0x0C\r
151 #define B_UARY_LCR_DLAB                 BIT7\r
152 #define R_UART_MCR                      0x10\r
153 #define R_UART_LSR                      0x14\r
154 #define B_UART_LSR_RXRDY                BIT0\r
155 #define B_UART_LSR_OE                   BIT1\r
156 #define B_UART_LSR_PE                   BIT2\r
157 #define B_UART_LSR_FE                   BIT3\r
158 #define B_UART_LSR_BI                   BIT4\r
159 #define B_UART_LSR_TXRDY                BIT5\r
160 #define B_UART_LSR_TEMT                 BIT6\r
161 #define R_UART_MSR                      0x18\r
162 #define R_UART_SCR                      0x1C\r
163 \r
164 void vInitializeGalileoSerialPort(uint32_t portnumber);\r
165 void vGalileoPrintc(char c);\r
166 uint8_t ucGalileoGetchar();\r
167 void vGalileoPuts(const char *string);\r
168 \r
169 #ifdef __cplusplus\r
170         } /* extern C */\r
171 #endif\r
172 \r
173 #endif /* __GALILEO_SUPPORT_H__ */\r
174 \r