blob: 9791d9e352f480f7301e69ffec88987e0a706787 [file] [log] [blame]
Eric Biedermanb138ac82003-04-22 18:44:01 +00001void land_test(void)
2{
3 int i;
4 i = 1 && 2;
5}
6void lor_test(void)
7{
8 int i;
9 i = 1 || 2;
10}
11
12void outb(unsigned char value, unsigned short port)
13{
14 __builtin_outb(value, port);
15}
16
17unsigned char inb(unsigned short port)
18{
19 return __builtin_inb(port);
20}
21
22static unsigned int config_cmd2(unsigned char bus, unsigned devfn, unsigned where)
23{
24 return 0x80000000 | (bus << 16) | (devfn << 8) | (where & ~3) ;
25}
26
27/* Base Address */
Stefan Reinauer08670622009-06-30 15:17:49 +000028#ifndef CONFIG_TTYS0_BASE
29#define CONFIG_TTYS0_BASE 0x3f8
Eric Biedermanb138ac82003-04-22 18:44:01 +000030#endif
31
Stefan Reinauer08670622009-06-30 15:17:49 +000032#ifndef CONFIG_TTYS0_BAUD
33#define CONFIG_TTYS0_BAUD 115200
Eric Biedermanb138ac82003-04-22 18:44:01 +000034#endif
35
Stefan Reinauer08670622009-06-30 15:17:49 +000036#if ((115200%CONFIG_TTYS0_BAUD) != 0)
Eric Biedermanb138ac82003-04-22 18:44:01 +000037#error Bad ttys0 baud rate
38#endif
39
Stefan Reinauer08670622009-06-30 15:17:49 +000040#define CONFIG_TTYS0_DIV (115200/CONFIG_TTYS0_BAUD)
Eric Biedermanb138ac82003-04-22 18:44:01 +000041
42/* Line Control Settings */
Stefan Reinauer08670622009-06-30 15:17:49 +000043#ifndef CONFIG_TTYS0_LCS
Eric Biedermanb138ac82003-04-22 18:44:01 +000044/* Set 8bit, 1 stop bit, no parity */
Stefan Reinauer08670622009-06-30 15:17:49 +000045#define CONFIG_TTYS0_LCS 0x3
Eric Biedermanb138ac82003-04-22 18:44:01 +000046#endif
47
Stefan Reinauer08670622009-06-30 15:17:49 +000048#define UART_LCS CONFIG_TTYS0_LCS
Eric Biedermanb138ac82003-04-22 18:44:01 +000049
50/* Data */
51#define UART_RBR 0x00
52#define UART_TBR 0x00
53
54/* Control */
55#define UART_IER 0x01
56#define UART_IIR 0x02
57#define UART_FCR 0x02
58#define UART_LCR 0x03
59#define UART_MCR 0x04
60#define UART_DLL 0x00
61#define UART_DLM 0x01
62
63/* Status */
64#define UART_LSR 0x05
65#define UART_MSR 0x06
66#define UART_SCR 0x07
67
68int uart_can_tx_byte(void)
69{
Stefan Reinauer08670622009-06-30 15:17:49 +000070 return inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x20;
Eric Biedermanb138ac82003-04-22 18:44:01 +000071}
72
73void uart_wait_to_tx_byte(void)
74{
75 while(!uart_can_tx_byte())
76 ;
77}
78
79void uart_wait_until_sent(void)
80{
Stefan Reinauer14e22772010-04-27 06:56:47 +000081 while(!(inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x40))
Eric Biedermanb138ac82003-04-22 18:44:01 +000082 ;
83}
84
85void uart_tx_byte(unsigned char data)
86{
87 uart_wait_to_tx_byte();
Stefan Reinauer08670622009-06-30 15:17:49 +000088 outb(data, CONFIG_TTYS0_BASE + UART_TBR);
Eric Biedermanb138ac82003-04-22 18:44:01 +000089 /* Make certain the data clears the fifos */
90 uart_wait_until_sent();
91}
92
93void dummy(void)
94{
95 uart_tx_byte(5);
96}
97
98#define PIIX4_DEVFN 0x90
99#define SMBUS_MEM_DEVICE_START 0x50
100#define SMBUS_MEM_DEVICE_END 0x53
101#define SMBUS_MEM_DEVICE_INC 1
102
103
104#define PM_BUS 0
105#define PM_DEVFN (PIIX4_DEVFN+3)
106
107#define SMBUS_IO_BASE 0x1000
108#define SMBHSTSTAT 0
109#define SMBHSTCTL 2
110#define SMBHSTCMD 3
111#define SMBHSTADD 4
112#define SMBHSTDAT0 5
113#define SMBHSTDAT1 6
114#define SMBBLKDAT 7
115
116static void smbus_wait_until_done(void)
117{
118 unsigned char byte;
119 do {
120 byte = inb(SMBUS_IO_BASE + SMBHSTSTAT);
121 }while((byte &1) == 1);
122#if 1
123 while( (byte & ~1) == 0) {
124 byte = inb(SMBUS_IO_BASE + SMBHSTSTAT);
125 }
126#endif
127}
128
129#if 0
130void ifthenelse(void)
131{
132 int i;
133 if (5 > 2) {
134 i = 1;
135 }
136 else {
137 i = 2;
138 }
139 i = i + 3;
140}
141#endif
142#if 0
143static int add(int left, int right)
144{
145 {
146 return left + right;
147 }
148}
149#else
150#if 0
151static int add(int left, int right)
152{
153 return left + right;
154}
155#endif
156#endif
157
158#if 0
159static void assign(void)
160{
161 int i, j;
162 i = j = 1;
163}
164#endif
165
166#if 0
167static void and(void)
168{
169 int i, j, k;
170 i = 1;
171 j = 2;
172 k = i && j;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000173
Eric Biedermanb138ac82003-04-22 18:44:01 +0000174}
175static void and_test(void)
176{
177 and();
178}
179#endif
180#if 0
181#define INC_TEST 2
182static void inc(void)
183{
184 int i;
185 i = 5;
186#if (INC_TEST == 1)
187 i += 7;
188#endif
189#if (INC_TEST == 2)
190 ++i;
191#endif
192#if (INC_TEST == 3)
193 i++;
194#endif
195}
196
197#if 0
198static void inc_test(void)
199{
200 inc();
201}
202#endif
203#endif
204#if 0
205static void loop(void)
206{
207 int i;
208 for(i = 0; i < 10; i++) {
209 ;
210 } while(i < 10);
211}
212
213static void loop_test(void)
214{
215 loop();
216}
217#endif
218
219#if 0
220static void simple(void)
221{
222 add(1,2);
223}
224#endif
225
226#if 0
227static void fun(void)
228{
229 int bar;
230 bar = add(1, 2);
231}
232#endif
233
234
235#if 0
236static void func(void)
237{
238 int bar, baz;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000239 int i;
240
241 baz = add(1, 2);
Eric Biedermanb138ac82003-04-22 18:44:01 +0000242 baz = add(1, 2);
243 bar = 1;
244 baz = 2;
245 for(i = 0; i < 10; i = i + 1) {
246 baz = i;
247 }
248 bar = 1 + 2 * 3;
249 bar = add(3, 4);
250 bar = add(bar, baz);
251}
252#endif