示例#1
0
/*** write command for initialisation ***/
 void write_command4_lcd(unsigned char ch)                  // ex: ch =0x03
{                           
  int lcd_output;                                             
  int i;
  // write lower nibble: 
  lcd_output = (ch & 0x0f) << LCD_D_SHIFT;          		 // lcd_output= 0x0180 (shift_left=11)
  MemoryWrite(GPIO0_OUT, lcd_output);                        // write lower nibble
  for(i=0;i<2;i++){}                                         // hold LCD_RS LCD_RW SF_D stable for 40ns before LCD_E goes high 
  HoldPulse_e12CC();                                         // LCD_E high for 12 Clock cycles
  for(i=0;i<1;i++){}
  MemoryWrite(GPIO0_CLEAR,lcd_output);
  for(i=0;i<2;i++){}
}
void HF_UpdateCounterMask(void){
	uint32_t m;

	m = MemoryRead(IRQ_MASK);					// read interrupt mask
	m ^= (IRQ_COUNTER | IRQ_COUNTER_NOT);				// toggle timer interrupt mask
	MemoryWrite(IRQ_MASK, m);					// write to irq mask register
}
/* basic libc abstraction stuff */
void uart_init(uint32_t baud){
	uint16_t d;

	d = (uint16_t)(CPU_SPEED / baud);
	MemoryWrite(UART_DIVISOR, d);
	MemoryRead(UART_READ);
}
示例#4
0
文件: executor.cpp 项目: nlsynth/nli
void Executor::ExecMemoryWrite(const Method *method, MethodFrame *frame,
			       Insn *insn) {
  Value &src_value = frame->reg_values_[insn->src_regs_[1]->id_];
  Value &dst_value = frame->reg_values_[insn->src_regs_[0]->id_];
  CHECK(dst_value.type_ == Value::NUM);
  int addr = dst_value.num_.int_part;
  MemoryWrite(addr, src_value.num_);
}
示例#5
0
//Plasma hardware dependent
uint32 OS_InterruptMaskClear(uint32 mask)
{
   uint32 state;
   state = OS_CriticalBegin();
   mask = MemoryRead(IRQ_MASK) & ~mask;
   MemoryWrite(IRQ_MASK, mask);
   OS_CriticalEnd(state);
   return mask;
}
示例#6
0
uint32_t HF_InterruptMaskClear(uint32_t mask){		// interrupt vector mask clear
	uint32_t m, state;

	state = HF_CriticalBegin();
	m = MemoryRead(IRQ_MASK) & ~mask;
	MemoryWrite(IRQ_MASK, m);
	HF_CriticalEnd(state);
	return m;
}
示例#7
0
/*
 * WriteMem - write some memory, using toolhelp or wdebug.386
 */
DWORD WriteMem( WORD sel, DWORD off, LPVOID buff, DWORD size )
{
    DWORD       rc;

    if( WDebug386 ) {
        rc = CopyMemory( sel, off, FP_SEG(buff), FP_OFF(buff), size );
    } else {
        if( DebugeeTask == NULL ) return( 0 );
        rc = MemoryWrite( sel, off, buff, size );
    }
    return( rc );

} /* WriteMem */
示例#8
0
//Plasma hardware dependent
static void OS_ThreadTickToggle(void *arg)
{
   uint32 status, mask, state;

   //Toggle looking for IRQ_COUNTER18 or IRQ_COUNTER18_NOT
   state = OS_SpinLock();
   status = MemoryRead(IRQ_STATUS) & (IRQ_COUNTER18 | IRQ_COUNTER18_NOT);
   mask = MemoryRead(IRQ_MASK) | IRQ_COUNTER18 | IRQ_COUNTER18_NOT;
   mask &= ~status;
   MemoryWrite(IRQ_MASK, mask);
   OS_ThreadTick(arg);
   OS_SpinUnlock(state);
}
示例#9
0
/*
 * WriteMem - write some memory, using toolhelp or wdebug.386
 */
