diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-08-05 16:51:39 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1998-08-05 16:51:39 +0000 |
commit | bd8c8b2a855f3219e3c4c73c9e67eb4bd6d473d7 (patch) | |
tree | d9f1b7bf8ee4865c1e485e2b161c5709e2b6b75d /c/src/lib/libbsp/i386/i386ex | |
parent | changed load address (diff) | |
download | rtems-bd8c8b2a855f3219e3c4c73c9e67eb4bd6d473d7.tar.bz2 |
Patch from Eric Valette <valette@crf.canon.fr> which brings the i386ex BSP
inline with the new IRQ structure.
Diffstat (limited to 'c/src/lib/libbsp/i386/i386ex')
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/clock/ckinit.c | 67 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/console/Makefile.in | 9 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/console/console.c | 19 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/include/bsp.h | 10 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/start/start.s | 24 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/startup/Makefile.in | 12 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/startup/bspstart.c | 5 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/timer/timer.c | 60 | ||||
-rw-r--r-- | c/src/lib/libbsp/i386/i386ex/timer/timerisr.s | 6 |
9 files changed, 153 insertions, 59 deletions
diff --git a/c/src/lib/libbsp/i386/i386ex/clock/ckinit.c b/c/src/lib/libbsp/i386/i386ex/clock/ckinit.c index 9c3bbd7dc2..0ede2182b9 100644 --- a/c/src/lib/libbsp/i386/i386ex/clock/ckinit.c +++ b/c/src/lib/libbsp/i386/i386ex/clock/ckinit.c @@ -21,19 +21,16 @@ */ #include <bsp.h> +#include <irq.h> #include <rtems/libio.h> #include <stdlib.h> -#define CLOCK_VECTOR 0x20 - rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ volatile rtems_unsigned32 Clock_driver_ticks; -rtems_isr_entry Old_ticker; - void Clock_exit( void ); /* @@ -47,9 +44,7 @@ rtems_device_major_number rtems_clock_minor = 0; * This is the ISR handler. */ -rtems_isr Clock_isr( - rtems_vector_number vector -) +void Clock_isr() { /* enable_tracing(); */ Clock_driver_ticks += 1; @@ -61,16 +56,13 @@ rtems_isr Clock_isr( Clock_isrs -= 1; } -void Install_clock( - rtems_isr_entry clock_isr -) +void ClockOff(const rtems_irq_connect_data* unused) { - Clock_driver_ticks = 0; - Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; - - if ( BSP_Configuration.ticks_per_timeslice ) { - Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, CLOCK_VECTOR, 1 ); + /* should do something here */; +} +void ClockOn(const rtems_irq_connect_data* unused) +{ /* The following is already set up in interns.s -> ( This is test code only... production code will move the TMRCFG stuff here ) @@ -81,24 +73,25 @@ void Install_clock( #define TMRCON 0xF043 #define TMRCFG 0xF834 - outport_byte ( TMRCFG , 0x80 ); + outport_byte ( TMRCFG , 0x80 ); - outport_byte ( TMRCON , 0x34 ); - outport_byte ( TMR0 , 0xA8 ); - outport_byte ( TMR0 , 0x04 ); + outport_byte ( TMRCON , 0x34 ); + outport_byte ( TMR0 , 0xA8 ); + outport_byte ( TMR0 , 0x04 ); - outport_byte ( TMRCFG , 0x00 ); - } - atexit( Clock_exit ); + outport_byte ( TMRCFG , 0x00 ); } -void Clock_exit( void ) +int ClockIsOn(const rtems_irq_connect_data* unused) { - if ( BSP_Configuration.ticks_per_timeslice ) { - /* should do something here */; - } + return ((i8259s_cache & 0x1) == 0); } +static rtems_irq_connect_data clockIrqData = {PC_386_PERIODIC_TIMER, + Clock_isr, + ClockOn, + ClockOff, + ClockIsOn}; rtems_device_driver Clock_initialize( rtems_device_major_number major, @@ -106,8 +99,12 @@ rtems_device_driver Clock_initialize( void *pargp ) { - Install_clock( Clock_isr ); - + Clock_driver_ticks = 0; + Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; + if (!pc386_install_rtems_irq_handler (&clockIrqData)) { + printk("Unable to initialize system clock\n"); + rtems_fatal_error_occurred(1); + } /* * make major/minor avail to others such as shared memory driver */ @@ -124,7 +121,6 @@ rtems_device_driver Clock_control( void *pargp ) { - rtems_unsigned32 isrlevel; rtems_libio_ioctl_args_t *args = pargp; if (args == 0) @@ -137,16 +133,21 @@ rtems_device_driver Clock_control( if (args->command == rtems_build_name('I', 'S', 'R', ' ')) { - Clock_isr(CLOCK_VECTOR); + Clock_isr(); } else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) { - rtems_interrupt_disable( isrlevel ); - (void) set_vector( args->buffer, CLOCK_VECTOR, 1 ); - rtems_interrupt_enable( isrlevel ); + if (!pc386_install_rtems_irq_handler (&clockIrqData)) { + printk("Error installing clock interrupt handler!\n"); + rtems_fatal_error_occurred(1); + } } done: return RTEMS_SUCCESSFUL; } +void Clock_exit() +{ + pc386_remove_rtems_irq_handler (&clockIrqData); +} diff --git a/c/src/lib/libbsp/i386/i386ex/console/Makefile.in b/c/src/lib/libbsp/i386/i386ex/console/Makefile.in index c1f28bc4c4..e774529a2b 100644 --- a/c/src/lib/libbsp/i386/i386ex/console/Makefile.in +++ b/c/src/lib/libbsp/i386/i386ex/console/Makefile.in @@ -10,8 +10,10 @@ PROJECT_ROOT = @PROJECT_ROOT@ PGM=${ARCH}/console.rel +IMPORT_SRC=$(srcdir)/../../shared/io/printk.c + # C source names, if any, go here -- minus the .c -C_PIECES=console +C_PIECES=console printk C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) @@ -49,10 +51,13 @@ LDFLAGS += CLEAN_ADDITIONS += CLOBBER_ADDITIONS += +preinstall: + ${CP} ${IMPORT_SRC} . + ${PGM}: ${SRCS} ${OBJS} $(make-rel) -all: ${ARCH} $(SRCS) $(PGM) +all: ${ARCH} preinstall $(SRCS) $(PGM) # the .rel file built here will be put into libbsp.a by ../wrapup/Makefile install: all diff --git a/c/src/lib/libbsp/i386/i386ex/console/console.c b/c/src/lib/libbsp/i386/i386ex/console/console.c index 0d05e84b30..03c2e3b4cd 100644 --- a/c/src/lib/libbsp/i386/i386ex/console/console.c +++ b/c/src/lib/libbsp/i386/i386ex/console/console.c @@ -16,7 +16,7 @@ #include <bsp.h> #include <rtems/libio.h> - +#include <bspIo.h> #include <stdlib.h> #include "../start/80386ex.h" @@ -109,6 +109,18 @@ rtems_boolean is_character_ready( return FALSE; } +/* + * Wait for an input. May be used before intr are ON. + */ +char BSP_wait_polled_input( void ) +{ + char c; + while (!is_character_ready(&c)) + continue; + + return c; +} + /* inbyte * * This routine reads a character from the UART. @@ -277,3 +289,8 @@ rtems_device_driver console_control( { return RTEMS_SUCCESSFUL; } + +BSP_output_char_function_type BSP_output_char = outbyte; +BSP_polling_getchar_function_type BSP_poll_char = BSP_wait_polled_input; + +void BSP_emergency_output_init() {} diff --git a/c/src/lib/libbsp/i386/i386ex/include/bsp.h b/c/src/lib/libbsp/i386/i386ex/include/bsp.h index 9c37d8248e..eef2d2559a 100644 --- a/c/src/lib/libbsp/i386/i386ex/include/bsp.h +++ b/c/src/lib/libbsp/i386/i386ex/include/bsp.h @@ -23,7 +23,9 @@ extern "C" { #include <iosupp.h> #include <console.h> #include <clockdrv.h> - +#include <bspIo.h> +#include <irq.h> + /* * Define the time limits for RTEMS Test Suite test durations. * Long test and short test duration limits are provided. These @@ -129,12 +131,6 @@ BSP_EXTERN unsigned int Gdt_base; /* routines */ -i386_isr_entry set_vector( - rtems_isr_entry handler, - rtems_vector_number vector, - int type -); - #ifdef __cplusplus } #endif diff --git a/c/src/lib/libbsp/i386/i386ex/start/start.s b/c/src/lib/libbsp/i386/i386ex/start/start.s index 51bbea97d4..02b4166eaf 100644 --- a/c/src/lib/libbsp/i386/i386ex/start/start.s +++ b/c/src/lib/libbsp/i386/i386ex/start/start.s @@ -33,6 +33,10 @@ #include "macros.inc" #include "80386ex.inc" +/* + * Needed for binutils 2.9.1.0.7 and higher + * #define NEXT_GAS + */ EXTERN (main) /* exits to bspstart */ EXTERN (stack_start) /* defined in startup/linkcmds */ @@ -179,6 +183,9 @@ SYM(reset): .code16 nop cli +#ifdef NEXT_GAS + addr32 +#endif jmp SYM(_initInternalRegisters) /* different section in this file */ .code32 /* in case this section moves */ nop /* required by CHIP LAB to pad out size */ @@ -192,8 +199,8 @@ SYM(reset): /* * Enable access to peripheral register at expanded I/O addresses */ - .code16 SYM(_initInternalRegisters): + .code16 movw $0x8000 , ax outb al , $REMAPCFGH xchg al , ah @@ -406,8 +413,8 @@ SYM(InitInt): SetExRegByte(ICW1M , 0x11 ) # edge triggered SetExRegByte(ICW2M , 0x20 ) # base vector starts at byte 32 - SetExRegByte(ICW3M , 0x04 ) # IR2 is cascaded internally - SetExRegByte(ICW4M , 0X03 ) # AEOI MODE FIRST! + SetExRegByte(ICW3M , 0x02 ) # IR2 is cascaded internally + SetExRegByte(ICW4M , 0x01 ) # idem SetExRegByte(OCW1M , 0xde ) # IR0 only = 0xfe. for IR5 and IR0 active use 0xde SetExRegByte(INTCFG , 0x00 ) @@ -481,7 +488,10 @@ SYM(xfer_gdt): movw $ _ram_gdt_segment, ax mov ax , ds - +#ifdef NEXT_GAS + data32 + addr32 +#endif lgdt _ram_gdt_offset # location of GDT @@ -494,16 +504,16 @@ SYM(SetUCS): /*************************** * Switch to Protected Mode ***************************/ - mov %cr0, eax + mov cr0, eax orw $0x1, ax - mov eax, %cr0 + mov eax, cr0 /************************** * Flush prefetch queue, * and load CS selector *********************/ - ljmp $ GDT_CODE_PTR , $ SYM(_copy_data) # sets the code selector + ljmpl $ GDT_CODE_PTR , $ SYM(_copy_data) # sets the code selector /* * Copy the data section down to RAM */ diff --git a/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in b/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in index 9f4b9ae2fb..ffd694f64f 100644 --- a/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in +++ b/c/src/lib/libbsp/i386/i386ex/startup/Makefile.in @@ -10,8 +10,11 @@ PROJECT_ROOT = @PROJECT_ROOT@ PGM=${ARCH}/startup.rel +IMPORT_SRC=$(srcdir)/../../shared/irq/irq.c \ + $(srcdir)/../../shared/irq/irq_init.c $(srcdir)/../../shared/irq/irq_asm.s + # C source names, if any, go here -- minus the .c -C_PIECES=bspclean bsplibc bsppost bspstart main sbrk setvec +C_PIECES=bspclean bsplibc bsppost bspstart main sbrk irq irq_init C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) @@ -19,7 +22,7 @@ H_FILES= # Assembly source names, if any, go here -- minus the .s # removed initcsu piece, ldsegs piece and flush -S_PIECES= +S_PIECES=irq_asm S_FILES=$(S_PIECES:%=%.s) S_O_FILES=$(S_FILES:%.s=${ARCH}/%.o) @@ -52,9 +55,12 @@ LDFLAGS += CLEAN_ADDITIONS += CLOBBER_ADDITIONS += +preinstall: + ${CP} ${IMPORT_SRC} . + ${PGM}: ${SRCS} ${OBJS} $(make-rel) -all: ${ARCH} $(SRCS) $(PGM) +all: ${ARCH} preinstall $(SRCS) $(PGM) $(INSTALL) $(srcdir)/linkcmds ${PROJECT_RELEASE}/lib # the .rel file built here will be put into libbsp.a by ../wrapup/Makefile diff --git a/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c b/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c index d71f182230..fc519b430a 100644 --- a/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c +++ b/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c @@ -114,5 +114,8 @@ void bsp_start( void ) */ /* console_reserve_resources( &BSP_Configuration ); */ - + /* + * Init rtems_interrupt_management + */ + rtems_irq_mngt_init(); } diff --git a/c/src/lib/libbsp/i386/i386ex/timer/timer.c b/c/src/lib/libbsp/i386/i386ex/timer/timer.c index af0217ef8d..4c29d6c57f 100644 --- a/c/src/lib/libbsp/i386/i386ex/timer/timer.c +++ b/c/src/lib/libbsp/i386/i386ex/timer/timer.c @@ -27,11 +27,13 @@ #include <rtems.h> #include <bsp.h> +#include <stdlib.h> int Ttimer_val; rtems_boolean Timer_driver_Find_average_overhead; -rtems_isr timerisr(); +extern void timerisr(); +extern int ClockIsOn(const rtems_raw_irq_connect_data*); #define TMR0 0xF040 #define TMR1 0xF041 @@ -39,11 +41,9 @@ rtems_isr timerisr(); #define TMRCON 0xF043 #define TMRCFG 0xF834 -void Timer_initialize() +void TimerOn(const rtems_raw_irq_connect_data* used) { - (void) set_vector( timerisr, 0x2a, 0 ); /* install ISR ( IR2 ) was 0x38*/ - Ttimer_val = 0; /* clear timer ISR count */ outport_byte ( TMRCON , 0xb0 ); /* select tmr2, stay in mode 0 */ @@ -51,8 +51,58 @@ void Timer_initialize() outport_byte ( TMR1 , 0x00 ); outport_byte ( TMRCON , 0x64 ); /* change to mode 2 ( starts timer ) */ /* interrupts ARE enabled */ -/* outport_byte( IERA, 0x41 ); enable interrupt */ + /* outport_byte( IERA, 0x41 ); enable interrupt */ + /* + * enable interrrupt at i8259 level + */ + pc386_irq_enable_at_i8259s(used->idtIndex - PC386_IRQ_VECTOR_BASE); +} + +void TimerOff(const rtems_raw_irq_connect_data* used) +{ + /* + * disable interrrupt at i8259 level + */ + pc386_irq_disable_at_i8259s(used->idtIndex - PC386_IRQ_VECTOR_BASE); + /* reset timer mode to standard (DOS) value */ +} + +static rtems_raw_irq_connect_data timer_raw_irq_data = { + PC_386_RT_TIMER3 + PC386_IRQ_VECTOR_BASE, + timerisr, + TimerOn, + TimerOff, + ClockIsOn +}; + +void Timer_exit() +{ + if (!i386_delete_idt_entry(&timer_raw_irq_data)) { + printk("Timer raw handler deconnexion failed\n"); + rtems_fatal_error_occurred(1); + } +} + +void Timer_initialize() +{ + + static rtems_boolean First = TRUE; + if (First) + { + First = FALSE; + + atexit(Timer_exit); /* Try not to hose the system at exit. */ + if (!i386_set_idt_entry (&timer_raw_irq_data)) { + printk("raw handler connexion failed\n"); + rtems_fatal_error_occurred(1); + } + } + /* wait for ISR to be called at least once */ + Ttimer_val = 0; + while (Ttimer_val == 0) + continue; + Ttimer_val = 0; } #define AVG_OVERHEAD 3 /* It typically takes 3.0 microseconds */ diff --git a/c/src/lib/libbsp/i386/i386ex/timer/timerisr.s b/c/src/lib/libbsp/i386/i386ex/timer/timerisr.s index 3264248b05..53463e1e70 100644 --- a/c/src/lib/libbsp/i386/i386ex/timer/timerisr.s +++ b/c/src/lib/libbsp/i386/i386ex/timer/timerisr.s @@ -28,6 +28,12 @@ PUBLIC (timerisr) SYM (timerisr): addl $250, SYM (Ttimer_val) # another 250 microseconds + pushl eax + movb 0xa0,al /* signal generic End Of Interrupt (EOI) to slave PIC */ + outb al, $0x20 + movb $0x20, al + outb al, $0x20 /* signal generic EOI to Master PIC */ + popl eax iret END_CODE |