diff options
author | Alex White <alex.white@oarcorp.com> | 2021-09-30 23:57:01 -0500 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2021-10-13 14:45:37 -0500 |
commit | d03776e804e2cb190442d2a2debf297714ca8049 (patch) | |
tree | 108aba7fb973915a52c407751ce23abf77eccac6 /c/src | |
parent | bsps: Add MicroBlaze FPGA BSP (diff) | |
download | rtems-d03776e804e2cb190442d2a2debf297714ca8049.tar.bz2 |
microblaze: Rework for RTEMS 6
This reworks the existing MicroBlaze architecture port and BSP to
achieve basic functionality using the latest RTEMS APIs.
Diffstat (limited to '')
-rw-r--r-- | bsps/microblaze/include/bsp/linker-symbols.h (renamed from c/src/lib/libbsp/microblaze/shared/include/linker-symbols.h) | 8 | ||||
-rw-r--r-- | bsps/microblaze/microblaze_fpga/console/debug-io.c (renamed from c/src/lib/libbsp/microblaze/microblaze_fpga/console/console-io.c) | 60 | ||||
-rw-r--r-- | bsps/microblaze/microblaze_fpga/include/bsp.h (renamed from c/src/lib/libbsp/microblaze/microblaze_fpga/include/bsp.h) | 31 | ||||
-rw-r--r-- | bsps/microblaze/microblaze_fpga/include/tm27.h (renamed from c/src/lib/libbsp/microblaze/microblaze_fpga/include/tm27.h) | 26 | ||||
-rw-r--r-- | bsps/microblaze/microblaze_fpga/start/_exception_handler.S (renamed from c/src/lib/libbsp/microblaze/microblaze_fpga/startup/_exception_handler.S) | 14 | ||||
-rw-r--r-- | bsps/microblaze/microblaze_fpga/start/_hw_exception_handler.S (renamed from c/src/lib/libbsp/microblaze/gdbmbsim/startup/_hw_exception_handler.S) | 16 | ||||
-rw-r--r-- | bsps/microblaze/microblaze_fpga/start/_interrupt_handler.S (renamed from c/src/lib/libbsp/microblaze/microblaze_fpga/startup/_interrupt_handler.S) | 15 | ||||
-rw-r--r-- | bsps/microblaze/shared/start/start.S (renamed from c/src/lib/libbsp/microblaze/microblaze_fpga/start/start.S) | 95 | ||||
-rw-r--r-- | c/src/lib/libbsp/microblaze/microblaze_fpga/startup/sim-crtinit.S | 85 |
9 files changed, 161 insertions, 189 deletions
diff --git a/c/src/lib/libbsp/microblaze/shared/include/linker-symbols.h b/bsps/microblaze/include/bsp/linker-symbols.h index 60a5057486..da162060b5 100644 --- a/c/src/lib/libbsp/microblaze/shared/include/linker-symbols.h +++ b/bsps/microblaze/include/bsp/linker-symbols.h @@ -1,5 +1,7 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (C) 2015 Hesham Almatary + * Copyright (C) 2015 Hesham Almatary * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -7,8 +9,8 @@ * 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. + * 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 diff --git a/c/src/lib/libbsp/microblaze/microblaze_fpga/console/console-io.c b/bsps/microblaze/microblaze_fpga/console/debug-io.c index 47592967ac..e88f5468a7 100644 --- a/c/src/lib/libbsp/microblaze/microblaze_fpga/console/console-io.c +++ b/bsps/microblaze/microblaze_fpga/console/debug-io.c @@ -1,13 +1,16 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * - * @ingroup microblaze_uart + * @ingroup RTEMSBSPsMicroblaze * - * @brief Console Configuration. + * @brief MicroBlaze debug IO support */ /* - * Copyright (C) 2015 Hesham Almatary + * Copyright (C) 2015 Hesham Almatary + * Copyright (C) 2021 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -15,8 +18,8 @@ * 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. + * 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 @@ -31,44 +34,33 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include <dev/serial/uartlite_l.h> #include <rtems/bspIo.h> -#include <libchip/serial.h> - #include <bspopts.h> -#include <bsp/uart.h> -console_tbl Console_Configuration_Ports [] = { - { - .sDeviceName = "/dev/ttyS0", - .deviceType = SERIAL_CUSTOM, - .pDeviceFns = µblaze_uart_fns, - .deviceProbe = NULL, - .pDeviceFlow = NULL, - .ulCtrlPort1 = UART_BASEADDRESS, - .ulCtrlPort2 = 0, - .ulClock = 9600, - .ulIntVector = 0 - } -}; +static void output_char( char c ) +{ + if ( c == '\n' ) { + XUartLite_SendByte( BSP_MICROBLAZE_FPGA_UART_BASE, '\r' ); + } + XUartLite_SendByte( BSP_MICROBLAZE_FPGA_UART_BASE, c ); +} -#define PORT_COUNT \ - (sizeof(Console_Configuration_Ports) \ - / sizeof(Console_Configuration_Ports [0])) +static int xUartLite_RecvByte( int minor ) +{ + if ( XUartLite_IsReceiveEmpty( BSP_MICROBLAZE_FPGA_UART_BASE ) ) { + return -1; + } -unsigned long Console_Configuration_Count = PORT_COUNT; + return XUartLite_ReadReg( BSP_MICROBLAZE_FPGA_UART_BASE, XUL_RX_FIFO_OFFSET ); +} -static void output_char(char c) +static int get_char( void ) { - const console_fns *con = - Console_Configuration_Ports [Console_Port_Minor].pDeviceFns; - - if (c == '\n') { - con->deviceWritePolled((int) Console_Port_Minor, '\r'); - } - con->deviceWritePolled((int) Console_Port_Minor, c); + return xUartLite_RecvByte( 0 ); } BSP_output_char_function_type BSP_output_char = output_char; -BSP_polling_getchar_function_type BSP_poll_char = NULL; +BSP_polling_getchar_function_type BSP_poll_char = get_char; diff --git a/c/src/lib/libbsp/microblaze/microblaze_fpga/include/bsp.h b/bsps/microblaze/microblaze_fpga/include/bsp.h index cb72835571..e83e632553 100644 --- a/c/src/lib/libbsp/microblaze/microblaze_fpga/include/bsp.h +++ b/bsps/microblaze/microblaze_fpga/include/bsp.h @@ -1,5 +1,16 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSBSPsMicroblaze + * + * @brief Core BSP definitions + */ + /* - * Copyright (C) 2015 Hesham Almatary + * Copyright (C) 2015 Hesham Almatary + * Copyright (C) 2021 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -7,8 +18,8 @@ * 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. + * 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 @@ -23,26 +34,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _BSP_H -#define _BSP_H +#ifndef LIBBSP_MICROBLAZE_FPGA_BSP_H +#define LIBBSP_MICROBLAZE_FPGA_BSP_H #ifdef __cplusplus extern "C" { #endif #include <bspopts.h> +#include <bsp/default-initial-extension.h> #include <rtems.h> -#include <rtems/iosupp.h> -#include <rtems/console.h> -#include <rtems/clockdrv.h> - -/* support for simulated clock tick */ -Thread clock_driver_sim_idle_body(uintptr_t); -#define BSP_IDLE_TASK_BODY clock_driver_sim_idle_body #ifdef __cplusplus } #endif -#endif +#endif /* LIBBSP_MICROBLAZE_FPGA_BSP_H */ diff --git a/c/src/lib/libbsp/microblaze/microblaze_fpga/include/tm27.h b/bsps/microblaze/microblaze_fpga/include/tm27.h index 393990157f..f2e384b534 100644 --- a/c/src/lib/libbsp/microblaze/microblaze_fpga/include/tm27.h +++ b/bsps/microblaze/microblaze_fpga/include/tm27.h @@ -1,6 +1,15 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSBSPsMicroblaze + * + * @brief BSP tm27 header + */ + /* - * COPYRIGHT (c) 1989-2011. - * On-Line Applications Research Corporation (OAR). + * Copyright (C) 2021 On-Line Applications Research Corporation (OAR) * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -8,8 +17,8 @@ * 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. + * 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 @@ -32,17 +41,18 @@ #define __tm27_h /* - * Define the interrupt mechanism for Time Test 27 + * Time Test 27 cannot be implemented reliably because the AXI interrupt + * controller is not guaranteed to support software interrupts. */ #define MUST_WAIT_FOR_INTERRUPT 0 #define Install_tm27_vector( handler ) /* set_vector( (handler), 6, 1 ) */ -#define Cause_tm27_intr() /* XXX */ +#define Cause_tm27_intr() /* empty */ -#define Clear_tm27_intr() /* XXX */ +#define Clear_tm27_intr() /* empty */ #define Lower_tm27_intr() /* empty */ -#endif +#endif /* __tm27_h */ diff --git a/c/src/lib/libbsp/microblaze/microblaze_fpga/startup/_exception_handler.S b/bsps/microblaze/microblaze_fpga/start/_exception_handler.S index dd9fee22f6..1d96b694a7 100644 --- a/c/src/lib/libbsp/microblaze/microblaze_fpga/startup/_exception_handler.S +++ b/bsps/microblaze/microblaze_fpga/start/_exception_handler.S @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + /* Copyright (c) 2001, 2009 Xilinx, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,5 +36,17 @@ .align 2 _exception_handler: +#ifndef __rtems__ rtsd r17, 0 nop +#else /* __rtems__ */ + /* Subtract stack frame */ + addik r1, r1, -52 + + swi r5, r1, 8 + + addi r5, r0, 0xFFFF + + braid _ISR_Handler + nop +#endif /* __rtems__ */ diff --git a/c/src/lib/libbsp/microblaze/gdbmbsim/startup/_hw_exception_handler.S b/bsps/microblaze/microblaze_fpga/start/_hw_exception_handler.S index 7b54d37dda..30436a43e9 100644 --- a/c/src/lib/libbsp/microblaze/gdbmbsim/startup/_hw_exception_handler.S +++ b/bsps/microblaze/microblaze_fpga/start/_hw_exception_handler.S @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + /* Copyright (c) 2001, 2009 Xilinx, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,5 +36,17 @@ .align 2 _hw_exception_handler: - rted r17, 0 +#ifndef __rtems__ + rtsd r17, 0 + nop +#else /* __rtems__ */ + /* Subtract stack frame */ + addik r1, r1, -52 + + swi r5, r1, 8 + + addi r5, r0, 0xFFFF + + braid _ISR_Handler nop +#endif /* __rtems__ */ diff --git a/c/src/lib/libbsp/microblaze/microblaze_fpga/startup/_interrupt_handler.S b/bsps/microblaze/microblaze_fpga/start/_interrupt_handler.S index 50326c1a93..b817503922 100644 --- a/c/src/lib/libbsp/microblaze/microblaze_fpga/startup/_interrupt_handler.S +++ b/bsps/microblaze/microblaze_fpga/start/_interrupt_handler.S @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + /* Copyright (c) 2001, 2009 Xilinx, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,5 +36,18 @@ .align 2 _interrupt_handler: +#ifndef __rtems__ rtid r14, 0 nop +#else /* __rtems__ */ + /* Subtract stack frame */ + addik r1, r1, -52 + + swi r5, r1, 8 + + /* Indicate unknown interrupt source */ + addi r5, r0, 0xFF + + braid _ISR_Handler + nop +#endif /* __rtems__ */ diff --git a/c/src/lib/libbsp/microblaze/microblaze_fpga/start/start.S b/bsps/microblaze/shared/start/start.S index bb3dc3dd65..97250f9316 100644 --- a/c/src/lib/libbsp/microblaze/microblaze_fpga/start/start.S +++ b/bsps/microblaze/shared/start/start.S @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + /* Copyright (c) 2001, 2009 Xilinx, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,76 +36,79 @@ Address Vector type Label ------- ----------- ------ - # 0x00 # (-- IMM --) - # 0x04 # Reset _start1 + # 0x00 # (-- IMM --) + # 0x04 # Reset _start1 - # 0x08 # (-- IMM --) - # 0x0c # Software Exception _exception_handler + # 0x08 # (-- IMM --) + # 0x0c # Software Exception _exception_handler - # 0x10 # (-- IMM --) - # 0x14 # Hardware Interrupt _interrupt_handler + # 0x10 # (-- IMM --) + # 0x14 # Hardware Interrupt _interrupt_handler - # 0x18 # (-- IMM --) - # 0x1C # Breakpoint Exception (-- Don't Care --) + # 0x18 # (-- IMM --) + # 0x1C # Breakpoint Exception (-- Don't Care --) - # 0x20 # (-- IMM --) - # 0x24 # Hardware Exception _hw_exception_handler + # 0x20 # (-- IMM --) + # 0x24 # Hardware Exception _hw_exception_handler */ .globl _start - .section .vectors.reset, "ax" + .section .vectors.reset, "ax" .align 2 - .ent _start - .type _start, @function + .ent _start + .type _start, @function _start: - brai _start1 - .end _start + brai _start1 + .end _start - .section .vectors.sw_exception, "ax" - .align 2 + .section .vectors.sw_exception, "ax" + .align 2 _vector_sw_exception: - brai _exception_handler + brai _exception_handler - .section .vectors.interrupt, "ax" - .align 2 + .section .vectors.interrupt, "ax" + .align 2 _vector_interrupt: - brai _interrupt_handler + brai _interrupt_handler - .section .vectors.hw_exception, "ax" - .align 2 + .section .vectors.hw_exception, "ax" + .align 2 _vector_hw_exception: - brai _hw_exception_handler + brai _hw_exception_handler - .section .text - .globl _start1 - .align 2 - .ent _start1 - .type _start1, @function + .section .text + .globl _start1 + .align 2 + .ent _start1 + .type _start1, @function _start1: - //la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */ - //la r2, r0, _SDA2_BASE_ - la r1, r0, bsp_section_stack_begin-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */ + //la r13, r0, _SDA_BASE_ /* Set the Small Data Anchors and the stack pointer */ + //la r2, r0, _SDA2_BASE_ + la r1, r0, _ISR_Stack_area_end-16 /* 16 bytes (4 words are needed by crtinit for args and link reg */ - brlid r15, _crtinit /* Initialize BSS and run program */ + brlid r15, _crtinit /* Initialize BSS and run program */ nop - brlid r15, exit /* Call exit with the return value of main */ - addik r5, r3, 0 - - /* Control does not reach here */ - .end _start1 +#ifndef __rtems__ + brlid r15, exit /* Call exit with the return value of main */ + addik r5, r3, 0 +#endif /* __rtems__ */ + /* Control does not reach here */ + .end _start1 +#ifndef __rtems__ /* - _exit - Our simple _exit + _exit + Our simple _exit */ - .globl _exit - .align 2 - .ent _exit - .type _exit, @function + .globl _exit + .align 2 + .ent _exit + .type _exit, @function _exit: - bri 0 + bri 0 .end _exit +#endif /* __rtems__ */ diff --git a/c/src/lib/libbsp/microblaze/microblaze_fpga/startup/sim-crtinit.S b/c/src/lib/libbsp/microblaze/microblaze_fpga/startup/sim-crtinit.S deleted file mode 100644 index 0cefb63116..0000000000 --- a/c/src/lib/libbsp/microblaze/microblaze_fpga/startup/sim-crtinit.S +++ /dev/null @@ -1,85 +0,0 @@ -## Copyright (c) 2015, Hesham Almatary -## Copyright (c) 2001, 2009 Xilinx, Inc. All rights reserved. -## -## Redistribution and use in source and binary forms, with or without -## modification, are permitted provided that the following conditions are -## met: -## -## 1. Redistributions 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. -## -## 3. Neither the name of Xilinx nor the names of its contributors may be -## used to endorse or promote products derived from this software without -## specific prior written permission. -## -## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER 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 -## HOLDER 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. -# -# -# sim-crtinit.s -# -# Default second stage of C run-time initialization that does not peform -# BSS initialization to zero. Typical use is on a simulator. -# - - .globl _crtinit - .align 2 - .ent _crtinit - -_crtinit: - addi r1, r1, -20 /* Save Link register */ - swi r15, r1, 0 - -#ifndef __rtems__ - brlid r15, _program_init /* Initialize the program */ - nop - - brlid r15, __init /* Invoke language initialization functions */ - nop -#endif - - - /* Init .bss */ - addi r6, r0, bsp_section_bss_begin - addi r7, r0, bsp_section_bss_end - -_clear_bss_loop: - swi r0, r6, 0 - - addi r6, r6, 4 - cmpu r8, r6, r7 - bgti r8, _clear_bss_loop - - addi r6, r0, 0 /* Initialize argc = 1 and argv = NULL and envp = NULL */ - addi r7, r0, 0 - brlid r15, boot_card /* Execute the program */ - addi r5, r0, 0 - - addik r19, r3, 0 /* Save return value */ - -#ifndef __rtems__ - brlid r15, __fini /* Invoke language cleanup functions */ - nop - - brlid r15, _program_clean /* Cleanup the program */ - nop -#endif - - lw r15, r1, r0 /* Return back to CRT */ - addik r3, r19, 0 /* Restore return value */ - rtsd r15, 8 - addi r1, r1, 20 - .end _crtinit |