1 /******************************************************************************* 2 3 Copyright (c) 2006, Myricom Inc. 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 3. Neither the name of the Myricom Inc, nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 POSSIBILITY OF SUCH DAMAGE. 31 32 $FreeBSD$ 33 ***************************************************************************/ 34 35 #ifndef _mcp_gen_header_h 36 #define _mcp_gen_header_h 37 38 /* this file define a standard header used as a first entry point to 39 exchange information between firmware/driver and driver. The 40 header structure can be anywhere in the mcp. It will usually be in 41 the .data section, because some fields needs to be initialized at 42 compile time. 43 The 32bit word at offset MX_HEADER_PTR_OFFSET in the mcp must 44 contains the location of the header. 45 46 Typically a MCP will start with the following: 47 .text 48 .space 52 ! to help catch MEMORY_INT errors 49 bt start ! jump to real code 50 nop 51 .long _gen_mcp_header 52 53 The source will have a definition like: 54 55 mcp_gen_header_t gen_mcp_header = { 56 .header_length = sizeof(mcp_gen_header_t), 57 .mcp_type = MCP_TYPE_XXX, 58 .version = "something $Id: mcp_gen_header.h,v 1.1 2005/12/23 02:10:44 gallatin Exp $", 59 .mcp_globals = (unsigned)&Globals 60 }; 61 */ 62 63 64 #define MCP_HEADER_PTR_OFFSET 0x3c 65 66 #define MCP_TYPE_MX 0x4d582020 /* "MX " */ 67 #define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */ 68 #define MCP_TYPE_ETH 0x45544820 /* "ETH " */ 69 #define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */ 70 71 72 typedef struct mcp_gen_header { 73 /* the first 4 fields are filled at compile time */ 74 unsigned header_length; 75 unsigned mcp_type; 76 char version[128]; 77 unsigned mcp_globals; /* pointer to mcp-type specific structure */ 78 79 /* filled by the MCP at run-time */ 80 unsigned sram_size; 81 unsigned string_specs; /* either the original STRING_SPECS or a superset */ 82 unsigned string_specs_len; 83 84 /* Fields above this comment are guaranteed to be present. 85 86 Fields below this comment are extensions added in later versions 87 of this struct, drivers should compare the header_length against 88 offsetof(field) to check wether a given MCP implements them. 89 90 Never remove any field. Keep everything naturally align. 91 */ 92 } mcp_gen_header_t; 93 94 /* Macro to create a simple mcp header */ 95 #define MCP_GEN_HEADER_DECL(type, version_str, global_ptr) \ 96 struct mcp_gen_header mcp_gen_header = { \ 97 sizeof (struct mcp_gen_header), \ 98 (type), \ 99 version_str, \ 100 (global_ptr), \ 101 SRAM_SIZE, \ 102 (unsigned int) STRING_SPECS, \ 103 256 \ 104 } 105 106 107 #endif /* _mcp_gen_header_h */ 108