From 4dc01bb53d83692cbe176499aff5c39cee197aaa Mon Sep 17 00:00:00 2001 From: Biser Milanov Date: Tue, 11 Sep 2018 21:11:09 +0300 Subject: [PATCH 1/3] Figure out CPU by MCU provided Added a MCU_To_CPU function that returns the string representation of the CPU based on the Device parameter. It is then used when generating handlers.S --- src/descriptors-device.adb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/descriptors-device.adb b/src/descriptors-device.adb index 1910879..ed0cf4d 100644 --- a/src/descriptors-device.adb +++ b/src/descriptors-device.adb @@ -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 + (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 + 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 -- ----------------- @@ -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); From 20dacd0938c73f95495d3f2976be790cae2bd5be Mon Sep 17 00:00:00 2001 From: Biser Milanov Date: Wed, 12 Sep 2018 18:35:57 +0300 Subject: [PATCH 2/3] Typo fixed per simonjwright's suggestion --- src/descriptors-device.adb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/descriptors-device.adb b/src/descriptors-device.adb index ed0cf4d..b945787 100644 --- a/src/descriptors-device.adb +++ b/src/descriptors-device.adb @@ -50,12 +50,12 @@ package body Descriptors.Device is function MCU_To_CPU (Device : Device_T) return Unbounded_String is - Descrition_String : constant String := To_String (Device.Short_Desc); + Description_String : constant String := To_String (Device.Short_Desc); CPU : Unbounded_String; begin - if Starts_With (S1 => Descrition_String, S2 => "STM32F0") then + if Starts_With (S1 => Description_String, S2 => "STM32F0") then CPU := To_Unbounded_String ("cortex-m0"); - elsif Starts_With (S1 => Descrition_String, S2 => "Cortex-M1") then + elsif Starts_With (S1 => Description_String, S2 => "Cortex-M1") then CPU := To_Unbounded_String ("cortex-m1"); else CPU := To_Unbounded_String ("cortex-m4"); From a12d9374c2095d3591e6888308c31dc6ce311527 Mon Sep 17 00:00:00 2001 From: Biser Milanov Date: Wed, 19 Sep 2018 19:21:23 +0300 Subject: [PATCH 3/3] Added MCU_To_CPU declaration --- src/descriptors-device.adb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/descriptors-device.adb b/src/descriptors-device.adb index b945787..e11d7dd 100644 --- a/src/descriptors-device.adb +++ b/src/descriptors-device.adb @@ -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;