示例#1
0
static void reset_registers(void) {
	uint32_t vectortable = read_word(VECTOR_TABLE_OFFSET);

	// R[0..12] = bits(32) UNKNOWN {nop}

	SW(&sp_main,read_word(vectortable) & 0xfffffffc);

	// sp_process = ((bits(30) UNKNOWN):'00')
	SW(&sp_process, SR(&sp_process) & ~0x3);

	CORE_reg_write(LR_REG, 0xFFFFFFFF);

	uint32_t tmp = read_word(vectortable+4);
	bool tbit = tmp & 0x1;
	CORE_reg_write(PC_REG, tmp & 0xfffffffe);
	if (! (tmp & 0x1) ) {
		WARN("Reset vector %08x at %08x invalid\n", tmp, vectortable+4);
		CORE_ERR_unpredictable("Thumb bit must be set for M-series\n");
	}

	// ASPR = bits(32) UNKNOWN {nop}

	union ipsr_t ipsr = CORE_ipsr_read();
	ipsr.bits.exception = 0;
	CORE_ipsr_write(ipsr);

	union epsr_t epsr = CORE_epsr_read();
	epsr.bits.T = tbit;
	epsr.bits.ICI_IT_top = 0;
	epsr.bits.ICI_IT_bot = 0;
	CORE_epsr_write(epsr);
}
示例#2
0
EXPORT void CORE_reg_write(int r, uint32_t val) {
	assert(r >= 0 && r < 16 && "CORE_reg_write");
	if (r == SP_REG) {
		SW(physical_sp_p, val & 0xfffffffc);
	} else if (r == LR_REG) {
		SW(&physical_lr, val);
	} else if (r == PC_REG) {
		DBG2("Writing %08x to PC\n", val & 0xfffffffe);
#ifdef NO_PIPELINE
		pipeline_flush_exception_handler(val & 0xfffffffe);
#else
		if (state_is_debugging()) {
			DBG1("PC write + debugging --> flush\n");
			state_pipeline_flush(val & 0xfffffffe);
		} else {
			// Only flush if the new PC differs from predicted in pipeline:
			if (((SR(&if_id_PC) & 0xfffffffe) - 4) == (val & 0xfffffffe)) {
				DBG2("Predicted PC correctly (%08x)\n", val);
			} else {
				state_pipeline_flush(val & 0xfffffffe);
				DBG2("Predicted PC incorrectly\n");
				DBG2("Pred: %08x, val: %08x\n", SR(&if_id_PC), val);
			}
		}
#endif
	}
	else {
		SW(&(physical_reg[r]), val);
	}
}
void GroupBattleRule::swap(GroupBattleRule & other) {
	GC::GroupBattleRule::swap(other);
	SW(nbPkm);
	SW(isBattleOpen);
	SW(revealDeoxysForm);
	SW(customName);
}
示例#4
0
/* Output the program header */
void output_ph(unsigned char *data)
{
	Elf32_Phdr *phdr;
	struct PspModuleInfo *pModinfo;
	int mod_flags;

	phdr = (Elf32_Phdr*) data;
	pModinfo = (struct PspModuleInfo *) (g_modinfo->pData);
	mod_flags = LW(pModinfo->flags);

	SW(&phdr->p_type, 1);
	/* Starts after the program header */
	SW(&phdr->p_offset, g_allocbase);
	SW(&phdr->p_vaddr, 0);

	/* Check if this is a kernel module */
	if(mod_flags & 0x1000)
	{
		SW(&phdr->p_paddr, 0x80000000 | (g_modinfo->iAddr + g_allocbase));
	}
	else
	{
		SW(&phdr->p_paddr, (g_modinfo->iAddr + g_allocbase));
	}
	SW(&phdr->p_filesz, g_alloc_size);
	SW(&phdr->p_memsz, g_mem_size);
	SW(&phdr->p_flags, 5);
	SW(&phdr->p_align, 0x10);
}
示例#5
0
static void intra_predict_vert_8x8_msa(const uint8_t *src, uint8_t *dst,
                                       int32_t dst_stride) {
  uint32_t row;
  uint32_t src_data1, src_data2;

  src_data1 = LW(src);
  src_data2 = LW(src + 4);

  for (row = 8; row--;) {
    SW(src_data1, dst);
    SW(src_data2, (dst + 4));
    dst += dst_stride;
  }
}
示例#6
0
void PCol(Colours8 Colour){
	switch(Colour){
	case Black:
		SW(0x0000, Dat);
		break;
	case Blue:
		SW(0x0010, Dat);
		break;
	case Red:
		SW(0x8000, Dat);
		break;
	case Magenta:
		SW(0x8010, Dat);
		break;
	case Green:
		SW(0x0400, Dat);
		break;
	case Cyan:
		SW(0x0410, Dat);
		break;
	case Yellow:
		SW(0x8400, Dat);
		break;
	case White:
		SW(0x8410, Dat);
		break;
	}
}
示例#7
0
文件: leds.c 项目: hoangt/M-ulator
static void led_write(uint32_t addr, uint32_t val) {
	switch (addr) {
		case REDLED:
			SW(&red, val & 0xff); // device emulates 8 leds
			break;
		case GRNLED:
			SW(&grn, val & 0xff);
			break;
		case BLULED:
			SW(&blu, val & 0xff);
			break;
		default:
			assert(false && "Bad LED memmap");
	}
}
示例#8
0
/* Output relocations */
void output_relocs(unsigned char *data)
{
	int i;
	unsigned char *pReloc;

	pReloc = data;

	for(i = 0; i < g_elfhead.iShnum; i++)
	{
		if((g_elfsections[i].blOutput) && 
				((g_elfsections[i].iType == SHT_REL) || (g_elfsections[i].iType == SHT_PRXRELOC)))
		{
			Elf32_Rel *rel;
			int j, count;

			memcpy(pReloc, g_elfsections[i].pData, g_elfsections[i].iSize);
			rel = (Elf32_Rel*) pReloc;
			count = g_elfsections[i].iSize / sizeof(Elf32_Rel);
			for(j = 0; j < count; j++)
			{
				unsigned int sym;

				/* Clear the top 24bits of the info */
				/* Kind of a dirty trick but hey :P */
				sym = LW(rel->r_info);
				sym &= 0xFF;
				SW(&rel->r_info, sym);
				rel++;
			}
			pReloc += g_elfsections[i].iSize;
		}
	}
}
示例#9
0
文件: board.cpp 项目: saining/go4ever
STATIC nbr3x3_t recalc_nbr3x3(board_t *b, index_t pos)
{
    return construct_3x3(b->stones[N(b, pos)], b->stones[S(b, pos)],
                         b->stones[W(b, pos)], b->stones[E(b, pos)],
                         b->stones[NE(b, pos)], b->stones[NW(b, pos)],
                         b->stones[SE(b, pos)], b->stones[SW(b, pos)]);
}
示例#10
0
void Handler_PSET_MON(int *myID, std::string* str)
{
	SYNCHED_CHARACTER_MAP* chars = SYNCHED_CHARACTER_MAP::getInstance();
	SYNCHED_MONSTER_MAP* mons = SYNCHED_MONSTER_MAP::getInstance();

	SET_MONSTER::CONTENTS setmonsterContents;
	setmonsterContents.ParseFromString(*str);

	Scoped_Wlock SW(&mons->srw);

	for (int i = 0; i < setmonsterContents.data_size(); ++i)
	{
		auto tmpMon = setmonsterContents.data(i);
		std::string monName = tmpMon.name();
		Monster* mon;
		if (monName == "기사")
		{
			mon = new Knight(tmpMon.id());
		}
		// 일단 else문 달음. 이것 안하면 c4703에러뜸
		else
		{
			mon = new Knight();
		}
		mon->setX(tmpMon.x());
		mon->setY(tmpMon.y());
		mon->setLv(tmpMon.lv(), tmpMon.maxhp(), tmpMon.power());
		
		mons->insert(tmpMon.id(), mon);
		
		printf("※ 앗!야생의 %s [ID:%d]가 나타났습니다!\n", mon->getName().c_str(), mon->getID());
	}
	setmonsterContents.clear_data();
}
示例#11
0
void Handler_PINIT(int* myID, Character *myChar, std::string* str)
{
	SYNCHED_CHARACTER_MAP* chars = SYNCHED_CHARACTER_MAP::getInstance();
	SYNCHED_MONSTER_MAP* mons = SYNCHED_MONSTER_MAP::getInstance();

	INIT::CONTENTS contents;
	contents.ParseFromString(*str);

	Scoped_Wlock SW(&chars->srw);

	auto user = contents.data(0);
	int id = user.id(), x = user.x(), y = user.y();
	std::string name = user.name();
	int lv = user.lv(), maxHp = user.maxhp(), power = user.power(), maxExp = user.maxexp();
	int prtExp = user.prtexp();
	*myID = id;
	
	Character* myCharacter = myChar;
	myCharacter->setID(id);
	myCharacter->setName(name);
	myCharacter->setX(x);
	myCharacter->setY(y);
	myCharacter->setLv(lv, maxHp, power, maxExp);
	myCharacter->setPrtExp(prtExp);

	chars->insert(id, myChar);
	
	printf("- %s님께서 위치 (%d,%d) 에 생성되었습니다!\n", myChar->getName().c_str(), myChar->getX(), myChar->getY());
	
	contents.clear_data();
}
示例#12
0
文件: m3_prc.c 项目: lab11/M-ulator
static void mbus_mmio_wr(uint32_t addr, uint32_t val,
		bool debugger __attribute__ ((unused)) ) {
	switch (addr) {
		case MBUS_MMIO_ADDR:
			SW(&mbus_mmio_addr, val);
			break;
		case MBUS_MMIO_DATA:
			SW(&mbus_mmio_data, val);
			INFO("MBus message: addr %08x, data %08x\n",
					SR(&mbus_mmio_addr),
					SR(&mbus_mmio_data)
			    );
			break;
		default:
			WARN("Unknown address, %08x\n", addr);
			CORE_ERR_unpredictable("Bad MBus MMIO address");
	}
	fflush(stdout);
}
示例#13
0
int main (int argc, char *argv[])
{
  FILE *fin;
  char *seq ;
  char *comp_seq;
  int ALIGNMENT;
  int size;
  char *buff;
  int i;

  if (argc !=  4)
    {
      printf ("\nusage: excutable seqstringfile print_alignment(0:1) segment_size\n");
      return 0; //error
    }
  
  else
    {
      //seq = argv[1];
      fin = fopen(argv[1],"r");
      if (fin == NULL)
	return 0;
      InputFileToString(fin, &seq) ;
          
      ALIGNMENT = atoi(argv[2]);
      size = atoi(argv[3]);
      
      comp_seq = (char *)malloc(sizeof(char)*(strlen(seq)+1));
      memset(comp_seq, 0, (strlen(seq)+1));
      
      buff=(char *)malloc(sizeof(char)*(strlen(seq)+1)*5);
      memset(buff, 0, (strlen(seq)+1));
      //printf("%d\n",strlen(buff));

      //complement sequence not reversed yet!
      Complement_Seq_RDNA (seq, comp_seq); 
      if (comp_seq == NULL)
	{
	  free (comp_seq);
	  return 0; //error
	}

      SW (seq, comp_seq, ALIGNMENT,size,buff);
      //printf("%d\n",strlen(buff));
      
      printf("%s",buff);
      //write(stdout, buff , strlen( buff ));
      //printf("%d\n",strlen(buff));
      //free comp_seq memory
      free (comp_seq);
      free(seq);

      return 1; //success
    }
}
示例#14
0
文件: cs8900.c 项目: bk1472/d2a_prj
/* Get a data block via Ethernet */
extern int eth_rx (void)
{
	int i;
	unsigned short rxlen;
	unsigned short *addr, data;
	unsigned short status;

	status = get_reg (PP_RER);

	if ((status & PP_RER_RxOK) == 0)
		return 0;

	status = CS8900_RTDATA;		/* stat */
	rxlen = CS8900_RTDATA;		/* len */

#ifdef DEBUG
	if (rxlen > PKTSIZE_ALIGN + PKTALIGN)
		printf ("packet too big!\n");
#endif
//	printf("Recv %04x %04x\n", status, rxlen);
	for (addr = (unsigned short *) NetRxPackets[0], i = rxlen >> 1; i > 0;
		 i--)
	{
		data = CS8900_RTDATA;
		*addr++ = SW(data);
	}
	if (rxlen & 1)
	{
		data = CS8900_RTDATA;
		*addr++ = SW(data);
	}
//	for ( i = 0 ; i < 10 ; i++)
//	{
//		printf("%04x ", addr[i]);
//	}
//	printf("\n");

	/* Pass the packet up to the protocol layers. */
	NetReceive (NetRxPackets[0], rxlen);

	return rxlen;
}
示例#15
0
EXPORT void CORE_apsr_write(union apsr_t val) {
	if (in_ITblock()) {
		WARN("WARN update of apsr in IT block\n");
	}
#ifdef M_PROFILE
	if (val.storage & 0x07f0ffff) {
		DBG1("WARN update of reserved APSR bits\n");
	}
#endif
	SW(&apsr.storage, val.storage);
}
示例#16
0
VOID FatSwapLFNDirEntry(PLFN_DIRENTRY Obj)
{
	int i;
	SW(Obj, StartCluster);
	for(i = 0; i < 5; i++)
		Obj->Name0_4[i] = SWAPW(Obj->Name0_4[i]);
	for(i = 0; i < 6; i++)
		Obj->Name5_10[i] = SWAPW(Obj->Name5_10[i]);
	for(i = 0; i < 2; i++)
		Obj->Name11_12[i] = SWAPW(Obj->Name11_12[i]);
}
示例#17
0
VOID FatSwapFatBootSector(PFAT_BOOTSECTOR Obj)
{
	SW(Obj, BytesPerSector);
	SW(Obj, ReservedSectors);
	SW(Obj, RootDirEntries);
	SW(Obj, TotalSectors);
	SW(Obj, SectorsPerFat);
	SW(Obj, SectorsPerTrack);
	SW(Obj, NumberOfHeads);
	SD(Obj, HiddenSectors);
	SD(Obj, TotalSectorsBig);
	SD(Obj, VolumeSerialNumber);
	SW(Obj, BootSectorMagic);
}
示例#18
0
VOID FatSwapDirEntry(PDIRENTRY Obj)
{
	SW(Obj, CreateTime);
	SW(Obj, CreateDate);
	SW(Obj, LastAccessDate);
	SW(Obj, ClusterHigh);
	SW(Obj, Time);
	SW(Obj, Date);
	SW(Obj, ClusterLow);
	SD(Obj, Size);
}
示例#19
0
int main(void) {
  scanf("%d%d", &n, &m);
  for(int i=0,a,b,c;i<m;++i){
    scanf("%d%d%d",&a,&b,&c);
    edg[a][b]+=c;
    edg[b][a]+=c;
  }

  printf("%d\n", SW());

  clear();
  return 0;
}
示例#20
0
文件: m3_prc.c 项目: lab11/M-ulator
static void cpu_conf_regs_wr(uint32_t addr, uint32_t val,
		bool debugger __attribute__ ((unused)) ) {
	switch (addr) {
		case CHIP_ID_REG_WR:
			SW(&m3_prc_reg_chip_id, val & MASK(CHIP_ID_REG_NBITS));
			break;
		case GOC_CTRL_REG_WR:
			SW(&m3_prc_reg_goc_ctrl, val & MASK(GOC_CTRL_REG_NBITS));
			break;
		case PMU_CTRL_REG_WR:
			SW(&m3_prc_reg_pmu_ctrl, val & MASK(PMU_CTRL_REG_NBITS));
			break;
		case WUP_CTRL_REG_WR:
			SW(&m3_prc_reg_wup_ctrl, val & MASK(WUP_CTRL_REG_NBITS));
			break;
		case TSTAMP_REG_WR:
			SW(&m3_prc_reg_tstamp, val & MASK(TSTAMP_REG_NBITS));
			break;
		default:
			CORE_ERR_unpredictable("Bad CPU Config Reg Write");
	}
}
示例#21
0
void PlayerData::swap(PlayerData& other) {
	if (size != other.size) throw std::invalid_argument("Cannot assign because *this and other are of different types");
	Base::DataStruct::swap(other);
	SW(SID); SW(TID); SW(money); SW(pkCoupons);
	CL(trainerName);
	SW_ARRAY(party, 6);
	SW(bag);
	SW(trainerGender);
}
示例#22
0
文件: cs8900.c 项目: bk1472/d2a_prj
/* Send a data block via Ethernet. */
extern int eth_send (volatile void *packet, int length)
{
	volatile unsigned short *addr;
	int tmo;
	unsigned short s;

retry:
	/* initiate a transmit sequence */
	CS8900_TxCMD = PP_TxCmd_TxStart_Full;
	CS8900_TxLEN = length;

	/* Test to see if the chip has allocated memory for the packet */
	if ((get_reg (PP_BusSTAT) & (PP_BusSTAT_TxRDY)) == 0) {
		/* Oops... this should not happen! */
#ifdef DEBUG
		printf ("cs: unable to send packet; retrying...\n");
#endif
		for (tmo = get_timer (0) + 5 * CFG_HZ; get_timer (0) < tmo;)
			/*NOP*/;
		eth_reset ();
		eth_reginit ();
		goto retry;
	}

	/* Write the contents of the packet */
	/* assume even number of bytes */
	for (addr = packet; length > 0; length -= 2)
	{
		unsigned short data = *addr;
		CS8900_RTDATA = SW(data);
		addr++;
	}

	/* wait for transfer to succeed */
	tmo = get_timer (0) + 5 * CFG_HZ;
	while ((s = get_reg (PP_TER) & ~0x1F) == 0) {
		if (get_timer (0) >= tmo)
			break;
	}

	/* nothing */ ;
	if ((s & (PP_TER_CRS | PP_TER_TxOK)) != PP_TER_TxOK) {
#ifdef DEBUG
		printf ("\ntransmission error %#x\n", s);
#endif
	}

	return 0;
}
示例#23
0
EXPORT void CORE_reg_write(int r, uint32_t val) {
	assert(r >= 0 && r < 16 && "CORE_reg_write");
	if (r == SP_REG) {
		SW(&SP, val & 0xfffffffc);
	} else if (r == LR_REG) {
		SW(&LR, val);
	} else if (r == PC_REG) {
#ifdef NO_PIPELINE
		/*
		if (*state_flags_cur & STATE_DEBUGGING) {
			SW(&pre_if_PC, val & 0xfffffffe);
			SW(&if_id_PC, val & 0xfffffffe);
			SW(&id_ex_PC, val & 0xfffffffe);
		} else {
		*/
			SW(&pre_if_PC, val & 0xfffffffe);
		//}
#else
		if (state_is_debugging()) {
			state_pipeline_flush(val & 0xfffffffe);
		} else {
			// Only flush if the new PC differs from predicted in pipeline:
			if (((SR(&if_id_PC) & 0xfffffffe) - 4) == (val & 0xfffffffe)) {
				DBG2("Predicted PC correctly (%08x)\n", val);
			} else {
				state_pipeline_flush(val & 0xfffffffe);
				DBG2("Predicted PC incorrectly\n");
				DBG2("Pred: %08x, val: %08x\n", SR(&if_id_PC), val);
			}
		}
#endif
	}
	else {
		SW(&(reg[r]), val);
	}
}
示例#24
0
static void control_SPSEL_write(bool spsel, bool force, enum Mode forced_mode) {
	union control_t c;
	c.storage = SR(&physical_control.storage);
	c.SPSEL = spsel;
	SW(&physical_control.storage, c.storage);

	enum Mode mode = (force) ? forced_mode : CORE_CurrentMode_read();
	(void) mode;

	// XXX: I'm confused on exactly the semantics here, esp w.r.t. exceptions
	//if (mode == Mode_Thread) {
		SWP(&physical_sp_p, (spsel) ? &sp_process : &sp_main);
	//} else {
	//	CORE_ERR_unpredictable("SPSEL write in Handler mode\n");
	//}
}
示例#25
0
VOID FatSwapFatXDirEntry(PFATX_DIRENTRY Obj)
{
	SD(Obj, StartCluster);
	SD(Obj, Size);
	SW(Obj, Time);
	SW(Obj, Date);
	SW(Obj, CreateTime);
	SW(Obj, CreateDate);
	SW(Obj, LastAccessTime);
	SW(Obj, LastAccessDate);
}
示例#26
0
文件: board.cpp 项目: saining/go4ever
inline static void delete_stone_update_3x3(board_t *b, index_t pos)
{
#define LOOP(P, OFFSET) {\
    b->nbr3x3[P] &= ~(3U << OFFSET); \
    touch_nbr3x3(b, P); \
}
    LOOP(W(b, pos), 0);
    LOOP(SW(b, pos), 2);
    LOOP(S(b, pos), 4);
    LOOP(SE(b, pos), 6);
    LOOP(E(b, pos), 8);
    LOOP(NE(b, pos), 10);
    LOOP(N(b, pos), 12);
    LOOP(NW(b, pos), 14);
