physmem.h revision 261643
1261643Sian/*- 2261643Sian * Copyright (c) 2014 Ian Lepore <ian@freebsd.org> 3261643Sian * All rights reserved. 4261643Sian * 5261643Sian * Redistribution and use in source and binary forms, with or without 6261643Sian * modification, are permitted provided that the following conditions 7261643Sian * are met: 8261643Sian * 1. Redistributions of source code must retain the above copyright 9261643Sian * notice, this list of conditions and the following disclaimer. 10261643Sian * 2. Redistributions in binary form must reproduce the above copyright 11261643Sian * notice, this list of conditions and the following disclaimer in the 12261643Sian * documentation and/or other materials provided with the distribution. 13261643Sian * 14261643Sian * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15261643Sian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16261643Sian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17261643Sian * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18261643Sian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19261643Sian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20261643Sian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21261643Sian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22261643Sian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23261643Sian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24261643Sian * SUCH DAMAGE. 25261643Sian * 26261643Sian * $FreeBSD: head/sys/arm/include/physmem.h 261643 2014-02-08 23:54:16Z ian $ 27261643Sian */ 28261643Sian 29261643Sian#ifndef _MACHINE_PHYSMEM_H_ 30261643Sian#define _MACHINE_PHYSMEM_H_ 31261643Sian 32261643Sian/* 33261643Sian * Routines to help configure physical ram. 34261643Sian * 35261643Sian * Multiple regions of contiguous physical ram can be added (in any order). 36261643Sian * 37261643Sian * Multiple regions of physical ram that should be excluded from crash dumps, or 38261643Sian * memory allocation, or both, can be added (in any order). 39261643Sian * 40261643Sian * After all early kernel init is done and it's time to configure all 41261643Sian * remainining non-excluded physical ram for use by other parts of the kernel, 42261643Sian * arm_physmem_init_kernel_globals() processes the hardware regions and 43261643Sian * exclusion regions to generate the global dump_avail and phys_avail arrays 44261643Sian * that communicate physical ram configuration to other parts of the kernel. 45261643Sian */ 46261643Sian 47261643Sian#define EXFLAG_NODUMP 0x01 48261643Sian#define EXFLAG_NOALLOC 0x02 49261643Sian 50261643Sianvoid arm_physmem_hardware_region(vm_offset_t pa, vm_size_t sz); 51261643Sianvoid arm_physmem_exclude_region(vm_offset_t pa, vm_size_t sz, uint32_t flags); 52261643Sianvoid arm_physmem_init_kernel_globals(void); 53261643Sianvoid arm_physmem_print_tables(void); 54261643Sian 55261643Sian/* 56261643Sian * Convenience routines for FDT. 57261643Sian */ 58261643Sian 59261643Sian#ifdef FDT 60261643Sian 61261643Sian#include <machine/ofw_machdep.h> 62261643Sian 63261643Sianinline void 64261643Sianarm_physmem_hardware_regions(struct mem_region * mrptr, int mrcount) 65261643Sian{ 66261643Sian while (mrcount--) { 67261643Sian arm_physmem_hardware_region(mrptr->mr_start, mrptr->mr_size); 68261643Sian ++mrptr; 69261643Sian } 70261643Sian} 71261643Sian 72261643Sianinline void 73261643Sianarm_physmem_exclude_regions(struct mem_region * mrptr, int mrcount, 74261643Sian uint32_t exflags) 75261643Sian{ 76261643Sian while (mrcount--) { 77261643Sian arm_physmem_exclude_region(mrptr->mr_start, mrptr->mr_size, 78261643Sian exflags); 79261643Sian ++mrptr; 80261643Sian } 81261643Sian} 82261643Sian 83261643Sian#endif /* FDT */ 84261643Sian 85261643Sian#endif 86261643Sian 87