Print this page
6149 use NULL capable segop as a shorthand for no-capabilities


  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 void     segmap_badop(void);
  91 static int      segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
  92 static int      segmap_capable(struct seg *seg, segcapability_t capability);
  93 
  94 /* segkpm support */
  95 static caddr_t  segmap_pagecreate_kpm(struct seg *, vnode_t *, u_offset_t,
  96                         struct smap *, enum seg_rw);
  97 struct smap     *get_smap_kpm(caddr_t, page_t **);
  98 
  99 #define SEGMAP_BADOP(t) (t(*)())segmap_badop
 100 
 101 static struct seg_ops segmap_ops = {
 102         .dup            = SEGMAP_BADOP(int),
 103         .unmap          = SEGMAP_BADOP(int),
 104         .free           = segmap_free,
 105         .fault          = segmap_fault,
 106         .faulta         = segmap_faulta,
 107         .setprot        = SEGMAP_BADOP(int),
 108         .checkprot      = segmap_checkprot,
 109         .kluster        = segmap_kluster,
 110         .swapout        = SEGMAP_BADOP(size_t),
 111         .sync           = SEGMAP_BADOP(int),
 112         .incore         = SEGMAP_BADOP(size_t),
 113         .lockop         = SEGMAP_BADOP(int),
 114         .getprot        = segmap_getprot,
 115         .getoffset      = segmap_getoffset,
 116         .gettype        = segmap_gettype,
 117         .getvp          = segmap_getvp,
 118         .advise         = SEGMAP_BADOP(int),
 119         .dump           = segmap_dump,
 120         .pagelock       = segmap_pagelock,
 121         .setpagesize    = SEGMAP_BADOP(int),
 122         .getmemid       = segmap_getmemid,
 123         .capable        = segmap_capable,
 124 };
 125 
 126 /*
 127  * Private segmap routines.
 128  */
 129 static void     segmap_unlock(struct hat *hat, struct seg *seg, caddr_t addr,
 130                         size_t len, enum seg_rw rw, struct smap *smp);
 131 static void     segmap_smapadd(struct smap *smp);
 132 static struct smap *segmap_hashin(struct smap *smp, struct vnode *vp,
 133                         u_offset_t off, int hashid);
 134 static void     segmap_hashout(struct smap *smp);
 135 
 136 
 137 /*
 138  * Statistics for segmap operations.
 139  *
 140  * No explicit locking to protect these stats.
 141  */
 142 struct segmapcnt segmapcnt = {
 143         { "fault",              KSTAT_DATA_ULONG },


2167                 }
2168                 addr += MAXBSIZE;
2169         }
2170 }
2171 
2172 /*ARGSUSED*/
2173 static int
2174 segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
2175     struct page ***ppp, enum lock_type type, enum seg_rw rw)
2176 {
2177         return (ENOTSUP);
2178 }
2179 
2180 static int
2181 segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
2182 {
2183         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
2184 
2185         memidp->val[0] = (uintptr_t)smd->smd_sm->sm_vp;
2186         memidp->val[1] = smd->smd_sm->sm_off + (uintptr_t)(addr - seg->s_base);
2187         return (0);
2188 }
2189 
2190 /*ARGSUSED*/
2191 static int
2192 segmap_capable(struct seg *seg, segcapability_t capability)
2193 {
2194         return (0);
2195 }
2196 
2197 
2198 #ifdef  SEGKPM_SUPPORT
2199 
2200 /*
2201  * segkpm support routines
2202  */
2203 
2204 static caddr_t
2205 segmap_pagecreate_kpm(struct seg *seg, vnode_t *vp, u_offset_t off,
2206         struct smap *smp, enum seg_rw rw)
2207 {
2208         caddr_t base;
2209         page_t  *pp;
2210         int     newpage = 0;
2211         struct kpme     *kpme;
2212 
2213         ASSERT(smp->sm_refcnt > 0);




  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 void     segmap_badop(void);
  91 static int      segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);

  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 #define SEGMAP_BADOP(t) (t(*)())segmap_badop
  99 
 100 static struct seg_ops segmap_ops = {
 101         .dup            = SEGMAP_BADOP(int),
 102         .unmap          = SEGMAP_BADOP(int),
 103         .free           = segmap_free,
 104         .fault          = segmap_fault,
 105         .faulta         = segmap_faulta,
 106         .setprot        = SEGMAP_BADOP(int),
 107         .checkprot      = segmap_checkprot,
 108         .kluster        = segmap_kluster,
 109         .swapout        = SEGMAP_BADOP(size_t),
 110         .sync           = SEGMAP_BADOP(int),
 111         .incore         = SEGMAP_BADOP(size_t),
 112         .lockop         = SEGMAP_BADOP(int),
 113         .getprot        = segmap_getprot,
 114         .getoffset      = segmap_getoffset,
 115         .gettype        = segmap_gettype,
 116         .getvp          = segmap_getvp,
 117         .advise         = SEGMAP_BADOP(int),
 118         .dump           = segmap_dump,
 119         .pagelock       = segmap_pagelock,
 120         .setpagesize    = SEGMAP_BADOP(int),
 121         .getmemid       = segmap_getmemid,

 122 };
 123 
 124 /*
 125  * Private segmap routines.
 126  */
 127 static void     segmap_unlock(struct hat *hat, struct seg *seg, caddr_t addr,
 128                         size_t len, enum seg_rw rw, struct smap *smp);
 129 static void     segmap_smapadd(struct smap *smp);
 130 static struct smap *segmap_hashin(struct smap *smp, struct vnode *vp,
 131                         u_offset_t off, int hashid);
 132 static void     segmap_hashout(struct smap *smp);
 133 
 134 
 135 /*
 136  * Statistics for segmap operations.
 137  *
 138  * No explicit locking to protect these stats.
 139  */
 140 struct segmapcnt segmapcnt = {
 141         { "fault",              KSTAT_DATA_ULONG },


2165                 }
2166                 addr += MAXBSIZE;
2167         }
2168 }
2169 
2170 /*ARGSUSED*/
2171 static int
2172 segmap_pagelock(struct seg *seg, caddr_t addr, size_t len,
2173     struct page ***ppp, enum lock_type type, enum seg_rw rw)
2174 {
2175         return (ENOTSUP);
2176 }
2177 
2178 static int
2179 segmap_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp)
2180 {
2181         struct segmap_data *smd = (struct segmap_data *)seg->s_data;
2182 
2183         memidp->val[0] = (uintptr_t)smd->smd_sm->sm_vp;
2184         memidp->val[1] = smd->smd_sm->sm_off + (uintptr_t)(addr - seg->s_base);







2185         return (0);
2186 }
2187 
2188 
2189 #ifdef  SEGKPM_SUPPORT
2190 
2191 /*
2192  * segkpm support routines
2193  */
2194 
2195 static caddr_t
2196 segmap_pagecreate_kpm(struct seg *seg, vnode_t *vp, u_offset_t off,
2197         struct smap *smp, enum seg_rw rw)
2198 {
2199         caddr_t base;
2200         page_t  *pp;
2201         int     newpage = 0;
2202         struct kpme     *kpme;
2203 
2204         ASSERT(smp->sm_refcnt > 0);