Exemple #1
0
int io_read(short size, uint32_t addr, uint32_t * value){
	void * state;
	switch(size){
		case 8:
			*value = io_read_byte (addr);
			break;
		case 16:
			*value = io_read_halfword(addr);
			break;
		case 32:
			*value = io_read_word(addr);
			break;
		default:
			return -1;
	}
	return 0;
}
UINT8 h8_register_read8(UINT32 address)
{
	UINT8 val;
	UINT8 reg;

	address &= 0xffffff;

	reg = address & 0xff;

	if(reg >= 0x60 && reg <= 0x9f)
	{
		return h8_itu_read8(reg);
	}
	else
	{
		switch(reg)
		{
		case 0xb4: // serial port A status
			val = h8.per_regs[reg];
			val |= 0xc4;		// transmit finished, receive ready, no errors
			break;
		case 0xb5: // serial port A receive
			val = io_read_byte(H8_SERIAL_A);
			break;
		case 0xbc: // serial port B status
			val = h8.per_regs[reg];
			val |= 0xc4;		// transmit finished, receive ready, no errors
			break;
		case 0xbd: // serial port B receive
			val = io_read_byte(H8_SERIAL_B);
			break;
		case 0xe0:
			val = io_read_byte_8(H8_ADC_0_H);
			break;
		case 0xe1:
			val = io_read_byte_8(H8_ADC_0_L);
			break;
		case 0xe2:
			val = io_read_byte_8(H8_ADC_1_H);
			break;
		case 0xe3:
			val = io_read_byte_8(H8_ADC_1_L);
			break;
		case 0xe4:
			val = io_read_byte_8(H8_ADC_2_H);
			break;
		case 0xe5:
			val = io_read_byte_8(H8_ADC_2_L);
			break;
		case 0xe6:
			val = io_read_byte_8(H8_ADC_3_H);
			break;
		case 0xe7:
			val = io_read_byte_8(H8_ADC_3_L);
			break;
		case 0xe8:		// adc status
			val = 0x80;
			break;
		case 0xc7:    		// port 4 data
			val = io_read_byte_8(H8_PORT4);
			break;
		case 0xcb:    		// port 6 data
			val = io_read_byte_8(H8_PORT6);
			break;
		case 0xce:		// port 7 data
			val = io_read_byte_8(H8_PORT7);
			break;
		case 0xcf:		// port 8 data
			val = io_read_byte_8(H8_PORT8);
			break;
		case 0xd2:		// port 9 data
			val = io_read_byte_8(H8_PORT9);
			break;
		case 0xd3:		// port a data
			val = io_read_byte_8(H8_PORTA);
			break;
		case 0xd6:		// port b data
			val = io_read_byte_8(H8_PORTB);
			break;
		default:
			val = h8.per_regs[reg];
			break;
		}
	}

	return val;
}
Exemple #3
0
CallBack events_swi_cm920iap_handler (int swi_number, SwiRegs *r) 
{
  switch (swi_number) 
  {

  /**********************************************************************
   * SLOS SWI's 
   **********************************************************************/

  case /* SWI */ SLOS:

    switch (r->r[0]) 
    {

    /* -----------------------------------------------------------------
     * Low level Debug SWI for debugging before the operating system is
     * up and running. The following register hold the debug information.
     *
     *  r8fiq  - fatal error 
     *  r9fiq  - trace entry value
     *  r10fiq - trace exit value
     *
     * -----------------------------------------------------------------
     */
    
    case /* SWI */ BringUp_Trace: 

      switch (r->r[1])
      {
      case 123: /* ENTRY into routine ...................... */
      bringupSetR9fiq (r->r[2]);
      break;

      case 321: /* EXIT into routine ....................... */
      bringupSetR10fiq (r->r[2]);
      break;
      }

    break;

    case /* SWI */ BringUp_FatalError:   
    bringupSetR8fiq (r->r[1]);
     
    fatalerror: goto fatalerror; /* setup infinite loop ... */
     
    break;

    /* -----------------------------------------------------------------
     * Device Driver SWI's for controlling and initializing device
     * drivers
     * -----------------------------------------------------------------
     */

    case /* SWI */ Event_IODeviceInit:
    io_initialize_drivers ();
    break;
 
    default:

    /* ----------------------------------------------------------------
     * switch to SYSTEM mode and switch ON IRQ interrupts. 
     * ----------------------------------------------------------------
     */

    if (STATE!=1) {modifyControlCPSR (SYSTEM|IRQoN);}

      switch (r->r[0]) 
      {
		  
      case /* SWI */ Event_IODeviceOpen:
      r->r[0] = (unsigned int) io_open_driver ((UID *)r->r[1],r->r[2],r->r[3]);
      break;

      case /* SWI */ Event_IODeviceClose:
      r->r[0] = (unsigned int) io_close_driver ((device_treestr *)r->r[1],(UID)r->r[2]);
      break;
	
      case /* SWI */ Event_IODeviceWriteByte:
      io_write_byte ((device_treestr *)r->r[1],(UID)r->r[2],(BYTE)r->r[3]);
      break;
	
      case /* SWI */ Event_IODeviceReadByte:
      r->r[0] = (unsigned int) io_read_byte ((device_treestr *)r->r[1],(UID)r->r[2]);
      break;

      case /* SWI */ Event_IODeviceWriteBit:
      io_write_bit ((device_treestr *)r->r[1],(UID)r->r[2],(UINT)r->r[3]);
      break;

      case /* SWI */ Event_IODeviceReadBit:
      r->r[0] = (unsigned int) io_read_bit ((device_treestr *)r->r[1],(UID)r->r[2]);
      break;

      case /* SWI */ Event_IODeviceWriteBlock:
      io_write_block ((device_treestr *)r->r[1],(UID)r->r[2],(void *)r->r[3]);
      break;

      case /* SWI */ Event_IODeviceReadBlock:
      r->r[0] = (unsigned int) io_read_block ((device_treestr *)r->r[1],(UID)r->r[2]);
      break;
      
      }

    if (STATE!=1) {modifyControlCPSR (SVC|IRQoFF);}
    }  
 }

return ReportOK();
}