Skip to content

MicroBlaze Port #53576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
aabf803
arch: microblaze: Early Boot Sequence
alpsayin Jan 18, 2023
ce9a91b
arch: microblaze: Interrupt and Exception Handling
alpsayin Jan 18, 2023
6ce1779
arch: microblaze: Support files (Minimal Board Support Package)
alpsayin Jan 27, 2023
ea18355
arch: microblaze: Thread Context Switching
alpsayin Jan 27, 2023
311b796
drivers: interrupt_controller: Xilinx AXI Interrupt Controller Driver
alpsayin Apr 21, 2023
3ef8838
drivers: timer: Xilinx AXI Timer Systick Driver
alpsayin Jan 18, 2023
e3eb57c
arch: microblaze: Thread Creation and Termination
alpsayin Jan 18, 2023
7c62171
arch: microblaze: CPU Idling/Power Management
alpsayin Jan 18, 2023
13f08c1
arch: microblaze: Fault Management
alpsayin Jan 18, 2023
24ec3d6
arch: microblaze: IRQ Offload implementation (emulated)
alpsayin Jan 18, 2023
235ec6b
arch: microblaze: Cache API implementation
alpsayin Jan 27, 2023
50ff4d1
arch: microblaze: Weak sys_arch_reboot implementation
alpsayin Jan 27, 2023
98ff2af
arch: microblaze: Toolchain: introduce MicroBlaze to build system
alpsayin Jan 18, 2023
f774ec3
arch: microblaze: Linker: add linker script and define output format
alpsayin Jan 18, 2023
e59b38a
arch: microblaze: add MicroBlaze arch headers
alpsayin Jan 27, 2023
a6a567c
include: arch: add MicroBlaze to cpu.h and arch_inlines.h
alpsayin Jan 27, 2023
d1cbfde
debug: thread_info: point MicroBlaze stack pointer to r1
alpsayin Jan 27, 2023
3e4b3f4
arch: microblaze: add MicroBlaze to arch/KConfig
alpsayin May 30, 2024
0359d19
arch: microblaze: add CMake files for building arch
alpsayin Jan 27, 2023
2f44610
dts: bindings: cpu: add MicroBlaze cpu binding
alpsayin Jan 27, 2023
e7b8154
soc: microblaze: add demo SoC with timer, interrupt_controller and uart
alpsayin Jan 18, 2023
853d4f6
boards: microblaze: add QEMU demo board with qemu hw-dtb
alpsayin Feb 20, 2023
019cc7a
script: logging/dictionary: add arch MicroBlaze
alpsayin Jan 27, 2023
4f4e122
tests: kernel: interrupt: MicroBlaze trigger_irq implementation (emul…
alpsayin Jan 27, 2023
5bf240b
tests: microblaze: test specific configuration additions for MicroBlaze
alpsayin May 30, 2024
522c5aa
zephyr-3.7 migration: deprecate z_arch_esf_t
alpsayin Oct 8, 2024
0de8037
zephyr-3.7 migration: include microblaze_asm.h only in asm files
alpsayin Oct 8, 2024
191d43a
migrate linker: CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE can be -1 now
alpsayin Oct 8, 2024
1447c5f
migrate irq_offload: fix arch_irq_offload_init undefined reference
alpsayin Oct 8, 2024
417f564
fix: secure_storage tests doesn't filter out any archs...
alpsayin Oct 8, 2024
85a1cba
fix: tickfull/tickless systimer inits are swapped
alpsayin Oct 8, 2024
c21d6c2
fix: -Wrestrict error because gcc thinks `(FILE*(1))` and `1` are the…
alpsayin Oct 8, 2024
a9a9df3
debug: start investigating missing sbrk
alpsayin Oct 8, 2024
4f0f6c9
Revert "debug: start investigating missing sbrk"
alpsayin Oct 8, 2024
9dab8d0
bodge: `sbrk` impl stolen from newlib to get minimal libc working w/ …
alpsayin Oct 8, 2024
2cc7aa2
WIP: Builds and tests pass: fixes/patches to be squashed
alpsayin Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@ config NIOS2
help
Nios II Gen 2 architecture

config MICROBLAZE
bool
select ARCH_IS_SET
select ATOMIC_OPERATIONS_C
select GEN_ISR_TABLES
select GEN_SW_ISR_TABLE
select ARCH_HAS_EXTRA_EXCEPTION_INFO
imply DYNAMIC_INTERRUPTS
imply ARCH_HAS_CUSTOM_BUSY_WAIT
help
MicroBlaze architecture

config RISCV
bool
select ARCH_IS_SET
Expand Down
2 changes: 2 additions & 0 deletions arch/archs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ archs:
path: xtensa
- name: x86
path: x86
- name: microblaze
path: microblaze
46 changes: 46 additions & 0 deletions arch/microblaze/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
# SPDX-License-Identifier: Apache-2.0


# Set output binary format
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-microblaze)

