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 (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 25 #ifndef _SYS_MD_NAMES_H 26 #define _SYS_MD_NAMES_H 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 #define NM_ALLOC_SIZE 512 33 #define NM_DID_ALLOC_SIZE 1024 34 35 #define NM_NOCOMMIT 0x0100 36 #define NM_SHARED 1 37 #define NM_NOTSHARED 0 38 #define NM_DEVID 0x0010 39 #define NM_IMP_SHARED 0x0020 40 #define NM_KEY_RECYCLE 0x0040 41 #define NM_DEVID_VALID 1 42 #define NM_DEVID_INVALID 0 43 44 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 45 #pragma pack(4) 46 #endif 47 48 #ifdef _KERNEL 49 struct nm_rec_hdr { 50 uint_t r_revision; /* revision number */ 51 uint_t r_alloc_size; /* alloc'd record size */ 52 uint_t r_used_size; /* number bytes used */ 53 mddb_recid_t r_next_recid; /* record id of next record */ 54 uint32_t xr_next_rec; /* ptr to record, calc at boot */ 55 mdkey_t r_next_key; /* Next key for alloc'd entry */ 56 }; 57 #else /* ! _KERNEL */ 58 struct nm_rec_hdr { 59 uint_t r_revision; /* revision number */ 60 uint_t r_alloc_size; /* alloc'd record size */ 61 uint_t r_used_size; /* number bytes used */ 62 mddb_recid_t r_next_recid; /* record id of next record */ 63 void *r_next_rec; /* ptr to record, calc at boot */ 64 mdkey_t r_next_key; /* Next key for alloc'd entry */ 65 }; 66 #endif /* _KERNEL */ 67 68 struct nm_next_hdr { 69 struct nm_next_hdr *nmn_nextp; 70 void *nmn_record; 71 }; 72 73 struct nm_shr_rec { 74 struct nm_rec_hdr sr_rec_hdr; /* Record header */ 75 struct nm_shared_name { 76 mdkey_t sn_key; /* Unique key for this name */ 77 uint32_t sn_count; /* Count of users of this name */ 78 uint32_t sn_data; /* Data ptr for users (e.g., devops */ 79 /* sn_data NOT USED anywhere */ 80 ushort_t sn_namlen; /* Length of string in nmsn_name */ 81 char sn_name[1]; /* Driver/Directory name */ 82 } sr_name[1]; 83 }; 84 85 #define SHR_NAMSIZ(n) \ 86 (((sizeof (struct nm_shared_name) - 1) + \ 87 (n)->sn_namlen + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1)) 88 89 struct nm_rec { 90 struct nm_rec_hdr r_rec_hdr; /* Record header */ 91 struct nm_name { 92 side_t n_side; /* (key 1) side associated with */ 93 mdkey_t n_key; /* (key 2) allocated unique key */ 94 uint32_t n_count; /* reference count */ 95 minor_t n_minor; /* minor number of device */ 96 mdkey_t n_drv_key; /* Key of driver name in nm_shared */ 97 mdkey_t n_dir_key; /* Key of dir. name in nm_shared */ 98 ushort_t n_namlen; /* Length of string in nme_name */ 99 char n_name[1]; /* Filename of device is here */ 100 } r_name[1]; 101 }; 102 103 #define NAMSIZ(n) \ 104 (((sizeof (struct nm_name) - 1) + \ 105 (n)->n_namlen + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1)) 106 107 /* 108 * Device id support 109 */ 110 struct devid_shr_rec { 111 struct nm_rec_hdr did_rec_hdr; 112 struct did_shr_name { 113 mdkey_t did_key; 114 uint32_t did_count; 115 uint32_t did_data; 116 ushort_t did_size; 117 char did_devid[1]; 118 } device_id[1]; 119 }; 120 121 #define DID_SHR_NAMSIZ(n) \ 122 (((sizeof (struct did_shr_name) - 1) + \ 123 (n)->did_size + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1)) 124 125 126 struct devid_min_rec { 127 struct nm_rec_hdr min_rec_hdr; 128 struct did_min_name { 129 side_t min_side; 130 mdkey_t min_key; 131 uint32_t min_count; 132 mdkey_t min_devid_key; 133 ushort_t min_namlen; 134 char min_name[1]; 135 } minor_name[1]; 136 }; 137 138 #define DID_NAMSIZ(n) \ 139 (((sizeof (struct did_min_name) - 1) + \ 140 (n)->min_namlen + (sizeof (uint_t) - 1)) & ~(sizeof (uint_t) - 1)) 141 142 143 struct nm_header { 144 uint_t h_revision; /* revision number */ 145 struct nm_rec_hdr h_names; /* device-name structures */ 146 struct nm_rec_hdr h_shared; /* shared structures */ 147 }; 148 149 struct nm_header_hdr { 150 struct nm_header *hh_header; 151 struct nm_next_hdr hh_names; 152 struct nm_next_hdr hh_shared; 153 }; 154 155 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 156 #pragma pack() 157 #endif 158 159 #ifdef __cplusplus 160 } 161 #endif 162 163 #endif /* _SYS_MD_NAMES_H */ 164