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