add_subdirectory(core)
zephyr_include_directories(include)

if(DEFINED CONFIG_BIG_ENDIAN)
set(extended_objdump_endianness "-EB")
else()
set(extended_objdump_endianness "-EL")
endif()

if(DEFINED CONFIG_OUTPUT_DISASSEMBLY)
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND $<TARGET_PROPERTY:bintools,disassembly_command>
${extended_objdump_endianness}
"-hSst"
${disassembly_type}
$<TARGET_PROPERTY:bintools,disassembly_flag_infile>${KERNEL_ELF_NAME}
$<TARGET_PROPERTY:bintools,disassembly_flag_outfile>extended_${KERNEL_LST_NAME}
$<TARGET_PROPERTY:bintools,disassembly_flag_final>
)
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND $<TARGET_PROPERTY:bintools,disassembly_command>
${extended_objdump_endianness}
"-hSst"
${disassembly_type}
$<TARGET_PROPERTY:bintools,disassembly_flag_infile>zephyr_pre0.elf
$<TARGET_PROPERTY:bintools,disassembly_flag_outfile>extended_zephyr_pre0.lst
$<TARGET_PROPERTY:bintools,disassembly_flag_final>
)
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND $<TARGET_PROPERTY:bintools,disassembly_command>
${extended_objdump_endianness}
"-hSst"
${disassembly_type}
$<TARGET_PROPERTY:bintools,disassembly_flag_infile>zephyr_pre1.elf
$<TARGET_PROPERTY:bintools,disassembly_flag_outfile>extended_zephyr_pre1.lst
$<TARGET_PROPERTY:bintools,disassembly_flag_final>
)
endif()
114 changes: 114 additions & 0 deletions arch/microblaze/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
# SPDX-License-Identifier: Apache-2.0


menu "MicroBlaze Options"
depends on MICROBLAZE

config ARCH
string
default "microblaze"

config CPU_MICROBLAZE
bool
default y
help
This option signifies the use of a MicroBlaze CPU

config CPU_VERSION
prompt "MicroBlaze CPU Version"
string
default "v9.00.a"
help
Use features of, and schedule code for, the given CPU.
Supported values are in the format "vX.YY.Z",
where X is a major version, YY is the minor version, and Z is compatibility code.
Example values are "v3.00.a", "v4.00.b", "v5.00.a", "v5.00.b", "v6.00.a".
Taken from https://gcc.gnu.org/onlinedocs/gcc/MicroBlaze-Options.html

config GEN_IRQ_VECTOR_TABLE
bool
default n if MICROBLAZE
help
MicroBlaze has a single interrupt and therefore doesn't have an IRQ vector table.

config BIG_ENDIAN
bool
default n if MICROBLAZE
help
Our current default endianness is Little-endian.

config ARCH_SW_ISR_TABLE_ALIGN
prompt "SW_ISR Table Align Size"
default 4

config NUM_IRQS
int
default 1
help
This isn't really a choice either because a barebones MicroBlaze offers
only 1 external interrupt pin (which is usually connected to an Xlnx Intc
or probably a single peripheral which a user wants IRQs from).

choice
prompt "Idle Sleep Option"
default MICROBLAZE_IDLE_NOP

config MICROBLAZE_IDLE_NOP
bool "NOP (no power saving)"
help
Executes pseudo-assembly instruction nop in idle.
Reset_Mode[0:1] is set to 10

config MICROBLAZE_IDLE_SLEEP
bool "Sleep"
help
Executes pseudo-assembly instruction sleep in idle.
Reset_Mode[0:1] is set to 10

config MICROBLAZE_IDLE_HIBERNATE
bool "Hibernate"
help
Executes pseudo-assembly instruction hibernate in idle.

