Print this page
use NULL capable segop as a shorthand for no-capabilities
Instead of forcing every segment driver to implement a dummy "return 0"
function, handle NULL capable segop function pointer as "no copabilities
supported" shorthand.


  71 /*
  72  * Private seg op routines.
  73  */
  74 static void     segmap_free(struct seg *seg);
  75 faultcode_t segmap_fault(struct hat *hat, struct seg *seg, caddr_t addr,
  76                         size_t len, enum fault_type type, enum seg_rw rw);
  77 static faultcode_t segmap_faulta(struct seg *seg, caddr_t addr);
  78 static int      segmap_checkprot(struct seg *seg, caddr_t addr, size_t len,
  79                         uint_t prot);
  80 static int      segmap_kluster(struct seg *seg, caddr_t addr, ssize_t);
  81 static int      segmap_getprot(struct seg *seg, caddr_t addr, size_t len,
  82                         uint_t *protv);
  83 static u_offset_t       segmap_getoffset(struct seg *seg, caddr_t addr);
  84 static int      segmap_gettype(struct seg *seg, caddr_t addr);
  85 static int      segmap_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
  86 static void     segmap_dump(struct seg *seg);
  87 static int      segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
  88                         struct page ***ppp, enum lock_type type,
  89                         enum seg_rw rw);
  90 static int      segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
  91 static int      segmap_capable(struct seg *seg, segcapability_t capability);
  92 
  93 /* segkpm support */
  94 static caddr_t  segmap_pagecreate_kpm(struct seg *, vnode_t *, u_offset_t,
  95                         struct smap *, enum seg_rw);
  96 struct smap     *get_smap_kpm(caddr_t, page_t **);
  97 
  98 static struct seg_ops segmap_ops = {
  99         .free           = segmap_free,
 100         .fault          = segmap_fault,
 101         .faulta         = segmap_faulta,
 102         .checkprot      = segmap_checkprot,
 103         .kluster        = segmap_kluster,
 104         .getprot        = segmap_getprot,
 105         .getoffset      = segmap_getoffset,
 106         .gettype        = segmap_gettype,
 107         .getvp          = segmap_getvp,
 108         .dump           = segmap_dump,
 109         .pagelock       = segmap_pagelock,
 110         .getmemid       = segmap_getmemid,
 111         .capable        = segmap_capable,
 112 };
 113 
 114 /*
 115  * Private segmap routines.
 116  */
 117 static void     segmap_unlock(struct hat *hat, struct seg *seg, caddr_t addr,
 118                         size_t len, enum seg_rw rw, struct smap *smp);
 119 static void     segmap_smapadd(struct smap *smp);
 120 static struct smap *segmap_hashin(struct smap *smp, struct vnode *vp,
 121                         u_offset_t off, int hashid);
 122 static void     segmap_hashout(struct smap *smp);
 123 
 124 
 125 /*
 126  * Statistics for segmap operations.
 127  *
 128  * No explicit locking to protect these stats.
 129  */
 130 struct segmapcnt segmapcnt = {
 131         { "fault",              KSTAT_DATA_ULONG },


2148                 }
2149                 addr += MAXBSIZE;
2150         }
2151 }
2152 
2153 /*ARGSUSED*/
2154 static int
2155 segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
2156     struct page ***ppp, enum lock_type type, enum seg_rw rw)
2157 {
2158         return (ENOTSUP);
2159 }
2160 
2161 static int
2162 segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
2163 {
2164         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
2165 
2166         memidp->val[0] = (uintptr_t)smd->smd_sm->sm_vp;
2167         memidp->val[1] = smd->smd_sm->sm_off + (uintptr_t)(addr - seg->s_base);
2168         return (0);
2169 }
2170 
2171 /*ARGSUSED*/
2172 static int
2173 segmap_capable(struct seg *seg, segcapability_t capability)
2174 {
2175         return (0);
2176 }
2177 
2178 
2179 #ifdef  SEGKPM_SUPPORT
2180 
2181 /*
2182  * segkpm support routines
2183  */
2184 
2185 static caddr_t
2186 segmap_pagecreate_kpm(struct seg *seg, vnode_t *vp, u_offset_t off,
2187         struct smap *smp, enum seg_rw rw)
2188 {
2189         caddr_t base;
2190         page_t  *pp;
2191         int     newpage = 0;
2192         struct kpme     *kpme;
2193 
2194         ASSERT(smp->sm_refcnt > 0);




  71 /*
  72  * Private seg op routines.
  73  */
  74 static void     segmap_free(struct seg *seg);
  75 faultcode_t segmap_fault(struct hat *hat, struct seg *seg, caddr_t addr,
  76                         size_t len, enum fault_type type, enum seg_rw rw);
  77 static faultcode_t segmap_faulta(struct seg *seg, caddr_t addr);
  78 static int      segmap_checkprot(struct seg *seg, caddr_t addr, size_t len,
  79                         uint_t prot);
  80 static int      segmap_kluster(struct seg *seg, caddr_t addr, ssize_t);
  81 static int      segmap_getprot(struct seg *seg, caddr_t addr, size_t len,
  82                         uint_t *protv);
  83 static u_offset_t       segmap_getoffset(struct seg *seg, caddr_t addr);
  84 static int      segmap_gettype(struct seg *seg, caddr_t addr);
  85 static int      segmap_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
  86 static void     segmap_dump(struct seg *seg);
  87 static int      segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
  88                         struct page ***ppp, enum lock_type type,
  89                         enum seg_rw rw);
  90 static int      segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);

  91 
  92 /* segkpm support */
  93 static caddr_t  segmap_pagecreate_kpm(struct seg *, vnode_t *, u_offset_t,
  94                         struct smap *, enum seg_rw);
  95 struct smap     *get_smap_kpm(caddr_t, page_t **);
  96 
  97 static struct seg_ops segmap_ops = {
  98         .free           = segmap_free,
  99         .fault          = segmap_fault,
 100         .faulta         = segmap_faulta,
 101         .checkprot      = segmap_checkprot,
 102         .kluster        = segmap_kluster,
 103         .getprot        = segmap_getprot,
 104         .getoffset      = segmap_getoffset,
 105         .gettype        = segmap_gettype,
 106         .getvp          = segmap_getvp,
 107         .dump           = segmap_dump,
 108         .pagelock       = segmap_pagelock,
 109         .getmemid       = segmap_getmemid,

 110 };
 111 
 112 /*
 113  * Private segmap routines.
 114  */
 115 static void     segmap_unlock(struct hat *hat, struct seg *seg, caddr_t addr,
 116                         size_t len, enum seg_rw rw, struct smap *smp);
 117 static void     segmap_smapadd(struct smap *smp);
 118 static struct smap *segmap_hashin(struct smap *smp, struct vnode *vp,
 119                         u_offset_t off, int hashid);
 120 static void     segmap_hashout(struct smap *smp);
 121 
 122 
 123 /*
 124  * Statistics for segmap operations.
 125  *
 126  * No explicit locking to protect these stats.
 127  */
 128 struct segmapcnt segmapcnt = {
 129         { "fault",              KSTAT_DATA_ULONG },


2146                 }
2147                 addr += MAXBSIZE;
2148         }
2149 }
2150 
2151 /*ARGSUSED*/
2152 static int
2153 segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
2154     struct page ***ppp, enum lock_type type, enum seg_rw rw)
2155 {
2156         return (ENOTSUP);
2157 }
2158 
2159 static int
2160 segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
2161 {
2162         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
2163 
2164         memidp->val[0] = (uintptr_t)smd->smd_sm->sm_vp;
2165         memidp->val[1] = smd->smd_sm->sm_off + (uintptr_t)(addr - seg->s_base);







2166         return (0);
2167 }
2168 
2169 
2170 #ifdef  SEGKPM_SUPPORT
2171 
2172 /*
2173  * segkpm support routines
2174  */
2175 
2176 static caddr_t
2177 segmap_pagecreate_kpm(struct seg *seg, vnode_t *vp, u_offset_t off,
2178         struct smap *smp, enum seg_rw rw)
2179 {
2180         caddr_t base;
2181         page_t  *pp;
2182         int     newpage = 0;
2183         struct kpme     *kpme;
2184 
2185         ASSERT(smp->sm_refcnt > 0);