예제 #1
0
static void I486OP(cmpxchg_rm8_r8)(i386_state *cpustate)	// Opcode 0x0f b0
{
	UINT8 modrm = FETCH(cpustate);
	if( modrm >= 0xc0 ) {
		UINT8 dst = LOAD_RM8(modrm);
		UINT8 src = LOAD_REG8(modrm);

		if( REG8(AL) == dst ) {
			STORE_RM8(modrm, src);
			cpustate->ZF = 1;
			CYCLES(cpustate,CYCLES_CMPXCHG_REG_REG_T);
		} else {
			REG8(AL) = dst;
			cpustate->ZF = 0;
			CYCLES(cpustate,CYCLES_CMPXCHG_REG_REG_F);
		}
	} else {
		UINT32 ea = GetEA(cpustate,modrm);
		UINT8 dst = READ8(cpustate,ea);
		UINT8 src = LOAD_REG8(modrm);

		if( REG8(AL) == dst ) {
			WRITE8(cpustate,modrm, src);
			cpustate->ZF = 1;
			CYCLES(cpustate,CYCLES_CMPXCHG_REG_MEM_T);
		} else {
			REG8(AL) = dst;
			cpustate->ZF = 0;
			CYCLES(cpustate,CYCLES_CMPXCHG_REG_MEM_F);
		}
	}
}
예제 #2
0
void i386_device::i486_cmpxchg_rm8_r8()    // Opcode 0x0f b0
{
	UINT8 modrm = FETCH();
	if( modrm >= 0xc0 ) {
		UINT8 dst = LOAD_RM8(modrm);
		UINT8 src = LOAD_REG8(modrm);

		if( REG8(AL) == dst ) {
			STORE_RM8(modrm, src);
			m_ZF = 1;
			CYCLES(CYCLES_CMPXCHG_REG_REG_T);
		} else {
			REG8(AL) = dst;
			m_ZF = 0;
			CYCLES(CYCLES_CMPXCHG_REG_REG_F);
		}
	} else {
		// TODO: Check write if needed
		UINT32 ea = GetEA(modrm,0);
		UINT8 dst = READ8(ea);
		UINT8 src = LOAD_REG8(modrm);

		if( REG8(AL) == dst ) {
			WRITE8(ea, src);
			m_ZF = 1;
			CYCLES(CYCLES_CMPXCHG_REG_MEM_T);
		} else {
			REG8(AL) = dst;
			m_ZF = 0;
			CYCLES(CYCLES_CMPXCHG_REG_MEM_F);
		}
	}
}
예제 #3
0
파일: or1k_uart.c 프로젝트: 8l/bomberjacket
int _or1k_uart_init(void)
{
	uint16_t divisor;

	// Is uart present?
	if (!_or1k_board_uart_base) {
			return -1;
	}

	// Reset the callback function
	_or1k_uart_read_cb = 0;

	// Calculate and set divisor
	divisor = _or1k_board_clk_freq / (_or1k_board_uart_baud * 16);
	REG8(LCR) = LCR_DLA;
	REG8(DLB1) = divisor & 0xff;
	REG8(DLB2) = divisor >> 8;

	// Set line control register:
	//  - 8 bits per character
	//  - 1 stop bit
	//  - No parity
	//  - Break disabled
	//  - Disallow access to divisor latch
	REG8(LCR) = LCR_BPC_8;

	// Reset FIFOs and set trigger level to 14 bytes
	REG8(FCR) = FCR_CLRRECV | FCR_CLRTMIT | FCR_TRIG_14;

	// Disable all interrupts
	REG8(IER) = 0;

	return 0;
}
예제 #4
0
int sadDefFunc_NetSemaphore(void) {
  REG8("NetSemTake",	tfNetSemTake,	3, NULL, NULL, 0);
  REG8("NetSemGive",	tfNetSemGive,	2, NULL, NULL, 0);
  REG8("NetSemInfo",	tfNetSemInfo,	3, NULL, NULL, 0);

  return 0;
}
예제 #5
0
파일: i2c.c 프로젝트: aurabindo/aura-soc
void i2c_irq(void)
{
	REG8(I2C_BASE+I2C_CR) = I2C_CR_CLR_IRQ;
	if (i2c_index <= i2c_end )
		i2c_byte_transfer();
	else
	{
		if ( cmd_list[i2c_index-1] == read_lbyte )
			i2c_data[i2c_wr_ptr].data |= REG8(I2C_BASE+I2C_RXR);

		i2c_index = 0;

		if ( i2c_pending_write )
			i2c_wr_done = 1;
		else
		{
			if (i2c_wr_ptr < I2C_BUF_LEN-1)
				i2c_wr_ptr++;
			else
				i2c_wr_ptr = 0;

			if (i2c_wr_ptr == i2c_rd_ptr+1)
			{
				i2c_rd_done = 1;
				i2c_buf_overflow++;
			}
			else
				i2c_rd_done++;
		}
	}
}
예제 #6
0
파일: exerc_6_2.c 프로젝트: origooo/C
__interrupt void ML13_interrupt(void) {
	interruptType = REG8(IRQ);
	switch (interruptType) {
		case DOOR_IS_OPEN: 
			puts("Door is open");
			setTimeout(TIME_OUT);
			REG8(STATUS) = 0x02;
			break;
		case DOOR_IS_CLOSED:
			puts("Door is closed");
			break;
		case SENSOR_B:
			puts("SENSOR B (right) activated");
			REG8(STATUS) = 0x01;
			break;
		case SENSOR_A:
			puts("SENSOR A (left) activated");
			REG8(STATUS) = 0x01;
			break;
		case IS_OPENING:
			puts("Door is opening");
			break;
		case IS_CLOSING: 
			puts("Door is closing");
			break;
		default: 
			printf("\tInterruptType = %#X",interruptType<<0);
			break;
	}
	REG8(IRQ) = 0x00;
}
예제 #7
0
void _or1k_uart_write(char c)
{
	// Wait until FIFO is empty
	while (!(REG8(LSR) & LSR_TFE)) {}

	// Write character to device
	REG8(THR) = c;
}
예제 #8
0
파일: tfPyInter_.c 프로젝트: KatsOide/SAD
int sadDefFunc_PyInter(void) {
  int id;

  id = REG8("PyEvalString",	tfPyEvalString,	   1, NULL, NULL, 0);
  id = REG8("PyShutDown",	tfPyShutDown,	   0, NULL, NULL, 0);

  return 0;
}
예제 #9
0
// ------------------------ usbInit -----------------------------
char usb_host_init(int core)
{
	volatile int i;

	// Reset the thing
	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HOST_SLAVE_MODE) = 0x2;

	// Wait 10 USB cycles ( this should be plenty)
	for (i = 0; i < 8; i++) ;

	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HC_INTERRUPT_MASK_REG) = 0x00;	// Disable interrupts

	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HC_INTERRUPT_STATUS_REG) = 0xff;	// Clear interrupt statuses

	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HC_TX_LINE_CONTROL_REG) = 0x00;	// low speed normal

	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HC_TX_SOF_ENABLE_REG) = 0x00;	// No SOF

	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HOST_SLAVE_MODE) = 0x01;	// Set core to HOST mode

	// Reset RX FIFO buffer
	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HC_RX_FIFO_CONTROL_REG) =
	    0xff;
	// Reset TX FIFO buffer
	REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HC_TX_FIFO_CONTROL_REG) =
	    0xff;

	// Return version number reg
	return REG8(USBHOSTSLAVE_HOST_CORE_ADR[core] + RA_HOST_SLAVE_VERSION);

}
예제 #10
0
파일: i2c.c 프로젝트: aurabindo/aura-soc
void i2c_byte_transfer(void)
{
	if ( i2c_index > 0 )
		if ( cmd_list[i2c_index-1] == read_hbyte )
			i2c_data[i2c_wr_ptr].data = (REG8(I2C_BASE+I2C_RXR) << 8) & 0xFF00;

	REG8(I2C_BASE+I2C_TXR) = dat_list[i2c_index];
	REG8(I2C_BASE+I2C_CR) = cmd_list[i2c_index];

	i2c_index++;
}
예제 #11
0
파일: i2c.c 프로젝트: aurabindo/aura-soc
void i2c_init(void)
{
	REG8(I2C_BASE+I2C_PRESC_HI) = 0x00;
	REG8(I2C_BASE+I2C_PRESC_LO) = 49;       //100kHz
	REG8(I2C_BASE+I2C_CTR) = I2C_CTR_EN | I2C_CTR_IRQ_EN;
	i2c_rd_done = 0;
	i2c_wr_done = 0;
	i2c_index = 0;
	i2c_wr_ptr = 0;
	i2c_rd_ptr = 0;
	i2c_buf_overflow = 0;
}
예제 #12
0
파일: led.c 프로젝트: DayUpWoniu/orpsoc
int main()
{
	int i, j;
	REG8(LED_BASE) = 0x01;
	while (1)
	{
		for(i=0;i<8;i++)
		{
			for(j=0;j<IN_CLK/16;j++);// delay
			REG8(LED_BASE) = 1<<i;
		}
	}
}
예제 #13
0
/**
 * This is the interrupt handler that is registered for the callback
 * function.
 */
