ia64/xen-unstable

view tools/ioemu/hw/pass-through.h @ 16342:11dcbf74edf2

HVM device passthru: Correct PCI_EXP_DEVCTL_FLR

This patch corrects PCI_EXP_DEVCTL_FLR so that function level reset
will be really executed, and also replaces some magic numbers with
macros.

Signed-off-by: Anthony Xu <anthony.xu@intel.com>
Signed-off-by: Weidong Han <weidong.han@intel.com>
author Keir Fraser <keir@xensource.com>
date Wed Nov 07 09:21:16 2007 +0000 (2007-11-07)
parents acfa9290746f
children ad55c06c9bbc
line source
1 /*
2 * Copyright (c) 2007, Neocleus Corporation.
3 * Copyright (c) 2007, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
17 */
18 #ifndef __PASSTHROUGH_H__
19 #define __PASSTHROUGH_H__
21 #include "vl.h"
22 #include "pci/header.h"
23 #include "pci/pci.h"
25 /* Log acesss */
26 #define PT_LOGGING_ENABLED
28 #ifdef PT_LOGGING_ENABLED
29 #define PT_LOG(_f, _a...) fprintf(logfile, "%s: " _f, __func__, ##_a)
30 #else
31 #define PT_LOG(_f, _a...)
32 #endif
34 /* Some compilation flags */
35 // #define PT_DEBUG_PCI_CONFIG_ACCESS
37 #define PT_MACHINE_IRQ_AUTO (0xFFFFFFFF)
38 #define PT_VIRT_DEVFN_AUTO (-1)
40 /* Misc PCI constants that should be moved to a separate library :) */
41 #define PCI_CONFIG_SIZE (256)
42 #define PCI_EXP_DEVCAP_FLR (1 << 28)
43 #define PCI_EXP_DEVCTL_FLR (1 << 15)
44 #define PCI_BAR_ENTRIES (6)
46 struct pt_region {
47 /* Virtual phys base & size */
48 uint32_t e_physbase;
49 uint32_t e_size;
50 /* Index of region in qemu */
51 uint32_t memory_index;
52 /* Translation of the emulated address */
53 union {
54 uint32_t maddr;
55 uint32_t pio_base;
56 uint32_t u;
57 } access;
58 };
60 /*
61 This structure holds the context of the mapping functions
62 and data that is relevant for qemu device management.
63 */
64 struct pt_dev {
65 PCIDevice dev;
66 struct pci_dev *pci_dev; /* libpci struct */
67 struct pt_region bases[PCI_NUM_REGIONS]; /* Access regions */
68 };
70 /* Used for formatting PCI BDF into cf8 format */
71 struct pci_config_cf8 {
72 union {
73 unsigned int value;
74 struct {
75 unsigned int reserved1:2;
76 unsigned int reg:6;
77 unsigned int func:3;
78 unsigned int dev:5;
79 unsigned int bus:8;
80 unsigned int reserved2:7;
81 unsigned int enable:1;
82 };
83 };
84 };
86 int pt_init(PCIBus * e_bus, char * direct_pci);
88 #endif /* __PASSTHROUGH_H__ */