1 /* 2 * Memory range attribute operations, performed on /dev/mem 3 */ 4 5 #ifndef _SYS_MEMRANGE_H_ 6 #define _SYS_MEMRANGE_H_ 7 8 #include <sys/ioccom.h> 9 10 /* Memory range attributes */ 11 #define MDF_UNCACHEABLE (1<<0) /* region not cached */ 12 #define MDF_WRITECOMBINE (1<<1) /* region supports "write combine" action */ 13 #define MDF_WRITETHROUGH (1<<2) /* write-through cached */ 14 #define MDF_WRITEBACK (1<<3) /* write-back cached */ 15 #define MDF_WRITEPROTECT (1<<4) /* read-only region */ 16 #define MDF_UNKNOWN (1<<5) /* any state we don't understand */ 17 #define MDF_ATTRMASK (0x00ffffff) 18 19 #define MDF_FIXBASE (1<<24) /* fixed base */ 20 #define MDF_FIXLEN (1<<25) /* fixed length */ 21 #define MDF_FIRMWARE (1<<26) /* set by firmware (XXX not useful?) */ 22 #define MDF_ACTIVE (1<<27) /* currently active */ 23 #define MDF_BOGUS (1<<28) /* we don't like it */ 24 #define MDF_FIXACTIVE (1<<29) /* can't be turned off */ 25 #define MDF_BUSY (1<<30) /* range is in use */ 26 #define MDF_FORCE (1<<31) /* force risky changes */ 27 28 struct mem_range_desc 29 { 30 u_int64_t mr_base; 31 u_int64_t mr_len; 32 int mr_flags; 33 char mr_owner[8]; 34 }; 35 36 struct mem_range_op 37 { 38 struct mem_range_desc *mo_desc; 39 int mo_arg[2]; 40 #define MEMRANGE_SET_UPDATE 0 41 #define MEMRANGE_SET_REMOVE 1 42 /* XXX want a flag that says "set and undo when I exit" */ 43 }; 44 45 #define MEMRANGE_GET _IOWR('m', 50, struct mem_range_op) 46 #define MEMRANGE_SET _IOW('m', 51, struct mem_range_op) 47 48 #define ME_STATE_INVALID 0 49 #define ME_STATE_VALID 1 50 #define ME_STATE_MAPPED 2 51 52 struct mem_extract { 53 uint64_t me_vaddr; 54 uint64_t me_paddr; 55 int me_domain; 56 int me_state; 57 uint64_t pad1[5]; 58 }; 59 60 #define MEM_EXTRACT_PADDR _IOWR('m', 52, struct mem_extract) 61 62 struct mem_livedump_arg { 63 int fd; 64 int flags; 65 uint8_t compression; 66 uint8_t pad1[7]; 67 uint64_t pad2[2]; 68 }; 69 70 #define MEM_KERNELDUMP _IOW('m', 53, struct mem_livedump_arg) 71 72 #ifdef _KERNEL 73 74 MALLOC_DECLARE(M_MEMDESC); 75 76 struct mem_range_softc; 77 struct mem_range_ops 78 { 79 void (*init)(struct mem_range_softc *sc); 80 int (*set)(struct mem_range_softc *sc, struct mem_range_desc *mrd, int *arg); 81 void (*initAP)(struct mem_range_softc *sc); 82 void (*reinit)(struct mem_range_softc *sc); 83 }; 84 85 struct mem_range_softc 86 { 87 struct mem_range_ops *mr_op; 88 int mr_cap; 89 int mr_ndesc; 90 struct mem_range_desc *mr_desc; 91 }; 92 93 extern struct mem_range_softc mem_range_softc; 94 95 extern void mem_range_init(void); 96 extern void mem_range_destroy(void); 97 98 extern int mem_range_attr_get(struct mem_range_desc *mrd, int *arg); 99 extern int mem_range_attr_set(struct mem_range_desc *mrd, int *arg); 100 101 #endif /* _KERNEL */ 102 103 #endif /* _SYS_MEMRANGE_H_ */ 104