diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-04-19 11:06:11 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-04-19 11:06:11 +0200 |
commit | e1417b38d53f0eb9eb1158324ea15222aeb12e7b (patch) | |
tree | b12fedf77dd7316a5032d816f4a0044863ccf060 | |
parent | Add libbsd sections (diff) | |
parent | rbheap: API changes and documentation (diff) | |
download | rtems-e1417b38d53f0eb9eb1158324ea15222aeb12e7b.tar.bz2 |
Merge branch 'upstream'
127 files changed, 2514 insertions, 1184 deletions
diff --git a/c/src/lib/libbsp/lm32/lm32_evr/Makefile.am b/c/src/lib/libbsp/lm32/lm32_evr/Makefile.am index fe659228f1..362bce0dc9 100644 --- a/c/src/lib/libbsp/lm32/lm32_evr/Makefile.am +++ b/c/src/lib/libbsp/lm32/lm32_evr/Makefile.am @@ -37,7 +37,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppost.c ../shared/startup/bspstart.c \ ../../shared/bspreset.c ../../shared/bsppretaskinghook.c \ ../../shared/bspgetworkarea.c ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../lm32/shared/startup/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += ../../lm32/shared/clock/ckinit.c diff --git a/c/src/lib/libbsp/lm32/shared/startup/setvec.c b/c/src/lib/libbsp/lm32/shared/startup/setvec.c deleted file mode 100644 index b7818d3699..0000000000 --- a/c/src/lib/libbsp/lm32/shared/startup/setvec.c +++ /dev/null @@ -1,43 +0,0 @@ -/* set_vector - * - * This routine installs an interrupt vector on the target Board/CPU. - * This routine is allowed to be as board dependent as necessary. - * - * INPUT: - * handler - interrupt handler entry point - * vector - vector number - * type - 0 indicates raw hardware connect - * 1 indicates RTEMS interrupt connect - * - * RETURNS: - * address of previous interrupt handler - * - * COPYRIGHT (c) 1989-1999. - * 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.com/license/LICENSE. - * - * $Id$ - * - */ - -#include <rtems.h> -#include <bsp.h> - -lm32_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 */ -) -{ - lm32_isr_entry previous_isr; - - if ( type ) - rtems_interrupt_catch( handler, vector, (rtems_isr_entry *) &previous_isr ); - else { - /* XXX: install non-RTEMS ISR as "raw" interupt */ - } - return previous_isr; -} diff --git a/c/src/lib/libbsp/lm32/shared/tsmac/tsmac.c b/c/src/lib/libbsp/lm32/shared/tsmac/tsmac.c index 568b413058..e9ef8a15da 100644 --- a/c/src/lib/libbsp/lm32/shared/tsmac/tsmac.c +++ b/c/src/lib/libbsp/lm32/shared/tsmac/tsmac.c @@ -134,7 +134,7 @@ static inline void tsmacregwrite(unsigned int reg, uint16_t value) rtems_isr tsmac_interrupt_handler(rtems_vector_number vector); -extern lm32_isr_entry set_vector(rtems_isr_entry handler, +extern rtems_isr_entry set_vector(rtems_isr_entry handler, rtems_vector_number vector, int type); /* diff --git a/c/src/lib/libbsp/m68k/Makefile.am b/c/src/lib/libbsp/m68k/Makefile.am index e569416ec0..4c98eb11d7 100644 --- a/c/src/lib/libbsp/m68k/Makefile.am +++ b/c/src/lib/libbsp/m68k/Makefile.am @@ -7,7 +7,7 @@ ACLOCAL_AMFLAGS = -I ../../../aclocal ## Descend into the @RTEMS_BSP_FAMILY@ directory SUBDIRS = @RTEMS_BSP_FAMILY@ -EXTRA_DIST = shared/m68kpretaskinghook.c shared/setvec.c shared/start.S +EXTRA_DIST = shared/m68kpretaskinghook.c ../shared/setvec.c shared/start.S EXTRA_DIST += shared/bspspuriousinit.c shared/m68000spurious.c diff --git a/c/src/lib/libbsp/m68k/av5282/Makefile.am b/c/src/lib/libbsp/m68k/av5282/Makefile.am index 00ae9e8902..7c1d52f69e 100644 --- a/c/src/lib/libbsp/m68k/av5282/Makefile.am +++ b/c/src/lib/libbsp/m68k/av5282/Makefile.am @@ -35,7 +35,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsppredriverhook.c \ ../../shared/bsppretaskinghook.c ../../shared/bspgetworkarea.c \ startup/init5282.c startup/bspstart.c \ ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/m68k/av5282/include/bsp.h b/c/src/lib/libbsp/m68k/av5282/include/bsp.h index b5b511777e..84d79b6237 100644 --- a/c/src/lib/libbsp/m68k/av5282/include/bsp.h +++ b/c/src/lib/libbsp/m68k/av5282/include/bsp.h @@ -43,7 +43,7 @@ extern int rtems_fec_driver_attach (struct rtems_bsdnet_ifconfig *config, int at uint32_t get_CPU_clock_speed(void); -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/csb360/Makefile.am b/c/src/lib/libbsp/m68k/csb360/Makefile.am index b00a2a9e32..a537907878 100644 --- a/c/src/lib/libbsp/m68k/csb360/Makefile.am +++ b/c/src/lib/libbsp/m68k/csb360/Makefile.am @@ -35,7 +35,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppredriverhook.c ../../shared/bsppretaskinghook.c \ ../../shared/bsppost.c ../../shared/bspgetworkarea.c \ ../../shared/bspstart.c startup/init5272.c ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # console libbsp_a_SOURCES += console/console-io.c ../../shared/console-polled.c diff --git a/c/src/lib/libbsp/m68k/csb360/include/bsp.h b/c/src/lib/libbsp/m68k/csb360/include/bsp.h index 79e3902f1a..7b6b352dd0 100644 --- a/c/src/lib/libbsp/m68k/csb360/include/bsp.h +++ b/c/src/lib/libbsp/m68k/csb360/include/bsp.h @@ -151,13 +151,13 @@ extern rtems_device_driver rtc_initialize( /* miscellaneous stuff assumed to exist */ -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ extern rtems_isr (*rtems_clock_hook)(rtems_vector_number); /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/gen68302/Makefile.am b/c/src/lib/libbsp/m68k/gen68302/Makefile.am index 9d4dea0237..fe1a77cdfd 100644 --- a/c/src/lib/libbsp/m68k/gen68302/Makefile.am +++ b/c/src/lib/libbsp/m68k/gen68302/Makefile.am @@ -37,7 +37,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppredriverhook.c ../../shared/bsppretaskinghook.c \ ../../shared/bsppost.c ../../shared/bspstart.c ../../shared/bootcard.c \ ../../shared/bspgetworkarea.c ../../shared/sbrk.c \ - ../../m68k/shared/setvec.c ../../shared/gnatinstallhandler.c + ../../shared/setvec.c ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/ckinit.c # console diff --git a/c/src/lib/libbsp/m68k/gen68302/include/bsp.h b/c/src/lib/libbsp/m68k/gen68302/include/bsp.h index 5a53d41b3f..2e75297b09 100644 --- a/c/src/lib/libbsp/m68k/gen68302/include/bsp.h +++ b/c/src/lib/libbsp/m68k/gen68302/include/bsp.h @@ -61,11 +61,11 @@ extern "C" { /* miscellaneous stuff assumed to exist */ -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/gen68340/Makefile.am b/c/src/lib/libbsp/m68k/gen68340/Makefile.am index 45c66a00ff..689ce53d02 100644 --- a/c/src/lib/libbsp/m68k/gen68340/Makefile.am +++ b/c/src/lib/libbsp/m68k/gen68340/Makefile.am @@ -39,7 +39,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppredriverhook.c ../../shared/bspgetworkarea.c \ ../../shared/bsppost.c ../../shared/bspstart.c startup/init68340.c \ ../../shared/bootcard.c ../../shared/bsppretaskinghook.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ startup/dumpanic.c ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/ckinit.c diff --git a/c/src/lib/libbsp/m68k/gen68340/include/bsp.h b/c/src/lib/libbsp/m68k/gen68340/include/bsp.h index 450131e727..e0eb9a7337 100644 --- a/c/src/lib/libbsp/m68k/gen68340/include/bsp.h +++ b/c/src/lib/libbsp/m68k/gen68340/include/bsp.h @@ -51,11 +51,11 @@ extern "C" { /* Structures */ -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/gen68340/startup/init68340.c b/c/src/lib/libbsp/m68k/gen68340/startup/init68340.c index 7525136488..b331ef3a59 100644 --- a/c/src/lib/libbsp/m68k/gen68340/startup/init68340.c +++ b/c/src/lib/libbsp/m68k/gen68340/startup/init68340.c @@ -22,7 +22,7 @@ extern void _CopyDataClearBSSAndStart (void); */ void _Init68340 (void) { - m68k_isr_entry *vbr; + rtems_isr_entry *vbr; int i; /* diff --git a/c/src/lib/libbsp/m68k/gen68360/Makefile.am b/c/src/lib/libbsp/m68k/gen68360/Makefile.am index 0de0a20215..ae439ca6c0 100644 --- a/c/src/lib/libbsp/m68k/gen68360/Makefile.am +++ b/c/src/lib/libbsp/m68k/gen68360/Makefile.am @@ -35,7 +35,7 @@ libbsp_a_SOURCES += startup/alloc360.c ../../shared/bspclean.c \ ../../shared/bsplibc.c ../../shared/bsppost.c \ ../../shared/bspgetworkarea.c ../../shared/bspstart.c \ startup/init68360.c ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/m68k/gen68360/include/bsp.h b/c/src/lib/libbsp/m68k/gen68360/include/bsp.h index a12495b63b..4b5c8588f0 100644 --- a/c/src/lib/libbsp/m68k/gen68360/include/bsp.h +++ b/c/src/lib/libbsp/m68k/gen68360/include/bsp.h @@ -61,7 +61,7 @@ extern int rtems_scc1_driver_attach (struct rtems_bsdnet_ifconfig *config, int a : "0" (_tmp), "1" (_delay) ); \ } -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ @@ -72,7 +72,7 @@ extern char M360DefaultWatchdogFeeder; extern int m360_clock_rate; /* BRG clock rate, defined in console.c */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c index 37c7076733..207ab1abea 100644 --- a/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c +++ b/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c @@ -45,7 +45,7 @@ void M360ExecuteRISC(uint16_t command) void _Init68360 (void) { int i; - m68k_isr_entry *vbr; + rtems_isr_entry *vbr; unsigned long ramSize; volatile unsigned long *RamBase_p; diff --git a/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am b/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am index 1aef08ac76..d020eb74c4 100644 --- a/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am +++ b/c/src/lib/libbsp/m68k/genmcf548x/Makefile.am @@ -37,7 +37,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppost.c ../../shared/bspgetworkarea.c \ ../../shared/bspreset_loop.c ../../shared/bsppretaskinghook.c \ ../../shared/bsppredriverhook.c startup/init548x.c startup/bspstart.c \ - ../../shared/bootcard.c ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/bootcard.c ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/m68k/genmcf548x/include/bsp.h b/c/src/lib/libbsp/m68k/genmcf548x/include/bsp.h index 948767e69f..dba6f5ae4c 100644 --- a/c/src/lib/libbsp/m68k/genmcf548x/include/bsp.h +++ b/c/src/lib/libbsp/m68k/genmcf548x/include/bsp.h @@ -81,7 +81,7 @@ extern int rtems_fec_driver_attach (struct rtems_bsdnet_ifconfig *config, int at uint32_t get_CPU_clock_speed(void); -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/idp/Makefile.am b/c/src/lib/libbsp/m68k/idp/Makefile.am index 0d522c26ff..c1979c3652 100644 --- a/c/src/lib/libbsp/m68k/idp/Makefile.am +++ b/c/src/lib/libbsp/m68k/idp/Makefile.am @@ -34,7 +34,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppredriverhook.c \ ../../shared/bsppost.c startup/bspstart.c ../../shared/bootcard.c \ ../../shared/bsppretaskinghook.c ../../shared/bspgetworkarea.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/ckinit.c diff --git a/c/src/lib/libbsp/m68k/idp/include/bsp.h b/c/src/lib/libbsp/m68k/idp/include/bsp.h index d22d585e88..aace39c825 100644 --- a/c/src/lib/libbsp/m68k/idp/include/bsp.h +++ b/c/src/lib/libbsp/m68k/idp/include/bsp.h @@ -23,11 +23,11 @@ #define RAM_START 0 #define RAM_END 0x200000 -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/idp/startup/bspstart.c b/c/src/lib/libbsp/m68k/idp/startup/bspstart.c index ef8d8dc5de..423564809d 100644 --- a/c/src/lib/libbsp/m68k/idp/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/idp/startup/bspstart.c @@ -30,7 +30,7 @@ void led_putnum(void); */ void bsp_start( void ) { - m68k_isr_entry *monitors_vector_table; + rtems_isr_entry *monitors_vector_table; int index; /* RAM size set in linker script */ @@ -39,7 +39,7 @@ void bsp_start( void ) /* * Set the VBR here to the monitor's default. */ - monitors_vector_table = (m68k_isr_entry *)0; + monitors_vector_table = (rtems_isr_entry *)0; /* This is where you set vector base register = 0 */ m68k_set_vbr( monitors_vector_table ); diff --git a/c/src/lib/libbsp/m68k/mcf5206elite/Makefile.am b/c/src/lib/libbsp/m68k/mcf5206elite/Makefile.am index 91e38f7520..54a027078b 100644 --- a/c/src/lib/libbsp/m68k/mcf5206elite/Makefile.am +++ b/c/src/lib/libbsp/m68k/mcf5206elite/Makefile.am @@ -43,7 +43,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppredriverhook.c ../../shared/bspgetworkarea.c \ ../../shared/bsppost.c ../../shared/bsppretaskinghook.c \ ../../shared/bspstart.c startup/init5206e.c ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # console libbsp_a_SOURCES += console/console.c ../../shared/dummy_printk_support.c diff --git a/c/src/lib/libbsp/m68k/mcf5206elite/include/bsp.h b/c/src/lib/libbsp/m68k/mcf5206elite/include/bsp.h index 7139981e12..a418ee3006 100644 --- a/c/src/lib/libbsp/m68k/mcf5206elite/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mcf5206elite/include/bsp.h @@ -162,13 +162,13 @@ extern char _SYS_CLOCK_FREQUENCY; /* Don't use this variable directly!!! */ } -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ extern rtems_isr (*rtems_clock_hook)(rtems_vector_number); /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mcf52235/Makefile.am b/c/src/lib/libbsp/m68k/mcf52235/Makefile.am index d4f3867bb4..a37ac2b88b 100644 --- a/c/src/lib/libbsp/m68k/mcf52235/Makefile.am +++ b/c/src/lib/libbsp/m68k/mcf52235/Makefile.am @@ -35,7 +35,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsppredriverhook.c \ ../../shared/bsppretaskinghook.c ../../shared/bspgetworkarea.c \ startup/init52235.c ../../shared/bspstart.c startup/cfinit.c \ startup/bspgetcpuclockspeed.c ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h b/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h index e494efd48e..701e604327 100644 --- a/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mcf52235/include/bsp.h @@ -43,7 +43,7 @@ extern "C" { uint32_t bsp_get_CPU_clock_speed(void); -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mcf5225x/Makefile.am b/c/src/lib/libbsp/m68k/mcf5225x/Makefile.am index 1d47db84da..4a7082db96 100644 --- a/c/src/lib/libbsp/m68k/mcf5225x/Makefile.am +++ b/c/src/lib/libbsp/m68k/mcf5225x/Makefile.am @@ -37,7 +37,7 @@ libbsp_a_SOURCES = \ ../../shared/bspgetworkarea.c \ startup/init5225x.c startup/bspstart.c \ ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c libbsp_a_SOURCES += clock/clock.c libbsp_a_SOURCES += console/console.c diff --git a/c/src/lib/libbsp/m68k/mcf5225x/include/bsp.h b/c/src/lib/libbsp/m68k/mcf5225x/include/bsp.h index d56c4f65ce..9f24087542 100644 --- a/c/src/lib/libbsp/m68k/mcf5225x/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mcf5225x/include/bsp.h @@ -64,7 +64,7 @@ extern "C" { uint32_t bsp_get_CPU_clock_speed(void); -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mcf5235/Makefile.am b/c/src/lib/libbsp/m68k/mcf5235/Makefile.am index dac6a0a711..a1cbb4ce24 100644 --- a/c/src/lib/libbsp/m68k/mcf5235/Makefile.am +++ b/c/src/lib/libbsp/m68k/mcf5235/Makefile.am @@ -35,7 +35,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsppredriverhook.c \ ../../shared/bsplibc.c ../../shared/bsppost.c ../../shared/bspreset_loop.c \ startup/bspgetcpuclockspeed.c ../../shared/bsppretaskinghook.c \ ../../shared/bspgetworkarea.c startup/init5235.c startup/bspstart.c \ - ../../shared/bootcard.c ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/bootcard.c ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c ../../shared/bspinit.c # clock libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/m68k/mcf5235/include/bsp.h b/c/src/lib/libbsp/m68k/mcf5235/include/bsp.h index b069050fdd..b822b8d59a 100644 --- a/c/src/lib/libbsp/m68k/mcf5235/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mcf5235/include/bsp.h @@ -37,7 +37,7 @@ extern int rtems_fec_driver_attach (struct rtems_bsdnet_ifconfig *config, int at /* functions */ uint32_t get_CPU_clock_speed(void); -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mcf5329/Makefile.am b/c/src/lib/libbsp/m68k/mcf5329/Makefile.am index 117ed35642..b242072731 100644 --- a/c/src/lib/libbsp/m68k/mcf5329/Makefile.am +++ b/c/src/lib/libbsp/m68k/mcf5329/Makefile.am @@ -35,7 +35,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsppredriverhook.c \ ../../shared/bsppretaskinghook.c ../../shared/bspgetworkarea.c \ startup/init5329.c startup/bspstart.c startup/cfinit.c\ ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h diff --git a/c/src/lib/libbsp/m68k/mcf5329/include/bsp.h b/c/src/lib/libbsp/m68k/mcf5329/include/bsp.h index 88421c15e1..7a7db3b575 100644 --- a/c/src/lib/libbsp/m68k/mcf5329/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mcf5329/include/bsp.h @@ -43,7 +43,7 @@ extern int rtems_fec_driver_attach (struct rtems_bsdnet_ifconfig *config, int at uint32_t bsp_get_CPU_clock_speed(void); uint32_t bsp_get_BUS_clock_speed(void); -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mrm332/Makefile.am b/c/src/lib/libbsp/m68k/mrm332/Makefile.am index a14f55ee03..2d9ec395ec 100644 --- a/c/src/lib/libbsp/m68k/mrm332/Makefile.am +++ b/c/src/lib/libbsp/m68k/mrm332/Makefile.am @@ -35,7 +35,7 @@ libbsp_a_SOURCES = libbsp_a_SOURCES += startup/start_c.c ../../shared/bsplibc.c \ ../../shared/bsppost.c ../../shared/bspstart.c startup/bsppredriverhook.c \ ../../shared/bspclean.c ../../shared/bootcard.c ../../shared/sbrk.c \ - ../../m68k/shared/setvec.c ../../shared/bsppretaskinghook.c \ + ../../shared/setvec.c ../../shared/bsppretaskinghook.c \ ../../shared/bspgetworkarea.c ../../shared/gnatinstallhandler.c \ startup/except_vect_332_ROM.S # clock diff --git a/c/src/lib/libbsp/m68k/mrm332/include/bsp.h b/c/src/lib/libbsp/m68k/mrm332/include/bsp.h index 4488abec50..88d2e6c94a 100644 --- a/c/src/lib/libbsp/m68k/mrm332/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mrm332/include/bsp.h @@ -86,14 +86,14 @@ extern char _copy_data_from_rom[]; /* miscellaneous stuff assumed to exist */ -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ extern int stack_size; extern int stack_start; /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mrm332/start/start.S b/c/src/lib/libbsp/m68k/mrm332/start/start.S index 5bdf88124b..8d73e308a0 100644 --- a/c/src/lib/libbsp/m68k/mrm332/start/start.S +++ b/c/src/lib/libbsp/m68k/mrm332/start/start.S @@ -120,7 +120,7 @@ END_CODE * Initialize vector table. */ { - m68k_isr_entry *monitors_vector_table; + rtems_isr_entry *monitors_vector_table; m68k_get_vbr(monitors_vector_table); diff --git a/c/src/lib/libbsp/m68k/mrm332/startup/start_c.c b/c/src/lib/libbsp/m68k/mrm332/startup/start_c.c index 1a9054e2e1..e268f56fe9 100644 --- a/c/src/lib/libbsp/m68k/mrm332/startup/start_c.c +++ b/c/src/lib/libbsp/m68k/mrm332/startup/start_c.c @@ -7,8 +7,8 @@ #define __START_C__ #include "bsp.h" -m68k_isr_entry M68Kvec[256]; -m68k_isr_entry vectors[256]; +rtems_isr_entry M68Kvec[256]; +rtems_isr_entry vectors[256]; void boot_card(const char *cmdline); @@ -94,7 +94,7 @@ void start_c(void) { * Initialize vector table. */ { - m68k_isr_entry *monitors_vector_table; + rtems_isr_entry *monitors_vector_table; m68k_get_vbr(monitors_vector_table); diff --git a/c/src/lib/libbsp/m68k/mvme136/Makefile.am b/c/src/lib/libbsp/m68k/mvme136/Makefile.am index faa0c889f8..9390a5c571 100644 --- a/c/src/lib/libbsp/m68k/mvme136/Makefile.am +++ b/c/src/lib/libbsp/m68k/mvme136/Makefile.am @@ -34,7 +34,7 @@ libbsp_a_SOURCES += startup/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppost.c ../../shared/bsppredriverhook.c \ startup/bspstart.c ../../shared/bootcard.c \ ../../shared/bsppretaskinghook.c ../../shared/bspgetworkarea.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c + ../../shared/sbrk.c ../../shared/setvec.c # gnatsupp libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c # clock diff --git a/c/src/lib/libbsp/m68k/mvme136/include/bsp.h b/c/src/lib/libbsp/m68k/mvme136/include/bsp.h index 26d8b5bb70..15d37cb4cb 100644 --- a/c/src/lib/libbsp/m68k/mvme136/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mvme136/include/bsp.h @@ -80,11 +80,11 @@ struct w_m681_info { char ivr; /* interrupt vector register */ }; -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c index d1b659e194..56eea977e4 100644 --- a/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme136/startup/bspstart.c @@ -24,10 +24,10 @@ */ void bsp_start( void ) { - m68k_isr_entry *monitors_vector_table; + rtems_isr_entry *monitors_vector_table; int index; - monitors_vector_table = (m68k_isr_entry *)0; /* 135Bug Vectors are at 0 */ + monitors_vector_table = (rtems_isr_entry *)0; /* 135Bug Vectors are at 0 */ m68k_set_vbr( monitors_vector_table ); for ( index=2 ; index<=255 ; index++ ) diff --git a/c/src/lib/libbsp/m68k/mvme147/Makefile.am b/c/src/lib/libbsp/m68k/mvme147/Makefile.am index 068d363bd5..4328aaa422 100644 --- a/c/src/lib/libbsp/m68k/mvme147/Makefile.am +++ b/c/src/lib/libbsp/m68k/mvme147/Makefile.am @@ -34,7 +34,7 @@ libbsp_a_SOURCES += startup/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppost.c startup/bspstart.c ../../shared/bootcard.c \ ../../shared/bsppretaskinghook.c ../../shared/bsppredriverhook.c \ ../../shared/bspgetworkarea.c ../../shared/sbrk.c \ - ../../m68k/shared/setvec.c ../../shared/gnatinstallhandler.c + ../../shared/setvec.c ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/ckinit.c # console diff --git a/c/src/lib/libbsp/m68k/mvme147/include/bsp.h b/c/src/lib/libbsp/m68k/mvme147/include/bsp.h index 79dfbe8c25..8ebbeffcfe 100644 --- a/c/src/lib/libbsp/m68k/mvme147/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mvme147/include/bsp.h @@ -104,11 +104,11 @@ struct pcc_map { #define CONSOLE_DATA 0xfffe3001 #endif -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mvme147/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme147/startup/bspstart.c index ffa27778fe..46999c3715 100644 --- a/c/src/lib/libbsp/m68k/mvme147/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme147/startup/bspstart.c @@ -28,10 +28,10 @@ void bsp_start( void ) { - m68k_isr_entry *monitors_vector_table; + rtems_isr_entry *monitors_vector_table; int index; - monitors_vector_table = (m68k_isr_entry *)0; /* 135Bug Vectors are at 0 */ + monitors_vector_table = (rtems_isr_entry *)0; /* 135Bug Vectors are at 0 */ m68k_set_vbr( monitors_vector_table ); for ( index=2 ; index<=255 ; index++ ) diff --git a/c/src/lib/libbsp/m68k/mvme147s/Makefile.am b/c/src/lib/libbsp/m68k/mvme147s/Makefile.am index ec47276a4b..04d42d1a27 100644 --- a/c/src/lib/libbsp/m68k/mvme147s/Makefile.am +++ b/c/src/lib/libbsp/m68k/mvme147s/Makefile.am @@ -33,8 +33,8 @@ libbsp_a_SOURCES = libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppost.c ../../shared/bsppredriverhook.c \ startup/bspstart.c ../../shared/bootcard.c \ - ../../shared/bsppretaskinghook.c ../../m68k/shared/setvec.c \ - ../../shared/bspgetworkarea.c ../../m68k/shared/setvec.c \ + ../../shared/bsppretaskinghook.c ../../shared/setvec.c \ + ../../shared/bspgetworkarea.c ../../shared/setvec.c \ ../../shared/sbrk.c ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += ../mvme147/clock/ckinit.c diff --git a/c/src/lib/libbsp/m68k/mvme147s/include/bsp.h b/c/src/lib/libbsp/m68k/mvme147s/include/bsp.h index 1df77f1f8f..246e4e0126 100644 --- a/c/src/lib/libbsp/m68k/mvme147s/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mvme147s/include/bsp.h @@ -175,7 +175,7 @@ struct vme_gcsr_map { #define EXTERN extern #endif -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* * NOTE: Use the standard Clock driver entry @@ -183,7 +183,7 @@ extern m68k_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mvme147s/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme147s/startup/bspstart.c index cc21805b25..d8d7544b4c 100644 --- a/c/src/lib/libbsp/m68k/mvme147s/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme147s/startup/bspstart.c @@ -27,11 +27,11 @@ */ void bsp_start( void ) { - m68k_isr_entry *monitors_vector_table; + rtems_isr_entry *monitors_vector_table; int index; uint8_t node_number; - monitors_vector_table = (m68k_isr_entry *)0; /* 147Bug Vectors are at 0 */ + monitors_vector_table = (rtems_isr_entry *)0; /* 147Bug Vectors are at 0 */ m68k_set_vbr( monitors_vector_table ); for ( index=2 ; index<=255 ; index++ ) diff --git a/c/src/lib/libbsp/m68k/mvme162/Makefile.am b/c/src/lib/libbsp/m68k/mvme162/Makefile.am index 4b3fb0e3e3..988245a1e1 100644 --- a/c/src/lib/libbsp/m68k/mvme162/Makefile.am +++ b/c/src/lib/libbsp/m68k/mvme162/Makefile.am @@ -39,7 +39,7 @@ libbsp_a_SOURCES += startup/bspclean.c ../../shared/bsplibc.c \ startup/bspstart.c ../../shared/bootcard.c \ ../../shared/bsppretaskinghook.c startup/page_table.c \ ../../shared/bspgetworkarea.c startup/page_table.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/ckinit.c diff --git a/c/src/lib/libbsp/m68k/mvme162/README b/c/src/lib/libbsp/m68k/mvme162/README index c2b3d4a7ca..a8c7798a07 100644 --- a/c/src/lib/libbsp/m68k/mvme162/README +++ b/c/src/lib/libbsp/m68k/mvme162/README @@ -114,7 +114,7 @@ configured for the board in use - bspstart.c was modified as follows: - monitors_vector_table = (m68k_isr *)0xFFE00000; + monitors_vector_table = (rtems_isr *)0xFFE00000; was made to point to the power-up location of MVME162 interrupt vector table. diff --git a/c/src/lib/libbsp/m68k/mvme162/include/bsp.h b/c/src/lib/libbsp/m68k/mvme162/include/bsp.h index b043c2c73f..7dfd0fe1a2 100644 --- a/c/src/lib/libbsp/m68k/mvme162/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mvme162/include/bsp.h @@ -185,11 +185,11 @@ typedef volatile struct { */ #define MOT_162BUG_VEC_ADDRESS 0x00000000 -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c index 7e23b53f8f..598344675f 100644 --- a/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c @@ -31,10 +31,10 @@ */ void bsp_start( void ) { - m68k_isr_entry *monitors_vector_table; + rtems_isr_entry *monitors_vector_table; int index; - monitors_vector_table = (m68k_isr_entry *)MOT_162BUG_VEC_ADDRESS; + monitors_vector_table = (rtems_isr_entry *)MOT_162BUG_VEC_ADDRESS; m68k_set_vbr( monitors_vector_table ); for ( index=2 ; index<=255 ; index++ ) diff --git a/c/src/lib/libbsp/m68k/mvme167/Makefile.am b/c/src/lib/libbsp/m68k/mvme167/Makefile.am index 8267ca2256..b6f76a66e3 100644 --- a/c/src/lib/libbsp/m68k/mvme167/Makefile.am +++ b/c/src/lib/libbsp/m68k/mvme167/Makefile.am @@ -39,7 +39,7 @@ libbsp_a_SOURCES += startup/bspclean.c ../../shared/bsplibc.c \ ../../shared/bspgetworkarea.c \ ../../shared/bsppost.c startup/bspstart.c ../../shared/bootcard.c \ ../../shared/bsppretaskinghook.c startup/page_table.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/ckinit.c diff --git a/c/src/lib/libbsp/m68k/mvme167/include/bsp.h b/c/src/lib/libbsp/m68k/mvme167/include/bsp.h index 5dbd996843..5c0ec6a3b0 100644 --- a/c/src/lib/libbsp/m68k/mvme167/include/bsp.h +++ b/c/src/lib/libbsp/m68k/mvme167/include/bsp.h @@ -296,7 +296,7 @@ typedef volatile struct cd2401_regs_ { /* BSP-wide functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type @@ -310,7 +310,7 @@ m68k_isr_entry set_vector( #define EXTERN extern #endif -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ #ifdef __cplusplus } diff --git a/c/src/lib/libbsp/m68k/mvme167/startup/bspstart.c b/c/src/lib/libbsp/m68k/mvme167/startup/bspstart.c index 030d648414..7e934b5257 100644 --- a/c/src/lib/libbsp/m68k/mvme167/startup/bspstart.c +++ b/c/src/lib/libbsp/m68k/mvme167/startup/bspstart.c @@ -26,7 +26,7 @@ rtems_extensions_table user_extension_table; void M68KFPSPInstallExceptionHandlers (void); -extern m68k_isr_entry M68Kvec[]; +extern rtems_isr_entry M68Kvec[]; /* * bsp_start() @@ -57,13 +57,13 @@ extern m68k_isr_entry M68Kvec[]; */ void bsp_start( void ) { - m68k_isr_entry *rom_monitor_vector_table; + rtems_isr_entry *rom_monitor_vector_table; int index; /* * 167Bug Vectors are at 0xFFE00000 */ - rom_monitor_vector_table = (m68k_isr_entry *)0xFFE00000; + rom_monitor_vector_table = (rtems_isr_entry *)0xFFE00000; m68k_set_vbr( rom_monitor_vector_table ); /* diff --git a/c/src/lib/libbsp/m68k/ods68302/Makefile.am b/c/src/lib/libbsp/m68k/ods68302/Makefile.am index 841d9e7a5a..3cd01c37e1 100644 --- a/c/src/lib/libbsp/m68k/ods68302/Makefile.am +++ b/c/src/lib/libbsp/m68k/ods68302/Makefile.am @@ -54,7 +54,7 @@ libbsp_a_SOURCES += startup/cpuboot.c startup/crc.c startup/debugport.c \ startup/trace.c ../../shared/gnatinstallhandler.c ../../shared/bsplibc.c \ ../../shared/bsppredriverhook.c ../../shared/bsppost.c \ ../../shared/bspstart.c ../../shared/bspclean.c ../../shared/sbrk.c \ - ../../m68k/shared/setvec.c + ../../shared/setvec.c # clock libbsp_a_SOURCES += clock/ckinit.c # console diff --git a/c/src/lib/libbsp/m68k/ods68302/include/bsp.h b/c/src/lib/libbsp/m68k/ods68302/include/bsp.h index 8c140445a5..1e08d4f6a6 100644 --- a/c/src/lib/libbsp/m68k/ods68302/include/bsp.h +++ b/c/src/lib/libbsp/m68k/ods68302/include/bsp.h @@ -68,11 +68,11 @@ extern "C" { #define EXTERN extern #endif -extern m68k_isr_entry M68Kvec[]; /* vector table address */ +extern rtems_isr_entry M68Kvec[]; /* vector table address */ /* functions */ -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/m68k/shared/setvec.c b/c/src/lib/libbsp/m68k/shared/setvec.c deleted file mode 100644 index 90323fbd51..0000000000 --- a/c/src/lib/libbsp/m68k/shared/setvec.c +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * This routine installs an interrupt vector using the basic - * RTEMS mechanisms. This implementation should be suitable for - * most m68k based boards. However, if the board has an unusual - * interrupt controller or most somehow manipulate board specific - * hardware to enable/disable, mask, prioritize, etc an interrupt - * source, then this routine should be customized to support that. - * - * COPYRIGHT (c) 1989-1999. - * 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.com/license/LICENSE. - * - * $Id$ - */ - -#include <rtems.h> -#include <bsp.h> - -m68k_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; - - if ( type ) - rtems_interrupt_catch( handler, vector, &previous_isr ); - else { - _CPU_ISR_install_raw_handler( vector, handler, (void *)&previous_isr ); - } - return (m68k_isr_entry) previous_isr; -} diff --git a/c/src/lib/libbsp/m68k/sim68000/Makefile.am b/c/src/lib/libbsp/m68k/sim68000/Makefile.am index a3d34d2395..c8d5223fca 100644 --- a/c/src/lib/libbsp/m68k/sim68000/Makefile.am +++ b/c/src/lib/libbsp/m68k/sim68000/Makefile.am @@ -34,7 +34,7 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ ../../shared/bsppost.c ../../shared/bspstart.c ../../shared/bootcard.c \ startup/bsppredriverhook.c ../../shared/bsppretaskinghook.c \ ../../shared/bspgetworkarea.c ../../shared/sbrk.c \ - ../../m68k/shared/setvec.c ../../shared/gnatinstallhandler.c \ + ../../shared/setvec.c ../../shared/gnatinstallhandler.c \ ../../m68k/shared/bspspuriousinit.c ../../m68k/shared/m68000spurious.c \ startup/spurious_assistant.c # clock diff --git a/c/src/lib/libbsp/m68k/sim68000/include/bsp.h b/c/src/lib/libbsp/m68k/sim68000/include/bsp.h index 4c0702d0da..3d6b71cc84 100644 --- a/c/src/lib/libbsp/m68k/sim68000/include/bsp.h +++ b/c/src/lib/libbsp/m68k/sim68000/include/bsp.h @@ -50,7 +50,7 @@ extern "C" { /* functions */ -m68k_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int ); +rtems_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int ); #ifdef __cplusplus } diff --git a/c/src/lib/libbsp/m68k/uC5282/Makefile.am b/c/src/lib/libbsp/m68k/uC5282/Makefile.am index 968ef39bac..51c0c24f4f 100644 --- a/c/src/lib/libbsp/m68k/uC5282/Makefile.am +++ b/c/src/lib/libbsp/m68k/uC5282/Makefile.am @@ -34,7 +34,7 @@ libbsp_a_SOURCES += startup/bspclean.c ../../shared/bsplibc.c startup/bspreset.c ../../shared/bsppost.c ../../shared/bsppredriverhook.c \ ../../shared/bsppretaskinghook.c ../../shared/bspgetworkarea.c \ startup/init5282.c startup/bspstart.c ../../shared/bootcard.c \ - ../../shared/sbrk.c ../../m68k/shared/setvec.c \ + ../../shared/sbrk.c ../../shared/setvec.c \ ../../shared/gnatinstallhandler.c # clock libbsp_a_SOURCES += clock/clock.c ../../../clockdrv_shell.h diff --git a/c/src/lib/libbsp/m68k/uC5282/include/bsp.h b/c/src/lib/libbsp/m68k/uC5282/include/bsp.h index 47e379781f..4365cf33d4 100644 --- a/c/src/lib/libbsp/m68k/uC5282/include/bsp.h +++ b/c/src/lib/libbsp/m68k/uC5282/include/bsp.h @@ -71,7 +71,7 @@ const char *bsp_getbenv(const char *a); int bsp_flash_erase_range(volatile unsigned short *flashptr, int start, int end); int bsp_flash_write_range(volatile unsigned short *flashptr, bsp_mnode_t *chain, int offset); -m68k_isr_entry set_vector( +rtems_isr_entry set_vector( rtems_isr_entry handler, rtems_vector_number vector, int type diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h b/c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h index 8513f7daed..c137ab4978 100644 --- a/c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h +++ b/c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h @@ -38,7 +38,7 @@ extern "C" { /* functions */ -no_cpu_isr_entry set_vector( /* returns old vector */ +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 */ diff --git a/c/src/lib/libbsp/no_cpu/no_bsp/startup/setvec.c b/c/src/lib/libbsp/no_cpu/no_bsp/startup/setvec.c index e72a92fb24..deb2b13a7f 100644 --- a/c/src/lib/libbsp/no_cpu/no_bsp/startup/setvec.c +++ b/c/src/lib/libbsp/no_cpu/no_bsp/startup/setvec.c @@ -25,13 +25,13 @@ #include <rtems.h> #include <bsp.h> -no_cpu_isr_entry set_vector( /* returns old vector */ +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 */ ) { - no_cpu_isr_entry previous_isr; + rtems_isr_entry previous_isr; if ( type ) rtems_interrupt_catch( handler, vector, (rtems_isr_entry *) &previous_isr ); diff --git a/c/src/lib/libbsp/sparc/Makefile.am b/c/src/lib/libbsp/sparc/Makefile.am index 4f445ba49d..2b9909c910 100644 --- a/c/src/lib/libbsp/sparc/Makefile.am +++ b/c/src/lib/libbsp/sparc/Makefile.am @@ -17,7 +17,17 @@ EXTRA_DIST += shared/irq/irq-shared.c # AMBA Plug&Play bus EXTRA_DIST += shared/include/ambapp.h +EXTRA_DIST += shared/include/ambapp_ids.h EXTRA_DIST += shared/amba/ambapp.c +EXTRA_DIST += shared/amba/ambapp_alloc.c +EXTRA_DIST += shared/amba/ambapp_count.c +EXTRA_DIST += shared/amba/ambapp_depth.c +EXTRA_DIST += shared/amba/ambapp_find_by_idx.c +EXTRA_DIST += shared/amba/ambapp_freq.c +EXTRA_DIST += shared/amba/ambapp_parent.c +EXTRA_DIST += shared/amba/ambapp_names.c +EXTRA_DIST += shared/amba/ambapp_old.c +EXTRA_DIST += shared/amba/ambapp_show.c # PCI bus EXTRA_DIST += shared/include/pci.h diff --git a/c/src/lib/libbsp/sparc/leon2/Makefile.am b/c/src/lib/libbsp/sparc/leon2/Makefile.am index 2acca78685..c2310bc726 100644 --- a/c/src/lib/libbsp/sparc/leon2/Makefile.am +++ b/c/src/lib/libbsp/sparc/leon2/Makefile.am @@ -14,7 +14,6 @@ include_HEADERS = include/bsp.h include_HEADERS += include/tm27.h include_HEADERS += include/rasta.h include_HEADERS += include/cchip.h -include_HEADERS += ../../sparc/shared/include/ambapp.h include_HEADERS += ../../sparc/shared/include/grspw.h include_HEADERS += ../../sparc/shared/include/grspw_pci.h include_HEADERS += ../../sparc/shared/include/grspw_rasta.h @@ -79,8 +78,20 @@ libbsp_a_SOURCES += \ ../../shared/src/irq-legacy.c \ ../../shared/src/irq-server.c \ ../../shared/src/irq-shell.c -# AMBA PnP Scanning + +# AMBA bus +include_HEADERS += ../../sparc/shared/include/ambapp.h +include_HEADERS += ../../sparc/shared/include/ambapp_ids.h libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_alloc.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_count.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_depth.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_find_by_idx.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_freq.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_parent.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_old.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_names.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_show.c # PCI libbsp_a_SOURCES += pci/pci.c ../../sparc/shared/pci/pcifinddevice.c # RASTA Kit diff --git a/c/src/lib/libbsp/sparc/leon2/cchip/cchip.c b/c/src/lib/libbsp/sparc/leon2/cchip/cchip.c index 59c17dd9ff..b3809aa116 100644 --- a/c/src/lib/libbsp/sparc/leon2/cchip/cchip.c +++ b/c/src/lib/libbsp/sparc/leon2/cchip/cchip.c @@ -1,5 +1,9 @@ /* - * $Id$ + * GR-701 (Companion Chip) PCI board driver + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. */ #include <bsp.h> @@ -83,8 +87,8 @@ typedef struct { int bus, dev, fun; /* AMBA bus */ - amba_confarea_type amba_bus; - struct amba_mmap amba_maps[2]; + struct ambapp_bus amba_bus; + struct ambapp_mmap amba_maps[2]; /* FT AHB SRAM */ int ftsram_size; /* kb */ @@ -100,8 +104,7 @@ int init_pcif(void){ int i,bus,dev,fun; pci_bridge_regs *pcib; amba_bridge_regs *ambab; - int amba_master_cnt; - amba_confarea_type *abus; + struct ambapp_bus *abus; if ( BSP_pciFindDevice(0x1AC8, 0x0701, 0, &bus, &dev, &fun) == 0 ) { ; @@ -136,13 +139,13 @@ int init_pcif(void){ /* AMBA MAP cc1.bars[1] (in CPU) ==> 0xf0000000(remote amba address) */ cc1.amba_maps[0].size = 0x04000000; - cc1.amba_maps[0].cpu_adr = cc1.bars[1]; - cc1.amba_maps[0].remote_amba_adr = 0xfc000000; + cc1.amba_maps[0].local_adr = cc1.bars[1]; + cc1.amba_maps[0].remote_adr = 0xfc000000; /* Mark end of table */ cc1.amba_maps[1].size=0; - cc1.amba_maps[1].cpu_adr = 0; - cc1.amba_maps[1].remote_amba_adr = 0; + cc1.amba_maps[1].local_adr = 0; + cc1.amba_maps[1].remote_adr = 0; /* Enable I/O and Mem accesses */ pci_read_config_dword(bus, dev, fun, 0x4, &com1); @@ -161,16 +164,14 @@ int init_pcif(void){ /* Scan bus for AMBA devices */ abus = &cc1.amba_bus; - memset(abus,0,sizeof(amba_confarea_type)); - amba_scan(abus,cc1.bars[1]+0x3f00000,&cc1.amba_maps[0]); + memset(abus,0,sizeof(*abus)); + ambapp_scan(abus, cc1.bars[1]+0x3f00000, NULL, &cc1.amba_maps[0]); - /* Get number of amba masters */ - amba_master_cnt = abus->ahbmst.devnr; -#ifdef BOARD_INFO - printk("Found %d AMBA masters\n\r",amba_master_cnt); -#endif - for(i=1; i<amba_master_cnt; i++){ + /* Init all msters, max 16 */ + for(i=1; i<16; i++) { ambab->ambabars[i] = 0x40000000; + if (READ_REG(&ambab->ambabars[i]) != 0x40000000) + break; } /* Enable PCI Master */ @@ -192,20 +193,22 @@ int init_pcif(void){ #define GAISLER_FTAHBRAM 0x50 #endif int init_onboard_sram(void){ - amba_ahb_device ahb; - amba_apb_device apb; + struct ambapp_ahb_info ahb; + struct ambapp_apb_info apb; unsigned int conf, size; /* Find SRAM controller * 1. AHB slave interface * 2. APB slave interface */ - if ( amba_find_apbslv(&cc1.amba_bus,VENDOR_GAISLER,GAISLER_FTAHBRAM,&apb) != 1 ){ + if ( ambapp_find_apbslv(&cc1.amba_bus, VENDOR_GAISLER, GAISLER_FTAHBRAM, + &apb) != 1 ){ printk("On Board FT SRAM not found (APB)\n"); return -1; } - if ( amba_find_ahbslv(&cc1.amba_bus,VENDOR_GAISLER,GAISLER_FTAHBRAM,&ahb) != 1 ){ + if ( ambapp_find_ahbslv(&cc1.amba_bus, VENDOR_GAISLER, GAISLER_FTAHBRAM, + &ahb) != 1 ){ printk("On Board FT SRAM not found (AHB)\n"); return -1; } diff --git a/c/src/lib/libbsp/sparc/leon2/preinstall.am b/c/src/lib/libbsp/sparc/leon2/preinstall.am index 00ed05ea78..2978d58b0c 100644 --- a/c/src/lib/libbsp/sparc/leon2/preinstall.am +++ b/c/src/lib/libbsp/sparc/leon2/preinstall.am @@ -53,10 +53,6 @@ $(PROJECT_INCLUDE)/cchip.h: include/cchip.h $(PROJECT_INCLUDE)/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/cchip.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/cchip.h -$(PROJECT_INCLUDE)/ambapp.h: ../../sparc/shared/include/ambapp.h $(PROJECT_INCLUDE)/$(dirstamp) - $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp.h -PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h - $(PROJECT_INCLUDE)/grspw.h: ../../sparc/shared/include/grspw.h $(PROJECT_INCLUDE)/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/grspw.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/grspw.h @@ -157,6 +153,14 @@ $(PROJECT_INCLUDE)/bsp/irq.h: include/bsp/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstam $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h +$(PROJECT_INCLUDE)/ambapp.h: ../../sparc/shared/include/ambapp.h $(PROJECT_INCLUDE)/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h + +$(PROJECT_INCLUDE)/ambapp_ids.h: ../../sparc/shared/include/ambapp_ids.h $(PROJECT_INCLUDE)/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp_ids.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp_ids.h + $(PROJECT_INCLUDE)/i2cmst.h: ../../sparc/shared/include/i2cmst.h $(PROJECT_INCLUDE)/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/i2cmst.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/i2cmst.h diff --git a/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c b/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c index 7b66b07246..0be7e4bf38 100644 --- a/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c +++ b/c/src/lib/libbsp/sparc/leon2/rasta/rasta.c @@ -1,5 +1,9 @@ /* - * $Id$ + * GR-RASTA-IO PCI board driver + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. */ #include <rtems/bspIo.h> @@ -209,16 +213,18 @@ void rasta_interrrupt_register(void *handler, int irqno, void *arg) } -int rasta_get_gpio(amba_confarea_type *abus, int index, struct gpio_reg **regs, int *irq) +int rasta_get_gpio(struct ambapp_bus *abus, int index, struct gpio_reg **regs, + int *irq) { - amba_apb_device dev; + struct ambapp_apb_info dev; int cores; if ( !abus ) return -1; /* Scan PnP info for GPIO port number 'index' */ - cores = amba_find_next_apbslv(abus,VENDOR_GAISLER,GAISLER_PIOPORT,&dev,index); + cores = ambapp_find_apbslv_next(abus, VENDOR_GAISLER, GAISLER_GPIO, &dev, + index); if ( cores < 1 ) return -1; @@ -232,8 +238,8 @@ int rasta_get_gpio(amba_confarea_type *abus, int index, struct gpio_reg **regs, } /* AMBA Plug&Play information */ -static amba_confarea_type abus; -static struct amba_mmap amba_maps[3]; +static struct ambapp_bus abus; +static struct ambapp_mmap amba_maps[3]; int rasta_register(void) { @@ -316,23 +322,24 @@ int rasta_register(void) /* AMBA MAP bar0 (in CPU) ==> 0x80000000(remote amba address) */ amba_maps[0].size = 0x10000000; - amba_maps[0].cpu_adr = bar0; - amba_maps[0].remote_amba_adr = 0x80000000; + amba_maps[0].local_adr = bar0; + amba_maps[0].remote_adr = 0x80000000; /* AMBA MAP bar1 (in CPU) ==> 0x40000000(remote amba address) */ amba_maps[1].size = 0x10000000; - amba_maps[1].cpu_adr = bar1; - amba_maps[1].remote_amba_adr = 0x40000000; + amba_maps[1].local_adr = bar1; + amba_maps[1].remote_adr = 0x40000000; /* Mark end of table */ amba_maps[2].size=0; - amba_maps[2].cpu_adr = 0; - amba_maps[2].remote_amba_adr = 0; + amba_maps[2].local_adr = 0; + amba_maps[2].remote_adr = 0; memset(&abus,0,sizeof(abus)); /* Start AMBA PnP scan at first AHB bus */ - amba_scan(&abus,bar0+(AHB1_IOAREA_BASE_ADDR&~0xf0000000),&amba_maps[0]); + ambapp_scan(&abus, bar0 + (AHB1_IOAREA_BASE_ADDR & ~0xf0000000), NULL, + &amba_maps[0]); printk("Registering RASTA GRCAN driver\n\r"); diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am index ebbeb46b18..6bcc53f446 100644 --- a/c/src/lib/libbsp/sparc/leon3/Makefile.am +++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am @@ -44,10 +44,21 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsplibc.c \ libbsp_a_SOURCES += ../../sparc/shared/irq_asm.S # gnatsupp libbsp_a_SOURCES += gnatsupp/gnatsupp.c ../../sparc/shared/gnatcommon.c -# amba +# AMBA bus include_HEADERS += include/amba.h include_HEADERS += ../../sparc/shared/include/ambapp.h -libbsp_a_SOURCES += amba/amba.c ../../sparc/shared/amba/ambapp.c +include_HEADERS += ../../sparc/shared/include/ambapp_ids.h +libbsp_a_SOURCES += amba/amba.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_alloc.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_count.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_depth.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_find_by_idx.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_freq.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_parent.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_old.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_names.c +libbsp_a_SOURCES += ../../sparc/shared/amba/ambapp_show.c # console libbsp_a_SOURCES += console/console.c # debugio diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c b/c/src/lib/libbsp/sparc/leon3/amba/amba.c index 16fb8dee81..60281f346d 100644 --- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c +++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c @@ -1,10 +1,10 @@ /* - * AMBA Plag & Play Bus Driver + * AMBA Plug & Play Bus Driver * * This driver hook performs bus scanning. * - * COPYRIGHT (c) 2004. - * Gaisler Research + * COPYRIGHT (c) 2011. + * Aeroflex Gaisler * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -14,9 +14,14 @@ */ #include <bsp.h> +#include <ambapp.h> -/* Structure containing address to devices found on the Amba Plug&Play bus */ -amba_confarea_type amba_conf; +/* AMBA Plug&Play information description. + * + * After software has scanned AMBA PnP it builds a tree to make + * it easier for drivers to work with the bus architecture. + */ +struct ambapp_bus ambapp_plb; /* GRLIB extended IRQ controller register */ extern void leon3_ext_irq_init(void); @@ -34,20 +39,23 @@ volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; * amba_ahb_masters, amba_ahb_slaves and amba. */ -extern int scan_uarts(void); - void amba_initialize(void) { - int i; int icsel; - amba_apb_device dev; + struct ambapp_dev *adev; - /* Scan the AMBA Plug&Play info at the default LEON3 area */ - amba_scan(&amba_conf,LEON3_IO_AREA,NULL); + /* Scan AMBA Plug&Play read-only information. The routine builds a PnP + * tree into ambapp_plb in RAM, after this we never access the PnP + * information in hardware directly any more. + * Since on Processor Local Bus (PLB) memory mapping is 1:1 + */ + ambapp_scan(&ambapp_plb, LEON3_IO_AREA, NULL, NULL); /* Find LEON3 Interrupt controller */ - i = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_IRQMP,&dev); - if (i <= 0){ + adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), + VENDOR_GAISLER, GAISLER_IRQMP, + ambapp_find_by_idx, NULL); + if (adev == NULL) { /* PANIC IRQ controller not found! * * What else can we do but stop ... @@ -55,7 +63,8 @@ void amba_initialize(void) asm volatile( "mov 1, %g1; ta 0x0" ); } - LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) dev.start; + LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) + DEV_TO_APB(adev)->start; if ((LEON3_IrqCtrl_Regs->ampctrl >> 28) > 0) { /* IRQ Controller has support for multiple IRQ Controllers, each * CPU can be routed to different Controllers, we find out which @@ -74,11 +83,14 @@ void amba_initialize(void) leon3_ext_irq_init(); /* find GP Timer */ - i = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&dev); - if ( i > 0 ) { - LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) dev.start; - } + adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), + VENDOR_GAISLER, GAISLER_GPTIMER, + ambapp_find_by_idx, NULL); + if (adev) { + LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *)DEV_TO_APB(adev)->start; - /* find UARTS */ - scan_uarts(); + /* Register AMBA Bus Frequency */ + ambapp_freq_init(&ambapp_plb, adev, + (LEON3_Timer_Regs->scaler_reload + 1) * 1000000); + } } diff --git a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c index 3cdbb20a66..2a75a35a62 100644 --- a/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c +++ b/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c @@ -16,12 +16,11 @@ * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. - * - * $Id$ */ #include <bsp.h> #include <bspopts.h> +#include <ambapp.h> #if SIMSPARC_FAST_IDLE==1 #define CLOCK_DRIVER_USE_FAST_IDLE @@ -59,14 +58,15 @@ static int clkirq; #define Clock_driver_support_find_timer() \ do { \ - int cnt; \ - amba_apb_device dev; \ + struct ambapp_dev *adev; \ \ - /* Find LEON3 GP Timer */ \ - cnt = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&dev); \ - if ( cnt > 0 ) { \ + /* Find first LEON3 GP Timer */ \ + adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS),\ + VENDOR_GAISLER, GAISLER_GPTIMER, ambapp_find_by_idx, NULL); \ + if (adev) { \ /* Found APB GPTIMER Timer */ \ - LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) dev.start; \ + LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) \ + DEV_TO_APB(adev)->start; \ clkirq = (LEON3_Timer_Regs->status & 0xf8) >> 3; \ \ Adjust_clkirq_for_node(); \ diff --git a/c/src/lib/libbsp/sparc/leon3/console/console.c b/c/src/lib/libbsp/sparc/leon3/console/console.c index 320aa373a5..fa67d370ea 100644 --- a/c/src/lib/libbsp/sparc/leon3/console/console.c +++ b/c/src/lib/libbsp/sparc/leon3/console/console.c @@ -62,6 +62,12 @@ extern int apbuart_inbyte_nonblocking(ambapp_apb_uart *regs); /* body is in debugputs.c */ +struct apbuart_priv { + ambapp_apb_uart *regs; + unsigned int freq_hz; +}; +static struct apbuart_priv apbuarts[BSP_NUMBER_OF_TERMIOS_PORTS]; +static int uarts = 0; /* * Console Termios Support Entry Points @@ -78,7 +84,7 @@ ssize_t console_write_support (int minor, const char *buf, size_t len) port = minor - 1; while (nwrite < len) { - apbuart_outbyte_polled((ambapp_apb_uart*)LEON3_Console_Uart[port], *buf++); + apbuart_outbyte_polled(apbuarts[port].regs, *buf++); nwrite++; } return nwrite; @@ -93,15 +99,44 @@ int console_pollRead(int minor) else port = minor - 1; - return apbuart_inbyte_nonblocking((ambapp_apb_uart*)LEON3_Console_Uart[port]); + return apbuart_inbyte_nonblocking(apbuarts[port].regs); +} + +/* AMBA PP find routine. Extract AMBA PnP information into data structure. */ +int find_matching_apbuart(struct ambapp_dev *dev, int index, void *arg) +{ + struct ambapp_apb_info *apb = (struct ambapp_apb_info *)dev->devinfo; + + /* Extract needed information of one APBUART */ + apbuarts[uarts].regs = (ambapp_apb_uart *)apb->start; + /* Get APBUART core frequency, it is assumed that it is the same + * as Bus frequency where the UART is situated + */ + apbuarts[uarts].freq_hz = ambapp_freq_get(&ambapp_plb, dev); + uarts++; + + if (uarts >= BSP_NUMBER_OF_TERMIOS_PORTS) + return 1; /* Satisfied number of UARTs, stop search */ + else + return 0; /* Continue searching for more UARTs */ +} + +/* Find all UARTs */ +int console_scan_uarts(void) +{ + memset(apbuarts, 0, sizeof(apbuarts)); + + /* Find APBUART cores */ + ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), VENDOR_GAISLER, + GAISLER_APBUART, find_matching_apbuart, NULL); + + return uarts; } /* * Console Device Driver Entry Points * */ -int uarts = 0; -volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS]; rtems_device_driver console_initialize( rtems_device_major_number major, @@ -115,6 +150,9 @@ rtems_device_driver console_initialize( rtems_termios_initialize(); + /* Find UARTs */ + console_scan_uarts(); + /* Update syscon_uart_index to index used as /dev/console * Let user select System console by setting syscon_uart_index. If the * BSP is to provide the default UART (syscon_uart_index==0): @@ -190,9 +228,8 @@ rtems_device_driver console_open( port = minor - 1; /* Initialize UART on opening */ - LEON3_Console_Uart[port]->ctrl |= LEON_REG_UART_CTRL_RE | - LEON_REG_UART_CTRL_TE; - LEON3_Console_Uart[port]->status = 0; + apbuarts[port]->regs->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE; + apbuarts[port]->regs->status = 0; return RTEMS_SUCCESSFUL; } diff --git a/c/src/lib/libbsp/sparc/leon3/console/debugputs.c b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c index 43c6d7d816..c6e0648fee 100644 --- a/c/src/lib/libbsp/sparc/leon3/console/debugputs.c +++ b/c/src/lib/libbsp/sparc/leon3/console/debugputs.c @@ -23,11 +23,6 @@ #include <assert.h> #include <stdio.h> -/* - * Number of uarts on AMBA bus - */ -extern int uarts; - static int isinit = 0; /* Let user override which on-chip APBUART will be debug UART @@ -40,24 +35,16 @@ static int isinit = 0; int debug_uart_index __attribute__((weak)) = 0; ambapp_apb_uart *dbg_uart = NULL; -/* - * Scan for UARTS in configuration +/* Initialize the BSP system debug console layer. It will scan AMBA Plu&Play + * for a debug APBUART and enable RX/TX for that UART. */ -int scan_uarts(void) +int bsp_debug_uart_init(void) { int i; - amba_apb_device apbuarts[LEON3_APBUARTS]; + struct ambapp_dev *adev; + struct ambapp_apb_info *apb; if (isinit == 0) { - i = 0; - uarts = 0; - - uarts = amba_find_apbslvs( - &amba_conf, VENDOR_GAISLER, GAISLER_APBUART, apbuarts, LEON3_APBUARTS); - for(i=0; i<uarts; i++) { - LEON3_Console_Uart[i] = (volatile LEON3_UART_Regs_Map *)apbuarts[i].start; - } - /* Update debug_uart_index to index used as debug console. * Let user select Debug console by setting debug_uart_index. If the * BSP is to provide the default UART (debug_uart_index==0): @@ -74,16 +61,27 @@ int scan_uarts(void) debug_uart_index = debug_uart_index - 1; /* User selected dbg-console */ } - /* initialize debug uart if present for printk */ - if (debug_uart_index < uarts) { - dbg_uart = (ambapp_apb_uart *)LEON3_Console_Uart[debug_uart_index]; + /* Find APBUART core for System Debug Console */ + i = debug_uart_index; + adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), + VENDOR_GAISLER, GAISLER_APBUART, + ambapp_find_by_idx, (void *)&i); + if (adev) { + /* Found a matching debug console, initialize debug uart if present + * for printk + */ + apb = (struct ambapp_apb_info *)adev->devinfo; + dbg_uart = (ambapp_apb_uart *)apb->start; dbg_uart->ctrl |= LEON_REG_UART_CTRL_RE | LEON_REG_UART_CTRL_TE; dbg_uart->status = 0; } isinit = 1; } - return uarts; + if (dbg_uart == NULL) + return 0; + else + return 1; } /* diff --git a/c/src/lib/libbsp/sparc/leon3/include/amba.h b/c/src/lib/libbsp/sparc/leon3/include/amba.h index 9167ff111f..32b4a4244b 100644 --- a/c/src/lib/libbsp/sparc/leon3/include/amba.h +++ b/c/src/lib/libbsp/sparc/leon3/include/amba.h @@ -25,7 +25,6 @@ #define LEON3_AHB_MASTERS 64 #define LEON3_AHB_SLAVES 64 #define LEON3_APB_SLAVES 16 -#define LEON3_APBUARTS 8 #include <ambapp.h> @@ -34,7 +33,7 @@ extern "C" { #endif /* The AMBA Plug&Play info of the bus that the LEON3 sits on */ -extern amba_confarea_type amba_conf; +extern struct ambapp_bus ambapp_plb; #ifdef __cplusplus } diff --git a/c/src/lib/libbsp/sparc/leon3/include/bsp.h b/c/src/lib/libbsp/sparc/leon3/include/bsp.h index e5ae2c1912..d883064660 100644 --- a/c/src/lib/libbsp/sparc/leon3/include/bsp.h +++ b/c/src/lib/libbsp/sparc/leon3/include/bsp.h @@ -41,6 +41,9 @@ extern "C" { void *bsp_idle_thread( uintptr_t ignored ); #define BSP_IDLE_TASK_BODY bsp_idle_thread +/* Maximum supported APBUARTs by BSP */ +#define BSP_NUMBER_OF_TERMIOS_PORTS 8 + /* * Network driver configuration */ diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h index 819800cf59..da752b284d 100644 --- a/c/src/lib/libbsp/sparc/leon3/include/leon.h +++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h @@ -47,12 +47,6 @@ extern "C" { (_trap) <= 0x1F ) typedef struct { - volatile unsigned int data; - volatile unsigned int status; - volatile unsigned int ctrl; -} LEON3_UART_Regs_Map; - -typedef struct { volatile unsigned int value; volatile unsigned int reload; volatile unsigned int conf; @@ -147,7 +141,6 @@ typedef struct { extern volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs; /* LEON3 Interrupt Controller */ extern volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs; /* LEON3 GP Timer */ -extern volatile LEON3_UART_Regs_Map *LEON3_Console_Uart[LEON3_APBUARTS]; /* LEON3 CPU Index of boot CPU */ extern int LEON3_Cpu_Index; diff --git a/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c b/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c index 5641575795..4c4c0b16ba 100644 --- a/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c +++ b/c/src/lib/libbsp/sparc/leon3/leon_greth/leon_greth.c @@ -31,17 +31,19 @@ int rtems_leon_greth_driver_attach( int attach ) { - int device_found = 0; unsigned int base_addr = 0; /* avoid warnings */ unsigned int eth_irq = 0; /* avoid warnings */ - amba_apb_device apbgreth; + struct ambapp_dev *adev; + struct ambapp_apb_info *apb; /* 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; + adev = (void *)ambapp_for_each(&ambapp_plb, (OPTIONS_ALL|OPTIONS_APB_SLVS), + VENDOR_GAISLER, GAISLER_ETHMAC, + ambapp_find_by_idx, NULL); + if (adev) { + apb = DEV_TO_APB(adev); + base_addr = apb->start; + eth_irq = apb->irq; /* clear control register and reset NIC */ *(volatile int *) base_addr = 0; diff --git a/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c index 5799f83dd6..a6bb848dbb 100644 --- a/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c +++ b/c/src/lib/libbsp/sparc/leon3/leon_open_eth/leon_open_eth.c @@ -31,31 +31,27 @@ int rtems_leon_open_eth_driver_attach( 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 */ - + struct ambapp_dev *adev; + struct ambapp_ahb_info *ahb; /* 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); - device_found = 1; - break; - } + 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 (device_found) + 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; @@ -65,7 +61,8 @@ int rtems_leon_open_eth_driver_attach( 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 (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); diff --git a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c index 841c4b6651..9e582fb599 100644 --- a/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c +++ b/c/src/lib/libbsp/sparc/leon3/leon_smc91111/leon_smc91111.c @@ -1,11 +1,14 @@ -/* - * $Id$ +/* LEON3 BSP SMC91111 registration and low-level initialization + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. */ #include <bsp.h> #include <libchip/smc91111exp.h> #include <rtems/bspIo.h> - +#include <ambapp.h> #define SMC91111_BASE_ADDR (void*)0x20000300 #define SMC91111_BASE_IRQ 4 @@ -32,21 +35,29 @@ rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config, { unsigned long addr_mctrl = 0; LEON3_IOPORT_Regs_Map *io; + struct ambapp_apb_info apbpio; + struct ambapp_apb_info apbmctrl; - amba_apb_device apbpio; - amba_ahb_device apbmctrl; - - if ( amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_PIOPORT,&apbpio) != 1 ){ + if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_GPIO, &apbpio) + != 1) { printk("SMC9111_leon3: didn't find PIO\n"); return 0; } - /* Find LEON2 memory controller */ - if ( amba_find_ahbslv(&amba_conf,VENDOR_ESA,ESA_MCTRL,&apbmctrl) != 1 ){ - /* LEON2 memory controller not found, search for fault tolerant memory controller */ - if ( amba_find_ahbslv(&amba_conf,VENDOR_GAISLER,GAISLER_FTMCTRL,&apbmctrl) != 1 ) { - printk("SMC9111_leon3: didn't find any memory controller\n"); - return 0; + /* In order to access the SMC controller the memory controller must have + * I/O bus enabled. Find first memory controller. + */ + if (ambapp_find_apbslv(&ambapp_plb, VENDOR_ESA, ESA_MCTRL, &apbmctrl) != 1) { + if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTMCTRL, + &apbmctrl) != 1) { + if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL, + &apbmctrl) != 1) { + if (ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, GAISLER_FTSRCTRL8, + &apbmctrl) != 1) { + printk("SMC9111_leon3: didn't find any memory controller\n"); + return 0; + } + } } } @@ -68,6 +79,5 @@ rtems_smc91111_driver_attach_leon3 (struct rtems_bsdnet_ifconfig *config, /* Setup memory controller I/O waitstates */ *((volatile unsigned int *) addr_mctrl) |= 0x10f80000; /* enable I/O area access */ - return _rtems_smc91111_driver_attach (config, - &leon_scmv91111_configuration); + return _rtems_smc91111_driver_attach(config, &leon_scmv91111_configuration); }; diff --git a/c/src/lib/libbsp/sparc/leon3/preinstall.am b/c/src/lib/libbsp/sparc/leon3/preinstall.am index 8c27b81933..540e37bdee 100644 --- a/c/src/lib/libbsp/sparc/leon3/preinstall.am +++ b/c/src/lib/libbsp/sparc/leon3/preinstall.am @@ -85,6 +85,10 @@ $(PROJECT_INCLUDE)/ambapp.h: ../../sparc/shared/include/ambapp.h $(PROJECT_INCLU $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp.h +$(PROJECT_INCLUDE)/ambapp_ids.h: ../../sparc/shared/include/ambapp_ids.h $(PROJECT_INCLUDE)/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/ambapp_ids.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/ambapp_ids.h + $(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp) $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c index 9cad164d1f..50fa5e52b8 100644 --- a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c +++ b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c @@ -31,6 +31,7 @@ int CPU_SPARC_HAS_SNOOPING; int LEON3_Cpu_Index = 0; extern void amba_initialize(void); +extern void bsp_debug_uart_init(void); /* * set_snooping @@ -75,6 +76,12 @@ void bsp_start( void ) */ LEON3_Cpu_Index = (get_asr17() >> 28) & 3; - /* Find UARTs */ + /* Scan AMBA Plug&Play and parse it into a RAM description (ambapp_plb), + * find GPTIMER for bus frequency, find IRQ Controller and initialize + * interrupt support + */ amba_initialize(); + + /* find debug UART for printk() */ + bsp_debug_uart_init(); } diff --git a/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c b/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c index e447df26d5..deec9084bc 100644 --- a/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c +++ b/c/src/lib/libbsp/sparc/shared/1553/b1553brm.c @@ -279,7 +279,7 @@ typedef struct { static int brm_cores; static unsigned int allbrm_memarea; static brm_priv *brms; -static amba_confarea_type *amba_bus; +static struct ambapp_bus *amba_bus; static unsigned int allbrm_cfg_clksel; static unsigned int allbrm_cfg_clkdiv; static unsigned int allbrm_cfg_freq; @@ -325,7 +325,7 @@ int brm_register_leon3_ramon_fpga(void){ * The BRM is always clocked with 24MHz. * 3 in BRM enhanced register will select 24MHz */ - return b1553brm_register(&amba_conf,0,0,3); + return b1553brm_register(&ambapp_plb, 0, 0, 3); } int brm_register_leon3_ramon_asic(void){ @@ -335,12 +335,12 @@ int brm_register_leon3_ramon_asic(void){ * * 3 in BRM enhanced register will select 24MHz */ - return b1553brm_register(&amba_conf,2,0,3); + return b1553brm_register(&ambapp_plb, 2, 0, 3); } #endif #endif -int B1553BRM_PREFIX(_register)(amba_confarea_type *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq) +int B1553BRM_PREFIX(_register)(struct ambapp_bus *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq) { rtems_status_code r; rtems_device_major_number m; @@ -568,7 +568,7 @@ static rtems_device_driver brm_initialize(rtems_device_major_number major, rtems int dev_cnt; char fs_name[20]; brm_priv *brm; - amba_ahb_device ambadev; + struct ambapp_ahb_info ambadev; char *mem; FUNCDBG("brm_initialize\n"); @@ -577,7 +577,7 @@ static rtems_device_driver brm_initialize(rtems_device_major_number major, rtems strcpy(fs_name,B1553BRM_DEVNAME); /* Find all BRM devices */ - dev_cnt = amba_get_number_ahbslv_devices(amba_bus,VENDOR_GAISLER,GAISLER_BRM); + dev_cnt = ambapp_get_number_ahbslv_devices(amba_bus, VENDOR_GAISLER, GAISLER_B1553BRM); if ( dev_cnt < 1 ){ /* Failed to find any CAN cores! */ printk("BRM: Failed to find any BRM cores\n\r"); @@ -619,7 +619,8 @@ static rtems_device_driver brm_initialize(rtems_device_major_number major, rtems brm = &brms[minor]; /* Get AMBA AHB device info from Plug&Play */ - amba_find_next_ahbslv(amba_bus,VENDOR_GAISLER,GAISLER_BRM,&ambadev,minor); + ambapp_find_ahbslv_next(amba_bus, VENDOR_GAISLER, + GAISLER_B1553BRM, &ambadev, minor); /* Copy Basic HW info */ brm->regs = (void *)ambadev.start[0]; diff --git a/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c b/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c index 76c9f2e56a..3be26b1b74 100644 --- a/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c +++ b/c/src/lib/libbsp/sparc/shared/1553/b1553brm_pci.c @@ -82,7 +82,7 @@ static void b1553brmpci_interrupt_handler(int irq, void *arg); */ int b1553brm_pci_register( - amba_confarea_type *bus, + struct ambapp_bus *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq, diff --git a/c/src/lib/libbsp/sparc/shared/1553/b1553brm_rasta.c b/c/src/lib/libbsp/sparc/shared/1553/b1553brm_rasta.c index 10adb0aec5..d1fa4d64e0 100644 --- a/c/src/lib/libbsp/sparc/shared/1553/b1553brm_rasta.c +++ b/c/src/lib/libbsp/sparc/shared/1553/b1553brm_rasta.c @@ -82,7 +82,7 @@ static void b1553brmrasta_interrupt_handler(int irq, void *arg); */ int b1553brm_rasta_register( - amba_confarea_type *bus, + struct ambapp_bus *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq, diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp.c index 814ee8c28e..504a3e7e75 100644 --- a/c/src/lib/libbsp/sparc/shared/amba/ambapp.c +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp.c @@ -1,499 +1,457 @@ /* - * AMBA Plag & Play Bus Driver + * AMBA Plug & Play routines * - * This driver hook performs bus scanning. - * - * COPYRIGHT (c) 2004. - * Gaisler Research + * COPYRIGHT (c) 2011. + * Aeroflex Gaisler. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at * http://www.rtems.com/license/LICENSE. - * - * $Id$ */ -#include <bsp.h> -#include <rtems/bspIo.h> +#include <string.h> +#include <stdlib.h> +#include <string.h> + #include <ambapp.h> +#include <bsp.h> -#define amba_insert_device(tab, address) \ -{ \ - if (*(address)) \ - { \ - (tab)->addr[(tab)->devnr] = (address); \ - (tab)->devnr ++; \ - } \ -} while(0) - -#define amba_insert_apb_device(tab, address, apbmst) \ -{ \ - if (*(address)) \ - { \ - (tab)->addr[(tab)->devnr] = (address); \ - (tab)->apbmst[(tab)->devnr] = (apbmst); \ - (tab)->devnr ++; \ - } \ -} while(0) - -static unsigned int -addr_from (struct amba_mmap *mmaps, unsigned int address) +#define AMBA_CONF_AREA 0xff000 +#define AMBA_AHB_SLAVE_CONF_AREA (1 << 11) +#define AMBA_APB_SLAVES 16 + +/* Allocate one AMBA device */ +struct ambapp_dev *ambapp_alloc_dev_struct(int dev_type) +{ + int size = sizeof(struct ambapp_dev); + struct ambapp_dev *dev; + + if (dev_type == DEV_APB_SLV) + size += sizeof(struct ambapp_apb_info); + else + size += sizeof(struct ambapp_ahb_info); /* AHB */ + dev = (struct ambapp_dev *)bsp_early_malloc(size); + if (dev == NULL) + return NULL; + memset(dev, 0 , size); + dev->dev_type = dev_type; + return dev; +} + +unsigned int +ambapp_addr_from (struct ambapp_mmap *mmaps, unsigned int address) { /* no translation? */ if (!mmaps) return address; while (mmaps->size) { - if ((address >= mmaps->remote_amba_adr) - && (address <= (mmaps->remote_amba_adr + (mmaps->size - 1)))) { - return (address - mmaps->remote_amba_adr) + mmaps->cpu_adr; + if ((address >= mmaps->remote_adr) && + (address <= (mmaps->remote_adr + (mmaps->size - 1)))) { + return (address - mmaps->remote_adr) + mmaps->local_adr; } mmaps++; } return 1; } - -void -amba_scan (amba_confarea_type * amba_conf, unsigned int ioarea, - struct amba_mmap *mmaps) +void ambapp_ahb_dev_init( + unsigned int ioarea, + struct ambapp_mmap *mmaps, + struct ambapp_pnp_ahb *ahb, + struct ambapp_dev *dev, + int ahbidx + ) { - unsigned int *cfg_area; /* address to configuration area */ - unsigned int mbar, conf, custom; - int i, j; - unsigned int apbmst; - int maxloops = amba_conf->notroot ? 16 : 64; /* scan first bus for 64 devices, rest for 16 devices */ - - amba_conf->ahbmst.devnr = 0; - amba_conf->ahbslv.devnr = 0; - amba_conf->apbslv.devnr = 0; - cfg_area = (unsigned int *) (ioarea | AMBA_CONF_AREA); - amba_conf->ioarea = ioarea; - amba_conf->mmaps = mmaps; - - for (i = 0; i < maxloops; i++) { - amba_insert_device (&amba_conf->ahbmst, cfg_area); - cfg_area += AMBA_AHB_CONF_WORDS; - } - - cfg_area = - (unsigned int *) (ioarea | AMBA_CONF_AREA | AMBA_AHB_SLAVE_CONF_AREA); - for (i = 0; i < maxloops; i++) { - amba_insert_device (&amba_conf->ahbslv, cfg_area); - cfg_area += AMBA_AHB_CONF_WORDS; - } - - for (i = 0; i < amba_conf->ahbslv.devnr; i++){ - conf = amba_get_confword(amba_conf->ahbslv, i, 0); - mbar = amba_ahb_get_membar(amba_conf->ahbslv, i, 0); - if ( (amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_AHB2AHB) ){ - /* Found AHB->AHB bus bridge, scan it if more free amba_confarea_type:s available - * Custom config 1 contain ioarea. - */ - custom = amba_ahb_get_custom(amba_conf->ahbslv,i,1); - - if ( amba_ver(conf) && amba_conf->next ){ - amba_conf->next->notroot = 1; - amba_scan(amba_conf->next,custom,mmaps); - } - }else if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_APBMST)) - { - apbmst = amba_membar_start(mbar); - if ( (apbmst=addr_from(mmaps,apbmst)) == 1 ) - continue; /* no available memory translation available, will not be able to access - * Plug&Play information for this AHB/APB bridge. Skip it. - */ - cfg_area = (unsigned int *)( apbmst | AMBA_CONF_AREA); - for (j=0; (amba_conf->apbslv.devnr<AMBA_APB_SLAVES) && (j<AMBA_APB_SLAVES); j++){ - amba_insert_apb_device(&amba_conf->apbslv, cfg_area, apbmst); - cfg_area += AMBA_APB_CONF_WORDS; + int bar; + struct ambapp_ahb_info *ahb_info; + unsigned int addr, mask, mbar; + + /* Setup device struct */ + dev->vendor = ambapp_pnp_vendor(ahb->id); + dev->device = ambapp_pnp_device(ahb->id); + ahb_info = DEV_TO_AHB(dev); + ahb_info->ver = ambapp_pnp_ver(ahb->id); + ahb_info->irq = ambapp_pnp_irq(ahb->id); + ahb_info->ahbidx = ahbidx; + ahb_info->custom[0] = (unsigned int)ahb->custom[0]; + ahb_info->custom[1] = (unsigned int)ahb->custom[1]; + ahb_info->custom[2] = (unsigned int)ahb->custom[2]; + + /* Memory BARs */ + for (bar=0; bar<4; bar++) { + mbar = ahb->mbar[bar]; + if (mbar == 0) { + addr = 0; + mask = 0; + } else { + addr = ambapp_pnp_start(mbar); + if (ambapp_pnp_mbar_type(mbar) == AMBA_TYPE_AHBIO) { + /* AHB I/O area is releative IO_AREA */ + addr = AMBA_TYPE_AHBIO_ADDR(addr, ioarea); + mask = (((unsigned int)(ambapp_pnp_mbar_mask(~mbar) << 8) | 0xff)) + 1; + } else { + /* AHB memory area, absolute address */ + addr = ambapp_addr_from(mmaps, addr); + mask = (~((unsigned int)(ambapp_pnp_mbar_mask(mbar) << 20))) + 1; } } + ahb_info->start[bar] = addr; + ahb_info->mask[bar] = mask; + ahb_info->type[bar] = ambapp_pnp_mbar_type(mbar); } } -void -amba_print_dev(int devno, unsigned int conf){ - int irq = amba_irq(conf); - if ( irq > 0 ){ - printk("%x.%x.%x: irq %d\n",devno,amba_vendor(conf),amba_device(conf),irq); - }else{ - printk("%x.%x.%x: no irq\n",devno,amba_vendor(conf),amba_device(conf)); - } -} - -void -amba_apb_print_dev(int devno, unsigned int conf, unsigned int address){ - int irq = amba_irq(conf); - if ( irq > 0 ){ - printk("%x.%x.%x: irq %d, apb: 0x%lx\n",devno,amba_vendor(conf),amba_device(conf),irq,address); - }else{ - printk("%x.%x.%x: no irq, apb: 0x%lx\n",devno,amba_vendor(conf),amba_device(conf),address); - } +void ambapp_apb_dev_init( + unsigned int base, + struct ambapp_mmap *mmaps, + struct ambapp_pnp_apb *apb, + struct ambapp_dev *dev, + int ahbidx + ) +{ + struct ambapp_apb_info *apb_info; + + /* Setup device struct */ + dev->vendor = ambapp_pnp_vendor(apb->id); + dev->device = ambapp_pnp_device(apb->id); + apb_info = DEV_TO_APB(dev); + apb_info->ver = ambapp_pnp_ver(apb->id); + apb_info->irq = ambapp_pnp_irq(apb->id); + apb_info->ahbidx = ahbidx; + apb_info->start = ambapp_pnp_apb_start(apb->iobar, base); + apb_info->mask = ambapp_pnp_apb_mask(apb->iobar); } -/* Print AMBA Plug&Play info on terminal */ -void -amba_print_conf (amba_confarea_type * amba_conf) +int ambapp_add_ahbbus( + struct ambapp_bus *abus, + unsigned int ioarea + ) { - int i,base=0; - unsigned int conf, iobar, address; - unsigned int apbmst; - - /* print all ahb masters */ - printk("--- AMBA AHB Masters ---\n"); - for(i=0; i<amba_conf->ahbmst.devnr; i++){ - conf = amba_get_confword(amba_conf->ahbmst, i, 0); - amba_print_dev(i,conf); - } - - /* print all ahb slaves */ - printk("--- AMBA AHB Slaves ---\n"); - for(i=0; i<amba_conf->ahbslv.devnr; i++){ - conf = amba_get_confword(amba_conf->ahbslv, i, 0); - amba_print_dev(i,conf); - } - - /* print all apb slaves */ - apbmst = 0; - for(i=0; i<amba_conf->apbslv.devnr; i++){ - if ( apbmst != amba_conf->apbslv.apbmst[i] ){ - apbmst = amba_conf->apbslv.apbmst[i]; - printk("--- AMBA APB Slaves on 0x%x ---\n",apbmst); - base=i; - } - conf = amba_get_confword(amba_conf->apbslv, i, 0); - iobar = amba_apb_get_membar(amba_conf->apbslv, i); - address = amba_iobar_start(amba_conf->apbslv.apbmst[i], iobar); - amba_apb_print_dev(i-base,conf,address); - } - + int i; + for (i=0; i<AHB_BUS_MAX; i++) { + if (abus->ahbs[i].ioarea == 0) { + abus->ahbs[i].ioarea = ioarea; + return i; + } else if (abus->ahbs[i].ioarea == ioarea) { + /* Bus already added */ + return -1; + } + } + return -1; } -/**** APB Slaves ****/ -/* Return number of APB Slave devices which has given vendor and device */ -int -amba_get_number_apbslv_devices (amba_confarea_type * amba_conf, int vendor, - int device) +/* Internal AMBA Scanning Function */ +static int ambapp_scan2( + struct ambapp_bus *abus, + unsigned int ioarea, + ambapp_memcpy_t memfunc, + struct ambapp_dev *parent, + struct ambapp_dev **root + ) { - unsigned int conf; - int cnt, i; + struct ambapp_pnp_ahb *ahb, ahb_buf; + struct ambapp_pnp_apb *apb, apb_buf; + struct ambapp_dev *dev, *prev, *prevapb, *apbdev; + struct ambapp_ahb_info *ahb_info; + int maxloops = 64; + unsigned int apbbase, bridge_adr; + int i, j, ahbidx; + + *root = NULL; + + if (parent) { + /* scan first bus for 64 devices, rest for 16 devices */ + maxloops = 16; + } - for (cnt = i = 0; i < amba_conf->apbslv.devnr; i++) { - conf = amba_get_confword (amba_conf->apbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) - cnt++; + ahbidx = ambapp_add_ahbbus(abus, ioarea); + if (ahbidx < 0) { + /* Bus already scanned, stop */ + return 0; } - return cnt; -} -/* Get First APB Slave device of this vendor&device id */ -int -amba_find_apbslv (amba_confarea_type * amba_conf, int vendor, int device, - amba_apb_device * dev) -{ - unsigned int conf, iobar; - int i; + prev = parent; - for (i = 0; i < amba_conf->apbslv.devnr; i++) { - conf = amba_get_confword (amba_conf->apbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - iobar = amba_apb_get_membar (amba_conf->apbslv, i); - dev->start = amba_iobar_start (amba_conf->apbslv.apbmst[i], iobar); - dev->irq = amba_irq (conf); - return 1; - } + /* AHB MASTERS */ + ahb = (struct ambapp_pnp_ahb *) (ioarea | AMBA_CONF_AREA); + for (i = 0; i < maxloops; i++, ahb++) { + memfunc(&ahb_buf, ahb, sizeof(struct ambapp_pnp_ahb), abus); + if (ahb_buf.id == 0) + continue; + + /* An AHB device present here */ + dev = ambapp_alloc_dev_struct(DEV_AHB_MST); + if (!dev) + return -1; + + ambapp_ahb_dev_init(ioarea, abus->mmaps, &ahb_buf, dev, ahbidx); + + if (*root == NULL) + *root = dev; + + if (prev != parent) + prev->next = dev; + dev->prev = prev; + prev = dev; } - return 0; -} -/* Get APB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_apbslv() ) */ -int -amba_find_next_apbslv (amba_confarea_type * amba_conf, int vendor, int device, - amba_apb_device * dev, int index) -{ - unsigned int conf, iobar; - int cnt, i; - - for (cnt = i = 0; i < amba_conf->apbslv.devnr; i++) { - conf = amba_get_confword (amba_conf->apbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - if (cnt == index) { - /* found device */ - iobar = amba_apb_get_membar (amba_conf->apbslv, i); - dev->start = amba_iobar_start (amba_conf->apbslv.apbmst[i], iobar); - dev->irq = amba_irq (conf); - return 1; + /* AHB SLAVES */ + ahb = (struct ambapp_pnp_ahb *) + (ioarea | AMBA_CONF_AREA | AMBA_AHB_SLAVE_CONF_AREA); + for (i = 0; i < maxloops; i++, ahb++) { + memfunc(&ahb_buf, ahb, sizeof(struct ambapp_pnp_ahb), abus); + if (ahb_buf.id == 0) + continue; + + /* An AHB device present here */ + dev = ambapp_alloc_dev_struct(DEV_AHB_SLV); + if (!dev) + return -1; + + ambapp_ahb_dev_init(ioarea, abus->mmaps, &ahb_buf, dev, ahbidx); + + if (*root == NULL) + *root = dev; + + if (prev != parent) + prev->next = dev; + dev->prev = prev; + prev = dev; + + ahb_info = DEV_TO_AHB(dev); + + /* Is it a AHB/AHB Bridge ? */ + if (((dev->device == GAISLER_AHB2AHB) && + (dev->vendor == VENDOR_GAISLER) && (ahb_info->ver > 0)) || + ((dev->device == GAISLER_L2CACHE) && + (dev->vendor == VENDOR_GAISLER)) || + ((dev->device == GAISLER_GRIOMMU) && + (dev->vendor == VENDOR_GAISLER))) { + /* AHB/AHB Bridge Found, recurse down the + * Bridge + */ + if (ahb_info->custom[1] != 0) { + bridge_adr = ambapp_addr_from(abus->mmaps, + ahb_info->custom[1]); + /* Scan next bus if not already scanned */ + if (ambapp_scan2(abus, bridge_adr, memfunc, dev, + &dev->children)) + return -1; + } + } else if ((dev->device == GAISLER_APBMST) && + (dev->vendor == VENDOR_GAISLER)) { + /* AHB/APB Bridge Found, add the APB devices to this + * AHB Slave's children + */ + prevapb = dev; + apbbase = ahb_info->start[0]; + + /* APB SLAVES */ + apb = (struct ambapp_pnp_apb *) + (apbbase | AMBA_CONF_AREA); + for (j=0; j<AMBA_APB_SLAVES; j++, apb++) { + memfunc(&apb_buf, apb, sizeof(*apb), abus); + if (apb_buf.id == 0) + continue; + + apbdev = ambapp_alloc_dev_struct(DEV_APB_SLV); + if (!dev) + return -1; + + ambapp_apb_dev_init(apbbase, abus->mmaps, + &apb_buf, apbdev, ahbidx); + + if (prevapb != dev) + prevapb->next = apbdev; + else + dev->children = apbdev; + apbdev->prev = prevapb; + prevapb = apbdev; } - cnt++; } } + + /* Remember first AHB MST/SLV device on bus and Parent Bridge */ + abus->ahbs[ahbidx].dev = *root; + abus->ahbs[ahbidx].bridge = parent; + return 0; } -/* Get first nr APB Slave devices, put them into dev (which is an array of nr length) */ -int -amba_find_apbslvs (amba_confarea_type * amba_conf, int vendor, int device, - amba_apb_device * devs, int maxno) +/* Build AMBA Plug & Play device graph */ +int ambapp_scan( + struct ambapp_bus *abus, + unsigned int ioarea, + ambapp_memcpy_t memfunc, + struct ambapp_mmap *mmaps + ) { - unsigned int conf, iobar; - int cnt, i; - - for (cnt = i = 0; (i < amba_conf->apbslv.devnr) && (cnt < maxno); i++) { - conf = amba_get_confword (amba_conf->apbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - /* found device */ - iobar = amba_apb_get_membar (amba_conf->apbslv, i); - devs[cnt].start = amba_iobar_start (amba_conf->apbslv.apbmst[i], iobar); - devs[cnt].irq = amba_irq (conf); - cnt++; - } - } - return cnt; -} + memset(abus, 0, sizeof(*abus)); + abus->mmaps = mmaps; -/***** AHB SLAVES *****/ + /* Default to memcpy() */ + if (!memfunc) + memfunc = (ambapp_memcpy_t)memcpy; -/* Return number of AHB Slave devices which has given vendor and device */ -int -amba_get_number_ahbslv_devices (amba_confarea_type * amba_conf, int vendor, - int device) -{ - unsigned int conf; - int cnt, i; - - for (cnt = i = 0; i < amba_conf->ahbslv.devnr; i++) { - conf = amba_get_confword (amba_conf->ahbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) - cnt++; - } - return cnt; + return ambapp_scan2(abus, ioarea, memfunc, NULL, &abus->root); } -/* Get First AHB Slave device of this vendor&device id */ -int -amba_find_ahbslv (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * dev) +/* Match search options againt device */ +int ambapp_dev_match_options(struct ambapp_dev *dev, unsigned int options, int vendor, int device) { - unsigned int conf, mbar, addr; - int j, i; - - for (i = 0; i < amba_conf->ahbslv.devnr; i++) { - conf = amba_get_confword (amba_conf->ahbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - for (j = 0; j < 4; j++) { - mbar = amba_ahb_get_membar (amba_conf->ahbslv, i, j); - addr = amba_membar_start (mbar); - if (amba_membar_type (mbar) == AMBA_TYPE_AHBIO) { - addr = AMBA_TYPE_AHBIO_ADDR (addr, amba_conf->ioarea); - } else { /* convert address if needed */ - if ((addr = addr_from (amba_conf->mmaps, addr)) == 1) { - addr = 0; /* no available memory translation available, will not be able to access - * Plug&Play information for this AHB address. Skip it. - */ - } - } - dev->start[j] = addr; - } - dev->irq = amba_irq (conf); - dev->ver = amba_ver (conf); - return 1; - } + if ((((options & (OPTIONS_ALL_DEVS)) == OPTIONS_ALL_DEVS) || /* TYPE */ + ((options & OPTIONS_AHB_MSTS) && (dev->dev_type == DEV_AHB_MST)) || + ((options & OPTIONS_AHB_SLVS) && (dev->dev_type == DEV_AHB_SLV)) || + ((options & OPTIONS_APB_SLVS) && (dev->dev_type == DEV_APB_SLV))) && + ((vendor == -1) || (vendor == dev->vendor)) && /* VENDOR/DEV ID */ + ((device == -1) || (device == dev->device)) && + (((options & OPTIONS_ALL) == OPTIONS_ALL) || /* Allocated State */ + ((options & OPTIONS_FREE) && DEV_IS_FREE(dev)) || + ((options & OPTIONS_ALLOCATED) && DEV_IS_ALLOCATED(dev)))) { + return 1; } return 0; } -/* Get AHB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbslv() ) */ -int -amba_find_next_ahbslv (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * dev, int index) +/* If device is an APB bridge all devices on the APB bridge is processed */ +static int ambapp_for_each_apb( + struct ambapp_dev *dev, + unsigned int options, + int vendor, + int device, + ambapp_func_t func, + void *arg) { - unsigned int conf, mbar, addr; - int i, j, cnt; - - for (cnt = i = 0; i < amba_conf->ahbslv.devnr; i++) { - conf = amba_get_confword (amba_conf->ahbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - if (cnt == index) { - for (j = 0; j < 4; j++) { - mbar = amba_ahb_get_membar (amba_conf->ahbslv, i, j); - addr = amba_membar_start (mbar); - if (amba_membar_type (mbar) == AMBA_TYPE_AHBIO) { - addr = AMBA_TYPE_AHBIO_ADDR (addr, amba_conf->ioarea); - } else { - /* convert address if needed */ - if ((addr = addr_from (amba_conf->mmaps, addr)) == 1) { - addr = 0; /* no available memory translation available, will not be able to access - * Plug&Play information for this AHB address. Skip it. - */ - } - } - dev->start[j] = addr; - } - dev->irq = amba_irq (conf); - dev->ver = amba_ver (conf); - return 1; + int index, ret; + struct ambapp_dev *apbslv; + + ret = 0; + if (dev->children && (dev->children->dev_type == DEV_APB_SLV)) { + /* Found a APB Bridge */ + index = 0; + apbslv = dev->children; + while (apbslv) { + if (ambapp_dev_match_options(apbslv, options, + vendor, device) == 1) { + ret = func(apbslv, index, arg); + if (ret != 0) + break; /* Signalled stopped */ } - cnt++; + index++; + apbslv = apbslv->next; } } - return 0; + + return ret; } -/* Get first nr AHB Slave devices, put them into dev (which is an array of nr length) */ -int -amba_find_ahbslvs (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * devs, int maxno) +/* Traverse the prescanned device information */ +static int ambapp_for_each_dev( + struct ambapp_dev *root, + unsigned int options, + int vendor, + int device, + ambapp_func_t func, + void *arg) { - unsigned int conf, mbar, addr; - int i, j, cnt; - - for (cnt = i = 0; (i < amba_conf->ahbslv.devnr) && (maxno < cnt); i++) { - conf = amba_get_confword (amba_conf->ahbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - for (j = 0; j < 4; j++) { - mbar = amba_ahb_get_membar (amba_conf->ahbslv, i, j); - addr = amba_membar_start (mbar); - if (amba_membar_type (mbar) == AMBA_TYPE_AHBIO) { - addr = AMBA_TYPE_AHBIO_ADDR (addr, amba_conf->ioarea); - } else { - /* convert address if needed */ - if ((addr = addr_from (amba_conf->mmaps, addr)) == 1) { - addr = 0; /* no available memory translation available, will not be able to access - * Plug&Play information for this AHB address. Skip it. - */ - } - } - devs[cnt].start[j] = addr; + struct ambapp_dev *dev; + int ahb_slave = 0; + int index, ret; + + /* Start at device 'root' and process downwards. + * + * Breadth first search, search order + * 1. AHB MSTS + * 2. AHB SLVS + * 3. APB SLVS on primary bus + * 4. AHB/AHB secondary... -> step to 1. + */ + + /* AHB MST / AHB SLV */ + if (options & (OPTIONS_AHB_MSTS|OPTIONS_AHB_SLVS|OPTIONS_DEPTH_FIRST)) { + index = 0; + dev = root; + while (dev) { + if ((dev->dev_type == DEV_AHB_SLV) && !ahb_slave) { + /* First AHB Slave */ + ahb_slave = 1; + index = 0; } - devs[cnt].irq = amba_irq (conf); - devs[cnt].ver = amba_ver (conf); - cnt++; - } - } - return cnt; -} + /* Conditions must be fullfilled for function to be + * called + */ + if (ambapp_dev_match_options(dev, options, vendor, device) == 1) { + /* Correct device and vendor ID */ + ret = func(dev, index, arg); + if (ret != 0) + return ret; /* Signalled stopped */ + } -/***** AHB Masters *****/ + if ((options & OPTIONS_DEPTH_FIRST) && (options & OPTIONS_APB_SLVS)) { + /* Check is APB bridge, and process all APB + * Slaves in that case + */ + ret = ambapp_for_each_apb(dev, options, vendor, device, func, arg); + if (ret != 0) + return ret; /* Signalled stopped */ + } -/* Return number of AHB Slave devices which has given vendor and device */ -int -amba_get_number_ahbmst_devices (amba_confarea_type * amba_conf, int vendor, - int device) -{ - unsigned int conf; - int cnt, i; + if (options & OPTIONS_DEPTH_FIRST) { + if (dev->children && (dev->children->dev_type != DEV_APB_SLV)) { + /* Found AHB Bridge, recurse */ + ret = ambapp_for_each_dev(dev->children, options, vendor, device, + func, arg); + if (ret != 0) + return ret; + } + } - for (cnt = i = 0; i < amba_conf->ahbmst.devnr; i++) { - conf = amba_get_confword (amba_conf->ahbmst, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) - cnt++; + index++; + dev = dev->next; + } } - return cnt; -} -/* Get First AHB Slave device of this vendor&device id */ -int -amba_find_ahbmst (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * dev) -{ - unsigned int conf, mbar, addr; - int j, i; - - for (i = 0; i < amba_conf->ahbmst.devnr; i++) { - conf = amba_get_confword (amba_conf->ahbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - for (j = 0; j < 4; j++) { - mbar = amba_ahb_get_membar (amba_conf->ahbmst, i, j); - addr = amba_membar_start (mbar); - if (amba_membar_type (mbar) == AMBA_TYPE_AHBIO) { - addr = AMBA_TYPE_AHBIO_ADDR (addr, amba_conf->ioarea); - } else { - /* convert address if needed */ - if ((addr = addr_from (amba_conf->mmaps, addr)) == 1) { - addr = 0; /* no available memory translation available, will not be able to access - * Plug&Play information for this AHB address. Skip it. - */ - } - } - dev->start[j] = addr; - } - dev->irq = amba_irq (conf); - dev->ver = amba_ver (conf); - return 1; + /* Find APB Bridges */ + if ((options & OPTIONS_APB_SLVS) && !(options & OPTIONS_DEPTH_FIRST)) { + dev = root; + while (dev) { + /* Check is APB bridge, and process all APB Slaves in + * that case + */ + ret = ambapp_for_each_apb(dev, options, vendor, device, func, arg); + if (ret != 0) + return ret; /* Signalled stopped */ + dev = dev->next; } } - return 0; -} -/* Get AHB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbslv() ) */ -int -amba_find_next_ahbmst (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * dev, int index) -{ - unsigned int conf, mbar, addr; - int i, j, cnt; - - for (cnt = i = 0; i < amba_conf->ahbmst.devnr; i++) { - conf = amba_get_confword (amba_conf->ahbmst, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - if (cnt == index) { - for (j = 0; j < 4; j++) { - mbar = amba_ahb_get_membar (amba_conf->ahbmst, i, j); - addr = amba_membar_start (mbar); - if (amba_membar_type (mbar) == AMBA_TYPE_AHBIO) { - addr = AMBA_TYPE_AHBIO_ADDR (addr, amba_conf->ioarea); - } else { - /* convert address if needed */ - if ((addr = addr_from (amba_conf->mmaps, addr)) == 1) { - addr = 0; /* no available memory translation available, will not be able to access - * Plug&Play information for this AHB address. Skip it. - */ - } - } - dev->start[j] = addr; - } - dev->irq = amba_irq (conf); - dev->ver = amba_ver (conf); - return 1; + /* Find AHB Bridges */ + if (!(options & OPTIONS_DEPTH_FIRST)) { + dev = root; + while (dev) { + if (dev->children && (dev->children->dev_type != DEV_APB_SLV)) { + /* Found AHB Bridge, recurse */ + ret = ambapp_for_each_dev(dev->children, options, vendor, device, + func, arg); + if (ret != 0) + return ret; } - cnt++; + dev = dev->next; } } + return 0; } -/* Get first nr AHB Slave devices, put them into dev (which is an array of nr length) */ -int -amba_find_ahbmsts (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * devs, int maxno) +int ambapp_for_each( + struct ambapp_bus *abus, + unsigned int options, + int vendor, + int device, + ambapp_func_t func, + void *arg) { - unsigned int conf, mbar, addr; - int i, j, cnt; - - for (cnt = i = 0; (i < amba_conf->ahbmst.devnr) && (maxno < cnt); i++) { - conf = amba_get_confword (amba_conf->ahbslv, i, 0); - if ((amba_vendor (conf) == vendor) && (amba_device (conf) == device)) { - for (j = 0; j < 4; j++) { - mbar = amba_ahb_get_membar (amba_conf->ahbmst, i, j); - addr = amba_membar_start (mbar); - if (amba_membar_type (mbar) == AMBA_TYPE_AHBIO) { - addr = AMBA_TYPE_AHBIO_ADDR (addr, amba_conf->ioarea); - } else { - /* convert address if needed */ - if ((addr = addr_from (amba_conf->mmaps, addr)) == 1) { - addr = 0; /* no available memory translation available, will not be able to access - * Plug&Play information for this AHB address. Skip it. - */ - } - } - devs[cnt].start[j] = addr; - } - devs[cnt].irq = amba_irq (conf); - devs[cnt].ver = amba_ver (conf); - cnt++; - } - } - return cnt; + return ambapp_for_each_dev(abus->root, options, vendor, device, func, arg); } diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_alloc.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_alloc.c new file mode 100644 index 0000000000..16962a7af7 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_alloc.c @@ -0,0 +1,25 @@ +/* + * AMBA Plug & Play routines + * + * COPYRIGHT (c) 2011 + * Aeroflex Gaisler + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <ambapp.h> + +int ambapp_alloc_dev(struct ambapp_dev *dev, void *owner) +{ + if (dev->owner) + return -1; + dev->owner = owner; + return 0; +} + +void ambapp_free_dev(struct ambapp_dev *dev) +{ + dev->owner = 0; +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_count.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_count.c new file mode 100644 index 0000000000..8e0708b4e9 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_count.c @@ -0,0 +1,23 @@ +/* + * AMBA Plug & Play routines + * + * COPYRIGHT (c) 2011 + * Aeroflex Gaisler + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <ambapp.h> + +/* Get number of devices matching search options */ +int ambapp_dev_count(struct ambapp_bus *abus, unsigned int options, + int vendor, int device) +{ + int count = 10000; + + ambapp_for_each(abus, options, vendor, device, ambapp_find_by_idx, &count); + + return 10000 - count; +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_depth.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_depth.c new file mode 100644 index 0000000000..02fa76743b --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_depth.c @@ -0,0 +1,25 @@ +/* + * AMBA Plug & Play routines + * + * COPYRIGHT (c) 2011 + * Aeroflex Gaisler + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <ambapp.h> + +/* Get bus depth a device is located at */ +int ambapp_depth(struct ambapp_dev *dev) +{ + int depth = 0; + + do { + dev = ambapp_find_parent(dev); + depth++; + } while (dev); + + return depth - 1; +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_find_by_idx.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_find_by_idx.c new file mode 100644 index 0000000000..7c6db627b1 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_find_by_idx.c @@ -0,0 +1,39 @@ +/* + * AMBA Plug & Play routines + * + * COPYRIGHT (c) 2011 + * Aeroflex Gaisler + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <ambapp.h> + +/* AMBAPP helper routine to find a device by index. The function is given to + * ambapp_for_each, the argument may be NULL (find first device) or a pointer + * to a index which is downcounted until 0 is reached. If the int-pointer + * points to a value of: + * 0 - first device is returned + * 1 - second device is returned + * ... + * + * The matching device is returned, which will stop the ambapp_for_each search. + * If zero is returned from ambapp_for_each no device matching the index was + * found + */ +int ambapp_find_by_idx(struct ambapp_dev *dev, int index, void *pcount) +{ + int *pi = pcount; + + if (pi) { + if (*pi-- == 0) + return (int)dev; + else + return 0; + } else { + /* Satisfied with first matching device, stop search */ + return (int)dev; + } +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_freq.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_freq.c new file mode 100644 index 0000000000..03c0f68303 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_freq.c @@ -0,0 +1,109 @@ +/* + * AMBA Plug & Play routines + * + * COPYRIGHT (c) 2011 + * Aeroflex Gaisler + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <ambapp.h> + +/* Calculate AHB Bus frequency of + * - Bus[0] (inverse=1), relative to the frequency of Bus[ahbidx] + * NOTE: set freq_hz to frequency of Bus[ahbidx]. + * or + * - Bus[ahbidx] (inverse=0), relative to the frequency of Bus[0] + * NOTE: set freq_hz to frequency of Bus[0]. + * + * If a unsupported bridge is found the invalid frequncy of 0Hz is + * returned. + */ +unsigned int ambapp_freq_calc( + struct ambapp_bus *abus, + int ahbidx, + unsigned int freq_hz, + int inverse) +{ + struct ambapp_ahb_info *ahb; + struct ambapp_dev *bridge; + unsigned char ffact; + int dir; + + /* Found Bus0? */ + bridge = abus->ahbs[ahbidx].bridge; + if (!bridge) + return freq_hz; + + /* Find this bus frequency relative to freq_hz */ + if ((bridge->vendor == VENDOR_GAISLER) && + ((bridge->device == GAISLER_AHB2AHB) || + (bridge->device == GAISLER_L2CACHE))) { + ahb = DEV_TO_AHB(bridge); + ffact = (ahb->custom[0] & AMBAPP_FLAG_FFACT) >> 4; + if (ffact != 0) { + dir = ahb->custom[0] & AMBAPP_FLAG_FFACT_DIR; + + /* Calculate frequency by dividing or + * multiplying system frequency + */ + if ((dir && !inverse) || (!dir && inverse)) + freq_hz = freq_hz * ffact; + else + freq_hz = freq_hz / ffact; + } + return ambapp_freq_calc(abus, ahb->ahbidx, freq_hz, inverse); + } else { + /* Unknown bridge, impossible to calc frequency */ + return 0; + } +} + +/* Find the frequency of all AHB Buses from knowing the frequency of one + * particular APB/AHB Device. + */ +void ambapp_freq_init( + struct ambapp_bus *abus, + struct ambapp_dev *dev, + unsigned int freq_hz) +{ + struct ambapp_common_info *info; + int i; + + for (i=0; i<AHB_BUS_MAX; i++) + abus->ahbs[i].freq_hz = 0; + + /* Register Frequency at the AHB bus that the device the user gave us + * is located at. + */ + if (dev) { + info = DEV_TO_COMMON(dev); + abus->ahbs[info->ahbidx].freq_hz = freq_hz; + + /* Find Frequency of Bus 0 */ + abus->ahbs[0].freq_hz = ambapp_freq_calc(abus, info->ahbidx, freq_hz, 1); + } else { + abus->ahbs[0].freq_hz = freq_hz; + } + + /* Find Frequency of all except for Bus0 and the bus which frequency + * was reported at + */ + for (i=1; i<AHB_BUS_MAX; i++) { + if (abus->ahbs[i].ioarea == 0) + break; + if (abus->ahbs[i].freq_hz != 0) + continue; + abus->ahbs[i].freq_hz = ambapp_freq_calc(abus, i, abus->ahbs[0].freq_hz, 0); + } +} + +/* Assign a AMBA Bus a frequency but reporting the frequency of a + * particular AHB/APB device */ +unsigned int ambapp_freq_get(struct ambapp_bus *abus, struct ambapp_dev *dev) +{ + struct ambapp_common_info *info = DEV_TO_COMMON(dev); + return abus->ahbs[info->ahbidx].freq_hz; +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_names.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_names.c new file mode 100644 index 0000000000..4a47366379 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_names.c @@ -0,0 +1,392 @@ +/* + * AMBA Plug & Play Device and Vendor name database: Created from GRLIB 3386. + * + * COPYRIGHT (c) 2009. + * Aeroflex Gaisler. + * + * The device and vendor definitions are extracted with a script from + * GRLIB. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <ambapp_ids.h> +#include <string.h> + +#ifndef NULL +#define NULL 0 +#endif + +typedef struct { + int device_id; + char *name; +} ambapp_device_name; + +typedef struct { + unsigned int vendor_id; + char *name; + ambapp_device_name *devices; +} ambapp_vendor_devnames; + +/**************** AUTO GENERATED FROM devices.vhd ****************/ +static ambapp_device_name GAISLER_devices[] = +{ + {GAISLER_LEON2DSU, "LEON2DSU"}, + {GAISLER_LEON3, "LEON3"}, + {GAISLER_LEON3DSU, "LEON3DSU"}, + {GAISLER_ETHAHB, "ETHAHB"}, + {GAISLER_APBMST, "APBMST"}, + {GAISLER_AHBUART, "AHBUART"}, + {GAISLER_SRCTRL, "SRCTRL"}, + {GAISLER_SDCTRL, "SDCTRL"}, + {GAISLER_SSRCTRL, "SSRCTRL"}, + {GAISLER_APBUART, "APBUART"}, + {GAISLER_IRQMP, "IRQMP"}, + {GAISLER_AHBRAM, "AHBRAM"}, + {GAISLER_AHBDPRAM, "AHBDPRAM"}, + {GAISLER_GPTIMER, "GPTIMER"}, + {GAISLER_PCITRG, "PCITRG"}, + {GAISLER_PCISBRG, "PCISBRG"}, + {GAISLER_PCIFBRG, "PCIFBRG"}, + {GAISLER_PCITRACE, "PCITRACE"}, + {GAISLER_DMACTRL, "DMACTRL"}, + {GAISLER_AHBTRACE, "AHBTRACE"}, + {GAISLER_DSUCTRL, "DSUCTRL"}, + {GAISLER_CANAHB, "CANAHB"}, + {GAISLER_GPIO, "GPIO"}, + {GAISLER_AHBROM, "AHBROM"}, + {GAISLER_AHBJTAG, "AHBJTAG"}, + {GAISLER_ETHMAC, "ETHMAC"}, + {GAISLER_SWNODE, "SWNODE"}, + {GAISLER_SPW, "SPW"}, + {GAISLER_AHB2AHB, "AHB2AHB"}, + {GAISLER_USBDC, "USBDC"}, + {GAISLER_USB_DCL, "USB_DCL"}, + {GAISLER_DDRMP, "DDRMP"}, + {GAISLER_ATACTRL, "ATACTRL"}, + {GAISLER_DDRSP, "DDRSP"}, + {GAISLER_EHCI, "EHCI"}, + {GAISLER_UHCI, "UHCI"}, + {GAISLER_I2CMST, "I2CMST"}, + {GAISLER_SPW2, "SPW2"}, + {GAISLER_AHBDMA, "AHBDMA"}, + {GAISLER_NUHOSP3, "NUHOSP3"}, + {GAISLER_CLKGATE, "CLKGATE"}, + {GAISLER_SPICTRL, "SPICTRL"}, + {GAISLER_DDR2SP, "DDR2SP"}, + {GAISLER_SLINK, "SLINK"}, + {GAISLER_GRTM, "GRTM"}, + {GAISLER_GRTC, "GRTC"}, + {GAISLER_GRPW, "GRPW"}, + {GAISLER_GRCTM, "GRCTM"}, + {GAISLER_GRHCAN, "GRHCAN"}, + {GAISLER_GRFIFO, "GRFIFO"}, + {GAISLER_GRADCDAC, "GRADCDAC"}, + {GAISLER_GRPULSE, "GRPULSE"}, + {GAISLER_GRTIMER, "GRTIMER"}, + {GAISLER_AHB2PP, "AHB2PP"}, + {GAISLER_GRVERSION, "GRVERSION"}, + {GAISLER_APB2PW, "APB2PW"}, + {GAISLER_PW2APB, "PW2APB"}, + {GAISLER_GRCAN, "GRCAN"}, + {GAISLER_I2CSLV, "I2CSLV"}, + {GAISLER_U16550, "U16550"}, + {GAISLER_AHBMST_EM, "AHBMST_EM"}, + {GAISLER_AHBSLV_EM, "AHBSLV_EM"}, + {GAISLER_GRTESTMOD, "GRTESTMOD"}, + {GAISLER_ASCS, "ASCS"}, + {GAISLER_IPMVBCTRL, "IPMVBCTRL"}, + {GAISLER_SPIMCTRL, "SPIMCTRL"}, + {GAISLER_LEON4, "LEON4"}, + {GAISLER_LEON4DSU, "LEON4DSU"}, + {GAISLER_GRPWM, "GRPWM"}, + {GAISLER_FTAHBRAM, "FTAHBRAM"}, + {GAISLER_FTSRCTRL, "FTSRCTRL"}, + {GAISLER_AHBSTAT, "AHBSTAT"}, + {GAISLER_LEON3FT, "LEON3FT"}, + {GAISLER_FTMCTRL, "FTMCTRL"}, + {GAISLER_FTSDCTRL, "FTSDCTRL"}, + {GAISLER_FTSRCTRL8, "FTSRCTRL8"}, + {GAISLER_MEMSCRUB, "MEMSCRUB"}, + {GAISLER_APBPS2, "APBPS2"}, + {GAISLER_VGACTRL, "VGACTRL"}, + {GAISLER_LOGAN, "LOGAN"}, + {GAISLER_SVGACTRL, "SVGACTRL"}, + {GAISLER_T1AHB, "T1AHB"}, + {GAISLER_MP7WRAP, "MP7WRAP"}, + {GAISLER_GRSYSMON, "GRSYSMON"}, + {GAISLER_GRACECTRL, "GRACECTRL"}, + {GAISLER_B1553BC, "B1553BC"}, + {GAISLER_B1553RT, "B1553RT"}, + {GAISLER_B1553BRM, "B1553BRM"}, + {GAISLER_SATCAN, "SATCAN"}, + {GAISLER_CANMUX, "CANMUX"}, + {GAISLER_GRTMRX, "GRTMRX"}, + {GAISLER_GRTCTX, "GRTCTX"}, + {GAISLER_GRTMDESC, "GRTMDESC"}, + {GAISLER_GRTMVC, "GRTMVC"}, + {GAISLER_GEFFE, "GEFFE"}, + {GAISLER_AES, "AES"}, + {GAISLER_GRAESDMA, "GRAESDMA"}, + {GAISLER_ECC, "ECC"}, + {GAISLER_PCIF, "PCIF"}, + {GAISLER_CLKMOD, "CLKMOD"}, + {GAISLER_HAPSTRAK, "HAPSTRAK"}, + {GAISLER_TEST_1X2, "TEST_1X2"}, + {GAISLER_WILD2AHB, "WILD2AHB"}, + {GAISLER_BIO1, "BIO1"}, + {GAISLER_GR1553B, "GR1553B"}, + {GAISLER_L2CACHE, "L2CACHE"}, + {GAISLER_L4STAT, "L4STAT"}, + {GAISLER_GRPCI2, "GRPCI2"}, + {GAISLER_GRPCI2_DMA, "GRPCI2_DMA"}, + {GAISLER_GRIOMMU, "GRIOMMU"}, + {GAISLER_SPW2_DMA, "SPW2_DMA"}, + {GAISLER_SPW_ROUTER, "SPW_ROUTER"}, + {0, NULL} +}; + +static ambapp_device_name PENDER_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name ESA_devices[] = +{ + {ESA_LEON2, "LEON2"}, + {ESA_LEON2APB, "LEON2APB"}, + {ESA_IRQ, "IRQ"}, + {ESA_TIMER, "TIMER"}, + {ESA_UART, "UART"}, + {ESA_CFG, "CFG"}, + {ESA_IO, "IO"}, + {ESA_MCTRL, "MCTRL"}, + {ESA_PCIARB, "PCIARB"}, + {ESA_HURRICANE, "HURRICANE"}, + {ESA_SPW_RMAP, "SPW_RMAP"}, + {ESA_AHBUART, "AHBUART"}, + {ESA_SPWA, "SPWA"}, + {ESA_BOSCHCAN, "BOSCHCAN"}, + {ESA_IRQ2, "IRQ2"}, + {ESA_AHBSTAT, "AHBSTAT"}, + {ESA_WPROT, "WPROT"}, + {ESA_WPROT2, "WPROT2"}, + {ESA_PDEC3AMBA, "PDEC3AMBA"}, + {ESA_PTME3AMBA, "PTME3AMBA"}, + {0, NULL} +}; + +static ambapp_device_name ASTRIUM_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name OPENCHIP_devices[] = +{ + {OPENCHIP_APBGPIO, "APBGPIO"}, + {OPENCHIP_APBI2C, "APBI2C"}, + {OPENCHIP_APBSPI, "APBSPI"}, + {OPENCHIP_APBCHARLCD, "APBCHARLCD"}, + {OPENCHIP_APBPWM, "APBPWM"}, + {OPENCHIP_APBPS2, "APBPS2"}, + {OPENCHIP_APBMMCSD, "APBMMCSD"}, + {OPENCHIP_APBNAND, "APBNAND"}, + {OPENCHIP_APBLPC, "APBLPC"}, + {OPENCHIP_APBCF, "APBCF"}, + {OPENCHIP_APBSYSACE, "APBSYSACE"}, + {OPENCHIP_APB1WIRE, "APB1WIRE"}, + {OPENCHIP_APBJTAG, "APBJTAG"}, + {OPENCHIP_APBSUI, "APBSUI"}, + {0, NULL} +}; + +static ambapp_device_name OPENCORES_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name CONTRIB_devices[] = +{ + {CONTRIB_CORE1, "CORE1"}, + {CONTRIB_CORE2, "CORE2"}, + {0, NULL} +}; + +static ambapp_device_name EONIC_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name RADIONOR_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name GLEICHMANN_devices[] = +{ + {GLEICHMANN_CUSTOM, "CUSTOM"}, + {GLEICHMANN_GEOLCD01, "GEOLCD01"}, + {GLEICHMANN_DAC, "DAC"}, + {GLEICHMANN_HPI, "HPI"}, + {GLEICHMANN_SPI, "SPI"}, + {GLEICHMANN_HIFC, "HIFC"}, + {GLEICHMANN_ADCDAC, "ADCDAC"}, + {GLEICHMANN_SPIOC, "SPIOC"}, + {GLEICHMANN_AC97, "AC97"}, + {0, NULL} +}; + +static ambapp_device_name MENTA_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name SUN_devices[] = +{ + {SUN_T1, "SUN_T1"}, + {SUN_S1, "SUN_S1"}, + {0, NULL} +}; + +static ambapp_device_name MOVIDIA_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name ORBITA_devices[] = +{ + {ORBITA_1553B, "1553B"}, + {ORBITA_429, "429"}, + {ORBITA_SPI, "SPI"}, + {ORBITA_I2C, "I2C"}, + {ORBITA_SMARTCARD, "SMARTCARD"}, + {ORBITA_SDCARD, "SDCARD"}, + {ORBITA_UART16550, "UART16550"}, + {ORBITA_CRYPTO, "CRYPTO"}, + {ORBITA_SYSIF, "SYSIF"}, + {ORBITA_PIO, "PIO"}, + {ORBITA_RTC, "RTC"}, + {ORBITA_COLORLCD, "COLORLCD"}, + {ORBITA_PCI, "PCI"}, + {ORBITA_DSP, "DSP"}, + {ORBITA_USBHOST, "USBHOST"}, + {ORBITA_USBDEV, "USBDEV"}, + {0, NULL} +}; + +static ambapp_device_name SYNOPSYS_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name NASA_devices[] = +{ + {NASA_EP32, "EP32"}, + {0, NULL} +}; + +static ambapp_device_name CAL_devices[] = +{ + {CAL_DDRCTRL, "DDRCTRL"}, + {0, NULL} +}; + +static ambapp_device_name EMBEDDIT_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name CETON_devices[] = +{ + {0, NULL} +}; + +static ambapp_device_name ACTEL_devices[] = +{ + {ACTEL_COREMP7, "COREMP7"}, + {0, NULL} +}; + +static ambapp_vendor_devnames vendors[] = +{ + {VENDOR_GAISLER, "GAISLER", GAISLER_devices}, + {VENDOR_PENDER, "PENDER", PENDER_devices}, + {VENDOR_ESA, "ESA", ESA_devices}, + {VENDOR_ASTRIUM, "ASTRIUM", ASTRIUM_devices}, + {VENDOR_OPENCHIP, "OPENCHIP", OPENCHIP_devices}, + {VENDOR_OPENCORES, "OPENCORES", OPENCORES_devices}, + {VENDOR_CONTRIB, "CONTRIB", CONTRIB_devices}, + {VENDOR_EONIC, "EONIC", EONIC_devices}, + {VENDOR_RADIONOR, "RADIONOR", RADIONOR_devices}, + {VENDOR_GLEICHMANN, "GLEICHMANN", GLEICHMANN_devices}, + {VENDOR_MENTA, "MENTA", MENTA_devices}, + {VENDOR_SUN, "SUN", SUN_devices}, + {VENDOR_MOVIDIA, "MOVIDIA", MOVIDIA_devices}, + {VENDOR_ORBITA, "ORBITA", ORBITA_devices}, + {VENDOR_SYNOPSYS, "SYNOPSYS", SYNOPSYS_devices}, + {VENDOR_NASA, "NASA", NASA_devices}, + {VENDOR_CAL, "CAL", CAL_devices}, + {VENDOR_EMBEDDIT, "EMBEDDIT", EMBEDDIT_devices}, + {VENDOR_CETON, "CETON", CETON_devices}, + {VENDOR_ACTEL, "ACTEL", ACTEL_devices}, + {0, NULL, NULL} +}; + +/*****************************************************************/ + +static char *ambapp_get_devname(ambapp_device_name *devs, int id) +{ + while (devs->device_id > 0) { + if (devs->device_id == id) + return devs->name; + devs++; + } + return NULL; +} + +char *ambapp_device_id2str(int vendor, int id) +{ + ambapp_vendor_devnames *ven = &vendors[0]; + + while (ven->vendor_id > 0) { + if (ven->vendor_id == vendor) + return ambapp_get_devname(ven->devices, id); + ven++; + } + return NULL; +} + +char *ambapp_vendor_id2str(int vendor) +{ + ambapp_vendor_devnames *ven = &vendors[0]; + + while (ven->vendor_id > 0) { + if (ven->vendor_id == vendor) + return ven->name; + ven++; + } + return NULL; +} + +int ambapp_vendev_id2str(int vendor, int id, char *buf) +{ + char *dstr, *vstr; + + *buf = '\0'; + + vstr = ambapp_vendor_id2str(vendor); + if (vstr == NULL) + return 0; + + dstr = ambapp_device_id2str(vendor, id); + if (dstr == NULL) + return 0; + + strcpy(buf, vstr); + strcat(buf, "_"); + strcat(buf, dstr); + + return strlen(buf); +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_old.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_old.c new file mode 100644 index 0000000000..15aebe58a1 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_old.c @@ -0,0 +1,112 @@ +/* + * Old AMBA scanning Interface provided for backwards compability + * + * COPYRIGHT (c) 2011 + * Aeroflex Gaisler + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <ambapp.h> + +struct ambapp_dev_find_match_arg { + int index; + int count; + int type; + void *dev; +}; + +/* AMBA PP find routines */ +int ambapp_dev_find_match(struct ambapp_dev *dev, int index, void *arg) +{ + struct ambapp_dev_find_match_arg *p = arg; + + if (p->index == 0) { + /* Found controller, stop */ + if (p->type == DEV_APB_SLV) { + *(struct ambapp_apb_info *)p->dev = *DEV_TO_APB(dev); + p->dev = ((struct ambapp_apb_info *)p->dev)+1; + } else { + *(struct ambapp_ahb_info *)p->dev = *DEV_TO_AHB(dev); + p->dev = ((struct ambapp_ahb_info *)p->dev)+1; + } + p->count--; + if (p->count < 1) + return 1; + } else { + p->index--; + } + return 0; +} + +int ambapp_find_apbslvs_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int index, int maxno) +{ + struct ambapp_dev_find_match_arg arg; + + arg.index = index; + arg.count = maxno; + arg.type = DEV_APB_SLV; /* APB */ + arg.dev = dev; + + ambapp_for_each(abus, (OPTIONS_ALL|OPTIONS_APB_SLVS), vendor, device, + ambapp_dev_find_match, &arg); + + return maxno - arg.count; +} + +int ambapp_find_apbslv(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev) +{ + return ambapp_find_apbslvs_next(abus, vendor, device, dev, 0, 1); +} + +int ambapp_find_apbslv_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int index) +{ + return ambapp_find_apbslvs_next(abus, vendor, device, dev, index, 1); +} + +int ambapp_find_apbslvs(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int maxno) +{ + return ambapp_find_apbslvs_next(abus, vendor, device, dev, 0, maxno); +} + +int ambapp_get_number_apbslv_devices(struct ambapp_bus *abus, int vendor, int device) +{ + return ambapp_dev_count(abus, (OPTIONS_ALL|OPTIONS_APB_SLVS), vendor, device); +} + +int ambapp_find_ahbslvs_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int index, int maxno) +{ + struct ambapp_dev_find_match_arg arg; + + arg.index = index; + arg.count = maxno; + arg.type = DEV_AHB_SLV; /* AHB SLV */ + arg.dev = dev; + + ambapp_for_each(abus, (OPTIONS_ALL|OPTIONS_AHB_SLVS), vendor, device, + ambapp_dev_find_match, &arg); + + return maxno - arg.count; +} + +int ambapp_find_ahbslv_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int index) +{ + return ambapp_find_ahbslvs_next(abus, vendor, device, dev, index, 1); +} + +int ambapp_find_ahbslv(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev) +{ + return ambapp_find_ahbslvs_next(abus, vendor, device, dev, 0, 1); +} + +int ambapp_find_ahbslvs(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int maxno) +{ + return ambapp_find_ahbslvs_next(abus, vendor, device, dev, 0, maxno); +} + +int ambapp_get_number_ahbslv_devices(struct ambapp_bus *abus, int vendor, int device) +{ + return ambapp_dev_count(abus, (OPTIONS_ALL|OPTIONS_AHB_SLVS), vendor, device); +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_parent.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_parent.c new file mode 100644 index 0000000000..ef6f7e2f0b --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_parent.c @@ -0,0 +1,23 @@ +/* + * AMBA Plug & Play routines + * + * COPYRIGHT (c) 2011 + * Aeroflex Gaisler + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <stdlib.h> +#include <ambapp.h> + +struct ambapp_dev *ambapp_find_parent(struct ambapp_dev *dev) +{ + while (dev->prev) { + if (dev == dev->prev->children) + return dev->prev; + dev = dev->prev; + } + return NULL; +} diff --git a/c/src/lib/libbsp/sparc/shared/amba/ambapp_show.c b/c/src/lib/libbsp/sparc/shared/amba/ambapp_show.c new file mode 100644 index 0000000000..f73ec1d768 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/amba/ambapp_show.c @@ -0,0 +1,71 @@ +/* + * AMBA Plug & Play routines: device information printing. + * + * COPYRIGHT (c) 2009. + * Aeroflex Gaisler. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + */ + +#include <stdio.h> +#include <ambapp.h> + +extern char *ambapp_device_id2str(int vendor, int id); +extern char *ambapp_vendor_id2str(int vendor); + +struct ambapp_dev_print_arg { + int show_depth; +}; + +static char *unknown = "unknown"; + +int ambapp_dev_print(struct ambapp_dev *dev, int index, void *arg) +{ + char *dev_str, *ven_str, *type_str; + struct ambapp_dev_print_arg *p = arg; + char dp[32]; + int i=0; + unsigned int basereg; + + if (p->show_depth) { + for (i=0; i<ambapp_depth(dev)*2; i+=2) { + dp[i] = ' '; + dp[i+1] = ' '; + } + } + dp[i] = '\0'; + + ven_str = ambapp_vendor_id2str(dev->vendor); + if (!ven_str) { + ven_str = unknown; + dev_str = unknown; + } else { + dev_str = ambapp_device_id2str(dev->vendor, dev->device); + if (!dev_str) + dev_str = unknown; + } + if (dev->dev_type == DEV_APB_SLV) { + /* APB */ + basereg = DEV_TO_APB(dev)->start; + type_str = "apb"; + } else { + /* AHB */ + basereg = DEV_TO_AHB(dev)->start[0]; + type_str = "ahb"; + } + printf("%s |-> 0x%x:0x%x:0x%x: %s_%s, %s: 0x%x, 0x%x (OWNER: 0x%x)\n", + dp, index, dev->vendor, dev->device, ven_str, dev_str, type_str, + basereg, (unsigned int)dev, (unsigned int)dev->owner); + + return 0; +} + +void ambapp_print(struct ambapp_bus *abus, int show_depth) +{ + struct ambapp_dev_print_arg arg; + arg.show_depth = show_depth; + ambapp_for_each(abus, (OPTIONS_ALL_DEVS|OPTIONS_ALL|OPTIONS_DEPTH_FIRST), -1, + -1, ambapp_dev_print, &arg); +} diff --git a/c/src/lib/libbsp/sparc/shared/can/grcan.c b/c/src/lib/libbsp/sparc/shared/can/grcan.c index fb48550365..3b0a14afac 100644 --- a/c/src/lib/libbsp/sparc/shared/can/grcan.c +++ b/c/src/lib/libbsp/sparc/shared/can/grcan.c @@ -212,7 +212,7 @@ struct grcan_priv { static int grcan_core_cnt; struct grcan_priv *grcans; -static amba_confarea_type *amba_bus; +static struct ambapp_bus *amba_bus; struct grcan_device_info *grcan_cores; static int grcan_core_cnt; @@ -1050,7 +1050,7 @@ static rtems_device_driver grcan_initialize( { int minor; struct grcan_priv *pDev; - amba_apb_device dev; + struct ambapp_apb_info dev; rtems_status_code status; char fs_name[20]; unsigned int sys_freq_hz; @@ -1062,10 +1062,12 @@ static rtems_device_driver grcan_initialize( /* find GRCAN cores */ if ( !grcan_cores ) { - grcan_core_cnt = amba_get_number_apbslv_devices(amba_bus,VENDOR_GAISLER,deviceid); + grcan_core_cnt = ambapp_get_number_apbslv_devices(amba_bus, VENDOR_GAISLER, + deviceid); if ( grcan_core_cnt < 1 ){ deviceid = GAISLER_GRCAN; - grcan_core_cnt = amba_get_number_apbslv_devices(amba_bus,VENDOR_GAISLER,deviceid); + grcan_core_cnt = ambapp_get_number_apbslv_devices(amba_bus, VENDOR_GAISLER, + deviceid); if ( grcan_core_cnt < 1 ) { DBG("GRCAN: Using AMBA Plug&Play, found %d cores\n",grcan_core_cnt); return RTEMS_UNSATISFIED; @@ -1094,10 +1096,10 @@ static rtems_device_driver grcan_initialize( #if defined(LEON3) /* LEON3: find timer address via AMBA Plug&Play info */ { - amba_apb_device gptimer; + struct ambapp_apb_info gptimer; LEON3_Timer_Regs_Map *tregs; - if (amba_find_apbslv (&amba_conf, VENDOR_GAISLER, GAISLER_GPTIMER, &gptimer) + if (ambapp_find_apbslv (&ambapp_plb, VENDOR_GAISLER, GAISLER_GPTIMER, &gptimer) == 1) { tregs = (LEON3_Timer_Regs_Map *) gptimer.start; sys_freq_hz = (tregs->scaler_reload + 1) * 1000 * 1000; @@ -1132,7 +1134,7 @@ static rtems_device_driver grcan_initialize( /* Find core address & IRQ */ if ( !grcan_cores ) { - amba_find_next_apbslv(amba_bus,VENDOR_GAISLER,deviceid,&dev,minor); + ambapp_find_apbslv_next(amba_bus, VENDOR_GAISLER, deviceid, &dev, minor); pDev->irq = dev.irq; pDev->regs = (struct grcan_regs *)dev.start; }else{ @@ -1799,7 +1801,7 @@ int GRCAN_PREFIX(_register_abs)(struct grcan_device_info *devices, int dev_cnt) } /* Use prescanned AMBA Plug&Play information to find all GRCAN cores */ -int GRCAN_PREFIX(_register)(amba_confarea_type *abus) +int GRCAN_PREFIX(_register)(struct ambapp_bus *abus) { FUNCDBG(); diff --git a/c/src/lib/libbsp/sparc/shared/can/grcan_rasta.c b/c/src/lib/libbsp/sparc/shared/can/grcan_rasta.c index f9b126f552..7fad48e16e 100644 --- a/c/src/lib/libbsp/sparc/shared/can/grcan_rasta.c +++ b/c/src/lib/libbsp/sparc/shared/can/grcan_rasta.c @@ -77,7 +77,7 @@ unsigned int grcan_rasta_rambase; #include "grcan.c" -int grcan_rasta_ram_register(amba_confarea_type *abus, int rambase) +int grcan_rasta_ram_register(struct ambapp_bus *abus, int rambase) { grcan_rasta_rambase = rambase; diff --git a/c/src/lib/libbsp/sparc/shared/can/occan.c b/c/src/lib/libbsp/sparc/shared/can/occan.c index 78c901a1e7..4fb932dc61 100644 --- a/c/src/lib/libbsp/sparc/shared/can/occan.c +++ b/c/src/lib/libbsp/sparc/shared/can/occan.c @@ -282,7 +282,7 @@ static void occan_interrupt_handler(rtems_vector_number v); #endif static int can_cores; static occan_priv *cans; -static amba_confarea_type *amba_bus; +static struct ambapp_bus *amba_bus; static unsigned int sys_freq_hz; @@ -914,7 +914,7 @@ static int pelican_speed_auto(occan_priv *priv){ static rtems_device_driver occan_initialize(rtems_device_major_number major, rtems_device_minor_number unused, void *arg){ int dev_cnt,minor,subcore_cnt,devi,subi,subcores; - amba_ahb_device ambadev; + struct ambapp_ahb_info ambadev; occan_priv *can; char fs_name[20]; rtems_status_code status; @@ -922,7 +922,8 @@ static rtems_device_driver occan_initialize(rtems_device_major_number major, rte strcpy(fs_name,OCCAN_DEVNAME); /* find device on amba bus */ - dev_cnt = amba_get_number_ahbslv_devices(amba_bus,VENDOR_GAISLER,GAISLER_OCCAN); + dev_cnt = ambapp_get_number_ahbslv_devices(amba_bus, VENDOR_GAISLER, + GAISLER_CANAHB); if ( dev_cnt < 1 ){ /* Failed to find any CAN cores! */ printk("OCCAN: Failed to find any CAN cores\n\r"); @@ -934,10 +935,11 @@ static rtems_device_driver occan_initialize(rtems_device_major_number major, rte #if defined(LEON3) /* LEON3: find timer address via AMBA Plug&Play info */ { - amba_apb_device gptimer; + struct ambapp_apb_info gptimer; LEON3_Timer_Regs_Map *tregs; - if ( amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&gptimer) == 1 ){ + if ( ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, + GAISLER_GPTIMER, &gptimer) == 1 ){ tregs = (LEON3_Timer_Regs_Map *)gptimer.start; sys_freq_hz = (tregs->scaler_reload+1)*1000*1000; DBG("OCCAN: detected %dHZ system frequency\n\r",sys_freq_hz); @@ -973,7 +975,8 @@ static rtems_device_driver occan_initialize(rtems_device_major_number major, rte */ for(subcore_cnt=devi=0; devi<dev_cnt; devi++){ - amba_find_next_ahbslv(amba_bus,VENDOR_GAISLER,GAISLER_OCCAN,&ambadev,devi); + ambapp_find_ahbslv_next(amba_bus, VENDOR_GAISLER, + GAISLER_CANAHB, &ambadev, devi); subcore_cnt += (ambadev.ver & 0x7)+1; } @@ -987,7 +990,8 @@ static rtems_device_driver occan_initialize(rtems_device_major_number major, rte for(devi=0; devi<dev_cnt; devi++){ /* Get AHB device info */ - amba_find_next_ahbslv(amba_bus,VENDOR_GAISLER,GAISLER_OCCAN,&ambadev,devi); + ambapp_find_ahbslv_next(amba_bus, VENDOR_GAISLER, + GAISLER_CANAHB, &ambadev, devi); subcores = (ambadev.ver & 0x7)+1; DBG("OCCAN: on dev %d found %d sub cores\n\r",devi,subcores); @@ -1802,7 +1806,7 @@ static void occan_interrupt_handler(rtems_vector_number v){ static rtems_driver_address_table occan_driver = OCCAN_DRIVER_TABLE_ENTRY; -int OCCAN_PREFIX(_register)(amba_confarea_type *bus){ +int OCCAN_PREFIX(_register)(struct ambapp_bus *bus){ rtems_status_code r; rtems_device_major_number m; diff --git a/c/src/lib/libbsp/sparc/shared/can/occan_pci.c b/c/src/lib/libbsp/sparc/shared/can/occan_pci.c index 2dd2e5be21..b27beb11c5 100644 --- a/c/src/lib/libbsp/sparc/shared/can/occan_pci.c +++ b/c/src/lib/libbsp/sparc/shared/can/occan_pci.c @@ -46,7 +46,7 @@ static void inline occanpci_set_channel(occan_priv *priv, int channel){ *chan_sel = 0xffffffff; } -int occan_pci_register(amba_confarea_type *bus) +int occan_pci_register(struct ambapp_bus *bus) { /* Setup configuration */ diff --git a/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c b/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c index fb6a573763..7ba7208622 100644 --- a/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c +++ b/c/src/lib/libbsp/sparc/shared/i2c/i2cmst.c @@ -285,7 +285,7 @@ static gr_i2cmst_desc_t gr_i2cmst_desc = { }; /* Scans for I2CMST core and initalizes i2c library */ -rtems_status_code leon_register_i2c(amba_confarea_type *abus) +rtems_status_code leon_register_i2c(struct ambapp_bus *abus) { #if defined(DEBUG) printk("leon_register_i2c called..."); @@ -293,11 +293,11 @@ rtems_status_code leon_register_i2c(amba_confarea_type *abus) int rc; int device_found = 0; - amba_apb_device apbi2cmst; + struct ambapp_apb_info apbi2cmst; /* Scan AMBA bus for I2CMST core */ - device_found = amba_find_apbslv(abus, VENDOR_GAISLER, GAISLER_I2CMST, - &apbi2cmst); + device_found = ambapp_find_apbslv(abus, VENDOR_GAISLER, GAISLER_I2CMST, + &apbi2cmst); if (device_found == 1) { @@ -317,11 +317,11 @@ rtems_status_code leon_register_i2c(amba_confarea_type *abus) #if defined(LEON3) /* LEON3: find timer address via AMBA Plug&Play info */ { - amba_apb_device gptimer; + struct ambapp_apb_info gptimer; LEON3_Timer_Regs_Map *tregs; - if (amba_find_apbslv(abus,VENDOR_GAISLER, - GAISLER_GPTIMER,&gptimer) == 1 ) { + if (ambapp_find_apbslv(abus, VENDOR_GAISLER, + GAISLER_GPTIMER, &gptimer) == 1 ) { tregs = (LEON3_Timer_Regs_Map *)gptimer.start; gr_i2cmst_desc.prv.sysfreq = (tregs->scaler_reload+1)*1000; } else { diff --git a/c/src/lib/libbsp/sparc/shared/include/ambapp.h b/c/src/lib/libbsp/sparc/shared/include/ambapp.h index 7ca2d13c86..5eb3f2ae0e 100644 --- a/c/src/lib/libbsp/sparc/shared/include/ambapp.h +++ b/c/src/lib/libbsp/sparc/shared/include/ambapp.h @@ -1,10 +1,8 @@ /* - * AMBA Plag & Play Bus Driver Macros for LEON2 + * AMBA Plug & Play routines * - * Macros used for AMBA Plug & Play bus scanning - * - * COPYRIGHT (c) 2007. - * Gaisler Research + * COPYRIGHT (c) 2009. + * Aeroflex Gaisler. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -16,224 +14,345 @@ #ifndef __AMBAPP_H__ #define __AMBAPP_H__ +/* Include VENDOR and DEVICE definitions */ +#include <ambapp_ids.h> + #ifdef __cplusplus extern "C" { #endif -#define AMBA_CONF_AREA 0xff000 -#define AMBA_AHB_SLAVE_CONF_AREA (1 << 11) - -#define AMBA_AHB_CONF_WORDS 8 -#define AMBA_APB_CONF_WORDS 2 -#define AMBA_AHB_MASTERS 16 -#define AMBA_AHB_SLAVES 16 -#define AMBA_APB_SLAVES 16 -#define AMBA_APBUARTS 8 - -/* Vendor codes */ -#define VENDOR_GAISLER 1 -#define VENDOR_PENDER 2 -#define VENDOR_ESA 4 -#define VENDOR_OPENCORES 8 - -/* Gaisler Research device id's */ -#define GAISLER_LEON3 0x03 -#define GAISLER_LEON3DSU 0x04 -#define GAISLER_ETHAHB 0x05 -#define GAISLER_APBMST 0x06 -#define GAISLER_AHBUART 0x07 -#define GAISLER_SRCTRL 0x08 -#define GAISLER_SDCTRL 0x09 -#define GAISLER_APBUART 0x0C -#define GAISLER_IRQMP 0x0D -#define GAISLER_AHBRAM 0x0E -#define GAISLER_GPTIMER 0x11 -#define GAISLER_PCITRG 0x12 -#define GAISLER_PCISBRG 0x13 -#define GAISLER_PCIFBRG 0x14 -#define GAISLER_PCITRACE 0x15 -#define GAISLER_DMACTRL 0x16 -#define GAISLER_OCCAN 0x19 -#define GAISLER_PIOPORT 0x1A -#define GAISLER_ETHMAC 0x1D -#define GAISLER_SPACEWIRE 0x1f -#define GAISLER_AHB2AHB 0x20 -#define GAISLER_I2CMST 0x28 -#define GAISLER_GRSPW2 0x29 -#define GAISLER_GRCAN 0x34 -#define GAISLER_GRHCAN 0x3d -#define GAISLER_GRFIFO 0x35 -#define GAISLER_GRADCDAC 0x36 -#define GAISLER_GRPULSE 0x37 -#define GAISLER_GRTIMER 0x38 -#define GAISLER_FTAHBRAM 0x50 -#define GAISLER_FTMCTRL 0x54 -#define GAISLER_BRM 0x72 - - -/* European Space Agency device id's */ -#define ESA_LEON2 0x2 -#define ESA_MCTRL 0xF -#define ESA_SPW2 0x12 - -/* Opencores device id's */ -#define OPENCORES_PCIBR 0x4 -#define OPENCORES_ETHMAC 0x5 +/* Max supported AHB buses */ +#define AHB_BUS_MAX 6 + +struct ambapp_dev; +struct ambapp_core; +struct ambapp_apb_info; +struct ambapp_ahb_info; + +struct ambapp_dev { + struct ambapp_dev *next; /* Next */ + struct ambapp_dev *prev; /* Previous Device. If (this == + * rev->child) prev is bus bridge */ + struct ambapp_dev *children; /* Points to first device on sub-bus */ + void *owner; /* Owner of this AMBA device */ + unsigned char dev_type; /* AHB MST, AHB SLV or APB SLV*/ + unsigned char vendor; /* Vendor ID */ + unsigned short device; /* Device ID */ + int devinfo[0]; /* Device info (APB/AHB dep. on type) */ +}; -/* - * - * Macros for manipulating Configuration registers - * - */ -#define amba_get_confword(tab, index, word) (*((tab).addr[(index)]+(word))) +#define AMBAPP_FLAG_FFACT_DIR 0x100 /* Frequency factor direction, 0=down, 1=up */ +#define AMBAPP_FLAG_FFACT 0x0f0 /* Frequency factor against top bus */ +#define AMBAPP_FLAG_MBUS 0x00c +#define AMBAPP_FLAG_SBUS 0x003 + +/* Get APB or AHB information from a AMBA device */ +#define DEV_TO_APB(adev) ((struct ambapp_apb_info *)((adev)->devinfo)) +#define DEV_TO_AHB(adev) ((struct ambapp_ahb_info *)((adev)->devinfo)) +#define DEV_TO_COMMON(adev) ((struct ambapp_common_info *)((adev)->devinfo)) +/* Convert address of ambapp_apb_info/ambapp_ahb_info into ambapp_dev */ +#define APB_TO_DEV(apb_info) ((struct ambapp_dev *)(unsigned int(apb_info) - \ + offsetof(struct ambapp_dev, devinfo))) +#define AHB_TO_DEV(ahb_info) ((struct ambapp_dev *)(unsigned int(ahb_info) - \ + offsetof(struct ambapp_dev, devinfo))) + +struct ambapp_common_info { + unsigned char irq; + unsigned char ver; + unsigned char ahbidx; /* AHB Bus Index */ +}; -#define amba_vendor(x) (((x) >> 24) & 0xff) +struct ambapp_apb_info { + /* COMMON */ + unsigned char irq; + unsigned char ver; + unsigned char ahbidx; /* AHB Bus Index */ -#define amba_device(x) (((x) >> 12) & 0xfff) + /* APB SPECIFIC */ + unsigned int start; + unsigned int mask; +}; + +struct ambapp_ahb_info { + /* COMMON */ + unsigned char irq; + unsigned char ver; + unsigned char ahbidx; /* AHB Bus Index */ + + /* AHB SPECIFIC */ + unsigned int start[4]; + unsigned int mask[4]; + char type[4]; /* type[N] Determine type of start[N]-mask[N], + * 2=AHB Memory Space, 3=AHB I/O Space */ + unsigned int custom[3]; +}; + +/* Describes a complete AMBA Core. Each device may consist of 3 interfaces */ +struct ambapp_core { + char irq; /* irq=-1 indicate no IRQ */ + unsigned char vendor; + unsigned short device; + int index; /* Core index */ + struct ambapp_ahb_info *ahb_mst; + struct ambapp_ahb_info *ahb_slv; + struct ambapp_apb_info *apb_slv; +}; + +struct ambapp_ahb_bus { + unsigned int ioarea; /* AHB Bus IOAREA */ + unsigned int freq_hz; /* Frequency of AHB Bus */ + struct ambapp_dev *bridge;/* Bridge Device on Parent AHB Bus */ + struct ambapp_dev *dev; /* First Device on AHB Bus */ +}; -#define amba_ahb_get_membar(tab, index, nr) (*((tab).addr[(index)]+4+(nr))) +struct ambapp_mmap { + unsigned int size; + unsigned int local_adr; + unsigned int remote_adr; +}; -#define amba_ahb_get_custom(tab, index, nr) (*((tab).addr[(index)]+1+(nr))) +/* Complete AMBA PnP information */ +struct ambapp_bus { + struct ambapp_dev *root; /* AHB/APB Device Tree*/ + struct ambapp_mmap *mmaps; /* Memory MAP Array */ + struct ambapp_ahb_bus ahbs[AHB_BUS_MAX]; /* AHB Buses */ +}; -#define amba_apb_get_membar(tab, index) (*((tab).addr[(index)]+1)) +/* + * Return values + * 0 - continue + * 1 - stop scanning + */ +typedef int (*ambapp_func_t)(struct ambapp_dev *dev, int index, void *arg); + +#define DEV_IS_FREE(dev) (dev->owner == NULL) +#define DEV_IS_ALLOCATED(dev) (dev->owner != NULL) + +/* Options to ambapp_for_each */ +#define OPTIONS_AHB_MSTS 0x00000001 +#define OPTIONS_AHB_SLVS 0x00000002 +#define OPTIONS_APB_SLVS 0x00000004 +#define OPTIONS_ALL_DEVS (OPTIONS_AHB_MSTS|OPTIONS_AHB_SLVS|OPTIONS_APB_SLVS) + +#define OPTIONS_FREE 0x00000010 +#define OPTIONS_ALLOCATED 0x00000020 +#define OPTIONS_ALL (OPTIONS_FREE|OPTIONS_ALLOCATED) + +/* Depth first search, Defualt is breath first search. */ +#define OPTIONS_DEPTH_FIRST 0x00000100 + +#define DEV_AHB_NONE 0 +#define DEV_AHB_MST 1 +#define DEV_AHB_SLV 2 +#define DEV_APB_SLV 3 + +/* Structures used to access Plug&Play information directly */ +struct ambapp_pnp_ahb { + const unsigned int id; /* VENDOR, DEVICE, VER, IRQ, */ + const unsigned int custom[3]; + const unsigned int mbar[4]; /* MASK, ADDRESS, TYPE, CACHABLE/PREFETCHABLE */ +}; -#define amba_membar_start(mbar) (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16)) +struct ambapp_pnp_apb { + const unsigned int id; /* VENDOR, DEVICE, VER, IRQ, */ + const unsigned int iobar; /* MASK, ADDRESS, TYPE, CACHABLE/PREFETCHABLE */ +}; -#define amba_iobar_start(base, iobar) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) ) +#define ambapp_pnp_vendor(id) (((id) >> 24) & 0xff) +#define ambapp_pnp_device(id) (((id) >> 12) & 0xfff) +#define ambapp_pnp_ver(id) (((id)>>5) & 0x1f) +#define ambapp_pnp_irq(id) ((id) & 0x1f) -#define amba_irq(conf) ((conf) & 0x1f) +#define ambapp_pnp_start(mbar) (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16)) +#define ambapp_pnp_mbar_mask(mbar) (((mbar)>>4) & 0xfff) +#define ambapp_pnp_mbar_type(mbar) ((mbar) & 0xf) -#define amba_ver(conf) (((conf)>>5) & 0x1f) +#define ambapp_pnp_apb_start(iobar, base) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) ) +#define ambapp_pnp_apb_mask(iobar) ((~(ambapp_pnp_mbar_mask(iobar)<<8) & 0x000fffff) + 1) -#define amba_membar_type(mbar) ((mbar) & 0xf) +#define AMBA_TYPE_AHBIO_ADDR(addr,base_ioarea) ((unsigned int)(base_ioarea) | ((addr) >> 12)) #define AMBA_TYPE_APBIO 0x1 #define AMBA_TYPE_MEM 0x2 #define AMBA_TYPE_AHBIO 0x3 -#define AMBA_TYPE_AHBIO_ADDR(addr,base_ioarea) ((unsigned int)(base_ioarea) | ((addr) >> 12)) - -/* - * Types and structure used for AMBA Plug & Play bus scanning +/* Copy Data from AMBA PnP I/O Area */ +typedef void *(*ambapp_memcpy_t)( + void *dest, /* Destination RAM copy */ + const void *src, /* Source AMBA PnP Address to copy from */ + int n, /* Number of bytes to be copied */ + struct ambapp_bus *abus /* Optional AMBA Bus pointer */ + ); + +/* Scan a AMBA Plug & Play bus and create all device structures describing the + * the devices. The devices will form a tree, where every node describes one + * interface. The resulting tree is placed in the location pointed to by root. + * + * Since it the tree is located in RAM it is easier to work with AMBA buses + * that is located over PCI and SpaceWire etc. + * + * \param ioarea The IO-AREA where Plug & Play information can be found. + * \param parent Used internally when recursing down a bridge. Set to NULL. + * \param mmaps Is used to perform address translation if needed. + * \param root Resulting device node tree root is stored here. * */ -typedef struct amba_device_table { - int devnr; /* numbrer of devices on AHB or APB bus */ - unsigned int *addr[16]; /* addresses to the devices configuration tables */ -} amba_device_table; - -typedef struct { - int devnr; - unsigned int *addr[AMBA_APB_SLAVES]; /* addresses to the devices configuration tables */ - unsigned int apbmst[AMBA_APB_SLAVES]; /* pointer to AHB slave (which is a APB master) */ -} amba_apb_dev; - -struct amba_mmap { - unsigned int cpu_adr; - unsigned int size; - unsigned int remote_amba_adr; -}; - -typedef struct _amba_confarea_type amba_confarea_type; - -struct _amba_confarea_type { - amba_confarea_type *next; /* next bus in chain */ - int notroot; /* is root of a bus (mother AHB has 64 masters/slaves rest 16) */ - unsigned int ioarea; - struct amba_mmap *mmaps; - amba_device_table ahbmst; - amba_device_table ahbslv; - amba_apb_dev apbslv; -}; - -typedef struct { - unsigned int start, irq, bus_id; -} amba_apb_device; - -typedef struct { - unsigned int start[4], irq, ver; -} amba_ahb_device; - -/* Scans AMBA Plug&Play Information and convers that information - * to a more readable format in RAM. +extern int ambapp_scan( + struct ambapp_bus *abus, + unsigned int ioarea, + ambapp_memcpy_t memfunc, + struct ambapp_mmap *mmaps + ); + +/* Initialize the frequency [Hz] of all AHB Buses from knowing the frequency + * of one particular APB/AHB Device. + */ +extern void ambapp_freq_init( + struct ambapp_bus *abus, + struct ambapp_dev *dev, + unsigned int freq); + +/* Returns the frequency [Hz] of a AHB/APB device */ +extern unsigned int ambapp_freq_get( + struct ambapp_bus *abus, + struct ambapp_dev *dev); + +/* Iterates through all AMBA devices previously found, it calls func + * once for every device that match the search arguments. * - * Will scan for - AHB Masters - * - AHB Slaves - * - APB Slaves (if a AHB/APB bridge is found) + * SEARCH OPTIONS + * All search options must be fulfilled, type of devices searched (options) + * and AMBA Plug&Play ID [VENDOR,DEVICE], before func() is called. The options + * can be use to search only for AMBA APB or AHB Slaves or AHB Masters for + * example. Note that when VENDOR=-1 or DEVICE=-1 it will match any vendor or + * device ID, this means setting both VENDOR and DEVICE to -1 will result in + * calling all devices matches the options argument. * - * \param amba_conf AMBA P&P device info is placed here. - * \param ioarea address of AMBA Plug&Play information, - * on LEON3 systems default is 0xfff00000 - * \param mmaps Memory mmap specific to this amba bus, - * if NULL no translation will be made (default). - * A array of maps, ending with a entry with size=0. + * \param abus AMBAPP Bus to search + * \param options Search options, see OPTIONS_* above + * \param vendor AMBAPP VENDOR ID to search for + * \param device AMBAPP DEVICE ID to search for + * \param func Function called for every device matching search options + * \param arg Optional argument passed on to func + * + * func return value affects the search, returning a non-zero value will + * stop the search and ambapp_for_each will return immediately returning the + * same non-zero value. + * + * Return Values + * 0 - all devices was scanned + * non-zero - stopped by user function returning the non-zero value */ -void amba_scan (amba_confarea_type * amba_conf, unsigned int ioarea, - struct amba_mmap *mmaps); - -/* Print AMBA Plug&Play info on terminal */ -void amba_print_conf (amba_confarea_type * amba_conf); - - - - -/***** APB SLAVES *****/ - -/* Return number of APB Slave devices which has given vendor and device */ -int amba_get_number_apbslv_devices (amba_confarea_type * amba_conf, int vendor, - int device); - -/* Get First APB Slave device of this vendor&device id */ -int amba_find_apbslv (amba_confarea_type * amba_conf, int vendor, int device, - amba_apb_device * dev); - -/* Get APB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_apbslv() ) */ -int amba_find_next_apbslv (amba_confarea_type * amba_conf, int vendor, - int device, amba_apb_device * dev, int index); - -/* Get first nr APB Slave devices, put them into dev (which is an array of nr length) */ -int amba_find_apbslvs (amba_confarea_type * amba_conf, int vendor, int device, - amba_apb_device * devs, int maxno); - - - -/***** AHB SLAVES *****/ - -/* Return number of AHB Slave devices which has given vendor and device */ -int amba_get_number_ahbslv_devices (amba_confarea_type * amba_conf, int vendor, - int device); - -/* Get First AHB Slave device of this vendor&device id */ -int amba_find_ahbslv (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * dev); +extern int ambapp_for_each( + struct ambapp_bus *abus, + unsigned int options, + int vendor, + int device, + ambapp_func_t func, + void *arg); + +/* Helper function for ambapp_for_each(), find a device by index. If pcount + * is NULL the first device is returned, else pcount is interpreted as index + * by decrementing the value until zero is reaced: *count=0 first device, + * *count=1 second device etc. + * + * The matching device is returned, which will stop the ambapp_for_each search. + * If zero is returned from ambapp_for_each no device matching the index was + * found + */ +extern int ambapp_find_by_idx(struct ambapp_dev *dev, int index, void *pcount); -/* Get AHB Slave device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbslv() ) */ -int amba_find_next_ahbslv (amba_confarea_type * amba_conf, int vendor, - int device, amba_ahb_device * dev, int index); +/* Get number of devices matching the options/vendor/device arguments, the + * arguments are passed onto ambapp_for_each(). + */ +extern int ambapp_dev_count(struct ambapp_bus *abus, unsigned int options, + int vendor, int device); -/* Get first nr AHB Slave devices, put them into dev (which is an array of nr length) */ -int amba_find_ahbslvs (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * devs, int maxno); +/* Print short information about devices on the AMBA bus onto the console */ +extern void ambapp_print(struct ambapp_bus *abus, int show_depth); +/* Mark a device taken (allocate), Owner field is set with owner Data. Returns + * -1 if device has already been allocated. + */ +extern int ambapp_alloc_dev(struct ambapp_dev *dev, void *owner); +/* Owner field is cleared, which indicates that device is not allocated */ +extern void ambapp_free_dev(struct ambapp_dev *dev); -/***** AHB MASTERS *****/ +/* Find AHB/APB Bridge or AHB/AHB Bridge Parent */ +extern struct ambapp_dev *ambapp_find_parent(struct ambapp_dev *dev); -/* Return number of AHB Master devices which has given vendor and device */ -int amba_get_number_ahbmst_devices (amba_confarea_type * amba_conf, int vendor, - int device); +/* Returns bus depth (number of sub AHB buses) of device from root bus */ +extern int ambapp_depth(struct ambapp_dev *dev); -/* Get First AHB Master device of this vendor&device id */ -int amba_find_ahbmst (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * dev); +/* Get Device Name from AMBA PnP name database */ +extern char *ambapp_device_id2str(int vendor, int id); -/* Get AHB Master device of this vendor&device id. (setting nr to 0 is eqivalent to calling amba_find_ahbmst() ) */ -int amba_find_next_ahbmst (amba_confarea_type * amba_conf, int vendor, - int device, amba_ahb_device * dev, int index); +/* Get Vendor Name from AMBA PnP name database */ +extern char *ambapp_vendor_id2str(int vendor); -/* Get first nr AHB Master devices, put them into dev (which is an array of nr length) */ -int amba_find_ahbmsts (amba_confarea_type * amba_conf, int vendor, int device, - amba_ahb_device * devs, int maxno); +/* Set together VENDOR_DEVICE Name from AMBA PnP name database. Return length + * of C-string stored in buf not including string termination '\0'. + */ +extern int ambapp_vendev_id2str(int vendor, int id, char *buf); + +/* Help functions for backwards compability */ + +extern int ambapp_find_apbslv( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_apb_info *dev); + +extern int ambapp_find_apbslv_next( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_apb_info *dev, + int index); + +extern int ambapp_find_apbslvs_next( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_apb_info *dev, + int index, + int maxno); + +extern int ambapp_find_apbslvs( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_apb_info *dev, + int maxno); + +extern int ambapp_find_ahbslv( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_ahb_info *dev); + +extern int ambapp_find_ahbslv_next( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_ahb_info *dev, + int index); + +extern int ambapp_find_ahbslvs_next( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_ahb_info *dev, + int index, + int maxno); + +extern int ambapp_find_ahbslvs( + struct ambapp_bus *abus, + int vendor, + int device, + struct ambapp_ahb_info *dev, + int maxno); /******** AMBA DEVICES *******/ diff --git a/c/src/lib/libbsp/sparc/shared/include/ambapp_ids.h b/c/src/lib/libbsp/sparc/shared/include/ambapp_ids.h new file mode 100644 index 0000000000..e6f3601ee2 --- /dev/null +++ b/c/src/lib/libbsp/sparc/shared/include/ambapp_ids.h @@ -0,0 +1,245 @@ +/* AMBA Plug & Play Bus Vendor and Device IDs. + * + * COPYRIGHT (c) 2008. + * Gaisler Research + * + * This header file provide all known VENDOR and DEVICE IDs available + * in the AMBA Plug & Play information. Taken from GRLIB 3386. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + */ + + +#ifndef __AMBAPP_DEVS_H__ +#define __AMBAPP_DEVS_H__ + +/* Vendor codes */ +#define VENDOR_GAISLER 1 +#define VENDOR_PENDER 2 +#define VENDOR_ESA 4 +#define VENDOR_ASTRIUM 6 +#define VENDOR_OPENCHIP 7 +#define VENDOR_OPENCORES 8 +#define VENDOR_CONTRIB 9 +#define VENDOR_EONIC 11 +#define VENDOR_RADIONOR 15 +#define VENDOR_GLEICHMANN 16 +#define VENDOR_MENTA 17 +#define VENDOR_SUN 19 +#define VENDOR_MOVIDIA 20 +#define VENDOR_ORBITA 23 +#define VENDOR_SYNOPSYS 33 +#define VENDOR_NASA 34 +#define VENDOR_ACTEL 172 +#define VENDOR_CAL 202 +#define VENDOR_EMBEDDIT 234 +#define VENDOR_CETON 203 + +/* Gaisler Research device id's */ +#define GAISLER_LEON2DSU 0x002 +#define GAISLER_LEON3 0x003 +#define GAISLER_LEON3DSU 0x004 +#define GAISLER_ETHAHB 0x005 +#define GAISLER_APBMST 0x006 +#define GAISLER_AHBUART 0x007 +#define GAISLER_SRCTRL 0x008 +#define GAISLER_SDCTRL 0x009 +#define GAISLER_SSRCTRL 0x00a +#define GAISLER_APBUART 0x00c +#define GAISLER_IRQMP 0x00d +#define GAISLER_AHBRAM 0x00e +#define GAISLER_AHBDPRAM 0x00f +#define GAISLER_GPTIMER 0x011 +#define GAISLER_PCITRG 0x012 +#define GAISLER_PCISBRG 0x013 +#define GAISLER_PCIFBRG 0x014 +#define GAISLER_PCITRACE 0x015 +#define GAISLER_DMACTRL 0x016 +#define GAISLER_AHBTRACE 0x017 +#define GAISLER_DSUCTRL 0x018 +#define GAISLER_CANAHB 0x019 +#define GAISLER_GPIO 0x01a +#define GAISLER_AHBROM 0x01b +#define GAISLER_AHBJTAG 0x01c +#define GAISLER_ETHMAC 0x01d +#define GAISLER_SWNODE 0x01e +#define GAISLER_SPW 0x01f +#define GAISLER_AHB2AHB 0x020 +#define GAISLER_USBDC 0x021 +#define GAISLER_USB_DCL 0x022 +#define GAISLER_DDRMP 0x023 +#define GAISLER_ATACTRL 0x024 +#define GAISLER_DDRSP 0x025 +#define GAISLER_EHCI 0x026 +#define GAISLER_UHCI 0x027 +#define GAISLER_I2CMST 0x028 +#define GAISLER_SPW2 0x029 +#define GAISLER_AHBDMA 0x02a +#define GAISLER_NUHOSP3 0x02b +#define GAISLER_CLKGATE 0x02c +#define GAISLER_SPICTRL 0x02d +#define GAISLER_DDR2SP 0x02e +#define GAISLER_SLINK 0x02f +#define GAISLER_GRTM 0x030 +#define GAISLER_GRTC 0x031 +#define GAISLER_GRPW 0x032 +#define GAISLER_GRCTM 0x033 +#define GAISLER_GRHCAN 0x034 +#define GAISLER_GRFIFO 0x035 +#define GAISLER_GRADCDAC 0x036 +#define GAISLER_GRPULSE 0x037 +#define GAISLER_GRTIMER 0x038 +#define GAISLER_AHB2PP 0x039 +#define GAISLER_GRVERSION 0x03a +#define GAISLER_APB2PW 0x03b +#define GAISLER_PW2APB 0x03c +#define GAISLER_GRCAN 0x03d +#define GAISLER_I2CSLV 0x03e +#define GAISLER_U16550 0x03f +#define GAISLER_AHBMST_EM 0x040 +#define GAISLER_AHBSLV_EM 0x041 +#define GAISLER_GRTESTMOD 0x042 +#define GAISLER_ASCS 0x043 +#define GAISLER_IPMVBCTRL 0x044 +#define GAISLER_SPIMCTRL 0x045 +#define GAISLER_L4STAT 0x047 +#define GAISLER_LEON4 0x048 +#define GAISLER_LEON4DSU 0x049 +#define GAISLER_GRPWM 0x04a +#define GAISLER_L2CACHE 0x04b +#define GAISLER_GR1553B 0x04d +#define GAISLER_GRIOMMU 0x04f +#define GAISLER_FTAHBRAM 0x050 +#define GAISLER_FTSRCTRL 0x051 +#define GAISLER_AHBSTAT 0x052 +#define GAISLER_LEON3FT 0x053 +#define GAISLER_FTMCTRL 0x054 +#define GAISLER_FTSDCTRL 0x055 +#define GAISLER_FTSRCTRL8 0x056 +#define GAISLER_MEMSCRUB 0x057 +#define GAISLER_APBPS2 0x060 +#define GAISLER_VGACTRL 0x061 +#define GAISLER_LOGAN 0x062 +#define GAISLER_SVGACTRL 0x063 +#define GAISLER_T1AHB 0x064 +#define GAISLER_MP7WRAP 0x065 +#define GAISLER_GRSYSMON 0x066 +#define GAISLER_GRACECTRL 0x067 +#define GAISLER_B1553BC 0x070 +#define GAISLER_B1553RT 0x071 +#define GAISLER_B1553BRM 0x072 +#define GAISLER_GRAES 0x073 +#define GAISLER_SATCAN 0x080 +#define GAISLER_CANMUX 0x081 +#define GAISLER_GRTMRX 0x082 +#define GAISLER_GRTCTX 0x083 +#define GAISLER_GRTMDESC 0x084 +#define GAISLER_GRTMVC 0x085 +#define GAISLER_GEFFE 0x086 +#define GAISLER_AES 0x073 +#define GAISLER_ECC 0x074 +#define GAISLER_PCIF 0x075 +#define GAISLER_CLKMOD 0x076 +#define GAISLER_HAPSTRAK 0x077 +#define GAISLER_TEST_1X2 0x078 +#define GAISLER_WILD2AHB 0x079 +#define GAISLER_BIO1 0x07a +#define GAISLER_GRAESDMA 0x07b +#define GAISLER_GRPCI2 0x07c +#define GAISLER_GRPCI2_DMA 0x07d +#define GAISLER_SPWCUC 0x089 +#define GAISLER_SPW2_DMA 0x08a +#define GAISLER_SPW_ROUTER 0x08b + + +#define GAISLER_PIPEWRAPPER 0xffa +#define GAISLER_L2TIME 0xffd /* internal device: leon2 timer */ +#define GAISLER_L2C 0xffe /* internal device: leon2compat */ +#define GAISLER_PLUGPLAY 0xfff /* internal device: plug & play configarea */ + +/* European Space Agency device id's */ +#define ESA_LEON2 0x002 +#define ESA_LEON2APB 0x003 +#define ESA_IRQ 0x005 +#define ESA_TIMER 0x006 +#define ESA_UART 0x007 +#define ESA_CFG 0x008 +#define ESA_IO 0x009 +#define ESA_MCTRL 0x00f +#define ESA_PCIARB 0x010 +#define ESA_HURRICANE 0x011 +#define ESA_SPW_RMAP 0x012 +#define ESA_SPW2 0x012 +#define ESA_AHBUART 0x013 +#define ESA_SPWA 0x014 +#define ESA_BOSCHCAN 0x015 +#define ESA_IRQ2 0x016 +#define ESA_AHBSTAT 0x017 +#define ESA_WPROT 0x018 +#define ESA_WPROT2 0x019 +#define ESA_PDEC3AMBA 0x020 +#define ESA_PTME3AMBA 0x021 + +#define OPENCHIP_APBGPIO 0x001 +#define OPENCHIP_APBI2C 0x002 +#define OPENCHIP_APBSPI 0x003 +#define OPENCHIP_APBCHARLCD 0x004 +#define OPENCHIP_APBPWM 0x005 +#define OPENCHIP_APBPS2 0x006 +#define OPENCHIP_APBMMCSD 0x007 +#define OPENCHIP_APBNAND 0x008 +#define OPENCHIP_APBLPC 0x009 +#define OPENCHIP_APBCF 0x00a +#define OPENCHIP_APBSYSACE 0x00b +#define OPENCHIP_APB1WIRE 0x00c +#define OPENCHIP_APBJTAG 0x00d +#define OPENCHIP_APBSUI 0x00e + + +#define CONTRIB_CORE1 0x001 +#define CONTRIB_CORE2 0x002 + +#define GLEICHMANN_CUSTOM 0x001 +#define GLEICHMANN_GEOLCD01 0x002 +#define GLEICHMANN_DAC 0x003 +#define GLEICHMANN_HPI 0x004 +#define GLEICHMANN_SPI 0x005 +#define GLEICHMANN_HIFC 0x006 +#define GLEICHMANN_ADCDAC 0x007 +#define GLEICHMANN_SPIOC 0x008 +#define GLEICHMANN_AC97 0x009 + +#define SUN_T1 0x001 +#define SUN_S1 0x011 + +#define ORBITA_1553B 0x001 +#define ORBITA_429 0x002 +#define ORBITA_SPI 0x003 +#define ORBITA_I2C 0x004 +#define ORBITA_SMARTCARD 0x064 +#define ORBITA_SDCARD 0x065 +#define ORBITA_UART16550 0x066 +#define ORBITA_CRYPTO 0x067 +#define ORBITA_SYSIF 0x068 +#define ORBITA_PIO 0x069 +#define ORBITA_RTC 0x0c8 +#define ORBITA_COLORLCD 0x12c +#define ORBITA_PCI 0x190 +#define ORBITA_DSP 0x1f4 +#define ORBITA_USBHOST 0x258 +#define ORBITA_USBDEV 0x2bc + +#define NASA_EP32 0x001 + +#define CAL_DDRCTRL 0x188 + +#define ACTEL_COREMP7 0x001 + +/* Opencores device id's */ +#define OPENCORES_PCIBR 0x4 +#define OPENCORES_ETHMAC 0x5 + +#endif diff --git a/c/src/lib/libbsp/sparc/shared/include/apbuart.h b/c/src/lib/libbsp/sparc/shared/include/apbuart.h index c8a6e35fec..c948b24da1 100644 --- a/c/src/lib/libbsp/sparc/shared/include/apbuart.h +++ b/c/src/lib/libbsp/sparc/shared/include/apbuart.h @@ -72,9 +72,9 @@ typedef struct { /* Register APBUART driver * bus = pointer to AMBA bus description used to search for APBUART(s). - * (&amba_conf for LEON3), (LEON2: see amba_scan) + * (&ambapp_plb for LEON3), (LEON2: see amba_scan) */ -int apbuart_register (amba_confarea_type * bus); +int apbuart_register (struct ambapp_bus *bus); #ifdef __cplusplus } diff --git a/c/src/lib/libbsp/sparc/shared/include/apbuart_pci.h b/c/src/lib/libbsp/sparc/shared/include/apbuart_pci.h index e8064297c8..11ac33e506 100644 --- a/c/src/lib/libbsp/sparc/shared/include/apbuart_pci.h +++ b/c/src/lib/libbsp/sparc/shared/include/apbuart_pci.h @@ -24,7 +24,7 @@ extern "C" { * */ -int apbuart_pci_register (amba_confarea_type * bus); +int apbuart_pci_register (struct ambapp_bus * bus); /* This function must be called on APBUART interrupt. Called from the * PCI interrupt handler. diff --git a/c/src/lib/libbsp/sparc/shared/include/apbuart_rasta.h b/c/src/lib/libbsp/sparc/shared/include/apbuart_rasta.h index 1edf6f98d3..61c6144818 100644 --- a/c/src/lib/libbsp/sparc/shared/include/apbuart_rasta.h +++ b/c/src/lib/libbsp/sparc/shared/include/apbuart_rasta.h @@ -24,7 +24,7 @@ extern "C" { * */ -int apbuart_rasta_register(amba_confarea_type *bus); +int apbuart_rasta_register(struct ambapp_bus *bus); /* This function must be called on APBUART interrupt. Called from the * RASTA interrupt handler. diff --git a/c/src/lib/libbsp/sparc/shared/include/b1553brm.h b/c/src/lib/libbsp/sparc/shared/include/b1553brm.h index f5fd343078..f0f09c5969 100644 --- a/c/src/lib/libbsp/sparc/shared/include/b1553brm.h +++ b/c/src/lib/libbsp/sparc/shared/include/b1553brm.h @@ -158,9 +158,9 @@ int brm_register_leon3_ramon_asic(void); /* Register BRM driver * See (struct brm_reg).w_ctrl for clksel and clkdiv. * See Enhanced register (the least signinficant 2 bits) in BRM Core for brm_freq - * bus = &amba_conf for LEON3. (LEON2 not yet supported for this driver) + * bus = &ambapp_plb for LEON3. (LEON2 not yet supported for this driver) */ -int b1553brm_register(amba_confarea_type *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq); +int b1553brm_register(struct ambapp_bus *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq); #ifdef __cplusplus } diff --git a/c/src/lib/libbsp/sparc/shared/include/b1553brm_pci.h b/c/src/lib/libbsp/sparc/shared/include/b1553brm_pci.h index 74f9d321de..9861dc3658 100644 --- a/c/src/lib/libbsp/sparc/shared/include/b1553brm_pci.h +++ b/c/src/lib/libbsp/sparc/shared/include/b1553brm_pci.h @@ -22,7 +22,7 @@ extern "C" { /* Register BRM driver * See (struct brm_reg).w_ctrl for clksel and clkdiv. * See Enhanced register (the least signinficant 2 bits) in BRM Core for brm_freq - * bus = &amba_conf for LEON3. (LEON2 not yet supported for this driver) + * bus = &ambapp_plb for LEON3. (LEON2 not yet supported for this driver) * * Memory setup: * memarea = 128k aligned pointer to memory (if zero malloc will be used) (as the CPU sees it) @@ -30,7 +30,7 @@ extern "C" { */ int b1553brm_pci_register( - amba_confarea_type *bus, + struct ambapp_bus *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq, diff --git a/c/src/lib/libbsp/sparc/shared/include/b1553brm_rasta.h b/c/src/lib/libbsp/sparc/shared/include/b1553brm_rasta.h index cd5165801c..360b72fc18 100644 --- a/c/src/lib/libbsp/sparc/shared/include/b1553brm_rasta.h +++ b/c/src/lib/libbsp/sparc/shared/include/b1553brm_rasta.h @@ -22,7 +22,7 @@ extern "C" { /* Register BRM driver * See (struct brm_reg).w_ctrl for clksel and clkdiv. * See Enhanced register (the least signinficant 2 bits) in BRM Core for brm_freq - * bus = &amba_conf for LEON3. (LEON2 not yet supported for this driver) + * bus = &ambapp_plb for LEON3. (LEON2 not yet supported for this driver) * * Memory setup: * memarea = 128k aligned pointer to memory (if zero malloc will be used) (as the CPU sees it) @@ -30,7 +30,7 @@ extern "C" { */ int b1553brm_rasta_register( - amba_confarea_type *bus, + struct ambapp_bus *bus, unsigned int clksel, unsigned int clkdiv, unsigned int brm_freq, diff --git a/c/src/lib/libbsp/sparc/shared/include/grcan.h b/c/src/lib/libbsp/sparc/shared/include/grcan.h index 8b3ed15e55..f8f577d4d5 100644 --- a/c/src/lib/libbsp/sparc/shared/include/grcan.h +++ b/c/src/lib/libbsp/sparc/shared/include/grcan.h @@ -190,7 +190,7 @@ struct grcan_device_info { int grcan_register_abs(struct grcan_device_info *devices, int dev_cnt); /* Use prescanned AMBA Plug&Play information to find all GRFIFO cores */ -int grcan_register(amba_confarea_type *abus); +int grcan_register(struct ambapp_bus *abus); #if 0 void grcan_register(unsigned int baseaddr, unsigned int ram_base); void grcan_interrupt_handler(rtems_vector_number v); diff --git a/c/src/lib/libbsp/sparc/shared/include/grcan_rasta.h b/c/src/lib/libbsp/sparc/shared/include/grcan_rasta.h index 1f96da6bef..20a2fac252 100644 --- a/c/src/lib/libbsp/sparc/shared/include/grcan_rasta.h +++ b/c/src/lib/libbsp/sparc/shared/include/grcan_rasta.h @@ -13,7 +13,7 @@ extern "C" { * rambase is address of the first GRCAN core has it's TX buffer, followed by * it's RX buffer */ -int grcan_rasta_ram_register(amba_confarea_type *abus, int rambase); +int grcan_rasta_ram_register(struct ambapp_bus *abus, int rambase); extern void (*grcan_rasta_int_reg)(void *handler, int irq, void *arg); diff --git a/c/src/lib/libbsp/sparc/shared/include/grspw.h b/c/src/lib/libbsp/sparc/shared/include/grspw.h index 4c6c869d61..e60aa87a07 100644 --- a/c/src/lib/libbsp/sparc/shared/include/grspw.h +++ b/c/src/lib/libbsp/sparc/shared/include/grspw.h @@ -111,7 +111,7 @@ typedef struct { #define SPACEWIRE_IOCTRL_START 64 #define SPACEWIRE_IOCTRL_STOP 65 -int grspw_register(amba_confarea_type *bus); +int grspw_register(struct ambapp_bus *bus); #if 0 diff --git a/c/src/lib/libbsp/sparc/shared/include/grspw_pci.h b/c/src/lib/libbsp/sparc/shared/include/grspw_pci.h index aea50f3791..9e2cd60d4a 100644 --- a/c/src/lib/libbsp/sparc/shared/include/grspw_pci.h +++ b/c/src/lib/libbsp/sparc/shared/include/grspw_pci.h @@ -20,14 +20,14 @@ extern "C" { #endif /* Register GRSPW Driver - * bus = &amba_conf for LEON3 + * bus = &ambapp_plb for LEON3 * * Memory setup: * memarea = 128k aligned pointer to memory (if zero malloc will be used) (as the CPU sees it) * hw_address = address that HW must use to access memarea. (used in the translation process) */ -int grspw_pci_register (amba_confarea_type * bus, +int grspw_pci_register (struct ambapp_bus *bus, unsigned int memarea, unsigned int hw_address); diff --git a/c/src/lib/libbsp/sparc/shared/include/grspw_rasta.h b/c/src/lib/libbsp/sparc/shared/include/grspw_rasta.h index 0e4e5bee4d..c4c0cd0dd7 100644 --- a/c/src/lib/libbsp/sparc/shared/include/grspw_rasta.h +++ b/c/src/lib/libbsp/sparc/shared/include/grspw_rasta.h @@ -20,14 +20,14 @@ extern "C" { #endif /* Register GRSPW Driver - * bus = &amba_conf for LEON3 + * bus = &ambapp_plb for LEON3 * * Memory setup: * ram_base = 128k aligned pointer to memory (as the CPU sees it) */ int grspw_rasta_register( - amba_confarea_type *bus, + struct ambapp_bus *bus, unsigned int ram_base ); diff --git a/c/src/lib/libbsp/sparc/shared/include/i2cmst.h b/c/src/lib/libbsp/sparc/shared/include/i2cmst.h index 21780ee143..9f612fab1e 100644 --- a/c/src/lib/libbsp/sparc/shared/include/i2cmst.h +++ b/c/src/lib/libbsp/sparc/shared/include/i2cmst.h @@ -68,7 +68,7 @@ typedef struct gr_i2cmst_desc { } gr_i2cmst_desc_t; /* Scans for I2CMST core and initalizes i2c library */ -rtems_status_code leon_register_i2c(amba_confarea_type *abus); +rtems_status_code leon_register_i2c(struct ambapp_bus *abus); #ifdef __cplusplus } diff --git a/c/src/lib/libbsp/sparc/shared/include/occan.h b/c/src/lib/libbsp/sparc/shared/include/occan.h index 12ec42a01c..5c875b324e 100644 --- a/c/src/lib/libbsp/sparc/shared/include/occan.h +++ b/c/src/lib/libbsp/sparc/shared/include/occan.h @@ -147,7 +147,7 @@ struct occan_afilter { #define OCCAN_BLK_MODE_RX 0x1 #define OCCAN_BLK_MODE_TX 0x2 -int occan_register(amba_confarea_type *bus); +int occan_register(struct ambapp_bus *bus); #define OCCAN_SPEED_500K 500000 diff --git a/c/src/lib/libbsp/sparc/shared/include/occan_pci.h b/c/src/lib/libbsp/sparc/shared/include/occan_pci.h index 2f46293af2..d351f85ff9 100644 --- a/c/src/lib/libbsp/sparc/shared/include/occan_pci.h +++ b/c/src/lib/libbsp/sparc/shared/include/occan_pci.h @@ -23,7 +23,7 @@ extern "C" { * bus = pointer to AMBA bus description used to search for OC_CAN contrller(s). */ -int occan_pci_register(amba_confarea_type *bus); +int occan_pci_register(struct ambapp_bus *bus); /* This function must be called on OC_CAN interrupt. Called from the * PCI interrupt handler. irq = AMBA IRQ assigned to the OC_CAN device, diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw.c b/c/src/lib/libbsp/sparc/shared/spw/grspw.c index 6a9da79dfa..8ab502023b 100644 --- a/c/src/lib/libbsp/sparc/shared/spw/grspw.c +++ b/c/src/lib/libbsp/sparc/shared/spw/grspw.c @@ -370,9 +370,9 @@ static rtems_device_driver grspw_control( grspw_control } static rtems_driver_address_table grspw_driver = GRSPW_DRIVER_TABLE_ENTRY; -static amba_confarea_type *amba_bus; +static struct ambapp_bus *amba_bus; -int GRSPW_PREFIX(_register)(amba_confarea_type *bus) +int GRSPW_PREFIX(_register)(struct ambapp_bus *bus) { rtems_status_code r; rtems_device_major_number m; @@ -389,10 +389,11 @@ int GRSPW_PREFIX(_register)(amba_confarea_type *bus) #ifdef LEON3 /* LEON3: find timer address via AMBA Plug&Play info */ { - amba_apb_device gptimer; + struct ambapp_apb_info gptimer; LEON3_Timer_Regs_Map *tregs; - if ( amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&gptimer) == 1 ){ + if ( ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, + GAISLER_GPTIMER, &gptimer) == 1 ) { tregs = (LEON3_Timer_Regs_Map *)gptimer.start; sys_freq_khz = (tregs->scaler_reload+1)*1000; SPACEWIRE_DBG("GRSPW: detected %dkHZ system frequency\n\r",sys_freq_khz); @@ -609,7 +610,7 @@ static rtems_device_driver grspw_initialize( char c; GRSPW_DEV *pDev; char console_name[20]; - amba_apb_device dev; + struct ambapp_apb_info dev; SPACEWIRE_DBG2("spacewire driver initialization\n"); @@ -620,19 +621,10 @@ static rtems_device_driver grspw_initialize( i=0; spw_cores = 0; spw_cores2 = 0; /* get number of GRSPW cores */ - spw_cores = amba_get_number_apbslv_devices(amba_bus,VENDOR_GAISLER,GAISLER_SPACEWIRE); - spw_cores2 = amba_get_number_apbslv_devices(amba_bus,VENDOR_GAISLER,GAISLER_GRSPW2); -#if 0 - if ( spw_cores > SPACEWIRE_MAX_CORENR ) - spw_cores = SPACEWIRE_MAX_CORENR; - - while (i < amba_conf.apbslv.devnr) { - conf = amba_get_confword(amba_conf.apbslv, i, 0); - if ((amba_vendor(conf) == VENDOR_GAISLER) && (amba_device(conf) == GAISLER_SPACEWIRE)) - spw_cores++; - i++; - } -#endif + spw_cores = ambapp_get_number_apbslv_devices(amba_bus, VENDOR_GAISLER, + GAISLER_SPW); + spw_cores2 = ambapp_get_number_apbslv_devices(amba_bus, VENDOR_GAISLER, + GAISLER_SPW2); if ( (spw_cores+spw_cores2) < 1 ){ /* No GRSPW cores around... */ @@ -653,10 +645,13 @@ static rtems_device_driver grspw_initialize( /* Get device */ if ( spw_cores > minor ) { - amba_find_next_apbslv(amba_bus,VENDOR_GAISLER,GAISLER_SPACEWIRE,&dev,minor); + ambapp_find_apbslv_next(amba_bus, VENDOR_GAISLER, + GAISLER_SPW, &dev, minor); pDev->core_ver = 1; } else { - amba_find_next_apbslv(amba_bus,VENDOR_GAISLER,GAISLER_GRSPW2,&dev,minor-spw_cores); + ambapp_find_apbslv_next(amba_bus, VENDOR_GAISLER, + GAISLER_SPW2, &dev, + minor - spw_cores); pDev->core_ver = 2; } diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c b/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c index a8003be8f9..2a9a8d6094 100644 --- a/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c +++ b/c/src/lib/libbsp/sparc/shared/spw/grspw_pci.c @@ -79,7 +79,7 @@ int grspwpci_interrupt_handler(int irq, void *arg); */ int grspw_pci_register( - amba_confarea_type *bus, + struct ambapp_bus *bus, unsigned int memarea, unsigned int hw_address ) diff --git a/c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c b/c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c index 6cd5698f44..9bf9437c4d 100644 --- a/c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c +++ b/c/src/lib/libbsp/sparc/shared/spw/grspw_rasta.c @@ -88,7 +88,7 @@ unsigned int grspw_rasta_memarea_address; */ int grspw_rasta_register( - amba_confarea_type *bus, + struct ambapp_bus *bus, unsigned int ram_base ) { diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c index b3f4bbdd9a..d442e80a46 100644 --- a/c/src/lib/libbsp/sparc/shared/uart/apbuart.c +++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart.c @@ -116,7 +116,7 @@ static unsigned int sys_freq_hz; #define APBUART_DRIVER_TABLE_ENTRY { apbuart_initialize, apbuart_open, apbuart_close, apbuart_read, apbuart_write, apbuart_control } static rtems_driver_address_table apbuart_driver = APBUART_DRIVER_TABLE_ENTRY; -static amba_confarea_type *amba_bus; +static struct ambapp_bus *amba_bus; static void apbuart_interrupt(apbuart_priv *uart); #ifdef APBUART_DEFINE_INTHANDLER @@ -322,7 +322,7 @@ static void apbuart_interrupt(apbuart_priv *uart){ } } -int APBUART_PREFIX(_register)(amba_confarea_type *bus) { +int APBUART_PREFIX(_register)(struct ambapp_bus *bus) { rtems_status_code r; rtems_device_major_number m; @@ -353,13 +353,14 @@ static rtems_device_driver apbuart_initialize(rtems_device_major_number major, rtems_status_code status; int i; - amba_apb_device dev; + struct ambapp_apb_info dev; char fs_name[20]; FUNCDBG("apbuart_initialize\n"); /* Find all APB UART devices */ - dev_cnt = amba_get_number_apbslv_devices(amba_bus,VENDOR_GAISLER,GAISLER_APBUART); + dev_cnt = ambapp_get_number_apbslv_devices(amba_bus, VENDOR_GAISLER, + GAISLER_APBUART); if ( dev_cnt < 1 ){ /* Failed to find any CAN cores! */ printk("APBUART: Failed to find any APBUART cores\n\r"); @@ -384,10 +385,11 @@ static rtems_device_driver apbuart_initialize(rtems_device_major_number major, #if defined(LEON3) /* LEON3: find timer address via AMBA Plug&Play info */ { - amba_apb_device gptimer; + struct ambapp_apb_info gptimer; LEON3_Timer_Regs_Map *tregs; - if ( amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&gptimer) == 1 ){ + if ( ambapp_find_apbslv(&ambapp_plb, VENDOR_GAISLER, + GAISLER_GPTIMER, &gptimer) == 1 ){ tregs = (LEON3_Timer_Regs_Map *)gptimer.start; sys_freq_hz = (tregs->scaler_reload+1)*1000*1000; DBG("APBUART: detected %dHZ system frequency\n\r",sys_freq_hz); @@ -413,7 +415,7 @@ static rtems_device_driver apbuart_initialize(rtems_device_major_number major, for(i=0; i<dev_cnt; i++){ /* Get AMBA AHB device info from Plug&Play */ - amba_find_next_apbslv(amba_bus,VENDOR_GAISLER,GAISLER_APBUART,&dev,i); + ambapp_find_apbslv_next(amba_bus,VENDOR_GAISLER,GAISLER_APBUART,&dev,i); printk("APBUART[%d]: at 0x%x irq %d (0x%x)\n\r",i,dev.start,dev.irq,(unsigned int)&apbuarts[i]); diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c index 54d14ce459..fce1197e8c 100644 --- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c +++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_pci.c @@ -24,7 +24,7 @@ void apbuartpci_interrupt_handler(int irq, void *arg); #include "apbuart.c" -int apbuart_pci_register(amba_confarea_type *bus) +int apbuart_pci_register(struct ambapp_bus *bus) { /* Setup configuration */ diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_rasta.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_rasta.c index 4b8734fdb6..3196bbb202 100644 --- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_rasta.c +++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_rasta.c @@ -24,7 +24,7 @@ void apbuartrasta_interrupt_handler(int irq, void *arg); #include "apbuart.c" -int apbuart_rasta_register(amba_confarea_type *bus) +int apbuart_rasta_register(struct ambapp_bus *bus) { /* Setup configuration */ diff --git a/c/src/libchip/network/open_eth.c b/c/src/libchip/network/open_eth.c index 86f7e6289b..dc8b22b204 100644 --- a/c/src/libchip/network/open_eth.c +++ b/c/src/libchip/network/open_eth.c @@ -55,13 +55,7 @@ #undef free #endif -#if defined(__m68k__) -extern m68k_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int ); -#elif defined(__lm32__) -extern lm32_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int ); -#else extern rtems_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int ); -#endif /* #define OPEN_ETH_DEBUG diff --git a/c/src/libchip/network/sonic.c b/c/src/libchip/network/sonic.c index 2abc949e41..d9007570ba 100644 --- a/c/src/libchip/network/sonic.c +++ b/c/src/libchip/network/sonic.c @@ -54,11 +54,7 @@ #include <netinet/in.h> #include <netinet/if_ether.h> -#if defined(__m68k__) -extern m68k_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int ); -#else extern rtems_isr_entry set_vector( rtems_isr_entry, rtems_vector_number, int ); -#endif #if (SONIC_DEBUG & SONIC_DEBUG_DUMP_MBUFS) #include <rtems/dumpbuf.h> diff --git a/cpukit/libqos/preinstall.am b/cpukit/libqos/preinstall.am new file mode 100644 index 0000000000..9b48932f2c --- /dev/null +++ b/cpukit/libqos/preinstall.am @@ -0,0 +1,28 @@ +## Automatically generated by ampolish3 - Do not edit + +if AMPOLISH3 +$(srcdir)/preinstall.am: Makefile.am + $(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am +endif + +PREINSTALL_DIRS = +DISTCLEANFILES = $(PREINSTALL_DIRS) + +all-am: $(PREINSTALL_FILES) + +PREINSTALL_FILES = +CLEANFILES = $(PREINSTALL_FILES) + +$(PROJECT_INCLUDE)/$(dirstamp): + @$(MKDIR_P) $(PROJECT_INCLUDE) + @: > $(PROJECT_INCLUDE)/$(dirstamp) +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp) + +$(PROJECT_INCLUDE)/qreslib.h: qreslib.h $(PROJECT_INCLUDE)/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/qreslib.h +PREINSTALL_FILES += $(PROJECT_INCLUDE)/qreslib.h + +$(PROJECT_INCLUDE)/qreslib.inl: qreslib.inl $(PROJECT_INCLUDE)/$(dirstamp) + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/qreslib.inl +PREINSTALL_FILES += $(PROJECT_INCLUDE)/qreslib.inl + diff --git a/cpukit/sapi/include/rtems/rbheap.h b/cpukit/sapi/include/rtems/rbheap.h index be1eec6b66..5481e8954f 100644 --- a/cpukit/sapi/include/rtems/rbheap.h +++ b/cpukit/sapi/include/rtems/rbheap.h @@ -36,60 +36,191 @@ extern "C" { * * @brief Red-Black Tree Heap API. * - * In the Red-Black Tree Heap the administration data structures are not - * contained in the managed memory area. This can be used for example in a - * task stack allocator which protects the task stacks from access by other - * tasks. + * The red-black tree heap provides a memory allocator suitable to implement + * the malloc() and free() interface. It uses a first-fit allocation strategy. + * In the red-black tree heap the administration data structures are not + * contained in the managed memory area. Thus writing beyond the boundaries of + * a chunk does not damage the data to maintain the heap. This can be used for + * example in a task stack allocator which protects the task stacks from access + * by other tasks. The allocated and free memory parts of the managed area are + * called chunks. Each chunk needs a descriptor which is stored outside of the + * managed area. * * @{ */ +/** + * @brief Red-black heap chunk descriptor. + */ typedef struct { + /** + * This chain node can be used in two chains + * - the chain of spare chunk descriptors and + * - the chain of free chunks in the managed memory area. + * + * In case this chain node is not part of a chain, the chunk represents a + * used chunk in the managed memory area. + */ rtems_chain_node chain_node; + + /** + * Tree node for chunks that represent a part of the managed memory area. + * These chunks are either free or used. + */ rtems_rbtree_node tree_node; + + /** + * Begin address of the chunk. The address alignment it specified in the + * @ref rtems_rbheap_control. + */ uintptr_t begin; + + /** + * Size of the chunk in bytes. + */ uintptr_t size; -} rtems_rbheap_page; +} rtems_rbheap_chunk; typedef struct rtems_rbheap_control rtems_rbheap_control; -typedef void (*rtems_rbheap_extend_page_pool)(rtems_rbheap_control *control); +/** + * @brief Handler to extend the available chunk descriptors. + * + * This handler is called when no more chunk descriptors are available. An + * example implementation is this: + * + * @code + * void extend_descriptors_with_malloc(rtems_rbheap_control *control) + * { + * rtems_rbheap_chunk *chunk = malloc(sizeof(*chunk)); + * + * if (chunk != NULL) { + * rtems_rbheap_add_to_spare_descriptor_chain(control, chunk); + * } + * } + * @endcode + * + * @see rtems_rbheap_extend_descriptors_never() and + * rtems_rbheap_extend_descriptors_with_malloc(). + */ +typedef void (*rtems_rbheap_extend_descriptors)(rtems_rbheap_control *control); +/** + * @brief Red-black heap control. + */ struct rtems_rbheap_control { - rtems_chain_control free_chain; - rtems_chain_control pool_chain; - rtems_rbtree_control page_tree; - uintptr_t page_alignment; - rtems_rbheap_extend_page_pool extend_page_pool; + /** + * Chain of free chunks in the managed memory area. + */ + rtems_chain_control free_chunk_chain; + + /** + * Chain of free chunk descriptors. Descriptors are consumed during + * allocation and may be produced during free if contiguous chunks can be + * coalesced. In case of descriptor starvation the @ref extend_descriptors + * handler will be called. + */ + rtems_chain_control spare_descriptor_chain; + + /** + * Tree of chunks representing the state of the managed memory area. + */ + rtems_rbtree_control chunk_tree; + + /** + * Minimum chunk begin alignment in bytes. + */ + uintptr_t alignment; + + /** + * Handler to extend the available chunk descriptors. + */ + rtems_rbheap_extend_descriptors extend_descriptors; + + /** + * User specified argument handler for private handler data. + */ void *handler_arg; }; +/** + * @brief Initializes the red-black tree heap @a control. + * + * @param[in, out] control The red-black tree heap. + * @param[in] area_begin The managed memory area begin. + * @param[in] area_size The managed memory area size. + * @param[in] alignment The minimum chunk alignment. + * @param[in] extend_descriptors The handler to extend the available chunk + * descriptors. + * @param[in] handler_arg The handler argument. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_NUMBER The alignment is not positive. + * @retval RTEMS_INVALID_ADDRESS The memory area is invalid. + * @retval RTEMS_NO_MEMORY Not enough chunk descriptors. + */ rtems_status_code rtems_rbheap_initialize( rtems_rbheap_control *control, void *area_begin, uintptr_t area_size, - uintptr_t page_alignment, - rtems_rbheap_extend_page_pool extend_page_pool, + uintptr_t alignment, + rtems_rbheap_extend_descriptors extend_descriptors, void *handler_arg ); +/** + * @brief Allocates a chunk of memory of at least @a size bytes from the + * red-black tree heap @a control. + * + * The chunk begin is aligned by the value specified in + * rtems_rbheap_initialize(). + * + * @param[in, out] control The red-black tree heap. + * @param[in] size The requested chunk size in bytes. + * + * @retval NULL Not enough free space in the heap. + * @retval otherwise Pointer to allocated chunk of memory. + */ void *rtems_rbheap_allocate(rtems_rbheap_control *control, size_t size); +/** + * @brief Frees a chunk of memory @a ptr allocated from the red-black tree heap + * @a control. + * + * @param[in, out] control The red-black tree heap. + * @param[in] ptr The pointer to the chunk of memory. + * + * @retval RTEMS_SUCCESSFUL Successful operation. + * @retval RTEMS_INVALID_ID The chunk of memory is not a valid chunk in the + * red-black tree heap. + * @retval RTEMS_INCORRECT_STATE The chunk of memory is not in the right state. + */ rtems_status_code rtems_rbheap_free(rtems_rbheap_control *control, void *ptr); -static inline rtems_chain_control *rtems_rbheap_get_pool_chain( +static inline rtems_chain_control *rtems_rbheap_get_spare_descriptor_chain( rtems_rbheap_control *control ) { - return &control->pool_chain; + return &control->spare_descriptor_chain; } -static inline void rtems_rbheap_set_extend_page_pool( +static inline void rtems_rbheap_add_to_spare_descriptor_chain( rtems_rbheap_control *control, - rtems_rbheap_extend_page_pool extend_page_pool + rtems_rbheap_chunk *chunk ) { - control->extend_page_pool = extend_page_pool; + rtems_chain_control *chain = + rtems_rbheap_get_spare_descriptor_chain(control); + + rtems_chain_prepend_unprotected(chain, &chunk->chain_node); +} + +static inline void rtems_rbheap_set_extend_descriptors( + rtems_rbheap_control *control, + rtems_rbheap_extend_descriptors extend_descriptors +) +{ + control->extend_descriptors = extend_descriptors; } static inline void *rtems_rbheap_get_handler_arg( @@ -107,20 +238,28 @@ static inline void rtems_rbheap_set_handler_arg( control->handler_arg = handler_arg; } -void rtems_rbheap_extend_page_pool_never(rtems_rbheap_control *control); +/** + * @brief Chunk descriptor extend handler that does nothing. + */ +void rtems_rbheap_extend_descriptors_never(rtems_rbheap_control *control); -void rtems_rbheap_extend_page_pool_with_malloc(rtems_rbheap_control *control); +/** + * @brief Chunk descriptor extend handler that uses malloc(). + */ +void rtems_rbheap_extend_descriptors_with_malloc( + rtems_rbheap_control *control +); /** @} */ /* Private API */ -#define rtems_rbheap_page_of_node(node) \ - rtems_rbtree_container_of(node, rtems_rbheap_page, tree_node) +#define rtems_rbheap_chunk_of_node(node) \ + rtems_rbtree_container_of(node, rtems_rbheap_chunk, tree_node) -static inline bool rtems_rbheap_is_page_free(const rtems_rbheap_page *page) +static inline bool rtems_rbheap_is_chunk_free(const rtems_rbheap_chunk *chunk) { - return !rtems_chain_is_node_off_chain(&page->chain_node); + return !rtems_chain_is_node_off_chain(&chunk->chain_node); } #ifdef __cplusplus diff --git a/cpukit/sapi/src/rbheap.c b/cpukit/sapi/src/rbheap.c index 798632520d..7facf4f9af 100644 --- a/cpukit/sapi/src/rbheap.c +++ b/cpukit/sapi/src/rbheap.c @@ -28,96 +28,96 @@ #include <stdlib.h> -static uintptr_t align_up(uintptr_t page_alignment, uintptr_t value) +static uintptr_t align_up(uintptr_t alignment, uintptr_t value) { - uintptr_t excess = value % page_alignment; + uintptr_t excess = value % alignment; if (excess > 0) { - value += page_alignment - excess; + value += alignment - excess; } return value; } -static uintptr_t align_down(uintptr_t page_alignment, uintptr_t value) +static uintptr_t align_down(uintptr_t alignment, uintptr_t value) { - uintptr_t excess = value % page_alignment; + uintptr_t excess = value % alignment; return value - excess; } -static int page_compare(const rtems_rbtree_node *a, const rtems_rbtree_node *b) +static int chunk_compare(const rtems_rbtree_node *a, const rtems_rbtree_node *b) { - const rtems_rbheap_page *left = rtems_rbheap_page_of_node(a); - const rtems_rbheap_page *right = rtems_rbheap_page_of_node(b); + const rtems_rbheap_chunk *left = rtems_rbheap_chunk_of_node(a); + const rtems_rbheap_chunk *right = rtems_rbheap_chunk_of_node(b); return (int) (left->begin - right->begin); } -static rtems_rbheap_page *get_page(rtems_rbheap_control *control) +static rtems_rbheap_chunk *get_chunk(rtems_rbheap_control *control) { - rtems_chain_control *pool_chain = &control->pool_chain; - rtems_chain_node *page = rtems_chain_get(pool_chain); + rtems_chain_control *chain = &control->spare_descriptor_chain; + rtems_chain_node *chunk = rtems_chain_get_unprotected(chain); - if (page == NULL) { - (*control->extend_page_pool)(control); - page = rtems_chain_get(pool_chain); + if (chunk == NULL) { + (*control->extend_descriptors)(control); + chunk = rtems_chain_get_unprotected(chain); } - return (rtems_rbheap_page *) page; + return (rtems_rbheap_chunk *) chunk; } static void add_to_chain( rtems_chain_control *chain, - rtems_rbheap_page *page + rtems_rbheap_chunk *chunk ) { - rtems_chain_prepend_unprotected(chain, &page->chain_node); + rtems_chain_prepend_unprotected(chain, &chunk->chain_node); } static void insert_into_tree( rtems_rbtree_control *tree, - rtems_rbheap_page *page + rtems_rbheap_chunk *chunk ) { - _RBTree_Insert_unprotected(tree, &page->tree_node); + _RBTree_Insert_unprotected(tree, &chunk->tree_node); } rtems_status_code rtems_rbheap_initialize( rtems_rbheap_control *control, void *area_begin, uintptr_t area_size, - uintptr_t page_alignment, - rtems_rbheap_extend_page_pool extend_page_pool, + uintptr_t alignment, + rtems_rbheap_extend_descriptors extend_descriptors, void *handler_arg ) { rtems_status_code sc = RTEMS_SUCCESSFUL; - if (page_alignment > 0) { + if (alignment > 0) { uintptr_t begin = (uintptr_t) area_begin; uintptr_t end = begin + area_size; - uintptr_t aligned_begin = align_up(page_alignment, begin); - uintptr_t aligned_end = align_down(page_alignment, end); + uintptr_t aligned_begin = align_up(alignment, begin); + uintptr_t aligned_end = align_down(alignment, end); if (begin < end && begin <= aligned_begin && aligned_begin < aligned_end) { - rtems_chain_control *free_chain = &control->free_chain; - rtems_rbtree_control *page_tree = &control->page_tree; - rtems_rbheap_page *first = NULL; + rtems_chain_control *free_chain = &control->free_chunk_chain; + rtems_rbtree_control *chunk_tree = &control->chunk_tree; + rtems_rbheap_chunk *first = NULL; rtems_chain_initialize_empty(free_chain); - rtems_chain_initialize_empty(&control->pool_chain); - rtems_rbtree_initialize_empty(page_tree, page_compare, true); - control->page_alignment = page_alignment; + rtems_chain_initialize_empty(&control->spare_descriptor_chain); + rtems_rbtree_initialize_empty(chunk_tree, chunk_compare, true); + control->alignment = alignment; control->handler_arg = handler_arg; - control->extend_page_pool = extend_page_pool; + control->extend_descriptors = extend_descriptors; - first = get_page(control); + first = get_chunk(control); if (first != NULL) { first->begin = aligned_begin; first->size = aligned_end - aligned_begin; add_to_chain(free_chain, first); - insert_into_tree(page_tree, first); + insert_into_tree(chunk_tree, first); } else { sc = RTEMS_NO_MEMORY; } @@ -131,20 +131,20 @@ rtems_status_code rtems_rbheap_initialize( return sc; } -static rtems_rbheap_page *search_free_page( +static rtems_rbheap_chunk *search_free_chunk( rtems_chain_control *free_chain, size_t size ) { rtems_chain_node *current = rtems_chain_first(free_chain); const rtems_chain_node *tail = rtems_chain_tail(free_chain); - rtems_rbheap_page *big_enough = NULL; + rtems_rbheap_chunk *big_enough = NULL; while (current != tail && big_enough == NULL) { - rtems_rbheap_page *free_page = (rtems_rbheap_page *) current; + rtems_rbheap_chunk *free_chunk = (rtems_rbheap_chunk *) current; - if (free_page->size >= size) { - big_enough = free_page; + if (free_chunk->size >= size) { + big_enough = free_chunk; } current = rtems_chain_next(current); @@ -156,34 +156,34 @@ static rtems_rbheap_page *search_free_page( void *rtems_rbheap_allocate(rtems_rbheap_control *control, size_t size) { void *ptr = NULL; - rtems_chain_control *free_chain = &control->free_chain; - rtems_rbtree_control *page_tree = &control->page_tree; - uintptr_t page_alignment = control->page_alignment; - uintptr_t aligned_size = align_up(page_alignment, size); + rtems_chain_control *free_chain = &control->free_chunk_chain; + rtems_rbtree_control *chunk_tree = &control->chunk_tree; + uintptr_t alignment = control->alignment; + uintptr_t aligned_size = align_up(alignment, size); if (size > 0 && size <= aligned_size) { - rtems_rbheap_page *free_page = search_free_page(free_chain, aligned_size); + rtems_rbheap_chunk *free_chunk = search_free_chunk(free_chain, aligned_size); - if (free_page != NULL) { - uintptr_t free_size = free_page->size; + if (free_chunk != NULL) { + uintptr_t free_size = free_chunk->size; if (free_size > aligned_size) { - rtems_rbheap_page *new_page = get_page(control); + rtems_rbheap_chunk *new_chunk = get_chunk(control); - if (new_page != NULL) { + if (new_chunk != NULL) { uintptr_t new_free_size = free_size - aligned_size; - free_page->size = new_free_size; - new_page->begin = free_page->begin + new_free_size; - new_page->size = aligned_size; - rtems_chain_set_off_chain(&new_page->chain_node); - insert_into_tree(page_tree, new_page); - ptr = (void *) new_page->begin; + free_chunk->size = new_free_size; + new_chunk->begin = free_chunk->begin + new_free_size; + new_chunk->size = aligned_size; + rtems_chain_set_off_chain(&new_chunk->chain_node); + insert_into_tree(chunk_tree, new_chunk); + ptr = (void *) new_chunk->begin; } } else { - rtems_chain_extract_unprotected(&free_page->chain_node); - rtems_chain_set_off_chain(&free_page->chain_node); - ptr = (void *) free_page->begin; + rtems_chain_extract_unprotected(&free_chunk->chain_node); + rtems_chain_set_off_chain(&free_chunk->chain_node); + ptr = (void *) free_chunk->begin; } } } @@ -191,38 +191,38 @@ void *rtems_rbheap_allocate(rtems_rbheap_control *control, size_t size) return ptr; } -#define NULL_PAGE rtems_rbheap_page_of_node(NULL) +#define NULL_PAGE rtems_rbheap_chunk_of_node(NULL) -static rtems_rbheap_page *find(rtems_rbtree_control *page_tree, uintptr_t key) +static rtems_rbheap_chunk *find(rtems_rbtree_control *chunk_tree, uintptr_t key) { - rtems_rbheap_page page = { .begin = key }; + rtems_rbheap_chunk chunk = { .begin = key }; - return rtems_rbheap_page_of_node( - _RBTree_Find_unprotected(page_tree, &page.tree_node) + return rtems_rbheap_chunk_of_node( + _RBTree_Find_unprotected(chunk_tree, &chunk.tree_node) ); } -static rtems_rbheap_page *get_next( - const rtems_rbtree_control *page_tree, - const rtems_rbheap_page *page, +static rtems_rbheap_chunk *get_next( + const rtems_rbtree_control *chunk_tree, + const rtems_rbheap_chunk *chunk, RBTree_Direction dir ) { - return rtems_rbheap_page_of_node( - _RBTree_Next_unprotected(page_tree, &page->tree_node, dir) + return rtems_rbheap_chunk_of_node( + _RBTree_Next_unprotected(chunk_tree, &chunk->tree_node, dir) ); } static void check_and_merge( rtems_chain_control *free_chain, - rtems_rbtree_control *page_tree, - rtems_rbheap_page *a, - rtems_rbheap_page *b + rtems_rbtree_control *chunk_tree, + rtems_rbheap_chunk *a, + rtems_rbheap_chunk *b ) { - if (b != NULL_PAGE && rtems_rbheap_is_page_free(b)) { + if (b != NULL_PAGE && rtems_rbheap_is_chunk_free(b)) { if (b->begin < a->begin) { - rtems_rbheap_page *t = a; + rtems_rbheap_chunk *t = a; a = b; b = t; @@ -231,47 +231,48 @@ static void check_and_merge( a->size += b->size; rtems_chain_extract_unprotected(&b->chain_node); add_to_chain(free_chain, b); - _RBTree_Extract_unprotected(page_tree, &b->tree_node); + _RBTree_Extract_unprotected(chunk_tree, &b->tree_node); } } rtems_status_code rtems_rbheap_free(rtems_rbheap_control *control, void *ptr) { rtems_status_code sc = RTEMS_SUCCESSFUL; - rtems_chain_control *free_chain = &control->free_chain; - rtems_rbtree_control *page_tree = &control->page_tree; - rtems_rbheap_page *page = find(page_tree, (uintptr_t) ptr); - - if (page != NULL_PAGE) { - if (!rtems_rbheap_is_page_free(page)) { - rtems_rbheap_page *pred = get_next(page_tree, page, RBT_LEFT); - rtems_rbheap_page *succ = get_next(page_tree, page, RBT_RIGHT); - - check_and_merge(free_chain, page_tree, page, succ); - add_to_chain(free_chain, page); - check_and_merge(free_chain, page_tree, page, pred); + + if (ptr != NULL) { + rtems_chain_control *free_chain = &control->free_chunk_chain; + rtems_rbtree_control *chunk_tree = &control->chunk_tree; + rtems_rbheap_chunk *chunk = find(chunk_tree, (uintptr_t) ptr); + + if (chunk != NULL_PAGE) { + if (!rtems_rbheap_is_chunk_free(chunk)) { + rtems_rbheap_chunk *pred = get_next(chunk_tree, chunk, RBT_LEFT); + rtems_rbheap_chunk *succ = get_next(chunk_tree, chunk, RBT_RIGHT); + + check_and_merge(free_chain, chunk_tree, chunk, succ); + add_to_chain(free_chain, chunk); + check_and_merge(free_chain, chunk_tree, chunk, pred); + } else { + sc = RTEMS_INCORRECT_STATE; + } } else { - sc = RTEMS_INCORRECT_STATE; + sc = RTEMS_INVALID_ID; } - } else { - sc = RTEMS_INVALID_ID; } return sc; } -void rtems_rbheap_extend_page_pool_never(rtems_rbheap_control *control) +void rtems_rbheap_extend_descriptors_never(rtems_rbheap_control *control) { /* Do nothing */ } -void rtems_rbheap_extend_page_pool_with_malloc(rtems_rbheap_control *control) +void rtems_rbheap_extend_descriptors_with_malloc(rtems_rbheap_control *control) { - rtems_rbheap_page *page = malloc(sizeof(*page)); - - if (page != NULL) { - rtems_chain_control *pool_chain = rtems_rbheap_get_pool_chain(control); + rtems_rbheap_chunk *chunk = malloc(sizeof(*chunk)); - add_to_chain(pool_chain, page); + if (chunk != NULL) { + rtems_rbheap_add_to_spare_descriptor_chain(control, chunk); } } diff --git a/cpukit/score/cpu/lm32/rtems/score/types.h b/cpukit/score/cpu/lm32/rtems/score/types.h index a46dd75220..949f9e2d9d 100644 --- a/cpukit/score/cpu/lm32/rtems/score/types.h +++ b/cpukit/score/cpu/lm32/rtems/score/types.h @@ -37,12 +37,6 @@ extern "C" { /** This defines the type for a priority bit map entry. */ typedef uint16_t Priority_bit_map_Control; -/** This defines the return type for an ISR entry point. */ -typedef void lm32_isr; - -/** This defines the prototype for an ISR entry point. */ -typedef lm32_isr ( *lm32_isr_entry )( void ); - #ifdef __cplusplus } #endif diff --git a/cpukit/score/cpu/m68k/rtems/score/types.h b/cpukit/score/cpu/m68k/rtems/score/types.h index 0c2442566f..eb87a6c83c 100644 --- a/cpukit/score/cpu/m68k/rtems/score/types.h +++ b/cpukit/score/cpu/m68k/rtems/score/types.h @@ -32,8 +32,6 @@ extern "C" { */ typedef uint16_t Priority_bit_map_Control; -typedef void m68k_isr; -typedef void ( *m68k_isr_entry )( void ); #ifdef __cplusplus } diff --git a/cpukit/score/cpu/no_cpu/rtems/score/types.h b/cpukit/score/cpu/no_cpu/rtems/score/types.h index c1fdc6d9a4..2fb960c899 100644 --- a/cpukit/score/cpu/no_cpu/rtems/score/types.h +++ b/cpukit/score/cpu/no_cpu/rtems/score/types.h @@ -34,12 +34,6 @@ extern "C" { /** This defines the type for a priority bit map entry. */ typedef uint16_t Priority_bit_map_Control; -/** This defines the return type for an ISR entry point. */ -typedef void no_cpu_isr; - -/** This defines the prototype for an ISR entry point. */ -typedef no_cpu_isr ( *no_cpu_isr_entry )( void ); - #ifdef __cplusplus } #endif diff --git a/testsuites/libtests/rbheap01/init.c b/testsuites/libtests/rbheap01/init.c index a66cc24273..ce180d8541 100644 --- a/testsuites/libtests/rbheap01/init.c +++ b/testsuites/libtests/rbheap01/init.c @@ -27,26 +27,27 @@ static char area [PAGE_SIZE * PAGE_COUNT + PAGE_SIZE - 1]; -static rtems_rbheap_page pages [PAGE_COUNT]; +static rtems_rbheap_chunk chunks [PAGE_COUNT]; -static void extend_page_pool(rtems_rbheap_control *control) +static void extend_descriptors(rtems_rbheap_control *control) { - rtems_chain_control *pool_chain = rtems_rbheap_get_pool_chain(control); + rtems_chain_control *chain = + rtems_rbheap_get_spare_descriptor_chain(control); - rtems_rbheap_set_extend_page_pool( + rtems_rbheap_set_extend_descriptors( control, - rtems_rbheap_extend_page_pool_never + rtems_rbheap_extend_descriptors_never ); rtems_chain_initialize( - pool_chain, - pages, + chain, + chunks, PAGE_COUNT, - sizeof(pages [0]) + sizeof(chunks [0]) ); } -static uintptr_t idx(const rtems_rbheap_page *page) +static uintptr_t idx(const rtems_rbheap_chunk *chunk) { uintptr_t base = (uintptr_t) area; uintptr_t excess = base % PAGE_SIZE; @@ -55,7 +56,7 @@ static uintptr_t idx(const rtems_rbheap_page *page) base += PAGE_SIZE - excess; } - return (page->begin - base) / PAGE_SIZE; + return (chunk->begin - base) / PAGE_SIZE; } typedef struct { @@ -63,22 +64,22 @@ typedef struct { const uintptr_t *index_end; const bool *free_current; const bool *free_end; -} page_visitor_context; +} chunk_visitor_context; -static bool page_visitor( +static bool chunk_visitor( const RBTree_Node *node, RBTree_Direction dir, void *visitor_arg ) { - rtems_rbheap_page *page = rtems_rbheap_page_of_node(node); - page_visitor_context *context = visitor_arg; + rtems_rbheap_chunk *chunk = rtems_rbheap_chunk_of_node(node); + chunk_visitor_context *context = visitor_arg; rtems_test_assert(context->index_current != context->index_end); rtems_test_assert(context->free_current != context->free_end); - rtems_test_assert(idx(page) == *context->index_current); - rtems_test_assert(rtems_rbheap_is_page_free(page) == *context->free_current); + rtems_test_assert(idx(chunk) == *context->index_current); + rtems_test_assert(rtems_rbheap_is_chunk_free(chunk) == *context->free_current); ++context->index_current; ++context->free_current; @@ -86,7 +87,7 @@ static bool page_visitor( return false; } -static void test_init_page_alignment(void) +static void test_init_chunk_alignment(void) { rtems_status_code sc = RTEMS_SUCCESSFUL; rtems_rbheap_control control; @@ -96,7 +97,7 @@ static void test_init_page_alignment(void) area, sizeof(area), 0, - extend_page_pool, + extend_descriptors, NULL ); rtems_test_assert(sc == RTEMS_INVALID_NUMBER); @@ -112,7 +113,7 @@ static void test_init_begin_greater_than_end(void) (void *) PAGE_SIZE, (uintptr_t) -PAGE_SIZE, PAGE_SIZE, - extend_page_pool, + extend_descriptors, NULL ); rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); @@ -128,7 +129,7 @@ static void test_init_begin_greater_than_aligned_begin(void) (void *) -(PAGE_SIZE / 2), PAGE_SIZE, PAGE_SIZE, - extend_page_pool, + extend_descriptors, NULL ); rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); @@ -144,13 +145,13 @@ static void test_init_aligned_begin_greater_than_aligned_end(void) (void *) PAGE_SIZE, PAGE_SIZE / 2, PAGE_SIZE, - extend_page_pool, + extend_descriptors, NULL ); rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); } -static void test_init_empty_page_pool(void) +static void test_init_empty_descriptors(void) { rtems_status_code sc = RTEMS_SUCCESSFUL; rtems_rbheap_control control; @@ -160,13 +161,13 @@ static void test_init_empty_page_pool(void) (void *) PAGE_SIZE, PAGE_SIZE, PAGE_SIZE, - rtems_rbheap_extend_page_pool_never, + rtems_rbheap_extend_descriptors_never, NULL ); rtems_test_assert(sc == RTEMS_NO_MEMORY); } -static void test_page_tree( +static void test_chunk_tree( const rtems_rbheap_control *control, const uintptr_t *index_begin, const uintptr_t *index_end, @@ -174,7 +175,7 @@ static void test_page_tree( const bool *free_end ) { - page_visitor_context context = { + chunk_visitor_context context = { .index_current = index_begin, .index_end = index_end, .free_current = free_begin, @@ -182,15 +183,15 @@ static void test_page_tree( }; _RBTree_Iterate_unprotected( - &control->page_tree, + &control->chunk_tree, RBT_RIGHT, - page_visitor, + chunk_visitor, &context ); } #define TEST_PAGE_TREE(control, indices, frees) \ - test_page_tree( \ + test_chunk_tree( \ control, \ indices, \ &indices [sizeof(indices) / sizeof(indices [0])], \ @@ -214,7 +215,7 @@ static void test_init_successful(rtems_rbheap_control *control) area, sizeof(area), PAGE_SIZE, - extend_page_pool, + extend_descriptors, NULL ); rtems_test_assert(sc == RTEMS_SUCCESSFUL); @@ -276,7 +277,7 @@ static void test_alloc_zero(void) TEST_PAGE_TREE(&control, indices, frees); } -static void test_alloc_huge_page(void) +static void test_alloc_huge_chunk(void) { static const uintptr_t indices [] = { 0 @@ -296,7 +297,7 @@ static void test_alloc_huge_page(void) TEST_PAGE_TREE(&control, indices, frees); } -static void test_alloc_one_page(void) +static void test_alloc_one_chunk(void) { static const uintptr_t indices_0 [] = { 0 @@ -328,7 +329,7 @@ static void test_alloc_one_page(void) TEST_PAGE_TREE(&control, indices_1, frees_1); } -static void test_alloc_many_pages(void) +static void test_alloc_many_chunks(void) { static const uintptr_t indices_0 [] = { 0, @@ -385,7 +386,7 @@ static void test_alloc_many_pages(void) TEST_PAGE_TREE(&control, indices_1, frees_1); } -static void test_free_invalid(void) +static void test_free_null(void) { rtems_status_code sc = RTEMS_SUCCESSFUL; rtems_rbheap_control control; @@ -393,6 +394,17 @@ static void test_free_invalid(void) test_init_successful(&control); sc = rtems_rbheap_free(&control, NULL); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); +} + +static void test_free_invalid(void) +{ + rtems_status_code sc = RTEMS_SUCCESSFUL; + rtems_rbheap_control control; + + test_init_successful(&control); + + sc = rtems_rbheap_free(&control, (void *) 1); rtems_test_assert(sc == RTEMS_INVALID_ID); } @@ -539,16 +551,17 @@ static void Init(rtems_task_argument arg) { puts("\n\n*** TEST RBHEAP 1 ***"); - test_init_page_alignment(); + test_init_chunk_alignment(); test_init_begin_greater_than_end(); test_init_begin_greater_than_aligned_begin(); test_init_aligned_begin_greater_than_aligned_end(); - test_init_empty_page_pool(); + test_init_empty_descriptors(); test_alloc_and_free_one(); test_alloc_zero(); - test_alloc_huge_page(); - test_alloc_one_page(); - test_alloc_many_pages(); + test_alloc_huge_chunk(); + test_alloc_one_chunk(); + test_alloc_many_chunks(); + test_free_null(); test_free_invalid(); test_free_double(); test_free_merge_left_or_right(true); |