Move arm's devmap to some generic place, so it can be used

by other architectures.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D6091
Sponsored by:	DARPA, AFRL
Sponsored by:	HEIF5
This commit is contained in:
Ruslan Bukin 2016-04-26 11:53:37 +00:00
parent 6487f78716
commit 30b72b6871
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298627
46 changed files with 188 additions and 341 deletions

View File

@ -39,12 +39,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platformvar.h>
@ -98,7 +98,7 @@ static vm_offset_t
allwinner_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
/*
@ -115,7 +115,7 @@ static int
allwinner_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x01C00000, 0x00400000); /* 4MB */
devmap_add_entry(0x01C00000, 0x00400000); /* 4MB */
return (0);
}

View File

@ -38,12 +38,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/armreg.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -51,7 +51,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -77,7 +77,7 @@ platform_devmap_init(void)
{
/* UART */
arm_devmap_add_entry(0xffc00000, 0x100000);
devmap_add_entry(0xffc00000, 0x100000);
/*
* USB OTG
@ -87,16 +87,16 @@ platform_devmap_init(void)
* It might be caused due to some power save options being turned
* on or something else.
*/
arm_devmap_add_entry(0xffb00000, 0x100000);
devmap_add_entry(0xffb00000, 0x100000);
/* dwmmc */
arm_devmap_add_entry(0xff700000, 0x100000);
devmap_add_entry(0xff700000, 0x100000);
/* scu */
arm_devmap_add_entry(0xfff00000, 0x100000);
devmap_add_entry(0xfff00000, 0x100000);
/* FPGA memory window, 256MB */
arm_devmap_add_entry(0xd0000000, 0x10000000);
devmap_add_entry(0xd0000000, 0x10000000);
return (0);
}

View File

@ -35,13 +35,13 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/cpufunc.h>
#include <machine/devmap.h>
#include <machine/intr.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -85,7 +85,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -108,7 +108,7 @@ platform_gpio_init(void)
* and platform_gpio_init during which printf can't be used.
*/
aml8726_aobus_kva_base =
(vm_offset_t)arm_devmap_ptov(0xc8100000, 0x100000);
(vm_offset_t)devmap_ptov(0xc8100000, 0x100000);
/*
* The hardware mux used by clkmsr is unique to the SoC (though
@ -154,14 +154,14 @@ int
platform_devmap_init(void)
{
arm_devmap_add_entry(0xc1100000, 0x200000); /* cbus */
arm_devmap_add_entry(0xc4200000, 0x100000); /* pl310 */
arm_devmap_add_entry(0xc4300000, 0x100000); /* periph */
arm_devmap_add_entry(0xc8000000, 0x100000); /* apbbus */
arm_devmap_add_entry(0xc8100000, 0x100000); /* aobus */
arm_devmap_add_entry(0xc9000000, 0x800000); /* ahbbus */
arm_devmap_add_entry(0xd9000000, 0x100000); /* ahb */
arm_devmap_add_entry(0xda000000, 0x100000); /* secbus */
devmap_add_entry(0xc1100000, 0x200000); /* cbus */
devmap_add_entry(0xc4200000, 0x100000); /* pl310 */
devmap_add_entry(0xc4300000, 0x100000); /* periph */
devmap_add_entry(0xc8000000, 0x100000); /* apbbus */
devmap_add_entry(0xc8100000, 0x100000); /* aobus */
devmap_add_entry(0xc9000000, 0x800000); /* ahbbus */
devmap_add_entry(0xd9000000, 0x100000); /* ahb */
devmap_add_entry(0xda000000, 0x100000); /* secbus */
return (0);
}

View File

@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@ -42,7 +43,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/frame.h> /* For trapframe_t, used in <machine/machdep.h> */
#include <machine/machdep.h>
#include <machine/devmap.h>
#include <machine/platform.h>
#include <machine/fdt.h>
@ -128,7 +128,7 @@ int
platform_devmap_init(void)
{
alpine_get_devmap_base(&al_devmap_pa, &al_devmap_size);
arm_devmap_add_entry(al_devmap_pa, al_devmap_size);
devmap_add_entry(al_devmap_pa, al_devmap_size);
return (0);
}

View File

@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@ -51,7 +52,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/cpufunc.h>
#include <machine/devmap.h>
void
generic_bs_unimplemented(void)

View File

@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <sys/cons.h>
#include <sys/cpu.h>
#include <sys/ctype.h>
#include <sys/devmap.h>
#include <sys/efi.h>
#include <sys/exec.h>
#include <sys/imgact.h>
@ -100,7 +101,6 @@ __FBSDID("$FreeBSD$");
#include <machine/cpuinfo.h>
#include <machine/debug_monitor.h>
#include <machine/db_machdep.h>
#include <machine/devmap.h>
#include <machine/frame.h>
#include <machine/intr.h>
#include <machine/machdep.h>
@ -455,7 +455,7 @@ cpu_startup(void *dummy)
(uintmax_t)arm32_ptob(vm_cnt.v_free_count) / mbyte);
if (bootverbose) {
arm_physmem_print_tables();
arm_devmap_print_table();
devmap_print_table();
}
bufinit();
@ -1692,7 +1692,7 @@ initarm(struct arm_boot_params *abp)
/* Establish static device mappings. */
err_devmap = platform_devmap_init();
arm_devmap_bootstrap(l1pagetable, NULL);
devmap_bootstrap(l1pagetable, NULL);
vm_max_kernel_address = platform_lastaddr();
cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT);
@ -1913,7 +1913,7 @@ initarm(struct arm_boot_params *abp)
/* Establish static device mappings. */
err_devmap = platform_devmap_init();
arm_devmap_bootstrap(0, NULL);
devmap_bootstrap(0, NULL);
vm_max_kernel_address = platform_lastaddr();
/*

View File

@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
@ -45,7 +46,6 @@ __FBSDID("$FreeBSD$");
#include <machine/armreg.h>
#define _ARM32_BUS_DMA_PRIVATE
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/intr.h>
#include <arm/at91/at91var.h>

View File

@ -30,10 +30,10 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/devmap.h>
#include <machine/intr.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include <machine/fdt.h>
extern const struct arm_devmap_entry at91_devmap[];
extern const struct devmap_entry at91_devmap[];
struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
@ -91,7 +91,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -106,9 +106,9 @@ int
platform_devmap_init(void)
{
// arm_devmap_add_entry(0xfff00000, 0x00100000); /* 1MB - uart, aic and timers*/
// devmap_add_entry(0xfff00000, 0x00100000); /* 1MB - uart, aic and timers*/
arm_devmap_register_table(at91_devmap);
devmap_register_table(at91_devmap);
return (0);
}

