diff options
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/ChangeLog | 7 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/Makefile.am | 25 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/clock/ckinit.c | 28 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/configure.ac | 6 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/preinstall.am | 14 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/start/start16.S | 74 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/startup/bspstart.c | 4 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/pc386/startup/ldsegs.S | 5 |
8 files changed, 134 insertions, 29 deletions
diff --git a/c/src/lib/libbsp/i386/pc386/ChangeLog b/c/src/lib/libbsp/i386/pc386/ChangeLog index 0731a41bdf..64d7be0850 100644 --- a/c/src/lib/libbsp/i386/pc386/ChangeLog +++ b/c/src/lib/libbsp/i386/pc386/ChangeLog @@ -1,3 +1,10 @@ +2011-08-01 Jennifer Averett <Jennifer.Averett@OARcorp.com> + + PR 1802 + * Makefile.am, configure.ac, preinstall.am, clock/ckinit.c, + start/start16.S, startup/bspstart.c, startup/ldsegs.S: Add SMP + support for i386. + 2011-07-20 Jennifer Averett <Jennifer.Averett@OARcorp.com> * start/start16.S: Removed tabs and added OAR standard copyright header diff --git a/c/src/lib/libbsp/i386/pc386/Makefile.am b/c/src/lib/libbsp/i386/pc386/Makefile.am index faddf6301a..1cc760e821 100644 --- a/c/src/lib/libbsp/i386/pc386/Makefile.am +++ b/c/src/lib/libbsp/i386/pc386/Makefile.am @@ -31,6 +31,11 @@ include_bsp_HEADERS = ../../i386/shared/irq/irq.h \ ../../shared/include/irq-generic.h \ ../../shared/include/irq-info.h +if HAS_SMP +include_bsp_HEADERS += ../../i386/shared/irq/apic.h +include_bsp_HEADERS += ../../i386/shared/smp/smp-imps.h +endif + include_HEADERS += include/crt.h nodist_include_HEADERS += ../../shared/include/coverhd.h @@ -109,8 +114,19 @@ libbsp_a_SOURCES += timer/timer.c timer/timerisr.S libbsp_a_SOURCES += ide/idecfg.c ide/ide.c if HAS_SMP -libbsp_a_SOURCES += ../../shared/smp/getcpuid.c ../../shared/smp/smp_stub.c \ - ../../shared/smp/bspsmp_wait_for.c +libbsp_a_SOURCES += ../../i386/shared/smp/getcpuid.c +libbsp_a_SOURCES += ../../i386/shared/smp/smp-imps.c + +project_lib_DATA += appstart.$(OBJEXT) +appcpustart.$(OBJEXT): start/start16.S + $(CPPASCOMPILE) $(AM_CPPFLAGS) -DSMP_SECONDARY_CORE -o $@ -c $< + +appstart.$(OBJEXT): appcpustart.$(OBJEXT) + $(LD) -N -T $(top_srcdir)/startup/linkcmds \ + -Ttext 0x70000 -e app_processor_start -nostdlib \ + -o appstart_tmp.exe $< + $(OBJCOPY) -O binary appstart_tmp.exe appstart.bin + $(OBJCOPY) -I binary -O elf32-i386 -B i386 appstart.bin $@ endif if HAS_NETWORKING @@ -144,6 +160,11 @@ endif libbsp_a_LIBADD = ../../../libcpu/@RTEMS_CPU@/cache.rel \ ../../../libcpu/@RTEMS_CPU@/page.rel \ ../../../libcpu/@RTEMS_CPU@/score.rel + +if HAS_SMP +libbsp_a_LIBADD += appstart.$(OBJEXT) +endif + # We only build the Network library if HAS_NETWORKING was defined # dec21140 is supported via libchip if HAS_NETWORKING diff --git a/c/src/lib/libbsp/i386/pc386/clock/ckinit.c b/c/src/lib/libbsp/i386/pc386/clock/ckinit.c index 76e3e82e54..c88d3b86ce 100644 --- a/c/src/lib/libbsp/i386/pc386/clock/ckinit.c +++ b/c/src/lib/libbsp/i386/pc386/clock/ckinit.c @@ -234,6 +234,8 @@ static void clockOn( } pc386_clock_click_count = US_TO_TICK(pc386_microseconds_per_isr); + BSP_irq_enable_at_i8259s( BSP_PERIODIC_TIMER - BSP_IRQ_VECTOR_BASE ); + #if 0 printk( "configured usecs per tick=%d \n", rtems_configuration_get_microseconds_per_tick() ); @@ -271,15 +273,33 @@ int clockIsOn(const rtems_irq_connect_data* unused) rtems_isr Clock_isr( rtems_vector_number vector ); + +bool Clock_isr_enabled = false; +void Clock_isr_handler( + rtems_irq_hdl_param param +) +{ + if ( Clock_isr_enabled ) + Clock_isr( 0 ); +} + static rtems_irq_connect_data clockIrqData = { BSP_PERIODIC_TIMER, - (void *)Clock_isr, + Clock_isr_handler, 0, clockOn, clockOff, clockIsOn }; +void Clock_driver_install_handler(void) +{ + if (!BSP_install_rtems_irq_handler (&clockIrqData)) { + printk("Unable to install system clock ISR handler\n"); + rtems_fatal_error_occurred(1); + } +} + void Clock_driver_support_initialize_hardware(void) { bool use_tsc = false; @@ -318,11 +338,7 @@ void Clock_driver_support_initialize_hardware(void) Clock_driver_nanoseconds_since_last_tick ); - if (!BSP_install_rtems_irq_handler (&clockIrqData)) { - printk("Unable to initialize system clock\n"); - rtems_fatal_error_occurred(1); - } - + Clock_isr_enabled = true; } #define Clock_driver_support_shutdown_hardware() \ diff --git a/c/src/lib/libbsp/i386/pc386/configure.ac b/c/src/lib/libbsp/i386/pc386/configure.ac index 7cfd322d9f..05618f5cbf 100644 --- a/c/src/lib/libbsp/i386/pc386/configure.ac +++ b/c/src/lib/libbsp/i386/pc386/configure.ac @@ -85,6 +85,12 @@ RTEMS_BSPOPTS_HELP([BSP_HAS_SMP], [Always defined when on a pc386 to enable the pc386 support for determining the CPU core number in an SMP configuration.]) +## The PC386 BSP supports SMP configurations if this is enabled. +RTEMS_BSPOPTS_SET([BSP_HAS_SMP],[*],[1]) +RTEMS_BSPOPTS_HELP([BSP_HAS_SMP], +[Always defined when on a pc386 to enable the pc386 support for + determining the CPU core number in an SMP configuration.]) + ## if this is an i386, does gas have good code16 support? RTEMS_I386_GAS_CODE16 AM_CONDITIONAL(RTEMS_GAS_CODE16,[test "$RTEMS_GAS_CODE16" = "yes"]) diff --git a/c/src/lib/libbsp/i386/pc386/preinstall.am b/c/src/lib/libbsp/i386/pc386/preinstall.am index 5b9cc42376..e90004b512 100644 --- a/c/src/lib/libbsp/i386/pc386/preinstall.am +++ b/c/src/lib/libbsp/i386/pc386/preinstall.am @@ -73,6 +73,15 @@ $(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INC $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h +if HAS_SMP +$(PROJECT_INCLUDE)/bsp/apic.h: ../../i386/shared/irq/apic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/apic.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/apic.h + +$(PROJECT_INCLUDE)/bsp/smp-imps.h: ../../i386/shared/smp/smp-imps.h $(PROJECT_INCLUDE)/bsp/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/smp-imps.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/smp-imps.h +endif $(PROJECT_INCLUDE)/crt.h: include/crt.h $(PROJECT_INCLUDE)/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/crt.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/crt.h @@ -122,6 +131,11 @@ $(PROJECT_INCLUDE)/uart.h: ../../i386/shared/comm/uart.h $(PROJECT_INCLUDE)/$(di $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/uart.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/uart.h +if HAS_SMP +$(PROJECT_LIB)/appstart.$(OBJEXT): appstart.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_LIB)/appstart.$(OBJEXT) +TMPINSTALL_FILES += $(PROJECT_LIB)/appstart.$(OBJEXT) +endif if HAS_NETWORKING $(PROJECT_INCLUDE)/wd80x3.h: include/wd80x3.h $(PROJECT_INCLUDE)/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/wd80x3.h diff --git a/c/src/lib/libbsp/i386/pc386/start/start16.S b/c/src/lib/libbsp/i386/pc386/start/start16.S index 74989dd014..1a36117b45 100644 --- a/c/src/lib/libbsp/i386/pc386/start/start16.S +++ b/c/src/lib/libbsp/i386/pc386/start/start16.S @@ -37,35 +37,57 @@ | Constants +----------------------------------------------------------------------------*/ +#if defined(SMP_SECONDARY_CORE) +.set PROT_CODE_SEG, 0x08 # offset of code segment descriptor into GDT +#else .set PROT_CODE_SEG, 0x0 # offset of code segment descriptor into GDT +#endif + .set PROT_DATA_SEG, 0x10 # offset of code segment descriptor into GDT .set CR0_PE, 1 # protected mode flag on CR0 register .set HDRSTART, HEADERADDR # address of start of bin2boot header .set HDROFF, 0x24 # offset into bin2boot header of start32 addr .set STACKOFF, 0x200-0x10 # offset to load into %esp, from start of image - /* #define NEW_GAS */ +/* #define NEW_GAS */ +#ifdef NEW_GAS + #define LJMPL ljmpl +#else + #define LJMPL ljmp +#endif + /*----------------------------------------------------------------------------+ | CODE section +----------------------------------------------------------------------------*/ .text - +#if defined(SMP_SECONDARY_CORE) + .globl app_processor_start # entry point +app_processor_start: +#else .globl _start16 # entry point .globl start16 start16: _start16: +#endif .code16 cli # DISABLE INTERRUPTS!!! +#if defined(SMP_SECONDARY_CORE) + jmp 1f + .align 4 +app_cpu_start: + .long 0 +app_cpu_stack: + .long 0 +1: +#endif + movw %cs, %ax # Initialize the rest of + movw %ax, %ds # segment registers + movw %ax, %es + movw %ax, %ss - movw %cs, %ax # - movw %ax, %ds # set the rest of real mode registers - movw %ax, %es # - movw %ax, %ss # - -#if (RTEMS_VIDEO_80x50 == 1) - +#if !defined(SMP_SECONDARY_CODE) && (RTEMS_VIDEO_80x50 == 1) movl $0x0040,%eax # use 32 bit constant to ensure 16 MSB=0 mov %ax,%es movw %es:0x4a, %ax # get 16 bit number of columns @@ -87,26 +109,30 @@ _start16: movb $0x01, %ah # define cursor (scan lines 0 to 7) movw $0x0007, %cx int $0x10 - 1: -#endif /* RTEMS_VIDEO_80x50 */ +#endif /* !SMP_SECONDARY_CODE and RTEMS_VIDEO_80x50 */ /*---------------------------------------------------------------------+ | Bare PC machines boot in real mode! We have to turn protected mode on. +---------------------------------------------------------------------*/ +#if defined(SMP_SECONDARY_CORE) + lgdt gdtptr - app_processor_start # load Global Descriptor Table +#else lgdt gdtptr - start16 # load Global Descriptor Table +#endif /* SMP_SECONDARY_CORE */ + movl %cr0, %eax orl $CR0_PE, %eax movl %eax, %cr0 # turn on protected mode - -#ifdef NEW_GAS - ljmpl $PROT_CODE_SEG, $1f # flush prefetch queue, and reload %cs +#if defined(SMP_SECONDARY_CORE) + LJMPL $PROT_CODE_SEG, $2f # flush prefetch queue, and reload %cs #else - ljmp $PROT_CODE_SEG, $1f # flush prefetch queue, and reload %cs + LJMPL $PROT_CODE_SEG, $2f # flush prefetch queue, and reload %cs #endif .code32 -1: +2: + /*---------------------------------------------------------------------+ | load the other segment registers +---------------------------------------------------------------------*/ @@ -114,8 +140,13 @@ _start16: movw %ax, %ds movw %ax, %es movw %ax, %ss +#if defined(SMP_SECONDARY_CORE) + movl app_cpu_stack, %esp # stack pointer + movl app_cpu_stack, %ebp # base pointer + #else movl $start16 + STACKOFF, %esp # set up stack pointer addl $start16 + STACKOFF, %ebp # set up stack pointer +#endif /* SMP_SECONDARY_CORE */ /*---------------------------------------------------------------------+ | we have to enable A20 in order to access memory above 1MByte @@ -132,9 +163,14 @@ _start16: call pc386_delay call pc386_delay - movl %cs:HDRSTART + HDROFF, %eax # - pushl %eax # jump to start of 32 bit code - ret # +#if defined(SMP_SECONDARY_CORE) + movl app_cpu_start, %eax # jump to app CPU start +#else + movl %cs:HDRSTART + HDROFF, %eax # jump to start of 32 bit code +#endif /* SMP_SECONDARY_CORE */ + pushl %eax + ret + /*----------------------------------------------------------------------------+ | pc386_delay diff --git a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c index 4df92b9420..3dd104a04a 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @@ -31,6 +31,7 @@ +--------------------------------------------------------------------------*/ #include <bsp.h> +#include <bsp/irq.h> #include <rtems/pci.h> #include <libcpu/cpuModel.h> @@ -40,6 +41,7 @@ extern void Calibrate_loop_1ms(void); extern void rtems_irq_mngt_init(void); extern void bsp_size_memory(void); +void Clock_driver_install_handler(void); /*-------------------------------------------------------------------------+ | Function: bsp_start @@ -80,6 +82,8 @@ void bsp_start_default( void ) printk("PCI bus: could not initialize PCI BIOS interface\n"); } + Clock_driver_install_handler(); + bsp_ide_cmdline_init(); } /* bsp_start */ diff --git a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S index c05ab13a58..ca3b7318d8 100644 --- a/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S +++ b/c/src/lib/libbsp/i386/pc386/startup/ldsegs.S @@ -96,7 +96,7 @@ pc386_delay1: SYM (_load_segments): lgdt SYM(gdtdesc) - lidt SYM(idtdesc) + lidt SYM(IDT_Descriptor) /* Load CS, flush prefetched queue */ ljmp $0x8, $next_step @@ -211,7 +211,8 @@ SYM(Interrupt_descriptor_table): +--------------------------------------------------------------------------*/ .p2align 4 -SYM(idtdesc): + PUBLIC(IDT_Descriptor) +SYM(IDT_Descriptor): .word (256*8 - 1) .long SYM (Interrupt_descriptor_table) |