#undef LOOP
    touch_nbr3x3(b, pos);
}
示例#27
0
文件: board.cpp 项目: saining/go4ever
inline static void add_stone_update_3x3(board_t *b, index_t pos)
{
    nbr3x3_t bit = (nbr3x3_t)b->stones[pos];
#define LOOP(P, OFFSET) {\
    b->nbr3x3[P] &= ~(3U << OFFSET); \
    b->nbr3x3[P] |= bit << OFFSET; \
    touch_nbr3x3(b, P); \
}
    LOOP(W(b, pos), 0);
    LOOP(SW(b, pos), 2);
    LOOP(S(b, pos), 4);
    LOOP(SE(b, pos), 6);
    LOOP(E(b, pos), 8);
    LOOP(NE(b, pos), 10);
    LOOP(N(b, pos), 12);
    LOOP(NW(b, pos), 14);
#undef LOOP
    touch_nbr3x3(b, pos);
}
示例#28
0
string DES::encrypt()
{
    /*
    string current = this->m_text;
    cout << "start:\t" << current << endl;
    current = IP(current);
    cout << "IP:\t" << current << endl;
    current = fK(current, this->m_k1);
    cout << "fK1:\t" << current << endl;
    current = SW(current);
    cout << "SW:\t" << current << endl;
    current = fK(current, this->m_k2);
    cout << "fK2:\t" << current << endl;
    current = inverseIP(current);
    cout << "invIP:\t" << current << endl;*/

    //return current;

    return inverseIP(fK(SW(fK(IP(this->m_text), this->m_k1)), this->m_k2));
}
void Handler_PUSER_SET_LV(int *myID, std::string* str)
{
	SYNCHED_CHARACTER_MAP* chars = SYNCHED_CHARACTER_MAP::getInstance();
	SYNCHED_MONSTER_MAP* mons = SYNCHED_MONSTER_MAP::getInstance();

	SET_USER_LV::CONTENTS setuserlvContents;
	setuserlvContents.ParseFromString(*str);

	Scoped_Rlock SW(&chars->srw);

	for (int i = 0; i < setuserlvContents.data_size(); ++i)
	{
		auto setuserlv = setuserlvContents.data(i);
		int id = setuserlv.id();
		int lv = setuserlv.lv();
		int maxHp = setuserlv.maxhp();
		int power = setuserlv.power();
		int expUp = setuserlv.expup();
		int maxexp = setuserlv.maxexp();

		Character* lvUpChar = chars->find(id);
		if (lvUpChar->getID() == *myID)
			printf("- 레벨 업을 하였습니다!!\n");

		if (lvUpChar == NULL)
		{
			printf("나 나오면 안돼는데 나옴?");
			exit(0);
		}
		else
		{
			lvUpChar->setExpUp(expUp);
			lvUpChar->setLv(lv, maxHp, power, maxexp);
			
			printf("★ 유저 %s 님께서 레벨이 %d로 올랐습니다!!\n", lvUpChar->getName().c_str(), id, lv);
		}
	}

}
示例#30
0
void SetScrn(Colours8 Colour){
	uint16_t XCnt, YCnt;

	SetAddr(0, 0, XPix-1, YPix-1);

	for(XCnt = 0; XCnt<XPix; XCnt++){
		for(YCnt = 0; YCnt<YPix; YCnt++){
			switch(Colour){
			case Black:
				SW(0x0000, Dat);
				break;
			case Blue:
				SW(0x0010, Dat);
				break;
			case Red:
				SW(0x8000, Dat);
				break;
			case Magenta:
				SW(0x8010, Dat);
				break;
			case Green:
				SW(0x0400, Dat);
				break;
			case Cyan:
				SW(0x0410, Dat);
				break;
			case Yellow:
				SW(0x8400, Dat);
				break;
			case White:
				SW(0x8410, Dat);
				break;
			}
		}
	}
}