Enable -Werror for romcc
[coreboot.git] / util / romcc / tests / simple_test34.c
1
2 typedef __builtin_msr_t msr_t;
3
4 static msr_t rdmsr(unsigned long index)
5 {
6         return __builtin_rdmsr(index);
7 }
8
9 static void uart_tx_byte(unsigned char data)
10 {
11         while(!(__builtin_inb(0x3f8 + 0x05) & 0x20))
12                 ;
13         __builtin_outb(data, 0x3f8 + 0x00);
14
15         while(!(__builtin_inb(0x3f8 + 0x05) & 0x40))
16                 ;
17 }
18
19
20 static void print_nibble(unsigned nibble)
21 {
22         unsigned char digit;
23         digit = nibble + '0';
24         if (digit > '9') {
25                 digit += 39;
26         }
27         uart_tx_byte(digit);
28 }
29
30 static void print_debug_hex32(unsigned int value)
31 {
32         print_nibble((value >> 28U) & 0x0fU);
33         print_nibble((value >> 24U) & 0x0fU);
34         print_nibble((value >> 20U) & 0x0fU);
35         print_nibble((value >> 16U) & 0x0fU);
36         print_nibble((value >> 12U) & 0x0fU);
37         print_nibble((value >> 8U) & 0x0fU);
38         print_nibble((value >> 4U) & 0x0fU);
39         print_nibble(value & 0x0fU);
40 }
41
42 static void print_debug(const char *str)
43 {
44         unsigned char ch;
45         while((ch = *str++) != '\0') {
46                 uart_tx_byte(ch);
47         }
48 }
49
50 static void main(void)
51 {
52         unsigned long start, stop;
53         msr_t msr;
54         msr = rdmsr(0xC001001A);
55         print_debug("TOP_MEM: ");
56         print_debug_hex32(msr.hi);
57         print_debug_hex32(msr.lo);
58         print_debug("\r\n");
59
60         start = 0;
61         stop = msr.lo;
62         print_debug("Testing DRAM : ");
63         print_debug_hex32(start);
64         print_debug("-");
65         print_debug_hex32(stop);
66         print_debug("\r\n");
67
68         print_debug("DRAM verify: ");
69         print_debug_hex32(start);
70         print_debug_hex32(stop);
71 }