Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:22:42

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsAArch64XilinxZynqMP
0007  *
0008  * @brief This source file contains the implementation of zynqmp_ecc_init().
0009  */
0010 
0011 /*
0012  * Copyright (C) 2023 On-Line Applications Research Corporation (OAR)
0013  * Written by Kinsey Moore <kinsey.moore@oarcorp.com>
0014  *
0015  * Redistribution and use in source and binary forms, with or without
0016  * modification, are permitted provided that the following conditions
0017  * are met:
0018  * 1. Redistributions of source code must retain the above copyright
0019  *    notice, this list of conditions and the following disclaimer.
0020  * 2. Redistributions in binary form must reproduce the above copyright
0021  *    notice, this list of conditions and the following disclaimer in the
0022  *    documentation and/or other materials provided with the distribution.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #include <bsp.h>
0038 #include <bsp/ecc_priv.h>
0039 #include <bsp/fatal.h>
0040 #include <bsp/utility.h>
0041 
0042 zynqmp_ecc_handler saved_handler = NULL;
0043 
0044 void zynqmp_ecc_register_handler( zynqmp_ecc_handler handler )
0045 {
0046   saved_handler = handler;
0047 }
0048 
0049 void zynqmp_invoke_ecc_handler( ECC_Event_Type event, void *data )
0050 {
0051   if (saved_handler == NULL) {
0052     bsp_fatal( BSP_FATAL_MEMORY_ECC_ERROR );
0053   }
0054 
0055   saved_handler(event, data);
0056 }
0057 
0058 int zynqmp_ecc_enable( ECC_Event_Type event )
0059 {
0060   rtems_status_code sc;
0061 
0062   switch (event) {
0063   case L1_CACHE:
0064   case L2_CACHE:
0065   case L1_L2_CACHE:
0066     sc = zynqmp_configure_cache_ecc();
0067     break;
0068   case OCM_RAM:
0069     sc = zynqmp_configure_ocm_ecc();
0070     break;
0071   case DDR_RAM:
0072     sc = zynqmp_configure_ddr_ecc();
0073     break;
0074   default:
0075     return 1;
0076   }
0077 
0078   if (sc != RTEMS_SUCCESSFUL) {
0079     return 1;
0080   }
0081   return 0;
0082 }
0083 
0084 void zynqmp_ecc_init( void )
0085 {
0086   /* Do something on hardware */
0087   zynqmp_ecc_enable( L1_L2_CACHE );
0088   zynqmp_ecc_enable( OCM_RAM );
0089 
0090   /* Call BSP-specific init function */
0091   zynqmp_ecc_init_bsp();
0092 }