void _or1k_uart_interrupt_handler(uint32_t data)
{
	uint8_t iir = REG8(IIR);

	// Check if this is a read fifo or timeout interrupt, bit 0
	// indicates pending interrupt and the other bits are IIR_RDA
	// or IIR_TO
	if (!(iir & 0x1) || ((iir & 0xfe) != IIR_RDA) ||
	    ((iir & 0xfe) != IIR_TO)) {
		return;
	}

	// Read character and call callback function
	_or1k_uart_read_cb(REG8(RB));
}
예제 #14
0
void initIRQ(void){
  SET_IRQ_VECTOR(ML13_interrupt, 0x3FF2);
  __asm(" CLI");
  REG8(ML13_IRQ_Control)= 0x01;
  timerSetup();
  puts("IRQ has been initiated");
}
예제 #15
0
파일: udc.c 프로젝트: HackLinux/jz4725
static void udcWriteFifo(PEPSTATE pep, int size)
{
	unsigned int *d = (unsigned int *)(pep->data_addr + pep->curlen);
	unsigned int fifo = pep->fifo_addr;
	u8 *c;
	int s, q;

#if 0
	unsigned char *ptr =(unsigned char *)d;
	
	dprintf("send:fifo(%x) = (%d)",fifo, size);
	for (s=0;s<size;s++) {
		if (s % 16 == 0)
			dprintf("\n");
		dprintf(" %02x", ptr[s]);
	}
	dprintf("\n");
#endif
	
	if (size > 0) {
		s = size >> 2;
		while (s--)
			REG32(fifo) = *d++;
		q = size & 3;
		if (q) {
			c = (u8 *)d;
			while (q--)
				REG8(fifo) = *c++;
		}
	} 
예제 #16
0
파일: setup.c 프로젝트: Cribstone/linino
static void __init jz_serial_setup(void)
{
#ifdef CONFIG_SERIAL_8250
	struct uart_port s;
	REG8(UART0_FCR) |= UARTFCR_UUE; /* enable UART module */
	memset(&s, 0, sizeof(s));
	s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
	s.iotype = SERIAL_IO_MEM;
	s.regshift = 2;
	s.uartclk = jz4740_clock_bdata.ext_rate;

	s.line = 0;
	s.membase = (u8 *)UART0_BASE;
	s.irq = JZ_IRQ_UART0;
	if (early_serial_setup(&s) != 0) {
		printk(KERN_ERR "Serial ttyS0 setup failed!\n");
	}

	s.line = 1;
	s.membase = (u8 *)UART1_BASE;
	s.irq = JZ_IRQ_UART1;
	if (early_serial_setup(&s) != 0) {
		printk(KERN_ERR "Serial ttyS1 setup failed!\n");
	}
#endif
}
예제 #17
0
파일: i2c.c 프로젝트: cpizano/lk
status_t i2c_transmit(int bus, uint8_t address, const void *buf, size_t count)
{
	status_t err;

	LTRACEF("bus %d, address 0x%hhx, buf %p, count %zd\n", bus, address, buf, count);

	i2c_wait_for_bb(bus);

	I2C_REG(bus, I2C_SA) = address;
	I2C_REG(bus, I2C_CNT) = count;
	I2C_REG(bus, I2C_CON) = (1<<15)|(1<<10)|(1<<9)|(1<<1)|(1<<0); // enable, master, transmit, STP, STT

	lk_time_t t = current_time();

	const uint8_t *ptr = (const uint8_t *)buf;
	for (;;) {
		uint16_t stat = I2C_REG(bus, I2C_STAT);
		if (stat & (1<<1)) {
			// NACK
//			printf("NACK\n");
			err = ERR_GENERIC;
			goto out;
		}
		if (stat & (1<<0)) {
			// AL (arbitration lost)
//			printf("arbitration lost!\n");
			err = ERR_GENERIC;
			goto out;
		}
		if (stat & (1<<2)) {
			// ARDY
//			printf("ARDY, completed\n");
			break;
		}
		if (stat & (1<<4)) {
			// RRDY
//			printf("XRDY\n");

			// transmit a byte
			*REG8(I2C_REG_ADDR(bus, I2C_DATA)) = *ptr;
			ptr++;
		}
		I2C_REG(bus, I2C_STAT) = stat;

		if (current_time() - t > I2C_TIMEOUT) {
//			printf("i2c timeout\n");
			err = ERR_TIMED_OUT;
			goto out;
		}
	}

	err = NO_ERROR;

out:
	I2C_REG(bus, I2C_STAT) = 0xffff;
	I2C_REG(bus, I2C_CNT) = 0;

	return err;
}
예제 #18
0
파일: i2c.c 프로젝트: offchooffcho/lk
int i2c_receive(int bus, uint8_t address, void *buf, size_t count)
{
	int err;

	LTRACEF("bus %d, address 0x%hhx, buf %p, count %zd\n", bus, address, buf, count);
		
	i2c_wait_for_bb(bus);

	I2C_REG(bus, I2C_SA) = address;
	I2C_REG(bus, I2C_CNT) = count;
	I2C_REG(bus, I2C_CON) = (1<<15)|(1<<10)|(1<<1)|(1<<0); // enable, master, STP, STT

	lk_time_t t = current_time();

	uint8_t *ptr = (uint8_t *)buf;
	for(;;) {
		uint16_t stat = I2C_REG(bus, I2C_STAT);
		if (stat & (1<<1)) {
			// NACK
//			printf("NACK\n");
			err = -1;
			goto out;
		}
		if (stat & (1<<0)) {
			// AL (arbitration lost)
//			printf("arbitration lost!\n");
			err = -1;
			goto out;
		}
		if (stat & (1<<2)) {
			// ARDY
//			printf("ARDY, completed\n");
			break;
		}
		if (stat & (1<<3)) {
			// RRDY
//			printf("RRDY\n");

			// read a byte, since our fifo threshold is set to 1 byte
			*ptr = *REG8(I2C_REG_ADDR(bus, I2C_DATA));
			ptr++;
		}
		I2C_REG(bus, I2C_STAT) = stat;

		if (current_time() - t > I2C_TIMEOUT) {
//			printf("i2c timeout\n");
			err = ERR_TIMED_OUT;
			goto out;
		}
	}

	err = 0;

out:
	I2C_REG(bus, I2C_STAT) = 0xffff;
	I2C_REG(bus, I2C_CNT) = 0;

	return err;
}
예제 #19
0
void printChar(reg_t r)
{
  char c = REG8(r);
  size_t n;
  if (transmit(STDOUT, &c, 1, &n) != 0 || n != 1) {
     _terminate(1);
  }
}
예제 #20
0
static uint8_t
rge_reg_get8(rge_t *rgep, uintptr_t regno)
{
	RGE_TRACE(("rge_reg_get8($%p, 0x%lx)",
	    (void *)rgep, regno));

	return (ddi_get8(rgep->io_handle, REG8(rgep, regno)));
}
예제 #21
0
static void
rge_reg_put8(rge_t *rgep, uintptr_t regno, uint8_t data)
{
	RGE_TRACE(("rge_reg_put8($%p, 0x%lx, 0x%x)",
	    (void *)rgep, regno, data));

	ddi_put8(rgep->io_handle, REG8(rgep, regno), data);
}
예제 #22
0
int isNumber(reg_t r, reg_t scratch)
{
  MOVIM8(scratch, '0');
  SUB8(scratch+1, r, scratch);
  MOVIM8(scratch+2, 10);

  LT8(scratch+3, scratch+1, scratch+2);
  return (REG8(scratch+3));
}
예제 #23
0
int isLowLetter(reg_t r, reg_t scratch)
{
  MOVIM8(scratch, 'a');
  MOVIM8(scratch+1, 'z');

  GTE8(scratch+2, r, scratch, scratch+3);
  LTE8(scratch+3, r, scratch+1, scratch+4);
  LAND8(scratch+2, scratch+2, scratch+3);
  return (REG8(scratch+2));
}
예제 #24
0
int isSpace(reg_t r, reg_t scratch)
{
  MOVIM8(scratch, ' ');
  MOVIM8(scratch+1, '\t');

  EQ8(scratch+2, r, scratch);
  EQ8(scratch+3, r, scratch+1);
  LOR8(scratch+2, scratch+2, scratch+3);
  return (REG8(scratch+2));
}
예제 #25
0
int main()
{
  char c;
  char block[512];
  int i;

  uart_init();
  /* version = get_master_version(); */
  /* uart_print_str("0x"); */
  /* uart_print_hex8(version); */
  /* uart_print_str("\n"); */
  
  if (!sd_init())
    uart_print_str("sd card initialized!");
  else uart_print_str("sd card initialisation fails!");
  uart_print_str("\n");

  uart_print_str("Before: RX FIFO entries:");
  while(1)
  c = REG8(SPI_MASTER_BASE+RX_FIFO_DATA_COUNT_MSB);
  uart_print_hex8(c);
  c = REG8(SPI_MASTER_BASE+RX_FIFO_DATA_COUNT_LSB);
  uart_print_hex8(c);
  uart_print_str("\n");

  /* if (!sd_block_write()) */
  /*   uart_print_str("sd card write succeeds!"); */
  /* else uart_print_str("sd card write fails!"); */
  /* uart_print_str("\n"); */

  /* if (!sd_block_read()) */
  /*   uart_print_str("sd card read succeeds!"); */
  /* else uart_print_str("sd card read fails!"); */
  /* uart_print_str("\n"); */
  
  /* for (i=0;i<512;i++) */
  /*   { */
  /*     uart_print_hex8(block[i]); */
  /*     uart_print_str("."); */
  /*   } */
  uart_print_str("\n");
  return 0;
}
예제 #26
0
파일: or1k_uart.c 프로젝트: 8l/bomberjacket
void or1k_uart_set_read_cb(void (*cb)(char c))
{
	_or1k_uart_read_cb = cb;

	// Enable interrupt
	REG8(IER) = 1 << IER_RDAI;

	or1k_interrupt_handler_add(_or1k_board_uart_IRQ,
			_or1k_uart_interrupt_handler, 0);
	or1k_interrupt_enable(_or1k_board_uart_IRQ);
}
예제 #27
0
int prom_putchar(char c)
{
   unsigned int busy_cnt = 0;

   do
   {
      /* Prevent Hanging */
      if (busy_cnt++ >= 30000)
      {
         /* Reset Tx FIFO */
         REG8(UART0_FCR) = TXRST | CHAR_TRIGGER_14;
         return 0;
      }
   } while ((REG8(UART0_LSR) & LSR_THRE) == TxCHAR_AVAIL);

   /* Send Character */
   REG8(UART0_THR) = c;

   return 1;
}
예제 #28
0
파일: exerc_6_1.c 프로젝트: origooo/C
int main() {
	int i = 0;
	
	while(1) {
		if(REG8(STATUS) & DOOR_IS_CLOSED) {
			puts("Door is closed.");
		}
		
		// Person approaching from outside
		if((REG8(STATUS) & BUTTON_A) || (REG8(STATUS) & BUTTON_B)) {
			puts("\tMotion detected...");
			REG8(STATUS) = 0x01;
			for(i = 0; i < 50; i++);
			
		} // Close if nothing is approaching
		else if ((REG8(STATUS) & DOOR_IS_OPEN)){// || REG8(STATUS) == 0x02) {
			puts("\t\tDoor is fully open. Closing...");
			REG8(STATUS) = 0x02;
			for(i = 0; i < 200; i++);
		}
		
		//if(REG8(STATUS) == DOOR_NEARLY_OPEN) {
		//	puts("Door is nearly fully open.");
		//}
		//else if(REG8(STATUS) == DOOR_NEARLY_CLOSED) {
		//	puts("Door is nearly fully closed.");
		//}
	}
	return 0;
}
예제 #29
0
void do_debug()
{
#if 0
	switch (fw_args->debug_ops)
	{
	case 1:      //sdram check
		gpio_init_4760();
		serial_init();
		sdram_init_4760();
		REG8(USB_REG_INDEX) = 1;
		REG32(USB_FIFO_EP1) = check_sdram(fw_args->start, fw_args->size);
		REG32(USB_FIFO_EP1) = 0x0;
		REG8(USB_REG_INCSR) |= USB_INCSR_INPKTRDY;
		break;
	case 2:      //set gpio
		gpio_test(1, fw_args->pin_num);
		break;
	case 3:      //clear gpio
		gpio_test(0, fw_args->pin_num);
		break;
	}
#endif
}
예제 #30
0
파일: exerc_4_5.c 프로젝트: origooo/C
int main( void) {

while(1){

	int i,j,val;
	for(i = 0; i < 4; i++){
		REG8(OUT) = 0x01 << i;
		for(j = 0; j < 4; j++){
		if(!((REG8(IN)) & (0x01 << j))){
			val = 15 - (3-i + j*4);
			
			if(val > 0x09) {
				putchar(val + 55);
			} else {
				putchar(val + 48);
			}
		}
	}
	}
	
}
return(0);
}