static void skipList(bfFile bf) { int len,i; unsigned char type; bfread(bf,&type,1); len=readDword(bf); switch (type) { default: break; case 1: //byte bfseek(bf,len,SEEK_CUR); break; case 2: //short bfseek(bf,len*2,SEEK_CUR); break; case 3: //int bfseek(bf,len*4,SEEK_CUR); break; case 4: //long bfseek(bf,len*8,SEEK_CUR); break; case 5: //float bfseek(bf,len*4,SEEK_CUR); break; case 6: //double bfseek(bf,len*8,SEEK_CUR); break; case 7: //byte array for (i=0;i<len;i++) { int slen=readDword(bf); bfseek(bf,slen,SEEK_CUR); } break; case 8: //string for (i=0;i<len;i++) { int slen=readWord(bf); bfseek(bf,slen,SEEK_CUR); } break; case 9: //list for (i=0;i<len;i++) skipList(bf); break; case 10: //compound for (i=0;i<len;i++) skipCompound(bf); break; case 11: //int array for (i=0;i<len;i++) { int slen=readDword(bf); bfseek(bf,slen*4,SEEK_CUR); } break; } }
void nbtGetSpawn(bfFile bf,int *x,int *y,int *z) { int len; *x=*y=*z=0; //Data/SpawnX bfseek(bf,1,SEEK_CUR); //skip type len=readWord(bf); //name length bfseek(bf,len,SEEK_CUR); //skip name () if (nbtFindElement(bf,"Data")!=10) return; if (nbtFindElement(bf,"SpawnX")!=3) return; *x=readDword(bf); if (nbtFindElement(bf,"SpawnY")!=3) return; *y=readDword(bf); if (nbtFindElement(bf,"SpawnZ")!=3) return; *z=readDword(bf); }
QList<section> MACHFile::getSectionsList32() { QList<section> listResult; // return listResult; QList<load_command_offset> list=getLoadCommands_offset(); unsigned int nOffset=0; section record; unsigned int nNumberOfSections=0; for(int i=0; i<list.count(); i++) { if(list.at(i).cmd==LC_SEGMENT) { nOffset=list.at(i).offset; nNumberOfSections=readDword(nOffset+offsetof(segment_command,nsects),isReverse()); nOffset+=sizeof(segment_command); for(int j=0; j<nNumberOfSections; j++) { readArray(nOffset+offsetof(section,sectname),record.sectname,16); readArray(nOffset+offsetof(section,segname),record.segname,16); record.addr=readDword(nOffset+offsetof(section,addr),isReverse()); record.size=readDword(nOffset+offsetof(section,size),isReverse()); record.offset=readDword(nOffset+offsetof(section,offset),isReverse()); record.align=readDword(nOffset+offsetof(section,align),isReverse()); record.reloff=readDword(nOffset+offsetof(section,reloff),isReverse()); record.nreloc=readDword(nOffset+offsetof(section,nreloc),isReverse()); record.flags=readDword(nOffset+offsetof(section,flags),isReverse()); record.reserved1=readDword(nOffset+offsetof(section,reserved1),isReverse()); record.reserved2=readDword(nOffset+offsetof(section,reserved2),isReverse()); listResult.append(record); nOffset+=sizeof(section); } } } return listResult; }
QList<segment_command> MACHFile::getSegmentsList32() { QList<load_command_offset> list=getLoadCommands_offset(); unsigned int nOffset=0; QList<segment_command> listResult; segment_command record; for(int i=0; i<list.count(); i++) { if(list.at(i).cmd==LC_SEGMENT) { nOffset=list.at(i).offset; // uint32_t cmd; // uint32_t cmdsize; // char segname[16]; // uint32_t vmaddr; // uint32_t vmsize; // uint32_t fileoff; // uint32_t filesize; // vm_prot_t maxprot; // vm_prot_t initprot; // uint32_t nsects; // uint32_t flags; record.cmd=readDword(nOffset+offsetof(segment_command,cmd),isReverse()); record.cmdsize=readDword(nOffset+offsetof(segment_command,cmdsize),isReverse()); readArray(nOffset+offsetof(segment_command,segname),record.segname,16); record.vmaddr=readDword(nOffset+offsetof(segment_command,vmaddr),isReverse()); record.vmsize=readDword(nOffset+offsetof(segment_command,vmsize),isReverse()); record.fileoff=readDword(nOffset+offsetof(segment_command,fileoff),isReverse()); record.filesize=readDword(nOffset+offsetof(segment_command,filesize),isReverse()); record.maxprot=readDword(nOffset+offsetof(segment_command,maxprot),isReverse()); record.initprot=readDword(nOffset+offsetof(segment_command,initprot),isReverse()); record.nsects=readDword(nOffset+offsetof(segment_command,nsects),isReverse()); record.flags=readDword(nOffset+offsetof(segment_command,flags),isReverse()); listResult.append(record); } } return listResult; }
static void skipType(bfFile bf,int type) { int len; switch (type) { default: break; case 1: //byte bfseek(bf,1,SEEK_CUR); break; case 2: //short bfseek(bf,2,SEEK_CUR); break; case 3: //int bfseek(bf,4,SEEK_CUR); break; case 4: //long bfseek(bf,8,SEEK_CUR); break; case 5: //float bfseek(bf,4,SEEK_CUR); break; case 6: //double bfseek(bf,8,SEEK_CUR); break; case 7: //byte array len=readDword(bf); bfseek(bf,len,SEEK_CUR); break; case 8: //string len=readWord(bf); bfseek(bf,len,SEEK_CUR); break; case 9: //list skipList(bf); break; case 10: //compound skipCompound(bf); break; case 11: //int array len=readDword(bf); bfseek(bf,len*4,SEEK_CUR); break; } }
void nbtGetFileVersion(bfFile bf, int *version) { int len; //Data/version bfseek(bf,1,SEEK_CUR); //skip type len=readWord(bf); //name length bfseek(bf,len,SEEK_CUR); //skip name () if (nbtFindElement(bf,"Data")!=10) return; if (nbtFindElement(bf,"version")!=3) return; *version=readDword(bf); }
bool MACHFile::isMACH64() { unsigned int nMagic=readDword(0); if((nMagic==MH_MAGIC_64)||(nMagic==MH_CIGAM_64)) { return true; } return false; }
static void cx26828_set_ptz_channel(int camera_src_sel) { // // Custom settings to support PTZ // unsigned long value = 0; if ( camera_src_sel >= MAX_DECODERS ) return; readDword(&cx26828_interface[0], ALCS_VP_OMUX_C, &value); value &= 0xFFF3E08F; value |= (0xE0010 | ( (camera_src_sel * 2) << 8) ); writeDword(&cx26828_interface[0], ALCS_VP_OMUX_C, value); writeDword(&cx26828_interface[1], ALCS_VP_OMUX_C, 0x0000); readDword(&cx26828_interface[0], ALCS_VDECA_OUT_CTRL1 + (0x200 * camera_src_sel), &value); value &= 0xFFFFFCFF; //clear clk_ph_sel bits writeDword(&cx26828_interface[0], ALCS_VDECA_OUT_CTRL1 + (0x200 * camera_src_sel), value | 0x200); }
QList<segment_command_64> MACHFile::getSegmentsList64() { QList<load_command_offset> list=getLoadCommands_offset(); unsigned int nOffset=0; QList<segment_command_64> listResult; segment_command_64 record; for(int i=0; i<list.count(); i++) { if(list.at(i).cmd==LC_SEGMENT_64) { nOffset=list.at(i).offset; record.cmd=readDword(nOffset+offsetof(segment_command_64,cmd),isReverse()); record.cmdsize=readDword(nOffset+offsetof(segment_command_64,cmdsize),isReverse()); readArray(nOffset+offsetof(segment_command_64,segname),record.segname,16); record.vmaddr=readQword(nOffset+offsetof(segment_command_64,vmaddr),isReverse()); record.vmsize=readQword(nOffset+offsetof(segment_command_64,vmsize),isReverse()); record.fileoff=readQword(nOffset+offsetof(segment_command_64,fileoff),isReverse()); record.filesize=readQword(nOffset+offsetof(segment_command_64,filesize),isReverse()); record.maxprot=readDword(nOffset+offsetof(segment_command_64,maxprot),isReverse()); record.initprot=readDword(nOffset+offsetof(segment_command_64,initprot),isReverse()); record.nsects=readDword(nOffset+offsetof(segment_command_64,nsects),isReverse()); record.flags=readDword(nOffset+offsetof(segment_command_64,flags),isReverse()); listResult.append(record); } } return listResult; }
bool readHeader(NxI8 hdr1, NxI8 hdr2, NxI8 hdr3, NxI8& a, NxI8& b, NxI8& c, NxI8& d, NxU32& version, bool& mismatch, const NxStream& stream) { // Import header NxI8 h1, h2, h3, h4; readChunk(h1, h2, h3, h4, stream); if(h1!=hdr1 || h2!=hdr2 || h3!=hdr3) return false; NxI8 fileLittleEndian = h4&1; mismatch = fileLittleEndian!=littleEndian(); readChunk(a, b, c, d, stream); version = readDword(mismatch, stream); return true; }
unsigned int MACHFile::getLoadCommand_offset(unsigned int nLoadCommand) { if(isLoadCommandPresent(nLoadCommand)) { unsigned int nOffset=getMachHeaderSize(); for(int i=0; i<nLoadCommand; i++) { nOffset+=readDword(nOffset+offsetof(load_command,cmdsize),isReverse()); } return nOffset; } return 0; }
void interpretLoad(Instruction* ins) { switch(ins->argSize) { case 1: pushByte(readByte(popDword())); break; case 2: pushWord(readWord(popDword())); break; case 4: pushDword(readDword(popDword())); break; case 8: pushQword(readQword(popDword())); break; } }
bool MACHFile::isValid() { if(size()>=(int)sizeof(mach_header)) { unsigned int nMagic=readDword(0); if((nMagic==MH_MAGIC)||(nMagic==MH_CIGAM)||(nMagic==MH_MAGIC_64)||(nMagic==MH_CIGAM_64)) { return true; } } emit appendError("Invalid MACH file"); return false; }
bool MACHFile::isReverse() { if(nIsReverse==-1) { unsigned int nMagic=readDword(0); if((nMagic==MH_CIGAM)||(nMagic==MH_CIGAM_64)) { nIsReverse=1; } else { nIsReverse=0; } } return (nIsReverse==1); }
bool RTree::load(PxInputStream& stream, PxU32 meshVersion) { PX_ASSERT((mFlags & IS_DYNAMIC) == 0); PX_UNUSED(meshVersion); release(); PxI8 a, b, c, d; readChunk(a, b, c, d, stream); if(a!='R' || b!='T' || c!='R' || d!='E') return false; bool mismatch = (littleEndian() == 1); if(readDword(mismatch, stream) != mVersion) return false; readFloatBuffer(&mBoundsMin.x, 4, mismatch, stream); readFloatBuffer(&mBoundsMax.x, 4, mismatch, stream); readFloatBuffer(&mInvDiagonal.x, 4, mismatch, stream); readFloatBuffer(&mDiagonalScaler.x, 4, mismatch, stream); mPageSize = readDword(mismatch, stream); mNumRootPages = readDword(mismatch, stream); mNumLevels = readDword(mismatch, stream); mTotalNodes = readDword(mismatch, stream); mTotalPages = readDword(mismatch, stream); mUnused = readDword(mismatch, stream); mPages = static_cast<RTreePage*>( Ps::AlignedAllocator<128>().allocate(sizeof(RTreePage)*mTotalPages, __FILE__, __LINE__)); Cm::markSerializedMem(mPages, sizeof(RTreePage)*mTotalPages); for (PxU32 j = 0; j < mTotalPages; j++) { readFloatBuffer(mPages[j].minx, RTreePage::SIZE, mismatch, stream); readFloatBuffer(mPages[j].miny, RTreePage::SIZE, mismatch, stream); readFloatBuffer(mPages[j].minz, RTreePage::SIZE, mismatch, stream); readFloatBuffer(mPages[j].maxx, RTreePage::SIZE, mismatch, stream); readFloatBuffer(mPages[j].maxy, RTreePage::SIZE, mismatch, stream); readFloatBuffer(mPages[j].maxz, RTreePage::SIZE, mismatch, stream); ReadDwordBuffer(mPages[j].ptrs, RTreePage::SIZE, mismatch, stream); } return true; }
static bool objc_find_refs(RCore *core) { static const char *oldstr = NULL; RCoreObjc objc = {0}; const int objc2ClassSize = 0x28; const int objc2ClassInfoOffs = 0x20; const int objc2ClassMethSize = 0x18; const int objc2ClassBaseMethsOffs = 0x20; const int objc2ClassMethImpOffs = 0x10; objc.core = core; objc.word_size = (core->assembler->bits == 64)? 8: 4; RList *sections = r_bin_get_sections (core->bin); if (!sections) { return false; } RBinSection *s; RListIter *iter; r_list_foreach (sections, iter, s) { const char *name = s->name; if (strstr (name, "__objc_data")) { objc._data = s; } else if (strstr (name, "__objc_selrefs")) { objc._selrefs = s; } else if (strstr (name, "__objc_msgrefs")) { objc._msgrefs = s; } else if (strstr (name, "__objc_const")) { objc._const = s; } } if (!objc._const) { if (core->anal->verbose) { eprintf ("Could not find necessary objc_const section\n"); } return false; } if ((objc._selrefs || objc._msgrefs) && !(objc._data && objc._const)) { if (core->anal->verbose) { eprintf ("Could not find necessary Objective-C sections...\n"); } return false; } objc.db = sdb_new0 (); if (!objc_build_refs (&objc)) { return false; } oldstr = r_print_rowlog (core->print, "Parsing metadata in ObjC to find hidden xrefs"); r_print_rowlog_done (core->print, oldstr); int total = 0; ut64 off; for (off = 0; off < objc._data->vsize ; off += objc2ClassSize) { ut64 va = objc._data->vaddr + off; ut64 classRoVA = readQword (&objc, va + objc2ClassInfoOffs); if (isInvalid (classRoVA)) { continue; } ut64 classMethodsVA = readQword (&objc, classRoVA + objc2ClassBaseMethsOffs); if (isInvalid (classMethodsVA)) { continue; } int count = readDword (&objc, classMethodsVA + 4); classMethodsVA += 8; // advance to start of class methods array ut64 from = classMethodsVA; ut64 to = from + (objc2ClassMethSize * count); ut64 va2; for (va2 = from; va2 < to; va2 += objc2ClassMethSize) { bool isMsgRef = false; ut64 selRefVA = getRefPtr (&objc, va2, &isMsgRef); if (!selRefVA) { continue; } // # adjust pointer to beginning of message_ref struct to get xrefs if (isMsgRef) { selRefVA -= 8; } ut64 funcVA = readQword (&objc, va2 + objc2ClassMethImpOffs); RList *list = r_anal_xrefs_get (core->anal, selRefVA); RListIter *iter; RAnalRef *ref; r_list_foreach (list, iter, ref) { r_anal_xrefs_set (core->anal, ref->addr, funcVA, R_META_TYPE_CODE); total++; } } }
// // Got a lot of good ideas from pykaraoke by Kelvin Lawson ([email protected]). Thanks! // void CKaraokeLyricsTextKAR::parseMIDI() { m_midiOffset = 0; // Bytes 0-4: header unsigned int header = readDword(); // If we get MS RIFF header, skip it if ( header == 0x52494646 ) { setPos( currentPos() + 16 ); header = readDword(); } // MIDI header if ( header != 0x4D546864 ) throw( "Not a MIDI file" ); // Bytes 5-8: header length unsigned int header_length = readDword(); // Bytes 9-10: format unsigned short format = readWord(); if ( format > 2 ) throw( "Unsupported format" ); // Bytes 11-12: tracks unsigned short tracks = readWord(); // Bytes 13-14: divisious unsigned short divisions = readWord(); if ( divisions > 32768 ) throw( "Unsupported division" ); // Number of tracks is always 1 if format is 0 if ( format == 0 ) tracks = 1; // Parsed per-channel info std::vector<MidiLyrics> lyrics; std::vector<MidiTempo> tempos; std::vector<MidiChannelInfo> channels; channels.resize( tracks ); // Set up default tempo MidiTempo te; te.clocks = 0; te.tempo = 500000; tempos.push_back( te ); int preferred_lyrics_track = -1; int lastchannel = 0; int laststatus = 0; unsigned int firstNoteClocks = 1000000000; // arbitrary large value unsigned int next_line_flag = 0; // Point to first byte after MIDI header setPos( 8 + header_length ); // Parse all tracks for ( int track = 0; track < tracks; track++ ) { char tempbuf[1024]; unsigned int clocks = 0; channels[track].total_lyrics = 0; channels[track].total_lyrics_space = 0; // Skip malformed files if ( readDword() != 0x4D54726B ) throw( "Malformed track header" ); // Next track position int tracklen = readDword(); unsigned int nexttrackstart = tracklen + currentPos(); // Parse track until end of track event while ( currentPos() < nexttrackstart ) { // field length clocks += readVarLen(); unsigned char msgtype = readByte(); // // Meta event // if ( msgtype == 0xFF ) { unsigned char metatype = readByte(); unsigned int metalength = readVarLen(); if ( metatype == 3 ) { // Track title metatype if ( metalength >= sizeof( tempbuf ) ) throw( "Meta event too long" ); readData( tempbuf, metalength ); tempbuf[metalength] = '\0'; if ( !strcmp( tempbuf, "Words" ) ) preferred_lyrics_track = track; } else if ( metatype == 5 || metatype == 1 ) { // Lyrics metatype if ( metalength >= sizeof( tempbuf ) ) throw( "Meta event too long" ); readData( tempbuf, metalength ); tempbuf[metalength] = '\0'; if ( (tempbuf[0] == '@' && tempbuf[1] >= 'A' && tempbuf[1] <= 'Z') || strstr( tempbuf, " SYX" ) || strstr( tempbuf, "Track-" ) || strstr( tempbuf, "%-" ) || strstr( tempbuf, "%+" ) ) { // Keywords if ( tempbuf[0] == '@' && tempbuf[1] == 'T' && strlen( tempbuf + 2 ) > 0 ) { if ( m_songName.empty() ) m_songName = convertText( tempbuf + 2 ); else { if ( !m_artist.empty() ) m_artist += "[CR]"; m_artist += convertText( tempbuf + 2 ); } } } else { MidiLyrics lyric; lyric.clocks = clocks; lyric.track = track; lyric.flags = next_line_flag; if ( tempbuf[0] == '\\' ) { lyric.flags = CKaraokeLyricsText::LYRICS_NEW_PARAGRAPH; lyric.text = convertText( tempbuf + 1 ); } else if ( tempbuf[0] == '/' ) { lyric.flags = CKaraokeLyricsText::LYRICS_NEW_LINE; lyric.text = convertText( tempbuf + 1 ); } else if ( tempbuf[1] == '\0' && (tempbuf[0] == '\n' || tempbuf[0] == '\r' ) ) { // An empty line; do not add it but set the flag if ( next_line_flag == CKaraokeLyricsText::LYRICS_NEW_LINE ) next_line_flag = CKaraokeLyricsText::LYRICS_NEW_PARAGRAPH; else next_line_flag = CKaraokeLyricsText::LYRICS_NEW_LINE; } else { next_line_flag = (strchr(tempbuf, '\n') || strchr(tempbuf, '\r')) ? CKaraokeLyricsText::LYRICS_NEW_LINE : CKaraokeLyricsText::LYRICS_NONE; lyric.text = convertText( tempbuf ); } lyrics.push_back( lyric ); // Calculate the number of spaces in current syllable for ( unsigned int j = 0; j < metalength; j++ ) { channels[ track ].total_lyrics++; if ( tempbuf[j] == 0x20 ) channels[ track ].total_lyrics_space++; } } } else if ( metatype == 0x51 ) { // Set tempo event if ( metalength != 3 ) throw( "Invalid tempo" ); unsigned char a1 = readByte(); unsigned char a2 = readByte(); unsigned char a3 = readByte(); unsigned int tempo = (a1 << 16) | (a2 << 8) | a3; // MIDI spec says tempo could only be on the first track... // but some MIDI editors still put it on second. Shouldn't break anything anyway, but let's see //if ( track != 0 ) // throw( "Invalid tempo track" ); // Check tempo array. If previous tempo has higher clocks, abort. if ( tempos.size() > 0 && tempos[ tempos.size() - 1 ].clocks > clocks ) throw( "Invalid tempo" ); // If previous tempo has the same clocks value, override it. Otherwise add new. if ( tempos.size() > 0 && tempos[ tempos.size() - 1 ].clocks == clocks ) tempos[ tempos.size() - 1 ].tempo = tempo; else { MidiTempo mt; mt.clocks = clocks; mt.tempo = tempo; tempos.push_back( mt ); } } else { // Skip the event completely setPos( currentPos() + metalength ); } } else if ( msgtype== 0xF0 || msgtype == 0xF7 ) { // SysEx event unsigned int length = readVarLen(); setPos( currentPos() + length ); } else { // Regular MIDI event if ( msgtype & 0x80 ) { // Status byte laststatus = ( msgtype >> 4) & 0x07; lastchannel = msgtype & 0x0F; if ( laststatus != 0x07 ) msgtype = readByte() & 0x7F; } switch ( laststatus ) { case 0: // Note off readByte(); break; case 1: // Note on if ( (readByte() & 0x7F) != 0 ) // this would be in fact Note off { // Remember the time the first note played if ( firstNoteClocks > clocks ) firstNoteClocks = clocks; } break; case 2: // Key Pressure case 3: // Control change case 6: // Pitch wheel readByte(); break; case 4: // Program change case 5: // Channel pressure break; default: // case 7: Ignore this event if ( (lastchannel & 0x0F) == 2 ) // Sys Com Song Position Pntr readWord(); else if ( (lastchannel & 0x0F) == 3 ) // Sys Com Song Select(Song #) readByte(); break; } } } }
int nbtGetBlocks(bfFile bf, unsigned char *buff, unsigned char *data, unsigned char *blockLight, unsigned char *biome) { int len,nsections; int biome_save; //int found; #ifndef C99 char *thisName; #endif //Level/Blocks bfseek(bf,1,SEEK_CUR); //skip type len=readWord(bf); //name length bfseek(bf,len,SEEK_CUR); //skip name () if (nbtFindElement(bf,"Level")!=10) return 0; // For some reason, on most maps the biome info is before the Sections; // on others they're after. So, read biome data, then rewind to find Sections. // Format info at http://wiki.vg/Map_Format, though don't trust order. biome_save = *bf.offset; memset(biome, 0, 16*16); if (nbtFindElement(bf,"Biomes")!=7) return 0; { len=readDword(bf); //array length bfread(bf,biome,len); } bfseek(bf,biome_save,SEEK_SET); //rewind to start of section if (nbtFindElement(bf,"Sections")!= 9) return 0; { unsigned char type=0; bfread(bf,&type,1); if (type != 10) return 0; } memset(buff, 0, 16*16*256); memset(data, 0, 16*16*128); memset(blockLight, 0, 16*16*128); nsections=readDword(bf); while (nsections--) { unsigned char y; int save = *bf.offset; if (nbtFindElement(bf,"Y")!=1) //which section is this? return 0; bfread(bf,&y,1); bfseek(bf,save,SEEK_SET); //rewind to start of section //found=0; for (;;) { int ret=0; unsigned char type=0; bfread(bf,&type,1); if (type==0) break; len=readWord(bf); #ifdef C99 char thisName[len+1]; #else thisName=(char *)malloc(len+1); #endif bfread(bf,thisName,len); thisName[len]=0; if (strcmp(thisName,"BlockLight")==0) { //found++; ret=1; len=readDword(bf); //array length bfread(bf,blockLight+16*16*8*y,len); } if (strcmp(thisName,"Blocks")==0) { //found++; ret=1; len=readDword(bf); //array length bfread(bf,buff+16*16*16*y,len); } else if (strcmp(thisName,"Data")==0) { //found++; ret=1; len=readDword(bf); //array length bfread(bf,data+16*16*8*y,len); } #ifndef C99 free(thisName); #endif if (!ret) skipType(bf,type); } } return 1; }
unsigned int MACHFile::getHeader_ncmds() { return readDword(offsetof(mach_header,ncmds),isReverse()); }
void XMFileBase::readDwords(mp_dword* buffer,mp_sint32 count) { for (mp_sint32 i = 0; i < count; i++) *buffer++ = readDword(); }
unsigned int MACHFile::getHeader_filetype() { return readDword(offsetof(mach_header,filetype),isReverse()); }
static int queryMotionDetectionInterrupt(void) { int i = 0, j; int result = 0; int wait_event_result = -1; int wait_event_timeout_result = -1; unsigned long int_status0 = 0; init_waitqueue_head(&motion_detection_event); has_motion_detection_irq = 0; enableMotionDetectionIrq(); if (prev_motion_detected_flag == 1) { wait_event_timeout_result = wait_event_interruptible_timeout(motion_detection_event,has_motion_detection_irq != 0, HZ/2); if (wait_event_timeout_result == -ERESTARTSYS || has_motion_detection_irq == 0) //has timed-out { wait_event_timeout_result = 0; disableMotionDetectionIrq(); prev_motion_detected_flag = 0; } } else { wait_event_result = wait_event_interruptible(motion_detection_event, has_motion_detection_irq != 0); } if (wait_event_result >= 0 || wait_event_timeout_result > 0) { disableMotionDetectionIrq(); prev_motion_detected_flag = 0; switch(has_motion_detection_irq) { case 2: result &= readDword( &cx26828_interface[0], ALCS_INT_STAT0, &int_status0 ); int_status0 = (int_status0 & 0xFF00) >> 8; //Wake up by GPIO11_1 interrupt for (i = 0; i < MAX_DECODERS; i++) { if ( (_mot_det_info[0][i].enable[i] == 1) && (getBit(int_status0, i) == 1) ) { ALCS_processMotionDetect(&cx26828_interface[0], &_mot_det_info[0][i], motion_detection_standard[0][i], i); if ((_mot_det_info[0][i].mot_num_blks_detected > 0) || (_mot_det_info[0][i].no_mot_detected == 1) ) prev_motion_detected_flag = 1; } } break; case 1: result &= readDword( &cx26828_interface[1], ALCS_INT_STAT0, &int_status0 ); int_status0 = (int_status0 & 0xFF00) >> 8; //Wake up by GPIO11_0 interrupt for (i = 0; i < MAX_DECODERS; i++) { if ( (_mot_det_info[1][i].mot_det_enable == 1) && (getBit(int_status0, i) == 1) ) { ALCS_processMotionDetect(&cx26828_interface[1], &_mot_det_info[1][i], motion_detection_standard[1][i], i); if ((_mot_det_info[1][i].mot_num_blks_detected > 0) || (_mot_det_info[1][i].no_mot_detected == 1) ) prev_motion_detected_flag = 1; } } break; case 3: //Wake up by GPIO11_0 and GPIO11_1 interrupt for (i = 0; i < 2; i++) { result &= readDword( &cx26828_interface[i], ALCS_INT_STAT0, &int_status0 ); int_status0 = (int_status0 & 0xFF00) >> 8; for (j = 0; j < MAX_DECODERS; j++) { if ( (_mot_det_info[i][j].mot_det_enable == 1) && (getBit(int_status0, j) == 1) ) { ALCS_processMotionDetect(&cx26828_interface[i], &_mot_det_info[i][j], motion_detection_standard[i][j], j); if ((_mot_det_info[i][j].mot_num_blks_detected > 0) || (_mot_det_info[i][j].no_mot_detected == 1)) prev_motion_detected_flag = 1; } } } break; } }
unsigned int MACHFile::getHeader_magic() { return readDword(offsetof(mach_header,magic),isReverse()); }
unsigned int MACHFile::getSection_nreloc32(unsigned int nSection) { return readDword(getSectionHeaderOffset(nSection)+offsetof(section,nreloc),isReverse()); }
unsigned int MACHFile::getSection_flags64(unsigned int nSection) { return readDword(getSectionHeaderOffset(nSection)+offsetof(section_64,flags),isReverse()); }
unsigned int MACHFile::getSegment_flags64(unsigned int nSegment) { return readDword(getSegmentHeaderOffset(nSegment)+offsetof(segment_command_64,flags),isReverse()); }
unsigned int MACHFile::getSegment_nsects32(unsigned int nSegment) { return readDword(getSegmentHeaderOffset(nSegment)+offsetof(segment_command,nsects),isReverse()); }
unsigned int MACHFile::getSegment_initprot32(unsigned int nSegment) { return readDword(getSegmentHeaderOffset(nSegment)+offsetof(segment_command,initprot),isReverse()); }
unsigned int MACHFile::getHeader_reserved() { return readDword(offsetof(mach_header_64,reserved),isReverse()); }
unsigned int MACHFile::getLoadCommand_size(unsigned int nLoadCommand) { return readDword(getLoadCommand_offset(nLoadCommand)+offsetof(load_command,cmdsize),isReverse()); }