Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:08

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  * @ingroup RTEMSBSPsSPARCLEON2
0006  * @brief LEON2 Cache Snooping Support
0007  */
0008 
0009 /*
0010  *  LEON2 Cache Snooping Support
0011  *
0012  *  COPYRIGHT (c) 2011
0013  *  Aeroflex Gaisler
0014  *
0015  *  COPYRIGHT (c) 1989-2009.
0016  *  On-Line Applications Research Corporation (OAR).
0017  *
0018  * Redistribution and use in source and binary forms, with or without
0019  * modification, are permitted provided that the following conditions
0020  * are met:
0021  * 1. Redistributions of source code must retain the above copyright
0022  *    notice, this list of conditions and the following disclaimer.
0023  * 2. Redistributions in binary form must reproduce the above copyright
0024  *    notice, this list of conditions and the following disclaimer in the
0025  *    documentation and/or other materials provided with the distribution.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0028  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0029  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0030  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0031  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0032  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0033  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0034  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0035  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0036  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0037  * POSSIBILITY OF SUCH DAMAGE.
0038  *
0039  *  Ported to ERC32 implementation of the SPARC by On-Line Applications
0040  *  Research Corporation (OAR) under contract to the European Space
0041  *  Agency (ESA).
0042  *
0043  *  ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
0044  *  European Space Agency.
0045  */
0046 
0047 #include <bsp.h>
0048 #include <bsp/bootcard.h>
0049 #include <bsp/irq-generic.h>
0050 #include <rtems/sysinit.h>
0051 
0052 /*
0053  * Tells us if data cache snooping is available
0054  */
0055 int CPU_SPARC_HAS_SNOOPING;
0056 
0057 /*
0058  * set_snooping
0059  *
0060  * Read the data cache configuration register to determine if
0061  * bus snooping is available. This is needed for some drivers so
0062  * that they can select the most efficient copy routines.
0063  */
0064 static inline int set_snooping(void)
0065 {
0066   unsigned int tmp = *(unsigned int *)0x80000014; /* Cache control register */
0067   return ((tmp>>23) & 1); /* Data cache snooping enabled */
0068 }
0069 
0070 void bsp_start( void )
0071 {
0072   CPU_SPARC_HAS_SNOOPING = set_snooping();
0073 }
0074 
0075 /* If RTEMS_DRVMGR_STARTUP is defined extra code is added that
0076  * registers the LEON2 AMBA bus driver as root driver into the
0077  * driver manager.
0078  *
0079  * The structues here are declared weak so that the user can override
0080  * the configuration and add custom cores in the RTEMS project.
0081  */
0082 #ifdef RTEMS_DRVMGR_STARTUP
0083 #include <drvmgr/drvmgr.h>
0084 #include <drvmgr/leon2_amba_bus.h>
0085 
0086 /* All drivers included by BSP, this is overridden by the user by including
0087  * the devmgr_confdefs.h. No specifc drivers needed by BSP since IRQ/TIMER/UART
0088  * is not drvmgr drivers.
0089  */
0090 drvmgr_drv_reg_func drvmgr_drivers[] __attribute__((weak)) =
0091 {
0092   NULL /* End array with NULL */
0093 };
0094 
0095 /* Defines what cores are avilable on the bus in addition to the standard
0096  * LEON2 peripherals.
0097  */
0098 struct leon2_core leon2_amba_custom_cores[] __attribute__((weak)) =
0099 {
0100   EMPTY_LEON2_CORE
0101 };
0102 
0103 /* Configure LEON2 Root bus driver */
0104 struct leon2_bus leon2_bus_config __attribute__((weak)) =
0105 {
0106   &leon2_std_cores[0], /* The standard cores, defined by driver */
0107   &leon2_amba_custom_cores[0],   /* custom cores, defined by us */
0108   DRVMGR_TRANSLATE_ONE2ONE,
0109   DRVMGR_TRANSLATE_ONE2ONE,
0110 };
0111 
0112 /* Driver resources on LEON2 AMBA bus. Used to set options for particular
0113  * LEON2 cores, it is up to the driver to look at the configuration paramters
0114  * once started.
0115  */
0116 struct drvmgr_bus_res leon2_amba_res __attribute__((weak)) =
0117 {
0118   .next = NULL,
0119   .resource = {
0120     DRVMGR_RES_EMPTY
0121   },
0122 };
0123 #endif /* RTEMS_DRVMGR_STARTUP */
0124 
0125 /*
0126  * Called just before drivers are initialized.  Is used to initialize shared
0127  * interrupt handling.
0128  */
0129 static void leon2_pre_driver_hook( void )
0130 {
0131   /* Initialize shared interrupt handling, must be done after IRQ
0132    * controller has been found and initialized.
0133    */
0134   bsp_interrupt_initialize();
0135 
0136 #ifdef RTEMS_DRVMGR_STARTUP
0137   leon2_root_register(&leon2_bus_config, &leon2_amba_res);
0138 #endif
0139 }
0140 
0141 RTEMS_SYSINIT_ITEM(
0142   leon2_pre_driver_hook,
0143   RTEMS_SYSINIT_BSP_PRE_DRIVERS,
0144   RTEMS_SYSINIT_ORDER_MIDDLE
0145 );