Printing coreboot debug messages on VGA console is pretty much useless, since
[coreboot.git] / src / drivers / emulation / qemu / init.c
1 #include <delay.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <arch/io.h>
5
6 #include <console/console.h>
7 #include <device/device.h>
8 #include <device/pci.h>
9 #include <device/pci_ids.h>
10 #include <device/pci_ops.h>
11
12 /* VGA init. We use the Bochs VESA VBE extensions  */
13 #define VBE_DISPI_INDEX_ID              0x0
14 #define VBE_DISPI_INDEX_XRES            0x1
15 #define VBE_DISPI_INDEX_YRES            0x2
16 #define VBE_DISPI_INDEX_BPP             0x3
17 #define VBE_DISPI_INDEX_ENABLE          0x4
18 #define VBE_DISPI_INDEX_BANK            0x5
19 #define VBE_DISPI_INDEX_VIRT_WIDTH      0x6
20 #define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
21 #define VBE_DISPI_INDEX_X_OFFSET        0x8
22 #define VBE_DISPI_INDEX_Y_OFFSET        0x9
23 #define VBE_DISPI_INDEX_NB              0xa
24
25 #define VBE_DISPI_ID0                   0xB0C0
26 #define VBE_DISPI_ID1                   0xB0C1
27 #define VBE_DISPI_ID2                   0xB0C2
28
29 #define VBE_DISPI_DISABLED              0x00
30 #define VBE_DISPI_ENABLED               0x01
31 #define VBE_DISPI_LFB_ENABLED           0x40
32 #define VBE_DISPI_NOCLEARMEM            0x80
33
34 #define VBE_DISPI_LFB_PHYSICAL_ADDRESS  0xE0000000
35
36 static void vbe_outw(int index, int val)
37 {
38     outw(0x1ce, index);
39     outw(0x1cf, val);
40 }
41
42 static void qemu_init(void)
43 {
44     int width=640, height=480, depth=8;
45
46     printk(BIOS_DEBUG, "Initializing VGA!\n");
47
48     vbe_outw(VBE_DISPI_INDEX_XRES, width);
49     vbe_outw(VBE_DISPI_INDEX_YRES, height);
50     vbe_outw(VBE_DISPI_INDEX_BPP, depth);
51     vbe_outw(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED);
52     outb(0x3c0, 0x20); /* disable blanking */
53 /*
54     vga_fb_phys_addr = VBE_DISPI_LFB_PHYSICAL_ADDRESS;
55     vga_fb_width = width;
56     vga_fb_height = height;
57     vga_fb_depth = depth;
58     vga_fb_bpp = (depth + 7) >> 3;
59     vga_fb_linesize = width * vga_fb_bpp;
60     */
61 }
62
63 static struct device_operations qemu_graph_ops  = {
64         .read_resources   = pci_dev_read_resources,
65         .set_resources    = pci_dev_set_resources,
66         .enable_resources = pci_dev_enable_resources,
67         .init             = qemu_init,
68         .scan_bus         = 0,
69 };
70
71 static const struct pci_driver qemu_graph_driver __pci_driver = {
72         .ops    = &qemu_graph_ops,
73         .vendor = 0x1234,
74         .device = 0x1111,
75 };
76
77