diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-15 12:47:30 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-12-22 16:09:46 +0100 |
commit | 1a24b524c2b9c49695a043c8b973ffcee8be47e4 (patch) | |
tree | 6937361bed8c101fbe64b7db9bd66dab3d3ac777 | |
parent | f1794092ba4d85f26db62e8f242c6fab525e69b4 (diff) |
bsps/sparc/include/dev/grlib/io.h
-rw-r--r-- | bsps/sparc/include/grlib/io.h | 226 | ||||
-rw-r--r-- | spec/build/testsuites/validation/objgrlib.yml | 14 | ||||
-rw-r--r-- | spec/build/testsuites/validation/validation-dev-0.yml | 23 | ||||
-rw-r--r-- | testsuites/validation/tc-bsp-sparc-leon3.c | 248 | ||||
-rw-r--r-- | testsuites/validation/ts-validation-dev-0.c | 73 |
5 files changed, 584 insertions, 0 deletions
diff --git a/bsps/sparc/include/grlib/io.h b/bsps/sparc/include/grlib/io.h new file mode 100644 index 0000000000..4f0b56178f --- /dev/null +++ b/bsps/sparc/include/grlib/io.h @@ -0,0 +1,226 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief This header file defines the register load/store interface. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +/* Generated from spec:/bsp/sparc/if/grlib-io-header */ + +#ifndef _GRLIB_IO_H +#define _GRLIB_IO_H + +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/* Generated from spec:/bsp/sparc/if/grlib-io-group */ + +/** + * @defgroup RTEMSDeviceGRLIBIO Register Load/Store + * + * @ingroup RTEMSDeviceGRLIB + * + * @brief This group contains the GRLIB register load/store API. + */ + +/* Generated from spec:/bsp/sparc/if/grlib-load-08 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Loads the memory-mapped unsigned 8-bit register. + * + * @param address is the address of the memory-mapped unsigned 8-bit register + * to load. + * + * @return Returns the loaded register value. + */ +static inline uint8_t grlib_load_8( const volatile uint8_t *address ) +{ + uint8_t value; + + __asm__ volatile ( "ldub [%1], %0" : "=&r" ( value ) : "r" ( address ) ); + + return value; +} + +/* Generated from spec:/bsp/sparc/if/grlib-load-16 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Loads the memory-mapped unsigned 16-bit register. + * + * @param address is the address of the memory-mapped unsigned 16-bit register + * to load. + * + * @return Returns the loaded register value. + */ +static inline uint16_t grlib_load_16( const volatile uint16_t *address ) +{ + uint16_t value; + + __asm__ volatile ( "lduh [%1], %0" : "=&r" ( value ) : "r" ( address ) ); + + return value; +} + +/* Generated from spec:/bsp/sparc/if/grlib-load-32 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Loads the memory-mapped unsigned 32-bit register. + * + * @param address is the address of the memory-mapped unsigned 32-bit register + * to load. + * + * @return Returns the loaded register value. + */ +static inline uint32_t grlib_load_32( const volatile uint32_t *address ) +{ + uint32_t value; + + __asm__ volatile ( "ld [%1], %0" : "=&r" ( value ) : "r" ( address ) ); + + return value; +} + +/* Generated from spec:/bsp/sparc/if/grlib-load-64 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Loads the memory-mapped unsigned 64-bit register. + * + * @param address is the address of the memory-mapped unsigned 64-bit register + * to load. + * + * @return Returns the loaded register value. + */ +static inline uint64_t grlib_load_64( const volatile uint64_t *address ) +{ + uint64_t value; + + __asm__ volatile ( "ldd [%1], %0" : "=&U" ( value ) : "r" ( address ) ); + + return value; +} + +/* Generated from spec:/bsp/sparc/if/grlib-store-08 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Stores the value to the memory-mapped unsigned 8-bit register. + * + * @param address is the address of the memory-mapped unsigned 8-bit register. + * + * @param value is the value to store. + */ +static inline void grlib_store_8( volatile uint8_t *address, uint8_t value ) +{ + __asm__ volatile ( "stb %0, [%1]" : : "r" ( value ), "r" ( address ) ); +} + +/* Generated from spec:/bsp/sparc/if/grlib-store-16 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Stores the value to the memory-mapped unsigned 16-bit register. + * + * @param address is the address of the memory-mapped unsigned 16-bit register. + * + * @param value is the value to store. + */ +static inline void grlib_store_16( volatile uint16_t *address, uint16_t value ) +{ + __asm__ volatile ( "sth %0, [%1]" : : "r" ( value ), "r" ( address ) ); +} + +/* Generated from spec:/bsp/sparc/if/grlib-store-32 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Stores the value to the memory-mapped unsigned 32-bit register. + * + * @param address is the address of the memory-mapped unsigned 32-bit register. + * + * @param value is the value to store. + */ +static inline void grlib_store_32( volatile uint32_t *address, uint32_t value ) +{ + __asm__ volatile ( "st %0, [%1]" : : "r" ( value ), "r" ( address ) ); +} + +/* Generated from spec:/bsp/sparc/if/grlib-store-64 */ + +/** + * @ingroup RTEMSDeviceGRLIBIO + * + * @brief Stores the value to the memory-mapped unsigned 64-bit register. + * + * @param address is the address of the memory-mapped unsigned 64-bit register. + * + * @param value is the value to store. + */ +static inline void grlib_store_64( volatile uint64_t *address, uint64_t value ) +{ + __asm__ volatile ( "std %0, [%1]" : : "U" ( value ), "r" ( address ) ); +} + +#ifdef __cplusplus +} +#endif + +#endif /* _GRLIB_IO_H */ diff --git a/spec/build/testsuites/validation/objgrlib.yml b/spec/build/testsuites/validation/objgrlib.yml new file mode 100644 index 0000000000..bf6ac3e4d4 --- /dev/null +++ b/spec/build/testsuites/validation/objgrlib.yml @@ -0,0 +1,14 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: objects +cflags: [] +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +cppflags: [] +cxxflags: [] +enabled-by: sparc/leon3 +includes: [] +install: [] +links: [] +source: +- testsuites/validation/tc-bsp-sparc-leon3.c +type: build diff --git a/spec/build/testsuites/validation/validation-dev-0.yml b/spec/build/testsuites/validation/validation-dev-0.yml new file mode 100644 index 0000000000..1c7945e774 --- /dev/null +++ b/spec/build/testsuites/validation/validation-dev-0.yml @@ -0,0 +1,23 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +build-type: test-program +cflags: [] +copyrights: +- Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) +cppflags: [] +cxxflags: [] +enabled-by: true +features: c cprogram +includes: [] +ldflags: +- -Wl,--wrap=_IO_Relax +links: +- role: build-dependency + uid: objgrlib +source: +- testsuites/validation/ts-validation-dev-0.c +stlib: [] +target: testsuites/validation/ts-validation-dev-0.exe +type: build +use-after: +- validation +use-before: [] diff --git a/testsuites/validation/tc-bsp-sparc-leon3.c b/testsuites/validation/tc-bsp-sparc-leon3.c new file mode 100644 index 0000000000..8eb3fc1e95 --- /dev/null +++ b/testsuites/validation/tc-bsp-sparc-leon3.c @@ -0,0 +1,248 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestCaseBspSparcValGrlibIo + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <dev/grlib/io.h> + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestCaseBspSparcValGrlibIo spec:/bsp/sparc/val/grlib-io + * + * @ingroup RTEMSTestSuiteTestsuitesValidationDev0 + * + * @brief Tests the SPARC-specific GRLIB API. + * + * This test case performs the following actions: + * + * - Call grlib_load_8() to load a prepared value. + * + * - Check that the returned value is equal to the prepared value. + * + * - Call grlib_load_16() to load a prepared value. + * + * - Check that the returned value is equal to the prepared value. + * + * - Call grlib_load_32() to load a prepared value. + * + * - Check that the returned value is equal to the prepared value. + * + * - Call grlib_load_64() to load a prepared value. + * + * - Check that the returned value is equal to the prepared value. + * + * - Call grlib_store_8() to store a value to an object. + * + * - Check that the value of the object is equal to the stored value. + * + * - Call grlib_store_16() to store a value to an object. + * + * - Check that the value of the object is equal to the stored value. + * + * - Call grlib_store_32() to store a value to an object. + * + * - Check that the value of the object is equal to the stored value. + * + * - Call grlib_store_64() to store a value to an object. + * + * - Check that the value of the object is equal to the stored value. + * + * @{ + */ + +/** + * @brief Call grlib_load_8() to load a prepared value. + */ +static void BspSparcValGrlibIo_Action_0( void ) +{ + uint8_t reg_8; + uint8_t val_8; + + reg_8 = 0x81; + val_8 = grlib_load_8( ®_8 ); + + /* + * Check that the returned value is equal to the prepared value. + */ + T_step_eq_u8( 0, val_8, 0x81 ); +} + +/** + * @brief Call grlib_load_16() to load a prepared value. + */ +static void BspSparcValGrlibIo_Action_1( void ) +{ + uint16_t reg_16; + uint16_t val_16; + + reg_16 = 0x8001; + val_16 = grlib_load_16( ®_16 ); + + /* + * Check that the returned value is equal to the prepared value. + */ + T_step_eq_u16( 1, val_16, 0x8001 ); +} + +/** + * @brief Call grlib_load_32() to load a prepared value. + */ +static void BspSparcValGrlibIo_Action_2( void ) +{ + uint32_t reg_32; + uint32_t val_32; + + reg_32 = 0x80000001; + val_32 = grlib_load_32( ®_32 ); + + /* + * Check that the returned value is equal to the prepared value. + */ + T_step_eq_u32( 2, val_32, 0x80000001 ); +} + +/** + * @brief Call grlib_load_64() to load a prepared value. + */ +static void BspSparcValGrlibIo_Action_3( void ) +{ + uint64_t reg_64; + uint64_t val_64; + + reg_64 = 0x8000000000000001; + val_64 = grlib_load_64( ®_64 ); + + /* + * Check that the returned value is equal to the prepared value. + */ + T_step_eq_u64( 3, val_64, 0x8000000000000001 ); +} + +/** + * @brief Call grlib_store_8() to store a value to an object. + */ +static void BspSparcValGrlibIo_Action_4( void ) +{ + uint8_t reg_8; + + grlib_store_8( ®_8, 0x81 ); + + /* + * Check that the value of the object is equal to the stored value. + */ + T_step_eq_u8( 4, reg_8, 0x81 ); +} + +/** + * @brief Call grlib_store_16() to store a value to an object. + */ +static void BspSparcValGrlibIo_Action_5( void ) +{ + uint16_t reg_16; + + grlib_store_16( ®_16, 0x8001 ); + + /* + * Check that the value of the object is equal to the stored value. + */ + T_step_eq_u16( 5, reg_16, 0x8001 ); +} + +/** + * @brief Call grlib_store_32() to store a value to an object. + */ +static void BspSparcValGrlibIo_Action_6( void ) +{ + uint32_t reg_32; + + grlib_store_32( ®_32, 0x80000001 ); + + /* + * Check that the value of the object is equal to the stored value. + */ + T_step_eq_u32( 6, reg_32, 0x80000001 ); +} + +/** + * @brief Call grlib_store_64() to store a value to an object. + */ +static void BspSparcValGrlibIo_Action_7( void ) +{ + uint64_t reg_64; + + grlib_store_64( ®_64, 0x8000000000000001 ); + + /* + * Check that the value of the object is equal to the stored value. + */ + T_step_eq_u64( 7, reg_64, 0x8000000000000001 ); +} + +/** + * @fn void T_case_body_BspSparcValGrlibIo( void ) + */ +T_TEST_CASE( BspSparcValGrlibIo ) +{ + T_plan( 8 ); + + BspSparcValGrlibIo_Action_0(); + BspSparcValGrlibIo_Action_1(); + BspSparcValGrlibIo_Action_2(); + BspSparcValGrlibIo_Action_3(); + BspSparcValGrlibIo_Action_4(); + BspSparcValGrlibIo_Action_5(); + BspSparcValGrlibIo_Action_6(); + BspSparcValGrlibIo_Action_7(); +} + +/** @} */ diff --git a/testsuites/validation/ts-validation-dev-0.c b/testsuites/validation/ts-validation-dev-0.c new file mode 100644 index 0000000000..0a68d21030 --- /dev/null +++ b/testsuites/validation/ts-validation-dev-0.c @@ -0,0 +1,73 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTestSuiteTestsuitesValidationDev0 + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * 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. + */ + +/* + * This file is part of the RTEMS quality process and was automatically + * generated. If you find something that needs to be fixed or + * worded better please post a report or patch to an RTEMS mailing list + * or raise a bug report: + * + * https://www.rtems.org/bugs.html + * + * For information on updating and regenerating please refer to the How-To + * section in the Software Requirements Engineering chapter of the + * RTEMS Software Engineering manual. The manual is provided as a part of + * a release. For development sources please refer to the online + * documentation at: + * + * https://docs.rtems.org + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/test.h> + +/** + * @defgroup RTEMSTestSuiteTestsuitesValidationDev0 \ + * spec:/testsuites/validation-dev-0 + * + * @ingroup RTEMSTestSuites + * + * @brief This general purpose validation test suite provides enough resources + * to run target-specific tests. + * + * @{ + */ + +const char rtems_test_name[] = "ValidationDev0"; + +#include "ts-default.h" + +/** @} */ |