1155852Sgallatin/*******************************************************************************
2155852Sgallatin
3171405SgallatinCopyright (c) 2006-2007, Myricom Inc.
4155852SgallatinAll rights reserved.
5155852Sgallatin
6155852SgallatinRedistribution and use in source and binary forms, with or without
7155852Sgallatinmodification, are permitted provided that the following conditions are met:
8155852Sgallatin
9155852Sgallatin 1. Redistributions of source code must retain the above copyright notice,
10155852Sgallatin    this list of conditions and the following disclaimer.
11155852Sgallatin
12171405Sgallatin 2. Neither the name of the Myricom Inc, nor the names of its
13155852Sgallatin    contributors may be used to endorse or promote products derived from
14155852Sgallatin    this software without specific prior written permission.
15155852Sgallatin
16155852SgallatinTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17155852SgallatinAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18155852SgallatinIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19155852SgallatinARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20155852SgallatinLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21155852SgallatinCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22155852SgallatinSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23155852SgallatinINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24155852SgallatinCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25155852SgallatinARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26155852SgallatinPOSSIBILITY OF SUCH DAMAGE.
27155852Sgallatin
28155852Sgallatin$FreeBSD$
29155852Sgallatin***************************************************************************/
30155852Sgallatin
31155852Sgallatin#ifndef _mcp_gen_header_h
32155852Sgallatin#define _mcp_gen_header_h
33155852Sgallatin
34155852Sgallatin/* this file define a standard header used as a first entry point to
35155852Sgallatin   exchange information between firmware/driver and driver.  The
36155852Sgallatin   header structure can be anywhere in the mcp. It will usually be in
37155852Sgallatin   the .data section, because some fields needs to be initialized at
38155852Sgallatin   compile time.
39155852Sgallatin   The 32bit word at offset MX_HEADER_PTR_OFFSET in the mcp must
40155852Sgallatin   contains the location of the header.
41155852Sgallatin
42155852Sgallatin   Typically a MCP will start with the following:
43155852Sgallatin   .text
44155852Sgallatin     .space 52    ! to help catch MEMORY_INT errors
45155852Sgallatin     bt start     ! jump to real code
46155852Sgallatin     nop
47155852Sgallatin     .long _gen_mcp_header
48155852Sgallatin
49155852Sgallatin   The source will have a definition like:
50155852Sgallatin
51155852Sgallatin   mcp_gen_header_t gen_mcp_header = {
52155852Sgallatin      .header_length = sizeof(mcp_gen_header_t),
53155852Sgallatin      .mcp_type = MCP_TYPE_XXX,
54155852Sgallatin      .version = "something $Id: mcp_gen_header.h,v 1.1 2005/12/23 02:10:44 gallatin Exp $",
55155852Sgallatin      .mcp_globals = (unsigned)&Globals
56155852Sgallatin   };
57155852Sgallatin*/
58155852Sgallatin
59155852Sgallatin
60155852Sgallatin#define MCP_HEADER_PTR_OFFSET  0x3c
61155852Sgallatin
62155852Sgallatin#define MCP_TYPE_MX 0x4d582020 /* "MX  " */
63155852Sgallatin#define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */
64155852Sgallatin#define MCP_TYPE_ETH 0x45544820 /* "ETH " */
65155852Sgallatin#define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */
66155852Sgallatin
67155852Sgallatin
68155852Sgallatintypedef struct mcp_gen_header {
69155852Sgallatin  /* the first 4 fields are filled at compile time */
70155852Sgallatin  unsigned header_length;
71155852Sgallatin  unsigned mcp_type;
72155852Sgallatin  char version[128];
73155852Sgallatin  unsigned mcp_globals; /* pointer to mcp-type specific structure */
74155852Sgallatin
75155852Sgallatin  /* filled by the MCP at run-time */
76155852Sgallatin  unsigned sram_size;
77155852Sgallatin  unsigned string_specs;  /* either the original STRING_SPECS or a superset */
78155852Sgallatin  unsigned string_specs_len;
79155852Sgallatin
80155852Sgallatin  /* Fields above this comment are guaranteed to be present.
81155852Sgallatin
82155852Sgallatin     Fields below this comment are extensions added in later versions
83155852Sgallatin     of this struct, drivers should compare the header_length against
84155852Sgallatin     offsetof(field) to check wether a given MCP implements them.
85155852Sgallatin
86155852Sgallatin     Never remove any field.  Keep everything naturally align.
87155852Sgallatin  */
88155852Sgallatin} mcp_gen_header_t;
89155852Sgallatin
90155852Sgallatin/* Macro to create a simple mcp header */
91155852Sgallatin#define MCP_GEN_HEADER_DECL(type, version_str, global_ptr)	\
92155852Sgallatin  struct mcp_gen_header mcp_gen_header = {			\
93155852Sgallatin    sizeof (struct mcp_gen_header),				\
94155852Sgallatin    (type),							\
95155852Sgallatin    version_str,						\
96155852Sgallatin    (global_ptr),						\
97155852Sgallatin    SRAM_SIZE,							\
98155852Sgallatin    (unsigned int) STRING_SPECS,				\
99155852Sgallatin    256								\
100155852Sgallatin  }
101155852Sgallatin
102155852Sgallatin
103155852Sgallatin#endif /* _mcp_gen_header_h */
104