Deleted Added
full compact
pci_emul.c (330449) pci_emul.c (336161)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: stable/11/usr.sbin/bhyve/pci_emul.c 330449 2018-03-05 07:26:05Z eadler $
28 * $FreeBSD: stable/11/usr.sbin/bhyve/pci_emul.c 336161 2018-07-10 04:26:32Z araujo $
29 */
30
31#include <sys/cdefs.h>
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/pci_emul.c 330449 2018-03-05 07:26:05Z eadler $");
32__FBSDID("$FreeBSD: stable/11/usr.sbin/bhyve/pci_emul.c 336161 2018-07-10 04:26:32Z araujo $");
33
34#include <sys/param.h>
35#include <sys/linker_set.h>
36
37#include <ctype.h>
38#include <errno.h>
39#include <pthread.h>
40#include <stdio.h>

--- 817 unchanged lines hidden (view full) ---

858}
859
860void
861msixcap_cfgwrite(struct pci_devinst *pi, int capoff, int offset,
862 int bytes, uint32_t val)
863{
864 uint16_t msgctrl, rwmask;
865 int off;
33
34#include <sys/param.h>
35#include <sys/linker_set.h>
36
37#include <ctype.h>
38#include <errno.h>
39#include <pthread.h>
40#include <stdio.h>

--- 817 unchanged lines hidden (view full) ---

858}
859
860void
861msixcap_cfgwrite(struct pci_devinst *pi, int capoff, int offset,
862 int bytes, uint32_t val)
863{
864 uint16_t msgctrl, rwmask;
865 int off;
866
866
867 off = offset - capoff;
868 /* Message Control Register */
869 if (off == 2 && bytes == 2) {
870 rwmask = PCIM_MSIXCTRL_MSIX_ENABLE | PCIM_MSIXCTRL_FUNCTION_MASK;
871 msgctrl = pci_get_cfgdata16(pi, offset);
872 msgctrl &= ~rwmask;
873 msgctrl |= val & rwmask;
874 val = msgctrl;
875
876 pi->pi_msix.enabled = val & PCIM_MSIXCTRL_MSIX_ENABLE;
877 pi->pi_msix.function_mask = val & PCIM_MSIXCTRL_FUNCTION_MASK;
878 pci_lintr_update(pi);
867 off = offset - capoff;
868 /* Message Control Register */
869 if (off == 2 && bytes == 2) {
870 rwmask = PCIM_MSIXCTRL_MSIX_ENABLE | PCIM_MSIXCTRL_FUNCTION_MASK;
871 msgctrl = pci_get_cfgdata16(pi, offset);
872 msgctrl &= ~rwmask;
873 msgctrl |= val & rwmask;
874 val = msgctrl;
875
876 pi->pi_msix.enabled = val & PCIM_MSIXCTRL_MSIX_ENABLE;
877 pi->pi_msix.function_mask = val & PCIM_MSIXCTRL_FUNCTION_MASK;
878 pci_lintr_update(pi);
879 }
880
879 }
880
881 CFGWRITE(pi, offset, val, bytes);
882}
883
884void
885msicap_cfgwrite(struct pci_devinst *pi, int capoff, int offset,
886 int bytes, uint32_t val)
887{
888 uint16_t msgctrl, rwmask, msgdata, mme;

--- 442 unchanged lines hidden (view full) ---

1331 dsdt_line(" })");
1332
1333 count = pci_count_lintr(bus);
1334 if (count != 0) {
1335 dsdt_indent(2);
1336 dsdt_line("Name (PPRT, Package ()");
1337 dsdt_line("{");
1338 pci_walk_lintr(bus, pci_pirq_prt_entry, NULL);
881 CFGWRITE(pi, offset, val, bytes);
882}
883
884void
885msicap_cfgwrite(struct pci_devinst *pi, int capoff, int offset,
886 int bytes, uint32_t val)
887{
888 uint16_t msgctrl, rwmask, msgdata, mme;

--- 442 unchanged lines hidden (view full) ---

1331 dsdt_line(" })");
1332
1333 count = pci_count_lintr(bus);
1334 if (count != 0) {
1335 dsdt_indent(2);
1336 dsdt_line("Name (PPRT, Package ()");
1337 dsdt_line("{");
1338 pci_walk_lintr(bus, pci_pirq_prt_entry, NULL);
1339 dsdt_line("})");
1339 dsdt_line("})");
1340 dsdt_line("Name (APRT, Package ()");
1341 dsdt_line("{");
1342 pci_walk_lintr(bus, pci_apic_prt_entry, NULL);
1340 dsdt_line("Name (APRT, Package ()");
1341 dsdt_line("{");
1342 pci_walk_lintr(bus, pci_apic_prt_entry, NULL);
1343 dsdt_line("})");
1343 dsdt_line("})");
1344 dsdt_line("Method (_PRT, 0, NotSerialized)");
1345 dsdt_line("{");
1346 dsdt_line(" If (PICM)");
1347 dsdt_line(" {");
1348 dsdt_line(" Return (APRT)");
1349 dsdt_line(" }");
1350 dsdt_line(" Else");
1351 dsdt_line(" {");

--- 369 unchanged lines hidden (view full) ---

1721 }
1722 }
1723
1724 /*
1725 * If INTx has been unmasked and is pending, assert the
1726 * interrupt.
1727 */
1728 pci_lintr_update(pi);
1344 dsdt_line("Method (_PRT, 0, NotSerialized)");
1345 dsdt_line("{");
1346 dsdt_line(" If (PICM)");
1347 dsdt_line(" {");
1348 dsdt_line(" Return (APRT)");
1349 dsdt_line(" }");
1350 dsdt_line(" Else");
1351 dsdt_line(" {");

--- 369 unchanged lines hidden (view full) ---

1721 }
1722 }
1723
1724 /*
1725 * If INTx has been unmasked and is pending, assert the
1726 * interrupt.
1727 */
1728 pci_lintr_update(pi);
1729}
1729}
1730
1731static void
1732pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
1733 int coff, int bytes, uint32_t *eax)
1734{
1735 struct businfo *bi;
1736 struct slotinfo *si;
1737 struct pci_devinst *pi;

--- 368 unchanged lines hidden ---
1730
1731static void
1732pci_cfgrw(struct vmctx *ctx, int vcpu, int in, int bus, int slot, int func,
1733 int coff, int bytes, uint32_t *eax)
1734{
1735 struct businfo *bi;
1736 struct slotinfo *si;
1737 struct pci_devinst *pi;

--- 368 unchanged lines hidden ---