1 /* $NetBSD: ieee1212reg.h,v 1.4 2001/04/23 00:57:05 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 #define P1212_KEYVALUE_Model_Id 0x17 /* immediate */ 183 184 #define P1212_KEYTYPE_STRINGS { "Immediate", "Offset", "Leaf", "Directory" } 185 186 #define P1212_KEYVALUE_STRINGS { NULL, \ 187 "Textual-Descriptor", "Bus-Dependent-Info", "Module-Vendor-Id", \ 188 "Module-Hw-Version", "Module-Spec-Id", "Module-Sw-Version", \ 189 "Module-Dependent-Info", "Node-Vendor-Id", "Node-Hw_Version", \ 190 "Node-Spec-Id", "Node-Sw-Verson", "Node-Capabilities", \ 191 "Node-Unique-Id", "Node-Units-Extent", "Node-Memory-Extent", \ 192 "Node-Dependent-Info", "Unit-Directory", "Unit-Spec-Id", \ 193 "Unit-Sw-Version", "Unit-Dependent-Info", "Unit-Location", \ 194 "Unit-Poll-Mask", "Model-Id" } 195 196 /* Leaf nodes look like: 197 * 198 * [0] 0xnnnn-0xcccc length, crc16 199 * [n] 200 * 201 * Text leaves look like: 202 * [0] 0xnnnn-0xcccc length, crc16 203 * [1] 0xtt-0xiiiiii specifier type, specifier id 204 * [2] 0xllllllll language id 205 */ 206 207 /* 208 * Directory nodes look like: 209 * [0] 0xnnnn-0xcccc length, crc16 210 * [1] direntry 211 * [n] direntry 212 */ 213 #endif /* _DEV_STD_IEEE1212REG_H_ */ 214