1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  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 2008 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 #ifndef _NSC_GEN_H
  27 #define _NSC_GEN_H
  28 
  29 #ifdef __cplusplus
  30 extern "C" {
  31 #endif
  32 
  33 #ifndef __NSC_GEN__
  34 Error: Illegal #include - private file.
  35 #endif
  36 
  37 
  38 /*
  39  * Global resource map.
  40  */
  41 
  42 #define _NSC_MAXNAME    20
  43 
  44 typedef struct nsc_rmmap_s {
  45         char    name[_NSC_MAXNAME];     /* Description */
  46         int32_t offset;                 /* Offset into arena */
  47         uint32_t        size;           /* Length of area */
  48         int32_t inuse;                  /* Bitmap of nodes using area */
  49         int32_t pad[2];                 /* For future expansion */
  50 } nsc_rmmap_t;
  51 
  52 
  53 #ifdef _KERNEL
  54 #include <sys/nsctl/nsc_mem.h>
  55 
  56 extern kmutex_t _nsc_global_lock;
  57 extern int _nsc_global_lock_init;
  58 
  59 extern int _nsc_rmmap_init(nsc_rmmap_t *, char *, int, size_t, ulong_t);
  60 extern ulong_t _nsc_rmmap_alloc(nsc_rmmap_t *, char *, size_t, void (*)());
  61 extern void _nsc_rmmap_free(nsc_rmmap_t *, char *, nsc_mem_t *);
  62 extern size_t _nsc_rmmap_size(nsc_rmmap_t *, char *);
  63 extern size_t _nsc_rmmap_avail(nsc_rmmap_t *);
  64 
  65 extern nsc_rmmap_t *_nsc_global_nvmemmap_lookup(nsc_rmmap_t *);
  66 extern void nsc_cm_errhdlr(void *, void *, size_t, int);
  67 extern caddr_t _nsc_rm_nvmem_base;
  68 
  69 /*
  70  * Inter-module function (callback) services.
  71  */
  72 
  73 typedef struct nsc_svc_s {
  74         struct nsc_svc_s *svc_next;     /* linked list */
  75         struct nsc_service_s *svc_svc;  /* back link */
  76         void (*svc_fn)(intptr_t);       /* service function, or NULL (client) */
  77 } nsc_svc_t;
  78 
  79 typedef struct nsc_service_s {
  80         struct nsc_service_s *s_next;   /* linked list */
  81         char *s_name;                   /* name of service */
  82         nsc_svc_t *s_servers;           /* providers of the service */
  83         nsc_svc_t *s_clients;           /* clients of the service */
  84         krwlock_t s_rwlock;             /* lock */
  85 } nsc_service_t;
  86 
  87 extern void _nsc_init_svc(void);
  88 extern void _nsc_deinit_svc(void);
  89 
  90 #endif /* _KERNEL */
  91 
  92 
  93 /*
  94  * ncall usage (NCALL_NSC .. NCALL_NSC+9)
  95  */
  96 
  97 /* inter-node setval */
  98 #define NSC_SETVAL              (NCALL_NSC + 1)
  99 #define NSC_SETVAL_ALL          (NCALL_NSC + 2)
 100 
 101 #define NSC_UNUSED3             (NCALL_NSC + 3)
 102 #define NSC_UNUSED4             (NCALL_NSC + 4)
 103 
 104 /* ncall-io io provider */
 105 #define NSC_NCIO_PARTSIZE       (NCALL_NSC + 5)
 106 #define NSC_NCIO_READ           (NCALL_NSC + 6)
 107 #define NSC_NCIO_WRITE          (NCALL_NSC + 7)
 108 
 109 #define NSC_UNUSED8             (NCALL_NSC + 8)
 110 #define NSC_UNUSED9             (NCALL_NSC + 9)
 111 
 112 #ifdef __cplusplus
 113 }
 114 #endif
 115 
 116 #endif /* _NSC_GEN_H */