1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <device/pci_ids.h>
5 #include <device/pci_ops.h>
12 static void print_pci_regs(struct device *dev)
18 byte = pci_read_config8(dev, i);
20 if((i & 0xf)==0) printk_debug("\n%02x:",i);
21 printk_debug(" %02x",byte);
26 static void print_mem(void)
29 unsigned int start = 0xfffff000;
30 for(i=start;i<0xffffffff;i++) {
31 if((i & 0xf)==0) printk_debug("\n %08x:",i);
32 printk_debug(" %02x ",(unsigned char)*((unsigned char *)i));
34 printk_debug(" %02x \n",(unsigned char)*((unsigned char *)i));
37 static void print_pci_regs_all(void)
43 for(j=0;j<=0x1f;j++) {
45 dev = dev_find_slot(i, PCI_DEVFN(j, k));
52 printk_debug("\n%02x:%02x:%02x aka %s",i,j,k, dev_path(dev));
60 static void debug_init(device_t dev)
65 // print_pci_regs_all();
71 unsigned eax, ebx, ecx, edx;
73 printk_debug("calling cpuid 0x%08x\n", index);
76 : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx)
79 printk_debug("cpuid[%08x]: %08x %08x %08x %08x\n",
80 index, eax, ebx, ecx, edx);
83 printk_debug("Reading msr: 0x%08x\n", index);
85 printk_debug("msr[0x%08x]: 0x%08x%08x\n",
86 index, msr.hi, msr.hi);
91 static void debug_noop(device_t dummy)
95 static struct device_operations debug_operations = {
96 .read_resources = debug_noop,
97 .set_resources = debug_noop,
98 .enable_resources = debug_noop,
102 static unsigned int scan_root_bus(device_t root, unsigned int max)
104 struct device_path path;
106 max = root_dev_scan_bus(root, max);
107 path.type = DEVICE_PATH_PNP;
109 path.u.pnp.device = 0;
110 debug = alloc_dev(&root->link[1], &path);
111 debug->ops = &debug_operations;
116 static void mainboard_init(device_t dev)
122 static struct device_operations mainboard_operations = {
123 .read_resources = root_dev_read_resources,
124 .set_resources = root_dev_set_resources,
125 .enable_resources = root_dev_enable_resources,
126 .init = mainboard_init,
127 .scan_bus = scan_root_bus,
130 static void enable_dev(struct device *dev)
132 dev_root.ops = &mainboard_operations;
136 struct chip_operations mainboard_tyan_s4882_ops = {
137 CHIP_NAME("Tyan s4882 mainboard")
139 .enable_dev = enable_dev,