Print this page
6144 use C99 initializers in segment ops structures


  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  27 /* All Rights Reserved */
  28 
  29 /*
  30  * Portions of this source code were derived from Berkeley 4.3 BSD
  31  * under license from the Regents of the University of California.
  32  */
  33 
  34 #pragma ident   "%Z%%M% %I%     %E% SMI"
  35 
  36 /*
  37  * VM - segment for non-faulting loads.
  38  */
  39 
  40 #include <sys/types.h>
  41 #include <sys/t_lock.h>
  42 #include <sys/param.h>
  43 #include <sys/mman.h>
  44 #include <sys/errno.h>
  45 #include <sys/kmem.h>
  46 #include <sys/cmn_err.h>
  47 #include <sys/vnode.h>
  48 #include <sys/proc.h>
  49 #include <sys/conf.h>
  50 #include <sys/debug.h>
  51 #include <sys/archsystm.h>
  52 #include <sys/lgrp.h>
  53 
  54 #include <vm/page.h>
  55 #include <vm/hat.h>


  69 static int      segnf_checkprot(struct seg *seg, caddr_t addr,
  70                     size_t len, uint_t prot);
  71 static void     segnf_badop(void);
  72 static int      segnf_nop(void);
  73 static int      segnf_getprot(struct seg *seg, caddr_t addr,
  74                     size_t len, uint_t *protv);
  75 static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr);
  76 static int      segnf_gettype(struct seg *seg, caddr_t addr);
  77 static int      segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
  78 static void     segnf_dump(struct seg *seg);
  79 static int      segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
  80                     struct page ***ppp, enum lock_type type, enum seg_rw rw);
  81 static int      segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len,
  82                     uint_t szc);
  83 static int      segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
  84 static lgrp_mem_policy_info_t   *segnf_getpolicy(struct seg *seg,
  85     caddr_t addr);
  86 
  87 
  88 struct seg_ops segnf_ops = {
  89         segnf_dup,
  90         segnf_unmap,
  91         segnf_free,
  92         (faultcode_t (*)(struct hat *, struct seg *, caddr_t, size_t,
  93             enum fault_type, enum seg_rw))
  94                 segnf_nomap,            /* fault */
  95         (faultcode_t (*)(struct seg *, caddr_t))
  96                 segnf_nomap,            /* faulta */
  97         segnf_setprot,
  98         segnf_checkprot,
  99         (int (*)())segnf_badop,         /* kluster */
 100         (size_t (*)(struct seg *))NULL, /* swapout */
 101         (int (*)(struct seg *, caddr_t, size_t, int, uint_t))
 102                 segnf_nop,              /* sync */
 103         (size_t (*)(struct seg *, caddr_t, size_t, char *))
 104                 segnf_nop,              /* incore */
 105         (int (*)(struct seg *, caddr_t, size_t, int, int, ulong_t *, size_t))
 106                 segnf_nop,              /* lockop */
 107         segnf_getprot,
 108         segnf_getoffset,
 109         segnf_gettype,
 110         segnf_getvp,
 111         (int (*)(struct seg *, caddr_t, size_t, uint_t))
 112                 segnf_nop,              /* advise */
 113         segnf_dump,
 114         segnf_pagelock,
 115         segnf_setpagesize,
 116         segnf_getmemid,
 117         segnf_getpolicy,
 118 };
 119 
 120 /*
 121  * vnode and page for the page of zeros we use for the nf mappings.
 122  */
 123 static kmutex_t segnf_lock;
 124 static struct vnode nfvp;
 125 static struct page **nfpp;
 126 
 127 #define addr_to_vcolor(addr)                                            \
 128         (shm_alignment) ?                                               \
 129         ((int)(((uintptr_t)(addr) & (shm_alignment - 1)) >> PAGESHIFT)) : 0
 130 
 131 /*
 132  * We try to limit the number of Non-fault segments created.
 133  * Non fault segments are created to optimize sparc V9 code which uses
 134  * the sparc nonfaulting load ASI (ASI_PRIMARY_NOFAULT).
 135  *
 136  * There are several reasons why creating too many non-fault segments
 137  * could cause problems.




  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  27 /* All Rights Reserved */
  28 
  29 /*
  30  * Portions of this source code were derived from Berkeley 4.3 BSD
  31  * under license from the Regents of the University of California.
  32  */
  33 


  34 /*
  35  * VM - segment for non-faulting loads.
  36  */
  37 
  38 #include <sys/types.h>
  39 #include <sys/t_lock.h>
  40 #include <sys/param.h>
  41 #include <sys/mman.h>
  42 #include <sys/errno.h>
  43 #include <sys/kmem.h>
  44 #include <sys/cmn_err.h>
  45 #include <sys/vnode.h>
  46 #include <sys/proc.h>
  47 #include <sys/conf.h>
  48 #include <sys/debug.h>
  49 #include <sys/archsystm.h>
  50 #include <sys/lgrp.h>
  51 
  52 #include <vm/page.h>
  53 #include <vm/hat.h>


  67 static int      segnf_checkprot(struct seg *seg, caddr_t addr,
  68                     size_t len, uint_t prot);
  69 static void     segnf_badop(void);
  70 static int      segnf_nop(void);
  71 static int      segnf_getprot(struct seg *seg, caddr_t addr,
  72                     size_t len, uint_t *protv);
  73 static u_offset_t segnf_getoffset(struct seg *seg, caddr_t addr);
  74 static int      segnf_gettype(struct seg *seg, caddr_t addr);
  75 static int      segnf_getvp(struct seg *seg, caddr_t addr, struct vnode **vpp);
  76 static void     segnf_dump(struct seg *seg);
  77 static int      segnf_pagelock(struct seg *seg, caddr_t addr, size_t len,
  78                     struct page ***ppp, enum lock_type type, enum seg_rw rw);
  79 static int      segnf_setpagesize(struct seg *seg, caddr_t addr, size_t len,
  80                     uint_t szc);
  81 static int      segnf_getmemid(struct seg *seg, caddr_t addr, memid_t *memidp);
  82 static lgrp_mem_policy_info_t   *segnf_getpolicy(struct seg *seg,
  83     caddr_t addr);
  84 
  85 
  86 struct seg_ops segnf_ops = {
  87         .dup            = segnf_dup,
  88         .unmap          = segnf_unmap,
  89         .free           = segnf_free,
  90         .fault          = (faultcode_t (*)(struct hat *, struct seg *, caddr_t,
  91             size_t, enum fault_type, enum seg_rw))segnf_nomap,
  92         .faulta         = (faultcode_t (*)(struct seg *, caddr_t)) segnf_nomap,
  93         .setprot        = segnf_setprot,
  94         .checkprot      = segnf_checkprot,
  95         .kluster        = (int (*)())segnf_badop,
  96         .sync           = (int (*)(struct seg *, caddr_t, size_t, int, uint_t))
  97                 segnf_nop,
  98         .incore         = (size_t (*)(struct seg *, caddr_t, size_t, char *))
  99                 segnf_nop,
 100         .lockop         = (int (*)(struct seg *, caddr_t, size_t, int, int,
 101             ulong_t *, size_t))segnf_nop,
 102         .getprot        = segnf_getprot,
 103         .getoffset      = segnf_getoffset,
 104         .gettype        = segnf_gettype,
 105         .getvp          = segnf_getvp,
 106         .advise         = (int (*)(struct seg *, caddr_t, size_t, uint_t))
 107                 segnf_nop,
 108         .dump           = segnf_dump,
 109         .pagelock       = segnf_pagelock,
 110         .setpagesize    = segnf_setpagesize,
 111         .getmemid       = segnf_getmemid,
 112         .getpolicy      = segnf_getpolicy,



 113 };
 114 
 115 /*
 116  * vnode and page for the page of zeros we use for the nf mappings.
 117  */
 118 static kmutex_t segnf_lock;
 119 static struct vnode nfvp;
 120 static struct page **nfpp;
 121 
 122 #define addr_to_vcolor(addr)                                            \
 123         (shm_alignment) ?                                               \
 124         ((int)(((uintptr_t)(addr) & (shm_alignment - 1)) >> PAGESHIFT)) : 0
 125 
 126 /*
 127  * We try to limit the number of Non-fault segments created.
 128  * Non fault segments are created to optimize sparc V9 code which uses
 129  * the sparc nonfaulting load ASI (ASI_PRIMARY_NOFAULT).
 130  *
 131  * There are several reasons why creating too many non-fault segments
 132  * could cause problems.