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