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