[80641] | 1 | /* $Id: IOMR0.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * IOM - Host Context Ring 0.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[80641] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[80641] | 26 | */
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 | /*********************************************************************************************************************************
|
---|
| 30 | * Header Files *
|
---|
| 31 | *********************************************************************************************************************************/
|
---|
| 32 | #define LOG_GROUP LOG_GROUP_IOM
|
---|
| 33 | #include <VBox/vmm/iom.h>
|
---|
[93650] | 34 | #include <VBox/vmm/pgm.h>
|
---|
[80641] | 35 | #include "IOMInternal.h"
|
---|
| 36 | #include <VBox/vmm/vmcc.h>
|
---|
| 37 | #include <VBox/log.h>
|
---|
[93650] | 38 | #include <iprt/assert.h>
|
---|
[81167] | 39 | #include <iprt/assertcompile.h>
|
---|
[93650] | 40 | #include <iprt/errcore.h>
|
---|
[80641] | 41 |
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
| 45 | * Initializes the per-VM data for the IOM.
|
---|
| 46 | *
|
---|
| 47 | * This is called from under the GVMM lock, so it should only initialize the
|
---|
| 48 | * data so IOMR0CleanupVM and others will work smoothly.
|
---|
| 49 | *
|
---|
| 50 | * @param pGVM Pointer to the global VM structure.
|
---|
| 51 | */
|
---|
| 52 | VMMR0_INT_DECL(void) IOMR0InitPerVMData(PGVM pGVM)
|
---|
| 53 | {
|
---|
| 54 | AssertCompile(sizeof(pGVM->iom.s) <= sizeof(pGVM->iom.padding));
|
---|
| 55 | AssertCompile(sizeof(pGVM->iomr0.s) <= sizeof(pGVM->iomr0.padding));
|
---|
| 56 |
|
---|
[81167] | 57 | iomR0IoPortInitPerVMData(pGVM);
|
---|
[81197] | 58 | iomR0MmioInitPerVMData(pGVM);
|
---|
[80641] | 59 | }
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 | /**
|
---|
[93650] | 63 | * Called during ring-0 init (vmmR0InitVM).
|
---|
| 64 | *
|
---|
| 65 | * @returns VBox status code.
|
---|
| 66 | * @param pGVM Pointer to the global VM structure.
|
---|
| 67 | */
|
---|
| 68 | VMMR0_INT_DECL(int) IOMR0InitVM(PGVM pGVM)
|
---|
| 69 | {
|
---|
| 70 | int rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_MMIO, 0 /*fFlags*/,
|
---|
| 71 | iomMmioHandlerNew, iomMmioPfHandlerNew,
|
---|
| 72 | "MMIO", pGVM->iom.s.hNewMmioHandlerType);
|
---|
| 73 | AssertRCReturn(rc, rc);
|
---|
| 74 | return VINF_SUCCESS;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 |
|
---|
| 78 | /**
|
---|
[80641] | 79 | * Cleans up any loose ends before the GVM structure is destroyed.
|
---|
| 80 | */
|
---|
| 81 | VMMR0_INT_DECL(void) IOMR0CleanupVM(PGVM pGVM)
|
---|
| 82 | {
|
---|
[81167] | 83 | iomR0IoPortCleanupVM(pGVM);
|
---|
[81197] | 84 | iomR0MmioCleanupVM(pGVM);
|
---|
[80641] | 85 | }
|
---|
| 86 |
|
---|