DWORD WriteMem( WORD sel, DWORD off, LPVOID buff, DWORD size )
{
    DWORD       rc;
    if( WDebug386 ) {
        return( CopyMemory386( sel, off, FP_SEG( buff ), FP_OFF( buff ), size ) );
    } else {
        PushAll();
        rc = MemoryWrite( sel, off, buff, size );
        PopAll();
        return( rc );
    }

} /* WriteMem */
示例#10
0
/*** write command for configuration ***/
void write_command8_lcd(unsigned char ch)                    // ex: ch=0x28        
{  
  int lcd_output;       
  int i;
  
  //upper nibble
  lcd_output = (ch & 0xf0) << (LCD_D_SHIFT-4);			     // lcd_output= 0x1000    (shift_left=4)
  MemoryWrite(GPIO0_OUT, lcd_output);                        // write upper nibble
  for(i=0;i<2;i++){}                                         // hold LCD_RS LCD_RW SF_D stable for 40ns before LCD_E goes high 
  HoldPulse_e12CC();                                         // LCD_E high for 12 Clock cycles
  for(i=0;i<1;i++){}
  MemoryWrite(GPIO0_CLEAR,lcd_output);
  delay1us();
  
  //lower nibble
  lcd_output = (ch & 0x0f) << LCD_D_SHIFT;					 // lcd_output= 0x0600     (shift_left=11)
  MemoryWrite(GPIO0_OUT, lcd_output);                        // write lower nibble
  for(i=0;i<2;i++){}                                         // hold LCD_RS LCD_RW SF_D stable for 40ns before LCD_E goes high 
  HoldPulse_e12CC();                                         // LCD_E high for 12 Clock cycles
  for(i=0;i<1;i++){}
  MemoryWrite(GPIO0_CLEAR,lcd_output);
  delay40us();                                               // delay 40us for the next lcd write command 
}
void HF_HardwareInit(void){
	HF_InterruptMaskSet(0x0000);							// and clear irq mask

	HF_TimerInit();
#ifdef NOC_INTERCONNECT
	HF_NetworkInterfaceInit();
#endif
//	HF_UartInit();
#ifdef DEBUG
	printf("\nKERNEL: hellfire is up and running!\n");
#endif
	HF_schedule = 1;
	MemoryWrite(IRQ_STATUS, 1);								// enable interrupts
}
示例#12
0
/*** write characters ***/
void write_char_lcd(unsigned char ch) 						// ex: char=0x6c   
{                                                                         
  int lcd_output;
  int i;
  // upper nibble
  lcd_output = (ch & 0xf0) << (LCD_D_SHIFT - 4); 			// lcd_output= 0x3000			(shift_left=7)			
  lcd_output |= LCD_RS;                                     // lcd_output= 0x3400   --> LCD_RS =1  LCD_RW=0    SF_D=0110
  MemoryWrite(GPIO0_OUT,lcd_output);
  for(i=0;i<2;i++){}                                        // hold LCD_RS LCD_RW SF_D stable for 40ns before LCD_E goes high
  HoldPulse_e12CC();                                        // LCD_E high for 12 Clock cycles
  for(i=0;i<1;i++){}
  MemoryWrite(GPIO0_CLEAR,lcd_output);					    //  LCD_RS=0 LCD_RW=0
  delay1us();
 
 // lower nibble
  lcd_output = (ch & 0x0f) << LCD_D_SHIFT;         			// lcd_output= 0x6000     (shift_left=11)
  lcd_output |= LCD_RS;                          			// lcd_output= 0x6400  --> LCD_RS =1   LCD_RW=0    SF_D=1010
  MemoryWrite(GPIO0_OUT, lcd_output);						// write lower nibble
  for(i=0;i<2;i++){}                                        // hold LCD_RS LCD_RW SF_D stable for 40ns before LCD_E goes high 
  HoldPulse_e12CC();										// LCD_E high for 12 Clock cycles
  for(i=0;i<1;i++){}
  MemoryWrite(GPIO0_CLEAR,lcd_output);						// LCD_RS=0 LCD_RW=0
  delay40us();                                              // delay 40us for the next write char lcd
}
示例#13
0
文件: main.c 项目: cfriedt/jcore-temp
int
ddr_init (void)
{
  volatile int i, j, k = 0;
  for (i = 0; i < sizeof (DdrInitData) / sizeof (int); ++i)
    {
      MemoryWrite (DDR_BASE + DdrInitData[i], 0);
      for (j = 0; j < 4; ++j)
	++k;
    }
  for (j = 0; j < 100; ++j)
    ++k;
  k += MemoryRead (DDR_BASE);	//Enable DDR
  return k;
}
void HF_Panic(int32_t cause){
	int8_t buf[20];

	MemoryWrite(IRQ_STATUS, 0);
	switch(cause){
		case 0: puts("\nKERNEL: execution aborted - system halted."); break;
		case 1:	puts("\nKERNEL: PANIC!! general protection fault - system halted."); break;
		case 2:	puts("\nKERNEL: PANIC!! stack overflow detected (task ");
			itoa(HF_current_task, buf, 10); 
			puts(buf);
			puts(") - system halted.\n");
			printf("%x\n", (HF_task[HF_current_task].stack[0] << 24) | (HF_task[HF_current_task].stack[1] << 16) | (HF_task[HF_current_task].stack[2] << 8) | HF_task[HF_current_task].stack[3]);
			break;
		case 3: puts("\nKERNEL: PANIC!! no more tasks left to dispatch - system halted.\n"); break;
		default:
			puts("\nKERNEL: PANIC!! you should never see this!");
	}
	for(;;);							// stay here forever
}
示例#15
0
int main()
{
   unsigned long number, i=0, j=0;

   number = 3;
   for(i = 0;; ++i)
   {
      number_text(number);
      number *= 3;

      for (j = 0; j < 9999; ++j);
      for (j = 0; j < 9999; ++j);
      for (j = 0; j < 9999; ++j);
      for (j = 0; j < 9999; ++j);

      MemoryWrite(GPIO0_OUT, number);

      //++number;
   }
}
示例#16
0
/*
 *	SEARCH
 *	FUZZING
 *	- small
 *	- lager
 *	- equal
 *	- notequal
 *	WRITE
 *	PROCESS(Process List)
 *	THREADLIST
 *	ATTACH
 *	CONTROL
 *	- STOP
 *	- START
 *	SHOWLIST(Data List)
 *	CLEAR
 *	EXIT
 */