View File

@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
#include <sys/exec.h>
#include <sys/kdb.h>
#include <sys/msgbuf.h>
#include <sys/devmap.h>
#include <machine/physmem.h>
#include <machine/reg.h>
#include <machine/cpu.h>
@ -81,7 +82,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
#include <machine/devmap.h>
#include <machine/vmparam.h>
#include <machine/pcb.h>
#include <machine/undefined.h>
@ -117,7 +117,7 @@ __FBSDID("$FreeBSD$");
struct pv_addr kernel_pt_table[NUM_KERNEL_PTS];
/* Static device mappings. */
const struct arm_devmap_entry at91_devmap[] = {
const struct devmap_entry at91_devmap[] = {
/*
* Map the critical on-board devices. The interrupt vector at
* 0xffff0000 makes it impossible to map them PA == VA, so we map all
@ -552,7 +552,7 @@ initarm(struct arm_boot_params *abp)
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
}
arm_devmap_bootstrap(l1pagetable, at91_devmap);
devmap_bootstrap(l1pagetable, at91_devmap);
cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL * 2)) | DOMAIN_CLIENT);
cpu_setttb(kernel_l1pt.pv_pa);
cpu_tlb_flushID();

View File

@ -46,12 +46,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
#include <machine/platformvar.h>
@ -66,7 +66,7 @@ static vm_offset_t
bcm2835_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
static void
@ -98,7 +98,7 @@ static int
bcm2835_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x20000000, 0x01000000);
devmap_add_entry(0x20000000, 0x01000000);
return (0);
}
#endif
@ -108,7 +108,7 @@ static int
bcm2836_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x3f000000, 0x01000000);
devmap_add_entry(0x3f000000, 0x01000000);
return (0);
}
#endif

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <sys/exec.h>
#include <sys/kdb.h>
#include <sys/msgbuf.h>
#include <sys/devmap.h>
#include <machine/physmem.h>
#include <machine/reg.h>
#include <machine/cpu.h>
@ -71,7 +72,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
#include <machine/devmap.h>
#include <machine/vmparam.h>
#include <machine/pcb.h>
#include <machine/undefined.h>
@ -105,7 +105,7 @@ struct pv_addr abtstack;
struct pv_addr kernelstack;
/* Static device mappings. */
static const struct arm_devmap_entry econa_devmap[] = {
static const struct devmap_entry econa_devmap[] = {
{
/*
* This maps DDR SDRAM
@ -263,7 +263,7 @@ initarm(struct arm_boot_params *abp)
VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
}
arm_devmap_bootstrap(l1pagetable, econa_devmap);
devmap_bootstrap(l1pagetable, econa_devmap);
cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
cpu_setttb(kernel_l1pt.pv_pa);
cpu_tlb_flushID();

View File

@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm.h>
#include <vm/pmap.h>
#include <dev/fdt/fdt_common.h>
#include <machine/devmap.h>
#include <sys/devmap.h>
static uint32_t *ocotp_regs;
static vm_size_t ocotp_size;

View File

@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/reboot.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platformvar.h>
@ -49,7 +49,7 @@ static vm_offset_t
imx51_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
static int
@ -74,9 +74,9 @@ static int
imx51_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x70000000, 0x00100000);
arm_devmap_add_entry(0x73f00000, 0x00100000);
arm_devmap_add_entry(0x83f00000, 0x00100000);
devmap_add_entry(0x70000000, 0x00100000);
devmap_add_entry(0x73f00000, 0x00100000);
devmap_add_entry(0x83f00000, 0x00100000);
return (0);
}

View File

@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/reboot.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platformvar.h>
@ -49,7 +49,7 @@ static vm_offset_t
imx53_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
static int
@ -74,9 +74,9 @@ static int
imx53_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x50000000, 0x00100000);
arm_devmap_add_entry(0x53f00000, 0x00100000);
arm_devmap_add_entry(0x63f00000, 0x00100000);
devmap_add_entry(0x50000000, 0x00100000);
devmap_add_entry(0x53f00000, 0x00100000);
devmap_add_entry(0x63f00000, 0x00100000);
return (0);
}

View File

@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/reboot.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/intr.h>
#include <machine/machdep.h>
#include <machine/platformvar.h>
@ -166,7 +166,7 @@ static vm_offset_t
imx6_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
static int
@ -220,9 +220,9 @@ imx6_devmap_init(platform_t plat)
const uint32_t IMX6_AIPS2_PHYS = 0x02100000;
const uint32_t IMX6_AIPS2_SIZE = 0x00100000;
arm_devmap_add_entry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE);
arm_devmap_add_entry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE);
arm_devmap_add_entry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE);
devmap_add_entry(IMX6_ARMMP_PHYS, IMX6_ARMMP_SIZE);
devmap_add_entry(IMX6_AIPS1_PHYS, IMX6_AIPS1_SIZE);
devmap_add_entry(IMX6_AIPS2_PHYS, IMX6_AIPS2_SIZE);
return (0);
}
@ -287,7 +287,7 @@ u_int imx_soc_type()
IMX6_ANALOG_DIGPROG_SOCTYPE_SHIFT;
/*printf("digprog = 0x%08x\n", digprog);*/
if (hwsoc == HWSOC_MX6DL) {
pcr = arm_devmap_ptov(SCU_CONFIG_PHYSADDR, 4);
pcr = devmap_ptov(SCU_CONFIG_PHYSADDR, 4);
if (pcr != NULL) {
/*printf("scu config = 0x%08x\n", *pcr);*/
if ((*pcr & 0x03) == 0) {

View File

@ -33,13 +33,13 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/reboot.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/armreg.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <arm/freescale/imx/imx_machdep.h>
@ -85,7 +85,7 @@ imx_wdog_cpu_reset(vm_offset_t wdcr_physaddr)
* control register. The reset happens on the next cycle of the wdog
* 32KHz clock, so hang out in a spin loop until the reset takes effect.
*/
if ((pcr = arm_devmap_ptov(wdcr_physaddr, sizeof(*pcr))) == NULL) {
if ((pcr = devmap_ptov(wdcr_physaddr, sizeof(*pcr))) == NULL) {
printf("cpu_reset() can't find its control register... locking up now.");
} else {
*pcr &= ~WDOG_CR_SRS;
@ -99,7 +99,7 @@ imx_wdog_init_last_reset(vm_offset_t wdsr_phys)
{
volatile uint16_t * psr;
if ((psr = arm_devmap_ptov(wdsr_phys, sizeof(*psr))) == NULL)
if ((psr = devmap_ptov(wdsr_phys, sizeof(*psr))) == NULL)
return;
last_reset_status = *psr;
if (last_reset_status & WDOG_RSR_SFTW) {

View File

@ -34,12 +34,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/armreg.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -49,7 +49,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -74,7 +74,7 @@ int
platform_devmap_init(void)
{
arm_devmap_add_entry(0x40000000, 0x100000);
devmap_add_entry(0x40000000, 0x100000);
return (0);
}

View File

@ -172,4 +172,6 @@ extern vm_offset_t vm_max_kernel_address;
#define SFBUF
#define SFBUF_MAP
#define DEVMAP_MAX_VADDR ARM_VECTORS_HIGH
#endif /* _MACHINE_VMPARAM_H_ */

View File

@ -45,13 +45,13 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/fdt.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -64,7 +64,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -90,13 +90,13 @@ platform_late_init(void)
/*
* Add a single static device mapping.
* The values used were taken from the ranges property of the SoC node in the
* dts file when this code was converted to arm_devmap_add_entry().
* dts file when this code was converted to devmap_add_entry().
*/
int
platform_devmap_init(void)
{
arm_devmap_add_entry(LPC_DEV_PHYS_BASE, LPC_DEV_SIZE);
devmap_add_entry(LPC_DEV_PHYS_BASE, LPC_DEV_SIZE);
return (0);
}

View File

@ -381,7 +381,7 @@ soc_id(uint32_t *dev, uint32_t *rev)
* Notice: system identifiers are available in the registers range of
* PCIE controller, so using this function is only allowed (and
* possible) after the internal registers range has been mapped in via
* arm_devmap_bootstrap().
* devmap_bootstrap().
*/
*dev = bus_space_read_4(fdtbus_bs_tag, MV_PCIE_BASE, 0) >> 16;
*rev = bus_space_read_4(fdtbus_bs_tag, MV_PCIE_BASE, 8) & 0xff;

View File

@ -36,10 +36,10 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/rman.h>
#include <sys/malloc.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/devmap.h>
#include <machine/fdt.h>
#include <dev/ofw/ofw_bus.h>
@ -384,7 +384,7 @@ localbus_get_devinfo(device_t bus, device_t child)
}
int
fdt_localbus_devmap(phandle_t dt_node, struct arm_devmap_entry *fdt_devmap,
fdt_localbus_devmap(phandle_t dt_node, struct devmap_entry *fdt_devmap,
int banks_max_num, int *banks_added)
{
pcell_t ranges[MV_LOCALBUS_MAX_BANKS * MV_LOCALBUS_MAX_BANK_CELLS];

View File

@ -45,12 +45,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/fdt.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -270,12 +270,12 @@ platform_late_init(void)
}
#define FDT_DEVMAP_MAX (MV_WIN_CPU_MAX + 2)
static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
{ 0, 0, 0, }
};
static int
platform_sram_devmap(struct arm_devmap_entry *map)
platform_sram_devmap(struct devmap_entry *map)
{
#if !defined(SOC_MV_ARMADAXP)
phandle_t child, root;
@ -318,10 +318,10 @@ platform_sram_devmap(struct arm_devmap_entry *map)
* real implementation of this function in arm/mv/mv_pci.c overrides the weak
* alias defined here.
*/
int mv_default_fdt_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap,
int mv_default_fdt_pci_devmap(phandle_t node, struct devmap_entry *devmap,
vm_offset_t io_va, vm_offset_t mem_va);
int
mv_default_fdt_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap,
mv_default_fdt_pci_devmap(phandle_t node, struct devmap_entry *devmap,
vm_offset_t io_va, vm_offset_t mem_va)
{
@ -345,7 +345,7 @@ platform_devmap_init(void)
int i, num_mapped;
i = 0;
arm_devmap_register_table(&fdt_devmap[0]);
devmap_register_table(&fdt_devmap[0]);
#ifdef SOC_MV_ARMADAXP
vm_paddr_t cur_immr_pa;

View File

@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/rman.h>
#include <sys/endian.h>
#include <sys/devmap.h>
#include <machine/fdt.h>
#include <machine/intr.h>
@ -70,7 +71,6 @@ __FBSDID("$FreeBSD$");
#include "ofw_bus_if.h"
#include "pcib_if.h"
#include <machine/devmap.h>
#include <machine/resource.h>
#include <machine/bus.h>
@ -221,7 +221,7 @@ mv_pci_ranges(phandle_t node, struct mv_pci_range *io_space,
}
int
mv_pci_devmap(phandle_t node, struct arm_devmap_entry *devmap, vm_offset_t io_va,
mv_pci_devmap(phandle_t node, struct devmap_entry *devmap, vm_offset_t io_va,
vm_offset_t mem_va)
{
struct mv_pci_range io_space, mem_space;

View File

@ -135,10 +135,10 @@ uint32_t mv_drbl_get_msg(int mnr, int dir, int unit);
int mv_msi_data(int irq, uint64_t *addr, uint32_t *data);
struct arm_devmap_entry;
struct devmap_entry;
int mv_pci_devmap(phandle_t, struct arm_devmap_entry *, vm_offset_t,
int mv_pci_devmap(phandle_t, struct devmap_entry *, vm_offset_t,
vm_offset_t);
int fdt_localbus_devmap(phandle_t, struct arm_devmap_entry *, int, int *);
int fdt_localbus_devmap(phandle_t, struct devmap_entry *, int, int *);
#endif /* _MVVAR_H_ */

View File

@ -73,7 +73,7 @@ __FBSDID("$FreeBSD$");
int platform_pci_get_irq(u_int bus, u_int slot, u_int func, u_int pin);
/* Static device mappings. */
const struct arm_devmap_entry db88f5xxx_devmap[] = {
const struct devmap_entry db88f5xxx_devmap[] = {
/*
* Map the on-board devices VA == PA so that we can access them
* with the MMU on or off.

View File

@ -34,11 +34,11 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/reboot.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/fdt.h>
#include <machine/intr.h>
#include <machine/machdep.h>
@ -84,7 +84,7 @@ static vm_offset_t
tegra124_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
static int
@ -108,7 +108,7 @@ static int
tegra124_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x70000000, 0x01000000);
devmap_add_entry(0x70000000, 0x01000000);
return (0);
}

View File

@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/rman.h>
#include <sys/endian.h>
#include <sys/devmap.h>
#include <machine/intr.h>
@ -60,7 +61,6 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcireg.h>
#include <dev/pci/pcib_private.h>
#include <machine/devmap.h>
#include <machine/resource.h>
#include <machine/bus.h>
@ -1688,4 +1688,4 @@ static driver_t tegra_pcib_driver = {
devclass_t pcib_devclass;
DRIVER_MODULE(pcib, simplebus, tegra_pcib_driver, pcib_devclass, 0, 0);
DRIVER_MODULE(pcib, simplebus, tegra_pcib_driver, pcib_devclass, 0, 0);

View File

@ -33,11 +33,11 @@ __FBSDID("$FreeBSD$");
#define _ARM32_BUS_DMA_PRIVATE
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/platform.h>
#include <machine/platformvar.h>
@ -70,7 +70,7 @@ static vm_offset_t
virt_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
/*
@ -80,7 +80,7 @@ static int
virt_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x09000000, 0x100000); /* Uart */
devmap_add_entry(0x09000000, 0x100000); /* Uart */
return (0);
}

View File

@ -38,13 +38,13 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/armreg.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -56,7 +56,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -86,8 +86,8 @@ int
platform_devmap_init(void)
{
arm_devmap_add_entry(0x10000000, 0x00200000);
arm_devmap_add_entry(0x20000000, 0x00100000);
devmap_add_entry(0x10000000, 0x00200000);
devmap_add_entry(0x20000000, 0x00100000);
return (0);
}

View File

@ -34,12 +34,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <machine/armreg.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -47,7 +47,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -73,13 +73,13 @@ platform_devmap_init(void)
{
/* CHIP ID */
arm_devmap_add_entry(0x10000000, 0x100000);
devmap_add_entry(0x10000000, 0x100000);
/* UART */
arm_devmap_add_entry(0x12C00000, 0x100000);
devmap_add_entry(0x12C00000, 0x100000);
/* DWMMC */
arm_devmap_add_entry(0x12200000, 0x100000);
devmap_add_entry(0x12200000, 0x100000);
return (0);
}

View File

@ -44,12 +44,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platformvar.h>
@ -63,7 +63,7 @@ static vm_offset_t
ti_lastaddr(platform_t plat)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
/*
@ -74,8 +74,8 @@ ti_lastaddr(platform_t plat)
static int
ti_omap4_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */
arm_devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_CFG devices */
devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */
devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_CFG devices */
return (0);
}
#endif
@ -85,13 +85,13 @@ static int
ti_am335x_devmap_init(platform_t plat)
{
arm_devmap_add_entry(0x44C00000, 0x00400000); /* 4mb L4_WKUP devices*/
arm_devmap_add_entry(0x47400000, 0x00100000); /* 1mb USB */
arm_devmap_add_entry(0x47800000, 0x00100000); /* 1mb mmchs2 */
arm_devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */
arm_devmap_add_entry(0x49000000, 0x00100000); /* 1mb edma3 */
arm_devmap_add_entry(0x49800000, 0x00300000); /* 3mb edma3 */
arm_devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_FAST devices*/
devmap_add_entry(0x44C00000, 0x00400000); /* 4mb L4_WKUP devices*/
devmap_add_entry(0x47400000, 0x00100000); /* 1mb USB */
devmap_add_entry(0x47800000, 0x00100000); /* 1mb mmchs2 */
devmap_add_entry(0x48000000, 0x01000000); /*16mb L4_PER devices */
devmap_add_entry(0x49000000, 0x00100000); /* 1mb edma3 */
devmap_add_entry(0x49800000, 0x00300000); /* 3mb edma3 */
devmap_add_entry(0x4A000000, 0x01000000); /*16mb L4_FAST devices*/
return (0);
}
#endif

View File

@ -43,12 +43,12 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -81,7 +81,7 @@ platform_late_init(void)
}
#define FDT_DEVMAP_MAX (2) /* FIXME */
static struct arm_devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
static struct devmap_entry fdt_devmap[FDT_DEVMAP_MAX] = {
{ 0, 0, 0, },
{ 0, 0, 0, }
};
@ -98,7 +98,7 @@ platform_devmap_init(void)
fdt_devmap[i].pd_pa = 0x10100000;
fdt_devmap[i].pd_size = 0x01000000; /* 1 MB */
arm_devmap_register_table(&fdt_devmap[0]);
devmap_register_table(&fdt_devmap[0]);
return (0);
}

View File

@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/pmap.h>
@ -47,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <dev/fdt/fdt_common.h>
#include <machine/bus.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@ -59,7 +59,7 @@ vm_offset_t
platform_lastaddr(void)
{
return (arm_devmap_lastaddr());
return (devmap_lastaddr());
}
void
@ -87,8 +87,8 @@ int
platform_devmap_init(void)
{
arm_devmap_add_entry(ZYNQ7_PSIO_HWBASE, ZYNQ7_PSIO_SIZE);
arm_devmap_add_entry(ZYNQ7_PSCTL_HWBASE, ZYNQ7_PSCTL_SIZE);
devmap_add_entry(ZYNQ7_PSIO_HWBASE, ZYNQ7_PSIO_SIZE);
devmap_add_entry(ZYNQ7_PSCTL_HWBASE, ZYNQ7_PSCTL_SIZE);
return (0);
}

View File

@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <sys/exec.h>
#include <sys/kdb.h>
#include <sys/msgbuf.h>
#include <sys/devmap.h>
#include <machine/reg.h>
#include <machine/cpu.h>
@ -80,7 +81,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
#include <machine/devmap.h>
#include <machine/vmparam.h>
#include <machine/pcb.h>
#include <machine/undefined.h>
@ -120,7 +120,7 @@ struct pv_addr abtstack;
struct pv_addr kernelstack;
/* Static device mappings. */
static const struct arm_devmap_entry iq81342_devmap[] = {
static const struct devmap_entry iq81342_devmap[] = {
{
IOP34X_VADDR,
IOP34X_HWADDR,
@ -249,7 +249,7 @@ initarm(struct arm_boot_params *abp)
/* Map the vector page. */
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
arm_devmap_bootstrap(l1pagetable, iq81342_devmap);
devmap_bootstrap(l1pagetable, iq81342_devmap);
/*
* Give the XScale global cache clean code an appropriately
* sized chunk of unmapped VA space starting at 0xff000000

View File

@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <sys/exec.h>
#include <sys/kdb.h>
#include <sys/msgbuf.h>
#include <sys/devmap.h>
#include <machine/physmem.h>
#include <machine/reg.h>
#include <machine/cpu.h>
@ -81,7 +82,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
#include <machine/devmap.h>
#include <machine/vmparam.h>
#include <machine/pcb.h>
#include <machine/undefined.h>
@ -117,7 +117,7 @@ struct pv_addr kernelstack;
struct pv_addr minidataclean;
/* Static device mappings. */
static const struct arm_devmap_entry ixp425_devmap[] = {
static const struct devmap_entry ixp425_devmap[] = {
/* Physical/Virtual address for I/O space */
{ IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE, },
@ -144,7 +144,7 @@ static const struct arm_devmap_entry ixp425_devmap[] = {
};
/* Static device mappings. */
static const struct arm_devmap_entry ixp435_devmap[] = {
static const struct devmap_entry ixp435_devmap[] = {
/* Physical/Virtual address for I/O space */
{ IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE, },
@ -326,9 +326,9 @@ initarm(struct arm_boot_params *abp)
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
if (cpu_is_ixp43x())
arm_devmap_bootstrap(l1pagetable, ixp435_devmap);
devmap_bootstrap(l1pagetable, ixp435_devmap);
else
arm_devmap_bootstrap(l1pagetable, ixp425_devmap);
devmap_bootstrap(l1pagetable, ixp425_devmap);
/*
* Give the XScale global cache clean code an appropriately
* sized chunk of unmapped VA space starting at 0xff000000

View File

@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <sys/exec.h>
#include <sys/kdb.h>
#include <sys/msgbuf.h>
#include <sys/devmap.h>
#include <machine/reg.h>
#include <machine/cpu.h>
@ -81,7 +82,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_object.h>
#include <vm/vm_page.h>
#include <vm/vm_map.h>
#include <machine/devmap.h>
#include <machine/vmparam.h>
#include <machine/pcb.h>
#include <machine/undefined.h>
@ -120,7 +120,7 @@ static void pxa_probe_sdram(bus_space_tag_t, bus_space_handle_t,
uint32_t *, uint32_t *);
/* Static device mappings. */
static const struct arm_devmap_entry pxa_devmap[] = {
static const struct devmap_entry pxa_devmap[] = {
/*
* Map the on-board devices up into the KVA region so we don't muck
* up user-space.
@ -254,7 +254,7 @@ initarm(struct arm_boot_params *abp)
/* Map the vector page. */
pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
arm_devmap_bootstrap(l1pagetable, pxa_devmap);
devmap_bootstrap(l1pagetable, pxa_devmap);
/*
* Give the XScale global cache clean code an appropriately

View File

@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/cons.h>
#include <sys/cpu.h>
#include <sys/devmap.h>
#include <sys/efi.h>
#include <sys/exec.h>
#include <sys/imgact.h>
@ -70,7 +71,6 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/debug_monitor.h>
#include <machine/kdb.h>
#include <machine/devmap.h>
#include <machine/machdep.h>
#include <machine/metadata.h>
#include <machine/md_var.h>
@ -912,7 +912,7 @@ initarm(struct arm64_bootparams *abp)
pmap_bootstrap(abp->kern_l0pt, abp->kern_l1pt,
KERNBASE - abp->kern_delta, lastaddr - KERNBASE);
arm_devmap_bootstrap(0, NULL);
devmap_bootstrap(0, NULL);
cninit();

View File

@ -1,91 +0,0 @@
/*-
* Copyright (c) 2013 Ian Lepore <ian@freebsd.org>
* 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.
*
* $FreeBSD$
*/
#ifndef _MACHINE_DEVMAP_H_
#define _MACHINE_DEVMAP_H_
/*
* This structure is used by MD code to describe static mappings of devices
* which are established as part of bringing up the MMU early in the boot.
*/
struct arm_devmap_entry {
vm_offset_t pd_va; /* virtual address */
vm_paddr_t pd_pa; /* physical address */
vm_size_t pd_size; /* size of region */
};
/*
* Return the lowest KVA address used in any entry in the registered devmap
* table. This works with whatever table is registered, including the internal
* table used by arm_devmap_add_entry() if that routine was used. Platforms can
* implement initarm_lastaddr() by calling this if static device mappings are
* their only use of high KVA space.
*/
vm_offset_t arm_devmap_lastaddr(void);
/*
* Automatically allocate KVA (from the top of the address space downwards) and
* make static device mapping entries in an internal table. The internal table
* is automatically registered on the first call to this.
*/
void arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz);
/*
* Register a platform-local table to be bootstrapped by the generic
* initarm() in arm/machdep.c. This is used by newer code that allocates and
* fills in its own local table but does not have its own initarm() routine.
*/
void arm_devmap_register_table(const struct arm_devmap_entry * _table);
/*
* Establish mappings for all the entries in the table. This is called
* automatically from the common initarm() in arm/machdep.c, and also from the
* custom initarm() routines in older code. If the table pointer is NULL, this
* will use the table installed previously by arm_devmap_register_table().
*/
void arm_devmap_bootstrap(vm_offset_t _l1pt,
const struct arm_devmap_entry *_table);
/*
* Translate between virtual and physical addresses within a region that is
* static-mapped by the devmap code. If the given address range isn't
* static-mapped, then ptov returns NULL and vtop returns DEVMAP_PADDR_NOTFOUND.
* The latter implies that you can't vtop just the last byte of physical address
* space. This is not as limiting as it might sound, because even if a device
* occupies the end of the physical address space, you're only prevented from
* doing vtop for that single byte. If you vtop a size bigger than 1 it works.
*/
#define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1))
void * arm_devmap_ptov(vm_paddr_t _pa, vm_size_t _sz);
vm_paddr_t arm_devmap_vtop(void * _va, vm_size_t _sz);
/* Print the static mapping table; used for bootverbose output. */
void arm_devmap_print_table(void);
#endif

View File

@ -247,4 +247,6 @@ extern vm_offset_t init_pt_va;
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -29,7 +29,6 @@ arm/arm/db_disasm.c optional ddb
arm/arm/db_interface.c optional ddb
arm/arm/db_trace.c optional ddb
arm/arm/debug_monitor.c optional ddb armv6
arm/arm/devmap.c standard
arm/arm/disassem.c optional ddb
arm/arm/dump_machdep.c standard
arm/arm/elf_machdep.c standard
@ -117,6 +116,7 @@ font.h optional sc \
clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8"
kern/pic_if.m optional intrng
kern/subr_busdma_bufalloc.c standard
kern/subr_devmap.c standard
kern/subr_sfbuf.c standard
libkern/arm/aeabi_unwind.c standard
libkern/arm/divsi3.S standard

View File

@ -1,5 +1,4 @@
# $FreeBSD$
arm/arm/devmap.c standard
arm/arm/generic_timer.c standard
arm/arm/pmu.c standard
arm64/acpica/acpi_machdep.c optional acpi
@ -84,6 +83,7 @@ dev/vnic/thunder_mdio_fdt.c optional vnic fdt
dev/vnic/thunder_mdio.c optional vnic
dev/vnic/lmac_if.m optional vnic
kern/kern_clocksource.c standard
kern/subr_devmap.c standard
libkern/bcmp.c standard
libkern/ffs.c standard
libkern/ffsl.c standard

View File

@ -3,6 +3,7 @@ crypto/blowfish/bf_enc.c optional crypto | ipsec
crypto/des/des_enc.c optional crypto | ipsec | netsmb
dev/ofw/ofw_cpu.c optional fdt
kern/kern_clocksource.c standard
kern/subr_devmap.c standard
kern/subr_dummy_vdso_tc.c standard
libkern/bcmp.c standard
libkern/ffs.c standard
@ -26,7 +27,6 @@ riscv/riscv/cpufunc_asm.S standard
riscv/riscv/db_disasm.c optional ddb
riscv/riscv/db_interface.c optional ddb
riscv/riscv/db_trace.c optional ddb
riscv/riscv/devmap.c standard
riscv/riscv/dump_machdep.c standard
riscv/riscv/elf_machdep.c standard
riscv/riscv/intr_machdep.c standard

View File

@ -27,45 +27,34 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* Routines for mapping device memory.
*
* This is used on both arm and arm64.
*/
/* Routines for mapping device memory. */
#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/devmap.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/pmap.h>
#ifdef __arm__
#include <machine/acle-compat.h>
#endif
#include <machine/armreg.h>
#include <machine/devmap.h>
#include <machine/vmparam.h>
static const struct arm_devmap_entry *devmap_table;
static const struct devmap_entry *devmap_table;
static boolean_t devmap_bootstrap_done = false;
#if defined(__aarch64__)
#define MAX_VADDR VM_MAX_KERNEL_ADDRESS
#elif defined(__arm__)
#define MAX_VADDR ARM_VECTORS_HIGH
#endif
/*
* The allocated-kva (akva) devmap table and metadata. Platforms can call
* arm_devmap_add_entry() to add static device mappings to this table using
* devmap_add_entry() to add static device mappings to this table using
* automatically allocated virtual addresses carved out of the top of kva space.
* Allocation begins immediately below the ARM_VECTORS_HIGH address.
*/
#define AKVA_DEVMAP_MAX_ENTRIES 32
static struct arm_devmap_entry akva_devmap_entries[AKVA_DEVMAP_MAX_ENTRIES];
static struct devmap_entry akva_devmap_entries[AKVA_DEVMAP_MAX_ENTRIES];
static u_int akva_devmap_idx;
static vm_offset_t akva_devmap_vaddr = MAX_VADDR;
static vm_offset_t akva_devmap_vaddr = DEVMAP_MAX_VADDR;
#ifdef __aarch64__
extern int early_boot;
@ -78,7 +67,7 @@ extern int early_boot;
static void
devmap_dump_table(int (*prfunc)(const char *, ...))
{
const struct arm_devmap_entry *pd;
const struct devmap_entry *pd;
if (devmap_table == NULL || devmap_table[0].pd_size == 0) {
prfunc("No static device mappings.\n");
@ -96,7 +85,7 @@ devmap_dump_table(int (*prfunc)(const char *, ...))
* Print the contents of the static mapping table. Used for bootverbose.
*/
void
arm_devmap_print_table()
devmap_print_table()
{
devmap_dump_table(printf);
}
@ -107,15 +96,15 @@ arm_devmap_print_table()
* the first unusable byte of KVA.
*/
vm_offset_t
arm_devmap_lastaddr()
devmap_lastaddr()
{
const struct arm_devmap_entry *pd;
const struct devmap_entry *pd;
vm_offset_t lowaddr;
if (akva_devmap_idx > 0)
return (akva_devmap_vaddr);
lowaddr = MAX_VADDR;
lowaddr = DEVMAP_MAX_VADDR;
for (pd = devmap_table; pd != NULL && pd->pd_size != 0; ++pd) {
if (lowaddr > pd->pd_va)
lowaddr = pd->pd_va;
@ -129,22 +118,22 @@ arm_devmap_lastaddr()
* physical address and size and a virtual address allocated from the top of
* kva. This automatically registers the akva table on the first call, so all a
* platform has to do is call this routine to install as many mappings as it
* needs and when initarm() calls arm_devmap_bootstrap() it will pick up all the
* needs and when initarm() calls devmap_bootstrap() it will pick up all the
* entries in the akva table automatically.
*/
void
arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz)
devmap_add_entry(vm_paddr_t pa, vm_size_t sz)
{
struct arm_devmap_entry *m;
struct devmap_entry *m;
if (devmap_bootstrap_done)
panic("arm_devmap_add_entry() after arm_devmap_bootstrap()");
panic("devmap_add_entry() after devmap_bootstrap()");
if (akva_devmap_idx == (AKVA_DEVMAP_MAX_ENTRIES - 1))
panic("AKVA_DEVMAP_MAX_ENTRIES is too small");
if (akva_devmap_idx == 0)
arm_devmap_register_table(akva_devmap_entries);
devmap_register_table(akva_devmap_entries);
/*
* Allocate virtual address space from the top of kva downwards. If the
@ -167,10 +156,10 @@ arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz)
}
/*
* Register the given table as the one to use in arm_devmap_bootstrap().
* Register the given table as the one to use in devmap_bootstrap().
*/
void
arm_devmap_register_table(const struct arm_devmap_entry *table)
devmap_register_table(const struct devmap_entry *table)
{
devmap_table = table;
@ -183,13 +172,13 @@ arm_devmap_register_table(const struct arm_devmap_entry *table)
* If a non-NULL table pointer is given it is used unconditionally, otherwise
* the previously-registered table is used. This smooths transition from legacy
* code that fills in a local table then calls this function passing that table,
* and newer code that uses arm_devmap_register_table() in platform-specific
* and newer code that uses devmap_register_table() in platform-specific
* code, then lets the common initarm() call this function with a NULL pointer.
*/
void
arm_devmap_bootstrap(vm_offset_t l1pt, const struct arm_devmap_entry *table)
devmap_bootstrap(vm_offset_t l1pt, const struct devmap_entry *table)
{
const struct arm_devmap_entry *pd;
const struct devmap_entry *pd;
devmap_bootstrap_done = true;
@ -222,9 +211,9 @@ arm_devmap_bootstrap(vm_offset_t l1pt, const struct arm_devmap_entry *table)
* corresponding virtual address, or NULL if not found.
*/
void *
arm_devmap_ptov(vm_paddr_t pa, vm_size_t size)
devmap_ptov(vm_paddr_t pa, vm_size_t size)
{
const struct arm_devmap_entry *pd;
const struct devmap_entry *pd;
if (devmap_table == NULL)
return (NULL);
@ -242,9 +231,9 @@ arm_devmap_ptov(vm_paddr_t pa, vm_size_t size)
* corresponding physical address, or DEVMAP_PADDR_NOTFOUND if not found.
*/
vm_paddr_t
arm_devmap_vtop(void * vpva, vm_size_t size)
devmap_vtop(void * vpva, vm_size_t size)
{
const struct arm_devmap_entry *pd;
const struct devmap_entry *pd;
vm_offset_t va;
if (devmap_table == NULL)
@ -277,7 +266,7 @@ pmap_mapdev(vm_offset_t pa, vm_size_t size)
void * rva;
/* First look in the static mapping table. */
if ((rva = arm_devmap_ptov(pa, size)) != NULL)
if ((rva = devmap_ptov(pa, size)) != NULL)
return (rva);
offset = pa & PAGE_MASK;
@ -310,7 +299,7 @@ pmap_unmapdev(vm_offset_t va, vm_size_t size)
vm_offset_t offset;
/* Nothing to do if we find the mapping in the static table. */
if (arm_devmap_vtop((void*)va, size) != DEVMAP_PADDR_NOTFOUND)
if (devmap_vtop((void*)va, size) != DEVMAP_PADDR_NOTFOUND)
return;
offset = va & PAGE_MASK;

View File

@ -239,4 +239,6 @@ extern vm_offset_t init_pt_va;
#define ZERO_REGION_SIZE (64 * 1024) /* 64KB */
#define DEVMAP_MAX_VADDR VM_MAX_KERNEL_ADDRESS
#endif /* !_MACHINE_VMPARAM_H_ */

View File

@ -1,61 +0,0 @@
/*-
* Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
* All rights reserved.
*
* Portions of this software were developed by SRI International and the
* University of Cambridge Computer Laboratory under DARPA/AFRL contract
* FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
*
* Portions of this software were developed by the University of Cambridge
* Computer Laboratory as part of the CTSRD Project, with support from the
* UK Higher Education Innovation Fund (HEIF).
*
* 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$");
/* RISC-V doesn't provide memory-mapped devices yet */
#include "opt_ddb.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <machine/riscvreg.h>
#include <machine/vmparam.h>
void *
pmap_mapdev(vm_offset_t pa, vm_size_t size)
{
return (NULL);
}
void
pmap_unmapdev(vm_offset_t va, vm_size_t size)
{
}

View File

@ -26,14 +26,18 @@
* $FreeBSD$
*/
#ifndef _MACHINE_DEVMAP_H_
#define _MACHINE_DEVMAP_H_
#ifndef _SYS_DEVMAP_H_
#define _SYS_DEVMAP_H_
#ifndef _KERNEL
#error "no user-servicable parts inside"
#endif
/*
* This structure is used by MD code to describe static mappings of devices
* which are established as part of bringing up the MMU early in the boot.
*/
struct arm_devmap_entry {
struct devmap_entry {
vm_offset_t pd_va; /* virtual address */
vm_paddr_t pd_pa; /* physical address */
vm_size_t pd_size; /* size of region */
@ -42,34 +46,34 @@ struct arm_devmap_entry {
/*
* Return the lowest KVA address used in any entry in the registered devmap
* table. This works with whatever table is registered, including the internal
* table used by arm_devmap_add_entry() if that routine was used. Platforms can
* table used by devmap_add_entry() if that routine was used. Platforms can
* implement platform_lastaddr() by calling this if static device mappings are
* their only use of high KVA space.
*/
vm_offset_t arm_devmap_lastaddr(void);
vm_offset_t devmap_lastaddr(void);
/*
* Automatically allocate KVA (from the top of the address space downwards) and
* make static device mapping entries in an internal table. The internal table
* is automatically registered on the first call to this.
*/
void arm_devmap_add_entry(vm_paddr_t pa, vm_size_t sz);
void devmap_add_entry(vm_paddr_t pa, vm_size_t sz);
/*
* Register a platform-local table to be bootstrapped by the generic
* initarm() in arm/machdep.c. This is used by newer code that allocates and
* fills in its own local table but does not have its own initarm() routine.
*/
void arm_devmap_register_table(const struct arm_devmap_entry * _table);
void devmap_register_table(const struct devmap_entry * _table);
/*
* Establish mappings for all the entries in the table. This is called
* automatically from the common initarm() in arm/machdep.c, and also from the
* custom initarm() routines in older code. If the table pointer is NULL, this
* will use the table installed previously by arm_devmap_register_table().
* will use the table installed previously by devmap_register_table().
*/
void arm_devmap_bootstrap(vm_offset_t _l1pt,
const struct arm_devmap_entry *_table);
void devmap_bootstrap(vm_offset_t _l1pt,
const struct devmap_entry *_table);
/*
* Translate between virtual and physical addresses within a region that is
@ -82,10 +86,10 @@ void arm_devmap_bootstrap(vm_offset_t _l1pt,
*/
#define DEVMAP_PADDR_NOTFOUND ((vm_paddr_t)(-1))
void * arm_devmap_ptov(vm_paddr_t _pa, vm_size_t _sz);
vm_paddr_t arm_devmap_vtop(void * _va, vm_size_t _sz);
void * devmap_ptov(vm_paddr_t _pa, vm_size_t _sz);
vm_paddr_t devmap_vtop(void * _va, vm_size_t _sz);
/* Print the static mapping table; used for bootverbose output. */
void arm_devmap_print_table(void);
void devmap_print_table(void);
#endif
#endif /* !_SYS_DEVMAP_H_ */