/** Returns TSC ticks per second. **/ UINT64 EFIAPI GetMemLogTscTicksPerSecond (VOID) { EFI_STATUS Status; if (mMemLog == NULL) { Status = MemLogInit (); if (EFI_ERROR (Status)) { return 0; } } return mMemLog->TscFreqSec; }
/** Sets callback that will be called when message is added to mem log. **/ VOID EFIAPI SetMemLogCallback ( MEM_LOG_CALLBACK Callback ) { EFI_STATUS Status; if (mMemLog == NULL) { Status = MemLogInit (); if (EFI_ERROR (Status)) { return; } } mMemLog->Callback = Callback; }
EFIAPI GetMemLogBuffer ( VOID ) { EFI_STATUS Status; if (mMemLog == NULL) { Status = MemLogInit (); if (EFI_ERROR (Status)) { return NULL; } } return mMemLog != NULL ? mMemLog->Buffer : NULL; }
/** Returns the length of log (number of chars written) in mem buffer. **/ UINTN EFIAPI GetMemLogLen ( VOID ) { EFI_STATUS Status; if (mMemLog == NULL) { Status = MemLogInit (); if (EFI_ERROR (Status)) { return 0; } } return mMemLog != NULL ? mMemLog->Cursor - mMemLog->Buffer : 0; }
/** * \brief OIL system initialization function. * * Calling this function initializes the OIL and starts the RIP. The function * first checks to ensure that the OIL is not in the \c OIL_Sys_JobActive or * \c OIL_Sys_Uninitialised states. This function: * \arg sets up the callback functions used by the Skin to allocate and free memory. * \n In addition, if the system is currently in the \c OIL_Sys_Inactive state and the next state * requested is the \c OIL_Sys_Active state, this function: * \arg allocates and initializes RIP memory; * \arg provides a list of embedded devices to the RIP; * \arg provides exit and reboot callback functions to the RIP; * \arg starts the RIP; * \arg registers resources, RIP modules and streams as required, and * \arg places the system into the \c OIL_Sys_Active state. * \n If the system is currently in the \c OIL_Sys_Suspended state, and the next state * requested is the \c OIL_Sys_Active state, this function: * \arg places the system into the \c OIL_Sys_Active state. * * During this call the RIP is started and claims * \c g_SystemState.cbRIPMemory bytes of memory. * * \param[in] eNextState The system state that is required by the end of the call; * expected to be \c OIL_Sys_Active. * \return Returns TRUE if the system is successfully initialized (as necessary) * and placed in the requested state, FALSE otherwise. */ int SysInit(OIL_eTySystemState eNextState) { struct SysMemFns tSkinMemoryFns; HQASSERT((OIL_Sys_JobActive != g_SystemState.eCurrentState), ("sys_init entered in state: OIL_Sys_JobActive")); HQASSERT((OIL_Sys_Uninitialised != g_SystemState.eCurrentState), ("sys_init entered in state: OIL_Sys_Uninitialised")); /* Initialise the memory helper functions */ /* - these are the memory allocation functions to be used by skin */ tSkinMemoryFns.pAllocFn = SysAllocFnCallback; tSkinMemoryFns.pFreeFn = SysFreeFnCallback; GG_SHOW(GG_SHOW_OIL, "SysInit:\n"); if ( g_profile_scope != NULL && !SwLeProfileOption(NULL, g_profile_scope) ) { oil_printf("sys_init: Invalid profile scope %s\n", g_profile_scope); return 0; } /* log the job start time */ GGglobal_timing(SW_TRACE_OIL_SYSSTART, 0); if ((g_SystemState.eCurrentState == OIL_Sys_Inactive) && (eNextState == OIL_Sys_Active)) { uint8 *reasonText ; /* allocate memory for the RIP, all systems ready for a job */ g_SystemState.pRIPMemory = NULL; #ifdef PMS_OIL_MERGE_DISABLE_MEM g_SystemState.pRIPMemory = OIL_malloc(OILMemoryPoolSys, OIL_MemBlock, g_SystemState.cbRIPMemory); #else g_SystemState.pRIPMemory = mmalloc(g_SystemState.cbRIPMemory); #endif if(g_SystemState.pRIPMemory == NULL) /*Bad Pointer*/ { oil_printf("sys_init: Failed to allocate RIP Memory\n"); return 0; } (void)SwLeInitRuntime(NULL) ; MemLogInit(g_mps_log, g_mps_telemetry) ; /* It is assumed that pthreads has been initialised. This is done earlier in the OIL boot process. */ /* initialize the SDK support libraries */ g_SystemState.cbmaxAddressSpace = g_SystemState.cbRIPMemory; if ( !SwLeSDKStart(&g_SystemState.cbmaxAddressSpace, &g_SystemState.cbRIPMemory, g_SystemState.pRIPMemory, &tSkinMemoryFns, &reasonText) ) { GG_SHOW(GG_SHOW_OIL, "sys_init: %s.\n", (char *)reasonText) ; return FALSE ; } /* Set number of RIP renderer threads */ SwLeSetRipRendererThreads( g_ConfigurableFeatures.nRendererThreads ); SwLeMemInit(g_SystemState.cbmaxAddressSpace, g_SystemState.cbRIPMemory, 0, g_SystemState.pRIPMemory); /* set MultipleCopies pgbdev param to true so that we get just 1 copy in rastercallback */ SwLePgbSetMultipleCopies(TRUE); SwLeSetRasterCallbacks(OIL_RasterStride, OIL_RasterRequirements, OIL_RasterDestination, OIL_RasterCallback); /* Add embedded devices to list passed to RIP */ SwLeAddCustomDevices( sizeof(ppEmbeddedDevices) / sizeof(ppEmbeddedDevices[0]), ppEmbeddedDevices ); /* set RIP exit callback */ SwLeSetRipExitFunction( OIL_RipExitCallback ); /* set RIP reboot callback */ SwLeSetRipRebootFunction( OIL_RipRebootCallback ); if (!oil_progress_init()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to start progress timeline \n"); return FALSE; } /* Start RIP */ if ( SwLeStart( g_SystemState.cbmaxAddressSpace, g_SystemState.cbRIPMemory, 0, g_SystemState.pRIPMemory, (SwLeMONITORCALLBACK *)OIL_MonitorCallback ) ) { g_SystemState.eCurrentState = eNextState; } else { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to start RIP \n"); return FALSE; } /* Report job processing times */ progevts_enable_times(); oil_events_initialise(); if(!RegisterResources()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register resources\n"); return FALSE; } if(!RegisterRIPModules()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register RIP modules\n"); return FALSE; } if(!Stream_Register()) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register Stream\n"); return FALSE; } } if ( !libjpeg_register() || !libjpegturbo_register() ) { GG_SHOW(GG_SHOW_OIL, "sys_init: Failed to register libjpeg\n"); return FALSE; } if ((g_SystemState.eCurrentState == OIL_Sys_Suspended) && (eNextState == OIL_Sys_Active)) { GG_SHOW(GG_SHOW_OIL, "**RIP awakes\n"); g_SystemState.eCurrentState = eNextState; return TRUE; } /* Reset the job error status */ g_JobErrorData.Code = 0; g_JobErrorData.bErrorPageComplete = FALSE; /* return TRUE if now in requested state */ return (g_SystemState.eCurrentState == eNextState); }
/** Prints a log message to memory buffer. @param Timing TRUE to prepend timing to log. @param DebugMode DebugMode will be passed to Callback function if it is set. @param Format The format string for the debug message to print. @param Marker VA_LIST with variable arguments for Format. **/ VOID EFIAPI MemLogVA ( IN CONST BOOLEAN Timing, IN CONST INTN DebugMode, IN CONST CHAR8 *Format, IN VA_LIST Marker ) { EFI_STATUS Status; UINTN DataWritten; CHAR8 *LastMessage; if (Format == NULL) { return; } if (mMemLog == NULL) { Status = MemLogInit (); if (EFI_ERROR (Status)) { return; } } // // Check if buffer can accept MEM_LOG_MAX_LINE_SIZE chars. // Increase buffer if not. // if ((UINTN)(mMemLog->Cursor - mMemLog->Buffer) + MEM_LOG_MAX_LINE_SIZE > mMemLog->BufferSize) { UINTN Offset; // not enough place for max line - make buffer bigger // but not too big (if something gets out of controll) if (mMemLog->BufferSize + MEM_LOG_INITIAL_SIZE > MEM_LOG_MAX_SIZE) { // Out of resources! return; } Offset = mMemLog->Cursor - mMemLog->Buffer; mMemLog->Buffer = ReallocatePool(mMemLog->BufferSize, mMemLog->BufferSize + MEM_LOG_INITIAL_SIZE, mMemLog->Buffer); mMemLog->BufferSize += MEM_LOG_INITIAL_SIZE; mMemLog->Cursor = mMemLog->Buffer + Offset; } // // Add log to buffer // LastMessage = mMemLog->Cursor; if (Timing) { // // Write timing only at the beginnign of a new line // if ((mMemLog->Buffer[0] == '\0') || (mMemLog->Cursor[-1] == '\n')) { DataWritten = AsciiSPrint( mMemLog->Cursor, mMemLog->BufferSize - (mMemLog->Cursor - mMemLog->Buffer), "%a ", GetTiming ()); mMemLog->Cursor += DataWritten; } } DataWritten = AsciiVSPrint( mMemLog->Cursor, mMemLog->BufferSize - (mMemLog->Cursor - mMemLog->Buffer), Format, Marker); mMemLog->Cursor += DataWritten; // // Pass this last message to callback if defined // if (mMemLog->Callback != NULL) { mMemLog->Callback(DebugMode, LastMessage); } }