Print this page
use NULL dump segop as a shorthand for no-op
Instead of forcing every segment driver to implement a dummy function that
does nothing, handle NULL dump segop function pointer as a no-op shorthand.


  55 #include <vm/seg.h>
  56 #include <vm/vpage.h>
  57 
  58 /*
  59  * Private seg op routines.
  60  */
  61 static int      segnf_dup(struct seg *seg, struct seg *newseg);
  62 static int      segnf_unmap(struct seg *seg, caddr_t addr, size_t len);
  63 static void     segnf_free(struct seg *seg);
  64 static faultcode_t segnf_nomap(void);
  65 static int      segnf_setprot(struct seg *seg, caddr_t addr,
  66                     size_t len, uint_t prot);
  67 static int      segnf_checkprot(struct seg *seg, caddr_t addr,
  68                     size_t len, uint_t prot);
  69 static int      segnf_nop(void);
  70 static int      segnf_getprot(struct seg *seg, caddr_t addr,
  71                     size_t len, uint_t *protv);
  72 static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr);
  73 static int      segnf_gettype(struct seg *seg, caddr_t addr);
  74 static int      segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
  75 static void     segnf_dump(struct seg *seg);
  76 static int      segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
  77                     struct page ***ppp, enum lock_type type, enum seg_rw rw);
  78 
  79 
  80 const struct seg_ops segnf_ops = {
  81         .dup            = segnf_dup,
  82         .unmap          = segnf_unmap,
  83         .free           = segnf_free,
  84         .fault          = (faultcode_t (*)(struct hat *, struct seg *, caddr_t,
  85             size_t, enum fault_type, enum seg_rw))segnf_nomap,
  86         .faulta         = (faultcode_t (*)(struct seg *, caddr_t)) segnf_nomap,
  87         .setprot        = segnf_setprot,
  88         .checkprot      = segnf_checkprot,
  89         .sync           = (int (*)(struct seg *, caddr_t, size_t, int, uint_t))
  90                 segnf_nop,
  91         .incore         = (size_t (*)(struct seg *, caddr_t, size_t, char *))
  92                 segnf_nop,
  93         .lockop         = (int (*)(struct seg *, caddr_t, size_t, int, int,
  94             ulong_t *, size_t))segnf_nop,
  95         .getprot        = segnf_getprot,
  96         .getoffset      = segnf_getoffset,
  97         .gettype        = segnf_gettype,
  98         .getvp          = segnf_getvp,
  99         .advise         = (int (*)(struct seg *, caddr_t, size_t, uint_t))
 100                 segnf_nop,
 101         .dump           = segnf_dump,
 102         .pagelock       = segnf_pagelock,
 103 };
 104 
 105 /*
 106  * vnode and page for the page of zeros we use for the nf mappings.
 107  */
 108 static kmutex_t segnf_lock;
 109 static struct vnode nfvp;
 110 static struct page **nfpp;
 111 
 112 #define addr_to_vcolor(addr)                                            \
 113         (shm_alignment) ?                                               \
 114         ((int)(((uintptr_t)(addr) & (shm_alignment - 1)) >> PAGESHIFT)) : 0
 115 
 116 /*
 117  * We try to limit the number of Non-fault segments created.
 118  * Non fault segments are created to optimize sparc V9 code which uses
 119  * the sparc nonfaulting load ASI (ASI_PRIMARY_NOFAULT).
 120  *
 121  * There are several reasons why creating too many non-fault segments


 419 }
 420 
 421 /* ARGSUSED */
 422 static int
 423 segnf_gettype(struct seg *seg, caddr_t addr)
 424 {
 425         ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
 426 
 427         return (MAP_SHARED);
 428 }
 429 
 430 /* ARGSUSED */
 431 static int
 432 segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp)
 433 {
 434         ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
 435 
 436         *vpp = &nfvp;
 437         return (0);
 438 }
 439 
 440 /*
 441  * segnf pages are not dumped, so we just return
 442  */
 443 /* ARGSUSED */
 444 static void
 445 segnf_dump(struct seg *seg)
 446 {}
 447 
 448 /*ARGSUSED*/
 449 static int
 450 segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
 451     struct page ***ppp, enum lock_type type, enum seg_rw rw)
 452 {
 453         return (ENOTSUP);
 454 }


  55 #include <vm/seg.h>
  56 #include <vm/vpage.h>
  57 
  58 /*
  59  * Private seg op routines.
  60  */
  61 static int      segnf_dup(struct seg *seg, struct seg *newseg);
  62 static int      segnf_unmap(struct seg *seg, caddr_t addr, size_t len);
  63 static void     segnf_free(struct seg *seg);
  64 static faultcode_t segnf_nomap(void);
  65 static int      segnf_setprot(struct seg *seg, caddr_t addr,
  66                     size_t len, uint_t prot);
  67 static int      segnf_checkprot(struct seg *seg, caddr_t addr,
  68                     size_t len, uint_t prot);
  69 static int      segnf_nop(void);
  70 static int      segnf_getprot(struct seg *seg, caddr_t addr,
  71                     size_t len, uint_t *protv);
  72 static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr);
  73 static int      segnf_gettype(struct seg *seg, caddr_t addr);
  74 static int      segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);

  75 static int      segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
  76                     struct page ***ppp, enum lock_type type, enum seg_rw rw);
  77 
  78 
  79 const struct seg_ops segnf_ops = {
  80         .dup            = segnf_dup,
  81         .unmap          = segnf_unmap,
  82         .free           = segnf_free,
  83         .fault          = (faultcode_t (*)(struct hat *, struct seg *, caddr_t,
  84             size_t, enum fault_type, enum seg_rw))segnf_nomap,
  85         .faulta         = (faultcode_t (*)(struct seg *, caddr_t)) segnf_nomap,
  86         .setprot        = segnf_setprot,
  87         .checkprot      = segnf_checkprot,
  88         .sync           = (int (*)(struct seg *, caddr_t, size_t, int, uint_t))
  89                 segnf_nop,
  90         .incore         = (size_t (*)(struct seg *, caddr_t, size_t, char *))
  91                 segnf_nop,
  92         .lockop         = (int (*)(struct seg *, caddr_t, size_t, int, int,
  93             ulong_t *, size_t))segnf_nop,
  94         .getprot        = segnf_getprot,
  95         .getoffset      = segnf_getoffset,
  96         .gettype        = segnf_gettype,
  97         .getvp          = segnf_getvp,
  98         .advise         = (int (*)(struct seg *, caddr_t, size_t, uint_t))
  99                 segnf_nop,

 100         .pagelock       = segnf_pagelock,
 101 };
 102 
 103 /*
 104  * vnode and page for the page of zeros we use for the nf mappings.
 105  */
 106 static kmutex_t segnf_lock;
 107 static struct vnode nfvp;
 108 static struct page **nfpp;
 109 
 110 #define addr_to_vcolor(addr)                                            \
 111         (shm_alignment) ?                                               \
 112         ((int)(((uintptr_t)(addr) & (shm_alignment - 1)) >> PAGESHIFT)) : 0
 113 
 114 /*
 115  * We try to limit the number of Non-fault segments created.
 116  * Non fault segments are created to optimize sparc V9 code which uses
 117  * the sparc nonfaulting load ASI (ASI_PRIMARY_NOFAULT).
 118  *
 119  * There are several reasons why creating too many non-fault segments


 417 }
 418 
 419 /* ARGSUSED */
 420 static int
 421 segnf_gettype(struct seg *seg, caddr_t addr)
 422 {
 423         ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
 424 
 425         return (MAP_SHARED);
 426 }
 427 
 428 /* ARGSUSED */
 429 static int
 430 segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp)
 431 {
 432         ASSERT(seg->s_as && AS_LOCK_HELD(seg->s_as, &seg->s_as->a_lock));
 433 
 434         *vpp = &nfvp;
 435         return (0);
 436 }








 437 
 438 /*ARGSUSED*/
 439 static int
 440 segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
 441     struct page ***ppp, enum lock_type type, enum seg_rw rw)
 442 {
 443         return (ENOTSUP);
 444 }