2020-03-06 11:09:57 +01:00
/*
2023-08-02 19:33:48 +02:00
* Copyright ( C ) 2020 - 2023 Intel Corporation
2020-03-06 11:09:57 +01:00
*
* SPDX - License - Identifier : MIT
*
*/
# include "pin.h"
2020-05-11 15:02:56 -07:00
# include "shared/source/debug_settings/debug_settings_manager.h"
# include "os_pin.h"
2023-10-04 16:11:47 +00:00
# include <memory>
2023-08-02 19:33:48 +02:00
namespace NEO {
2020-03-06 11:09:57 +01:00
2022-07-26 01:38:44 +00:00
PinContext : : OsLibraryLoadPtr PinContext : : osLibraryLoadFunction ( NEO : : OsLibrary : : load ) ;
2023-08-02 19:33:48 +02:00
bool PinContext : : init ( const std : : string & gtPinOpenFunctionName ) {
2023-10-04 16:11:47 +00:00
auto hGtPinLibrary = std : : unique_ptr < OsLibrary > ( PinContext : : osLibraryLoadFunction ( PinContext : : gtPinLibraryFilename . c_str ( ) ) ) ;
2020-05-11 15:02:56 -07:00
2022-07-26 01:38:44 +00:00
if ( hGtPinLibrary = = nullptr ) {
2023-11-30 08:32:25 +00:00
PRINT_DEBUG_STRING ( NEO : : debugManager . flags . PrintDebugMessages . get ( ) , stderr , " Unable to find gtpin library %s \n " , PinContext : : gtPinLibraryFilename . c_str ( ) ) ;
2023-08-02 19:33:48 +02:00
return false ;
2020-05-11 15:02:56 -07:00
}
2022-05-09 16:21:21 +00:00
OpenGTPin_fn openGTPin = reinterpret_cast < OpenGTPin_fn > ( hGtPinLibrary - > getProcAddress ( gtPinOpenFunctionName . c_str ( ) ) ) ;
2020-05-11 15:02:56 -07:00
if ( openGTPin = = nullptr ) {
2023-11-30 08:32:25 +00:00
PRINT_DEBUG_STRING ( NEO : : debugManager . flags . PrintDebugMessages . get ( ) , stderr , " Unable to find gtpin library open function symbol %s \n " , gtPinOpenFunctionName . c_str ( ) ) ;
2023-08-02 19:33:48 +02:00
return false ;
2020-05-11 15:02:56 -07:00
}
uint32_t openResult = openGTPin ( nullptr ) ;
if ( openResult ! = 0 ) {
2023-11-30 08:32:25 +00:00
PRINT_DEBUG_STRING ( NEO : : debugManager . flags . PrintDebugMessages . get ( ) , stderr , " gtpin library open %s failed with status %u \n " , gtPinOpenFunctionName . c_str ( ) , openResult ) ;
2023-08-02 19:33:48 +02:00
return false ;
2020-03-06 11:09:57 +01:00
}
2023-08-02 19:33:48 +02:00
return true ;
2020-03-06 11:09:57 +01:00
}
2023-08-02 19:33:48 +02:00
} // namespace NEO