int main(int argc, const char* argv[]) {

	getUUID();

	char message[BUFSIZE];
	char command1[BUFSIZE] = { '\0', }, command2[BUFSIZE] = { '\0', },command3[BUFSIZE] = { '\0', };

	while (1) {
		printf("Lazenca$ ");
		fgets(message, BUFSIZE, stdin);
		fflush (stdin);

		//입력값이 있는지 없는지 확인
		if (strlen(message) > 1) {
			sscanf(message, "%s%s%s", command1, command2, command3);
			/*printf("command1 : %s, command2 : %s, command3 : %s\n",
			 strupr(command1), command2, command3);*/

			//Process Attach
			if (!strcmp(ATTACH, strupr(command1))) {
				ListClear();
				ProcAttach(command2);
				continue;
				//Process List
			} else if (!strcmp(PROCESSLIST, strupr(command1))) {
				showProcessList();
				continue;
				//Process Exit
			} else if (!strcmp(EXIT, strupr(command1))) {
				exit(0);
			}

			char tempPath[256];
			sprintf(tempPath, "/proc/%d", privatePid);
			if (checkDir(tempPath)) {
				//검색
				if (!strcmp(SEARCH, strupr(command1))) {
					MemorySearch(command2);
					//퍼징
				} else if (!strcmp(FUZZING, strupr(command1))) {
					MemoryFuzzing(command2);
					//값 변경
				} else if (!strcmp(WRITE, strupr(command1))) {
					MemoryWrite(command2, command3);
					//Thread List
				} else if (!strcmp(THREADLIST, strupr(command1))) {
					showThreadList();
					//Process Control
				} else if (!strcmp(CONTROL, strupr(command1))) {
					ThreadControl(command2, command3);
					//Data List
				} else if (!strcmp(DATALIST, strupr(command1))) {
					ShowDataList();
					//Data List Clear
				} else if (!strcmp(CLEAR, strupr(command1))) {
					ListClear();
					//Data Lock
				} else if (!strcmp(DATALOCK, strupr(command1))) {
					DataLock(command2);
				} else if (!strcmp(LOCKLIST, strupr(command1))) {
					ShowLockDataList();
				} else {
					printf("Main Command Input Error!\n");
				}
			} else {
				ListClear();
				printf("%s\n", errorMsgPid);
			}
		}
	}
	return 0;
}
示例#17
0
static trap_elen WriteMemory( addr48_ptr *addr, void *data, trap_elen len )
/*************************************************************************/
{
    return( MemoryWrite( addr->offset, addr->segment, data, len ) );
}
void _putchar(int32_t value){		// polled putchar()
	MemoryWrite(DEBUG_ADDR, value);
}
void _putchar(int32_t value){		// polled putchar()
	while((MemoryRead(IRQ_CAUSE) & IRQ_UART_WRITE_AVAILABLE) == 0);
	MemoryWrite(UART_WRITE, value);
}
示例#20
0
文件: monitor.c 项目: inouema/toppers
/*
 *  設定コマンド
 */
