]>
Commit | Line | Data |
---|---|---|
9bda413c AL |
1 | /* |
2 | * qtest I440FX test case | |
3 | * | |
4 | * Copyright IBM, Corp. 2012-2013 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <aliguori@us.ibm.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2 or later. | |
10 | * See the COPYING file in the top-level directory. | |
11 | */ | |
12 | ||
13 | #include "libqos/pci.h" | |
14 | #include "libqos/pci-pc.h" | |
15 | #include "libqtest.h" | |
16 | ||
17 | #include "hw/pci/pci_regs.h" | |
18 | ||
19 | #include <glib.h> | |
20 | #include <stdio.h> | |
21 | ||
22 | #define BROKEN 1 | |
23 | ||
24 | typedef struct TestData | |
25 | { | |
26 | int num_cpus; | |
27 | QPCIBus *bus; | |
28 | } TestData; | |
29 | ||
30 | static void test_i440fx_defaults(gconstpointer opaque) | |
31 | { | |
32 | const TestData *s = opaque; | |
33 | QPCIDevice *dev; | |
34 | uint32_t value; | |
35 | ||
36 | dev = qpci_device_find(s->bus, QPCI_DEVFN(0, 0)); | |
37 | g_assert(dev != NULL); | |
38 | ||
39 | /* 3.2.2 */ | |
40 | g_assert_cmpint(qpci_config_readw(dev, PCI_VENDOR_ID), ==, 0x8086); | |
41 | /* 3.2.3 */ | |
42 | g_assert_cmpint(qpci_config_readw(dev, PCI_DEVICE_ID), ==, 0x1237); | |
43 | #ifndef BROKEN | |
44 | /* 3.2.4 */ | |
45 | g_assert_cmpint(qpci_config_readw(dev, PCI_COMMAND), ==, 0x0006); | |
46 | /* 3.2.5 */ | |
47 | g_assert_cmpint(qpci_config_readw(dev, PCI_STATUS), ==, 0x0280); | |
48 | #endif | |
49 | /* 3.2.7 */ | |
50 | g_assert_cmpint(qpci_config_readb(dev, PCI_CLASS_PROG), ==, 0x00); | |
51 | g_assert_cmpint(qpci_config_readw(dev, PCI_CLASS_DEVICE), ==, 0x0600); | |
52 | /* 3.2.8 */ | |
53 | g_assert_cmpint(qpci_config_readb(dev, PCI_LATENCY_TIMER), ==, 0x00); | |
54 | /* 3.2.9 */ | |
55 | g_assert_cmpint(qpci_config_readb(dev, PCI_HEADER_TYPE), ==, 0x00); | |
56 | /* 3.2.10 */ | |
57 | g_assert_cmpint(qpci_config_readb(dev, PCI_BIST), ==, 0x00); | |
58 | ||
59 | /* 3.2.11 */ | |
60 | value = qpci_config_readw(dev, 0x50); /* PMCCFG */ | |
61 | if (s->num_cpus == 1) { /* WPE */ | |
62 | g_assert(!(value & (1 << 15))); | |
63 | } else { | |
64 | g_assert((value & (1 << 15))); | |
65 | } | |
66 | ||
67 | g_assert(!(value & (1 << 6))); /* EPTE */ | |
68 | ||
69 | /* 3.2.12 */ | |
70 | g_assert_cmpint(qpci_config_readb(dev, 0x52), ==, 0x00); /* DETURBO */ | |
71 | /* 3.2.13 */ | |
72 | #ifndef BROKEN | |
73 | g_assert_cmpint(qpci_config_readb(dev, 0x53), ==, 0x80); /* DBC */ | |
74 | #endif | |
75 | /* 3.2.14 */ | |
76 | g_assert_cmpint(qpci_config_readb(dev, 0x54), ==, 0x00); /* AXC */ | |
77 | /* 3.2.15 */ | |
78 | g_assert_cmpint(qpci_config_readw(dev, 0x55), ==, 0x0000); /* DRT */ | |
79 | #ifndef BROKEN | |
80 | /* 3.2.16 */ | |
81 | g_assert_cmpint(qpci_config_readb(dev, 0x57), ==, 0x01); /* DRAMC */ | |
82 | /* 3.2.17 */ | |
83 | g_assert_cmpint(qpci_config_readb(dev, 0x58), ==, 0x10); /* DRAMT */ | |
84 | #endif | |
85 | /* 3.2.18 */ | |
86 | g_assert_cmpint(qpci_config_readb(dev, 0x59), ==, 0x00); /* PAM0 */ | |
87 | g_assert_cmpint(qpci_config_readb(dev, 0x5A), ==, 0x00); /* PAM1 */ | |
88 | g_assert_cmpint(qpci_config_readb(dev, 0x5B), ==, 0x00); /* PAM2 */ | |
89 | g_assert_cmpint(qpci_config_readb(dev, 0x5C), ==, 0x00); /* PAM3 */ | |
90 | g_assert_cmpint(qpci_config_readb(dev, 0x5D), ==, 0x00); /* PAM4 */ | |
91 | g_assert_cmpint(qpci_config_readb(dev, 0x5E), ==, 0x00); /* PAM5 */ | |
92 | g_assert_cmpint(qpci_config_readb(dev, 0x5F), ==, 0x00); /* PAM6 */ | |
93 | #ifndef BROKEN | |
94 | /* 3.2.19 */ | |
95 | g_assert_cmpint(qpci_config_readb(dev, 0x60), ==, 0x01); /* DRB0 */ | |
96 | g_assert_cmpint(qpci_config_readb(dev, 0x61), ==, 0x01); /* DRB1 */ | |
97 | g_assert_cmpint(qpci_config_readb(dev, 0x62), ==, 0x01); /* DRB2 */ | |
98 | g_assert_cmpint(qpci_config_readb(dev, 0x63), ==, 0x01); /* DRB3 */ | |
99 | g_assert_cmpint(qpci_config_readb(dev, 0x64), ==, 0x01); /* DRB4 */ | |
100 | g_assert_cmpint(qpci_config_readb(dev, 0x65), ==, 0x01); /* DRB5 */ | |
101 | g_assert_cmpint(qpci_config_readb(dev, 0x66), ==, 0x01); /* DRB6 */ | |
102 | g_assert_cmpint(qpci_config_readb(dev, 0x67), ==, 0x01); /* DRB7 */ | |
103 | #endif | |
104 | /* 3.2.20 */ | |
105 | g_assert_cmpint(qpci_config_readb(dev, 0x68), ==, 0x00); /* FDHC */ | |
106 | /* 3.2.21 */ | |
107 | g_assert_cmpint(qpci_config_readb(dev, 0x70), ==, 0x00); /* MTT */ | |
108 | #ifndef BROKEN | |
109 | /* 3.2.22 */ | |
110 | g_assert_cmpint(qpci_config_readb(dev, 0x71), ==, 0x10); /* CLT */ | |
111 | #endif | |
112 | /* 3.2.23 */ | |
113 | g_assert_cmpint(qpci_config_readb(dev, 0x72), ==, 0x02); /* SMRAM */ | |
114 | /* 3.2.24 */ | |
115 | g_assert_cmpint(qpci_config_readb(dev, 0x90), ==, 0x00); /* ERRCMD */ | |
116 | /* 3.2.25 */ | |
117 | g_assert_cmpint(qpci_config_readb(dev, 0x91), ==, 0x00); /* ERRSTS */ | |
118 | /* 3.2.26 */ | |
119 | g_assert_cmpint(qpci_config_readb(dev, 0x93), ==, 0x00); /* TRC */ | |
120 | } | |
121 | ||
122 | int main(int argc, char **argv) | |
123 | { | |
124 | QTestState *s; | |
125 | TestData data; | |
126 | char *cmdline; | |
127 | int ret; | |
128 | ||
129 | g_test_init(&argc, &argv, NULL); | |
130 | ||
131 | data.num_cpus = 1; | |
132 | ||
133 | cmdline = g_strdup_printf("-display none -smp %d", data.num_cpus); | |
134 | s = qtest_start(cmdline); | |
135 | g_free(cmdline); | |
136 | ||
137 | data.bus = qpci_init_pc(); | |
138 | ||
139 | g_test_add_data_func("/i440fx/defaults", &data, test_i440fx_defaults); | |
140 | ||
141 | ret = g_test_run(); | |
142 | ||
143 | if (s) { | |
144 | qtest_quit(s); | |
145 | } | |
146 | ||
147 | return ret; | |
148 | } |