1 /*
2 * Copyright (c) 2020, Intel Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22 //!
23 //! \file     mos_os_mock_adaptor.h
24 //! \brief    Common interface and structure used in mock adaptor.
25 //!
26 
27 #ifndef __MOS_OS_MOCK_ADAPTOR_H__
28 #define __MOS_OS_MOCK_ADAPTOR_H__
29 
30 #include "mos_os.h"
31 #include "mos_os_specific.h"
32 
33 #define MOS_MOCKADAPTOR_DEFAULT_PLATFORM                "tgllp"
34 #define MOS_MOCKADAPTOR_DEFAULT_STEPPING                "a0"
35 
36 class MosMockAdaptor
37 {
38 public:
39     MosMockAdaptor();
40 
41     virtual ~MosMockAdaptor();
42 
43     //!
44     //! \brief    Interface for initializing Mock Adaptor.
45     //! \details  Interface for initializing Mock Adaptor.
46     //! \param    [in/out] osContext
47     //!           Pointer to OS context.
48     //! \return   MOS_STATUS
49     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
50     //!
51     static MOS_STATUS Init(
52         PMOS_CONTEXT osContext);
53 
54     //!
55     //! \brief    Destroy MockAdaptor.
56     //! \details  Destroy MockAdaptor.
57     //! \return   void
58     //!
59     static MOS_STATUS Destroy();
60 
61 protected:
62     //!
63     //! \brief    Initialize MockAdaptor and replace platform information for device context.
64     //! \details  Initialize according to regkey and replace platform infomation for device context.
65     //! \param    [in] osContext
66     //!           Pointer to Os Context.
67     //! \return   MOS_STATUS
68     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
69     //!
70     MOS_STATUS Initialize(
71         PMOS_CONTEXT osContext);
72 
73     //!
74     //! \brief    Read corresponding regkey for mockadaptor
75     //! \details  Read corresponding regkey for mockadaptor.
76     //! \param    [in] osContext
77     //!           Pointer to Os Context.
78     //! \return   MOS_STATUS
79     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
80     //!
81     static MOS_STATUS RegkeyRead(PMOS_CONTEXT osContext);
82 
83     //!
84     //! \brief    Initialize PlatForm.
85     //! \details  Initialize PlatForm according to the regkey.
86     //! \return   MOS_STATUS
87     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
88     //!
89     MOS_STATUS InitializePlatForm();
90 
91     //!
92     //! \brief    Initialize SKU/WA table for device context.
93     //! \details  Initialize the SKU/WA table for device context by mocking.
94     //! \return   MOS_STATUS
95     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
96     //!
InitializeSkuWaTable(PMOS_CONTEXT context)97     virtual MOS_STATUS InitializeSkuWaTable(PMOS_CONTEXT context)
98     {
99         return MOS_STATUS_SUCCESS;
100     }
101 
102     //!
103     //! \brief    Replace platform infomation for device context.
104     //! \details  Replace platform infomation for device context.
105     //! \return   MOS_STATUS
106     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
107     //!
ReplacePlatformInfo(PMOS_CONTEXT context)108     virtual MOS_STATUS ReplacePlatformInfo(PMOS_CONTEXT context)
109     {
110         return MOS_STATUS_SUCCESS;
111     }
112 
113     //!
114     //! \brief    Initialize device context.
115     //! \details  Initialize the device context according the regkey.
116     //! \return   MOS_STATUS
117     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
118     //!
119     virtual MOS_STATUS InitContext(
120         PMOS_CONTEXT osContext);
121 
122     //!
123     //! \brief    Update User FeatureKey
124     //! \details  Update User FeatureKey to report platform info.
125     //! \return   MOS_STATUS
126     //!           Return MOS_STATUS_SUCCESS if successful, otherwise failed
127     //!
UpdateUserFeatureKey(PMOS_CONTEXT osContext)128     virtual MOS_STATUS UpdateUserFeatureKey(
129         PMOS_CONTEXT osContext)
130     {
131         return MOS_STATUS_SUCCESS;
132     }
133 
134 protected:
135     PLATFORM                *m_pPlatform     = nullptr;
136     MEDIA_WA_TABLE          *m_pWaTable      = nullptr;
137     MEDIA_FEATURE_TABLE     *m_pSkuTable     = nullptr;
138     MEDIA_SYSTEM_INFO       *m_pGtSystemInfo = nullptr;
139 
140 
141     static bool  m_enabled;
142     static PRODUCT_FAMILY m_productFamily;
143     static std::string m_stepping;
144     static uint16_t m_deviceId;
145     static MosMockAdaptor *m_mocAdaptor;
146 
147 };
148 
149 #endif // __MOS_OS_MOCK_ADAPTOR_H__