static UW
set_command(B *command)
{
	INT  point=0;
	B    cmd=0;
	UB   b;
	UH   h;
	UW   w, value1, value2;
	int  no, count;
	BOOL cont;

	count = sizeof(mon_set) / sizeof(struct SUBCOMMAND_TABLE);
	if(command[point]){
		for(no = 0 ; no < count ; no++){
			if(compare_word(mon_set[no].subcommand, command, 0)){
				skip_word(command, &point);
				cmd = mon_set[no].type;
				break;
			}
		}
	}
	switch(cmd){
	default:						/* デフォルト */
		cmd = mon_datatype;
	case MONSET_BYTE:				/* バイト単位メモリ設定 */
	case MONSET_HALF:				/* ハーフ単位メモリ設定 */
	case MONSET_WORD:				/* ワード単位メモリ設定 */
		if(!get_value(command, &point, &value1, HEX_BASE))
			value1 = mon_address;
		value1 = MonAlignAddress(value1);
		mon_datatype = cmd;
		do{
			printf("  %08lx", (unsigned long)value1);
			switch(mon_datatype){
			case DATA_HALF:
				if(MemoryRead(value1, &h, 2) == 0)
					h = -1;
				printf(" %04x =", h);
				break;
			case DATA_WORD:
				if(MemoryRead(value1, &w, 4) == 0)
					w = -1;
				printf(" %08lx =", (unsigned long)w);
				break;
			default:
				if(MemoryRead(value1, &b, 1) == 0)
					b = -1;
				printf(" %02x =", b);
				break;
			}
			monitor_getstring(mon_command, &point);
			if(get_value(mon_command, &point, &value2, HEX_BASE)){
				switch(mon_datatype){
				case DATA_HALF:
					h = value2;
					MemoryWrite(value1, &h, 2);
					if(MemoryRead(value1, &h, 2) == 0)
						h = -1;
					printf(" %04x\n", h);
					break;
				case DATA_WORD:
					w = value2;
					MemoryWrite(value1, &w, 4);
					if(MemoryRead(value1, &w, 4) == 0)
						w = -1;
					printf(" %08lx\n", (unsigned long)w);
					break;
				default:
					b = value2;
					MemoryWrite(value1, &b, 1);
					if(MemoryRead(value1, &b, 1) == 0)
						b = -1;
					printf(" %02x\n", b);
					break;
				}
				value1 += mon_datatype;
				cont = TRUE;
			}
			else
				cont = FALSE;
		}while(cont || point == 0);
		putchar('\n');
		mon_address = value1;
		break;
	case MONSET_COMMAND:			/* コマンドモード設定 */
		if(get_value(command, &point, &value1, DEC_BASE)){
			if(value1 == 1 || value1 == 2){
				printf("  set %d command(s) mode !\n", value1);
				mon_mode = value1;
			}
		}
		printf("  set command mode=%d word(s) !\n", mon_mode);
		break;
	case MONSET_SERIAL:				/* シリアル設定 */
		if(get_value(command, &point, &value1, DEC_BASE)){
			if(value1 > 0 && mon_portid != value1){
				if(mon_portid != mon_default_portid && mon_portid != CONSOLE_PORTID)
					syscall(serial_cls_por(mon_portid));
				mon_portid = value1;
				if(mon_portid != mon_default_portid && mon_portid != CONSOLE_PORTID)
					syscall(serial_opn_por(mon_portid));
				syscall(serial_ctl_por(mon_portid, (IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV)));
				printf(banner,
					(TMONITOR_PRVER >> 12) & 0x0f,
					(TMONITOR_PRVER >> 4) & 0xff,
					TMONITOR_PRVER & 0x0f);
			}
		}
		printf("  set serial port id=%d !\n", mon_portid);
		break;
	case MONSET_TASK:				/* タスク選択 */
		if(get_value(command, &point, &value1, DEC_BASE)){
			if(value1 >= TMIN_TSKID && value1 < (TMIN_TSKID+tmax_tskid))
				current_tskid = value1;
			else
				current_tskid = MONTASK;
		}
		else
			current_tskid = MONTASK;
		break;
	case MONSET_IN:					/* 入力設定 */
		value1 = 0;
		get_value(command, &point, &value1, DEC_BASE);
		if(value1 == 1)
			mon_infile = stdout;
		else if(value1 == 2)
			mon_infile = stderr;
		else
			mon_infile = stdin;
		break;
	}
	return 0;
}
示例#21
0
static inline void NocWrite(uint16_t data){
	MemoryWrite(NOC_WRITE, data);
	asm ("nop\nnop\nnop");
}
示例#22
0
static unsigned WriteMemory( addr48_ptr *addr, void *data, unsigned len )
/***********************************************************************/
{
    return( MemoryWrite( addr->offset, addr->segment, data, len ) );
}
示例#23
0
//pulse LCD_E High for 12 clock cycles for 50 MHz
void HoldPulse_e12CC(void) {
  int i;
  MemoryWrite(GPIO0_OUT, LCD_E);
  for(i=0;i<12/4;i++){}
  MemoryWrite(GPIO0_CLEAR,LCD_E);
}
示例#24
0
void USBUpdate()
{
	int a,b;
    // User Application USB tasks
    if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;
    
    if(!HIDRxHandleBusy(USBOutHandle))				//Check if data was received from the host.
    {   
        switch(ReceivedDataBuffer[0])				//Look at the data the host sent, to see what kind of application specific command it sent.
        {
			case 0x01:
				a=EPPoll(*(int16*)&ReceivedDataBuffer[1]);
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x03;
					if(a!=0)
						ToSendDataBuffer[1]=0;
					else
						ToSendDataBuffer[1]=255;
					USBWrite();
                }
				break;
			case 0x02:
				EPBufferSize=ReceivedDataBuffer[3];
				for(a=0;a<EPBufferSize;a++)Set8(a,ReceivedDataBuffer[a+4]);
				EPSend(*(int16*)&ReceivedDataBuffer[1]);
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x02;
                    USBWrite();
                }
				break;
			case 0x06:
				ToSendDataBuffer[1]=KismetExecuteEvent(((int16*)&ReceivedDataBuffer[1])[0],ReceivedDataBuffer[3]);
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x06;
                    USBWrite();
                }
				break;
			case 0x07:
				OperationEnabled=0;
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x07;
                    USBWrite();
                }
				break;
			case 0x08:
				OperationEnabled=0xff;
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x08;
                    USBWrite();
                }
				break;
			case 0x03://EEPROM Write
				MemoryBeginWrite(((int16*)&ReceivedDataBuffer[1])[0]);
				MemoryWrite(ReceivedDataBuffer[3]);
				MemoryEndWrite();
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x03;
                    USBWrite();
                }
				break;
			case 0x04://EEPROM WRITE PAGE
				MemoryBeginWrite(((int16*)&ReceivedDataBuffer[1])[0]);
				for(a=0;a<32;a++)
					MemoryWrite(ReceivedDataBuffer[3+a]);
				MemoryEndWrite();
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x04;
                    USBWrite();
                }
				break;
			case 0x05://EEPROM READ
				if(!USBBusy())
                {
					MemoryBeginRead(((int16*)&ReceivedDataBuffer[1])[0]);
					ToSendDataBuffer[0]=0x05;
					ToSendDataBuffer[1]=MemoryReadInt8();
					MemoryEndRead();
                    USBWrite();
                }
				break;
			case 0x40://READ TIME
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x40;
					ToSendDataBuffer[1]=RTCSecond;
					ToSendDataBuffer[2]=RTCMinute;
					ToSendDataBuffer[3]=RTCHour;
					INT16(ToSendDataBuffer[4])=RTCDay;
					USBWrite();
                }
				break;
			case 0x41://WRITE TIME
				RTCSecond	=ReceivedDataBuffer[1];
				RTCMinute	=ReceivedDataBuffer[2];
				RTCHour		=ReceivedDataBuffer[3];
				RTCDay		=INT16(ReceivedDataBuffer[4]);
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x41;
					USBWrite();
                }
				break;
			case 0x50://SET TIMER
				SetTimer(ReceivedDataBuffer[1],ReceivedDataBuffer[2],INT16(ReceivedDataBuffer[3]));
				if(!USBBusy())
                {
					ToSendDataBuffer[0]=0x50;
					USBWrite();
                }
				break;
        }

        if(!HIDTxHandleBusy(USBInHandle))
        {
            USBInHandle = HIDTxPacket(HID_EP,(BYTE*)&ToSendDataBuffer[0],64);
        }
		ReceivedDataBuffer[0]=0;
        //Re-arm the OUT endpoint for the next packet
        USBOutHandle = HIDRxPacket(HID_EP,(BYTE*)&ReceivedDataBuffer,64);
    }
}