physmem.h revision 261649
1130803Smarcel/*- 2130803Smarcel * Copyright (c) 2014 Ian Lepore <ian@freebsd.org> 3130803Smarcel * All rights reserved. 4130803Smarcel * 5130803Smarcel * Redistribution and use in source and binary forms, with or without 6130803Smarcel * modification, are permitted provided that the following conditions 7130803Smarcel * are met: 8130803Smarcel * 1. Redistributions of source code must retain the above copyright 9130803Smarcel * notice, this list of conditions and the following disclaimer. 10130803Smarcel * 2. Redistributions in binary form must reproduce the above copyright 11130803Smarcel * notice, this list of conditions and the following disclaimer in the 12130803Smarcel * documentation and/or other materials provided with the distribution. 13130803Smarcel * 14130803Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15130803Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16130803Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17130803Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18130803Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19130803Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20130803Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21130803Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22130803Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23130803Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24130803Smarcel * SUCH DAMAGE. 25130803Smarcel * 26130803Smarcel * $FreeBSD: head/sys/arm/include/physmem.h 261649 2014-02-09 02:39:00Z ian $ 27130803Smarcel */ 28130803Smarcel 29130803Smarcel#ifndef _MACHINE_PHYSMEM_H_ 30130803Smarcel#define _MACHINE_PHYSMEM_H_ 31130803Smarcel 32130803Smarcel/* 33130803Smarcel * The physical address at which the kernel was loaded. 34130803Smarcel */ 35130803Smarcelextern vm_offset_t arm_physmem_kernaddr; 36130803Smarcel 37130803Smarcel/* 38130803Smarcel * Routines to help configure physical ram. 39130803Smarcel * 40130803Smarcel * Multiple regions of contiguous physical ram can be added (in any order). 41130803Smarcel * 42130803Smarcel * Multiple regions of physical ram that should be excluded from crash dumps, or 43130803Smarcel * memory allocation, or both, can be added (in any order). 44130803Smarcel * 45130803Smarcel * After all early kernel init is done and it's time to configure all 46130803Smarcel * remainining non-excluded physical ram for use by other parts of the kernel, 47130803Smarcel * arm_physmem_init_kernel_globals() processes the hardware regions and 48130803Smarcel * exclusion regions to generate the global dump_avail and phys_avail arrays 49130803Smarcel * that communicate physical ram configuration to other parts of the kernel. 50130803Smarcel */ 51130803Smarcel 52130803Smarcel#define EXFLAG_NODUMP 0x01 53130803Smarcel#define EXFLAG_NOALLOC 0x02 54130803Smarcel 55130803Smarcelvoid arm_physmem_hardware_region(vm_offset_t pa, vm_size_t sz); 56130803Smarcelvoid arm_physmem_exclude_region(vm_offset_t pa, vm_size_t sz, uint32_t flags); 57130803Smarcelvoid arm_physmem_init_kernel_globals(void); 58130803Smarcelvoid arm_physmem_print_tables(void); 59130803Smarcel 60130803Smarcel/* 61130803Smarcel * Convenience routines for FDT. 62130803Smarcel */ 63130803Smarcel 64130803Smarcel#ifdef FDT 65130803Smarcel 66130803Smarcel#include <machine/ofw_machdep.h> 67130803Smarcel 68130803Smarcelinline void 69130803Smarcelarm_physmem_hardware_regions(struct mem_region * mrptr, int mrcount) 70130803Smarcel{ 71130803Smarcel while (mrcount--) { 72130803Smarcel arm_physmem_hardware_region(mrptr->mr_start, mrptr->mr_size); 73130803Smarcel ++mrptr; 74130803Smarcel } 75130803Smarcel} 76130803Smarcel 77130803Smarcelinline void 78130803Smarcelarm_physmem_exclude_regions(struct mem_region * mrptr, int mrcount, 79130803Smarcel uint32_t exflags) 80130803Smarcel{ 81130803Smarcel while (mrcount--) { 82130803Smarcel arm_physmem_exclude_region(mrptr->mr_start, mrptr->mr_size, 83130803Smarcel exflags); 84130803Smarcel ++mrptr; 85130803Smarcel } 86130803Smarcel} 87130803Smarcel 88130803Smarcel#endif /* FDT */ 89130803Smarcel 90130803Smarcel#endif 91130803Smarcel 92130803Smarcel