Skip to content

A couple of updates to prepare the support of GNAT FSF 15 #445

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

Merged
merged 3 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion arch/ARM/cortex_m/src/semihosting-filesystem.adb
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ package body Semihosting.Filesystem is
function Flush
(This : in out SHFS_File_Handle)
return Status_Code
is (OK);
is
pragma Unreferenced (This);
begin
return OK;
end Flush;

end Semihosting.Filesystem;
1 change: 0 additions & 1 deletion arch/RISC-V/SiFive/drivers/fe310-time.adb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
-- --
------------------------------------------------------------------------------

with FE310; use FE310;
with FE310.CLINT; use FE310.CLINT;

package body FE310.Time is
Expand Down
23 changes: 16 additions & 7 deletions arch/RISC-V/src/riscv-csr_generic.adb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@ with System.Machine_Code; use System.Machine_Code;

package body RISCV.CSR_Generic is

NL : constant String := ASCII.CR & ASCII.LF;

--------------
-- Read_CSR --
--------------

function Read_CSR return Reg_Type is
Ret : Reg_Type;
begin
Asm ("csrr %0, " & Reg_Name,
Asm (".option arch, +zicsr" & NL &
"csrr %0, " & Reg_Name,
Outputs => Reg_Type'Asm_Output ("=r", Ret),
Volatile => True);
return Ret;
Expand All @@ -52,7 +55,8 @@ package body RISCV.CSR_Generic is

procedure Write_CSR (Val : Reg_Type) is
begin
Asm ("csrw " & Reg_Name & ", %0",
Asm (".option arch, +zicsr" & NL &
"csrw " & Reg_Name & ", %0",
Inputs => Reg_Type'Asm_Input ("r", Val),
Volatile => True);
end Write_CSR;
Expand All @@ -64,7 +68,8 @@ package body RISCV.CSR_Generic is
function Swap_CSR (Val : Reg_Type) return Reg_Type is
Ret : Reg_Type;
begin
Asm ("csrrw %1, " & Reg_Name & ", %0",
Asm (".option arch, +zicsr" & NL &
"csrrw %1, " & Reg_Name & ", %0",
Inputs => Reg_Type'Asm_Input ("r", Val),
Outputs => Reg_Type'Asm_Output ("=r", Ret),
Volatile => True);
Expand All @@ -77,7 +82,8 @@ package body RISCV.CSR_Generic is

procedure Set_Bits_CSR (Val : Reg_Type) is
begin
Asm ("csrs " & Reg_Name & ", %0",
Asm (".option arch, +zicsr" & NL &
"csrs " & Reg_Name & ", %0",
Inputs => Reg_Type'Asm_Input ("r", Val),
Volatile => True);
end Set_Bits_CSR;
Expand All @@ -89,7 +95,8 @@ package body RISCV.CSR_Generic is
function Read_And_Set_Bits_CSR (Val : Reg_Type) return Reg_Type is
Ret : Reg_Type;
begin
Asm ("csrrs %1, " & Reg_Name & ", %0",
Asm (".option arch, +zicsr" & NL &
"csrrs %1, " & Reg_Name & ", %0",
Inputs => Reg_Type'Asm_Input ("r", Val),
Outputs => Reg_Type'Asm_Output ("=r", Ret),
Volatile => True);
Expand All @@ -102,7 +109,8 @@ package body RISCV.CSR_Generic is

procedure Clear_Bits_CSR (Val : Reg_Type) is
begin
Asm ("csrc " & Reg_Name & ", %0",
Asm (".option arch, +zicsr" & NL &
"csrc " & Reg_Name & ", %0",
Inputs => Reg_Type'Asm_Input ("r", Val),
Volatile => True);
end Clear_Bits_CSR;
Expand All @@ -114,7 +122,8 @@ package body RISCV.CSR_Generic is
function Read_And_Clear_Bits_CSR (Val : Reg_Type) return Reg_Type is
Ret : Reg_Type;
begin
Asm ("csrrc %1, " & Reg_Name & ", %0",
Asm (".option arch, +zicsr" & NL &
"csrrc %1, " & Reg_Name & ", %0",
Inputs => Reg_Type'Asm_Input ("r", Val),
Outputs => Reg_Type'Asm_Output ("=r", Ret),
Volatile => True);
Expand Down
2 changes: 1 addition & 1 deletion boards/HiFive1/hifive1_zfp.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ library project HiFive1_ZFP is
Build_Checks : Build_Checks_Type := external ("ADL_BUILD_CHECKS", "Disabled");

-- Target architecture
for Target use "riscv32-elf";
for Target use "riscv64-elf";
Target := Project'Target;

-- Callgraph info is not available on all architectures
Expand Down
4 changes: 2 additions & 2 deletions boards/HiFive1_rev_B/hifive1_rev_b_zfp.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ library project HiFive1_rev_B_ZFP is
Build_Checks : Build_Checks_Type := external ("ADL_BUILD_CHECKS", "Disabled");

-- Target architecture
for Target use "riscv32-elf";
for Target use "riscv64-elf";
Target := Project'Target;

-- Callgraph info is not available on all architectures
Callgraph_Switch := ();
case Target is
when "riscv32-unknown-elf" => null;
when "riscv64-elf" => null;
when others => Callgraph_Switch := ("-fcallgraph-info=su");
end case;

Expand Down
4 changes: 2 additions & 2 deletions boards/Unleashed/unleashed_full.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ library project Unleashed_Full is
Build_Checks : Build_Checks_Type := external ("ADL_BUILD_CHECKS", "Disabled");

-- Target architecture
for Target use "riscv32-elf";
for Target use "riscv64-elf";
Target := Project'Target;

-- Callgraph info is not available on all architectures
Callgraph_Switch := ();
case Target is
when "riscv32-unknown-elf" => null;
when "riscv64-elf" => null;
when others => Callgraph_Switch := ("-fcallgraph-info=su");
end case;

Expand Down
4 changes: 2 additions & 2 deletions boards/Unleashed/unleashed_sfp.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ library project Unleashed_SFP is
Build_Checks : Build_Checks_Type := external ("ADL_BUILD_CHECKS", "Disabled");

-- Target architecture
for Target use "riscv32-elf";
for Target use "riscv64-elf";
Target := Project'Target;

-- Callgraph info is not available on all architectures
Callgraph_Switch := ();
case Target is
when "riscv32-unknown-elf" => null;
when "riscv64-elf" => null;
when others => Callgraph_Switch := ("-fcallgraph-info=su");
end case;

Expand Down
4 changes: 2 additions & 2 deletions boards/Unleashed/unleashed_zfp.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ library project Unleashed_ZFP is
Build_Checks : Build_Checks_Type := external ("ADL_BUILD_CHECKS", "Disabled");

-- Target architecture
for Target use "riscv32-elf";
for Target use "riscv64-elf";
Target := Project'Target;

-- Callgraph info is not available on all architectures
Callgraph_Switch := ();
case Target is
when "riscv32-unknown-elf" => null;
when "riscv64-elf" => null;
when others => Callgraph_Switch := ("-fcallgraph-info=su");
end case;

Expand Down
2 changes: 1 addition & 1 deletion examples/HiFive1/hifive1_example.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with "../../boards/HiFive1/hifive1_zfp.gpr";
project HiFive1_Example is

for Runtime ("ada") use HiFive1_ZFP'Runtime ("Ada");
for Target use "riscv32-elf";
for Target use "riscv64-elf";
for Main use ("main.adb");
for Languages use ("Ada");
for Source_Dirs use ("src");
Expand Down
2 changes: 1 addition & 1 deletion examples/HiFive1_rev_B/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This will create a folder named `obj` in the same directory with the elf-formate
binary plus some auxiliary files. Inside this folder run the following command
to create the `hex` file:

`$ riscv32-elf-objcopy -O ihex main main.hex`
`$ riscv64-elf-objcopy -O ihex main main.hex`

This new revision of the HiFive board allows the `hex` file to be uploaded
through the USB connection that should appear in your file manager. Just copy
Expand Down
2 changes: 1 addition & 1 deletion examples/HiFive1_rev_B/hifive1_rev_B_example.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with "../../boards/HiFive1_rev_B/hifive1_rev_b_zfp.gpr";
project HiFive1_rev_B_Example is

for Runtime ("ada") use HiFive1_rev_B_ZFP'Runtime ("Ada");
for Target use "riscv32-elf";
for Target use "riscv64-elf";
for Main use ("main.adb");
for Languages use ("Ada");
for Source_Dirs use ("src");
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_all_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def gprbuild(project_file, debug=False):
]

# Check if RISC-V32 compiler is available
if distutils.spawn.find_executable("riscv32-elf-gnatls"):
if distutils.spawn.find_executable("riscv64-elf-gnatls"):

# Add RISC-V32 projects
projects += ["/examples/HiFive1/hifive1_example.gpr"]
Expand Down
2 changes: 1 addition & 1 deletion scripts/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def target(self):
if arch == "ARM":
target = "arm-eabi"
elif arch == "RISC-V":
target = "riscv32-elf"
target = "riscv64-elf"

return target

Expand Down
Loading