static void IODTGetICellCounts( IORegistryEntry * regEntry,
			    UInt32 * iCellCount, UInt32 * aCellCount)
{
    if( !GetUInt32( regEntry, gIODTInterruptCellKey, iCellCount))
        unexpected( *iCellCount = 1 );
    if( !GetUInt32( regEntry, gIODTAddressCellKey, aCellCount))
        *aCellCount = 0;
}
Example #2
0
void CGCode3DParser::M26Command()
{
	// set sd pos

	if (!GetExecutingFile() || CControl::GetInstance()->PrintFromSDRunnding())
	{
		Error(MESSAGE_PARSER3D_NO_FILE_SELECTED);
		return;
	}

	if (_reader->SkipSpacesToUpper() == 'S')
	{
		_reader->GetNextChar();
		_state._printFilePos = GetUInt32();
		_state._printFileLine = 1;					// TO DO => count line 
		if (IsError()) return;

		GetExecutingFile().seek(_state._printFilePos);
	}
	else if (_reader->GetCharToUpper() == 'L')
	{
		_reader->GetNextChar();
		unsigned long lineNr = GetUInt32();
		if (IsError()) return;

		if (lineNr < 1)
		{
			Error(MESSAGE_PARSER3D_LINE_SEEK_ERROR);
			return;
		}

		GetExecutingFile().seek(0);

		for (unsigned long line = 1; line < lineNr; line++)
		{
			// read line until \n
			char ch;
			do
			{
				if (GetExecutingFile().available() == 0)
				{
					Error(MESSAGE_PARSER3D_LINE_SEEK_ERROR);
					return;
				}

				ch = GetExecutingFile().read();
			} 
			while (ch != '\n');
		}
		
		_state._printFileLine = lineNr;
		_state._printFilePos = GetExecutingFile().position();
	}
}
Example #3
0
void CTreSubfile::Parse(CSubFile * pSubFile)
{
	m_pSubFile = pSubFile;
	m_fSubdivisionsParsed = false;
	m_fLevelsParsed = false;
	// Read header with constant size
	{
		// Read header data
		Byte data[cnHeaderSize];
		pSubFile->Read(data, 0x0, cnHeaderSize);
		// Get header length
		m_uiHeaderLength = GetUInt16(data + 0x0);
		// Read file type
		m_strType.assign((char*)(data + 0x2), 10);

		// General data
		// Read boundaries
		Int igNorthBoundary = GetInt24(data + 0x15) << (GPWIDTH - 24);
		Int igEastBoundary = GetInt24(data + 0x18) << (GPWIDTH - 24);
		Int igSouthBoundary = GetInt24(data + 0x1B) << (GPWIDTH - 24);
		Int igWestBoundary = GetInt24(data + 0x1E) << (GPWIDTH - 24);
		if (igEastBoundary <= igWestBoundary)
			igEastBoundary += (1 << GPWIDTH);
		m_grBound = GeoRect(igWestBoundary, igEastBoundary, igSouthBoundary, igNorthBoundary);

		// Get levels block info
		m_uiMapLevelsOffset = GetUInt32(data + 0x21);
		m_uiMapLevelsLen = GetUInt32(data + 0x25);

		// Get subdivisions block info
		m_uiSubdivisionOffset = GetUInt32(data + 0x29);
		m_uiSubdivisionLen = GetUInt32(data + 0x2D);

		// Get polyline block info
		m_uiPolylineOffset = GetUInt32(data + 0x4A);
		m_uiPolylineLen = GetUInt32(data + 0x4E);
		m_uiPolylineRecSize = GetUInt16(data + 0x52);

		// Get polygons block info
		m_uiPolygonOffset = GetUInt32(data + 0x58);
		m_uiPolygonLen = GetUInt32(data + 0x5C);
		m_uiPolygonRecSize = GetUInt16(data + 0x60);

		// Get points block info
		m_uiPointOffset = GetUInt32(data + 0x66);
		m_uiPointLen = GetUInt32(data + 0x6A);
		m_uiPointRecSize = GetUInt16(data + 0x6E);
	}
}
Example #4
0
 const char* DBCRecord::GetString(size_t field, uint32 field_count, const uint32 field_offset, uint32 string_size, unsigned char* string_table)
 {
     assert(field < field_count);
     size_t string_offset = GetUInt32(field, field_count, field_offset);
     assert(string_offset < string_size);
     return reinterpret_cast<char*>(string_table + string_offset);
 }
