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