1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2016-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: MIT
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef _BINDATA_PRIVATE_H
25 #define _BINDATA_PRIVATE_H
26 
27 #include "core/core.h"
28 #include "lib/zlib/inflate.h"
29 #include "core/bin_data.h"
30 
31 /**************************************************************************************************************
32 *
33 *    File:  bin_data_private.h
34 *
35 *    Description:
36 *        Private data structure for binary data management API
37 *
38 **************************************************************************************************************/
39 
40 //
41 // WARNING: This header should not be included directly (outside of bindata
42 // impl)
43 //
44 // TODO: Clean up the references that have snuck in and move outside of the
45 // public module directory
46 //
47 
48 //
49 // Private data structure for binary data management
50 //
51 
52 //
53 // Binary data management static information (generated by bindata.pl)
54 //
55 typedef struct
56 {
57     NvU32           actualSize;         // size of (uncompressed) pData
58     NvU32           compressedSize;     // size of (compressed) pData array
59     const void *    pData;              // pointer to the raw binary (whether compressed or not) data
60     NvBool          bCompressed            : 1;    // is compressed?
61     NvBool          bFileOverrideSupported : 1;    // contain information for file overriding?
62     NvBool          bReferenced            : 1;    // Has this data been referenced before?
63 } BINDATA_STORAGE_PVT, *PBINDATA_STORAGE_PVT;
64 
65 //
66 // Binary data management runtime information
67 //
68 struct BINDATA_RUNTIME_INFO
69 {
70     const BINDATA_STORAGE_PVT  *pBinStoragePvt;  // pointer to the static init struct
71     PGZ_INFLATE_STATE           pGzState;        // used by gzip
72     NvU32                       currDataPos;     // position where next chunk acquire should start at
73 };
74 
75 //
76 // This knob controls whether the data will be placed into .rodata section and
77 // be considered constant for the lifetime of RM, or if it can be modified
78 // during execution. Right now, we only need to modify it on GSP to reclaim
79 // the memory as general purpose heap.
80 //
81 #define BINDATA_IS_MUTABLE RMCFG_FEATURE_PLATFORM_GSP
82 #if BINDATA_IS_MUTABLE
83 #define BINDATA_CONST __attribute__((section(".bindata")))
84 #else
85 #define BINDATA_CONST const
86 #endif
87 
88 void bindataMarkReferenced(const BINDATA_STORAGE *pBinStorage);
89 
90 #endif // _BINDATA_PRIVATE_H
91