Changeset View
Changeset View
Standalone View
Standalone View
sys/x86/xen/arch.c
- This file was added.
/* | |||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD | |||||
* | |||||
* Copyright (c) 2021 Elliott Mitchell | |||||
* All rights reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in the | |||||
* documentation and/or other materials provided with the distribution. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS AS IS'' AND | |||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
* SUCH DAMAGE. | |||||
*/ | |||||
#include <sys/cdefs.h> | |||||
__FBSDID("$FreeBSD$"); | |||||
#include <sys/param.h> | |||||
#include <sys/systm.h> | |||||
#include <sys/bus.h> | |||||
#include <sys/rman.h> | |||||
#include <xen/xen-os.h> | |||||
/* | |||||
* Allocate unused physical memory above 4GB in order to map memory | |||||
* from foreign domains. We use memory starting at 4GB in order to | |||||
* prevent clashes with MMIO/ACPI regions. | |||||
* | |||||
* Since this is not possible on i386 just use any available memory | |||||
* chunk above 1MB and hope we don't clash with anything else. | |||||
*/ | |||||
#ifdef __amd64__ | |||||
#define LOW_MEM_LIMIT 0x100000000ul | |||||
#elif defined(__i386__) | |||||
#define LOW_MEM_LIMIT 0x100000ul | |||||
#else | |||||
#error "Unsupported architecture" | |||||
#endif | |||||
/* | |||||
* Function for allocating physical address resource to xenpv code | |||||
*/ | |||||
struct resource *xen_arch_alloc_addr(device_t dev, int *res_id, size_t size) | |||||
{ | |||||
return bus_alloc_resource(dev, SYS_RES_MEMORY, res_id, LOW_MEM_LIMIT, | |||||
~0, size, RF_ACTIVE | RF_UNMAPPED); | |||||
} | |||||
/* | |||||
* Function for releasing physical address resource from xenpv code | |||||
*/ | |||||
int xen_arch_release_addr(device_t dev, int res_id, struct resource *res) | |||||
{ | |||||
return bus_release_resource(dev, SYS_RES_MEMORY, res_id, res); | |||||
} |