rtems_isr_entry set_vector( /* returns old vector */ rtems_isr_entry handler, /* isr routine */ rtems_vector_number vector, /* vector number */ int type /* RTEMS or RAW intr */ ) { rtems_isr_entry previous_isr; uint32_t real_trap; uint32_t source; if ( type ) rtems_interrupt_catch( handler, vector, &previous_isr ); else _CPU_ISR_install_raw_handler( vector, handler, (void *)&previous_isr ); real_trap = SPARC_REAL_TRAP_NUMBER( vector ); if ( LEON_INT_TRAP( real_trap ) ) { source = LEON_TRAP_SOURCE( real_trap ); LEON_Clear_interrupt( source ); LEON_Unmask_interrupt( source ); } return previous_isr; }
int rtems_leon_greth_driver_attach( struct rtems_bsdnet_ifconfig *config, int attach ) { int device_found = 0; unsigned int base_addr = 0; /* avoid warnings */ unsigned int eth_irq = 0; /* avoid warnings */ amba_apb_device apbgreth; /* Scan for MAC AHB slave interface */ device_found = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_ETHMAC,&apbgreth); if (device_found == 1) { base_addr = apbgreth.start; eth_irq = apbgreth.irq + 0x10; /* clear control register and reset NIC */ *(volatile int *) base_addr = 0; *(volatile int *) base_addr = GRETH_CTRL_RST; *(volatile int *) base_addr = 0; leon_greth_configuration.base_address = base_addr; leon_greth_configuration.vector = eth_irq; leon_greth_configuration.txd_count = TDA_COUNT; leon_greth_configuration.rxd_count = RDA_COUNT; if (rtems_greth_driver_attach( config, &leon_greth_configuration )) { LEON_Clear_interrupt(leon_greth_configuration.vector); LEON_Unmask_interrupt(leon_greth_configuration.vector); } } return 0; }
void leon3_secondary_cpu_initialize(uint32_t cpu) { leon3_set_cache_control_register(0x80000F); LEON_Unmask_interrupt(LEON3_MP_IRQ); LEON3_IrqCtrl_Regs->mask[cpu] |= 1 << LEON3_MP_IRQ; _SMP_Start_multitasking_on_secondary_processor(); }
uint32_t _CPU_SMP_Initialize( void ) { if ( !leon3_data_cache_snooping_enabled() ) bsp_fatal( LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR ); if ( rtems_configuration_get_maximum_processors() > 1 ) { LEON_Unmask_interrupt(LEON3_mp_irq); set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_mp_irq), 1); } return leon3_get_cpu_count(LEON3_IrqCtrl_Regs); }
int rtems_leon_open_eth_driver_attach( struct rtems_bsdnet_ifconfig *config, int attach ) { int device_found = 0; int i; unsigned int conf, iobar; unsigned int base_addr = 0; /* avoid warnings */ unsigned int eth_irq = 0; /* avoid warnings */ /* Scan for MAC AHB slave interface */ for (i = 0; i < amba_conf.ahbslv.devnr; i++) { conf = amba_get_confword(amba_conf.ahbslv, i, 0); if (((amba_vendor(conf) == VENDOR_OPENCORES) && (amba_device(conf) == OPENCORES_ETHMAC)) || ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_ETHAHB))) { iobar = amba_ahb_get_membar(amba_conf.ahbslv, i, 0); base_addr = amba_iobar_start(LEON3_IO_AREA, iobar); eth_irq = amba_irq(conf) + 0x10; device_found = 1; break; } } if (device_found) { /* clear control register and reset NIC */ *(volatile int *) base_addr = 0; *(volatile int *) base_addr = 0x800; *(volatile int *) base_addr = 0; leon_open_eth_configuration.base_address = base_addr; leon_open_eth_configuration.vector = eth_irq; leon_open_eth_configuration.txd_count = TDA_COUNT; leon_open_eth_configuration.rxd_count = RDA_COUNT; /* enable 100 MHz operation only if cpu frequency >= 50 MHz */ if (LEON3_Timer_Regs->scaler_reload >= 49) leon_open_eth_configuration.en100MHz = 1; if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) { LEON_Clear_interrupt(leon_open_eth_configuration.vector); LEON_Unmask_interrupt(leon_open_eth_configuration.vector); } } return 0; }
int rtems_leon_open_eth_driver_attach( struct rtems_bsdnet_ifconfig *config, int attach ) { unsigned int base_addr = 0; /* avoid warnings */ unsigned int eth_irq = 0; /* avoid warnings */ struct ambapp_dev *adev; struct ambapp_ahb_info *ahb; /* Scan for MAC AHB slave interface */ adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS), VENDOR_OPENCORES, OPENCORES_ETHMAC, ambapp_find_by_idx, NULL); if (!adev) { adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_AHB_SLVS), VENDOR_GAISLER, GAISLER_ETHAHB, ambapp_find_by_idx, NULL); } if (adev) { ahb = DEV_TO_AHB(adev); base_addr = ahb->start[0]; eth_irq = ahb->irq; /* clear control register and reset NIC */ *(volatile int *) base_addr = 0; *(volatile int *) base_addr = 0x800; *(volatile int *) base_addr = 0; leon_open_eth_configuration.base_address = base_addr; leon_open_eth_configuration.vector = eth_irq + 0x10; leon_open_eth_configuration.txd_count = TDA_COUNT; leon_open_eth_configuration.rxd_count = RDA_COUNT; /* enable 100 MHz operation only if cpu frequency >= 50 MHz */ if (LEON3_Timer_Regs->scaler_reload >= 49) leon_open_eth_configuration.en100MHz = 1; if (rtems_open_eth_driver_attach( config, &leon_open_eth_configuration )) { LEON_Clear_interrupt(eth_irq); LEON_Unmask_interrupt(eth_irq); } } return 0; }
uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count ) { uint32_t max_cpu_count; uint32_t used_cpu_count; uint32_t cpu; leon3_set_cache_control_register(0x80000F); max_cpu_count = leon3_get_cpu_count(LEON3_IrqCtrl_Regs); used_cpu_count = configured_cpu_count < max_cpu_count ? configured_cpu_count : max_cpu_count; #if defined(RTEMS_DEBUG) printk( "Found %d CPUs\n", max_cpu_count ); if ( max_cpu_count > configured_cpu_count ) { printk( "%d CPUs IS MORE THAN CONFIGURED -- ONLY USING %d\n", max_cpu_count, configured_cpu_count ); } #endif if ( used_cpu_count > 1 ) { LEON_Unmask_interrupt(LEON3_MP_IRQ); set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_MP_IRQ), 1); } for ( cpu = 1 ; cpu < used_cpu_count ; ++cpu ) { #if defined(RTEMS_DEBUG) printk( "Waking CPU %d\n", cpu ); #endif LEON3_IrqCtrl_Regs->mpstat = 1 << cpu; } return used_cpu_count; }