1 /* $NetBSD: ieee1212reg.h,v 1.7 2002/04/02 10:10:54 jmc Exp $ */ 2 3 /*- 4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef _DEV_STD_IEEE1212REG_H_ 40 #define _DEV_STD_IEEE1212REG_H_ 41 42 /* This file contains definitions from ISO/IEC 1312 or ANSI/IEEE Std 1212 43 * Informaton techonology 44 * Microprocessor systes 45 * Control and Status Registers (CSR) 46 * Architecture for microcomputer buses 47 * First edition 1994-10-05 48 */ 49 50 /* Lock transaction codes (Table 5) 51 */ 52 #define P1212_XTCODE_RESERVED_0 0 53 #define P1212_XTCODE_MASK_SWAP 1 54 #define P1212_XTCODE_COMPARE_SWAP 2 55 #define P1212_XTCODE_FETCH_ADD 3 56 #define P1212_XTCODE_LITTLE_ADD 4 57 #define P1212_XTCODE_BOUNDED_ADD 5 58 #define P1212_XTCODE_WRAP_ADD 6 59 #define P1212_XTCODE_VENDOR_DEPENDENT 7 60 61 /* Header: Rom Format (1 Quadlet) 62 * Bus Info Block: <info-length> Quadlets 63 * Root Directory 64 * Unit Directory 65 * Root & Unit Leaves 66 * Vendor Dependent Information 67 */ 68 /* ROM Formats 69 * 0x00-0x000000 Initializing 70 * 0x01-0xzzyyxx Minimal (zz-yy-xx is an OUI) 71 * 0xii-0xcc-0xllll General (ii is info-length, 72 * cc is crc-length, llll is length) 73 */ 74 75 #define P1212_ROMFMT_INIT 0x00 76 #define P1212_ROMFMT_MINIMAL 0x01 77 78 /* uint32_t P1212_ROMFMT_MK_INIT(void) 79 */ 80 #define P1212_ROMFMT_MK_INIT() 0x00000000 81 82 /* uint32_t P1212_ROMFMT_MK_MINIMAL(const uint8_t *oui); 83 */ 84 #define P1212_ROMFMT_MK_MINIMAL(oui) \ 85 ((P1212_ROMFMT_MINIMAL << 24) \ 86 | ((oui[0]) << 16) \ 87 | ((oui[1]) << 8) \ 88 | ((oui[2]) << 0)) 89 90 /* uint32_t P1212_ROMFMT_MK_GENERAL(size_t info_len, size_t crc_len, 91 * uint16_t crc); 92 */ 93 #define P1212_ROMFMT_MK_GENERAL(info_len, crc_len, crc_value) \ 94 (((info_len) << 24) \ 95 | ((crc_len) << 16) \ 96 | ((crc_value) << 0)) 97 98 /* unsigned P1212_ROMFMT_GET_FMT(uint32_t); 99 */ 100 #define P1212_ROMFMT_GET_FMT(quadlet) (((quadlet) >> 24) & 0xff) 101 102 /* void P1212_ROMFMT_GET_OUI(uint32_t quadlet, uint8_t *oui); 103 */ 104 #define P1212_ROMTFMT_GET_OUI(quadlet, oui) do { \ 105 (oui)[0] = ((quadlet) >> 16) & 0xff; \ 106 (oui)[1] = ((quadlet) >> 8) & 0xff; \ 107 (oui)[2] = ((quadlet) >> 0) & 0xff; \ 108 } while (0) 109 110 /* size_t P1212_ROMGET_GET_INFOLEN(uint32_t quadlet); 111 */ 112 #define P1212_ROMFMT_GET_INFOLEN(quadlet) (((quadlet) >> 24) & 0xff) 113 114 /* size_t P1212_ROMGET_GET_CRCLEN(uint32_t quadlet); 115 */ 116 #define P1212_ROMFMT_GET_CRCLEN(quadlet) (((quadlet) >> 16) & 0xff) 117 118 /* size_t P1212_ROMGET_GET_CRC(uint32_t quadlet); 119 */ 120 #define P1212_ROMFMT_GET_CRC(quadlet) ((uint16_t)(quadlet)) 121 122 /* uint8_t P1212_DIRENT_GET_KEY(uint32_t quadlet); 123 */ 124 #define P1212_DIRENT_GET_KEY(quadlet) (((quadlet) >> 24) & 0xff) 125 126 /* unsigned int P1212_DIRENT_GET_KEYTYPE(uint32_t quadlet); 127 */ 128 #define P1212_DIRENT_GET_KEYTYPE(quadlet) (((quadlet) >> 30) & 0x03) 129 130 /* unsigned int P1212_DIRENT_GET_KEYVALUE(uint32_t quadlet); 131 */ 132 #define P1212_DIRENT_GET_KEYVALUE(quadlet) (((quadlet) >> 24) & 0x3f) 133 134 /* unsigned int P1212_DIRENT_GET_OFFSET(uint32_t quadlet); 135 */ 136 #define P1212_DIRENT_GET_OFFSET(quadlet) ((quadlet) & 0xffffff) 137 138 /* unsigned int P1212_DIRENT_GET_VALUE(uint32_t quadlet); 139 */ 140 #define P1212_DIRENT_GET_VALUE(quadlet) ((quadlet) & 0xffffff) 141 142 /* u_int16_t P1212_DIRENT_GET_LEN(quadlet); 143 */ 144 #define P1212_DIRENT_GET_LEN(quadlet) (((quadlet) >> 16) & 0xffff) 145 146 /* u_int16_t P1212_DIRENT_GET_CRC(quadlet); 147 */ 148 #define P1212_DIRENT_GET_CRC(quadlet) ((uint16_t)(quadlet)) 149 150 /* Key Types are stored in bits 31-30 of a directory entry. 151 */ 152 153 #define P1212_KEYTYPE_Immediate 0x00 154 #define P1212_KEYTYPE_Offset 0x01 155 #define P1212_KEYTYPE_Leaf 0x02 156 #define P1212_KEYTYPE_Directory 0x03 157 158 /* Key Values are stored in bits 29-24 of a directory entry. 159 */ 160 #define P1212_KEYVALUE_Textual_Descriptor 0x01 /* leaf | directory */ 161 #define P1212_KEYVALUE_Bus_Dependent_Info 0x02 /* leaf | directory */ 162 #define P1212_KEYVALUE_Module_Vendor_Id 0x03 /* immediate */ 163 #define P1212_KEYVALUE_Module_Hw_Version 0x04 /* immediate */ 164 #define P1212_KEYVALUE_Module_Spec_Id 0x05 /* immediate */ 165 #define P1212_KEYVALUE_Module_Sw_Version 0x06 /* immediate */ 166 #define P1212_KEYVALUE_Module_Dependent_Info 0x07 /* leaf | directory */ 167 #define P1212_KEYVALUE_Node_Vendor_Id 0x08 /* immediate */ 168 #define P1212_KEYVALUE_Node_Hw_Version 0x09 /* immediate */ 169 #define P1212_KEYVALUE_Node_Spec_Id 0x0a /* immediate */ 170 #define P1212_KEYVALUE_Node_Sw_Version 0x0b /* immediate */ 171 #define P1212_KEYVALUE_Node_Capabilities 0x0c /* immediate */ 172 #define P1212_KEYVALUE_Node_Unique_Id 0x0d /* leaf */ 173 #define P1212_KEYVALUE_Node_Units_Extent 0x0e /* immediate | offset */ 174 #define P1212_KEYVALUE_Node_Memory_Extent 0x0f /* immediate | offset */ 175 #define P1212_KEYVALUE_Node_Dependent_Info 0x10 /* leaf | directory */ 176 #define P1212_KEYVALUE_Unit_Directory 0x11 /* directory */ 177 #define P1212_KEYVALUE_Unit_Spec_Id 0x12 /* immediate */ 178 #define P1212_KEYVALUE_Unit_Sw_Version 0x13 /* immediate */ 179 #define P1212_KEYVALUE_Unit_Dependent_Info 0x14 /* leaf | directory */ 180 #define P1212_KEYVALUE_Unit_Location 0x15 /* leaf */ 181 #define P1212_KEYVALUE_Unit_Poll_Mask 0x16 /* immediate */ 182 183 /* 184 * Items not in original p1212 standard but are in proposed drafts and in use 185 * already in some roms. 186 */ 187 188 #define P1212_KEYVALUE_Model 0x17 /* immediate */ 189 #define P1212_KEYVALUR_Instance_Directory 0x18 /* directory */ 190 #define P1212_KEYVALUE_Keyword 0x19 /* leaf */ 191 #define P1212_KEYVALUE_Feature_Directory 0x1A /* directory */ 192 #define P1212_KEYVALUE_Extended_ROM 0x1B /* leaf */ 193 #define P1212_KEYVALUE_Extended_Key_Spec_Id 0x1C /* immediate */ 194 #define P1212_KEYVALUE_Extended_Key 0x1D /* immediate */ 195 #define P1212_KEYVALUE_Extended_Data 0x1E /* imm|leaf|dir|offset */ 196 #define P1212_KEYVALUE_Modifiable_Descriptor 0x1F /* leaf */ 197 #define P1212_KEYVALUE_Directory_Id 0x20 /* immediate */ 198 199 #define P1212_KEYTYPE_STRINGS { "Immediate", "Offset", "Leaf", "Directory" } 200 201 #define P1212_KEYVALUE_STRINGS { "Root-Directory", \ 202 "Textual-Descriptor", "Bus-Dependent-Info", "Module-Vendor-Id", \ 203 "Module-Hw-Version", "Module-Spec-Id", "Module-Sw-Version", \ 204 "Module-Dependent-Info", "Node-Vendor-Id", "Node-Hw_Version", \ 205 "Node-Spec-Id", "Node-Sw-Verson", "Node-Capabilities", \ 206 "Node-Unique-Id", "Node-Units-Extent", "Node-Memory-Extent", \ 207 "Node-Dependent-Info", "Unit-Directory", "Unit-Spec-Id", \ 208 "Unit-Sw-Version", "Unit-Dependent-Info", "Unit-Location", \ 209 "Unit-Poll-Mask", "Model", "Instance-Directory", "Keyword", \ 210 "Feature-Directory", "Extended-ROM", "Extended-Key-Spec-Id", \ 211 "Extended-Key", "Extended-Data", "Modifiable-Descriptor", \ 212 "Directory-Id" } 213 214 /* Leaf nodes look like: 215 * 216 * [0] 0xnnnn-0xcccc length, crc16 217 * [n] 218 * 219 * Text leaves look like: 220 * [0] 0xnnnn-0xcccc length, crc16 221 * [1] 0xtt-0xiiiiii specifier type, specifier id 222 * [2] 0xllllllll language id 223 */ 224 225 #define P1212_TEXT_Min_Leaf_Length 0x3 226 #define P1212_TEXT_GET_Spec_Type(quadlet) (((quadlet) & 0xff000000) >> 24) 227 #define P1212_TEXT_GET_Spec_Id(quadlet) ((quadlet) & 0xffffff) 228 229 /* 230 * Directory nodes look like: 231 * [0] 0xnnnn-0xcccc length, crc16 232 * [1] direntry 233 * [n] direntry 234 */ 235 236 /* Some definitions for the p1212_find routines. */ 237 238 #define P1212_FIND_SEARCHALL 0x1 239 #define P1212_FIND_RETURNALL 0x2 240 241 /* Mask definitions for overriding the p1212 standard checks. */ 242 243 /* 244 * XXX: Note that some of these go away if full p1212r support is done as 245 * a lot of the restrictions were lifted there in what can go where. 246 */ 247 248 249 /* Normally dependent info can only be leaf or directory. Allow offsets also */ 250 #define P1212_ALLOW_DEPENDENT_INFO_OFFSET_TYPE 0x1 251 252 /* Same thing applies for immediate types. */ 253 #define P1212_ALLOW_DEPENDENT_INFO_IMMED_TYPE 0x2 254 #define P1212_ALLOW_VENDOR_DIRECTORY_TYPE 0x4 255 256 #endif /* _DEV_STD_IEEE1212REG_H_ */ 257