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

Figure out CPU by MCU provided #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 26 additions & 1 deletion src/descriptors-device.adb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ package body Descriptors.Device is
package Interrupt_Sort is new Interrupt_Vectors.Generic_Sorting
(Base_Types."<");

function MCU_To_CPU
(Device : Device_T) return Unbounded_String;

procedure Dump_Handler_ASM
(Device : Device_T;
Ints : Interrupt_Vectors.Vector;
Expand All @@ -43,6 +46,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
Description_String : constant String := To_String (Device.Short_Desc);
CPU : Unbounded_String;
begin
if Starts_With (S1 => Description_String, S2 => "STM32F0") then
CPU := To_Unbounded_String ("cortex-m0");
elsif Starts_With (S1 => Description_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 +233,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