Skip to content
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

MicroBlaze Port #53576

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c73945
arch: microblaze: Early Boot Sequence
alpsayin Jan 18, 2023
0f34a08
arch: microblaze: Interrupt and Exception Handling
alpsayin Jan 18, 2023
3c67b1b
arch: microblaze: Support files (Minimal Board Support Package)
alpsayin Jan 27, 2023
a223896
arch: microblaze: Thread Context Switching
alpsayin Jan 27, 2023
2b150b3
drivers: interrupt_controller: Xilinx AXI Interrupt Controller Driver
alpsayin Apr 21, 2023
844b865
drivers: timer: Xilinx AXI Timer Systick Driver
alpsayin Jan 18, 2023
b72e339
arch: microblaze: Thread Creation and Termination
alpsayin Jan 18, 2023
9969562
arch: microblaze: CPU Idling/Power Management
alpsayin Jan 18, 2023
829df31
arch: microblaze: Fault Management
alpsayin Jan 18, 2023
4be73eb
arch: microblaze: IRQ Offload implementation (emulated)
alpsayin Jan 18, 2023
1f4dc80
arch: microblaze: Cache API implementation
alpsayin Jan 27, 2023
6be0d41
arch: microblaze: Weak sys_arch_reboot implementation
alpsayin Jan 27, 2023
042c51d
arch: microblaze: Toolchain: introduce MicroBlaze to build system
alpsayin Jan 18, 2023
fdbfc63
arch: microblaze: Linker: add linker script and define output format
alpsayin Jan 18, 2023
a6d6963
arch: microblaze: add MicroBlaze arch headers
alpsayin Jan 27, 2023
1285554
include: arch: add MicroBlaze to cpu.h and arch_inlines.h
alpsayin Jan 27, 2023
e8fdca5
debug: thread_info: point MicroBlaze stack pointer to r1
alpsayin Jan 27, 2023
1c1f8ba
arch: microblaze: add MicroBlaze to arch/KConfig
alpsayin May 30, 2024
c00668a
arch: microblaze: add CMake files for building arch
alpsayin Jan 27, 2023
0ba9b23
dts: bindings: cpu: add MicroBlaze cpu binding
alpsayin Jan 27, 2023
b4aba6f
soc: microblaze: add demo SoC with timer, interrupt_controller and uart
alpsayin Jan 18, 2023
0a7a5ba
boards: microblaze: add QEMU demo board with qemu hw-dtb
alpsayin Feb 20, 2023
24c331d
script: logging/dictionary: add arch MicroBlaze
alpsayin Jan 27, 2023
69da9dd
tests: kernel: interrupt: MicroBlaze trigger_irq implementation (emul…
alpsayin Jan 27, 2023
b49b9dd
tests: microblaze: test specific configuration additions for MicroBlaze
alpsayin May 30, 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 @@ -106,6 +106,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 <[email protected]>
# 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 <[email protected]>
# 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 <[email protected]>
# 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
32 changes: 32 additions & 0 deletions arch/microblaze/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
# Copyright (c) 2023 Alp Sayin <[email protected]>
# 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
)

zephyr_library_sources_ifdef(CONFIG_IRQ_OFFLOAD irq_offload.c)
Loading
Loading