Example #1
0
uint_32 _psp_get_sr
   (
      void
   )
{ /* Body */
   uint_32 old_sr_value;

   _PSP_GET_SR(old_sr_value);
   return(old_sr_value);

} /* Endbody */
Example #2
0
uint_32 _psp_set_sr
   (
      /* [IN] the new value for the status register */
      uint_32 sr_value
   )
{ /* Body */
   uint_32 old_sr_value;

   _PSP_GET_SR(old_sr_value);
   _PSP_SET_SR(sr_value);
   return(old_sr_value);

} /* Endbody */
Example #3
0
uint_32 _bsp_enable_card
   (
      void
   )
{
    KERNEL_DATA_STRUCT_PTR        kernel_data;
    uint_32                       result;

    /* Enable Timer */
    _e200_enable_timer(BSP_TIMEBASE_USES_EXTERNAL_CLK);

    if (_psp_core_num()==0) {
        P1_Start( __boot);
    }

    _GET_KERNEL_DATA(kernel_data);

    _mqx_set_cpu_type(MQX_CPU);

    /* Set the bsp exit handler, called by _mqx_exit */
    _mqx_set_exit_handler(_bsp_exit_handler);

    /* Initialize the MPXSxx support functions */
    _mpxsxx_initialize_support();


    /* Initialize the interrupt handling */
    result =  _psp_int_init(BSP_FIRST_INTERRUPT_VECTOR_USED, BSP_LAST_INTERRUPT_VECTOR_USED);
    if (result != MQX_OK) {
        return result;
    }

    /* Initialize peripheral bridge */
    //_qpbridge_init(pbridge_mprot_config, ELEMENTS_OF(pbridge_mprot_config));

    /* Initialize Enhanced Interrupt Controller */
    result =  _qintc_install(_bsp_get_qintc_base_address(), PSP_EXCPT_EXTERNAL);
    if (result != MQX_OK) {
        return result;
    }

    /* enable processor recognition of External/Decrementer/Fit interrupts */
    _PSP_SET_SR (_PSP_GET_SR() | PSP_MSR_EE);

#if BSPCFG_ENABLE_PIT_TIMER
    _qpit_timer_install_kernel(BSPCFG_TIMER_PIT_DEVICE, BSPCFG_TIMER_PIT_CHANNEL,BSP_ALARM_FREQUENCY, BSP_PERI1_CLOCK, BSPCFG_TIMER_INT_LEVEL);
    //_e200_decrementer_null_install();
#else
    _e200_decrementer_timer_install(BSP_ALARM_FREQUENCY, BSP_TIMEBASE_CLOCK);
#endif


    /*------------------------------------------------------------------------*/
    /*
    ** Setup MMU page tables
    */

    if (_mqx_monitor_type == MQX_MONITOR_TYPE_NONE) {
        _mmu_init(NULL);
        // First, mark the three TLBs that the boot code used as 'not-free'
        _mmu_reserve_tlb(BSP_FLASH_TLB);
        _mmu_reserve_tlb(BSP_RAM_TLB);
        _mmu_reserve_tlb(BSP_PERIPHERAL_TLB);

        // Next, add regions for RAM.
        //                        Physical Address                  Virtual Address              Size                    Attributes
        _mmu_add_virtual_region(_bsp_vtop(BSP_PRIVATE_RAM_START),  BSP_PRIVATE_RAM_START,       BSP_PRIVATE_RAM_SIZE,   BSP_PRIVATE_RAM_ATTR,        BSP_PID_MQX);
        _mmu_add_virtual_region(_bsp_vtop(BSP_SHARED_RAM_START),   BSP_SHARED_RAM_START,        BSP_SHARED_RAM_SIZE,    BSP_SHARED_RAM_ATTR,         BSP_PID_MQX);
        _mmu_add_virtual_region(_bsp_vtopr(BSP_PRIVATE_RAM_START), BSP_REMOTE_PRIVATE_RAM_START,BSP_PRIVATE_RAM_SIZE,   BSP_REMOTE_PRIVATE_RAM_ATTR, BSP_PID_MQX);
        _mmu_add_virtual_region(_bsp_vtopr(BSP_SHARED_RAM_START),  BSP_REMOTE_SHARED_RAM_START, BSP_SHARED_RAM_SIZE,    BSP_SHARED_RAM_ATTR,         BSP_PID_MQX);
        _mmu_add_virtual_region(_bsp_vtop(BSP_UNCACHED_DATA_START),BSP_UNCACHED_DATA_START,     BSP_UNCACHED_DATA_SIZE, BSP_UNCACHED_DATA_ATTR,      BSP_PID_MQX);

        // switch PID from 1 (boot) to 2 (MQX)
        _psp_set_pid(BSP_PID_MQX);

        // Reclaim the BOOT RAM TLB
        _mmu_release_tlb(BSP_RAM_TLB);

#ifndef BSP_CACHE_INHIBIT
        _icache_enable(0);
        _dcache_enable(0);
#endif
    }


#if BSPCFG_ENABLE_CPP
    /* initialize C++ constructors */
#if defined(__DCC__) || defined(__HIGHC__)
    __init();
#elif defined(__CODEWARRIOR__)
    __cpp_init();
#endif
#endif

#if BSPCFG_CORE_MUTEX
    result = _core_mutex_install(&_core_mutex_init_info);
    if (result != MQX_OK) {
        return result;
    }
#endif

    /*------------------------------------------------------------------------*/
    /*
    ** Initialize the I/O Sub-system
    */
    #if BSPCFG_ENABLE_IO_SUBSYSTEM
        /* Initialize the I/O Sub-system */
        result = _io_init();
        if (result != MQX_OK) {
            return result;
        }

     #if PSP_HAS_DEVICE_PROTECTION
     if (!_bsp_lwgpio_enable_access(0)) {
         return MQX_INVALID_DEVICE;
     }
     #endif

        /* Install device drivers */
        #if BSPCFG_ENABLE_TTYA
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_0)) {
                _linflexd_serial_polled_install("ttya:", &_bsp_linflexd0_init);
            }
        #endif
        #if BSPCFG_ENABLE_ITTYA
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_0)) {
                _linflexd_serial_int_install("ittya:", &_bsp_linflexd0_init);
            }
        #endif

        #if BSPCFG_ENABLE_TTYB
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_1)) {
                _linflexd_serial_polled_install("ttyb:", &_bsp_linflexd1_init);
            }
        #endif
        #if BSPCFG_ENABLE_ITTYB
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_1)) {
                _linflexd_serial_int_install("ittyb:", &_bsp_linflexd1_init);
            }
        #endif

        #if BSPCFG_ENABLE_TTYC
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_2)) {
                _linflexd_serial_polled_install("ttyc:", &_bsp_linflexd2_init);
            }
        #endif
        #if BSPCFG_ENABLE_ITTYC
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_2)) {
                _linflexd_serial_int_install("ittyc:", &_bsp_linflexd2_init);
            }
        #endif

        #if BSPCFG_ENABLE_TTYD
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_3)) {
                _linflexd_serial_polled_install("ttyd:", &_bsp_linflexd3_init);
            }
        #endif
        #if BSPCFG_ENABLE_ITTYD
            if (_psp_core_peripheral_enabled(CORECFG_LINFLEX_3)) {
            _linflexd_serial_int_install("ittyd:", &_bsp_linflexd3_init);
            }
        #endif

        #if BSPCFG_ENABLE_SPI0
            if (_psp_core_peripheral_enabled(CORECFG_SPI_0)) {
                _io_spi_install("spi0:", &_bsp_spi0_init);
            }
        #endif

        #if BSPCFG_ENABLE_SPI1
            if (_psp_core_peripheral_enabled(CORECFG_SPI_1)) {
                _io_spi_install("spi1:", &_bsp_spi1_init);
            }
        #endif

        #if BSPCFG_ENABLE_SPI2
            if (_psp_core_peripheral_enabled(CORECFG_SPI_2)) {
                _io_spi_install("spi2:", &_bsp_spi2_init);
            }
        #endif
        
        #if BSPCFG_ENABLE_I2C0
            if (_psp_core_peripheral_enabled(CORECFG_I2C_0)) {
                _qi2c_polled_install("i2c0:", &_bsp_i2c0_init);
            }
        #endif
        #if BSPCFG_ENABLE_II2C0
            if (_psp_core_peripheral_enabled(CORECFG_I2C_0)) {
                _qi2c_int_install("ii2c0:", &_bsp_i2c0_init);
            }
        #endif
        #if BSPCFG_ENABLE_I2C1
            if (_psp_core_peripheral_enabled(CORECFG_I2C_1)) {
                _qi2c_polled_install("i2c1:", &_bsp_i2c1_init);
            }
        #endif
        #if BSPCFG_ENABLE_II2C1
            if (_psp_core_peripheral_enabled(CORECFG_I2C_1)) {
                _qi2c_int_install("ii2c1:", &_bsp_i2c1_init);
            }
        #endif
        #if BSPCFG_ENABLE_I2C2
            if (_psp_core_peripheral_enabled(CORECFG_I2C_2)) {
                _qi2c_polled_install("i2c2:", &_bsp_i2c2_init);
            }
        #endif
        #if BSPCFG_ENABLE_II2C2
            if (_psp_core_peripheral_enabled(CORECFG_I2C_2)) {
                _qi2c_int_install("ii2c2:", &_bsp_i2c2_init);
            }
        #endif

        #if BSPCFG_ENABLE_FLASHX
            _io_flashx_install("flashx:", &_bsp_data_flashx_init);
            /* code flash support in alpha stage, not tested! */
            /* _io_flashx_install("flashx_code:", &_bsp_code_flashx_init); */
        #endif

        #if BSPCFG_ENABLE_LWADC
            #if BSPCFG_ENABLE_LWADC0
            if (_psp_core_peripheral_enabled(CORECFG_ADC_0)) {
                    _lwadc_init(&lwadc0_init);
            }
            #endif
            #if BSPCFG_ENABLE_LWADC1
                if (_psp_core_peripheral_enabled(CORECFG_ADC_1)) {
                    _lwadc_init(&lwadc1_init);
                }
            #endif
            #if BSPCFG_ENABLE_LWADC2
                if (_psp_core_peripheral_enabled(CORECFG_ADC_2)) {
                    _lwadc_init(&lwadc2_init);
                }
            #endif
            #if BSPCFG_ENABLE_LWADC3
                if (_psp_core_peripheral_enabled(CORECFG_ADC_3)) {
                    _lwadc_init(&lwadc3_init);
                }
            #endif
        #endif

        #ifdef BSP_DEFAULT_IO_CHANNEL_DEFINED
            /* Initialize the default serial I/O */
            _io_serial_default_init();
        #endif
   #endif
   return MQX_OK;
}
Example #4
0
uint_32 _bsp_enable_card
    (
        void
    )
{
    KERNEL_DATA_STRUCT_PTR        kernel_data;
    uint_32                       result;

    _GET_KERNEL_DATA(kernel_data);

    _mqx_set_cpu_type(PSP_CPU_MPXN20);

    /* Set the bsp exit handler, called by _mqx_exit */
    _mqx_set_exit_handler(_bsp_exit_handler);

    /* Initialize the MPXNxx MMU support functions */
    _mpxnxx_initialize_support();

    /* === Debugging is not allowed from here === */
    /* Initialize the interrupt handling */
    result = _psp_int_init(BSP_FIRST_INTERRUPT_VECTOR_USED, BSP_LAST_INTERRUPT_VECTOR_USED);
    /* === Debugging may now resume === */
    if (result != MQX_OK) {
        return result;
    }

    result = _qintc_install(_bsp_get_qintc_base_address(), PSP_EXCPT_EXTERNAL);
    if (result != MQX_OK) {
        return result;
    }

    /* enable processor recognition of External/Decrementer/Fit interrupts */
    _PSP_SET_SR (_PSP_GET_SR() | PSP_MSR_EE);

#if 0
    /* Install program exception handler */
    if (_int_install_isr(PSP_EXCPT_PROGRAM, _psp_program_isr, NULL) == NULL)
    {
        return _task_get_error();
    }
#endif

#if BSPCFG_ENABLE_PIT_TIMER
    _qpit_timer_install_kernel(BSPCFG_TIMER_PIT_DEVICE, BSPCFG_TIMER_PIT_CHANNEL, BSP_ALARM_FREQUENCY, BSP_SYSTEM_CLOCK, BSPCFG_TIMER_INT_LEVEL);
#else
    _e200_decrementer_timer_install(BSP_ALARM_FREQUENCY, BSP_TIMEBASE_CLOCK);
#endif

    /*------------------------------------------------------------------------*/
    /*
     ** Setup MMU page tables
     */

    if (_mqx_monitor_type == MQX_MONITOR_TYPE_NONE) {
        _mmu_init(NULL);
        /* First, mark the three TLBs that the boot code used as 'not-free' */
        _mmu_reserve_tlb(BSP_FLASH_TLB);
        _mmu_reserve_tlb(BSP_INT_SRAM_TLB);
        
        /* Periph B Modules */
        _mmu_reserve_tlb(BSP_PERIPHERAL_TLB); 
        _mmu_reserve_tlb(BSP_EXT_RAM_TLB);

        _mmu_reserve_tlb(BSP_PERIPHERAL_A_TLB);
        
        /* Next, add regions for RAM.
         **                        Physical Address       Virtual Address              Size                    Attributes
         */
        //_mmu_add_virtual_region((BSP_PRIVATE_RAM_START),  BSP_PRIVATE_RAM_START,       BSP_PRIVATE_RAM_SIZE,   BSP_PRIVATE_RAM_ATTR,        BSP_PID_MQX);                
        //_mmu_add_virtual_region((BSP_UNCACHED_DATA_START),BSP_UNCACHED_DATA_START,     BSP_UNCACHED_DATA_SIZE, BSP_UNCACHED_DATA_ATTR,      BSP_PID_MQX);
                
        /* switch PID from 1 (boot) to 2 (MQX) */
        /*_psp_set_pid(BSP_PID_MQX);*/
               
         /*Reclaim the BOOT RAM TLB*/        
        /*_mmu_release_tlb(BSP_RAM_TLB);*/

#ifndef BSP_CACHE_INHIBIT
        _icache_enable(0);
        _dcache_enable(0);
#endif
    } 

#if BSPCFG_ENABLE_CPP

    /* initialize C++ constructors */
#if defined(__DCC__) || defined(__HIGHC__)
    __init();
#elif defined(__CODEWARRIOR__)
    __cpp_init();
#endif

#endif //BSPCFG_ENABLE_CPP
    

#if BSPCFG_ENABLE_IO_SUBSYSTEM
    /*------------------------------------------------------------------------*/
    /*
    ** Initialize the I/O Sub-system
    */
    result = _io_init();
    if (result != MQX_OK) {
        return result;
    } /* Endif */

    /* Install device drivers */

#if BSPCFG_ENABLE_TTYA
    _lin_serial_polled_install("ttya:", &_bsp_lin0_init);
#endif
#if BSPCFG_ENABLE_ITTYA
    _lin_serial_int_install("ittya:", &_bsp_lin0_init);
#endif


#if BSPCFG_ENABLE_TTYB
    _lin_serial_polled_install("ttyb:", &_bsp_lin1_init);
#endif
#if BSPCFG_ENABLE_ITTYB
    _lin_serial_int_install("ittyb:", &_bsp_lin1_init);
#endif

    
#if BSPCFG_ENABLE_TTYC
    _lin_serial_polled_install("ttyc:", &_bsp_lin2_init);
#endif
#if BSPCFG_ENABLE_ITTYC
    _lin_serial_int_install("ittyc:", &_bsp_lin2_init);
#endif

    
#if BSPCFG_ENABLE_TTYD
    _lin_serial_polled_install("ttyd:", &_bsp_lin3_init);
#endif
#if BSPCFG_ENABLE_ITTYD
    _lin_serial_int_install("ittyd:", &_bsp_lin3_init);
#endif

    
#if BSPCFG_ENABLE_TTYE
    _lin_serial_polled_install("ttye:", &_bsp_lin4_init);
#endif
#if BSPCFG_ENABLE_ITTYE
    _lin_serial_int_install("ittye:", &_bsp_lin4_init);
#endif

    
#if BSPCFG_ENABLE_TTYF
    _lin_serial_polled_install("ttyf:", &_bsp_lin5_init);
#endif
#if BSPCFG_ENABLE_ITTYF
    _lin_serial_int_install("ittyf:", &_bsp_lin5_init);
#endif


#if BSPCFG_ENABLE_SPI0
    _io_spi_install("spi0:", &_bsp_spi0_init);
#endif

#if BSPCFG_ENABLE_SPI1
    _io_spi_install("spi1:", &_bsp_spi1_init);
#endif

#if BSPCFG_ENABLE_SPI2
    _io_spi_install("spi2:", &_bsp_spi2_init);
#endif

#if BSPCFG_ENABLE_SPI3
    _io_spi_install("spi3:", &_bsp_spi3_init);
#endif

    
#if BSPCFG_ENABLE_FLASHX
    _io_flashx_install("flashx:", &_bsp_flashx_init);
#endif

    
#if BSPCFG_ENABLE_I2C0
    _qi2c_polled_install("i2c0:", &_bsp_i2c0_init);
#endif
    
#if BSPCFG_ENABLE_II2C0
    _qi2c_int_install("ii2c0:", &_bsp_i2c0_init);
#endif

#if BSPCFG_ENABLE_I2C1
    _qi2c_polled_install("i2c1:", &_bsp_i2c1_init);
#endif
    
#if BSPCFG_ENABLE_II2C1
   _qi2c_int_install("ii2c1:", &_bsp_i2c1_init);
#endif

#if BSPCFG_ENABLE_I2C2
    _qi2c_polled_install("i2c2:", &_bsp_i2c2_init);
#endif

#if BSPCFG_ENABLE_II2C2
   _qi2c_int_install("ii2c2:", &_bsp_i2c2_init);
#endif
   
#if BSPCFG_ENABLE_I2C3
    _qi2c_polled_install("i2c3:", &_bsp_i2c3_init);
#endif

#if BSPCFG_ENABLE_II2C3
   _qi2c_int_install("ii2c3:", &_bsp_i2c3_init);
#endif

#if BSPCFG_ENABLE_RTCDEV
   _rtc_init (RTC_INIT_FLAG_CLEAR | RTC_INIT_FLAG_RESET | RTC_INIT_FLAG_ENABLE);
#endif
   
#if BSPCFG_ENABLE_LWADC
   #if BSPCFG_ENABLE_LWADC0
      _lwadc_init(&lwadc0_init);
   #endif
#endif
      
    /* Initialize the default serial I/O */
    _io_serial_default_init();

#endif // BSPCFG_ENABLE_IO_SUBSYSTEM

    return MQX_OK;
}