hashcode_t HashCode::hashcodeByUnRepeatedField(const Message* msg, const FieldDescriptor* field) {
  auto reflect = msg->GetReflection();
  switch (field->cpp_type()) {
  case FieldDescriptor::CPPTYPE_UINT64:
    return stl_hashcode(reflect->GetUInt64(*msg, field));
  case FieldDescriptor::CPPTYPE_INT64:
    return stl_hashcode(reflect->GetInt64(*msg, field));
  case FieldDescriptor::CPPTYPE_UINT32:
    return stl_hashcode(reflect->GetUInt32(*msg, field));
  case FieldDescriptor::CPPTYPE_INT32:
    return stl_hashcode(reflect->GetInt32(*msg, field));
  case FieldDescriptor::CPPTYPE_STRING:
    return stl_hashcode(reflect->GetString(*msg, field));
  case FieldDescriptor::CPPTYPE_DOUBLE:
    return stl_hashcode(reflect->GetDouble(*msg, field));
  case FieldDescriptor::CPPTYPE_FLOAT:
    return stl_hashcode(reflect->GetFloat(*msg, field));
  case FieldDescriptor::CPPTYPE_BOOL:
    return stl_hashcode(reflect->GetBool(*msg, field));
  case FieldDescriptor::CPPTYPE_ENUM:
    return stl_hashcode(reflect->GetEnum(*msg, field)->number());
  case FieldDescriptor::CPPTYPE_MESSAGE:
    return stl_hashcode(reflect->GetMessage(*msg, field));
  default:
    LOG(ERROR)<< "The type of protobuf is not supported";
    return 0;
  }
}
 Value *GetDefaultValue(CodeGenerator *codegen, Type *type) {
     switch (type->getTypeID()) {
     default: return nullptr;
     case Type::PointerTyID: return ConstantPointerNull::get(0);
     case Type::DoubleTyID: return GetDouble(codegen, 0.0);
     case Type::FloatTyID: return GetFloat(codegen, 0.0f);
     case Type::IntegerTyID: return GetUInt32(codegen, 0);
     }
 }
