1 /*- 2 * Copyright (c) 2000 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. All advertising materials mentioning features or use of this software 17 * must display the following acknowledgement: 18 * This product includes software developed by the NetBSD 19 * Foundation, Inc. and its contributors. 20 * 4. Neither the name of The NetBSD Foundation nor the names of its 21 * contributors may be used to endorse or promote products derived 22 * from this software without specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * POSSIBILITY OF SUCH DAMAGE. 35 */ 36 37 #ifndef _DEV_STD_IEEE1212REG_H_ 38 #define _DEV_STD_IEEE1212REG_H_ 39 40 /* This file contains definitions from ISO/IEC 1312 or ANSI/IEEE Std 1212 41 * Informaton techonology 42 * Microprocessor systes 43 * Control and Status Registers (CSR) 44 * Architecture for microcomputer buses 45 * First edition 1994-10-05 46 */ 47 48 /* Lock transaction codes (Table 5) 49 */ 50 #define P1212_XTCODE_RESERVED_0 0 51 #define P1212_XTCODE_MASK_SWAP 1 52 #define P1212_XTCODE_COMPARE_SWAP 2 53 #define P1212_XTCODE_FETCH_ADD 3 54 #define P1212_XTCODE_LITTLE_ADD 4 55 #define P1212_XTCODE_BOUNDED_ADD 5 56 #define P1212_XTCODE_WRAP_ADD 6 57 #define P1212_XTCODE_VENDOR_DEPENDENT 7 58 59 /* Header: Rom Format (1 Quadlet) 60 * Bus Info Block: <info-length> Quadlets 61 * Root Directory 62 * Unit Directory 63 * Root & Unit Leaves 64 * Vendor Dependent Information 65 */ 66 /* ROM Formats 67 * 0x00-0x000000 Initializing 68 * 0x01-0xzzyyxx Minimal (zz-yy-xx is an OUI) 69 * 0xii-0xcc-0xllll General (ii is info-length, 70 * cc is crc-length, llll is length) 71 */ 72 73 #define P1212_ROMFMT_INIT 0x00 74 #define P1212_ROMFMT_MINIMAL 0x01 75 76 /* uint32_t P1212_ROMFMT_MK_INIT(void) 77 */ 78 #define P1212_ROMFMT_MK_INIT() 0x00000000 79 80 /* uint32_t P1212_ROMFMT_MK_MINIMAL(const uint8_t *oui); 81 */ 82 #define P1212_ROMFMT_MK_MINIMAL(oui) \ 83 ((P1212_ROMFMT_MINIMAL << 24) \ 84 | ((oui[0]) << 16) \ 85 | ((oui[1]) << 8) \ 86 | ((oui[2]) << 0)) 87 88 /* uint32_t P1212_ROMFMT_MK_GENERAL(size_t info_len, size_t crc_len, 89 * uint16_t crc); 90 */ 91 #define P1212_ROMFMT_MK_GENERAL(info_len, crc_len, crc_value) \ 92 (((info_len) << 24) \ 93 | ((crc_len) << 16) \ 94 | ((crc_value) << 0)) 95 96 /* unsigned P1212_ROMFMT_GET_FMT(uint32_t); 97 */ 98 #define P1212_ROMFMT_GET_FMT(quadlet) (((quadlet) >> 24) & 0xff) 99 100 /* void P1212_ROMFMT_GET_OUI(uint32_t quadlet, uint8_t *oui); 101 */ 102 #define P1212_ROMTFMT_GET_OUI(quadlet, oui) do { \ 103 (oui)[0] = ((quadlet) >> 16) & 0xff; \ 104 (oui)[1] = ((quadlet) >> 8) & 0xff; \ 105 (oui)[2] = ((quadlet) >> 0) & 0xff; \ 106 } while (0) 107 108 /* size_t P1212_ROMGET_GET_INFOLEN(uint32_t quadlet); 109 */ 110 #define P1212_ROMFMT_GET_INFOLEN(quadlet) (((quadlet) >> 24) & 0xff) 111 112 /* size_t P1212_ROMGET_GET_CRCLEN(uint32_t quadlet); 113 */ 114 #define P1212_ROMFMT_GET_CRCLEN(quadlet) (((quadlet) >> 16) & 0xff) 115 116 /* size_t P1212_ROMGET_GET_INFOLEN(uint32_t quadlet); 117 */ 118 #define P1212_ROMFMT_GET_CRC(quadlet) ((uint16_t)(quadlet)) 119 120 /* unsigned int P1212_DIRENT_GET_KEYTYPE(uint32_t quadlet); 121 */ 122 #define P1212_DIRENT_GET_KEYTYPE(quadlet) (((quadlet) >> 30) & 0x03) 123 124 /* unsigned int P1212_DIRENT_GET_KEYVALUE(uint32_t quadlet); 125 */ 126 #define P1212_DIRENT_GET_KEYVALUE(quadlet) (((quadlet) >> 24) & 0x3f) 127 128 /* unsigned int P1212_DIRECT_GET_OFFSET(uint32_t quadlet); 129 */ 130 #define P1212_DIRENT_GET_OFFSET(quadlet) ((quadlet) & 0xffffff) 131 132 /* unsigned int P1212_DIRECT_GET_OFFSET(uint32_t quadlet); 133 */ 134 #define P1212_DIRENT_GET_OFFSET(quadlet) ((quadlet) & 0xffffff) 135 136 /* unsigned int P1212_DIRECT_GET_VALUE(uint32_t quadlet); 137 */ 138 #define P1212_DIRENT_GET_VALUE(quadlet) ((quadlet) & 0xffffff) 139 140 /* Key Types are stored in bits 31-30 of a directory entry. 141 */ 142 143 #define P1212_KEYTYPE_Immediate 0x00 144 #define P1212_KEYTYPE_Offset 0x01 145 #define P1212_KEYTYPE_Leaf 0x02 146 #define P1212_KEYTYPE_Directory 0x03 147 148 /* Key Values are stored in bits 29-24 of a directory entry. 149 */ 150 #define P1212_KEYVALUE_Textual_Descriptor 0x01 /* leaf | directory */ 151 #define P1212_KEYVALUE_Bus_Dependent_Info 0x02 /* leaf | directory */ 152 #define P1212_KEYVALUE_Module_Vendor_Id 0x03 /* immediate */ 153 #define P1212_KEYVALUE_Module_Hw_Version 0x04 /* immediate */ 154 #define P1212_KEYVALUE_Module_Spec_Id 0x05 /* immediate */ 155 #define P1212_KEYVALUE_Module_Sw_Version 0x06 /* immediate */ 156 #define P1212_KEYVALUE_Module_Dependent_info 0x07 /* leaf | directory */ 157 #define P1212_KEYVALUE_Node_Vendor_Id 0x08 /* immediate */ 158 #define P1212_KEYVALUE_Node_Hw_Version 0x09 /* immediate */ 159 #define P1212_KEYVALUE_Node_Spec_Id 0x0a /* immediate */ 160 #define P1212_KEYVALUE_Node_Sw_Version 0x0b /* immediate */ 161 #define P1212_KEYVALUE_Node_Capabilities 0x0c /* immediate */ 162 #define P1212_KEYVALUE_Node_Unique_Id 0x0d /* leaf */ 163 #define P1212_KEYVALUE_Node_Units_Extent 0x0e /* immediate | offset */ 164 #define P1212_KEYVALUE_Node_Memory_Extent 0x0f /* immediate | offset */ 165 #define P1212_KEYVALUE_Node_Dependent_Info 0x10 /* leaf | directory */ 166 #define P1212_KEYVALUE_Unit_Directory 0x11 /* directory */ 167 #define P1212_KEYVALUE_Unit_Spec_Id 0x12 /* immediate */ 168 #define P1212_KEYVALUE_Unit_Sw_Version 0x13 /* immediate */ 169 #define P1212_KEYVALUE_Unit_Dependent_Info 0x14 /* leaf | directory */ 170 #define P1212_KEYVALUE_Unit_Location 0x15 /* leaf */ 171 #define P1212_KEYVALUE_Unit_Poll_Mask 0x16 /* immediate */ 172 173 #define P1212_KEYTYPE_STRINGS { "Immediate", "Offset", "Leaf", "Directory" } 174 175 #define P1212_KEYVALUE_STRINGS { NULL, \ 176 "Textual-Descriptor", "Bus-Dependent-Info", "Module-Vendor-Id", \ 177 "Module-Hw-Version", "Module-Spec-Id", "Module-Sw-Version", \ 178 "Module-Dependent-Info", "Node-Vendor-Id", "Node-Hw_Version", \ 179 "Node-Spec-Id", "Node-Sw-Verson", "Node-Capabilities", \ 180 "Node-Unique-Id", "Node-Units-Extent", "Node-Memory-Extent", \ 181 "Node-Dependent-Info", "Unit-Directory", "Unit-Spec-Id", \ 182 "Unit-Sw-Version", "Unit-Dependent-Info", "Unit-Location", \ 183 "Unit-Poll-Mask", } 184 185 /* Leaf nodes look like: 186 * 187 * [0] 0xnnnn-0xcccc length, crc16 188 * [n] 189 * 190 * Text leaves look like: 191 * [0] 0xnnnn-0xcccc length, crc16 192 * [1] 0xtt-0xiiiiii specifier type, specifier id 193 * [2] 0xllllllll language id 194 */ 195 196 /* 197 * Directory nodes look like: 198 * [0] 0xnnnn-0xcccc length, crc16 199 * [1] direntry 200 * [n] direntry 201 */ 202 #endif /* _DEV_STD_IEEE1212REG_H_ */ 203