Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:51

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsNios2ISS
0007  *
0008  * @brief Global BSP definitions.
0009  */
0010 
0011 /*  bsp.h
0012  *
0013  *  This include file contains all board IO definitions.
0014  *
0015  *  XXX : put yours in here
0016  *
0017  *  COPYRIGHT (c) 1989-1999.
0018  *  On-Line Applications Research Corporation (OAR).
0019  *
0020  * Redistribution and use in source and binary forms, with or without
0021  * modification, are permitted provided that the following conditions
0022  * are met:
0023  * 1. Redistributions of source code must retain the above copyright
0024  *    notice, this list of conditions and the following disclaimer.
0025  * 2. Redistributions in binary form must reproduce the above copyright
0026  *    notice, this list of conditions and the following disclaimer in the
0027  *    documentation and/or other materials provided with the distribution.
0028  *
0029  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0030  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0031  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0032  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0033  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0034  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0035  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0036  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0037  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0038  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0039  * POSSIBILITY OF SUCH DAMAGE.
0040  */
0041 
0042 #ifndef LIBBSP_NIOS2_NIOS2_ISS_BSP_H
0043 #define LIBBSP_NIOS2_NIOS2_ISS_BSP_H
0044 
0045 /**
0046  * @defgroup RTEMSBSPsNios2ISS ISS
0047  *
0048  * @ingroup RTEMSBSPsNios2
0049  *
0050  * @brief ISS Board Support Package.
0051  *
0052  * @{
0053  */
0054 
0055 #include <stdint.h>
0056 #include <bspopts.h>
0057 #include <bsp/default-initial-extension.h>
0058 
0059 #include <rtems.h>
0060 
0061 #ifdef __cplusplus
0062 extern "C" {
0063 #endif
0064 
0065 /* ============================================ */
0066 
0067 /* SOPC-specific Constants */
0068 
0069 #define SYSTEM_BUS_WIDTH 32
0070 
0071 #define JTAG_UART_BASE 0x08000000
0072 #define JTAG_UART_IRQ 2
0073 
0074 #define CLOCK_BASE 0x08001000
0075 #define CLOCK_FREQ 50000000
0076 #define CLOCK_VECTOR 1
0077 
0078 #define TIMER_BASE 0x08002000
0079 #define TIMER_FREQ 50000000
0080 #define TIMER_VECTOR 3
0081 
0082 /* ============================================ */
0083 
0084 #define NIOS2_BYPASS_CACHE ((uint32_t)0x80000000ul)
0085 #define NIOS2_IO_BASE(x) ( (void*) ((uint32_t)x | NIOS2_BYPASS_CACHE ) )
0086 #define NIOS2_IENABLE(x) do{ __builtin_wrctl(3,__builtin_rdctl(3)|x);}while(0)
0087 #define NIOS2_IRQ_ENABLE(x) do {__builtin_wrctl(3,__builtin_rdctl(3)|x);} while(0)
0088 
0089 /* ============================================ */
0090 /* TODO: Put this in an external header file */
0091 
0092 #ifndef SYSTEM_BUS_WIDTH
0093 #error SYSTEM_BUS_WIDTH is undefined
0094 #endif
0095 
0096 #if SYSTEM_BUS_WIDTH != 32
0097 #error Only SYSTEM_BUS_WIDTH 32 is supported
0098 #endif
0099 
0100 typedef struct
0101 {
0102   volatile uint32_t status;
0103   volatile uint32_t control;
0104   volatile uint32_t period_lo;
0105   volatile uint32_t period_hi;
0106   volatile uint32_t snap_lo;
0107   volatile uint32_t snap_hi;
0108 }
0109 altera_avalon_timer_regs;
0110 
0111 #define ALTERA_AVALON_TIMER_STATUS_TO_MSK             (0x1)
0112 #define ALTERA_AVALON_TIMER_STATUS_TO_OFST            (0)
0113 #define ALTERA_AVALON_TIMER_STATUS_RUN_MSK            (0x2)
0114 #define ALTERA_AVALON_TIMER_STATUS_RUN_OFST           (1)
0115 
0116 #define ALTERA_AVALON_TIMER_CONTROL_ITO_MSK           (0x1)
0117 #define ALTERA_AVALON_TIMER_CONTROL_ITO_OFST          (0)
0118 #define ALTERA_AVALON_TIMER_CONTROL_CONT_MSK          (0x2)
0119 #define ALTERA_AVALON_TIMER_CONTROL_CONT_OFST         (1)
0120 #define ALTERA_AVALON_TIMER_CONTROL_START_MSK         (0x4)
0121 #define ALTERA_AVALON_TIMER_CONTROL_START_OFST        (2)
0122 #define ALTERA_AVALON_TIMER_CONTROL_STOP_MSK          (0x8)
0123 #define ALTERA_AVALON_TIMER_CONTROL_STOP_OFST         (3)
0124 
0125 typedef struct
0126 {
0127   volatile uint32_t data;
0128   volatile uint32_t control;
0129 }
0130 altera_avalon_jtag_uart_regs;
0131 
0132 #define ALTERA_AVALON_JTAG_UART_DATA_DATA_MSK             (0x000000FFu)
0133 #define ALTERA_AVALON_JTAG_UART_DATA_DATA_OFST            (0)
0134 #define ALTERA_AVALON_JTAG_UART_DATA_RVALID_MSK           (0x00008000u)
0135 #define ALTERA_AVALON_JTAG_UART_DATA_RVALID_OFST          (15)
0136 #define ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_MSK           (0xFFFF0000u)
0137 #define ALTERA_AVALON_JTAG_UART_DATA_RAVAIL_OFST          (16)
0138 
0139 #define ALTERA_AVALON_JTAG_UART_CONTROL_RE_MSK            (0x00000001u)
0140 #define ALTERA_AVALON_JTAG_UART_CONTROL_RE_OFST           (0)
0141 #define ALTERA_AVALON_JTAG_UART_CONTROL_WE_MSK            (0x00000002u)
0142 #define ALTERA_AVALON_JTAG_UART_CONTROL_WE_OFST           (1)
0143 #define ALTERA_AVALON_JTAG_UART_CONTROL_RI_MSK            (0x00000100u)
0144 #define ALTERA_AVALON_JTAG_UART_CONTROL_RI_OFST           (8)
0145 #define ALTERA_AVALON_JTAG_UART_CONTROL_WI_MSK            (0x00000200u)
0146 #define ALTERA_AVALON_JTAG_UART_CONTROL_WI_OFST           (9)
0147 #define ALTERA_AVALON_JTAG_UART_CONTROL_AC_MSK            (0x00000400u)
0148 #define ALTERA_AVALON_JTAG_UART_CONTROL_AC_OFST           (10)
0149 #define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_MSK        (0xFFFF0000u)
0150 #define ALTERA_AVALON_JTAG_UART_CONTROL_WSPACE_OFST       (16)
0151 
0152 /* ============================================ */
0153 
0154 /* functions */
0155 
0156 rtems_isr_entry set_vector(                     /* returns old vector */
0157   rtems_isr_entry     handler,                  /* isr routine        */
0158   rtems_vector_number vector,                   /* vector number      */
0159   int                 type                      /* RTEMS or RAW intr  */
0160 );
0161 
0162 #ifdef __cplusplus
0163 }
0164 #endif
0165 
0166 /** @} */
0167 
0168 #endif
0169 /* end of include file */