FreeBSD/Linux Kernel Cross Reference
sys/sys/memrange.h
1 /* $OpenBSD: memrange.h,v 1.10 2015/08/18 20:19:32 miod Exp $ */
2 /*-
3 * Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27 /*
28 * Memory range attribute operations, performed on /dev/mem
29 */
30
31 /* Memory range attributes */
32 #define MDF_UNCACHEABLE (1<<0) /* region not cached */
33 #define MDF_WRITECOMBINE (1<<1) /* region supports "write combine" action */
34 #define MDF_WRITETHROUGH (1<<2) /* write-through cached */
35 #define MDF_WRITEBACK (1<<3) /* write-back cached */
36 #define MDF_WRITEPROTECT (1<<4) /* read-only region */
37 #define MDF_UNKNOWN (1<<5) /* any state we don't understand */
38 #define MDF_ATTRMASK (0x00ffffff)
39
40 #define MDF_FIXBASE (1<<24) /* fixed base */
41 #define MDF_FIXLEN (1<<25) /* fixed length */
42 #define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */
43 #define MDF_ACTIVE (1<<27) /* currently active */
44 #define MDF_BOGUS (1<<28) /* we don't like it */
45 #define MDF_FIXACTIVE (1<<29) /* can't be turned off */
46 #define MDF_FORCE (1<<31) /* force risky changes */
47
48 struct mem_range_desc {
49 u_int64_t mr_base;
50 u_int64_t mr_len;
51 int mr_flags;
52 char mr_owner[8];
53 };
54
55 struct mem_range_op {
56 struct mem_range_desc *mo_desc;
57 int mo_arg[2];
58 #define MEMRANGE_SET_UPDATE 0
59 #define MEMRANGE_SET_REMOVE 1
60 /* XXX want a flag that says "set and undo when I exit" */
61 };
62
63 #define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op)
64 #define MEMRANGE_SET _IOW('m', 51, struct mem_range_op)
65
66 /* Offset indicating a write combining mapping is requested. */
67 #define MEMRANGE_WC_RANGE 0x4000000000000000ULL
68
69 #ifdef _KERNEL
70
71 struct mem_range_softc;
72 struct mem_range_ops {
73 void (*init)(struct mem_range_softc *sc);
74 int (*set)(struct mem_range_softc *sc,
75 struct mem_range_desc *mrd, int *arg);
76 void (*initAP)(struct mem_range_softc *sc);
77 void (*reload)(struct mem_range_softc *sc);
78 };
79
80 struct mem_range_softc {
81 struct mem_range_ops *mr_op;
82 int mr_cap;
83 int mr_ndesc;
84 struct mem_range_desc *mr_desc;
85 };
86
87 extern struct mem_range_softc mem_range_softc;
88
89 __BEGIN_DECLS
90 extern void mem_range_attach(void);
91 extern int mem_range_attr_get(struct mem_range_desc *mrd, int *arg);
92 extern int mem_range_attr_set(struct mem_range_desc *mrd, int *arg);
93 extern void mem_range_AP_init(void);
94 extern void mem_range_reload(void);
95 __END_DECLS
96 #endif /* _KERNEL */
97
Cache object: 9ae9afebbbfa26a730b7f9a8cf8dac67
|