xref: /freebsd/sys/dev/mxge/mcp_gen_header.h (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1 /*******************************************************************************
2 SPDX-License-Identifier: BSD-2-Clause-FreeBSD
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 
61 #define MCP_HEADER_PTR_OFFSET  0x3c
62 
63 #define MCP_TYPE_MX 0x4d582020 /* "MX  " */
64 #define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */
65 #define MCP_TYPE_ETH 0x45544820 /* "ETH " */
66 #define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */
67 
68 
69 typedef struct mcp_gen_header {
70   /* the first 4 fields are filled at compile time */
71   unsigned header_length;
72   unsigned mcp_type;
73   char version[128];
74   unsigned mcp_globals; /* pointer to mcp-type specific structure */
75 
76   /* filled by the MCP at run-time */
77   unsigned sram_size;
78   unsigned string_specs;  /* either the original STRING_SPECS or a superset */
79   unsigned string_specs_len;
80 
81   /* Fields above this comment are guaranteed to be present.
82 
83      Fields below this comment are extensions added in later versions
84      of this struct, drivers should compare the header_length against
85      offsetof(field) to check wether a given MCP implements them.
86 
87      Never remove any field.  Keep everything naturally align.
88   */
89 } mcp_gen_header_t;
90 
91 /* Macro to create a simple mcp header */
92 #define MCP_GEN_HEADER_DECL(type, version_str, global_ptr)	\
93   struct mcp_gen_header mcp_gen_header = {			\
94     sizeof (struct mcp_gen_header),				\
95     (type),							\
96     version_str,						\
97     (global_ptr),						\
98     SRAM_SIZE,							\
99     (unsigned int) STRING_SPECS,				\
100     256								\
101   }
102 
103 
104 #endif /* _mcp_gen_header_h */
105