From 090de1adf5c64d4c59d86fa3d5c3f1dd2bae1f80 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 11 Apr 2001 14:07:22 +0000 Subject: 2001-04-11 Eric Valette * Makefile.am, configure.in, console/console.c, include/Makefile.am, include/bsp.h, network/network.c, startup/Makefile.am, startup/bspstart.c, startup/linkcmds, wrapup/Makefile.am: Switch the eth_comm BSP to use the "new exception processing model." --- c/src/lib/libbsp/powerpc/eth_comm/ChangeLog | 8 +++ c/src/lib/libbsp/powerpc/eth_comm/Makefile.am | 2 +- c/src/lib/libbsp/powerpc/eth_comm/configure.in | 3 + .../lib/libbsp/powerpc/eth_comm/console/console.c | 17 ++--- .../libbsp/powerpc/eth_comm/include/Makefile.am | 20 ++++-- c/src/lib/libbsp/powerpc/eth_comm/include/bsp.h | 3 +- .../lib/libbsp/powerpc/eth_comm/network/network.c | 81 +++++++++++++--------- .../libbsp/powerpc/eth_comm/startup/Makefile.am | 4 +- .../lib/libbsp/powerpc/eth_comm/startup/bspstart.c | 47 ++++++++++++- c/src/lib/libbsp/powerpc/eth_comm/startup/linkcmds | 10 ++- .../lib/libbsp/powerpc/eth_comm/wrapup/Makefile.am | 4 +- 11 files changed, 141 insertions(+), 58 deletions(-) (limited to 'c/src/lib/libbsp/powerpc/eth_comm') diff --git a/c/src/lib/libbsp/powerpc/eth_comm/ChangeLog b/c/src/lib/libbsp/powerpc/eth_comm/ChangeLog index 6925746228..04ca56bb7c 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/ChangeLog +++ b/c/src/lib/libbsp/powerpc/eth_comm/ChangeLog @@ -1,3 +1,11 @@ +2001-04-11 Eric Valette + + * Makefile.am, configure.in, console/console.c, + include/Makefile.am, include/bsp.h, network/network.c, + startup/Makefile.am, startup/bspstart.c, startup/linkcmds, + wrapup/Makefile.am: Switch the eth_comm BSP to use the + "new exception processing model." + 2000-11-09 Ralf Corsepius * Makefile.am: Use ... instead of RTEMS_TOPdir in ACLOCAL_AMFLAGS. diff --git a/c/src/lib/libbsp/powerpc/eth_comm/Makefile.am b/c/src/lib/libbsp/powerpc/eth_comm/Makefile.am index 36c0cfe58c..a2f8425e14 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/Makefile.am +++ b/c/src/lib/libbsp/powerpc/eth_comm/Makefile.am @@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I ../../../../../../aclocal # wrapup is the one that actually builds and installs the library # from the individual .rel files built in other directories -SUBDIRS = include startup start canbus console network wrapup +SUBDIRS = clock include startup start canbus console irq network vectors wrapup include $(top_srcdir)/../../bsp.am diff --git a/c/src/lib/libbsp/powerpc/eth_comm/configure.in b/c/src/lib/libbsp/powerpc/eth_comm/configure.in index 774d9ee485..9ae78c2a72 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/configure.in +++ b/c/src/lib/libbsp/powerpc/eth_comm/configure.in @@ -28,10 +28,13 @@ RTEMS_PROJECT_ROOT # Explicitly list all Makefiles here AC_OUTPUT( Makefile +clock/Makefile canbus/Makefile console/Makefile include/Makefile +irq/Makefile network/Makefile start/Makefile startup/Makefile +vectors/Makefile wrapup/Makefile) diff --git a/c/src/lib/libbsp/powerpc/eth_comm/console/console.c b/c/src/lib/libbsp/powerpc/eth_comm/console/console.c index 7118cbcd3e..db6859cbb6 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/console/console.c +++ b/c/src/lib/libbsp/powerpc/eth_comm/console/console.c @@ -30,6 +30,10 @@ #include /* Must be before libio.h */ #include #include +#include + +static void _BSP_null_char( char c ) {return;} +BSP_output_char_function_type BSP_output_char = _BSP_null_char; rtems_device_driver console_initialize(rtems_device_major_number major, rtems_device_minor_number minor, @@ -58,11 +62,6 @@ rtems_device_driver console_initialize(rtems_device_major_number major, m8xx_uart_scc_initialize(SCC3_MINOR); /* /dev/tty3 */ m8xx_uart_scc_initialize(SCC4_MINOR); /* /dev/tty4 */ - /* - * Set up interrupts - */ - m8xx_uart_interrupts_initialize(); - /* * Register the devices */ @@ -108,28 +107,20 @@ rtems_device_driver console_open(rtems_device_major_number major, switch (minor) { case 0: m8xx.smc1.smcm = 1; /* Enable SMC1 RX interrupts */ - m8xx.cimr |= 1UL << 4; /* Enable SMC1 interrupts */ break; case 1: m8xx.smc2.smcm = 1; /* Enable SMC2 RX interrupts */ - m8xx.cimr |= 1UL << 3; /* Enable SMC2 interrupts */ break; case 2: - m8xx.cimr |= 1UL << 30; /* Enable SCC1 interrupts */ sccregs = &m8xx.scc1; break; case 3: -#ifndef I_WANT_TERMIOS - m8xx.cimr |= 1UL << 29; /* Enable SCC2 interrupts */ -#endif /* I_WANT_TERMIOS */ sccregs = &m8xx.scc2; break; case 4: - m8xx.cimr |= 1UL << 28; /* Enable SCC3 interrupts */ sccregs = &m8xx.scc3; break; case 5: - m8xx.cimr |= 1UL << 27; /* Enable SCC4 interrupts */ sccregs = &m8xx.scc4; break; default: diff --git a/c/src/lib/libbsp/powerpc/eth_comm/include/Makefile.am b/c/src/lib/libbsp/powerpc/eth_comm/include/Makefile.am index 1c9de158e1..49898fe552 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/include/Makefile.am +++ b/c/src/lib/libbsp/powerpc/eth_comm/include/Makefile.am @@ -6,9 +6,14 @@ AUTOMAKE_OPTIONS = foreign 1.4 H_FILES = bsp.h coverhd.h canbus.h info.h +BSP_H_FILES = commproc.h 8xx_immap.h + $(PROJECT_INCLUDE): $(mkinstalldirs) $@ +$(PROJECT_INCLUDE)/bsp: + $(mkinstalldirs) $@ + $(PROJECT_INCLUDE)/bsp.h: bsp.h $(INSTALL_DATA) $< $@ @@ -21,11 +26,18 @@ $(PROJECT_INCLUDE)/canbus.h: canbus.h $(PROJECT_INCLUDE)/info.h: info.h $(INSTALL_DATA) $< $@ -TMPINSTALL_FILES += $(PROJECT_INCLUDE) $(PROJECT_INCLUDE)/bsp.h \ - $(PROJECT_INCLUDE)/coverhd.h $(PROJECT_INCLUDE)/canbus.h \ - $(PROJECT_INCLUDE)/info.h + $(PROJECT_INCLUDE)/bsp/commproc.h : commproc.h + $(INSTALL_DATA) $< $@ + +$(PROJECT_INCLUDE)/bsp/8xx_immap.h : 8xx_immap.h + $(INSTALL_DATA) $< $@ + +PREINSTALL_FILES += $(PROJECT_INCLUDE) $(PROJECT_INCLUDE)/bsp \ + $(PROJECT_INCLUDE)/bsp.h $(PROJECT_INCLUDE)/info.h \ + $(PROJECT_INCLUDE)/coverhd.h $(PROJECT_INCLUDE)/canbus.h \ + $(PROJECT_INCLUDE)/bsp/commproc.h $(PROJECT_INCLUDE)/bsp/8xx_immap.h -all-local: $(TMPINSTALL_FILES) +all-local: $(PREINSTALL_FILES) EXTRA_DIST = bsp.h canbus.h coverhd.h info.h diff --git a/c/src/lib/libbsp/powerpc/eth_comm/include/bsp.h b/c/src/lib/libbsp/powerpc/eth_comm/include/bsp.h index ae9f4192c8..8a0b49445b 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/include/bsp.h +++ b/c/src/lib/libbsp/powerpc/eth_comm/include/bsp.h @@ -82,7 +82,8 @@ extern int rtems_enet_driver_attach (struct rtems_bsdnet_ifconfig *config); #define RAM_START 0 #define RAM_END 0x100000 - +#define IMAP_ADDR ((unsigned int)0xff000000) +#define IMAP_SIZE ((unsigned int)(16 * 1024)) /* miscellaneous stuff assumed to exist */ extern rtems_configuration_table BSP_Configuration; diff --git a/c/src/lib/libbsp/powerpc/eth_comm/network/network.c b/c/src/lib/libbsp/powerpc/eth_comm/network/network.c index 2fa25f664c..0def297e0c 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/network/network.c +++ b/c/src/lib/libbsp/powerpc/eth_comm/network/network.c @@ -30,6 +30,7 @@ #include #include +#include /* * Number of interfaces supported by this driver @@ -45,6 +46,8 @@ #define TX_BUF_COUNT 8 #define TX_BD_PER_BUF 4 +#define INET_ADDR_MAX_BUF_SIZE (sizeof "255.255.255.255") + /* * RTEMS event used by interrupt handler to signal daemons. * This must *not* be the same event used by the TCP/IP task synchronization. @@ -108,11 +111,29 @@ struct m860_enet_struct { }; static struct m860_enet_struct enet_driver[NIFACES]; +static void m8xx_scc1_ethernet_on(const rtems_irq_connect_data* ptr) +{ + /* + * Please put relevant code there + */ +} + +static void m8xx_scc1_ethernet_off(const rtems_irq_connect_data* ptr) +{ + /* + * Please put relevant code there + */ +} + +static void m8xx_scc1_ethernet_isOn(const rtems_irq_connect_data* ptr) +{ + return BSP_irq_enabled_at_cpm (ptr->name); +} + /* * SCC1 interrupt handler */ -static rtems_isr -m860_scc1_interrupt_handler (rtems_vector_number v) +static void m860_scc1_interrupt_handler () { /* * Frame received? @@ -139,14 +160,12 @@ m860_scc1_interrupt_handler (rtems_vector_number v) enet_driver[0].txInterrupts++; rtems_event_send (enet_driver[0].txDaemonTid, INTERRUPT_EVENT); } - m8xx.cisr = 1UL << 30; /* Clear SCC1 interrupt-in-service bit */ } /* * FEC interrupt handler */ -static rtems_isr -m860_fec_interrupt_handler (rtems_vector_number v) +static void m860_fec_interrupt_handler () { /* * Frame received? @@ -166,6 +185,13 @@ m860_fec_interrupt_handler (rtems_vector_number v) rtems_event_send (enet_driver[0].txDaemonTid, INTERRUPT_EVENT); } } +static rtems_irq_connect_data ethernetSCC1IrqData = { + BSP_CPM_IRQ_SCC1, + (rtems_irq_hdl) m860_scc1_interrupt_handler, + (rtems_irq_enable) m8xx_scc1_ethernet_on, + (rtems_irq_disable) m8xx_scc1_ethernet_off, + (rtems_irq_is_enabled)m8xx_scc1_ethernet_isOn +}; /* * Initialize the ethernet hardware @@ -334,15 +360,12 @@ m860_scc_initialize_hardware (struct m860_enet_struct *sc) /* * Set up interrupts */ - status = rtems_interrupt_catch (m860_scc1_interrupt_handler, - PPC_IRQ_CPM_SCC1, - &old_handler); + status = BSP_install_rtems_irq_handler (ðernetSCC1IrqData); if (status != RTEMS_SUCCESSFUL) { - rtems_panic ("Can't attach M860 SCC1 interrupt handler: %s\n", + rtems_panic ("Can't attach M8xx SCC1 interrupt handler: %s\n", rtems_status_text (status)); } m8xx.scc1.sccm = 0; /* No interrupts unmasked till necessary */ - m8xx.cimr |= (1UL << 30); /* Enable SCC1 interrupt */ /* * Set up General SCC Mode Register @@ -381,27 +404,25 @@ m860_scc_initialize_hardware (struct m860_enet_struct *sc) m8xx.pcpar |= 0x1; m8xx.pcdir &= ~0x1; - - /* - * Set up interrupts - * FIXME: DANGER: WARNING: - * CICR and SIMASK must be set in any module that uses - * the CPM. Currently those are console-generic.c and - * network.c. If the registers are not set the same - * in both places, strange things may happen. - * If they are only set in one place, then an application - * that used the other module won't work correctly. - * Put this comment in each module that sets these 2 registers - */ - m8xx.cicr = 0x00e43e80; /* SCaP=SCC1, SCbP=SCC2, SCcP=SCC3, - SCdP=SCC4, IRL=1, HP=SCC1, IEN=1 */ - m8xx.simask |= M8xx_SIMASK_LVM1; - /* * Enable receiver and transmitter */ m8xx.scc1.gsmr_l = 0x1088003c; } +static void m8xx_fec_ethernet_on(){}; +static void m8xx_fec_ethernet_off(){}; +static int m8xx_fec_ethernet_isOn (const rtems_irq_connect_data* ptr) +{ + return BSP_irq_enabled_at_siu (ptr->name); +} + +static rtems_irq_connect_data ethernetFECIrqData = { + BSP_FAST_ETHERNET_CTRL, + (rtems_irq_hdl) m860_fec_interrupt_handler, + (rtems_irq_enable) m8xx_fec_ethernet_on, + (rtems_irq_disable) m8xx_fec_ethernet_off, + (rtems_irq_is_enabled)m8xx_fec_ethernet_isOn +}; static void m860_fec_initialize_hardware (struct m860_enet_struct *sc) @@ -437,7 +458,7 @@ m860_fec_initialize_hardware (struct m860_enet_struct *sc) * Set SIU interrupt level to LVL2 * */ - m8xx.fec.ivec = 0x02 << 29; + m8xx.fec.ivec = ((((unsigned) BSP_FAST_ETHERNET_CTRL)/2) << 29); /* * Set the TX and RX fifo sizes. For now, we'll split it evenly @@ -551,15 +572,11 @@ m860_fec_initialize_hardware (struct m860_enet_struct *sc) /* * Set up interrupts */ - status = rtems_interrupt_catch (m860_fec_interrupt_handler, - PPC_IRQ_LVL2, - &old_handler); + status = BSP_install_rtems_irq_handler (ðernetFECIrqData); if (status != RTEMS_SUCCESSFUL) rtems_panic ("Can't attach M860 FEC interrupt handler: %s\n", rtems_status_text (status)); - m8xx.simask |= M8xx_SIMASK_LVM2; - } diff --git a/c/src/lib/libbsp/powerpc/eth_comm/startup/Makefile.am b/c/src/lib/libbsp/powerpc/eth_comm/startup/Makefile.am index 6c3a60d726..55640aaf09 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/startup/Makefile.am +++ b/c/src/lib/libbsp/powerpc/eth_comm/startup/Makefile.am @@ -9,7 +9,7 @@ VPATH = @srcdir@:@srcdir@/../../../shared PGM = $(ARCH)/startup.rel C_FILES = bspclean.c bsplibc.c bsppost.c bspstart.c bootcard.c cpuinit.c \ - main.c mmutlbtab.c sbrk.c setvec.c gnatinstallhandler.c + main.c mmutlbtab.c sbrk.c gnatinstallhandler.c C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) OBJS = $(C_O_FILES) @@ -35,6 +35,6 @@ all-local: $(ARCH) $(OBJS) $(PGM) $(TMPINSTALL_FILES) .PRECIOUS: $(PGM) -EXTRA_DIST = bspstart.c linkcmds setvec.c +EXTRA_DIST = bspstart.c linkcmds include $(top_srcdir)/../../../../../../automake/local.am diff --git a/c/src/lib/libbsp/powerpc/eth_comm/startup/bspstart.c b/c/src/lib/libbsp/powerpc/eth_comm/startup/bspstart.c index 6013336b7e..11236cafd6 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/startup/bspstart.c +++ b/c/src/lib/libbsp/powerpc/eth_comm/startup/bspstart.c @@ -31,7 +31,7 @@ boardinfo_t M860_binfo; * some changes. */ extern rtems_configuration_table Configuration; - +extern unsigned long intrStackPtr; rtems_configuration_table BSP_Configuration; rtems_cpu_table Cpu_table; @@ -44,6 +44,18 @@ char *rtems_progname; void bsp_postdriver_hook(void); void bsp_libc_init( void *, unsigned32, int ); +void BSP_panic(char *s) +{ + printk("%s PANIC %s\n",_RTEMS_version, s); + __asm__ __volatile ("sc"); +} + +void _BSP_Fatal_error(unsigned int v) +{ + printk("%s PANIC ERROR %x\n",_RTEMS_version, v); + __asm__ __volatile ("sc"); +} + /* * Function: bsp_pretasking_hook * Created: 95/03/10 @@ -99,10 +111,33 @@ void bsp_start(void) extern int _end; rtems_unsigned32 heap_start; rtems_unsigned32 ws_start; + ppc_cpu_id_t myCpu; + ppc_cpu_revision_t myCpuRevision; + register unsigned char* intrStack; + register unsigned int intrNestingLevel = 0; + + /* + * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function + * store the result in global variables so that it can be used latter... + */ + myCpu = get_ppc_cpu_type(); + myCpuRevision = get_ppc_cpu_revision(); cpu_init(); mmu_init(); - + /* + * Initialize some SPRG registers related to irq handling + */ + + intrStack = (((unsigned char*)&intrStackPtr) - CPU_MINIMUM_STACK_FRAME_SIZE); + asm volatile ("mtspr 273, %0" : "=r" (intrStack) : "0" (intrStack)); + asm volatile ("mtspr 272, %0" : "=r" (intrNestingLevel) : "0" (intrNestingLevel)); + + /* + * Install our own set of exception vectors + */ + initialize_exceptions(); + /* * Allocate the memory for the RTEMS Work Space. This can come from * a variety of places: hard coded address, malloc'ed from outside @@ -162,6 +197,14 @@ void bsp_start(void) m8xx.scc2p.rbase=0; m8xx.scc2p.tbase=0; m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 ); + /* + * Initalize RTEMS IRQ system + */ + BSP_rtems_irq_mng_init(0); +#ifdef SHOW_MORE_INIT_SETTINGS + printk("Exit from bspstart\n"); +#endif + } diff --git a/c/src/lib/libbsp/powerpc/eth_comm/startup/linkcmds b/c/src/lib/libbsp/powerpc/eth_comm/startup/linkcmds index fc0dd33287..192fceb700 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/startup/linkcmds +++ b/c/src/lib/libbsp/powerpc/eth_comm/startup/linkcmds @@ -125,7 +125,15 @@ SECTIONS bss.size = bss.end - bss.start; text.size = text.end - text.start; PROVIDE(_end = bss.end); - + /* + * Interrupt stack setup + */ + + IntrStack_start = ALIGN(0x10); + . += 0x4000; + intrStack = .; + PROVIDE(intrStackPtr = intrStack); + dpram : { m8xx = .; diff --git a/c/src/lib/libbsp/powerpc/eth_comm/wrapup/Makefile.am b/c/src/lib/libbsp/powerpc/eth_comm/wrapup/Makefile.am index 7f9f2097b3..6e0916e4ad 100644 --- a/c/src/lib/libbsp/powerpc/eth_comm/wrapup/Makefile.am +++ b/c/src/lib/libbsp/powerpc/eth_comm/wrapup/Makefile.am @@ -9,7 +9,7 @@ if HAS_NETWORKING NETWORKING = network endif -BSP_PIECES = startup start canbus console $(NETWORKING) +BSP_PIECES = clock irq startup start canbus vectors console $(NETWORKING) # pieces to pick up out of libcpu/ppc # CPU_PIECES = mpc860/clock mpc860/timer mpc860/console-generic \ # mpc860/vectors @@ -17,7 +17,7 @@ BSP_PIECES = startup start canbus console $(NETWORKING) # bummer; have to use $foreach since % pattern subst rules only replace 1x OBJS = $(foreach piece, $(BSP_PIECES), $(wildcard ../$(piece)/$(ARCH)/*.o)) \ $(wildcard ../../../../libcpu/$(RTEMS_CPU)/shared/*/$(ARCH)/*.o) \ - $(wildcard ../../../../libcpu/powerpc/old_exception_processing/$(ARCH)/*.rel) \ + $(wildcard ../../../../libcpu/powerpc/new_exception_processing/$(ARCH)/*.rel) \ $(wildcard ../../../../libcpu/$(RTEMS_CPU)/$(RTEMS_CPU_MODEL)/*/$(ARCH)/*.o) LIB = $(ARCH)/libbsp.a -- cgit v1.2.3