void *FMUC_ReserveMemory(char *Requester, dword size) { tFMUC_MemDebug *Mem; void *ret; dword NrReservations, NrTotalSize; ret = TAP_MemAlloc(size); return ret; Mem = FMUC_MemoryFindFree(); if(Mem == NULL) { LogEntryFBLibPrintf(TRUE, "FMUC_ReserveMemory: no space in lookup table"); return ret; } Mem->Requester = Requester; Mem->Size = size; Mem->Alloc = ret; FMUC_MemoryDump(&NrReservations, &NrTotalSize); LogEntryFBLibPrintf(TRUE, "FMUC: %s has requested %d bytes. Currently %d, %d bytes", Requester, size, NrReservations, NrTotalSize); return ret; }
bool EPGInfo_CreateCache(int NrRecords) { TRACEENTER(); extern dword __tap_ud__; TAP_SPrint(EPGCacheFile, "/mnt/hd/tmp/EPGCache_%x.bin", __tap_ud__); if(EPGInfoCacheFile) EPGInfo_DestroyCache(); EPGInfoCacheSize = NrRecords * sizeof(TYPE_EPGInfo); //Delete the old cache unlink(EPGCacheFile); mkdir("/mnt/hd/tmp", 0777); EPGInfoCacheFile = open(EPGCacheFile, O_RDWR | O_CREAT | O_TRUNC, (mode_t)0600); if(EPGInfoCacheFile == -1) { LogEntryFBLibPrintf(TRUE, "EPGInfo: failed to create the memory mapped EPG cache"); TRACEEXIT(); return FALSE; } //Increase the size of the cache as needed if(lseek(EPGInfoCacheFile, EPGInfoCacheSize, SEEK_SET) == -1) { LogEntryFBLibPrintf(TRUE, "EPGInfo: failed to stretch the memory mapped EPG cache"); close(EPGInfoCacheFile); unlink(EPGCacheFile); TRACEEXIT(); return FALSE; } write(EPGInfoCacheFile, "", 1); //Map the memory EPGInfoCacheMap = mmap(0, EPGInfoCacheSize, PROT_READ | PROT_WRITE, MAP_SHARED, EPGInfoCacheFile, 0); if(EPGInfoCacheMap == MAP_FAILED) { LogEntryFBLibPrintf(TRUE, "EPGInfo: failed to memory map the EPG cache file"); close(EPGInfoCacheFile); unlink(EPGCacheFile); TRACEEXIT(); return FALSE; } EPGInfoCache = (TYPE_EPGInfo*)EPGInfoCacheMap; TRACEEXIT(); return TRUE; }
int TAP_Osd_Create_Chk(char *Comment, dword x, dword y, dword w, dword h, byte lutIdx, int flag) { TRACEENTER(); int ret; if(Comment) { if(x > 719) LogEntryFBLibPrintf(TRUE, "TAP_Osd_Create_Chk Warning: x(%d) out of range @ %s", x, Comment); if(y > 575) LogEntryFBLibPrintf(TRUE, "TAP_Osd_Create_Chk Warning: y(%d) out of range @ %s", y, Comment); if((x + w) > 720) LogEntryFBLibPrintf(TRUE, "TAP_Osd_Create_Chk Warning: x(%d) + w(%d) out of range @ %s", x, w, Comment); if((y + h) > 576) LogEntryFBLibPrintf(TRUE, "TAP_Osd_Create_Chk Warning: y(%d) + h(%d) out of range @ %s", y, h, Comment); } ret = TAP_Osd_Create(x, y, w, h, lutIdx, flag); if(Comment && ret < 128) LogEntryFBLibPrintf(TRUE, "TAP_Osd_Create_Chk Warning: TAP_Osd_Create() returned %d @ %s", ret, Comment); TRACEEXIT(); return ret; }
void FMUC_FreeMemory(char *Requester, void *Pointer) { tFMUC_MemDebug *Mem; dword NrReservations, NrTotalSize; TAP_MemFree(Pointer); return; Mem = FMUC_MemoryFindPointer(Pointer); if(Mem == NULL) { LogEntryFBLibPrintf(TRUE, "FMUC_FreeMemory: entry not found in lookup table"); return; } Mem->Alloc = NULL; FMUC_MemoryDump(&NrReservations, &NrTotalSize); LogEntryFBLibPrintf(TRUE, "FMUC: '%s' has released %d bytes from '%s'. Currently %d, %d bytes", Requester, Mem->Size, Mem->Requester, NrReservations, NrTotalSize); Mem->Size = 0; Mem->Requester = NULL; }
void TAP_Osd_RestoreBox_Chk(char *Comment, word rgn, dword x, dword y, dword w, dword h, void *data) { TRACEENTER(); dword RgnH, RgnW; if(Comment) { RgnH = GetOSDRegionHeight(rgn); RgnW = GetOSDRegionWidth(rgn); if(!isOSDRegionAlive(rgn)) LogEntryFBLibPrintf(TRUE, "TAP_Osd_RestoreBox_Chk Warning: rgn(%d) points to an undefined region @ %s", rgn, Comment); if(x >= RgnW) LogEntryFBLibPrintf(TRUE, "TAP_Osd_RestoreBox_Chk Warning: x(%d) out of range @ %s", x, Comment); if(y >= RgnH) LogEntryFBLibPrintf(TRUE, "TAP_Osd_RestoreBox_Chk Warning: y(%d) out of range @ %s", y, Comment); if((x + w) > RgnW) LogEntryFBLibPrintf(TRUE, "TAP_Osd_RestoreBox_Chk Warning: x(%d) + w(%d) out of range @ %s", x, w, Comment); if((y + h) > RgnH) LogEntryFBLibPrintf(TRUE, "TAP_Osd_RestoreBox_Chk Warning: y(%d) + h(%d) out of range @ %s", y, h, Comment); if(data == NULL) LogEntryFBLibPrintf(TRUE, "TAP_Osd_RestoreBox_Chk Warning: trying to restore from NULL @ %s", Comment); } TAP_Osd_RestoreBox(rgn, x, y, w, h, data); TRACEEXIT(); }
void CallTraceExitResult(dword *Magic, char *Result) { char Spaces[101]; int i, j; dword t; byte *ISOText; extern dword __tap_ud__; if(CallTraceDoNotReenter) return; CallTraceDoNotReenter = TRUE; t = TAP_GetTick(); if(!CallTraceInitialized) CallTraceInit(); Spaces[0] = '\0'; if(CallLevel > 0) { CallLevel--; if(CallTraceEnabled && CallTraceStats && CallLevel < CTSTACKSIZE) { //Check if the proc name is already known by the stats array j = -1; for(i = 0; i < CallTraceStatsEntries; i++) if(CallTraceStats[i].ProcName == CallTraceStack[CallLevel].ProcName) { j = i; break; } //If not, use the next free entry if(j == -1) j = CallTraceStatsEntries; //Add the stats if(j < CTSTATENTRIES) { i = t - CallTraceStack[CallLevel].EntryTime; if(CallTraceStats[j].ProcName) { //Already known if((dword)i < CallTraceStats[j].MinTime) CallTraceStats[j].MinTime = i; if((dword)i > CallTraceStats[j].MaxTime) CallTraceStats[j].MaxTime = i; if(CallTraceStats[j].NrCalls < 0xffffffff) { CallTraceStats[j].TotalTime += i; CallTraceStats[j].NrCalls++; } } else { //New procedure CallTraceStats[j].ProcName = CallTraceStack[CallLevel].ProcName; CallTraceStats[j].MinTime = i; CallTraceStats[j].MaxTime = i; CallTraceStats[j].TotalTime = i; CallTraceStats[j].NrCalls = 1; CallTraceStatsEntries++; } } } } else LogEntryFBLibPrintf(TRUE, "CallLevel Underflow! (TAPID 0x%8.8x)", __tap_ud__); if((CallTraceEnabled || Magic) && Result) { memset(Spaces, ' ', CallLevel < CTSTACKSIZE ? CallLevel << 1 : 100); Spaces[CallLevel < CTSTACKSIZE ? CallLevel << 1 : 100] = '\0'; StrToISOAlloc(Result, &ISOText); if(ISOText && *ISOText) TAP_PrintNet("%s = %s\n", Spaces, ISOText); TAP_MemFree(ISOText); } if(Magic && *Magic != DEFAULTMAGIC) { TAP_PrintNet("%sINVALID MAGIC!\n", Spaces); *Magic = DEFAULTMAGIC; } CallTraceDoNotReenter = FALSE; }