Skip to content
Open
Changes from 1 commit
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
24 changes: 23 additions & 1 deletion src/descriptors-device.adb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,27 @@ package body Descriptors.Device is
Output_Dir : String);
-- Dump the IRQ names and trap handlers

-----------------
-- MCU_To_CPU --
-----------------

function MCU_To_CPU
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would need to declare the function first, at the beginning of the package. I'm a bit surprised this didn't raise a compilation error. I'll check the project file to make sure this rule is checked by gnat.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can put in place an automatic validation of the pull request with Travis-CI.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also can confirm that the project builds and executes successfully even without the declaration.

(Device : Device_T) return Unbounded_String
is
Descrition_String : constant String := To_String (Device.Short_Desc);
CPU : Unbounded_String;
begin
if Starts_With (S1 => Descrition_String, S2 => "STM32F0") then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is very useful, but I'm a bit uncomfortable with it: the element is supposed to be there for this purpose, while here we skip it entirely. So this makes svd2ada very dependant on ST-generated SVD files (and they don't seem to generate this optional information, while they should), while other vendors do and so we should first check if the information is present there.

Basically, I'm not refusing such consideration, it's only that to be fair, the SVD standard already provides means to provide this information, and having such routine that is ST-specific there without the more generic handling implemented first seems unfair, and risky (if ST decides at some point to fill the gaps).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that's cause for concern.

CPU := To_Unbounded_String ("cortex-m0");
elsif Starts_With (S1 => Descrition_String, S2 => "Cortex-M1") then
CPU := To_Unbounded_String ("cortex-m1");
else
CPU := To_Unbounded_String ("cortex-m4");
end if;

return CPU;
end MCU_To_CPU;

-----------------
-- Read_Device --
-----------------
Expand Down Expand Up @@ -209,7 +230,8 @@ package body Descriptors.Device is
New_Line (ASM);
Put_Line (ASM, ASCII.HT & ".syntax unified");
-- ??? target is m4/m7, but what about previous versions?
Put_Line (ASM, ASCII.HT & ".cpu cortex-m4");
Put_Line (ASM, ASCII.HT & ".cpu " &
To_String (MCU_To_CPU (Device => Device)));
Put_Line (ASM, ASCII.HT & ".thumb");
New_Line (ASM);

Expand Down