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