config MICROBLAZE_IDLE_SUSPEND
bool "Suspend"
help
Executes pseudo-assembly instruction suspend in idle.
endchoice

config MICROBLAZE_DUMP_ON_EXCEPTION
bool "Dump core on exceptions"
default y

config EXTRA_EXCEPTION_INFO
bool "Extra exception debug information"
default y
help
Have exceptions print additional useful debugging information in
human-readable form, at the expense of code size. For example,
the cause code for an exception will be supplemented by a string
describing what that cause code means.

# Bump the kernel default stack size values.
config MAIN_STACK_SIZE
default 4096 if COVERAGE_GCOV
default 2048

config IDLE_STACK_SIZE
default 1024

config ISR_STACK_SIZE
default 4096

config TEST_EXTRA_STACK_SIZE
default 4096 if COVERAGE_GCOV
default 2048

config SYSTEM_WORKQUEUE_STACK_SIZE
default 4096

source "arch/microblaze/Kconfig.features"

endmenu
76 changes: 76 additions & 0 deletions arch/microblaze/Kconfig.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
# SPDX-License-Identifier: Apache-2.0


menu "HW Feature Options"
depends on MICROBLAZE

# Picolibc with C++ support in Zephyr SDK is handled by Zephyr SDK's own Kconfig.
config PICOLIBC_SUPPORTED
bool
default n
help
Microblaze doesn't have picolibc support yet

config MICROBLAZE_USE_MSR_INSTR
prompt "Use msrset & msrclr instructions"
def_bool y
help
This depends on CPU supporting msrset/msrclr instructions.
xparameters would define this as MICROBLAZE_USE_MSR_INSTR = 1.

config MICROBLAZE_USE_BARREL_SHIFT_INSTR
prompt "Use barrel shift instructions"
def_bool y
help
This depends on CPU supporting barrel shift instructions.
xparameters would define this as USE_BARREL = 1.

config MICROBLAZE_USE_PATTERN_COMPARE_INSTR
prompt "Use pattern compare instructions"
def_bool y
help
This depends on CPU supporting pattern compare instructions.
xparameters would define this as USE_PCMP = 1.

config MICROBLAZE_USE_DIV_INSTR
prompt "Use division instructions"
def_bool y
help
This depends on CPU supporting hardware division instructions.
xparameters would define this as USE_DIV = 1.

config MICROBLAZE_USE_MUL_INSTR
prompt "Use multiplication instructions"
def_bool y
help
This depends on CPU supporting hardware multiplication instructions.
xparameters would define this as USE_HW_MUL >= 1.

config MICROBLAZE_USE_MULHI_INSTR
prompt "Use mulhi for multiplication of higher bits"
def_bool y
depends on MICROBLAZE_USE_MUL_INSTR
help
Use multiply high instructions for high part of 32x32 multiply.
This depends on CPU supporting hardware high multiplication instructions.
xparameters would define this as USE_HW_MUL = 2.

config MICROBLAZE_USE_HARDWARE_FLOAT_INSTR
def_bool n
depends on CPU_HAS_FPU
help
This depends on CPU supporting hardware float instructions.
xparameters would define this as USE_FPU = 1.

config MICROBLAZE_DATA_IS_TEXT_RELATIVE
bool "Assume data & text segment distance is static"
default y
help
Assume that the displacement between the text and data segments is fixed at
static link time. This allows data to be referenced by offset from start of
text address instead of GOT (r20) since PC-relative addressing is not supported.
Injects -mpic-data-is-text-relative

endmenu
36 changes: 36 additions & 0 deletions arch/microblaze/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
# SPDX-License-Identifier: Apache-2.0


zephyr_library()

zephyr_library_sources(
cache.c
cpu_idle.c
crt0.S
exception.S
fatal.c
irq_manage.c
isr.S
emulate_isr.S
microblaze_disable_exceptions.S
microblaze_disable_dcache.S
microblaze_disable_icache.S
microblaze_disable_interrupts.S
microblaze_enable_exceptions.S
microblaze_enable_interrupts.S
microblaze_enable_dcache.S
microblaze_enable_icache.S
prep_c.c
reboot.c
reset.S
swap.S
thread.c
)

if (CONFIG_MINIMAL_LIBC)
zephyr_library_sources(sbrk.c)
endif()

zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
Loading
Loading