Example #7
0
void CIMGFile::Parse()
{
	Map * currentMap;
	currentMap = new Map(this);
	m_maps.push_back(currentMap);

	// Read XOR byte & set it to file
	Byte bXOR;
	m_File.Read(&bXOR, 0, 1);
	m_File.SetXOR(bXOR);
	// Buffer for header data
	Byte data[cnHeaderSize];
	// Read header
	m_File.Read(data, 0, cnHeaderSize);
	// Read xor byte
	m_bXOR = data[0x0];
	// Get filesystem block size
	UInt uiBlockSizeExp = data[0x61] + data[0x62];
	m_uiBlockSize = 1 << (uiBlockSizeExp);
	// Get first fs block offset
	m_uiFirstBlockOffset = GetUInt32(data + 0x40C);

	UInt uiFATBlockStart;
	bool fTrueMet = false;
	// FAT blocks start after header and end before first block
	for (uiFATBlockStart = cnHeaderSize; uiFATBlockStart < m_uiFirstBlockOffset || !m_uiFirstBlockOffset; uiFATBlockStart += CFATBlock::cnSize)
	{
		// Add block
		m_FATBlocks.push_back(CFATBlock());
		// Parse its data
		m_FATBlocks.back().Parse(this, uiFATBlockStart);
		// If it is true, add to corresponding subfile
		if (m_FATBlocks.back().IsTrue())
		{
			if (
				m_FATBlocks.back().GetPart() == 0 && 
				currentMap->m_SubFiles.find(m_FATBlocks.back().GetFileName()) 
					!= currentMap->m_SubFiles.end())
			{
				currentMap = new Map(this);
				m_maps.push_back(currentMap);
			}
			currentMap->m_SubFiles[m_FATBlocks.back().GetFileName()].Add(&m_FATBlocks.back());
			fTrueMet = true;
		}
		else 
		{
			if (!m_uiFirstBlockOffset && fTrueMet)
				break;
		}
	}
	for (Maps::iterator it = m_maps.begin(); it != m_maps.end(); ++it)
		(*it)->ParseSubfiles();
};
unsigned int InitGraphics(unsigned int screenWidth, unsigned int screenHeight, unsigned int bitDepth)
{
	//set global parameters
	m_screenWidth = screenWidth;
	m_screenHeight = screenHeight;
	m_bitDepth = bitDepth;


	//Set up the frame buffer info

	//physical width of the screen
	PutUInt32(0x40040000, m_screenWidth);
	//physical height of the screen
	PutUInt32(0x40040004, m_screenHeight);
	//virtual width of the screen
	PutUInt32(0x40040008, m_screenWidth);
	// virtual height of the screen
	PutUInt32(0x4004000C, m_screenHeight);
	//pitch ( number of bytes between each row of the frame buffer) set by the GPU ( set to 0 for now )
	PutUInt32(0x40040010, 0);
	//bit depth
	PutUInt32(0x40040014, m_bitDepth);
	// X offset
	PutUInt32(0x40040018, 0);
	// Y offset
	PutUInt32(0x4004001C, 0);
	// pointer returned by the GPU ( set to 0 for now )r
	PutUInt32(0x40040020, 0);
	// size of the frame buffer, set by the GPU ( set to 0 for now )
	PutUInt32(0x40040024, 0);

	// !!!! This seems to break the system, looks like we dont need to add on 0x40000000. !!!!
	// add on 0x40000000 into the value in the frame buffer to specify how to write it to the structure, this will make the GPU clear its cache so we can see the result
	//PutUInt32(0x40040000, (GetUInt32(0x40040000) + 0x40000000));

	// send the frame buffer info to channel 1
	if (MailboxWrite(0x40040000, 1) == 0)
	{
		return 0;
	}

	unsigned int frameBufferResponce;
	frameBufferResponce = MailboxRead(1);

	if (frameBufferResponce == 0)
	{
		m_framebufferAddress = GetUInt32(0x40040020);
		return 1;
	}
	return 0;
}
Example #9
0
void CFX_CTTGSUBTable::ParseFeatureList(FT_Bytes raw, TFeatureList* rec) {
  int i;
  FT_Bytes sp = raw;
  rec->FeatureCount = GetUInt16(sp);
  if (rec->FeatureCount <= 0) {
    return;
  }
  rec->FeatureRecord = new struct TFeatureRecord[rec->FeatureCount];
  for (i = 0; i < rec->FeatureCount; i++) {
    rec->FeatureRecord[i].FeatureTag = GetUInt32(sp);
    TT_uint16_t offset = GetUInt16(sp);
    ParseFeature(&raw[offset], &rec->FeatureRecord[i].Feature);
  }
}
Example #10
0
void CFX_CTTGSUBTable::ParseScriptList(FT_Bytes raw, struct TScriptList* rec) {
  int i;
  FT_Bytes sp = raw;
  rec->ScriptCount = GetUInt16(sp);
  if (rec->ScriptCount <= 0) {
    return;
  }
  rec->ScriptRecord = new struct TScriptRecord[rec->ScriptCount];
  for (i = 0; i < rec->ScriptCount; i++) {
    rec->ScriptRecord[i].ScriptTag = GetUInt32(sp);
    TT_uint16_t offset = GetUInt16(sp);
    ParseScript(&raw[offset], &rec->ScriptRecord[i].Script);
  }
}
unsigned int MailboxRead(unsigned int mailbox)
{
	// this checks to make sure we have a valid 0-15 mailbox
	if (mailbox > 15)
	{
		// returns 1 as the GPU will return 0 at the end of this function if everything is ok
		return 0;
	}

	unsigned int newMail;

	unsigned int ready; ready = 0;
	while (!ready)
	{
		// get the status of the mailbox, shifting 16 bytes to the status address
		unsigned int mailStatus; mailStatus = GetUInt32(MAILBOX_STATUS);

		// if the 30th bit is 0 then you are ready to read.
		if ((mailStatus & 0x40000000) == 0)
		{
			//read the next item in the mailbox
			newMail = GetUInt32(MAILBOX_READ);

			//check to make sure the channel of the message we have just read is the one we want
			if ((newMail & 0xF) == mailbox)
			{
				// break the whle loop 
				ready = 1;
			}

		}

	}

	//returns the top 28 bits of the mail ( delete the channel off of the mail )
	return (newMail & 0xfffffff0);
}
Example #12
0
void CFX_CTTGSUBTable::ParseScript(FT_Bytes raw, struct TScript* rec) {
  int i;
  FT_Bytes sp = raw;
  rec->DefaultLangSys = GetUInt16(sp);
  rec->LangSysCount = GetUInt16(sp);
  if (rec->LangSysCount <= 0) {
    return;
  }
  rec->LangSysRecord = new struct TLangSysRecord[rec->LangSysCount];
  for (i = 0; i < rec->LangSysCount; i++) {
    rec->LangSysRecord[i].LangSysTag = GetUInt32(sp);
    TT_uint16_t offset = GetUInt16(sp);
    ParseLangSys(&raw[offset], &rec->LangSysRecord[i].LangSys);
  }
}
const OSSymbol * IODTInterruptControllerName( IORegistryEntry * regEntry )
{
    const OSSymbol	*sym;
    UInt32		phandle;
    bool		ok;
    char 		buf[48];

    ok = GetUInt32( regEntry, gIODTPHandleKey, &phandle);
    assert( ok );

    if( ok) {
        snprintf(buf, sizeof(buf), "IOInterruptController%08X", (uint32_t)phandle);
        sym = OSSymbol::withCString( buf );
    } else
        sym = 0;

    return( sym );
}
    Value *GetDefaultValue(CodeGenerator *codegen, AstTypeNode *typeNode) {
        switch (typeNode->getTypeType()) {
        default: return nullptr;
        case node_boolean: return codegen->getBuilder().getFalse();
        case node_float: return GetFloat(codegen, 0.0f);
        case node_double: return GetDouble(codegen, 0.0);

        case node_signed_integer8: return GetInt8(codegen, 0);
        case node_signed_integer16: return GetInt16(codegen, 0);
        case node_signed_integer32: return GetInt32(codegen, 0);
        case node_signed_integer64: return GetInt64(codegen, 0);

        case node_unsigned_integer8: return GetUInt8(codegen, 0);
        case node_unsigned_integer16: return GetUInt16(codegen, 0);
        case node_unsigned_integer32: return GetUInt32(codegen, 0);
        case node_unsigned_integer64: return GetUInt64(codegen, 0);

        case node_string: return GetString(codegen, "");
        }
    }
