From 208cd6b7948675022d8ea9bb394e3610c3607d07 Mon Sep 17 00:00:00 2001 From: Jan Sommer Date: Sun, 31 May 2020 16:22:57 +0200 Subject: bsps/pc386: Separate smp API functions. Makes smpfatal08 link --- bsps/i386/include/bsp/smp-imps.h | 3 +++ bsps/i386/pc386/include/bsp.h | 7 +++++++ bsps/i386/pc386/start/bspsmp.c | 43 ++++++++++++++++++++++++++++++++++++++++ bsps/i386/pc386/start/getcpuid.c | 22 -------------------- bsps/i386/pc386/start/smp-imps.c | 40 +++++++------------------------------ 5 files changed, 60 insertions(+), 55 deletions(-) create mode 100644 bsps/i386/pc386/start/bspsmp.c delete mode 100644 bsps/i386/pc386/start/getcpuid.c (limited to 'bsps/i386') diff --git a/bsps/i386/include/bsp/smp-imps.h b/bsps/i386/include/bsp/smp-imps.h index 03434b81ef..7b023ddcfc 100644 --- a/bsps/i386/include/bsp/smp-imps.h +++ b/bsps/i386/include/bsp/smp-imps.h @@ -233,6 +233,9 @@ extern unsigned char imps_apic_cpu_map[IMPS_MAX_CPUS]; extern char _binary_appstart_bin_start[]; extern char _binary_appstart_bin_size[]; +/** @brief base address of the local apic. Usually 0xFEE00000 */ +extern unsigned imps_lapic_addr; + /* * Defines that use variables */ diff --git a/bsps/i386/pc386/include/bsp.h b/bsps/i386/pc386/include/bsp.h index 7989b880a9..1ed92e469a 100644 --- a/bsps/i386/pc386/include/bsp.h +++ b/bsps/i386/pc386/include/bsp.h @@ -252,6 +252,13 @@ uint32_t BSP_irq_count_dump(FILE *f); void raw_idt_notify(void); void C_dispatch_isr(int vector); +#ifdef RTEMS_SMP + /* CPU specific functions used by the SMP API */ + int imps_probe(void); + void ipi_install_irq(void); + int send_ipi(unsigned int dst, unsigned int v); +#endif + #ifdef __cplusplus } #endif diff --git a/bsps/i386/pc386/start/bspsmp.c b/bsps/i386/pc386/start/bspsmp.c new file mode 100644 index 0000000000..026f86916f --- /dev/null +++ b/bsps/i386/pc386/start/bspsmp.c @@ -0,0 +1,43 @@ + +#include + +#include +#include +#include +#include + +void _CPU_SMP_Prepare_start_multitasking( void ) +{ + /* Do nothing */ +} + +bool _CPU_SMP_Start_processor( uint32_t cpu_index ) +{ + (void) cpu_index; + + return true; +} + + +uint32_t _CPU_SMP_Get_current_processor( void ) +{ + return imps_apic_cpu_map[APIC_ID(IMPS_LAPIC_READ(LAPIC_ID))]; +} + +uint32_t _CPU_SMP_Initialize( void ) +{ + /* XXX need to deal with finding too many cores */ + + return (uint32_t) imps_probe(); +} + +void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) +{ + if ( cpu_count > 1 ) + ipi_install_irq(); +} + +void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ) +{ + send_ipi( target_processor_index, 0x30 ); +} diff --git a/bsps/i386/pc386/start/getcpuid.c b/bsps/i386/pc386/start/getcpuid.c deleted file mode 100644 index 4918a2a970..0000000000 --- a/bsps/i386/pc386/start/getcpuid.c +++ /dev/null @@ -1,22 +0,0 @@ -/* - * COPYRIGHT (c) 2011. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. - */ - -#include - -#include -#include - -static int lapic_dummy = 0; -unsigned imps_lapic_addr = ((unsigned)(&lapic_dummy)) - LAPIC_ID; - -uint32_t _CPU_SMP_Get_current_processor( void ) -{ - return imps_apic_cpu_map[APIC_ID(IMPS_LAPIC_READ(LAPIC_ID))]; -} - diff --git a/bsps/i386/pc386/start/smp-imps.c b/bsps/i386/pc386/start/smp-imps.c index 6480c0d25e..de593f3c40 100644 --- a/bsps/i386/pc386/start/smp-imps.c +++ b/bsps/i386/pc386/start/smp-imps.c @@ -85,6 +85,9 @@ extern void _pc386_delay(void); extern uint32_t* gdtdesc; +static int lapic_dummy = 0; +unsigned imps_lapic_addr = ((unsigned)(&lapic_dummy)) - LAPIC_ID; + /* #define KERNEL_PRINT(_format) printk(_format) */ static void CMOS_WRITE_BYTE( @@ -220,7 +223,7 @@ get_checksum(unsigned start, int length) /* * APIC ICR write and status check function. */ -static int +int send_ipi(unsigned int dst, unsigned int v) { int to, send_status; @@ -698,7 +701,7 @@ imps_force(int ncpus) * * Function finished. */ -static int +int imps_probe(void) { /* @@ -768,7 +771,8 @@ static void bsp_inter_processor_interrupt(void *arg) _SMP_Inter_processor_interrupt_handler(_Per_CPU_Get()); } -static void ipi_install_irq(void) +void +ipi_install_irq(void) { rtems_status_code status; @@ -802,33 +806,3 @@ static void secondary_cpu_initialize(void) _SMP_Start_multitasking_on_secondary_processor( _Per_CPU_Get() ); } - -uint32_t _CPU_SMP_Initialize( void ) -{ - /* XXX need to deal with finding too many cores */ - - return (uint32_t) imps_probe(); -} - -void _CPU_SMP_Prepare_start_multitasking( void ) -{ - /* Do nothing */ -} - -bool _CPU_SMP_Start_processor( uint32_t cpu_index ) -{ - (void) cpu_index; - - return true; -} - -void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) -{ - if ( cpu_count > 1 ) - ipi_install_irq(); -} - -void _CPU_SMP_Send_interrupt( uint32_t target_processor_index ) -{ - send_ipi( target_processor_index, 0x30 ); -} -- cgit v1.2.3