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