Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 1 | void land_test(void) |
| 2 | { |
| 3 | int i; |
| 4 | i = 1 && 2; |
| 5 | } |
| 6 | void lor_test(void) |
| 7 | { |
| 8 | int i; |
| 9 | i = 1 || 2; |
| 10 | } |
| 11 | |
| 12 | void outb(unsigned char value, unsigned short port) |
| 13 | { |
| 14 | __builtin_outb(value, port); |
| 15 | } |
| 16 | |
| 17 | unsigned char inb(unsigned short port) |
| 18 | { |
| 19 | return __builtin_inb(port); |
| 20 | } |
| 21 | |
| 22 | static 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 Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 28 | #ifndef CONFIG_TTYS0_BASE |
| 29 | #define CONFIG_TTYS0_BASE 0x3f8 |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 30 | #endif |
| 31 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 32 | #ifndef CONFIG_TTYS0_BAUD |
| 33 | #define CONFIG_TTYS0_BAUD 115200 |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 34 | #endif |
| 35 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 36 | #if ((115200%CONFIG_TTYS0_BAUD) != 0) |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 37 | #error Bad ttys0 baud rate |
| 38 | #endif |
| 39 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 40 | #define CONFIG_TTYS0_DIV (115200/CONFIG_TTYS0_BAUD) |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 41 | |
| 42 | /* Line Control Settings */ |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 43 | #ifndef CONFIG_TTYS0_LCS |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 44 | /* Set 8bit, 1 stop bit, no parity */ |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 45 | #define CONFIG_TTYS0_LCS 0x3 |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 46 | #endif |
| 47 | |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 48 | #define UART_LCS CONFIG_TTYS0_LCS |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 49 | |
| 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 | |
| 68 | int uart_can_tx_byte(void) |
| 69 | { |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 70 | return inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x20; |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void uart_wait_to_tx_byte(void) |
| 74 | { |
| 75 | while(!uart_can_tx_byte()) |
| 76 | ; |
| 77 | } |
| 78 | |
| 79 | void uart_wait_until_sent(void) |
| 80 | { |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 81 | while(!(inb(CONFIG_TTYS0_BASE + UART_LSR) & 0x40)) |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 82 | ; |
| 83 | } |
| 84 | |
| 85 | void uart_tx_byte(unsigned char data) |
| 86 | { |
| 87 | uart_wait_to_tx_byte(); |
Stefan Reinauer | 0867062 | 2009-06-30 15:17:49 +0000 | [diff] [blame] | 88 | outb(data, CONFIG_TTYS0_BASE + UART_TBR); |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 89 | /* Make certain the data clears the fifos */ |
| 90 | uart_wait_until_sent(); |
| 91 | } |
| 92 | |
| 93 | void 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 | |
| 116 | static 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 |
| 130 | void 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 |
| 143 | static int add(int left, int right) |
| 144 | { |
| 145 | { |
| 146 | return left + right; |
| 147 | } |
| 148 | } |
| 149 | #else |
| 150 | #if 0 |
| 151 | static int add(int left, int right) |
| 152 | { |
| 153 | return left + right; |
| 154 | } |
| 155 | #endif |
| 156 | #endif |
| 157 | |
| 158 | #if 0 |
| 159 | static void assign(void) |
| 160 | { |
| 161 | int i, j; |
| 162 | i = j = 1; |
| 163 | } |
| 164 | #endif |
| 165 | |
| 166 | #if 0 |
| 167 | static void and(void) |
| 168 | { |
| 169 | int i, j, k; |
| 170 | i = 1; |
| 171 | j = 2; |
| 172 | k = i && j; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 173 | |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 174 | } |
| 175 | static void and_test(void) |
| 176 | { |
| 177 | and(); |
| 178 | } |
| 179 | #endif |
| 180 | #if 0 |
| 181 | #define INC_TEST 2 |
| 182 | static 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 |
| 198 | static void inc_test(void) |
| 199 | { |
| 200 | inc(); |
| 201 | } |
| 202 | #endif |
| 203 | #endif |
| 204 | #if 0 |
| 205 | static void loop(void) |
| 206 | { |
| 207 | int i; |
| 208 | for(i = 0; i < 10; i++) { |
| 209 | ; |
| 210 | } while(i < 10); |
| 211 | } |
| 212 | |
| 213 | static void loop_test(void) |
| 214 | { |
| 215 | loop(); |
| 216 | } |
| 217 | #endif |
| 218 | |
| 219 | #if 0 |
| 220 | static void simple(void) |
| 221 | { |
| 222 | add(1,2); |
| 223 | } |
| 224 | #endif |
| 225 | |
| 226 | #if 0 |
| 227 | static void fun(void) |
| 228 | { |
| 229 | int bar; |
| 230 | bar = add(1, 2); |
| 231 | } |
| 232 | #endif |
| 233 | |
| 234 | |
| 235 | #if 0 |
| 236 | static void func(void) |
| 237 | { |
| 238 | int bar, baz; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame^] | 239 | int i; |
| 240 | |
| 241 | baz = add(1, 2); |
Eric Biederman | b138ac8 | 2003-04-22 18:44:01 +0000 | [diff] [blame] | 242 | 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 |