Print this page
use C99 initializers in segment ops structures


  69  * the system) they can patch the segspt_minfree to smaller number.
  70  */
  71 pgcnt_t segspt_minfree = 0;
  72 
  73 static int segspt_create(struct seg *seg, caddr_t argsp);
  74 static int segspt_unmap(struct seg *seg, caddr_t raddr, size_t ssize);
  75 static void segspt_free(struct seg *seg);
  76 static void segspt_free_pages(struct seg *seg, caddr_t addr, size_t len);
  77 static lgrp_mem_policy_info_t *segspt_getpolicy(struct seg *seg, caddr_t addr);
  78 
  79 static void
  80 segspt_badop()
  81 {
  82         panic("segspt_badop called");
  83         /*NOTREACHED*/
  84 }
  85 
  86 #define SEGSPT_BADOP(t) (t(*)())segspt_badop
  87 
  88 struct seg_ops segspt_ops = {
  89         SEGSPT_BADOP(int),              /* dup */
  90         segspt_unmap,
  91         segspt_free,
  92         SEGSPT_BADOP(int),              /* fault */
  93         SEGSPT_BADOP(faultcode_t),      /* faulta */
  94         SEGSPT_BADOP(int),              /* setprot */
  95         SEGSPT_BADOP(int),              /* checkprot */
  96         SEGSPT_BADOP(int),              /* kluster */
  97         SEGSPT_BADOP(int),              /* sync */
  98         SEGSPT_BADOP(size_t),           /* incore */
  99         SEGSPT_BADOP(int),              /* lockop */
 100         SEGSPT_BADOP(int),              /* getprot */
 101         SEGSPT_BADOP(u_offset_t),       /* getoffset */
 102         SEGSPT_BADOP(int),              /* gettype */
 103         SEGSPT_BADOP(int),              /* getvp */
 104         SEGSPT_BADOP(int),              /* advise */
 105         SEGSPT_BADOP(void),             /* dump */
 106         SEGSPT_BADOP(int),              /* pagelock */
 107         SEGSPT_BADOP(int),              /* setpgsz */
 108         SEGSPT_BADOP(int),              /* getmemid */
 109         segspt_getpolicy,               /* getpolicy */
 110         SEGSPT_BADOP(int),              /* capable */
 111         seg_inherit_notsup              /* inherit */
 112 };
 113 
 114 static int segspt_shmdup(struct seg *seg, struct seg *newseg);
 115 static int segspt_shmunmap(struct seg *seg, caddr_t raddr, size_t ssize);
 116 static void segspt_shmfree(struct seg *seg);
 117 static faultcode_t segspt_shmfault(struct hat *hat, struct seg *seg,
 118                 caddr_t addr, size_t len, enum fault_type type, enum seg_rw rw);
 119 static faultcode_t segspt_shmfaulta(struct seg *seg, caddr_t addr);
 120 static int segspt_shmsetprot(register struct seg *seg, register caddr_t addr,
 121                         register size_t len, register uint_t prot);
 122 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
 123                         uint_t prot);
 124 static int      segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
 125 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
 126                         register char *vec);
 127 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
 128                         int attr, uint_t flags);
 129 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
 130                         int attr, int op, ulong_t *lockmap, size_t pos);
 131 static int segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len,
 132                         uint_t *protv);
 133 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
 134 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
 135 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
 136 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
 137                         uint_t behav);
 138 static void segspt_shmdump(struct seg *seg);
 139 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
 140                         struct page ***, enum lock_type, enum seg_rw);
 141 static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
 142 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
 143 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
 144 static int segspt_shmcapable(struct seg *, segcapability_t);
 145 
 146 struct seg_ops segspt_shmops = {
 147         segspt_shmdup,
 148         segspt_shmunmap,
 149         segspt_shmfree,
 150         segspt_shmfault,
 151         segspt_shmfaulta,
 152         segspt_shmsetprot,
 153         segspt_shmcheckprot,
 154         segspt_shmkluster,
 155         segspt_shmsync,
 156         segspt_shmincore,
 157         segspt_shmlockop,
 158         segspt_shmgetprot,
 159         segspt_shmgetoffset,
 160         segspt_shmgettype,
 161         segspt_shmgetvp,
 162         segspt_shmadvise,       /* advise */
 163         segspt_shmdump,
 164         segspt_shmpagelock,
 165         segspt_shmsetpgsz,
 166         segspt_shmgetmemid,
 167         segspt_shmgetpolicy,
 168         segspt_shmcapable,
 169         seg_inherit_notsup
 170 };
 171 
 172 static void segspt_purge(struct seg *seg);
 173 static int segspt_reclaim(void *, caddr_t, size_t, struct page **,
 174                 enum seg_rw, int);
 175 static int spt_anon_getpages(struct seg *seg, caddr_t addr, size_t len,
 176                 page_t **ppa);
 177 
 178 
 179 
 180 /*ARGSUSED*/
 181 int
 182 sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp,
 183         uint_t prot, uint_t flags, uint_t share_szc)
 184 {
 185         int     err;
 186         struct  as      *newas;
 187         struct  segspt_crargs sptcargs;
 188 
 189 #ifdef DEBUG




  69  * the system) they can patch the segspt_minfree to smaller number.
  70  */
  71 pgcnt_t segspt_minfree = 0;
  72 
  73 static int segspt_create(struct seg *seg, caddr_t argsp);
  74 static int segspt_unmap(struct seg *seg, caddr_t raddr, size_t ssize);
  75 static void segspt_free(struct seg *seg);
  76 static void segspt_free_pages(struct seg *seg, caddr_t addr, size_t len);
  77 static lgrp_mem_policy_info_t *segspt_getpolicy(struct seg *seg, caddr_t addr);
  78 
  79 static void
  80 segspt_badop()
  81 {
  82         panic("segspt_badop called");
  83         /*NOTREACHED*/
  84 }
  85 
  86 #define SEGSPT_BADOP(t) (t(*)())segspt_badop
  87 
  88 struct seg_ops segspt_ops = {
  89         .dup            = SEGSPT_BADOP(int),
  90         .unmap          = segspt_unmap,
  91         .free           = segspt_free,
  92         .fault          = SEGSPT_BADOP(int),
  93         .faulta         = SEGSPT_BADOP(faultcode_t),
  94         .setprot        = SEGSPT_BADOP(int),
  95         .checkprot      = SEGSPT_BADOP(int),
  96         .kluster        = SEGSPT_BADOP(int),
  97         .sync           = SEGSPT_BADOP(int),
  98         .incore         = SEGSPT_BADOP(size_t),
  99         .lockop         = SEGSPT_BADOP(int),
 100         .getprot        = SEGSPT_BADOP(int),
 101         .getoffset      = SEGSPT_BADOP(u_offset_t),
 102         .gettype        = SEGSPT_BADOP(int),
 103         .getvp          = SEGSPT_BADOP(int),
 104         .advise         = SEGSPT_BADOP(int),
 105         .dump           = SEGSPT_BADOP(void),
 106         .pagelock       = SEGSPT_BADOP(int),
 107         .setpagesize    = SEGSPT_BADOP(int),
 108         .getmemid       = SEGSPT_BADOP(int),
 109         .getpolicy      = segspt_getpolicy,
 110         .capable        = SEGSPT_BADOP(int),
 111         .inherit        = seg_inherit_notsup,
 112 };
 113 
 114 static int segspt_shmdup(struct seg *seg, struct seg *newseg);
 115 static int segspt_shmunmap(struct seg *seg, caddr_t raddr, size_t ssize);
 116 static void segspt_shmfree(struct seg *seg);
 117 static faultcode_t segspt_shmfault(struct hat *hat, struct seg *seg,
 118                 caddr_t addr, size_t len, enum fault_type type, enum seg_rw rw);
 119 static faultcode_t segspt_shmfaulta(struct seg *seg, caddr_t addr);
 120 static int segspt_shmsetprot(register struct seg *seg, register caddr_t addr,
 121                         register size_t len, register uint_t prot);
 122 static int segspt_shmcheckprot(struct seg *seg, caddr_t addr, size_t size,
 123                         uint_t prot);
 124 static int      segspt_shmkluster(struct seg *seg, caddr_t addr, ssize_t delta);
 125 static size_t segspt_shmincore(struct seg *seg, caddr_t addr, size_t len,
 126                         register char *vec);
 127 static int segspt_shmsync(struct seg *seg, register caddr_t addr, size_t len,
 128                         int attr, uint_t flags);
 129 static int segspt_shmlockop(struct seg *seg, caddr_t addr, size_t len,
 130                         int attr, int op, ulong_t *lockmap, size_t pos);
 131 static int segspt_shmgetprot(struct seg *seg, caddr_t addr, size_t len,
 132                         uint_t *protv);
 133 static u_offset_t segspt_shmgetoffset(struct seg *seg, caddr_t addr);
 134 static int segspt_shmgettype(struct seg *seg, caddr_t addr);
 135 static int segspt_shmgetvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
 136 static int segspt_shmadvise(struct seg *seg, caddr_t addr, size_t len,
 137                         uint_t behav);
 138 static void segspt_shmdump(struct seg *seg);
 139 static int segspt_shmpagelock(struct seg *, caddr_t, size_t,
 140                         struct page ***, enum lock_type, enum seg_rw);
 141 static int segspt_shmsetpgsz(struct seg *, caddr_t, size_t, uint_t);
 142 static int segspt_shmgetmemid(struct seg *, caddr_t, memid_t *);
 143 static lgrp_mem_policy_info_t *segspt_shmgetpolicy(struct seg *, caddr_t);
 144 static int segspt_shmcapable(struct seg *, segcapability_t);
 145 
 146 struct seg_ops segspt_shmops = {
 147         .dup            = segspt_shmdup,
 148         .unmap          = segspt_shmunmap,
 149         .free           = segspt_shmfree,
 150         .fault          = segspt_shmfault,
 151         .faulta         = segspt_shmfaulta,
 152         .setprot        = segspt_shmsetprot,
 153         .checkprot      = segspt_shmcheckprot,
 154         .kluster        = segspt_shmkluster,
 155         .sync           = segspt_shmsync,
 156         .incore         = segspt_shmincore,
 157         .lockop         = segspt_shmlockop,
 158         .getprot        = segspt_shmgetprot,
 159         .getoffset      = segspt_shmgetoffset,
 160         .gettype        = segspt_shmgettype,
 161         .getvp          = segspt_shmgetvp,
 162         .advise         = segspt_shmadvise,
 163         .dump           = segspt_shmdump,
 164         .pagelock       = segspt_shmpagelock,
 165         .setpagesize    = segspt_shmsetpgsz,
 166         .getmemid       = segspt_shmgetmemid,
 167         .getpolicy      = segspt_shmgetpolicy,
 168         .capable        = segspt_shmcapable,
 169         .inherit        = seg_inherit_notsup,
 170 };
 171 
 172 static void segspt_purge(struct seg *seg);
 173 static int segspt_reclaim(void *, caddr_t, size_t, struct page **,
 174                 enum seg_rw, int);
 175 static int spt_anon_getpages(struct seg *seg, caddr_t addr, size_t len,
 176                 page_t **ppa);
 177 
 178 
 179 
 180 /*ARGSUSED*/
 181 int
 182 sptcreate(size_t size, struct seg **sptseg, struct anon_map *amp,
 183         uint_t prot, uint_t flags, uint_t share_szc)
 184 {
 185         int     err;
 186         struct  as      *newas;
 187         struct  segspt_crargs sptcargs;
 188 
 189 #ifdef DEBUG