int TAP_Main(void) { char* path = "fileTest.txt"; char line[512]; UFILE *fp; TYPE_File *tf; printf("Starting file tester...\r\n"); PrintMem(); initFile(_INFO); PrintMem(); if (fp = fopen(path, "w")) { if (fputs("This is a test message1\n", fp) == EOF) ShowError(); //TAP_Print("1. File is %d bytes\r\n", TAP_Hdd_Flen(fp->fd)); if (fputs("This is a test message2\n", fp) == EOF) ShowError(); //TAP_Print("2. File is %d bytes\r\n", TAP_Hdd_Flen(fp->fd)); fclose(fp); } PrintMem(); tf = TAP_Hdd_Fopen("fileTest.txt"); TAP_Print("re-opened file is %d bytes\r\n", TAP_Hdd_Flen(tf)); TAP_Hdd_Fclose(tf); printf("Ending file tester...\r\n"); return 0; }
void openLogfile() { if (logFD != NULL) { TAP_Print("openLogfile: attempting to open file that's already open\r\n"); return; } logFD = TAP_Hdd_Fopen((char *)LOGFILENAME); if (logFD == NULL) { //TAP_Print("File doesn't exist. Creating log file...\r\n"); TAP_Hdd_Create((char *)LOGFILENAME, ATTR_NORMAL); logFD = TAP_Hdd_Fopen((char *)LOGFILENAME); //write the header stuff identifying this machine/firmware logByteCount = sizeof logByteCount; //TAP_Hdd_Fwrite((void *)logByteCount, logByteCount, 1, logFD); TAP_Hdd_Fwrite((void *)"4 ", logByteCount, 1, logFD); //TAP_Print("File marker written...\r\n"); } else { // goto the end of the file //TAP_Hdd_Fseek(logFD, 0, SEEK_END); } }
// // Write a string to the logfile. // void appendToLogfile(const char* text, int logLevel) { if (logLevel > LOGLEVEL) return; TAP_Print("%s\r\n",text); TAP_Delay(0); }
// Replace a single instruction with another instruction dword HackFirmware( dword* address, dword value ) { if ( (dword)address < 0x80000000 || (dword)address > 0x83ffffff ) { TAP_Print( "HackFirmware address %08X out of range.\n", address ); return; } #ifdef DEBUG TAP_Print( "%d: %08X changed from %08X to %08X\n", hackCount, address, *address, value ); #endif firmwareHacks[hackCount].address = address; firmwareHacks[hackCount].oldValue = *address; ++hackCount; *address = value; return firmwareHacks[hackCount].oldValue; }
//---------------------------------------------------------------------------- // This function cleans up and closes the TAP bool TSRCommanderExitTAP() { #ifdef DEBUG TAP_Print("Exiting DescriptionExtender\n"); #endif UndoFirmwareHacks(); return TRUE; }
dword TAP_EventHandler( word event, dword param1, dword param2 ) { if (event != EVT_KEY) return param1; TAP_Exit(); TAP_Print("Exiting Skeleton tap\n" ); return 0; }
byte HDD_Smart_ExecuteOfflineImmediate (byte TestMode) { int Ret; Ret = SendHDDCommand (0xD4, 0, TestMode, 0x4F, 0xC2, 0x00, 0xB0); #ifdef DEBUG_FIREBIRDLIB if (Ret != 0) TAP_Print ("FireBirdLib: HDDSmartExecuteOfflineImmediates: Ret=%d\r\n", Ret); #endif return *HDD_pLBAHigh; }
int HDD_AAM_Disable (void) { int Ret; Ret = SendHDDCommand (0xC2, 0, 0, 0, 0, 0xA0, 0xEF); if (Ret != 0) { #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: HDDDisableAAM: Ret=%d\r\n", Ret); #endif //Send a "AAM Maximum Performance" to circumvent devices, which do not implement the "Disable AAM" command Ret=SendHDDCommand (0x42, 0xFE, 0, 0, 0, 0xA0, 0xEF); #ifdef DEBUG_FIREBIRDLIB if (Ret != 0) TAP_Print ("FireBirdLib: HDDAAMDisable: Ret=%d\r\n", Ret); #endif } return Ret; }
// Undo hacks void UndoFirmwareHacks() { while ( hackCount > 0 ) { --hackCount; #ifdef DEBUG TAP_Print( "%d: %08X set to %08X\n", hackCount, firmwareHacks[hackCount].address, firmwareHacks[hackCount].oldValue ); #endif *firmwareHacks[hackCount].address = firmwareHacks[hackCount].oldValue; } }
/* fputs: put string s on file f */ int fputs(char *s, UFILE *iop) { int c; TAP_Print("fputs: Adding string '%s'\r\n", s); while (c = *s++) putc(c, iop); return ferror(iop) ? EOF : 0; }
void logOutput( int ltype, char *fmt, ... ) { char buff[512]; va_list args; switch (loggingLevel) { case _logNone: return; break; case _logSome: //log F(atal) only if (LOG_FATAL & ltype) break; return; break; case _logMore: //log F(atal) and E(rror) if ((LOG_FATAL & ltype) || (LOG_ERROR & ltype)) break; return; break; case _logAll: if ((LOG_FATAL & ltype) || (LOG_ERROR & ltype) || (LOG_WARNING & ltype) || (LOG_INFO & ltype)) break; return; break; default: // unknown TAP_Print("Invalid log type: %d\r\n", ltype); return; break; } va_start(args, fmt); vsprintf(buff, fmt, args); //magic happens here va_end(args); appendToLogfile(buff); strcat(buff,"\n"); TAP_Print(buff); return; }
//--------------------------------------- FlashFindEndOfServiceTableAddress -------------------------------- // dword FlashFindEndOfServiceTableAddress (bool TVService) { TYPE_Service *TvSvc; if (!LibInitialized) InitTAPex (); if (!LibInitialized || (FlashOffset == 0)) return 0; if (TVService)(dword) TvSvc = FlashBlockOffset [TVServices] + 4; else (dword) TvSvc = FlashBlockOffset [RadioServices] + 4; while (TvSvc->TunerNum != 0) TvSvc++; #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: FindEndOfServiceTable @ 0x%8.8x\n", (dword) TvSvc); #endif return (dword) TvSvc; }
word GetOSDRegionWidth (word Region) { tOSDMapInfo *OSDMapInfo; OSDMapInfo = (tOSDMapInfo*) GetOSDMapAddress(); #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: %d/%d %dx%d @%8.8x %2.2x %2.2x %2.2x %2.2x\n", OSDMapInfo [Region].x, OSDMapInfo [Region].y, OSDMapInfo [Region].Width, OSDMapInfo [Region].Height, OSDMapInfo [Region].pMemoryOSD, OSDMapInfo [Region].Flags [0], OSDMapInfo [Region].Flags [1], OSDMapInfo [Region].Flags [2], OSDMapInfo [Region].Flags [3]); #endif return OSDMapInfo[Region].Width; }
int HDD_Smart_ReturnStatus (void) { int Ret; Ret = SendHDDCommand (0xDA, 0, 0, 0x4F, 0xC2, 0x00, 0xB0); if (Ret != 0) { //If the ERR flag in the status register has been set, //the SMART feature has been disabled. #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: HDDSmartReturnStatus: Ret=%d\r\n", Ret); #endif return 19; } if (*HDD_pLBAMid == 0x4F) return 0; else return 20; }
Tapplication::Tapplication() : m_screenOffsetX(0), m_screenOffsetY(0), m_isClosing(false), m_reshowUIKey(0) { #ifdef DEBUG if ( tap != 0 ) TAP_Print( "Tapplication already exists\n" ); #endif m_pTaskManager = new TaskManager(); pageCount = 0; screenRgn = (word)TAP_Osd_Create( 0, 0, 720, 576, 0, FALSE ); m_activeDialog = NULL; }
// Create a code wrapper based on TAP_GetTime. The function allocates a buffer and copies // TAP_GetTime into it except for the actual call of the getTime() firmware function. // The address of getTime() is replaced with the provided address. // The wrapped function call supports up to 4 parameters and returns a short value. // Parameters: // functionAddress - address of the FW function to be wrapped // Returns: // Address of the new wrapper dword* CreateAPIWrapper( dword functionAddress ) { int i; // TAP_GetTime provides a template for wrapper code. The only thing to be // changed is the address of the wrapped function. dword *src = (dword*)TAP_GetTime; dword *buffer; int bufferSize = 0; // find the return statement while ( src[bufferSize] != JR_CMD ) { ++bufferSize; } // the buffer should include the return statement and the command following // the return statement bufferSize += 2; // allocate memory buffer = malloc( sizeof(dword) * bufferSize ); if ( buffer == NULL ) { TAP_Print( "malloc failed\n" ); return NULL; } for ( i = 0; i < bufferSize; ++i, ++src ) { if ( (*src & JAL_MASK) == JAL_CMD ) { // this is the wrapped call to the actual firmware implementation // replace it with the call to the provided address buffer[i] = JAL(functionAddress); } else { buffer[i] = *src; } } return buffer; }
void CallTraceComment(char *Comment) { char Spaces[101]; byte *ISOText; if(Comment) { if(!CallTraceInitialized) CallTraceInit(); Spaces[0] = '\0'; if(CallTraceEnabled) { memset(Spaces, ' ', CallLevel < 50 ? CallLevel << 1 : 100); Spaces[CallLevel < CTSTACKSIZE ? CallLevel << 1 : 100] = '\0'; StrToISOAlloc(Comment, &ISOText); if(ISOText && *ISOText) TAP_Print("%s# %s\n", Spaces, ISOText); TAP_MemFree(ISOText); } } }
//----------- TAP_EventHandler ------------------------------------------ // dword TAP_EventHandler (word event, dword param1, dword param2) { dword CallerID, ServiceID, ParamBlockVersion; tTAPCOM_DemoServer_Parameter *ParamBlock = NULL; TAPCOM_Channel Channel = 0; static dword ServerReservedByID = 0; (void) param2; if (event == EVT_TAPCOM) { Channel = TAPCOM_GetChannel (param1, &CallerID, &ServiceID, &ParamBlockVersion, (void*) &ParamBlock); if (Channel != 0) { switch (ServiceID) { case TAPCOM_DemoServer_ReserveServer: { if (ServerReservedByID) { TAP_Print (PROGRAM_NAME " : Server is already reserved by 0x%8.8x\n", ServerReservedByID); TAPCOM_Reject (Channel); } else { TAP_Print (PROGRAM_NAME " : Server sucessfully reserved by 0x%8.8x\n", CallerID); ServerReservedByID = CallerID; TAPCOM_Finish (Channel, TAPCOM_DemoServer_ResultOK); } break; } case TAPCOM_DemoServer_ExecAdd: { if (!ServerReservedByID || (CallerID != ServerReservedByID)) { TAP_Print (PROGRAM_NAME " : Server hasn't been reserved by 0x%8.8x\n", CallerID); TAPCOM_Reject (Channel); } else { if (ParamBlockVersion != TAPCOM_DemoServer_ParameterVersion) { TAP_Print (PROGRAM_NAME " : Unexpected parameter version\n"); TAPCOM_Finish (Channel, TAPCOM_DemoServer_ResultInvalidParameter); } else if (ParamBlock == NULL) { TAP_Print (PROGRAM_NAME " : Parameters are needed to complete the command\n"); TAPCOM_Finish (Channel, TAPCOM_DemoServer_ResultNoParameter); } else { ParamBlock->Result = ParamBlock->Number1 + ParamBlock->Number2; TAP_Print (PROGRAM_NAME " : Calculation done, result = %d\n", ParamBlock->Result); TAPCOM_Finish (Channel, TAPCOM_DemoServer_ResultOK); } } break; } case TAPCOM_DemoServer_ReleaseServer: { if (CallerID == ServerReservedByID) { TAP_Print (PROGRAM_NAME " : Server sucessfully released by 0x%8.8x\n", CallerID); ServerReservedByID = 0; TAPCOM_Finish (Channel, TAPCOM_DemoServer_ResultOK); break; } else { TAP_Print (PROGRAM_NAME " : Server is reserved by different client 0x%8.8x\n", ServerReservedByID); TAPCOM_Reject (Channel); } break; } default: { TAP_Print (PROGRAM_NAME " : Client 0x%8.8x is trying to access the unknown service 0x%8.8x\n", CallerID, ServiceID); TAPCOM_Reject (Channel); break; } } } } if ((event == EVT_IDLE) && ServerReservedByID) { if (!HDD_TAP_isRunning (ServerReservedByID)) { TAP_Print (PROGRAM_NAME " : The client 0x%8.8x has been terminated while I'm reserved for that client. Closing channel\n", ServerReservedByID); ServerReservedByID = 0; TAPCOM_Reject (Channel); } } if (event == EVT_KEY) { switch (param1) { case RKEY_Uhf: { TAP_Print (PROGRAM_NAME " : Exiting\n"); TAP_Exit(); param1 = 0; break; } } } return param1; }
void LogEntry(char *FileName, char *ProgramName, bool Console, eTimeStampFormat TimeStampFormat, char *Text) { TRACEENTER(); int f; char TimeResult[40]; char CRLF[] = {'\r', '\n'}; byte Sec; byte *ISOText; char AbsFileName[FBLIB_DIR_SIZE]; struct utimbuf times; if(!Text) { TRACEEXIT(); return; } TimeFormat(Now(&Sec), Sec, TimeStampFormat, TimeResult); if(TimeResult[0]) strcat(TimeResult, " "); if(FileName && FileName[0]) { ConvertPathType(FileName, AbsFileName, PF_FullLinuxPath); f = open(AbsFileName, O_WRONLY | O_CREAT | O_APPEND); if(f >= 0) { write(f, TimeResult, strlen(TimeResult)); if(Text && Text[0]) write(f, Text, strlen(Text)); write(f, CRLF, 2); close(f); //As the log would receive the Linux time stamp (01.01.2000), adjust to the PVR's time times.actime = PvrTimeToLinux(Now(NULL)); times.modtime = times.actime; utime(AbsFileName, ×); } } if(Console) { if(TimeStampFormat != TIMESTAMP_NONE) TAP_Print(TimeResult); if(ProgramName && ProgramName[0]) TAP_Print("%s: ", ProgramName); if(isUTFToppy()) { if(strlen(Text) < 510) { TAP_Print("%s", Text); } else { char *p = Text; while(*p) { int l; char q; l = strlen(p); q = p[l]; p[l] = '\0'; TAP_Print("%s", p); p[l] = q; p += l; } } TAP_Print("\n"); } else { //Max length is 512. If above, a buffer overflow may occur StrToISOAlloc(Text, &ISOText); if(ISOText && ISOText[0]) { if(strlen(ISOText) < 510) { TAP_Print("%s", ISOText); } else { char *p = ISOText; while(*p) { int l; char q; l = strlen(p); if(l > 510) l = 510; q = p[l]; p[l] = '\0'; TAP_Print("%s", p); p[l] = q; p += l; } } } TAP_Print("\n"); TAP_MemFree(ISOText); } } TRACEEXIT(); }
//--------------------------------------- HDD_DecodeRECHeader -------------------------------- // SYSTEM_TYPE HDD_DecodeRECHeader (char *Buffer, tRECHeaderInfo *RECHeaderInfo) { dword Frq, SR; byte Modulation, Polarization, BandWidth, LPHPStream; dword p; dword sPoints = 0, tPoints = 0, cPoints = 0; word v1, v2; memset (RECHeaderInfo, 0, sizeof (tRECHeaderInfo)); RECHeaderInfo->HeaderType = ST_UNKNOWN; if (!LibInitialized) InitTAPex (); if (!LibInitialized) return RECHeaderInfo->HeaderType; //Is this a REC header? p = 0; RECHeaderInfo->HeaderMagic = *(dword*)(&Buffer [p + 0]); if (RECHeaderInfo->HeaderMagic != 0x54467263) return RECHeaderInfo->HeaderType; //Header block RECHeaderInfo->HeaderVersion = *( word*)(&Buffer [p + 4]); memcpy (RECHeaderInfo->HeaderReserved1, &Buffer [p + 6], 2); RECHeaderInfo->HeaderDuration = *( word*)(&Buffer [p + 8]); RECHeaderInfo->HeaderSvcNumber = *( word*)(&Buffer [p + 10]); RECHeaderInfo->HeaderSvcType = *( word*)(&Buffer [p + 12]); p += 14; //Service Info block RECHeaderInfo->SISatIndex = *( byte*)(&Buffer [p + 0]); RECHeaderInfo->SIReserved1 = *( byte*)(&Buffer [p + 1]); RECHeaderInfo->SITPIdx = *( word*)(&Buffer [p + 2]) >> 6; RECHeaderInfo->SITunerNum = (*( word*)(&Buffer [p + 2]) >> 4) & 3; RECHeaderInfo->SIDelFlag = (*( word*)(&Buffer [p + 2]) >> 3) & 1; RECHeaderInfo->SICASFlag = (*( word*)(&Buffer [p + 2]) >> 2) & 1; RECHeaderInfo->SILockFlag = (*( word*)(&Buffer [p + 2]) >> 1) & 1; RECHeaderInfo->SISkipFlag = (*( word*)(&Buffer [p + 2]) ) & 1; RECHeaderInfo->SIServiceID = *( word*)(&Buffer [p + 4]); RECHeaderInfo->SIPMTPID = *( word*)(&Buffer [p + 6]); RECHeaderInfo->SIPCRPID = *( word*)(&Buffer [p + 8]); RECHeaderInfo->SIVideoPID = *( word*)(&Buffer [p + 10]); RECHeaderInfo->SIAudioPID = *( word*)(&Buffer [p + 12]); if (RECHeaderInfo->HeaderVersion == 0x5010) { memcpy (RECHeaderInfo->SISvcName, &Buffer [p + 14], 28); p += 42; } else { memcpy (RECHeaderInfo->SISvcName, &Buffer [p + 14], 24); p += 38; } //Use the following rules for the type decision (thx to jkIT) //Count 1 point for every matching rule //for dvb-s: // Transponder_Info.Polarity & 0x6F == 0 ? // Transponder_Info.Symbol_Rate in [2000...30000] ? // Transponder_Info.Frequency in [10700...12800] ? //for dvb-t // Transponder_Info.Bandwidth in [6..8] ? // Transponder_Info.Frequency in [174000...230000] or [470000...862000] ? // Transponder_Info.LP_HP_Stream & 0xFE == 0 ? //for dvb-c // Transponder_Info.Frequency in [47000...862000] ? // Transponder_Info.Symbol_Rate in [2000...30000] ? // Transponder_Info.Modulation <= 4 ? //Count cable points Frq = *(dword*)(&Buffer [p + 0]); SR = *(word*)(&Buffer [p + 4]); Modulation = *(byte *) (&Buffer [p + 10]); if ((Frq >= 47000) && (Frq <= 862000)) cPoints++; if ((SR >= 2000) && (SR <= 30000)) cPoints++; if (Modulation <= 4) cPoints++; //Count sat points Frq = *(dword*)(&Buffer [p + 4]); SR = *(word*)(&Buffer [p + 8]); Polarization = *(byte *) (&Buffer [p + 1]); if ((Frq >= 10700) && (Frq <= 12800)) sPoints++; if ((SR >= 2000) && (SR <= 30000)) sPoints++; if ((Polarization & 0x6F) == 0) sPoints++; //Count terrestrial points BandWidth = *(byte *) (&Buffer [p + 2]); LPHPStream = *(byte *) (&Buffer [p + 10]); if (((Frq >= 174000) && (Frq <= 230000)) || ((Frq >= 470000) && (Frq <= 862000))) tPoints++; if ((BandWidth >= 6) && (BandWidth <= 8)) tPoints++; if ((LPHPStream & 0xFE) == 0) tPoints++; //If one system has 3 points and all other have less than 3, use that DVB system if ((sPoints == 3) && (tPoints < 3) && (cPoints < 3)) RECHeaderInfo->HeaderType = ST_DVBS; if ((sPoints < 3) && (tPoints == 3) && (cPoints < 3)) { //Try to find out if this is a TF5700 Header: compare the date v1 = *(word*)(&Buffer [84]); // StartMJD v2 = *(word*)(&Buffer [88]); // EndMJD RECHeaderInfo->HeaderType = (v1 && v2 && (v1 == v2 || v1 + 1 == v2) ? ST_DVBT5700 : ST_DVBT); } if ((sPoints < 3) && (tPoints < 3) && (cPoints == 3)) RECHeaderInfo->HeaderType = ST_DVBC; #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: DecodeRCEHeader: DVBs=%d, DVBt=%d, DVBc=%d\n", sPoints, tPoints, cPoints); #endif //Transponder block switch (RECHeaderInfo->HeaderType) { case ST_DVBS: { RECHeaderInfo->TPSatIndex = *( byte*)(&Buffer [p + 0]); RECHeaderInfo->TPPolarization = *( byte*)(&Buffer [p + 1]) >> 7; RECHeaderInfo->TPMode = (*( byte*)(&Buffer [p + 1]) >> 4) & 7; RECHeaderInfo->TPReserved3 = (*( byte*)(&Buffer [p + 1]) ) & 15; memcpy (RECHeaderInfo->TPReserved1, &Buffer [p + 2], 2); RECHeaderInfo->TPFrequency = *(dword*)(&Buffer [p + 4]); RECHeaderInfo->TPSymbolRate = *( word*)(&Buffer [p + 8]); RECHeaderInfo->TPTSID = *( word*)(&Buffer [p + 10]); memcpy (RECHeaderInfo->TPReserved2, &Buffer [p + 12], 2); RECHeaderInfo->TPNetworkID = *( word*)(&Buffer [p + 14]); p += 16; break; } case ST_DVBT: case ST_DVBT5700: { RECHeaderInfo->TPChannelNumber = *( word*)(&Buffer [p + 0]); RECHeaderInfo->TPBandwidth = *( byte*)(&Buffer [p + 2]); RECHeaderInfo->TPReserved3 = *( byte*)(&Buffer [p + 3]); RECHeaderInfo->TPFrequency = *(dword*)(&Buffer [p + 4]); RECHeaderInfo->TPTSID = *( word*)(&Buffer [p + 8]); RECHeaderInfo->TPLPHPStream = *( byte*)(&Buffer [p + 10]); RECHeaderInfo->TPReserved4 = *( byte*)(&Buffer [p + 11]); RECHeaderInfo->TPNetworkID = *( word*)(&Buffer [p + 12]); memcpy (RECHeaderInfo->TPUnknown1, &Buffer [p + 14], 2); p += 16; if (RECHeaderInfo->HeaderType == ST_DVBT5700) { memcpy(RECHeaderInfo->TPUnknown2, &Buffer[p + 16], 8); p += 8; } break; } case ST_DVBC: { RECHeaderInfo->TPFrequency = *(dword*)(&Buffer [p + 0]); RECHeaderInfo->TPSymbolRate = *( word*)(&Buffer [p + 4]); RECHeaderInfo->TPTSID = *( word*)(&Buffer [p + 6]); RECHeaderInfo->TPNetworkID = *( word*)(&Buffer [p + 8]); RECHeaderInfo->TPModulation = *( byte*)(&Buffer [p + 10]); RECHeaderInfo->TPReserved5 = *( byte*)(&Buffer [p + 11]); p += 12; break; } default: { p += 16; break; } } //Event block memcpy (RECHeaderInfo->EventUnknown2, &Buffer [p], 2); RECHeaderInfo->EventDurationHour = *( byte*)(&Buffer [p + 2]); RECHeaderInfo->EventDurationMin = *( byte*)(&Buffer [p + 3]); RECHeaderInfo->EventEventID = *(dword*)(&Buffer [p + 4]); memcpy (&RECHeaderInfo->EventStartTime, &Buffer [p + 8], 4); memcpy (&RECHeaderInfo->EventEndTime , &Buffer [p + 12], 4); RECHeaderInfo->EventRunningStatus = *( byte*)(&Buffer [p + 16]); RECHeaderInfo->EventTextLength = *( byte*)(&Buffer [p + 17]); RECHeaderInfo->EventParentalRate = *( byte*)(&Buffer [p + 18]); memcpy (RECHeaderInfo->EventEventName, &Buffer [p + 19], RECHeaderInfo->EventTextLength); memcpy (RECHeaderInfo->EventEventDescription, &Buffer [p + 19 + RECHeaderInfo->EventTextLength], 257 - RECHeaderInfo->EventTextLength); memcpy (RECHeaderInfo->EventUnknown1, &Buffer [p + 276], 18); p += 294; //Extended Event block RECHeaderInfo->ExtEventTextLength = *( word*)(&Buffer [p + 0]); RECHeaderInfo->ExtEventEventID = *(dword*)(&Buffer [p + 2]); memcpy (RECHeaderInfo->ExtEventText, &Buffer [p + 6], 1024); p += 1030; //Crypt Flag block memcpy (RECHeaderInfo->CryptReserved1, &Buffer [p], 4); RECHeaderInfo->CryptFlag = *( byte*)(&Buffer [p + 4]); memcpy (RECHeaderInfo->CryptReserved2, &Buffer [p + 5], 3); p += 8; //Bookmark block memcpy (RECHeaderInfo->Bookmark, &Buffer [p], 64 * sizeof (dword)); p += 256; RECHeaderInfo->Resume = *( dword*)(&Buffer [p + 0]); return RECHeaderInfo->HeaderType; }
//------------ // void ScreenConfigKeyHandler(dword key) { int i, oldEditLine, tempPIP_X; switch ( key ) { case RKEY_ChDown : // Move Down switch (window) { case 1: if (SCREEN_Y + SCREEN_H < (EVENT_Y-1)) { SCREEN_Y++; ShowPictureWindows(window); } break; case 2: if ((PIP_SCRY + PIP_SCRH < OSD_MAX_Y) && (PIP_SCRY < OSD_MAX_Y - 90)) { PIP_SCRY++; ShowPictureWindows(window); } break; case 3: if (LOGO_WINDOW_H < EVENT_Y) { BASE_Y++; ShowPictureWindows(window); } break; case 4: if ((EVENT_Y+EVENT_H < OSD_MAX_Y) && (EVENT_Y < PIP_SCRY)) { EVENT_Y++; ShowPictureWindows(window); } break; case 5: if (CLOCK_Y + CLOCK_H < OSD_MAX_Y) { CLOCK_Y++; ShowPictureWindows(window); } break; case 6: if (GDE_SCREEN_Y + GDE_SCREEN_H < (EVENT_Y-1)) { GDE_SCREEN_Y++; ShowPictureWindows(window); } break; case 7: if (OVERSCAN_Y + OVERSCAN_H < (OSD_MAX_Y-1)) { OVERSCAN_Y++; ShowPictureWindows(window); } break; } break; case RKEY_ChUp : // Move Up switch (window) { case 1: if (SCREEN_Y > 0) { SCREEN_Y--; ShowPictureWindows(window); } break; case 2: if (PIP_SCRY > PIP_Y_MIN) { PIP_SCRY--; ShowPictureWindows(window); } break; case 3: if (BASE_Y > HEADER_H) { BASE_Y--; ShowPictureWindows(window); } break; case 4: if ((EVENT_Y > SCREEN_Y+SCREEN_H) && (EVENT_Y > LOGO_WINDOW_H)) { EVENT_Y--; ShowPictureWindows(window); } break; case 5: if (CLOCK_Y > 0) { CLOCK_Y--; ShowPictureWindows(window); } break; case 6: if (GDE_SCREEN_Y > 0) { GDE_SCREEN_Y--; ShowPictureWindows(window); } break; case 7: if (OVERSCAN_Y > 0) { OVERSCAN_Y--; ShowPictureWindows(window); } break; } break; case RKEY_VolUp : // Move Right switch (window) { case 1: if (SCREEN_X + SCREEN_W < SCREEN_X_MAX) { SCREEN_X++; ShowPictureWindows(window); } break; case 2: if (PIP_SCRX + PIP_SCRW < EVENT_X) { PIP_SCRX++; ShowPictureWindows(window); } break; case 3: if (LOGO_WINDOW_W < SCREEN_X) { BASE_X++; ShowPictureWindows(window); } break; case 4: if (EVENT_X + EVENT_W < OSD_MAX_X) { EVENT_X++; ShowPictureWindows(window); } break; case 5: if (CLOCK_X < OSD_MAX_X) { CLOCK_X++; ShowPictureWindows(window); } break; case 6: if (GDE_SCREEN_X + GDE_SCREEN_W < SCREEN_X_MAX) { GDE_SCREEN_X++; ShowPictureWindows(window); } break; case 7: if (OVERSCAN_X + OVERSCAN_W < (OSD_MAX_X-1)) { OVERSCAN_X++; ShowPictureWindows(window); } break; } break; case RKEY_VolDown : // Move Left switch (window) { case 1: if (SCREEN_X > SCREEN_X_MIN) { SCREEN_X--; ShowPictureWindows(window); } break; case 2: if (PIP_SCRX > 0 ) { PIP_SCRX--; ShowPictureWindows(window); } break; case 3: if (BASE_X-10 > 0) { BASE_X--; ShowPictureWindows(window); } break; case 4: if ((EVENT_X > PIP_SCRX + PIP_SCRW) && (EVENT_X > EVENT_X_MIN)) { EVENT_X--; ShowPictureWindows(window); } break; case 5: if (CLOCK_X - CLOCK_W > 0 ) { CLOCK_X--; ShowPictureWindows(window); } break; case 6: if (GDE_SCREEN_X > (LOGO_WINDOW_W + GDE_W)-20 ) { GDE_SCREEN_X--; ShowPictureWindows(window); } break; case 7: if (OVERSCAN_X > 0) { OVERSCAN_X--; ShowPictureWindows(window); } break; } break; case RKEY_Forward: // Increase Window size switch (window) { case 1: if ((SCREEN_Y > SCREEN_Y_MIN) && ((SCREEN_X + SCREEN_W + (SCREEN_RATIO/1000) + 1) < SCREEN_X_MAX ) ) { SCREEN_H++; SCREEN_W = (SCREEN_RATIO * SCREEN_H) / 1000; SCREEN_Y--; ShowPictureWindows(window); } break; case 2: if ((PIP_SCRH + PIP_SCRY < OSD_MAX_Y) && ((PIP_SCRX - (SCREEN_RATIO/1000) - 1) > 0 ) ) { tempPIP_X = PIP_SCRX + PIP_SCRW; // temp store of current right-hand x-coord. PIP_SCRH++; PIP_SCRW = (SCREEN_RATIO * PIP_SCRH) / 1000; PIP_SCRX = tempPIP_X - PIP_SCRW; // Keep the window still on right-handside and grow to the left. ShowPictureWindows(window); } break; case 3: if (GDE_W < GDE_W_MAX) { GDE_W++; ShowPictureWindows(window); } break; case 4: if ((EVENT_H < EVENT_H_MAX) && ( EVENT_Y + EVENT_H < OSD_MAX_Y)) { EVENT_H++; ShowPictureWindows(window); } break; case 6: if ((GDE_SCREEN_Y > SCREEN_Y_MIN) && ((GDE_SCREEN_X + GDE_SCREEN_W + (SCREEN_RATIO/1000) + 1) < SCREEN_X_MAX ) ) { GDE_SCREEN_H++; GDE_SCREEN_W = (SCREEN_RATIO * GDE_SCREEN_H) / 1000; GDE_SCREEN_Y--; ShowPictureWindows(window); } break; case 7: switch (axis) { case 0: // Top/Bottom if (OVERSCAN_H < (OSD_MAX_Y - OVERSCAN_Y) ) { OVERSCAN_H++; ShowPictureWindows(window); } break; case 1: // Left/Right if (OVERSCAN_W < (OSD_MAX_X - OVERSCAN_X)) { OVERSCAN_W++; ShowPictureWindows(window); } break; } /* if ((OVERSCAN_Y + OVERSCAN_H < OSD_MAX_Y) && ((OVERSCAN_X + OVERSCAN_W + (SCREEN_RATIO/1000) + 1) < OSD_MAX_X ) ) { OVERSCAN_H++; OVERSCAN_W = (WINDOW_RATIO * OVERSCAN_H) / 1000; ShowPictureWindows(window); } break; */ } break; case RKEY_Rewind: // Decrease Window size. switch (window) { case 1: if ((SCREEN_Y < (EVENT_Y-1)) && (SCREEN_H > 100)) { SCREEN_H--; SCREEN_W = (SCREEN_RATIO * SCREEN_H) / 1000; SCREEN_Y++; TAP_Print("X=%d Y=%d W=%d H=%d \r\n",SCREEN_X,SCREEN_Y,SCREEN_W,SCREEN_H); ShowPictureWindows(window); } break; case 2: if (PIP_SCRH > 100) { tempPIP_X = PIP_SCRX + PIP_SCRW; // temp store of current right-hand x-coord. PIP_SCRH--; PIP_SCRW = (SCREEN_RATIO * PIP_SCRH) / 1000; PIP_SCRX = tempPIP_X - PIP_SCRW; // Keep the window still on right-handside and grow to the left. ShowPictureWindows(window); } break; case 3: if (GDE_W > GDE_W_MIN) { GDE_W--; ShowPictureWindows(window); } break; case 4: if (EVENT_H > EVENT_H_MIN) { EVENT_H--; ShowPictureWindows(window); } break; case 6: if (GDE_SCREEN_Y < (EVENT_Y-1)) { GDE_SCREEN_H--; GDE_SCREEN_W = (SCREEN_RATIO * GDE_SCREEN_H) / 1000; GDE_SCREEN_Y++; ShowPictureWindows(window); } break; case 7: switch (axis) { case 0: // Top/Bottom if (OVERSCAN_H > (GDE_H + EVENT_H) ) { OVERSCAN_H--; ShowPictureWindows(window); } break; case 1: // Left/Right if (OVERSCAN_W > (10 + LOGO_W + 10 + GDE_W + EVENT_W)) { OVERSCAN_W--; ShowPictureWindows(window); } break; } /* if (OVERSCAN_H > (GDE_H + EVENT_H) ) { OVERSCAN_H--; OVERSCAN_W = (WINDOW_RATIO * OVERSCAN_H) / 1000; ShowPictureWindows(window); } break; */ } break; case RKEY_Ok : if (window==OVERSCAN_WINDOW) // Change the axis that we will change. { axis = !axis; DisplayScreenConfigWindow(window); ShowPictureWindows(window); break; } if (window < NUMBER_OF_WINDOWS) window++; else window=1; DisplayScreenConfigWindow(window); ShowPictureWindows(window); break; case RKEY_Recall : ResetScreenConfig(); // Reload the original data DisplayScreenConfigWindow(window); ShowPictureWindows(window); break; case RKEY_Record : SaveScreenConfig(); // Save the modified config info CloseScreenConfigWindow(); // Close the config window break; case RKEY_Guide: //guideFormat = 0; // Reset the Guide Display Format to Now/Next Display Format //displayStartTime = 0; if (!guideWindowDisplayed) { ActivateGuideWindow(); LoadGuideEventInfo(currentSvcType, currentSvcNum); DisplayGuideWindow(currentSvcType, currentSvcNum); } else { CloseGuideWindow(); guideWindowDisplayed = FALSE; } ShowPictureWindows(window); break; case RKEY_Exit : ResetScreenConfig(); // Reload the original data CloseScreenConfigWindow(); // Close the config window break; default : break; } }
void DumpMemory(byte* p, dword size, int BytesPerLine) { TRACEENTER(); byte *StartAddress = p; int CollectedBytes, i; char text[200], Header[20]; char s[255]; dword Remaining; if(!p) { TAP_Print("0x00000000 NULL\n"); TRACEEXIT(); return; } s[0] = '\0'; text[0] = '\0'; CollectedBytes = 0; TAP_SPrint(Header, "%p 0x%4.4x: ", p, (dword)(p - StartAddress)); Remaining = size; while(Remaining > 0) { TAP_SPrint(&s[strlen(s)], "%2.2x ", *p); if((*p >= 0x20) && (*p <= 0x7e)) // && (*p != 0x25) TAP_SPrint(&text[strlen(text)], "%c", *p); else TAP_SPrint(&text[strlen(text)], "."); CollectedBytes++; p++; Remaining--; if(CollectedBytes >= BytesPerLine) { TAP_SPrint(&s[strlen(s)], " %s\n", text); TAP_Print(Header); TAP_Print(s); s[0] = '\0'; text[0] = '\0'; TAP_SPrint(Header, "%p 0x%4.4x: ", p, (dword)(p - StartAddress)); CollectedBytes = 0; } } if(strlen(s)) { size %= BytesPerLine; if(size) { size = BytesPerLine - size; for(i = 0; i < (int)size; i++) strcat(s, " "); } TAP_SPrint(&s[strlen(s)], " %s\n", text); TAP_Print(Header); TAP_Print(s); } TRACEEXIT(); }
void PrintMem() { dword heapSize, freeHeapSize, availHeapSize; TAP_MemInfo(&heapSize, &freeHeapSize, &availHeapSize); TAP_Print("TotalHeap: %d, FreeHeap: %d, AvailHeap: %d\n", heapSize, freeHeapSize, availHeapSize); }
int TAP_Main(void) { TAP_Print("Starting Skeleton tap\n" ); return 1; }
//--------------------------------------- FlashFindTransponderIndex -------------------------------- // int FlashFindTransponderIndex (dword SatIndex, dword NetworkID, dword TSID) { dword TrCount, i; int Ret = -1; if (!LibInitialized) InitTAPex (); if (!LibInitialized || (FlashOffset == 0)) return 0; switch (SystemType) { case ST_DVBS: { TYPE_TpInfoS *Transponder; #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: FindTransponderIndex: Sat=%d, TSID=%d ", SatIndex, TSID); #endif TrCount = *((dword *) (FlashBlockOffset [Transponders] + 4)); Transponder = (TYPE_TpInfoS *) (FlashBlockOffset [Transponders] + 4 + 4); i=-1; while (TrCount > 0) { if (Transponder->SatIdx == SatIndex) i++; if ((Transponder->SatIdx == SatIndex) && (Transponder->TSID == TSID)) break; Transponder++; TrCount--; } if (TrCount != 0) { #ifdef DEBUG_FIREBIRDLIB TAP_Print ("@ 0x%8.8x (Index %d)\n", (dword) Transponder, i); #endif Ret = i; } else { #ifdef DEBUG_FIREBIRDLIB TAP_Print ("not found\n"); #endif Ret = -1; } break; } case ST_DVBT: case ST_DVBT5700: { byte *Transponder; #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: FindTransponderIndex: NetworkID=%d, TSID=%d ", NetworkID, TSID); #endif TrCount = *((dword *) (FlashBlockOffset [Transponders] + 4)); Transponder = (byte *) (FlashBlockOffset [Transponders] + 4 + 4); i=-1; while (TrCount > 0) { i++; // fortunately, the structures are identical until NetworkID (and TSID) if ((((TYPE_TpInfoT *) Transponder)->NetworkID == NetworkID) && (((TYPE_TpInfoT *) Transponder)->TSID == TSID)) break; Transponder += (SystemType == ST_DVBT ? sizeof(TYPE_TpInfoT) : sizeof(TYPE_TpInfoT5700)); TrCount--; } if (TrCount != 0) { #ifdef DEBUG_FIREBIRDLIB TAP_Print ("@ 0x%8.8x (Index %d)\n", (dword) Transponder, i); #endif Ret = i; } else { #ifdef DEBUG_FIREBIRDLIB TAP_Print ("not found\n"); #endif Ret = -1; } break; } case ST_DVBC: { TYPE_TpInfoC *Transponder; #ifdef DEBUG_FIREBIRDLIB TAP_Print ("FireBirdLib: FindTransponderIndex: NetworkID=%d, TSID=%d ", NetworkID, TSID); #endif //2005-15-11 Mod: Run from the last entry towards the first entry. This should prevent to hit a dummy 47MHz Premiere transponder TrCount = *((dword *) (FlashBlockOffset [Transponders] + 4)); Transponder = (TYPE_TpInfoC *) (FlashBlockOffset [Transponders] + 4 + 4 + sizeof(TYPE_TpInfoC) * (TrCount -1)); while (TrCount > 0) { if ((Transponder->NetworkID == NetworkID) && (Transponder->TSID == TSID)) break; Transponder--; TrCount--; } if (TrCount != 0) { #ifdef DEBUG_FIREBIRDLIB TAP_Print ("@ 0x%8.8x (Index %d)\n", (dword) Transponder, TrCount-1); #endif Ret = (TrCount-1); } else { #ifdef DEBUG_FIREBIRDLIB TAP_Print ("not found\n"); #endif Ret = -1; } break; } case ST_UNKNOWN: { break; } } return Ret; }
dword TAP_EventHandler(word event, dword param1, dword param2) { static TAPCOM_Channel Channel = 0; TAPCOM_Status Status; tTAPCOM_DemoServer_Parameter Parameter; int ret = 0; (void) param2; if (event == EVT_KEY) { switch (param1) { case RKEY_4: { TAP_Print (PROGRAM_NAME ": Trying to reserve the server\n"); Channel = TAPCOM_OpenChannel (TAPCOM_App_DemoServer, TAPCOM_DemoServer_ReserveServer, 0, NULL); Status = TAPCOM_GetStatus (Channel); TAP_Print (PROGRAM_NAME ": Server answered with status %s\n", StatusStrings [Status]); TAPCOM_CloseChannel (Channel); param1 = 0; break; } case RKEY_5: { TAP_Print (PROGRAM_NAME ": Trying to calculate\n"); Parameter.Number1 = 1; Parameter.Number2 = 2; Channel = TAPCOM_OpenChannel (TAPCOM_App_DemoServer, TAPCOM_DemoServer_ExecAdd, TAPCOM_DemoServer_ParameterVersion, NULL); //(void*) &Parameter Status = TAPCOM_GetStatus (Channel); TAP_Print (PROGRAM_NAME ": Server answered with status %s\n", StatusStrings [Status]); if (Status == TAPCOM_Status_FINISHED) { ret = TAPCOM_GetReturnValue (Channel); TAP_Print (PROGRAM_NAME ": Return value was %d\n", ret); if (ret == TAPCOM_DemoServer_ResultOK) TAP_Print (PROGRAM_NAME ": Result = %d\n", Parameter.Result); } TAPCOM_CloseChannel (Channel); param1 = 0; break; } case RKEY_6: { TAP_Print (PROGRAM_NAME ": Trying to release the server\n"); Channel = TAPCOM_OpenChannel (TAPCOM_App_DemoServer, TAPCOM_DemoServer_ReleaseServer, 0, NULL); Status = TAPCOM_GetStatus (Channel); TAP_Print (PROGRAM_NAME ": Server answered with status %s\n", StatusStrings [Status]); TAPCOM_CloseChannel (Channel); param1 = 0; break; } case RKEY_Uhf: { TAP_Print (PROGRAM_NAME ": Exiting\n"); TAP_Exit(); param1 = 0; break; } } } return param1; }