xref: /netbsd-src/sys/dev/fdt/fdt_memory.h (revision accf8784309c9496b8539e1f0b5e72da21c92434)
1*accf8784Sjmcneill /* $NetBSD: fdt_memory.h,v 1.2 2022/11/04 10:51:16 jmcneill Exp $ */
2ff970d37Sskrll 
3ff970d37Sskrll /*-
4ff970d37Sskrll  * Copyright (c) 2018 The NetBSD Foundation, Inc.
5ff970d37Sskrll  * All rights reserved.
6ff970d37Sskrll  *
7ff970d37Sskrll  * This code is derived from software contributed to The NetBSD Foundation
8ff970d37Sskrll  * by Jared McNeill <jmcneill@invisible.ca>.
9ff970d37Sskrll  *
10ff970d37Sskrll  * Redistribution and use in source and binary forms, with or without
11ff970d37Sskrll  * modification, are permitted provided that the following conditions
12ff970d37Sskrll  * are met:
13ff970d37Sskrll  * 1. Redistributions of source code must retain the above copyright
14ff970d37Sskrll  *    notice, this list of conditions and the following disclaimer.
15ff970d37Sskrll  * 2. Redistributions in binary form must reproduce the above copyright
16ff970d37Sskrll  *    notice, this list of conditions and the following disclaimer in the
17ff970d37Sskrll  *    documentation and/or other materials provided with the distribution.
18ff970d37Sskrll  *
19ff970d37Sskrll  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20ff970d37Sskrll  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21ff970d37Sskrll  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22ff970d37Sskrll  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23ff970d37Sskrll  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24ff970d37Sskrll  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25ff970d37Sskrll  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26ff970d37Sskrll  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27ff970d37Sskrll  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28ff970d37Sskrll  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29ff970d37Sskrll  * POSSIBILITY OF SUCH DAMAGE.
30ff970d37Sskrll  */
31ff970d37Sskrll 
32ff970d37Sskrll #ifndef _DEV_FDT_FDT_MEMORY_H_
33ff970d37Sskrll #define _DEV_FDT_FDT_MEMORY_H_
34ff970d37Sskrll 
35*accf8784Sjmcneill #include "opt_fdt.h"
36*accf8784Sjmcneill 
37*accf8784Sjmcneill #ifndef FDT_MEMORY_RANGES
38*accf8784Sjmcneill #define FDT_MEMORY_RANGES 256
39*accf8784Sjmcneill #endif
40*accf8784Sjmcneill 
41ff970d37Sskrll struct fdt_memory {
42ff970d37Sskrll 	uint64_t	start;
43ff970d37Sskrll 	uint64_t	end;
44ff970d37Sskrll };
45ff970d37Sskrll 
46ff970d37Sskrll void	fdt_memory_init(void);
47ff970d37Sskrll void	fdt_memory_get(uint64_t *, uint64_t *);
48ff970d37Sskrll void	fdt_memory_add_range(uint64_t, uint64_t);
49ff970d37Sskrll void	fdt_memory_remove_range(uint64_t, uint64_t);
50ff970d37Sskrll void	fdt_memory_remove_reserved(uint64_t, uint64_t);
51ff970d37Sskrll 
52ff970d37Sskrll void	fdt_memory_foreach(void (*)(const struct fdt_memory *, void *), void *);
53ff970d37Sskrll 
54ff970d37Sskrll #endif /* _DEV_FDT_FDT_MEMORY_H_ */
55