summaryrefslogtreecommitdiffstats
path: root/bsps/sparc/shared
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bsps/sparc/shared/doxygen.h8
-rw-r--r--bsps/sparc/shared/drvmgr/ambapp_bus_leon2.c25
-rw-r--r--bsps/sparc/shared/drvmgr/leon2_amba_bus.c41
-rw-r--r--bsps/sparc/shared/irq/bsp_isr_handler.c45
-rw-r--r--bsps/sparc/shared/irq/irq-shared.c75
-rw-r--r--bsps/sparc/shared/pci/gr_cpci_gr740.c25
-rw-r--r--bsps/sparc/shared/pci/gr_leon4_n2x.c31
-rw-r--r--bsps/sparc/shared/pci/pci_memreg_sparc_be.c25
-rw-r--r--bsps/sparc/shared/pci/pci_memreg_sparc_le.c25
-rw-r--r--bsps/sparc/shared/start/bsp_fatal_exit.c25
-rw-r--r--bsps/sparc/shared/start/bsp_fatal_halt.c33
-rw-r--r--bsps/sparc/shared/start/bspgetworkarea.c2
-rw-r--r--bsps/sparc/shared/start/linkcmds.base2
-rw-r--r--bsps/sparc/shared/start/sparc-counter-asm.S151
-rw-r--r--bsps/sparc/shared/start/start.S60
15 files changed, 457 insertions, 116 deletions
diff --git a/bsps/sparc/shared/doxygen.h b/bsps/sparc/shared/doxygen.h
index 100a9b6c18..4ed2ae7285 100644
--- a/bsps/sparc/shared/doxygen.h
+++ b/bsps/sparc/shared/doxygen.h
@@ -1,4 +1,12 @@
/**
+ * @file
+ *
+ * @ingroup RTEMSImplDoxygen
+ *
+ * @brief This header file defines sparc-specific groups.
+ */
+
+/**
* @defgroup RTEMSBSPsSPARC SPARC
*
* @ingroup RTEMSBSPs
diff --git a/bsps/sparc/shared/drvmgr/ambapp_bus_leon2.c b/bsps/sparc/shared/drvmgr/ambapp_bus_leon2.c
index 1a60f23b22..753247d27e 100644
--- a/bsps/sparc/shared/drvmgr/ambapp_bus_leon2.c
+++ b/bsps/sparc/shared/drvmgr/ambapp_bus_leon2.c
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/* LEON2 GRLIB AMBA Plug & Play bus driver.
*
* COPYRIGHT (c) 2008.
@@ -10,9 +12,26 @@
* to work. The PnP information is used to extract IRQs and base
* register addresses.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <bsp.h>
diff --git a/bsps/sparc/shared/drvmgr/leon2_amba_bus.c b/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
index aca776c753..9b8de54adc 100644
--- a/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
+++ b/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/* LEON2 Hardcoded bus driver.
*
* COPYRIGHT (c) 2008.
@@ -11,9 +13,26 @@
* A Core is described by assigning a base register and
* IRQ0..IRQ15 using the leon2_core structure.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
@@ -354,7 +373,7 @@ int leon2_amba_int_register
DBG("Registering IRQ %d to func 0x%x arg 0x%x\n", irq, (unsigned int)isr, (unsigned int)arg);
- return BSP_shared_interrupt_register(irq, info, isr, arg);
+ return rtems_interrupt_handler_install(irq, info, RTEMS_INTERRUPT_SHARED, isr, arg);
}
int leon2_amba_int_unregister
@@ -373,7 +392,7 @@ int leon2_amba_int_unregister
DBG("Unregistering IRQ %d to func 0x%x arg 0x%x\n", irq, (unsigned int)handler, (unsigned int)arg);
- return BSP_shared_interrupt_unregister(irq, isr, arg);
+ return rtems_interrupt_handler_remove(irq, isr, arg);
}
int leon2_amba_int_clear
@@ -388,7 +407,9 @@ int leon2_amba_int_clear
if ( irq < 0 )
return -1;
- BSP_shared_interrupt_clear(irq);
+ if (rtems_interrupt_clear(irq) != RTEMS_SUCCESSFUL) {
+ return DRVMGR_FAIL;
+ }
return DRVMGR_OK;
}
@@ -405,7 +426,9 @@ int leon2_amba_int_mask
if ( irq < 0 )
return -1;
- BSP_shared_interrupt_mask(irq);
+ if (rtems_interrupt_vector_disable(irq) != RTEMS_SUCCESSFUL) {
+ return DRVMGR_FAIL;
+ }
return DRVMGR_OK;
}
@@ -422,7 +445,9 @@ int leon2_amba_int_unmask
if ( irq < 0 )
return -1;
- BSP_shared_interrupt_unmask(irq);
+ if (rtems_interrupt_vector_enable(irq) != RTEMS_SUCCESSFUL) {
+ return DRVMGR_FAIL;
+ }
return DRVMGR_OK;
}
diff --git a/bsps/sparc/shared/irq/bsp_isr_handler.c b/bsps/sparc/shared/irq/bsp_isr_handler.c
index 2616b5caae..4cd5c7be17 100644
--- a/bsps/sparc/shared/irq/bsp_isr_handler.c
+++ b/bsps/sparc/shared/irq/bsp_isr_handler.c
@@ -1,15 +1,44 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSBSPsSPARCLEON3
+ *
+ * @brief This source file contains the implementation of
+ * _SPARC_Interrupt_dispatch().
+ */
+
/*
-* COPYRIGHT (c) 2015
-* Cobham Gaisler
-*
-* The license and distribution terms for this file may be
-* found in the file LICENSE in this distribution or at
-* http://www.rtems.org/license/LICENSE.
-*
-*/
+ * COPYRIGHT (c) 2015
+ * Cobham Gaisler
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include <bsp.h>
#include <bsp/irq-generic.h>
+#include <bsp/irqimpl.h>
/*
* This function is called directly from _SPARC_Interrupt_trap() for
diff --git a/bsps/sparc/shared/irq/irq-shared.c b/bsps/sparc/shared/irq/irq-shared.c
index c815e00e40..3d73ad90e7 100644
--- a/bsps/sparc/shared/irq/irq-shared.c
+++ b/bsps/sparc/shared/irq/irq-shared.c
@@ -1,31 +1,41 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/*
-* COPYRIGHT (c) 2012-2015
-* Cobham Gaisler
-*
-* The license and distribution terms for this file may be
-* found in the file LICENSE in this distribution or at
-* http://www.rtems.org/license/LICENSE.
-*
-*/
+ * COPYRIGHT (c) 2012-2015
+ * Cobham Gaisler
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
#include <bsp.h>
#include <bsp/irq-generic.h>
+#include <rtems/score/processormaskimpl.h>
static inline int bsp_irq_cpu(int irq)
{
-#if defined(RTEMS_SMP)
- Processor_mask affinity;
-
- (void) bsp_interrupt_get_affinity((rtems_vector_number) irq, &affinity);
- return (int) _Processor_mask_Find_last_set(&affinity);
-#elif defined(LEON3)
- return _LEON3_Get_current_processor();
-#else
return 0;
-#endif
}
-#if !defined(LEON3)
bool bsp_interrupt_is_valid_vector(rtems_vector_number vector)
{
if (vector == 0) {
@@ -131,22 +141,25 @@ rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
BSP_Cpu_Mask_interrupt(vector, 0);
return RTEMS_SUCCESSFUL;
}
-#endif
-
-void BSP_shared_interrupt_mask(int irq)
-{
- BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
-}
-void BSP_shared_interrupt_unmask(int irq)
+#if defined(RTEMS_SMP)
+rtems_status_code bsp_interrupt_get_affinity(
+ rtems_vector_number vector,
+ Processor_mask *affinity
+)
{
- BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
+ (void) vector;
+ _Processor_mask_From_index( affinity, 0 );
+ return RTEMS_UNSATISFIED;
}
-void BSP_shared_interrupt_clear(int irq)
+rtems_status_code bsp_interrupt_set_affinity(
+ rtems_vector_number vector,
+ const Processor_mask *affinity
+)
{
- /* We don't have to interrupt lock here, because the register is only
- * written and self clearing
- */
- BSP_Clear_interrupt(irq);
+ (void) vector;
+ (void) affinity;
+ return RTEMS_UNSATISFIED;
}
+#endif
diff --git a/bsps/sparc/shared/pci/gr_cpci_gr740.c b/bsps/sparc/shared/pci/gr_cpci_gr740.c
index 96cb2196bf..bb5bb2db01 100644
--- a/bsps/sparc/shared/pci/gr_cpci_gr740.c
+++ b/bsps/sparc/shared/pci/gr_cpci_gr740.c
@@ -1,11 +1,30 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/* GR-CPCI-GR740 PCI Target driver.
*
* COPYRIGHT (c) 2017.
* Cobham Gaisler AB.
*
- * The license and distribution terms for this file may be
- * found in found in the file LICENSE in this distribution or at
- * http://www.rtems.com/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
* Configures the GR-CPCI-GR740 interface PCI board in peripheral
* mode. This driver provides a AMBA PnP bus by using the general part
diff --git a/bsps/sparc/shared/pci/gr_leon4_n2x.c b/bsps/sparc/shared/pci/gr_leon4_n2x.c
index af7a5d7ec3..26fa8d0d16 100644
--- a/bsps/sparc/shared/pci/gr_leon4_n2x.c
+++ b/bsps/sparc/shared/pci/gr_leon4_n2x.c
@@ -1,11 +1,32 @@
-/* GR-CPCI-LEON4-N2X (NGFP) PCI Peripheral driver
- *
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
* COPYRIGHT (c) 2013.
* Cobham Gaisler AB.
*
- * The license and distribution terms for this file may be
- * found in found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* @brief GR-CPCI-LEON4-N2X (NGFP) PCI Peripheral driver
*
* Configures the GR-CPIC-LEON4-N2X interface PCI board in peripheral
* mode. This driver provides a AMBA PnP bus by using the general part
diff --git a/bsps/sparc/shared/pci/pci_memreg_sparc_be.c b/bsps/sparc/shared/pci/pci_memreg_sparc_be.c
index 6dae9c89fe..c2a942c1bb 100644
--- a/bsps/sparc/shared/pci/pci_memreg_sparc_be.c
+++ b/bsps/sparc/shared/pci/pci_memreg_sparc_be.c
@@ -1,11 +1,30 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/* Registers-over-Memory Space - SPARC Big endian PCI bus definitions
*
* COPYRIGHT (c) 2011.
* Cobham Gaisler AB.
*
- * The license and distribution terms for this file may be
- * found in found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <pci.h>
diff --git a/bsps/sparc/shared/pci/pci_memreg_sparc_le.c b/bsps/sparc/shared/pci/pci_memreg_sparc_le.c
index bc95811f24..4f572c9d19 100644
--- a/bsps/sparc/shared/pci/pci_memreg_sparc_le.c
+++ b/bsps/sparc/shared/pci/pci_memreg_sparc_le.c
@@ -1,11 +1,30 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/* Registers-over-Memory Space - SPARC Little endian PCI bus definitions
*
* COPYRIGHT (c) 2011.
* Cobham Gaisler AB.
*
- * The license and distribution terms for this file may be
- * found in found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
diff --git a/bsps/sparc/shared/start/bsp_fatal_exit.c b/bsps/sparc/shared/start/bsp_fatal_exit.c
index 2ad11846e5..d2ecfb1b7a 100644
--- a/bsps/sparc/shared/start/bsp_fatal_exit.c
+++ b/bsps/sparc/shared/start/bsp_fatal_exit.c
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* @file
* @ingroup RTEMSBSPsSPARCShared
@@ -8,9 +10,26 @@
* COPYRIGHT (c) 2014.
* Aeroflex Gaisler AB.
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <bsp.h>
diff --git a/bsps/sparc/shared/start/bsp_fatal_halt.c b/bsps/sparc/shared/start/bsp_fatal_halt.c
deleted file mode 100644
index f53275a073..0000000000
--- a/bsps/sparc/shared/start/bsp_fatal_halt.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * @file
- * @ingroup RTEMSBSPsSPARCShared
- * @brief ERC32/LEON2 BSP Fatal_halt handler.
- *
- * COPYRIGHT (c) 2014.
- * Aeroflex Gaisler AB.
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#include <bsp.h>
-#include <rtems/score/cpuimpl.h>
-
-void _CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error )
-{
-#ifdef BSP_POWER_DOWN_AT_FATAL_HALT
- /* Spin CPU on fatal error exit */
- uint32_t level = sparc_disable_interrupts();
-
- __asm__ volatile ( "mov %0, %%g1 " : "=r" (level) : "0" (level) );
-
- while (1) ; /* loop forever */
-#else
- /*
- * Return to debugger, simulator, hypervisor or similar by exiting
- * with an error code. g1=1, g2=FATAL_SOURCE, G3=error-code.
- */
- sparc_syscall_exit(source, error);
-#endif
-}
diff --git a/bsps/sparc/shared/start/bspgetworkarea.c b/bsps/sparc/shared/start/bspgetworkarea.c
index 6ceda38c07..f30d6e186c 100644
--- a/bsps/sparc/shared/start/bspgetworkarea.c
+++ b/bsps/sparc/shared/start/bspgetworkarea.c
@@ -9,7 +9,7 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (C) 2019, 2021 embedded brains GmbH
+ * Copyright (C) 2019, 2021 embedded brains GmbH & Co. KG
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/bsps/sparc/shared/start/linkcmds.base b/bsps/sparc/shared/start/linkcmds.base
index ed7ab38b37..b278c78a46 100644
--- a/bsps/sparc/shared/start/linkcmds.base
+++ b/bsps/sparc/shared/start/linkcmds.base
@@ -155,7 +155,7 @@ SECTIONS
*(.rela.rtemsrwset*)
} >ram
.noinit (NOLOAD) : {
- *(.noinit*)
+ *(SORT_BY_NAME (SORT_BY_ALIGNMENT (.noinit*)))
} > ram
.rtemsstack (NOLOAD) : {
*(SORT(.rtemsstack.*))
diff --git a/bsps/sparc/shared/start/sparc-counter-asm.S b/bsps/sparc/shared/start/sparc-counter-asm.S
new file mode 100644
index 0000000000..590d77050d
--- /dev/null
+++ b/bsps/sparc/shared/start/sparc-counter-asm.S
@@ -0,0 +1,151 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/*
+ * Copyright (C) 2016, 2023 embedded brains GmbH & Co. KG
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/asm.h>
+
+ /*
+ * All functions except _SPARC_Counter_read_clock() in this module are
+ * sometimes called with traps disabled.
+ */
+
+ .section ".text"
+ .align 4
+
+ /*
+ * This is a workaround for:
+ * https://gcc.gnu.org/bugzilla//show_bug.cgi?id=69027
+ */
+ PUBLIC(_CPU_Counter_read)
+SYM(_CPU_Counter_read):
+ sethi %hi(_SPARC_Counter + 4), %o1
+ ld [%o1 + %lo(_SPARC_Counter + 4)], %o1
+ or %o7, %g0, %g1
+ call %o1, 0
+ or %g1, %g0, %o7
+
+#if defined(RTEMS_PROFILING)
+ /*
+ * This is a workaround for:
+ * https://gcc.gnu.org/bugzilla//show_bug.cgi?id=69027
+ */
+ PUBLIC(_SPARC_Counter_read_ISR_disabled)
+SYM(_SPARC_Counter_read_ISR_disabled):
+ sethi %hi(_SPARC_Counter), %o1
+ ld [%o1 + %lo(_SPARC_Counter)], %o1
+ or %o7, %g0, %g1
+ call %o1, 0
+ or %g1, %g0, %o7
+#endif
+
+ PUBLIC(_SPARC_Counter_read_default)
+SYM(_SPARC_Counter_read_default):
+ sethi %hi(_SPARC_Counter + 12), %o1
+ ld [%o1 + %lo(_SPARC_Counter + 12)], %o0
+ add %o0, 1, %o0
+ st %o0, [%o1 + %lo(_SPARC_Counter + 12)]
+ jmp %o7 + 8
+ nop
+
+ /*
+ * For the corresponding C code is something like this:
+ *
+ * CPU_Counter_ticks _SPARC_Counter_read_clock_isr_disabled( void )
+ * {
+ * const SPARC_Counter *ctr;
+ * CPU_Counter_ticks ticks;
+ * CPU_Counter_ticks accumulated;
+ *
+ * ctr = &_SPARC_Counter;
+ * ticks = *ctr->counter_register;
+ * accumulated = ctr->accumulated;
+ *
+ * if ( ( *ctr->pending_register & ctr->pending_mask ) != 0 ) {
+ * ticks = *ctr->counter_register;
+ * accumulated += ctr->interval;
+ * }
+ *
+ * return accumulated - ticks;
+ * }
+ */
+ PUBLIC(_SPARC_Counter_read_clock_isr_disabled)
+SYM(_SPARC_Counter_read_clock_isr_disabled):
+ sethi %hi(_SPARC_Counter), %o5
+ or %o5, %lo(_SPARC_Counter), %o5
+ ld [%o5 + 8], %o3
+ ld [%o5 + 12], %o4
+ ld [%o5 + 16], %o2
+ ld [%o3], %o0
+ ld [%o4], %o1
+ btst %o1, %o2
+ bne .Lpending_isr_disabled
+ ld [%o5 + 20], %o4
+ jmp %o7 + 8
+ sub %o4, %o0, %o0
+.Lpending_isr_disabled:
+ ld [%o5 + 24], %o5
+ ld [%o3], %o0
+ add %o4, %o5, %o4
+ jmp %o7 + 8
+ sub %o4, %o0, %o0
+
+ /*
+ * For the corresponding C code see
+ * _SPARC_Counter_read_clock_isr_disabled() above.
+ */
+ PUBLIC(_SPARC_Counter_read_clock)
+ PUBLIC(_SPARC_Get_timecount_clock)
+SYM(_SPARC_Counter_read_clock):
+SYM(_SPARC_Get_timecount_clock):
+ sethi %hi(_SPARC_Counter), %o5
+ or %o5, %lo(_SPARC_Counter), %o5
+ ta SPARC_SWTRAP_IRQDIS
+ ld [%o5 + 8], %o3
+ ld [%o5 + 12], %o4
+ ld [%o5 + 16], %o2
+ ld [%o3], %o0
+ ld [%o4], %o1
+ btst %o1, %o2
+ bne .Lpending
+ ld [%o5 + 20], %o4
+ ta SPARC_SWTRAP_IRQEN
+#ifdef __FIX_LEON3FT_TN0018
+ /* A nop is added to work around the GRLIB-TN-0018 errata */
+ nop
+#endif
+ jmp %o7 + 8
+ sub %o4, %o0, %o0
+.Lpending:
+ ld [%o5 + 24], %o5
+ ld [%o3], %o0
+ ta SPARC_SWTRAP_IRQEN
+ add %o4, %o5, %o4
+ jmp %o7 + 8
+ sub %o4, %o0, %o0
diff --git a/bsps/sparc/shared/start/start.S b/bsps/sparc/shared/start/start.S
index 45bd145d4a..8a22f8ff74 100644
--- a/bsps/sparc/shared/start/start.S
+++ b/bsps/sparc/shared/start/start.S
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/**
* Common start code for SPARC.
*
@@ -10,9 +12,26 @@
* COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#include <rtems/asm.h>
@@ -474,17 +493,13 @@ SYM(hard_reset):
mov %sp, %fp ! set frame pointer
#if defined(START_LEON3_ENABLE_SMP)
- /* If LEON3_Boot_Cpu < 0 then assign us as boot CPU and continue. */
- set SYM(LEON3_Boot_Cpu), %l0
- ld [%l0], %l1
- tst %l1
- bneg .Lbootcpu
- nop
-
- call SYM(bsp_start_on_secondary_processor) ! does not return
- mov %g6, %o0
-.Lbootcpu:
- st %l7, [%l0]
+ /* If .Lbootcpuindex < 0 then assign us as boot CPU and continue. */
+ set SYM(.Lbootcpuindex), %l0
+ mov -1, %l1
+ casa [%l0] (10), %l1, %l7
+ cmp %l1, %l7
+ bne .Lbootsecondarycpu
+ nop
#endif
/* clear the bss */
@@ -508,4 +523,21 @@ SYM(hard_reset):
call SYM(boot_card) ! does not return
mov %g0, %o0 ! command line
+#if defined(START_LEON3_ENABLE_SMP)
+.Lbootsecondarycpu:
+ call SYM(bsp_start_on_secondary_processor) ! does not return
+ mov %g6, %o0
+
+ /*
+ * This is the index of the boot CPU. Set by the first CPU at boot to
+ * its CPU index.
+ */
+ .section .data, "aw"
+ .align 4
+ .type .Lbootcpuindex, #object
+ .size .Lbootcpuindex, 4
+.Lbootcpuindex:
+ .long -1
+#endif
+
/* end of file */