1 /*
2  * Copyright 2008-2012 Freescale Semiconductor Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *     * Redistributions of source code must retain the above copyright
7  *       notice, this list of conditions and the following disclaimer.
8  *     * Redistributions in binary form must reproduce the above copyright
9  *       notice, this list of conditions and the following disclaimer in the
10  *       documentation and/or other materials provided with the distribution.
11  *     * Neither the name of Freescale Semiconductor nor the
12  *       names of its contributors may be used to endorse or promote products
13  *       derived from this software without specific prior written permission.
14  *
15  *
16  * ALTERNATIVELY, this software may be distributed under the terms of the
17  * GNU General Public License ("GPL") as published by the Free Software
18  * Foundation, either version 2 of that License or (at your option) any
19  * later version.
20  *
21  * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
22  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
25  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 
34 /******************************************************************************
35  @File          fm_sp_common.h
36 
37  @Description   FM SP  ...
38 *//***************************************************************************/
39 #ifndef __FM_SP_COMMON_H
40 #define __FM_SP_COMMON_H
41 
42 #include "std_ext.h"
43 #include "error_ext.h"
44 #include "list_ext.h"
45 
46 #include "fm_ext.h"
47 #include "fm_pcd_ext.h"
48 #include "fsl_fman.h"
49 
50 /**************************************************************************//**
51  @Description       defaults
52 *//***************************************************************************/
53 #define DEFAULT_FM_SP_bufferPrefixContent_privDataSize      0
54 #define DEFAULT_FM_SP_bufferPrefixContent_passPrsResult     FALSE
55 #define DEFAULT_FM_SP_bufferPrefixContent_passTimeStamp     FALSE
56 #define DEFAULT_FM_SP_bufferPrefixContent_allOtherPCDInfo   FALSE
57 #define DEFAULT_FM_SP_bufferPrefixContent_dataAlign         64
58 
59 /**************************************************************************//**
60  @Description   structure for defining internal context copying
61 *//***************************************************************************/
62 typedef struct
63 {
64     uint16_t    extBufOffset;       /**< Offset in External buffer to which internal
65                                          context is copied to (Rx) or taken from (Tx, Op). */
66     uint8_t     intContextOffset;   /**< Offset within internal context to copy from
67                                          (Rx) or to copy to (Tx, Op). */
68     uint16_t    size;               /**< Internal offset size to be copied */
69 } t_FmSpIntContextDataCopy;
70 
71 /**************************************************************************//**
72  @Description   struct for defining external buffer margins
73 *//***************************************************************************/
74 typedef struct {
75     uint16_t    startMargins;           /**< Number of bytes to be left at the beginning
76                                              of the external buffer (must be divisible by 16) */
77     uint16_t    endMargins;             /**< number of bytes to be left at the end
78                                              of the external buffer(must be divisible by 16) */
79 } t_FmSpBufMargins;
80 
81 typedef struct {
82     uint32_t      dataOffset;
83     uint32_t      prsResultOffset;
84     uint32_t      timeStampOffset;
85     uint32_t      hashResultOffset;
86     uint32_t      pcdInfoOffset;
87     uint32_t      manipOffset;
88 } t_FmSpBufferOffsets;
89 
90 
91 t_Error        FmSpBuildBufferStructure(t_FmSpIntContextDataCopy      *p_FmPortIntContextDataCopy,
92                                         t_FmBufferPrefixContent       *p_BufferPrefixContent,
93                                         t_FmSpBufMargins              *p_FmPortBufMargins,
94                                         t_FmSpBufferOffsets           *p_FmPortBufferOffsets,
95                                         uint8_t                       *internalBufferOffset);
96 
97 t_Error     FmSpCheckIntContextParams(t_FmSpIntContextDataCopy *p_FmSpIntContextDataCopy);
98 t_Error     FmSpCheckBufPoolsParams(t_FmExtPools *p_FmExtPools,
99                                     t_FmBackupBmPools *p_FmBackupBmPools,
100                                     t_FmBufPoolDepletion *p_FmBufPoolDepletion);
101 t_Error     FmSpCheckBufMargins(t_FmSpBufMargins *p_FmSpBufMargins);
102 void        FmSpSetBufPoolsInAscOrderOfBufSizes(t_FmExtPools *p_FmExtPools, uint8_t *orderedArray, uint16_t *sizesArray);
103 
104 t_Error     FmPcdSpAllocProfiles(t_Handle h_FmPcd,
105                                  uint8_t  hardwarePortId,
106                                  uint16_t numOfStorageProfiles,
107                                  uint16_t *base,
108                                  uint8_t  *log2Num);
109 t_Error     FmPcdSpGetAbsoluteProfileId(t_Handle                        h_FmPcd,
110                                         t_Handle                        h_FmPort,
111                                         uint16_t                        relativeProfile,
112                                         uint16_t                        *p_AbsoluteId);
113 void SpInvalidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
114 void SpValidateProfileSw(t_Handle h_FmPcd, uint16_t absoluteProfileId);
115 
116 
117 #endif /* __FM_SP_COMMON_H */
118