Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


fixed null memory list bug in print_shadow_map
[palacios.releases.git] / palacios / src / devices / piix3.c
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2009, Lei Xia <lxia@northwestern.edu>
11  * Copyright (c) 2009, Chang Seok Bae <jhuell@gmail.com>
12  * Copyright (c) 2009, Jack Lange <jarusl@cs.northwestern.edu>
13  * Copyright (c) 2009, The V3VEE Project <http://www.v3vee.org> 
14  * All rights reserved.
15  *
16  * Author:  Lei Xia <lxia@northwestern.edu>
17  *          Chang Seok Bae <jhuell@gmail.com>
18  *          Jack Lange <jarusl@cs.northwestern.edu>
19  *
20  * This is free software.  You are permitted to use,
21  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
22  */ 
23  
24 #include <devices/piix3.h>
25 #include <palacios/vmm.h>
26 #include <devices/pci.h>
27 #include <devices/southbridge.h>
28
29
30
31 static int reset_piix3(struct vm_device * dev) {
32     struct v3_southbridge * piix3 = (struct v3_southbridge *)(dev->private_data);
33     struct pci_device * pci_dev = piix3->southbridge_pci;
34
35     pci_dev->config_header.command = 0x0007; // master, memory and I/O
36     pci_dev->config_header.status = 0x0200;
37
38     pci_dev->config_space[0x4c] = 0x4d;
39     pci_dev->config_space[0x4e] = 0x03;
40     pci_dev->config_space[0x4f] = 0x00;
41     pci_dev->config_space[0x60] = 0x80;
42     pci_dev->config_space[0x69] = 0x02;
43     pci_dev->config_space[0x70] = 0x80;
44     pci_dev->config_space[0x76] = 0x0c;
45     pci_dev->config_space[0x77] = 0x0c;
46     pci_dev->config_space[0x78] = 0x02;
47     pci_dev->config_space[0x79] = 0x00;
48     pci_dev->config_space[0x80] = 0x00;
49     pci_dev->config_space[0x82] = 0x00;
50     pci_dev->config_space[0xa0] = 0x08;
51     pci_dev->config_space[0xa2] = 0x00;
52     pci_dev->config_space[0xa3] = 0x00;
53     pci_dev->config_space[0xa4] = 0x00;
54     pci_dev->config_space[0xa5] = 0x00;
55     pci_dev->config_space[0xa6] = 0x00;
56     pci_dev->config_space[0xa7] = 0x00;
57     pci_dev->config_space[0xa8] = 0x0f;
58     pci_dev->config_space[0xaa] = 0x00;
59     pci_dev->config_space[0xab] = 0x00;
60     pci_dev->config_space[0xac] = 0x00;
61     pci_dev->config_space[0xae] = 0x00;
62
63     return 0;
64 }
65
66
67 static int init_piix3(struct vm_device * dev) {
68     struct v3_southbridge * piix3 = (struct v3_southbridge *)(dev->private_data);
69     struct pci_device * pci_dev = NULL;
70     struct v3_pci_bar bars[6];
71     int i;
72
73     for (i = 0; i < 6; i++) {
74         bars[i].type = PCI_BAR_NONE;
75     }
76
77     pci_dev = v3_pci_register_device(piix3->pci_bus, PCI_MULTIFUNCTION, 
78                                      0, -1, 0, 
79                                      "PIIX3", bars, 
80                                      NULL, NULL, NULL, dev);
81     if (!pci_dev) {
82         PrintError("Could not register PCI Device for PIIX3\n");
83         return -1;
84     }
85
86     pci_dev->config_header.vendor_id = 0x8086;
87     pci_dev->config_header.device_id = 0x7000; // PIIX4 is 0x7001
88     pci_dev->config_header.subclass = 0x01; //  SubClass: host2pci
89     pci_dev->config_header.class = 0x06;    // Class: PCI bridge
90
91     piix3->southbridge_pci = pci_dev;
92
93     reset_piix3(dev);
94
95     return 0;
96 }
97
98
99 static int deinit_piix3(struct vm_device * dev) {
100     return 0;
101 }
102
103
104 static struct vm_device_ops dev_ops = {
105     .init = init_piix3,
106     .deinit = deinit_piix3,
107     .reset = reset_piix3,
108     .start = NULL,
109     .stop = NULL,
110 };
111
112
113 struct vm_device * v3_create_piix3(struct vm_device * pci) {
114     struct v3_southbridge * piix3 = (struct v3_southbridge *)V3_Malloc(sizeof(struct v3_southbridge));
115     struct vm_device * dev = NULL;
116
117     piix3->pci_bus = pci;
118     piix3->type = V3_SB_PIIX3;
119     
120     dev = v3_create_device("PIIX3", &dev_ops, piix3);
121
122     PrintDebug("Created PIIX3\n");
123
124     return dev;
125 }