uvm_physseg.h revision 1.1 1 1.1 cherry /* $NetBSD: uvm_physseg.h,v 1.1 2016/12/19 12:21:29 cherry Exp $ */
2 1.1 cherry
3 1.1 cherry /*
4 1.1 cherry * Consolidated API from uvm_page.c and others.
5 1.1 cherry * Consolidated and designed by Cherry G. Mathew <cherry (at) zyx.in>
6 1.1 cherry */
7 1.1 cherry
8 1.1 cherry #ifndef _UVM_UVM_PHYSSEG_H_
9 1.1 cherry #define _UVM_UVM_PHYSSEG_H_
10 1.1 cherry
11 1.1 cherry #if defined(_KERNEL_OPT)
12 1.1 cherry #include "opt_uvm_hotplug.h"
13 1.1 cherry #endif
14 1.1 cherry
15 1.1 cherry #include <sys/cdefs.h>
16 1.1 cherry #include <sys/param.h>
17 1.1 cherry #include <sys/types.h>
18 1.1 cherry
19 1.1 cherry /*
20 1.1 cherry * No APIs are explicitly #included in uvm_physseg.c
21 1.1 cherry */
22 1.1 cherry
23 1.1 cherry #if defined(UVM_HOTPLUG) /* rbtree impementation */
24 1.1 cherry #define PRIxPHYSSEG "p"
25 1.1 cherry
26 1.1 cherry /*
27 1.1 cherry * These are specific values of invalid constants for uvm_physseg_t.
28 1.1 cherry * uvm_physseg_valid() == false on any of the below constants.
29 1.1 cherry *
30 1.1 cherry * Specific invalid constants encapsulate specific explicit failure
31 1.1 cherry * scenarios (see the comments next to them)
32 1.1 cherry */
33 1.1 cherry
34 1.1 cherry #define UVM_PHYSSEG_TYPE_INVALID NULL /* Generic invalid value */
35 1.1 cherry #define UVM_PHYSSEG_TYPE_INVALID_EMPTY NULL /* empty segment access */
36 1.1 cherry #define UVM_PHYSSEG_TYPE_INVALID_OVERFLOW NULL /* ran off the end of the last segment */
37 1.1 cherry
38 1.1 cherry typedef struct uvm_physseg * uvm_physseg_t;
39 1.1 cherry
40 1.1 cherry #else /* UVM_HOTPLUG */
41 1.1 cherry
42 1.1 cherry #define PRIxPHYSSEG "d"
43 1.1 cherry
44 1.1 cherry /*
45 1.1 cherry * These are specific values of invalid constants for uvm_physseg_t.
46 1.1 cherry * uvm_physseg_valid() == false on any of the below constants.
47 1.1 cherry *
48 1.1 cherry * Specific invalid constants encapsulate specific explicit failure
49 1.1 cherry * scenarios (see the comments next to them)
50 1.1 cherry */
51 1.1 cherry
52 1.1 cherry #define UVM_PHYSSEG_TYPE_INVALID -1 /* Generic invalid value */
53 1.1 cherry #define UVM_PHYSSEG_TYPE_INVALID_EMPTY -1 /* empty segment access */
54 1.1 cherry #define UVM_PHYSSEG_TYPE_INVALID_OVERFLOW (uvm_physseg_get_last() + 1) /* ran off the end of the last segment */
55 1.1 cherry
56 1.1 cherry typedef int uvm_physseg_t;
57 1.1 cherry #endif /* UVM_HOTPLUG */
58 1.1 cherry
59 1.1 cherry void uvm_physseg_init(void);
60 1.1 cherry
61 1.1 cherry bool uvm_physseg_valid(uvm_physseg_t);
62 1.1 cherry
63 1.1 cherry /*
64 1.1 cherry * Return start/end pfn of given segment
65 1.1 cherry * Returns: -1 if the segment number is invalid
66 1.1 cherry */
67 1.1 cherry paddr_t uvm_physseg_get_start(uvm_physseg_t);
68 1.1 cherry paddr_t uvm_physseg_get_end(uvm_physseg_t);
69 1.1 cherry
70 1.1 cherry paddr_t uvm_physseg_get_avail_start(uvm_physseg_t);
71 1.1 cherry paddr_t uvm_physseg_get_avail_end(uvm_physseg_t);
72 1.1 cherry
73 1.1 cherry struct vm_page * uvm_physseg_get_pg(uvm_physseg_t, paddr_t);
74 1.1 cherry
75 1.1 cherry #ifdef __HAVE_PMAP_PHYSSEG
76 1.1 cherry struct pmap_physseg * uvm_physseg_get_pmseg(uvm_physseg_t);
77 1.1 cherry #endif
78 1.1 cherry
79 1.1 cherry int uvm_physseg_get_free_list(uvm_physseg_t);
80 1.1 cherry u_int uvm_physseg_get_start_hint(uvm_physseg_t);
81 1.1 cherry bool uvm_physseg_set_start_hint(uvm_physseg_t, u_int);
82 1.1 cherry
83 1.1 cherry /*
84 1.1 cherry * Functions to help walk the list of segments.
85 1.1 cherry * Returns: NULL if the segment number is invalid
86 1.1 cherry */
87 1.1 cherry uvm_physseg_t uvm_physseg_get_next(uvm_physseg_t);
88 1.1 cherry uvm_physseg_t uvm_physseg_get_prev(uvm_physseg_t);
89 1.1 cherry uvm_physseg_t uvm_physseg_get_first(void);
90 1.1 cherry uvm_physseg_t uvm_physseg_get_last(void);
91 1.1 cherry
92 1.1 cherry
93 1.1 cherry /* Return the frame number of the highest registered physical page frame */
94 1.1 cherry paddr_t uvm_physseg_get_highest_frame(void);
95 1.1 cherry
96 1.1 cherry /* Actually, uvm_page_physload takes PF#s which need their own type */
97 1.1 cherry uvm_physseg_t uvm_page_physload(paddr_t, paddr_t, paddr_t,
98 1.1 cherry paddr_t, int);
99 1.1 cherry
100 1.1 cherry bool uvm_page_physunload(uvm_physseg_t, int, paddr_t *);
101 1.1 cherry bool uvm_page_physunload_force(uvm_physseg_t, int, paddr_t *);
102 1.1 cherry
103 1.1 cherry uvm_physseg_t uvm_physseg_find(paddr_t, psize_t *);
104 1.1 cherry
105 1.1 cherry bool uvm_physseg_plug(paddr_t, size_t, uvm_physseg_t *);
106 1.1 cherry bool uvm_physseg_unplug(paddr_t, size_t);
107 1.1 cherry
108 1.1 cherry #if defined(PMAP_STEAL_MEMORY)
109 1.1 cherry /*
110 1.1 cherry * XXX: Legacy: This needs to be upgraded to a full pa management
111 1.1 cherry * layer.
112 1.1 cherry */
113 1.1 cherry void uvm_physseg_set_avail_start(uvm_physseg_t, paddr_t);
114 1.1 cherry void uvm_physseg_set_avail_end(uvm_physseg_t, paddr_t);
115 1.1 cherry #endif /* PMAP_STEAL_MEMORY */
116 1.1 cherry
117 1.1 cherry #endif /* _UVM_UVM_PHYSSEG_H_ */
118 1.1 cherry
119