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.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
20 #include <palacios/vmm.h>
21 #include <devices/i440fx.h>
22 #include <devices/pci.h>
25 struct vm_device * pci;
29 static int io_read(ushort_t port, void * dst, uint_t length, struct vm_device * dev) {
30 PrintError("Unhandled read on port %x\n", port);
34 static int io_write(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
35 PrintError("Unhandled write on port %x\n", port);
41 static int i440_init(struct vm_device * dev) {
42 struct i440_state * state = (struct i440_state *)(dev->private_data);
43 struct pci_device * pci_dev = NULL;
44 struct v3_pci_bar bars[6];
47 for (i = 0; i < 4; i++) {
48 v3_dev_hook_io(dev, 0x0cf8 + i,
50 v3_dev_hook_io(dev, 0x0cfc + i,
54 for (i = 0; i < 6; i++) {
55 bars[i].type = PCI_BAR_NONE;
58 pci_dev = v3_pci_register_device(state->pci, PCI_STD_DEVICE, 0, 0, 0, "i440FX", bars,
59 NULL, NULL, NULL, dev);
65 pci_dev->config_header.vendor_id = 0x8086;
66 pci_dev->config_header.device_id = 0x1237;
67 pci_dev->config_header.revision = 0x02;
68 pci_dev->config_header.subclass = 0x00; // SubClass: host2pci
69 pci_dev->config_header.class = 0x06; // Class: PCI bridge
71 pci_dev->config_space[0x72] = 0x02; // SMRAM (?)
77 static int i440_deinit(struct vm_device * dev) {
81 static struct vm_device_ops dev_ops = {
83 .deinit = i440_deinit,
91 struct vm_device * v3_create_i440fx(struct vm_device * pci) {
92 struct i440_state * state = NULL;
94 state = (struct i440_state *)V3_Malloc(sizeof(struct i440_state));
98 struct vm_device * i440_dev = v3_create_device("i440FX", &dev_ops, state);