Example #15
0
void CMdbResult::GetNumber(void* v, register uint32 nFieldNo)
{
	switch(GetType(nFieldNo))
	{
	case MDB_INT8_FIELD:
		*(int8*)v = GetInt8(nFieldNo);
		break;
	case MDB_INT16_FIELD:
		*(int16*)v = GetInt16(nFieldNo);
		break;
	case MDB_INT32_FIELD:
		*(int32*)v = GetInt32(nFieldNo);
		break;
	case MDB_INT64_FIELD:
		*(int64*)v = GetInt64(nFieldNo);
		break;
	case MDB_UINT8_FIELD:
		*(uint8*)v = GetUInt8(nFieldNo);
		break;
	case MDB_UINT16_FIELD:
		*(uint16*)v = GetUInt16(nFieldNo);
		break;
	case MDB_UINT32_FIELD:
		*(uint32*)v = GetUInt32(nFieldNo);
		break;
	case MDB_UINT64_FIELD:
		*(uint64*)v = GetUInt64(nFieldNo);
		break;
	case MDB_FLOAT_FIELD:
		*(float*)v = GetFloat(nFieldNo);
		break;
	case MDB_DOUBLE_FIELD:
	case MDB_DATETIME_FIELD:
		*(double*)v = GetDouble(nFieldNo);
		break;
	case MDB_DATE_FIELD:
	case MDB_TIME_FIELD:
		*(int32*)v = GetInt32(nFieldNo);
		break;
	}
}
unsigned int MailboxWrite(unsigned int input, unsigned int mailbox)
{
	//this checks that the lowest 4 bits of the input are 0 ( this will be where the mailbox address "channel" will be)
	if ((input & 0xF) > 0)
	{
		return 0;
	}
	
	//This checks if the mailbox address is correct, 0-15
	if (mailbox > 15)
	{
		return 0;
	}
	

	unsigned int ready; ready = 0;
	while (!ready)
	{
		// get the status of the mailbox, shifting 16 bytes to the status address
		unsigned int mailStatus; mailStatus = GetUInt32(MAILBOX_STATUS);
		// if the top bit is 0 then you are ready to write.
		if ((mailStatus & 0x80000000) == 0)
		{
			ready = 1;
		}

	}

	//add the mailbox "chanel" onto the input
	unsigned int finalMessage = input + mailbox;

	//store the value at the write address ( address, value)
	PutUInt32(MAILBOX_WRITE, finalMessage);

	return 1;
}
Example #17
0
void Pb2Json::Message2Json(const ProtobufMsg& message, Json& json, bool enum2str) {
    auto descriptor = message.GetDescriptor();
    auto reflection = message.GetReflection();
    if (nullptr == descriptor || nullptr == descriptor) return;

    auto count = descriptor->field_count();

    for (auto i = 0; i < count; ++i) {
        const auto field = descriptor->field(i);

        if (field->is_repeated()) {
            if (reflection->FieldSize(message, field) > 0)
                RepeatedMessage2Json(message, field, reflection, json[field->name()], enum2str);

            continue;
        }

        if (!reflection->HasField(message, field)) {
            continue;
        }

        switch (field->type()) {
            case ProtobufFieldDescriptor::TYPE_MESSAGE: {
                const ProtobufMsg& tmp_message = reflection->GetMessage(message, field);
                if (0 != tmp_message.ByteSize()) Message2Json(tmp_message, json[field->name()]);
            } break;

            case ProtobufFieldDescriptor::TYPE_BOOL:
                json[field->name()] = reflection->GetBool(message, field) ? true : false;
                break;

            case ProtobufFieldDescriptor::TYPE_ENUM: {
                auto* enum_value_desc = reflection->GetEnum(message, field);
                if (enum2str) {
                    json[field->name()] = enum_value_desc->name();
                } else {
                    json[field->name()] = enum_value_desc->number();
                }
            } break;

            case ProtobufFieldDescriptor::TYPE_INT32:
            case ProtobufFieldDescriptor::TYPE_SINT32:
            case ProtobufFieldDescriptor::TYPE_SFIXED32:
                json[field->name()] = reflection->GetInt32(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_UINT32:
            case ProtobufFieldDescriptor::TYPE_FIXED32:
                json[field->name()] = reflection->GetUInt32(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_INT64:
            case ProtobufFieldDescriptor::TYPE_SINT64:
            case ProtobufFieldDescriptor::TYPE_SFIXED64:
                json[field->name()] = reflection->GetInt64(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_UINT64:
            case ProtobufFieldDescriptor::TYPE_FIXED64:
                json[field->name()] = reflection->GetUInt64(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_FLOAT:
                json[field->name()] = reflection->GetFloat(message, field);
                break;

            case ProtobufFieldDescriptor::TYPE_STRING:
            case ProtobufFieldDescriptor::TYPE_BYTES:
                json[field->name()] = reflection->GetString(message, field);
                break;

            default:
                break;
        }
    }
}
/*  扱えるMVNのデータかヘッダを確認 */
bool PacketParserNeuron::CheckHeader(const uint8* raw, const int32 length)
{
	/*  ヘッダ部の長さ未満なら不正として終了 */
	if (length < 63) return false;

	int32 index = 0;

	/*  先頭の文字列を確認 */
	if (GetUInt16(raw, 0) != 0xDDFF) return false;
	index += 2;
	
	/* バージョン番号 4バイト */
	uint8 verBuildNumb = raw[index++];
	uint8 verRevision = raw[index++];
	uint8 verMinor = raw[index++];
	uint8 verMajor = raw[index++];

	/* Ver.1.x.x.x までのみ対応 */
	if (verMajor > 1) return false;

	/* Ver.1.0 と Ver.1.1 でヘッダーの仕様が変わった */
	if (verMinor < 1) {
		/*  このパケット中のデータ数 4バイト */
		uint32 dataCount = GetUInt32(raw, index);
		index += 4;
		
		/*  データ数と受信された長さが一致しなければ不正として終了 */
		if (length != (dataCount * 4 + 64)) return false;

		/*  変位もデータに含まれるか */
		this->hasDisplacement = (GetUInt32(raw, index) != 0);
		index += 4;

		/*  リファレンスが含まれるか */
		this->hasReference = (GetUInt32(raw, index) != 0);
		index += 4;
	} else {
		/*  このパケット中のデータ数 4バイト */
		uint16 dataCount = GetUInt16(raw, index);
		index += 2;
		
		/*  データ数と受信された長さが一致しなければ不正として終了 */
		if (length != (dataCount * 4 + 64)) return false;

		/*  変位もデータに含まれるか */
		this->hasDisplacement = (raw[index++] != 0);

		/*  リファレンスが含まれるか */
		this->hasReference = (raw[index++] != 0);
	}

	/*  アバターID */
	this->userId = GetUInt32(raw, index);
	index += 4;

	/*  ヘッダーの終了を確認 */
	index = 62;
	if (GetUInt16(raw, index) != 0xEEFF) return false;

	return true;
}
Example #19
0
DWORD Cx_CfgRecord::GetRGB(const wchar_t* pszEntry, DWORD crDefault)
{
    return GetUInt32(pszEntry, crDefault);
}