├── obj └── .gitignore ├── CMSIS-SVD ├── .gitignore ├── Cortex_M │ ├── support │ │ ├── trailing │ │ └── preamble │ ├── Makefile │ └── IPs │ │ ├── nvic.part │ │ ├── cache.part │ │ ├── systick.part │ │ ├── fpu.part │ │ ├── pf.part │ │ ├── dwt_m4.part │ │ ├── dwt_m7.part │ │ ├── debug.part │ │ └── mpu.part ├── README.md ├── ST │ └── ST_License.html ├── ATMEL │ └── ATMEL_License.html └── Microsemi │ └── M1AGL.svd ├── .gitignore ├── alire.toml ├── .github └── workflows │ └── main.yml ├── README.md ├── src ├── descriptors.ads ├── base_types-register_properties.ads ├── descriptors-enumerate.ads ├── descriptors-device.ads ├── base_types-register_properties.adb ├── svd2ada_utils.ads ├── descriptors-peripheral.ads ├── descriptors-field.ads ├── descriptors-register.ads ├── descriptors-cluster.ads ├── descriptors-enumerate.adb ├── base_types.ads ├── descriptors-register.adb ├── svd2ada.adb └── svd2ada_utils.adb └── svd2ada.gpr /obj/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CMSIS-SVD/.gitignore: -------------------------------------------------------------------------------- 1 | orig/* 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /lib/ 2 | /alire/ 3 | /config/ 4 | /obj/ 5 | /bin/ 6 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/support/trailing: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /CMSIS-SVD/README.md: -------------------------------------------------------------------------------- 1 | This directory contains some of the SVD files that have been 2 | used and checked internally. 3 | 4 | They contain some fixes of bugs found in the original SVD files retrieved from 5 | https://cmsis.arm.com. 6 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/support/preamble: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /alire.toml: -------------------------------------------------------------------------------- 1 | name = "svd2ada" 2 | description = "Ada binding generator from CMSIS-SVD hardware descriptions files" 3 | version = "0.1.1" 4 | 5 | authors = ["AdaCore"] 6 | maintainers = ["Fabien Chouteau "] 7 | maintainers-logins = ["Fabien-Chouteau"] 8 | 9 | executables = ["svd2ada"] 10 | 11 | [[depends-on]] 12 | xmlada = ">=22.0.0" 13 | 14 | [configuration] 15 | disabled = true 16 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | pull_request: 4 | workflow_dispatch: 5 | env: 6 | SVD2ADA_COMPILE_CHECKS: enabled 7 | SVD2ADA_RUNTIME_CHECKS: enabled 8 | SVD2ADA_STYLE_CHECKS: enabled 9 | SVD2ADA_CONTRACTS: enabled 10 | jobs: 11 | build: 12 | strategy: 13 | matrix: 14 | os: [macos-latest, windows-latest, ubuntu-latest] 15 | runs-on: ${{ matrix.os }} 16 | steps: 17 | - uses: actions/checkout@v3 18 | - uses: alire-project/setup-alire@v3 19 | with: 20 | toolchain: gnat_native${{ matrix.gnat_version }} gprbuild${{ matrix.gprbuild_version }} --disable-assistant 21 | - run: alr build 22 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/Makefile: -------------------------------------------------------------------------------- 1 | VPATH = IPs 2 | 3 | all: cm4.svd cm4f.svd cm7.svd 4 | 5 | cm4.svd: nvic.part scb.part systick.part mpu.part debug.part dwt_m4.part 6 | @echo "creating $@ from $+" 7 | @cat support/preamble > $@ 8 | @for f in $+; do \ 9 | cat $$f >> $@; \ 10 | done 11 | @cat support/trailing >> $@ 12 | 13 | cm4f.svd: nvic.part scb.part systick.part fpu.part mpu.part debug.part dwt_m4.part 14 | @echo "creating $@ from $+" 15 | @cat support/preamble > $@ 16 | @for f in $+; do \ 17 | cat $$f >> $@; \ 18 | done 19 | @cat support/trailing >> $@ 20 | 21 | cm7.svd: nvic.part scb.part systick.part fpu.part mpu.part pf.part cache.part debug.part dwt_m7.part 22 | @echo "creating $@ from $+" 23 | @cat support/preamble > $@ 24 | @for f in $+; do \ 25 | cat $$f >> $@; \ 26 | done 27 | @cat support/trailing >> $@ 28 | 29 | clean: 30 | rm -f *.svd 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # svd2ada 2 | SVD2Ada is an Ada binding generator from CMSIS-SVD descriptions for 3 | ARM Cortex-M devices. It is meant to ease, strengthen and speed up driver 4 | development for those platforms. 5 | 6 | # Build 7 | 8 | To build `SVD2Ada` you need a native GNAT compiler, for instance GNAT Community 9 | edition that you can find [here](https://www.adacore.com/download). 10 | 11 | After installing GNAT, you can build with the following command: 12 | ``` 13 | $ gprbuild -P svd2ada.gpr 14 | ``` 15 | 16 | # Usage 17 | 18 | To run `SVD2Ada` you need to specify at least the SVD file from which you want 19 | to generate code, and the output directory where the code will be generated. 20 | 21 | ``` 22 | $ svd2ada -o 23 | ``` 24 | 25 | Use `--help` to display information about the different code generation 26 | options available: 27 | 28 | ``` 29 | $ svd2ada --help 30 | ``` 31 | -------------------------------------------------------------------------------- /src/descriptors.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | package Descriptors is 21 | pragma Pure; 22 | end Descriptors; 23 | -------------------------------------------------------------------------------- /src/base_types-register_properties.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with DOM.Core; use DOM.Core; 21 | 22 | -- Decodes the register properties group from an SVD element. 23 | -- This group is used in Device, Peripherals and Registers descriptors. 24 | package Base_Types.Register_Properties is 25 | 26 | type Register_Properties_T is record 27 | Size : Natural := 0; 28 | Reg_Access : Access_Type := Read_Write; 29 | Protection : Protection_Type := Undefined_Protection; 30 | Reset_Value : Unsigned := 0; 31 | Reset_Mask : Unsigned := 0; 32 | end record; 33 | 34 | Null_Register_Property : constant Register_Properties_T := (others => <>); 35 | 36 | function Is_Register_Property (Tag : String) return Boolean; 37 | 38 | procedure Read_Register_Property 39 | (Child : Element; 40 | Props : in out Register_Properties_T); 41 | 42 | end Base_Types.Register_Properties; 43 | -------------------------------------------------------------------------------- /src/descriptors-enumerate.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Containers.Vectors; 21 | with Ada.Strings.Unbounded; use Ada.Strings; 22 | 23 | with DOM.Core; 24 | 25 | with Base_Types; use Base_Types; 26 | 27 | package Descriptors.Enumerate is 28 | 29 | type Enumerate_Value is record 30 | Name : Unbounded.Unbounded_String; 31 | Descr : Unbounded.Unbounded_String; 32 | Value : Unsigned; 33 | IsDefault : Boolean := False; 34 | end record; 35 | 36 | package Enumerate_Values_Vectors is new Ada.Containers.Vectors 37 | (Positive, Enumerate_Value); 38 | 39 | type Enumerate_T is record 40 | Name : Unbounded.Unbounded_String; 41 | Values : Enumerate_Values_Vectors.Vector; 42 | Usage : Enum_Usage_Type := Read_Write; 43 | end record; 44 | 45 | package Enumerate_Vectors is new Ada.Containers.Vectors 46 | (Positive, Enumerate_T); 47 | 48 | function Read_Enumerate 49 | (Elt : DOM.Core.Element; 50 | Vector : Enumerate_Vectors.Vector; 51 | Write_Only : Boolean) 52 | return Enumerate_T; 53 | 54 | end Descriptors.Enumerate; 55 | -------------------------------------------------------------------------------- /src/descriptors-device.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Strings.Unbounded; use Ada.Strings; 21 | 22 | with DOM.Core; 23 | 24 | with Base_Types; use Base_Types; 25 | with Base_Types.Register_Properties; 26 | 27 | with Descriptors.Peripheral; use Descriptors.Peripheral; 28 | 29 | -- Decodes and dumps the elements of the SVD file. This is the 30 | -- main entry point for decoding this file. 31 | package Descriptors.Device is 32 | 33 | type Device_T is new Peripheral_Db with record 34 | Name : Unbounded.Unbounded_String; 35 | Version : Unbounded.Unbounded_String; 36 | Description : Unbounded.Unbounded_String; 37 | Short_Desc : Unbounded.Unbounded_String; 38 | 39 | -- BUS interface properties: 40 | -- adressable unit 41 | Address_Unit_Bits : Unsigned := 0; 42 | -- maximum data bit width accessbile within a single transfer 43 | Width : Natural := 0; 44 | 45 | Has_FPU : Boolean := True; 46 | 47 | -- REGISTERS properties 48 | Reg_Properties : Register_Properties.Register_Properties_T; 49 | 50 | Peripherals : Peripheral_Vectors.Vector; 51 | end record; 52 | 53 | function Read_Device (Elt : DOM.Core.Element; 54 | Pkg_Name : String) return Device_T; 55 | 56 | overriding function Get_Peripheral 57 | (Db : Device_T; 58 | XML_Id : String) return Peripheral_Access; 59 | 60 | procedure Dump 61 | (Device : Device_T; 62 | Output_Dir : String); 63 | 64 | end Descriptors.Device; 65 | -------------------------------------------------------------------------------- /svd2ada.gpr: -------------------------------------------------------------------------------- 1 | with "xmlada"; 2 | 3 | project SVD2ada is 4 | 5 | for Source_Dirs use ("src"); 6 | for Object_Dir use "obj"; 7 | for Create_Missing_Dirs use "True"; 8 | for Exec_Dir use "bin"; 9 | for Main use ("svd2ada.adb"); 10 | 11 | type Enabled_Kind is ("enabled", "disabled"); 12 | Compile_Checks : Enabled_Kind := External ("SVD2ADA_COMPILE_CHECKS", "disabled"); 13 | Runtime_Checks : Enabled_Kind := External ("SVD2ADA_RUNTIME_CHECKS", "enabled"); 14 | Style_Checks : Enabled_Kind := External ("SVD2ADA_STYLE_CHECKS", "disabled"); 15 | Contracts_Checks : Enabled_Kind := External ("SVD2ADA_CONTRACTS", "disabled"); 16 | 17 | type Build_Kind is ("debug", "optimize"); 18 | Build_Mode : Build_Kind := External ("SVD2ADA_BUILD_MODE", "optimize"); 19 | 20 | Compile_Checks_Switches := (); 21 | case Compile_Checks is 22 | when "enabled" => 23 | Compile_Checks_Switches := 24 | ("-gnatwa", -- All warnings 25 | "-gnatVa", -- All validity checks 26 | "-gnatwe"); -- Warnings as errors 27 | when others => null; 28 | end case; 29 | 30 | Runtime_Checks_Switches := (); 31 | case Runtime_Checks is 32 | when "enabled" => null; 33 | when others => 34 | Runtime_Checks_Switches := 35 | ("-gnatp"); -- Suppress checks 36 | end case; 37 | 38 | Style_Checks_Switches := (); 39 | case Style_Checks is 40 | when "enabled" => 41 | Style_Checks_Switches := 42 | ("-gnatyg", -- GNAT Style checks 43 | "-gnaty-d", -- Disable no DOS line terminators 44 | "-gnatyM120", -- Maximum line length 45 | "-gnatyO"); -- Overriding subprograms explicitly marked as such 46 | when others => null; 47 | end case; 48 | 49 | Contracts_Switches := (); 50 | case Contracts_Checks is 51 | when "enabled" => 52 | Contracts_Switches := 53 | ("-gnata"); -- Enable assertions and contracts 54 | when others => null; 55 | end case; 56 | 57 | Build_Switches := (); 58 | case Build_Mode is 59 | when "optimize" => 60 | Build_Switches := ("-O3", -- Optimization 61 | "-gnatn"); -- Enable inlining 62 | when "debug" => 63 | Build_Switches := ("-g", -- Debug info 64 | "-Og"); -- No optimization 65 | end case; 66 | 67 | package Compiler is 68 | for Default_Switches ("Ada") use 69 | Compile_Checks_Switches & 70 | Build_Switches & 71 | Runtime_Checks_Switches & 72 | Style_Checks_Switches & 73 | Contracts_Switches & 74 | ("-gnatw.X", -- Disable warnings for No_Exception_Propagation 75 | "-gnatQ"); -- Don't quit. Generate ALI and tree files even if illegalities 76 | end Compiler; 77 | 78 | package Binder is 79 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 80 | end Binder; 81 | 82 | package Install is 83 | for Mode use "usage"; 84 | for Required_Artifacts ("schema") use ("schema/"); 85 | for Required_Artifacts ("share/CMSIS-SVD") use ("CMSIS-SVD/"); 86 | end Install; 87 | 88 | end SVD2ada; 89 | -------------------------------------------------------------------------------- /src/base_types-register_properties.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with DOM.Core.Elements; 21 | 22 | package body Base_Types.Register_Properties is 23 | 24 | TAG_SIZE : constant String := "size"; 25 | TAG_ACCESS : constant String := "access"; 26 | TAG_PROTECTION : constant String := "protection"; 27 | TAG_RESET_VALUE : constant String := "resetValue"; 28 | TAG_RESET_MASK : constant String := "resetMask"; 29 | 30 | -------------------------- 31 | -- Is_Register_Property -- 32 | -------------------------- 33 | 34 | function Is_Register_Property (Tag : String) return Boolean is 35 | begin 36 | return Tag = TAG_SIZE 37 | or else Tag = TAG_ACCESS 38 | or else Tag = TAG_PROTECTION 39 | or else Tag = TAG_RESET_VALUE 40 | or else Tag = TAG_RESET_MASK; 41 | end Is_Register_Property; 42 | 43 | ---------------------------- 44 | -- Read_Register_Property -- 45 | ---------------------------- 46 | 47 | procedure Read_Register_Property 48 | (Child : Element; 49 | Props : in out Register_Properties_T) 50 | is 51 | Tag : String renames Elements.Get_Tag_Name (Child); 52 | begin 53 | if Tag = TAG_SIZE then 54 | Props.Size := Get_Value (Child); 55 | 56 | elsif Tag = TAG_ACCESS then 57 | Props.Reg_Access := Get_Value (Child); 58 | 59 | elsif Tag = TAG_PROTECTION then 60 | Props.Protection := Get_Value (Child); 61 | 62 | elsif Tag = TAG_RESET_VALUE then 63 | Props.Reset_Value := Get_Value (Child); 64 | 65 | elsif Tag = TAG_RESET_MASK then 66 | Props.Reset_Mask := Get_Value (Child); 67 | 68 | end if; 69 | end Read_Register_Property; 70 | 71 | end Base_Types.Register_Properties; 72 | -------------------------------------------------------------------------------- /CMSIS-SVD/ST/ST_License.html: -------------------------------------------------------------------------------- 1 |

End User License Agreement for STMicroelectronics (Version 1.0)

2 | Licence Terms

3 |

4 | STMicroelectronics International N.V.,   (“LICENSOR”) hereby grants and you (“LICENSEE”) hereby accept a non transferable, non-exclusive licence to use and copy the deliverables (“Deliverables”) solely for the purpose of; (i) developing LICENSEE’s development tools and distributing such development tools to third parties; (ii) generating derivative representations of the Deliverables to develop and debug software for LICENSOR’s targeted devices or device series identified within the Deliverables, (together the “Purpose”) under the following terms and conditions:

5 |

6 | 1.         Ownership.  The Deliverables are the property of LICENSOR. LICENSEE acquires no right, title or interest in the Deliverables other than the licence rights granted herein. 

7 |

8 | 2.         Use.  LICENSEE shall only be permitted to use the Deliverables for the Purpose.  LICENSEE shall not reverse engineer, decompile or disassemble the Deliverables, in whole or in part.

9 |

10 | 3.         Copies.  All copies of the Deliverables must bear the same notice(s) contained on the original copies of the Deliverables.

11 |

12 | 4.         No Warranty. THE DELIVERABLES ARE PROVIDED “AS IS” AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 |
14 | IN NO EVENT SHALL LICENSOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE DELIVERABLES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 |
16 | LICENSEE EXPRESSLY ASSUMES ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE DELIVERABLES.

17 |

18 | 5.         In the event that LICENSEE receives early access to the Deliverables, LICENSEE acknowledges and agrees that; (a) notwithstanding the licence grants above, LICENSEE shall only be permitted to use the Deliverables solely internally for evaluation and providing feedback to LICENSOR; (b) except with respect to the limited licence grants in 5(a), LICENSEE shall be subject to all of the terms and conditions set out above; and (c) the Deliverables are confidential information and LICENSEE shall maintain in confidence the Deliverables and apply security measures no less stringent than the measures that LICENSEE applies to its own like information, but not less than a reasonable degree of care, to prevent unauthorised disclosure and use of the Deliverables.

-------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/nvic.part: -------------------------------------------------------------------------------- 1 | 2 | NVIC 3 | 0xE000E100 4 | read-write 5 | 6 | 7 | 0 8 | 0x350 9 | registers 10 | 11 | 12 | 13 | 14 | NVIC_ISER 15 | Interrupt Set-Enable Registers 16 | 0x00 17 | 32 18 | read-only 19 | 8 20 | 0-7 21 | 4 22 | 23 | 24 | NVIC_ICER 25 | Interrupt Clear-Enable Registers 26 | 0x80 27 | 32 28 | read-only 29 | 8 30 | 0-7 31 | 4 32 | 33 | 34 | NVIC_ISPR 35 | Interrupt Set-Pending Registers 36 | 0x100 37 | 32 38 | read-only 39 | 8 40 | 0-7 41 | 4 42 | 43 | 44 | NVIC_ICPR 45 | Interrupt Clear-Pending Registers 46 | 0x180 47 | 32 48 | read-only 49 | 8 50 | 0-7 51 | 4 52 | 53 | 54 | NVIC_IABR 55 | Interrupt Active Bit Register 56 | 0x200 57 | 32 58 | read-only 59 | 8 60 | 0-7 61 | 4 62 | 63 | 64 | NVIC_IPR 65 | Interrupt Priority Register 66 | 0x300 67 | 32 68 | read-only 69 | 60 70 | 0-59 71 | 4 72 | 73 | 74 | STIR 75 | Software Trigger Interrupt Register 76 | 0xE00 77 | 32 78 | write-only 79 | 80 | 81 | INTID 82 | Interrupt ID of the interrupt to trigger, in the 83 | range 0-239. 84 | 0 85 | 9 86 | 87 | 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /src/svd2ada_utils.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2024, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | package SVD2Ada_Utils is 21 | 22 | function Executable_Location return String; 23 | 24 | procedure Set_Use_Boolean_For_Bit (Value : Boolean); 25 | 26 | function Use_Boolean_For_Bit return Boolean; 27 | 28 | procedure Set_Use_UInt (Value : Boolean); 29 | 30 | function Use_UInt_Always return Boolean; 31 | 32 | procedure Set_No_UInt_Subtype (Value : Boolean); 33 | 34 | function Gen_UInt_Subtype return Boolean; 35 | 36 | procedure Set_No_Defaults (Value : Boolean); 37 | 38 | function Gen_Fields_Default return Boolean; 39 | 40 | procedure Set_Base_Types_Package (Value : String); 41 | 42 | function Base_Types_Package return String; 43 | 44 | function External_Base_Types_Package return Boolean; 45 | 46 | procedure Set_Root_Package (Value : String); 47 | 48 | function Root_Package return String; 49 | 50 | function In_Runtime return Boolean; 51 | 52 | function No_Elaboration_Code_All return Boolean; 53 | 54 | procedure Set_No_Elaboration_Code_All (Value : Boolean); 55 | 56 | procedure Set_No_VFA_On_Reg_Types (Value : Boolean); 57 | 58 | function No_VFA_On_Reg_Types return Boolean; 59 | -- Whether the Volatile_Full_Access pragma is applied on the base 60 | -- register type or on the fields of peripherals/clusters. 61 | -- This has impacts on the way arrays of registers are generated: 62 | -- until we have something like Volatile_Full_Access_Components pragma 63 | -- for arrays, there's no way to indicate to the compiler that the 64 | -- components of an array should be VFA, unless we apply the pragma to the 65 | -- base register type. 66 | 67 | procedure Set_Gen_Arrays (Value : Boolean); 68 | 69 | function Gen_Arrays return Boolean; 70 | -- If Gen_Arrays is set, the register fields with similar names and types 71 | -- only differing by a numbered suffix are generated as an array. 72 | 73 | procedure Set_Gen_IRQ_Support (Value : Boolean); 74 | 75 | function Gen_IRQ_Support return Boolean; 76 | -- Whether to generate trap handler assembly file and Interrupts.Names 77 | -- package 78 | 79 | function Is_Reserved_Word (Word : String) return Boolean; 80 | -- Check if Word one of the Ada languuage reserved words. 81 | -- Word is required to be in lower case. 82 | 83 | end SVD2Ada_Utils; 84 | -------------------------------------------------------------------------------- /src/descriptors-peripheral.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Containers.Vectors; 21 | with Ada.Strings.Unbounded; use Ada.Strings; 22 | 23 | with DOM.Core; 24 | 25 | with Base_Types; use Base_Types; 26 | with Base_Types.Register_Properties; use Base_Types.Register_Properties; 27 | 28 | with Descriptors.Cluster; use Descriptors.Cluster; 29 | with Descriptors.Register; use Descriptors.Register; 30 | 31 | -- Decodes and then dumps the elements of the SVD file. 32 | package Descriptors.Peripheral is 33 | 34 | type Peripheral_T; 35 | type Peripheral_Access is access all Peripheral_T; 36 | 37 | type Peripheral_Db is interface; 38 | 39 | function Get_Peripheral 40 | (Db : Peripheral_Db; 41 | XML_Id : String) return Peripheral_Access is abstract; 42 | 43 | type Peripheral_T is new Register_Db and Cluster_Db with record 44 | Name : Unbounded.Unbounded_String; 45 | Type_Name : Unbounded.Unbounded_String; 46 | Version : Unbounded.Unbounded_String; 47 | Description : Unbounded.Unbounded_String; 48 | Group_Name : Unbounded.Unbounded_String; 49 | Prepend_To_Name : Unbounded.Unbounded_String; 50 | Append_To_Name : Unbounded.Unbounded_String; 51 | Base_Address : Unsigned := 0; 52 | Reg_Properties : Register_Properties_T := Null_Register_Property; 53 | Address_Blocks : Address_Block_Vectors.Vector; 54 | Interrupts : Interrupt_Vectors.Vector; 55 | Content : Peripheral_Element_Vectors.Vector; 56 | end record; 57 | 58 | overriding function Get_Register 59 | (Db : Peripheral_T; 60 | XML_Id : String) return Register_Access; 61 | 62 | overriding function Get_Cluster 63 | (Db : Peripheral_T; 64 | XML_Id : String) return Cluster_Access; 65 | 66 | function Read_Peripheral 67 | (Elt : DOM.Core.Element; 68 | Reg_Properties : Register_Properties_T; 69 | Periph_Db : Peripheral_Db'Class) return Peripheral_T; 70 | 71 | procedure Dump 72 | (Peripheral : in out Peripheral_T; 73 | Dev_Name : String; 74 | Output_Dir : String); 75 | 76 | package Peripheral_Vectors is new Ada.Containers.Vectors 77 | (Positive, Peripheral_Access); 78 | 79 | procedure Dump 80 | (Group : Peripheral_Vectors.Vector; 81 | Dev_Name : String; 82 | Output_Dir : String); 83 | 84 | end Descriptors.Peripheral; 85 | -------------------------------------------------------------------------------- /src/descriptors-field.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2024, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Containers.Vectors; 21 | with Ada.Strings.Unbounded; use Ada.Strings; 22 | 23 | with DOM.Core; 24 | 25 | with Ada_Gen; 26 | with Base_Types; use Base_Types; 27 | with Base_Types.Register_Properties; use Base_Types.Register_Properties; 28 | 29 | limited with Descriptors.Register; 30 | with Descriptors.Enumerate; 31 | 32 | -- Decodes the elements of the SVD file. 33 | package Descriptors.Field is 34 | 35 | -- From the SVD, these components are in an optional : 36 | -- specifies the number of array elements, 37 | -- specifies the address (?bit) offset between consecutive 38 | -- array elements, 39 | -- (optional) specifies "a comma seperated list of 40 | -- strings being used for identifying each element in the array", 41 | -- but we only see r'[0-9]+\-[0-9]+'. 42 | -- 43 | -- We will produce fields, where %s in the Name translates 44 | -- to the first component of incremented by 1 for each 45 | -- field, and LSB, MSB are incremented by . 46 | 47 | type Field_T is record 48 | Name : Unbounded.Unbounded_String; 49 | Description : Unbounded.Unbounded_String; 50 | Dimensions : Natural; -- 51 | Increment : Natural; -- 52 | Index : Natural; -- first component of 53 | LSB : Natural; 54 | MSB : Natural; 55 | Size : Natural; 56 | Acc : Access_Type; 57 | Mod_Write_Values : Modified_Write_Values_Type := Modify; 58 | Read_Action : Read_Action_Type := Undefined_Read_Action; 59 | Enums : Descriptors.Enumerate.Enumerate_Vectors.Vector; 60 | end record; 61 | 62 | overriding 63 | function "=" (F1, F2 : Field_T) return Boolean; 64 | 65 | Null_Field : constant Field_T := 66 | (Name => Unbounded.Null_Unbounded_String, 67 | Description => Unbounded.Null_Unbounded_String, 68 | Dimensions => 0, 69 | Increment => 0, 70 | Index => 0, 71 | LSB => 0, 72 | MSB => 0, 73 | Size => 0, 74 | Acc => Read_Write, 75 | others => <>); 76 | 77 | package Field_Vectors is new Ada.Containers.Vectors 78 | (Positive, Field_T); 79 | 80 | function Read_Field 81 | (Elt : DOM.Core.Element; 82 | Vec : Field_Vectors.Vector; 83 | Default_Access : Access_Type; 84 | Default_Read : Read_Action_Type) 85 | return Field_T; 86 | 87 | procedure Dump 88 | (Spec : in out Ada_Gen.Ada_Spec; 89 | Reg : Descriptors.Register.Register_Access; 90 | Rec : in out Ada_Gen.Ada_Type_Record; 91 | Reg_Fields : Field_Vectors.Vector; 92 | Properties : Register_Properties_T); 93 | 94 | end Descriptors.Field; 95 | -------------------------------------------------------------------------------- /CMSIS-SVD/ATMEL/ATMEL_License.html: -------------------------------------------------------------------------------- 1 |

End User License Agreement for Atmel (Version 1.0)

2 |  License Terms

3 |

4 | ATMEL CORPORATION (“LICENSOR”) hereby grants and you (“LICENSEE”) hereby accept a non transferable, non-exclusive licence to use and copy the deliverables (“Deliverables”) solely for the purpose of; (i) developing LICENSEE’s development tools and distributing such development tools to third parties; (ii) generating derivative representations of the Deliverables to develop and debug software for LICENSOR’s targeted devices or device series identified within the Deliverables, (together the “Purpose”) under the following terms and conditions:

5 |
    6 |
  1. 7 |  Ownership.  The Deliverables are the property of LICENSOR. LICENSOR retains full rights, title, and ownership including all patents, copyrights, trade secrets, trade names, trademarks, and other intellectual property rights in and to the Deliverables. LICENSEE acquires no right, title or interest in the Deliverables other than the licence rights granted herein.
    8 |  
  2. 9 |
  3. 10 | Use.  LICENSEE shall only be permitted to use the Deliverables for the Purpose.  LICENSEE shall not reverse engineer, decompile or disassemble the Deliverables, in whole or in part.
    11 |  
  4. 12 |
  5. 13 | Copies.  All copies of the Deliverables must bear the same trademark or copyright markings and notice(s) contained on the original copies of the Deliverables.
    14 |  
  6. 15 |
  7. 16 | No Warranty and No Support. THE DELIVERABLES ARE PROVIDED “AS IS” AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY. FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE DISCLAIMED. LICENSOR IS NOT OBLIGATED TO FURNISH OR MAKE AVAILABLE TO LICENSEE ANY FURTHER INFORMATION, KNOW-HOW, SHOW-HOW, BUG-FIXES, OR SUPPORT.  LICENSEE EXPRESSLY ASSUMES ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE DELIVERABLES.
    17 |
    18 | LICENSEE EXPRESSLY ASSUMES ALL LIABILITIES AND RISKS, FOR USE OR OPERATION OF THE DELIVERABLES.
    19 |  
  8. 20 |
  9. 21 | Early Access.  In the event that LICENSEE receives early access to the Deliverables, LICENSEE acknowledges and agrees that; (a) notwithstanding the licence grants above, LICENSEE shall only be permitted to use the Deliverables solely internally for evaluation and providing feedback to LICENSOR; (b) except with respect to the limited licence grants in 5(a), LICENSEE shall be subject to all of the terms and conditions set out above; and (c) the Deliverables are confidential information and LICENSEE shall maintain in confidence the Deliverables and apply security measures no less stringent than the measures that LICENSEE applies to its own like information, but not less than a reasonable degree of care, to prevent unauthorised disclosure and use of the Deliverables.
    22 |  
  10. 23 |
  11. 24 | Limitation of Liability.  IN NO EVENT SHALL LICENSOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE DELIVERABLES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  IN NO EVENT SHALL THE LIABILITY OF LICENSOR ARISING OUT OF OR RELATING TO THIS AGREEMENT EXCEED THE GREATER OF ONE THOUSAND U.S. DOLLARS (US$1,000) OR THE PRICE PAID BY LICENSEE TO LICENSOR FOR THE DELIVERABLES.
    25 |  
  12. 26 |
  13. 27 | Entire Agreement.  THIS AGREEMENT IS THE ENTIRE AND EXCLUSIVE AGREEMENT BETWEEN LICENSOR AND LICENSEE AND SUPERSEDES ALL PRIOR ORAL AND WRITTEN AGREEMENTS AND COMMUNICATIONS BETWEEN THE PARTIES PERTAINING TO THE SUBJECT MATTER OF THIS AGREEMENT.  NO DIFFERENT OR ADDITIONAL TERMS WILL BE ENFORCEABLE AGAINST LICENSOR UNLESS LICENSOR GIVES ITS EXPRESS WRITTEN CONSENT, INCLUDING AN EXPRESS WAIVER OF THE TERMS OF THIS AGREEMENT.
  14. 28 |
29 |

30 | (20. August 2012)

-------------------------------------------------------------------------------- /src/descriptors-register.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Containers.Indefinite_Holders; 21 | with Ada.Strings.Unbounded; use Ada.Strings; 22 | 23 | with DOM.Core; 24 | 25 | with Base_Types; use Base_Types; 26 | with Base_Types.Register_Properties; use Base_Types.Register_Properties; 27 | 28 | with Descriptors.Field; use Descriptors.Field; 29 | 30 | with Ada_Gen; 31 | 32 | -- Decodes and then dumps the elements of the SVD file. 33 | package Descriptors.Register is 34 | 35 | type Register_T; 36 | 37 | type Register_Access is access all Register_T; 38 | 39 | package Type_Holders is new Ada.Containers.Indefinite_Holders 40 | (Ada_Gen.Ada_Type'Class, Ada_Gen."="); 41 | function "-" (Holder : Type_Holders.Holder) return Ada_Gen.Ada_Type'Class 42 | is (Type_Holders.Element (Holder)); 43 | function "-" (Typ : Ada_Gen.Ada_Type'Class) return Type_Holders.Holder 44 | is (Type_Holders.To_Holder (Typ)); 45 | 46 | type Register_T is record 47 | Xml_Id : Unbounded.Unbounded_String; 48 | Name : Unbounded.Unbounded_String; 49 | Display_Name : Unbounded.Unbounded_String; 50 | Description : Unbounded.Unbounded_String; 51 | Alternate_Group : Unbounded.Unbounded_String; 52 | Alternate_Reg : Unbounded.Unbounded_String; 53 | Address_Offset : Natural; 54 | Reg_Properties : Register_Properties_T; 55 | Mod_Write_Values : Modified_Write_Values_Type := Modify; 56 | Read_Action : Read_Action_Type := Undefined_Read_Action; 57 | Fields : Field_Vectors.Vector; 58 | 59 | -- By default, equal to Name. In case similar types are found, then 60 | -- this holds the common prefix to be used to the type definition 61 | Type_Name : Unbounded.Unbounded_String; 62 | 63 | -- When two registers are at the same location, we specify a shared 64 | -- common union type name here to support this overlapping 65 | Is_Overlapping : Boolean := False; 66 | Overlap_Suffix : Unbounded.Unbounded_String; 67 | 68 | -- When two registers are identical, the second register will not 69 | -- generate an Ada type. We reference the first register here to 70 | -- keep track of the type name. 71 | Type_Holder : Register_Access := null; 72 | -- This holds the Ada type as generated in the spec file. 73 | -- Only available when Type_Holder is null. 74 | Ada_Type : Type_Holders.Holder; 75 | 76 | Dim : Positive := 1; 77 | Dim_Increment : Natural := 4; 78 | Dim_Index : Unbounded.Unbounded_String; 79 | end record; 80 | 81 | function Equal (R1, R2 : Register_Access) return Boolean; 82 | 83 | function Similar_Type 84 | (R1, R2 : Register_Access) return Unbounded.Unbounded_String; 85 | -- If R1 and R2 share a common type, then return the base type name. 86 | -- else, return an empty string 87 | 88 | type Register_Db is interface; 89 | 90 | function Get_Register 91 | (Db : Register_Db; 92 | XML_Id : String) return Register_Access is abstract; 93 | 94 | function Read_Register 95 | (Elt : DOM.Core.Element; 96 | Prepend : Unbounded.Unbounded_String; 97 | Append : Unbounded.Unbounded_String; 98 | Reg_Properties : Register_Properties_T; 99 | Reg_Db : Register_Db'Class) 100 | return Register_Access; 101 | 102 | function Get_Ada_Type (Reg : Register_Access) return Ada_Gen.Ada_Type'Class; 103 | 104 | procedure Dump (Spec : in out Ada_Gen.Ada_Spec; Reg : Register_Access); 105 | 106 | end Descriptors.Register; 107 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/cache.part: -------------------------------------------------------------------------------- 1 | 2 | Cache 3 | Cache maintenance operations 4 | 0xE000EF50 5 | 6 | 0 7 | 0x2C 8 | registers 9 | 10 | 11 | 12 | 13 | ICIALLU 14 | Instruction cache invalidate all to the PoU 15 | 0x0 16 | 32 17 | 0x0 18 | 0xFFFFFFFF 19 | write-only 20 | 21 | 22 | ICIMVAU 23 | Instruction cache invalidate by address to the PoU 24 | 0x8 25 | 32 26 | 0x0 27 | 0xFFFFFFFF 28 | write-only 29 | 30 | 31 | DCIMVAC 32 | Data cache invalidate by address to the PoC 33 | 0xC 34 | 32 35 | 0x0 36 | 0xFFFFFFFF 37 | write-only 38 | 39 | 40 | DCISW 41 | Data cache invalidate by set/way 42 | 0x10 43 | 32 44 | 0x0 45 | 0xFFFFFFFF 46 | write-only 47 | 48 | 49 | Set 50 | Set/index that operation applies to. The number of 51 | indices in a cache depends on the configured cache size. When 52 | this is less than the maximum, use the LSB of this field. 53 | 54 | 5 55 | 9 56 | 57 | 58 | Way 59 | Way that operation applies to. For the data cache, 60 | values 0, 1, 2 and 3 are supported.. 61 | 62 | 30 63 | 2 64 | 65 | 66 | 67 | 68 | DCCMVAU 69 | Data cache clean by address to the PoU 70 | 0x14 71 | 32 72 | 0x0 73 | 0xFFFFFFFF 74 | write-only 75 | 76 | 77 | DCCMVAC 78 | Data cache clean by address to the PoC 79 | 0x18 80 | 32 81 | 0x0 82 | 0xFFFFFFFF 83 | write-only 84 | 85 | 86 | DCCSW 87 | Data cache clean by set/way 88 | 0x1C 89 | 32 90 | 0x0 91 | 0xFFFFFFFF 92 | write-only 93 | 94 | 95 | Set 96 | Set/index that operation applies to. The number of 97 | indices in a cache depends on the configured cache size. When 98 | this is less than the maximum, use the LSB of this field. 99 | 100 | 5 101 | 9 102 | 103 | 104 | Way 105 | Way that operation applies to. For the data cache, 106 | values 0, 1, 2 and 3 are supported.. 107 | 108 | 30 109 | 2 110 | 111 | 112 | 113 | 114 | DCCIMVAC 115 | Data cache clean and invalidate by address to the PoC 116 | 0x20 117 | 32 118 | 0x0 119 | 0xFFFFFFFF 120 | write-only 121 | 122 | 123 | DCCISW 124 | Data cache clean and invalidate by set/way 125 | 0x24 126 | 32 127 | 0x0 128 | 0xFFFFFFFF 129 | write-only 130 | 131 | 132 | Set 133 | Set/index that operation applies to. The number of 134 | indices in a cache depends on the configured cache size. When 135 | this is less than the maximum, use the LSB of this field. 136 | 137 | 5 138 | 9 139 | 140 | 141 | Way 142 | Way that operation applies to. For the data cache, 143 | values 0, 1, 2 and 3 are supported.. 144 | 145 | 30 146 | 2 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/systick.part: -------------------------------------------------------------------------------- 1 | 2 | SysTick 3 | 24Bit System Tick Timer for use in RTOS 4 | 0xE000E010 5 | SYST_ 6 | 7 | 8 | 0 9 | 0x10 10 | registers 11 | 12 | 13 | 14 | 15 | CSR 16 | SysTick Control and Status Register 17 | 0 18 | 32 19 | 0x4 20 | 0xFFFFFFFF 21 | 22 | 23 | ENABLE 24 | Enable SysTick Timer 25 | 0 26 | 1 27 | read-write 28 | 29 | 30 | Disable 31 | counter disabled 32 | 0 33 | 34 | 35 | Enable 36 | counter enabled 37 | 1 38 | 39 | 40 | 41 | 42 | TICKINT 43 | Generate Tick Interrupt 44 | 1 45 | 1 46 | read-write 47 | 48 | 49 | Disable 50 | Counting down to zero asserts the 51 | SysTick exception request 52 | 0 53 | 54 | 55 | Enable 56 | Counting down to zero does not assert the 57 | SysTick exception request 58 | 1 59 | 60 | 61 | 62 | 63 | CLKSOURCE 64 | Source to count from 65 | 2 66 | 1 67 | read-write 68 | 69 | 70 | External_Clk 71 | External Clock 72 | 0 73 | 74 | 75 | CPU_Clk 76 | CPU Clock 77 | 1 78 | 79 | 80 | 81 | 82 | COUNTFLAG 83 | SysTick counted to zero 84 | 16 85 | 1 86 | read-write 87 | 88 | 89 | 90 | 91 | RVR 92 | SysTick Reload Value Register 93 | 0x4 94 | 32 95 | 0 96 | 0xFFFFFFFF 97 | 98 | 99 | RELOAD 100 | Value to auto reload SysTick after reaching zero 101 | 0 102 | 24 103 | read-write 104 | 105 | 106 | 107 | 108 | CVR 109 | SysTick Current Value Register 110 | 0x8 111 | 32 112 | 0 113 | 0xFFFFFFFF 114 | 115 | 116 | CURRENT 117 | Current value 118 | 0 119 | 24 120 | read-write 121 | 122 | 123 | 124 | 125 | CALIB 126 | SysTick Calibration Value Register 127 | 0xC 128 | 32 129 | 0 130 | 0xFFFFFFFF 131 | 132 | 133 | TENMS 134 | Reload value to use for 10ms timing 135 | 0 136 | 24 137 | read-only 138 | 139 | 140 | SKEW 141 | Clock Skew 142 | 30 143 | 1 144 | read-only 145 | 146 | 147 | Exact 148 | 10ms calibration value is exact 149 | 0 150 | 151 | 152 | Inexact 153 | 10ms calibration value is inexact, because of the clock frequency 154 | 1 155 | 156 | 157 | 158 | 159 | NOREF 160 | No Ref 161 | 31 162 | 1 163 | read-only 164 | 165 | 166 | Ref_Clk_Available 167 | Ref Clk available 168 | 0 169 | 170 | 171 | Ref_Clk_Unavailable 172 | Ref Clk not available 173 | 1 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | -------------------------------------------------------------------------------- /src/descriptors-cluster.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2019, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Containers.Vectors; 21 | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; 22 | 23 | with DOM.Core; 24 | 25 | with Ada_Gen; use Ada_Gen; 26 | with Base_Types; use Base_Types; 27 | with Base_Types.Register_Properties; use Base_Types.Register_Properties; 28 | 29 | with Descriptors.Register; use Descriptors.Register; 30 | 31 | -- Decodes and then dumps the elements of the SVD file. 32 | package Descriptors.Cluster is 33 | 34 | type Cluster_T; 35 | type Cluster_Access is access all Cluster_T; 36 | 37 | type Cluster_Db is interface; 38 | 39 | function Get_Cluster 40 | (Db : Cluster_Db; 41 | XML_Id : String) return Cluster_Access is abstract; 42 | 43 | type Peripheral_Element_Type is (Register_Element, Cluster_Element); 44 | 45 | type Peripheral_Element (Kind : Peripheral_Element_Type := Register_Element) 46 | is record 47 | case Kind is 48 | when Register_Element => 49 | Reg : Register_Access; 50 | when Cluster_Element => 51 | Cluster : Cluster_Access; 52 | end case; 53 | end record; 54 | 55 | function "+" (Reg : Register_Access) return Peripheral_Element; 56 | function "+" (Cluster : Cluster_Access) return Peripheral_Element; 57 | function Equal (E1, E2 : Peripheral_Element) return Boolean; 58 | function Deep_Copy (E : Peripheral_Element) return Peripheral_Element; 59 | function Address_Offset (Elt : Peripheral_Element) return Natural; 60 | function Is_Overlapping (Elt : Peripheral_Element) return Boolean; 61 | 62 | package Peripheral_Element_Vectors is new Ada.Containers.Vectors 63 | (Positive, Peripheral_Element, Equal); 64 | 65 | procedure Process_Overlapping_Registers 66 | (Reg_Set : Peripheral_Element_Vectors.Vector; 67 | Found : out Boolean); 68 | -- Detect any overlapping registers and, for those that overlap together, 69 | -- mark them as such and determine a common name. Found indicates whether 70 | -- any overlapping registers were identified. 71 | 72 | procedure Find_Common_Types (Elts : Peripheral_Element_Vectors.Vector); 73 | 74 | function Get_Discriminent_Type 75 | (Reg_Set : Peripheral_Element_Vectors.Vector; 76 | Spec : in out Ada_Gen.Ada_Spec; 77 | Type_Name : String) return Ada_Type_Enum; 78 | 79 | procedure Dump_Peripheral_Elements 80 | (Parent : in out Ada_Gen.Ada_Type_Record'Class; 81 | Elts : Peripheral_Element_Vectors.Vector); 82 | 83 | type Cluster_T is new Register_Db and Cluster_Db with record 84 | Name : Unbounded_String; 85 | Xml_Id : Unbounded_String; 86 | Type_Name : Unbounded_String; 87 | 88 | -- When two clusters are identical, the second register will not 89 | -- generate an Ada type. We reference the first register here to 90 | -- keep track of the type name. 91 | Type_Holder : Cluster_Access := null; 92 | 93 | Ada_Type : Type_Holders.Holder; 94 | Description : Unbounded_String; 95 | 96 | -- When two registers are at the same location, we specify a shared 97 | -- common union type name here to support this overlapping 98 | Is_Overlapping : Boolean := False; 99 | Overlap_Suffix : Unbounded_String; 100 | 101 | Address_Offset : Natural; 102 | Reg_Properties : Register_Properties_T := Null_Register_Property; 103 | Dim : Positive := 1; 104 | Dim_Increment : Natural := 4; 105 | Dim_Index : Unbounded_String; 106 | Content : Peripheral_Element_Vectors.Vector; 107 | end record; 108 | 109 | function Equal (C1, C2 : Cluster_Access) return Boolean; 110 | 111 | function Read_Cluster 112 | (Elt : DOM.Core.Element; 113 | Prepend : Unbounded_String; 114 | Append : Unbounded_String; 115 | Reg_Properties : Register_Properties_T; 116 | Db : Cluster_Db'Class) return Cluster_T; 117 | 118 | function Deep_Copy (Cluster : Cluster_Access) return Cluster_Access; 119 | 120 | overriding function Get_Register 121 | (Db : Cluster_T; 122 | XML_Id : String) return Register_Access; 123 | 124 | overriding function Get_Cluster 125 | (Db : Cluster_T; 126 | XML_Id : String) return Cluster_Access; 127 | 128 | function Get_Size (Cluster : Cluster_T) return Positive; 129 | 130 | procedure Dump 131 | (Spec : in out Ada_Gen.Ada_Spec; 132 | Cluster : Cluster_Access); 133 | 134 | private 135 | 136 | function Name (Elt : Peripheral_Element) return Unbounded_String 137 | is (case Elt.Kind is 138 | when Register_Element => Elt.Reg.Name, 139 | when Cluster_Element => Elt.Cluster.Name); 140 | 141 | function Address_Offset (Elt : Peripheral_Element) return Natural 142 | is (case Elt.Kind is 143 | when Register_Element => Elt.Reg.Address_Offset, 144 | when Cluster_Element => Elt.Cluster.Address_Offset); 145 | 146 | function Is_Overlapping (Elt : Peripheral_Element) return Boolean 147 | is (case Elt.Kind is 148 | when Register_Element => Elt.Reg.Is_Overlapping, 149 | when Cluster_Element => Elt.Cluster.Is_Overlapping); 150 | 151 | function Overlap_Suffix 152 | (Elt : Peripheral_Element) return Unbounded_String 153 | is (case Elt.Kind is 154 | when Register_Element => Elt.Reg.Overlap_Suffix, 155 | when Cluster_Element => Elt.Cluster.Overlap_Suffix); 156 | 157 | function "+" (Reg : Register_Access) return Peripheral_Element 158 | is ((Register_Element, Reg)); 159 | 160 | function "+" (Cluster : Cluster_Access) return Peripheral_Element 161 | is ((Cluster_Element, Cluster)); 162 | 163 | function Equal (E1, E2 : Peripheral_Element) return Boolean is 164 | (E1.Kind = E2.Kind and then 165 | (case E1.Kind is 166 | when Register_Element => Equal (E1.Reg, E2.Reg), 167 | when Cluster_Element => Equal (E1.Cluster, E2.Cluster))); 168 | 169 | function Deep_Copy (E : Peripheral_Element) return Peripheral_Element is 170 | (case E.Kind is 171 | when Register_Element => 172 | (Register_Element, new Register_T'(E.Reg.all)), 173 | when Cluster_Element => 174 | (Cluster_Element, Deep_Copy (E.Cluster))); 175 | 176 | end Descriptors.Cluster; 177 | -------------------------------------------------------------------------------- /src/descriptors-enumerate.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2020, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; 21 | with Ada.Text_IO; 22 | with Interfaces; 23 | 24 | with DOM.Core; use DOM.Core; 25 | with DOM.Core.Elements; use DOM.Core.Elements; 26 | with DOM.Core.Nodes; 27 | 28 | package body Descriptors.Enumerate is 29 | 30 | procedure Read_Value 31 | (Elt : DOM.Core.Element; 32 | Write_Only : Boolean; 33 | Values : in out Enumerate_Values_Vectors.Vector); 34 | -- Reads the enum value from the DOM element 35 | 36 | ---------------- 37 | -- Read_Value -- 38 | ---------------- 39 | 40 | procedure Read_Value 41 | (Elt : DOM.Core.Element; 42 | Write_Only : Boolean; 43 | Values : in out Enumerate_Values_Vectors.Vector) 44 | is 45 | procedure Read_Value 46 | (Val : String; 47 | Name : String); 48 | 49 | List : constant Node_List := Nodes.Child_Nodes (Elt); 50 | Result : Enumerate_Value; 51 | Has_X : Boolean := False; 52 | 53 | procedure Read_Value 54 | (Val : String; 55 | Name : String) 56 | is 57 | begin 58 | for J in Val'Range loop 59 | if Val (J) = 'x' then 60 | Read_Value 61 | (Val (Val'First .. J - 1) & "0" & Val (J + 1 .. Val'Last), 62 | Name & "0"); 63 | Read_Value 64 | (Val (Val'First .. J - 1) & "1" & Val (J + 1 .. Val'Last), 65 | Name & "1"); 66 | return; 67 | end if; 68 | end loop; 69 | 70 | Result.Name := To_Unbounded_String (Name); 71 | Result.Value := Interfaces.Unsigned_64'Value ("2" & Val & "#"); 72 | Values.Append (Result); 73 | end Read_Value; 74 | 75 | begin 76 | for J in 0 .. Nodes.Length (List) - 1 loop 77 | if Nodes.Node_Type (Nodes.Item (List, J)) = Element_Node then 78 | declare 79 | Child : constant DOM.Core.Element := DOM.Core.Element (Nodes.Item (List, J)); 80 | Tag : String renames Elements.Get_Tag_Name (Child); 81 | begin 82 | if Tag = "name" then 83 | Result.Name := Get_Value (Child); 84 | 85 | elsif Tag = "description" then 86 | Result.Descr := Get_Value (Child); 87 | 88 | elsif Tag = "value" then 89 | declare 90 | S : String := Get_Value (Child); 91 | begin 92 | if S'Length >= 2 93 | and then S (S'First) = '#' 94 | then 95 | Has_X := False; 96 | 97 | for J in S'Range loop 98 | if S (J) = 'x' or else S (J) = 'X' then 99 | if Write_Only then 100 | -- Easy case: we just fill with '0' 101 | S (J) := '0'; 102 | else 103 | Has_X := True; 104 | end if; 105 | end if; 106 | end loop; 107 | 108 | if not Has_X then 109 | Result.Value := Interfaces.Unsigned_64'Value ("2#" & S (S'First + 1 .. S'Last) & "#"); 110 | else 111 | Read_Value (S, To_String (Result.Name)); 112 | end if; 113 | else 114 | 115 | Result.Value := Get_Value (Child); 116 | end if; 117 | end; 118 | 119 | Result.IsDefault := False; 120 | 121 | elsif Tag = "isDefault" then 122 | Result.Value := 0; 123 | Result.IsDefault := True; 124 | 125 | else 126 | Ada.Text_IO.Put_Line ("*** WARNING: ignoring enumerate element " & Tag & " at " & Full_Name (Child)); 127 | end if; 128 | end; 129 | end if; 130 | end loop; 131 | 132 | if not Has_X then 133 | Values.Append (Result); 134 | end if; 135 | end Read_Value; 136 | 137 | -------------------- 138 | -- Read_Enumerate -- 139 | -------------------- 140 | 141 | function Read_Enumerate 142 | (Elt : DOM.Core.Element; 143 | Vector : Enumerate_Vectors.Vector; 144 | Write_Only : Boolean) 145 | return Enumerate_T 146 | is 147 | List : constant Node_List := Nodes.Child_Nodes (Elt); 148 | Result : Enumerate_T; 149 | Derived_From : constant String := Elements.Get_Attribute (Elt, "derivedFrom"); 150 | begin 151 | if Derived_From /= "" then 152 | declare 153 | Found : Boolean := False; 154 | begin 155 | for Oth of Vector loop 156 | if Unbounded.To_String (Oth.Name) = Derived_From then 157 | -- Copy the derived from enumerate type into the new value 158 | Result := Oth; 159 | Found := True; 160 | exit; 161 | end if; 162 | end loop; 163 | 164 | if not Found then 165 | raise Constraint_Error with 166 | "enumerate 'derivedFrom' is not known: " & Derived_From; 167 | end if; 168 | end; 169 | end if; 170 | 171 | for J in 0 .. Nodes.Length (List) - 1 loop 172 | if Nodes.Node_Type (Nodes.Item (List, J)) = Element_Node then 173 | declare 174 | Child : constant DOM.Core.Element := DOM.Core.Element (Nodes.Item (List, J)); 175 | Tag : String renames Elements.Get_Tag_Name (Child); 176 | begin 177 | if Tag = "name" then 178 | Result.Name := Get_Value (Child); 179 | 180 | elsif Tag = "usage" then 181 | Result.Usage := Get_Value (Child); 182 | 183 | elsif Tag = "enumeratedValue" then 184 | Read_Value (Child, Write_Only, Result.Values); 185 | 186 | else 187 | Ada.Text_IO.Put_Line ("*** WARNING: ignoring enumerate element " & Tag & " at " & Full_Name (Child)); 188 | end if; 189 | end; 190 | end if; 191 | end loop; 192 | 193 | return Result; 194 | end Read_Enumerate; 195 | 196 | end Descriptors.Enumerate; 197 | -------------------------------------------------------------------------------- /src/base_types.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Interfaces; use Interfaces; 21 | 22 | with Ada.Containers.Vectors; 23 | with Ada.Strings.Unbounded; use Ada.Strings; 24 | 25 | with DOM.Core; 26 | 27 | -- Package responsible for defining and decoding the basic types of a SVD 28 | -- file. 29 | package Base_Types is 30 | 31 | subtype Unsigned is Unsigned_64; 32 | -- We have to use a 64-bit type here, as the analyzed board can manipulate 33 | -- potentially 64-bit addresses. 34 | 35 | subtype NVIC_Priority_Type is Unsigned range 2 .. 8; 36 | 37 | -- pre-defines the tokens for specifying the endianess of the device 38 | type Endian_Type is 39 | (Undefined_Endian, 40 | Little_Endian, 41 | Big_Endian, 42 | Selectable_Endian, 43 | Other_Endian); 44 | 45 | -- Data_Type pre-defines the tokens in line with CMSIS data type 46 | -- definitions 47 | type Data_Type is 48 | (Undefined_Data_Type, 49 | uint8_t_Data, 50 | uint16_t_Data, 51 | uint32_t_Data, 52 | uint64_t_Data, 53 | int8_t_Data, 54 | int16_t_Data, 55 | int32_t_Data, 56 | int64_t_Data, 57 | puint8_t_Data, 58 | puint16_t_Data, 59 | puint32_t_Data, 60 | puint64_t_Data, 61 | pint8_t_Data, 62 | pint16_t_Data, 63 | pint32_t_Data, 64 | pint64_t_Data); 65 | 66 | -- Protection Access Attribute 67 | type Protection_Type is 68 | (Undefined_Protection, 69 | Secure_Protection, 70 | Non_Secure_Protection, 71 | Privileged_Protection); 72 | 73 | -- Access_Type specfies the pre-defined tokens for the available accesses 74 | type Access_Type is 75 | (Read_Only, 76 | Write_Only, 77 | Read_Write, 78 | Write_Once, 79 | Read_Write_Once); 80 | 81 | -- Modified_Write_Values_Type specifies the pre-defined tokens for the 82 | -- write side effects 83 | type Modified_Write_Values_Type is 84 | (One_To_Clear, 85 | One_To_Set, 86 | One_To_Toggle, 87 | Zero_To_Clear, 88 | Zero_To_Set, 89 | Zero_To_Toggle, 90 | Clear, 91 | Set, 92 | Modify); 93 | 94 | -- Read_Action_Type specifies the pre-defined tokens for read side effects 95 | type Read_Action_Type is 96 | (Undefined_Read_Action, 97 | Clear, 98 | Set, 99 | Modify, 100 | Modify_Exernal); 101 | 102 | -- Enum_Usage_Type specifies the pre-defined tokens for selecting what 103 | -- access types an enumeratedValues set is associated with 104 | type Enum_Usage_Type is 105 | (Undefined_Enum_Usage, 106 | Read, 107 | Write, 108 | Read_Write); 109 | 110 | -- Bit_Range_Type specifies the bit numbers to be restricted values 111 | -- from 0 - 69 112 | type Bit_Range_Type is record 113 | From, To : Natural; 114 | end record; 115 | 116 | -- Write_Constraint_Type specifies how to describe the restriction of the 117 | -- allowed values that can be written to a resource 118 | type Write_Constraint_Type is record 119 | Write_As_Read : Boolean; 120 | Use_Enumerated_Values : Boolean; 121 | Minimum : Unsigned; 122 | Maximum : Unsigned; 123 | end record; 124 | 125 | type Address_Block_Usage_Type is 126 | (Registers_Usage, 127 | Buffer_Usage, 128 | Reserved_Usage); 129 | 130 | -- Address_Block_Type specifies the elements to describe an address block 131 | type Address_Block_Type is record 132 | Offset : Unsigned; 133 | Size : Unsigned; 134 | Usage : Address_Block_Usage_Type; 135 | Protection : Protection_Type := Undefined_Protection; 136 | end record; 137 | 138 | package Address_Block_Vectors is new Ada.Containers.Vectors 139 | (Positive, Address_Block_Type); 140 | 141 | type Interrupt_Type is record 142 | Name : Unbounded.Unbounded_String; 143 | Description : Unbounded.Unbounded_String; 144 | Value : Integer; 145 | end record; 146 | 147 | overriding 148 | function "=" (I1, I2 : Interrupt_Type) return Boolean; 149 | 150 | function "<" (I1, I2 : Interrupt_Type) return Boolean; 151 | 152 | package Interrupt_Vectors is new Ada.Containers.Vectors 153 | (Positive, Interrupt_Type); 154 | 155 | generic 156 | type T is private; 157 | with procedure Read_Elt 158 | (Tag : String; 159 | Elt : DOM.Core.Element; 160 | Value : in out T); 161 | procedure Gen_DOM_Iter 162 | (Elt : DOM.Core.Element; 163 | Obj : in out T); 164 | 165 | function To_Hex (Val : Natural) return String; 166 | function To_Hex (Val : Unsigned) return String; 167 | function To_String (Val : Integer) return String; 168 | function To_String (Val : Unsigned) return String; 169 | 170 | function Target_Type 171 | (Size : Natural; 172 | Fully_Qualified : Boolean := True) return String; 173 | -- Returns the name of the type on the target given the size of the int 174 | 175 | function Get_Value (Elt : DOM.Core.Element) return String; 176 | function Get_Value (Elt : DOM.Core.Element) return Unbounded.Unbounded_String; 177 | function Get_Value (Elt : DOM.Core.Element) return Boolean; 178 | function Get_Value (Elt : DOM.Core.Element) return Natural; 179 | function Get_Value (Elt : DOM.Core.Element) return Unsigned; 180 | function Get_Value (Elt : DOM.Core.Element) return Access_Type; 181 | function Get_Value (Elt : DOM.Core.Element) return Protection_Type; 182 | function Get_Value (Elt : DOM.Core.Element) return Endian_Type; 183 | function Get_Value (Elt : DOM.Core.Element) return Data_Type; 184 | function Get_Value (Elt : DOM.Core.Element) return Modified_Write_Values_Type; 185 | function Get_Value (Elt : DOM.Core.Element) return Read_Action_Type; 186 | function Get_Value (Elt : DOM.Core.Element) return Bit_Range_Type; 187 | function Get_Value (Elt : DOM.Core.Element) return Write_Constraint_Type; 188 | function Get_Value (Elt : DOM.Core.Element) return Address_Block_Type; 189 | function Get_Value (Elt : DOM.Core.Element) return Interrupt_Type; 190 | function Get_Value (Elt : DOM.Core.Element) return Enum_Usage_Type; 191 | 192 | function Common_Prefix 193 | (Name1, Name2 : Unbounded.Unbounded_String) 194 | return Unbounded.Unbounded_String; 195 | -- Returns the prefix common to Name1 and Name2 if any, or 196 | -- Null_Unbounded_String 197 | 198 | function Full_Name (Elt : DOM.Core.Node) return String; 199 | 200 | end Base_Types; 201 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/fpu.part: -------------------------------------------------------------------------------- 1 | 2 | FPU 3 | Floating Point Unit 4 | 0xE000ED88 5 | 6 | 7 | 0 8 | 0x1B8 9 | registers 10 | 11 | 12 | 13 | 14 | CPACR 15 | Coprocessor Access Control Register 16 | 0 17 | 32 18 | 0x0 19 | 0xFFFFFFFF 20 | 21 | 22 | CP10 23 | Access privileges for coprocessor 10. 24 | 20 25 | 2 26 | read-write 27 | 28 | 29 | Access_Denied 30 | Any attempted access generates a NOCP 31 | UsageFault. 32 | 0x0 33 | 34 | 35 | Privileged 36 | Privileged access only. An unprivileged 37 | addess generates a NOCP 38 | UsageFault. 39 | 0x1 40 | 41 | 42 | Full_Access 43 | Full access. 44 | 0x3 45 | 46 | 47 | 48 | 49 | CP11 50 | Access privileges for coprocessor 11. 51 | 22 52 | 2 53 | read-write 54 | 55 | 56 | Access_Denied 57 | Any attempted access generates a NOCP 58 | UsageFault. 59 | 0x0 60 | 61 | 62 | Privileged 63 | Privileged access only. An unprivileged 64 | addess generates a NOCP 65 | UsageFault. 66 | 0x1 67 | 68 | 69 | Full_Access 70 | Full access. 71 | 0x3 72 | 73 | 74 | 75 | 76 | 77 | 78 | FPCCR 79 | Floating-Point Context Control Register 80 | 0x1AC 81 | 32 82 | 0xC0000000 83 | 0xFFFFFFFF 84 | 85 | 86 | LSPACT 87 | Lazy state preservation activation. 88 | 0 89 | 1 90 | read-write 91 | 92 | 93 | USER 94 | If set, privilege level was user when the 95 | floating-point stack frame was allocated. 96 | 1 97 | 1 98 | read-only 99 | 100 | 101 | THREAD 102 | If set, the mode was Thread Mode when the 103 | floating-point stack frame was allocated. 104 | 3 105 | 1 106 | read-only 107 | 108 | 109 | HFRDY 110 | If set, priority permitted setting the HardFault 111 | handler to the pending state when the floating-point stack 112 | frame was allocated. 113 | 4 114 | 1 115 | read-only 116 | 117 | 118 | MMRDY 119 | If set, MemManage is enabled and priority permitted 120 | setting the MemManage handler to the pending state when the 121 | floating-point stack frame was allocated. 122 | 5 123 | 1 124 | read-only 125 | 126 | 127 | BFRDY 128 | If set, BusFault is enabled and priority permitted 129 | setting the BusFault handler to the pending state when the 130 | floating-point stack frame was allocated. 131 | 6 132 | 1 133 | read-only 134 | 135 | 136 | MONRDY 137 | If set, DebugMonitor is enabled and priority 138 | permitted setting the DebugMonitor handler to the pending state 139 | when the floating-point stack frame was allocated. 140 | 8 141 | 1 142 | read-only 143 | 144 | 145 | LSPEN 146 | Enables automatic lazy state preservation for 147 | floating-point context. 148 | 30 149 | 1 150 | read-write 151 | 152 | 153 | ASPEN 154 | Enables CONTROL.FPCA setting on execution of 155 | a floating point instruction. This results in automatic 156 | hardware state preservation and restoration, for floating-point 157 | context, on exception entry and exit. 158 | 31 159 | 1 160 | read-write 161 | 162 | 163 | 164 | 165 | FPCAR 166 | Floating-Point Context Address Register 167 | 0x1B0 168 | 32 169 | 0x0 170 | 0xFFFFFFFF 171 | 172 | 173 | ADDRESS 174 | The FPCAR register holds the location of the 175 | unpopulated floating-point register space allocated on an 176 | exception stack frame. 177 | 3 178 | 29 179 | read-write 180 | 181 | 182 | 183 | 184 | FPDSCR 185 | Floating-Point Default Status Control Register 186 | 0x1B4 187 | 32 188 | 0x0 189 | 0xFFFFFFFF 190 | 191 | 192 | RMode 193 | Default value for FPSCR.RMode. 194 | 22 195 | 2 196 | read-write 197 | 198 | 199 | FZ 200 | Default value for FPSCR.FZ. 201 | 24 202 | 1 203 | read-write 204 | 205 | 206 | DN 207 | Default value for FPSCR.DN. 208 | 25 209 | 1 210 | read-write 211 | 212 | 213 | AHP 214 | Default value for FPSCR.AHP. 215 | 26 216 | 1 217 | read-write 218 | 219 | 220 | 221 | 222 | 223 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/pf.part: -------------------------------------------------------------------------------- 1 | 2 | PF 3 | Processor Features 4 | 0xE000ED78 5 | 6 | 0 7 | 0x10 8 | registers 9 | 10 | 11 | 12 | CLIDR 13 | Cache Level ID Register 14 | 0x0 15 | 32 16 | 0x09000003 17 | 0xFFFFFFFF 18 | 19 | 20 | ICL1 21 | An instrumentation Cache is implemented at L1 22 | 0 23 | 1 24 | read-only 25 | 26 | 27 | DCL1 28 | Data Cache is implemented at L1 29 | 1 30 | 1 31 | read-only 32 | 33 | 34 | UCL1 35 | Unified Cache is implemented at L1 36 | 2 37 | 1 38 | read-only 39 | 40 | 41 | LoC 42 | Level of Coherency 43 | 24 44 | 3 45 | read-only 46 | 47 | 48 | Level_1 49 | Level 1, if neither instruction nor data cache is implemented 50 | 0x0 51 | 52 | 53 | Level_2 54 | Level 2, if either cache is implemented 55 | 0x1 56 | 57 | 58 | 59 | 60 | LoU 61 | Level of Unification 62 | 27 63 | 3 64 | read-only 65 | 66 | 67 | Level_1 68 | Level 1, if neither instruction nor data cache is implemented 69 | 0x0 70 | 71 | 72 | Level_2 73 | Level 2, if either cache is implemented 74 | 0x1 75 | 76 | 77 | 78 | 79 | 80 | 81 | CTR 82 | Cache Type Register 83 | 0x4 84 | 32 85 | 0x8303C003 86 | 0xFFFFFFFF 87 | 88 | 89 | IMinLine 90 | Smallest cache line of all the instruction caches. 91 | 0 92 | 4 93 | read-only 94 | 95 | 96 | Line_8_Words 97 | 8 words for the Cortex-M7 processor. 98 | 0x3 99 | 100 | 101 | 102 | 103 | DMinLine 104 | Smallest cache line of all the data caches. 105 | 16 106 | 4 107 | read-only 108 | 109 | 110 | Line_8_Words 111 | 8 words for the Cortex-M7 processor. 112 | 0x3 113 | 114 | 115 | 116 | 117 | ERG 118 | Exclusive Reservation Granule. 119 | The local monitor within the processor does not hold any physical 120 | address. It treats any STREX instruction access as matching the 121 | address of the previous LDREX instruction. This means that the 122 | implemented exclusive reservation granule is the entire memory 123 | address range. 124 | 20 125 | 4 126 | read-only 127 | 128 | 129 | CWG 130 | Cache Writable Granule. 131 | 24 132 | 4 133 | read-only 134 | 135 | 136 | Granularity_8_Words 137 | 8 words granularity for the Cortex-M7 138 | processor. 139 | 0x3 140 | 141 | 142 | 143 | 144 | Format 145 | Cache Writable Granule. 146 | 29 147 | 3 148 | read-only 149 | 150 | 151 | ARMv7 152 | ARMv7 register forat. 153 | 0x4 154 | 155 | 156 | 157 | 158 | 159 | 160 | CCSIDR 161 | Cache Size ID Register 162 | 0x8 163 | 32 164 | 0x0 165 | 0xFFFFFFFF 166 | 167 | 168 | LineSize 169 | Indicates the number of words in each cache line. 170 | Encoded as 2 - log(2) number of words. 171 | e.g. 0 means 4 words, 1 means 8 words. 172 | 0 173 | 3 174 | read-only 175 | 176 | 177 | Associativity 178 | Indicates the number of ways as (ways - 1) 179 | 3 180 | 10 181 | read-only 182 | 183 | 184 | NumSets 185 | Indicates the number of sets as (sets - 1) 186 | 13 187 | 15 188 | read-only 189 | 190 | 191 | WA 192 | Indicates support available for write allocation. 193 | 28 194 | 1 195 | read-only 196 | 197 | 198 | RA 199 | Indicates support available for read allocation. 200 | 29 201 | 1 202 | read-only 203 | 204 | 205 | WB 206 | Indicates support available for write back. 207 | 30 208 | 1 209 | read-only 210 | 211 | 212 | WT 213 | Indicates support available for write through. 214 | 31 215 | 1 216 | read-only 217 | 218 | 219 | 220 | 221 | CSSELR 222 | Cache Size Selection Register 223 | 0xC 224 | 32 225 | 0x0 226 | 0xFFFFFFFF 227 | 228 | 229 | InD 230 | Selects the cache currently visible in the CCSIDR. 231 | 0 232 | 1 233 | read-write 234 | 235 | 236 | Data_Cache 237 | Data cache is selected. 238 | 0x0 239 | 240 | 241 | Instruction_Cache 242 | Instruction cache is selected. 243 | 0x1 244 | 245 | 246 | 247 | 248 | Level 249 | Identifies the cache level selected. 250 | 1 251 | 3 252 | read-write 253 | 254 | 255 | Level_1 256 | Level 1 cache is selected. 257 | 0x0 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/dwt_m4.part: -------------------------------------------------------------------------------- 1 | 2 | DWT 3 | 1.0 4 | Data Watchpoint Trace 5 | 0xE0001000 6 | read-write 7 | 8 | 9 | 0 10 | 0x5C 11 | registers 12 | 13 | 14 | 15 | 16 | CTRL 17 | Control Register 18 | 0 19 | 32 20 | 21 | 22 | NUMCOMP 23 | Number of comparators 24 | 28 25 | 4 26 | read-write 27 | 28 | 29 | NOTRCPKT 30 | No trace sampling and exception tracing 31 | 27 32 | 1 33 | read-write 34 | 35 | 36 | NOEXTTRIG 37 | No external match signals 38 | 26 39 | 1 40 | read-write 41 | 42 | 43 | NOCYCCNT 44 | No cycle counter 45 | 25 46 | 1 47 | read-write 48 | 49 | 50 | NOPRFCNT 51 | No profiling counters 52 | 24 53 | 1 54 | read-write 55 | 56 | 57 | Reserved_23 58 | Reserved bit 23 59 | 23 60 | 1 61 | read-only 62 | 63 | 64 | CYCEVTENA 65 | enable Cycle count event 66 | 22 67 | 1 68 | read-write 69 | 70 | 71 | FOLDEVTENA 72 | enable Folded instruction count event 73 | 21 74 | 1 75 | read-write 76 | 77 | 78 | LSUEVTENA 79 | enable Load Store Unit (LSU) count event 80 | 20 81 | 1 82 | read-write 83 | 84 | 85 | SLEEPEVTENA 86 | enable Sleep count event 87 | 19 88 | 1 89 | read-write 90 | 91 | 92 | EXCEVTENA 93 | enable interrupt overhead event 94 | 18 95 | 1 96 | read-write 97 | 98 | 99 | CPIEVTENA 100 | enable CPI count event 101 | 17 102 | 1 103 | read-write 104 | 105 | 106 | EXCTRCENA 107 | enable interrupt event tracing 108 | 16 109 | 1 110 | read-write 111 | 112 | 113 | Reserved_13_15 114 | Reserved bits 13..15 115 | 13 116 | 3 117 | read-write 118 | 119 | 120 | PCSAMPLENA 121 | enable POSTCNT as timer for PC sample packets 122 | 12 123 | 1 124 | read-write 125 | 126 | 127 | SYNCTAP 128 | ??? 129 | 10 130 | 2 131 | read-write 132 | 133 | 134 | CYCTAP 135 | ??? 136 | 9 137 | 1 138 | read-write 139 | 140 | 141 | POSTINIT 142 | ??? 143 | 5 144 | 4 145 | read-write 146 | 147 | 148 | POSTPRESET 149 | ??? 150 | 1 151 | 4 152 | read-write 153 | 154 | 155 | CYCCNTENA 156 | enable cycle counter 157 | 0 158 | 1 159 | read-write 160 | 161 | 162 | 163 | 164 | CYCCNT 165 | Cycle Count Register 166 | 4 167 | 32 168 | 169 | 170 | CPICNT 171 | CPI Count Register 172 | 8 173 | 32 174 | 175 | 176 | EXCCNT 177 | Exception Overhead Count Register 178 | 0xC 179 | 32 180 | 181 | 182 | SLEEPCNT 183 | Sleep Count Register 184 | 0x10 185 | 32 186 | 187 | 188 | LSUCNT 189 | LSU Count Register 190 | 0x14 191 | 32 192 | 193 | 194 | FOLDCNT 195 | Folded-instruction Count Register 196 | 0x18 197 | 32 198 | 199 | 200 | PCSR 201 | Program Counter Sample Register 202 | 0x1C 203 | 32 204 | 205 | 206 | COMP0 207 | Comparator Register 0 208 | 0x20 209 | 32 210 | 211 | 212 | MASK0 213 | Mask Register 0 214 | 0x24 215 | 32 216 | 217 | 218 | FUNCTION0 219 | Function Register 0 220 | 0x28 221 | 32 222 | 223 | 224 | RESERVED0 225 | Reserved 0 226 | 0x2C 227 | 32 228 | 229 | 230 | COMP1 231 | Comparator Register 1 232 | 0x30 233 | 32 234 | 235 | 236 | MASK1 237 | Mask Register 1 238 | 0x34 239 | 32 240 | 241 | 242 | FUNCTION1 243 | Function Register 1 244 | 0x38 245 | 32 246 | 247 | 248 | RESERVED1 249 | Reserved 1 250 | 0x3C 251 | 32 252 | 253 | 254 | COMP2 255 | Comparator Register 2 256 | 0x40 257 | 32 258 | 259 | 260 | MASK2 261 | Mask Register 2 262 | 0x44 263 | 32 264 | 265 | 266 | FUNCTION2 267 | Function Register 2 268 | 0x48 269 | 32 270 | 271 | 272 | RESERVED2 273 | Reserved 2 274 | 0x4C 275 | 32 276 | 277 | 278 | COMP3 279 | Comparator Register 3 280 | 0x50 281 | 32 282 | 283 | 284 | MASK3 285 | Mask Register 3 286 | 0x54 287 | 32 288 | 289 | 290 | FUNCTION3 291 | Function Register 3 292 | 0x58 293 | 32 294 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/dwt_m7.part: -------------------------------------------------------------------------------- 1 | 2 | DWT 3 | 1.0 4 | Data Watchpoint Trace 5 | 0xE0001000 6 | read-write 7 | 8 | 9 | 0 10 | 0xFB8 11 | registers 12 | 13 | 14 | 15 | 16 | CTRL 17 | Control Register 18 | 0 19 | 32 20 | 21 | 22 | NUMCOMP 23 | Number of comparators 24 | 28 25 | 4 26 | read-write 27 | 28 | 29 | NOTRCPKT 30 | No trace sampling and exception tracing 31 | 27 32 | 1 33 | read-write 34 | 35 | 36 | NOEXTTRIG 37 | No external match signals 38 | 26 39 | 1 40 | read-write 41 | 42 | 43 | NOCYCCNT 44 | No cycle counter 45 | 25 46 | 1 47 | read-write 48 | 49 | 50 | NOPRFCNT 51 | No profiling counters 52 | 24 53 | 1 54 | read-write 55 | 56 | 57 | Reserved_23 58 | Reserved bit 23 59 | 23 60 | 1 61 | read-only 62 | 63 | 64 | CYCEVTENA 65 | enable Cycle count event 66 | 22 67 | 1 68 | read-write 69 | 70 | 71 | FOLDEVTENA 72 | enable Folded instruction count event 73 | 21 74 | 1 75 | read-write 76 | 77 | 78 | LSUEVTENA 79 | enable Load Store Unit (LSU) count event 80 | 20 81 | 1 82 | read-write 83 | 84 | 85 | SLEEPEVTENA 86 | enable Sleep count event 87 | 19 88 | 1 89 | read-write 90 | 91 | 92 | EXCEVTENA 93 | enable interrupt overhead event 94 | 18 95 | 1 96 | read-write 97 | 98 | 99 | CPIEVTENA 100 | enable CPI count event 101 | 17 102 | 1 103 | read-write 104 | 105 | 106 | EXCTRCENA 107 | enable interrupt event tracing 108 | 16 109 | 1 110 | read-write 111 | 112 | 113 | Reserved_13_15 114 | Reserved bits 13..15 115 | 13 116 | 3 117 | read-write 118 | 119 | 120 | PCSAMPLENA 121 | enable POSTCNT as timer for PC sample packets 122 | 12 123 | 1 124 | read-write 125 | 126 | 127 | SYNCTAP 128 | ??? 129 | 10 130 | 2 131 | read-write 132 | 133 | 134 | CYCTAP 135 | ??? 136 | 9 137 | 1 138 | read-write 139 | 140 | 141 | POSTINIT 142 | ??? 143 | 5 144 | 4 145 | read-write 146 | 147 | 148 | POSTPRESET 149 | ??? 150 | 1 151 | 4 152 | read-write 153 | 154 | 155 | CYCCNTENA 156 | enable cycle counter 157 | 0 158 | 1 159 | read-write 160 | 161 | 162 | 163 | 164 | CYCCNT 165 | Cycle Count Register 166 | 4 167 | 32 168 | 169 | 170 | CPICNT 171 | CPI Count Register 172 | 8 173 | 32 174 | 175 | 176 | EXCCNT 177 | Exception Overhead Count Register 178 | 0xC 179 | 32 180 | 181 | 182 | SLEEPCNT 183 | Sleep Count Register 184 | 0x10 185 | 32 186 | 187 | 188 | LSUCNT 189 | LSU Count Register 190 | 0x14 191 | 32 192 | 193 | 194 | FOLDCNT 195 | Folded-instruction Count Register 196 | 0x18 197 | 32 198 | 199 | 200 | PCSR 201 | Program Counter Sample Register 202 | 0x1C 203 | 32 204 | read-only 205 | 206 | 207 | COMP0 208 | Comparator Register 0 209 | 0x20 210 | 32 211 | 212 | 213 | MASK0 214 | Mask Register 0 215 | 0x24 216 | 32 217 | 218 | 219 | FUNCTION0 220 | Function Register 0 221 | 0x28 222 | 32 223 | 224 | 225 | RESERVED0 226 | Reserved 0 227 | 0x2C 228 | 32 229 | 230 | 231 | COMP1 232 | Comparator Register 1 233 | 0x30 234 | 32 235 | 236 | 237 | MASK1 238 | Mask Register 1 239 | 0x34 240 | 32 241 | 242 | 243 | FUNCTION1 244 | Function Register 1 245 | 0x38 246 | 32 247 | 248 | 249 | RESERVED1 250 | Reserved 1 251 | 0x3C 252 | 32 253 | 254 | 255 | COMP2 256 | Comparator Register 2 257 | 0x40 258 | 32 259 | 260 | 261 | MASK2 262 | Mask Register 2 263 | 0x44 264 | 32 265 | 266 | 267 | FUNCTION2 268 | Function Register 2 269 | 0x48 270 | 32 271 | 272 | 273 | RESERVED2 274 | Reserved 2 275 | 0x4C 276 | 32 277 | 278 | 279 | COMP3 280 | Comparator Register 3 281 | 0x50 282 | 32 283 | 284 | 285 | MASK3 286 | Mask Register 3 287 | 0x54 288 | 32 289 | 290 | 291 | FUNCTION3 292 | Function Register 3 293 | 0x58 294 | 32 295 | 296 | 297 | LAR 298 | Lock Access Register 299 | 0xFB0 300 | 32 301 | write-only 302 | 303 | 304 | LSR 305 | Lock Status Register 306 | 0xFB4 307 | 32 308 | read-only 309 | 310 | 311 | 312 | -------------------------------------------------------------------------------- /CMSIS-SVD/Microsemi/M1AGL.svd: -------------------------------------------------------------------------------- 1 | 2 | 3 | Microsemi 4 | Microsemi 5 | M1AGL 6 | IGLOO 7 | 8 | Cortex-M1 on IGLOO FPGA 9 | 10 | 8 11 | 32 12 | 32 13 | 0x00000000 14 | 0xFFFFFFFF 15 | 16 | 17 | CM1 18 | little 19 | 20 | 21 | 22 | 23 | 24 | CoreUARTapb 25 | serial communication controller with a flexible serial data 26 | interface 27 | 28 | 0xA1000000 29 | 32 30 | read-write 31 | 32 | 33 | Core_Timer_Interrupt 34 | 1 35 | 36 | 37 | 38 | 0 39 | 0x1000 40 | registers 41 | 42 | 43 | 44 | 45 | Tx_Data 46 | Transmit Data register 47 | 0x000 48 | 49 | Value07 50 | 51 | 52 | 53 | 54 | Rx_Data 55 | Receive Data register 56 | 0x004 57 | 58 | Value07 59 | 60 | 61 | 62 | 63 | Control_1 64 | Control register 1 65 | 0x008 66 | 67 | Baud_Value07 68 | 69 | 70 | 71 | 72 | Control_2 73 | Control register 1 74 | 0x00C 75 | 76 | Bit800 77 | Parity_En11 78 | Odd_N_Even22 79 | 80 | 81 | Even 82 | 83 | 0 84 | 85 | 86 | Odd 87 | 88 | 1 89 | 90 | 91 | 92 | Baud_Value37 93 | 94 | 95 | 96 | 97 | Status 98 | Control register 1 99 | 0x010 100 | 101 | TX_Rdy00 102 | RX_Rdy11 103 | Parity_Err22 104 | Overflow33 105 | Framing_Err44 106 | 107 | 108 | 109 | 110 | Control_3 111 | Control register 1 112 | 0x014 113 | 114 | Baud_Val_Fraction02 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | CoreTimer 123 | interrupt-generating, programmable decrementing counter 124 | 0xA2000000 125 | 32 126 | read-write 127 | 128 | 129 | Core_Timer_Interrupt 130 | 1 131 | 132 | 133 | 134 | 0 135 | 0x1000 136 | registers 137 | 138 | 139 | 140 | 141 | Load_Value 142 | Counter load value 143 | 0x000 144 | 145 | Value031 146 | 147 | 148 | 149 | 150 | Current_Value 151 | Counter current value 152 | 0x004 153 | 154 | Value031 155 | 156 | 157 | 158 | 159 | Control 160 | PWM Configuration Register. 161 | 0x008 162 | 163 | 164 | Enable00 165 | 166 | Interrupt_Enable11 167 | 168 | Timer_Mode22 169 | 170 | 171 | Continuous 172 | 173 | 0 174 | 175 | 176 | One_Shot 177 | 178 | 1 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | Prescale 187 | Clock prescale setting 188 | 0x00C 189 | 190 | Value03 191 | 192 | 193 | 194 | Divide_By_2 195 | 196 | 0 197 | 198 | 199 | Divide_By_4 200 | 201 | 1 202 | 203 | 204 | Divide_By_8 205 | 206 | 2 207 | 208 | 209 | Divide_By_16 210 | 211 | 3 212 | 213 | 214 | Divide_By_32 215 | 216 | 4 217 | 218 | 219 | Divide_By_64 220 | 221 | 5 222 | 223 | 224 | Divide_By_128 225 | 226 | 6 227 | 228 | 229 | Divide_By_256 230 | 231 | 7 232 | 233 | 234 | Divide_By_512 235 | 236 | 8 237 | 238 | 239 | Divide_By_1024 240 | 241 | 9 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | Interrupt_Clear 250 | Interrupt Clear. Any write to this register will clear 251 | the interrupt. 252 | 253 | 0x010 254 | 255 | 256 | 257 | Raw_Interrupt_Status 258 | PWM Configuration Register. 259 | 0x014 260 | 261 | Pending00 262 | 263 | 264 | 265 | 266 | Masked_Interrupt_Status 267 | PWM Configuration Register. 268 | 0x018 269 | 270 | Pending00 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | CoreInterrupt 279 | Flexible Interrupt Controller for Advanced Microcontroller 280 | Bus Architecture (AMBA) Based Systems 281 | 282 | 0xA3000000 283 | 32 284 | read-write 285 | 286 | 287 | 0 288 | 0x1000 289 | registers 290 | 291 | 292 | 293 | 294 | 295 | IRQ_Soft_Interrupt 296 | Software interrupt trigger IRQs. 297 | 0x018 298 | 0x20 299 | read-write 300 | 0x00000000 301 | 302 | IRQ100 303 | IRQ211 304 | IRQ322 305 | IRQ433 306 | IRQ544 307 | IRQ655 308 | IRQ766 309 | IRQ877 310 | 311 | 312 | 313 | 314 | IRQ_Soft_Interrupt_Clear 315 | Clear soft IRQs. 316 | 0x01C 317 | 318 | 319 | 320 | IRQ_Enable 321 | Enable IRQs. 322 | 0x020 323 | 324 | 325 | 326 | IRQ_Enable_Clear 327 | Disable IRQs. 328 | 0x024 329 | 330 | 331 | 332 | IRQ_Raw_Status 333 | IRQ Raw status 334 | 0x028 335 | 336 | 337 | 338 | IRQ_Status 339 | IRQ status 340 | 0x02C 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | -------------------------------------------------------------------------------- /src/descriptors-register.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2016, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with System; 21 | with Ada.Text_IO; 22 | 23 | with DOM.Core; 24 | with DOM.Core.Elements; use DOM.Core.Elements; 25 | with DOM.Core.Nodes; 26 | 27 | with Ada_Gen; use Ada_Gen; 28 | with SVD2Ada_Utils; 29 | 30 | package body Descriptors.Register is 31 | 32 | ------------------- 33 | -- Read_Register -- 34 | ------------------- 35 | 36 | function Read_Register 37 | (Elt : DOM.Core.Element; 38 | Prepend : Unbounded.Unbounded_String; 39 | Append : Unbounded.Unbounded_String; 40 | Reg_Properties : Register_Properties_T; 41 | Reg_Db : Register_Db'Class) 42 | return Register_Access 43 | is 44 | use DOM.Core; 45 | use type Unbounded.Unbounded_String; 46 | 47 | List : constant Node_List := Nodes.Child_Nodes (Elt); 48 | Result : Register_T; 49 | Derived_From : constant String := 50 | Elements.Get_Attribute (Elt, "derivedFrom"); 51 | 52 | function Compute_Name return Unbounded.Unbounded_String; 53 | 54 | ------------------ 55 | -- Compute_Name -- 56 | ------------------ 57 | 58 | function Compute_Name return Unbounded.Unbounded_String 59 | is 60 | Name : constant String := Unbounded.To_String (Result.Xml_Id); 61 | Result : String (Name'Range); 62 | Idx : Natural; 63 | Skip : Boolean := False; 64 | begin 65 | Idx := Result'First - 1; 66 | 67 | for J in Name'Range loop 68 | if Skip then 69 | Skip := False; 70 | 71 | elsif Name (J) = '[' 72 | or else Name (J) = ']' 73 | then 74 | null; 75 | 76 | elsif J < Name'Last and then Name (J .. J + 1) = "%s" then 77 | -- Skip the next character (e.g. 's') 78 | Skip := True; 79 | 80 | else 81 | Idx := Idx + 1; 82 | Result (Idx) := Name (J); 83 | end if; 84 | end loop; 85 | 86 | if Idx in Result'Range and then Result (Idx) = '_' then 87 | Idx := Idx - 1; 88 | end if; 89 | 90 | return Unbounded.To_Unbounded_String (Result (Result'First .. Idx)); 91 | end Compute_Name; 92 | 93 | begin 94 | Result.Reg_Properties := Reg_Properties; 95 | 96 | if Derived_From /= "" then 97 | declare 98 | Oth : constant Register_Access := 99 | Reg_Db.Get_Register (Derived_From); 100 | begin 101 | if Oth /= null then 102 | Result := Oth.all; 103 | Result.Name := Unbounded.Null_Unbounded_String; 104 | else 105 | raise Constraint_Error with 106 | "register 'derivedFrom' is not known: " & Derived_From; 107 | end if; 108 | end; 109 | end if; 110 | 111 | for J in 0 .. Nodes.Length (List) - 1 loop 112 | if Nodes.Node_Type (Nodes.Item (List, J)) = Element_Node then 113 | declare 114 | Child : constant Element := Element (Nodes.Item (List, J)); 115 | Tag : String renames Elements.Get_Tag_Name (Child); 116 | begin 117 | if Tag = "name" then 118 | Result.Xml_Id := Get_Value (Child); 119 | Result.Name := Compute_Name; 120 | Result.Type_Name := Prepend & Result.Name & Append; 121 | 122 | elsif Tag = "displayName" then 123 | Result.Display_Name := Get_Value (Child); 124 | 125 | elsif Tag = "description" then 126 | Result.Description := Get_Value (Child); 127 | 128 | elsif Tag = "alternateGroup" then 129 | Result.Alternate_Group := Get_Value (Child); 130 | 131 | elsif Tag = "alternateRegister" then 132 | Result.Alternate_Reg := Get_Value (Child); 133 | 134 | elsif Tag = "addressOffset" then 135 | Result.Address_Offset := Get_Value (Child); 136 | 137 | elsif Is_Register_Property (Tag) then 138 | Read_Register_Property (Child, Result.Reg_Properties); 139 | 140 | elsif Tag = "modifiedWriteValue" then 141 | Result.Mod_Write_Values := Get_Value (Child); 142 | 143 | elsif Tag = "readAction" then 144 | Result.Read_Action := Get_Value (Child); 145 | 146 | elsif Tag = "fields" then 147 | declare 148 | Child_List : constant Node_List := 149 | Nodes.Child_Nodes (Child); 150 | Field : Field_T; 151 | begin 152 | for K in 0 .. Nodes.Length (Child_List) - 1 loop 153 | if Nodes.Node_Type (Nodes.Item (Child_List, K)) = Element_Node 154 | then 155 | Field := 156 | Read_Field 157 | (Element (Nodes.Item (Child_List, K)), 158 | Result.Fields, 159 | Result.Reg_Properties.Reg_Access, 160 | Result.Read_Action); 161 | if not Result.Fields.Contains (Field) then 162 | Result.Fields.Append (Field); 163 | end if; 164 | end if; 165 | end loop; 166 | end; 167 | 168 | elsif Tag = "dim" then 169 | Result.Dim := Get_Value (Child); 170 | 171 | if Unbounded.Length (Result.Xml_Id) > 0 then 172 | Result.Name := Compute_Name; 173 | end if; 174 | 175 | elsif Tag = "dimIncrement" then 176 | Result.Dim_Increment := Get_Value (Child); 177 | 178 | elsif Tag = "dimIndex" then 179 | Result.Dim_Index := Get_Value (Child); 180 | 181 | else 182 | Ada.Text_IO.Put_Line 183 | ("*** WARNING: ignoring register element " & Tag & " at " & Full_Name (Child)); 184 | end if; 185 | end; 186 | end if; 187 | end loop; 188 | 189 | return new Register_T'(Result); 190 | end Read_Register; 191 | 192 | --------- 193 | -- "=" -- 194 | --------- 195 | 196 | function Equal (R1, R2 : Register_Access) return Boolean 197 | is 198 | use type Unbounded.Unbounded_String; 199 | use type Field_Vectors.Vector; 200 | begin 201 | if R1 = null then 202 | return R2 = null; 203 | elsif R2 = null then 204 | return False; 205 | end if; 206 | 207 | return R1.Name = R2.Name 208 | and then R1.Address_Offset = R2.Address_Offset 209 | and then R1.Reg_Properties.Size = R2.Reg_Properties.Size 210 | and then R1.Dim = R2.Dim 211 | and then R1.Dim_Increment = R2.Dim_Increment 212 | and then R1.Fields = R2.Fields; 213 | end Equal; 214 | 215 | ----------------- 216 | -- Common_Type -- 217 | ----------------- 218 | 219 | function Similar_Type 220 | (R1, R2 : Register_Access) 221 | return Unbounded.Unbounded_String 222 | is 223 | use Field_Vectors; 224 | use type Ada.Containers.Count_Type; 225 | 226 | begin 227 | if Length (R1.Fields) /= Length (R2.Fields) then 228 | return Unbounded.Null_Unbounded_String; 229 | end if; 230 | 231 | if R1.Dim /= R2.Dim then 232 | return Unbounded.Null_Unbounded_String; 233 | end if; 234 | 235 | for J in R1.Fields.First_Index .. R1.Fields.Last_Index loop 236 | if R1.Fields.Element (J) /= R2.Fields.Element (J) then 237 | return Unbounded.Null_Unbounded_String; 238 | end if; 239 | end loop; 240 | 241 | return Common_Prefix (R1.Name, R2.Name); 242 | end Similar_Type; 243 | 244 | ------------------ 245 | -- Get_Ada_Type -- 246 | ------------------ 247 | 248 | function Get_Ada_Type (Reg : Register_Access) return Ada_Gen.Ada_Type'Class 249 | is 250 | use Unbounded; 251 | begin 252 | if Reg.Type_Holder /= null then 253 | return Get_Ada_Type (Reg.Type_Holder); 254 | 255 | elsif not Reg.Ada_Type.Is_Empty then 256 | return -Reg.Ada_Type; 257 | 258 | else 259 | raise Constraint_Error with "No ada type defined yet for " & 260 | To_String (Reg.Name); 261 | end if; 262 | end Get_Ada_Type; 263 | 264 | ---------- 265 | -- Dump -- 266 | ---------- 267 | 268 | procedure Dump 269 | (Spec : in out Ada_Gen.Ada_Spec; 270 | Reg : Register_Access) 271 | is 272 | use Ada.Strings.Unbounded; 273 | use type Ada.Containers.Count_Type; 274 | begin 275 | if Reg.Type_Holder /= null then 276 | -- This register is not responsible for emitting the Ada type. 277 | return; 278 | end if; 279 | 280 | if (Reg.Fields.Length = 1 281 | and then Reg.Fields.First_Element.Size = Reg.Reg_Properties.Size) 282 | or else Reg.Fields.Is_Empty 283 | then 284 | -- Don't generate anything here: we use a base type 285 | Reg.Ada_Type := -Ada_Gen.Target_Type (Reg.Reg_Properties.Size); 286 | 287 | if Reg.Dim > 1 then 288 | -- Just generate a comment to document the array that's going 289 | -- to be generated 290 | Add (Spec, 291 | New_Comment (To_String (Reg.Description), Strip => True)); 292 | end if; 293 | 294 | else 295 | declare 296 | Rec : Ada_Type_Record; 297 | 298 | begin 299 | Rec := Ada_Type_Record 300 | (New_Type_Record 301 | (To_String (Reg.Type_Name) & "_Register", 302 | To_String (Reg.Description))); 303 | 304 | Descriptors.Field.Dump 305 | (Spec, 306 | Reg, 307 | Rec, 308 | Reg.Fields, 309 | Reg.Reg_Properties); 310 | 311 | if not SVD2Ada_Utils.No_VFA_On_Reg_Types then 312 | Add_Aspect (Rec, "Volatile_Full_Access"); 313 | end if; 314 | Add_Object_Size_Aspect (Rec, Reg.Reg_Properties.Size); 315 | Add_Bit_Order_Aspect (Rec, System.Low_Order_First); 316 | 317 | declare 318 | Res : Ada_Type'Class := Simplify (Rec, Spec); 319 | begin 320 | Add (Spec, Res); 321 | Reg.Ada_Type := -Res; 322 | end; 323 | end; 324 | end if; 325 | 326 | -- Create an array of registers if Dim > 1 and the registers are 327 | -- contiguous. 328 | -- Do not do this when we apply the Virtual_Full_Access to clusters or 329 | -- peripheral fields instead of the base register type, as we can't 330 | -- specify that array components are Virtual_Full_Access. 331 | if Reg.Dim > 1 332 | and then Reg.Dim_Increment = Reg.Reg_Properties.Size / 8 333 | and then not SVD2Ada_Utils.No_VFA_On_Reg_Types 334 | then 335 | declare 336 | Array_T : Ada_Type_Array := 337 | New_Type_Array 338 | (Id => To_String (Reg.Type_Name) & "_Registers", 339 | Index_Type => "", 340 | Index_First => 0, 341 | Index_Last => Reg.Dim - 1, 342 | Element_Type => Get_Ada_Type (Reg), 343 | Comment => To_String (Reg.Description)); 344 | begin 345 | Add (Spec, Array_T); 346 | Reg.Ada_Type := -Array_T; 347 | end; 348 | end if; 349 | end Dump; 350 | 351 | end Descriptors.Register; 352 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/debug.part: -------------------------------------------------------------------------------- 1 | 2 | Debug 3 | 1.0 4 | 0xE000ED00 5 | read-write 6 | 7 | 8 | 0 9 | 0x100 10 | registers 11 | 12 | 13 | 14 | 15 | 16 | 17 | DFSR 18 | Debug Fault Status Register 19 | 0x30 20 | 32 21 | read-write 22 | 23 | 24 | 25 | HALTED 26 | [0:0] 27 | 28 | 29 | BKPT 30 | BKPT instruction executed or breakpoint match in 31 | FPB. 32 | [1:1] 33 | 34 | 35 | DWTTRAP 36 | Data Watchpoint and Trace trap. Indicates that the 37 | core halted due to at least one DWT trap event. 38 | [2:2] 39 | 40 | 41 | VCATCH 42 | Vector catch triggered. Corresponding FSR will 43 | contain the primary cause of the exception. 44 | [3:3] 45 | 46 | 47 | EXTERNAL 48 | An asynchronous exception generated due to the 49 | assertion of EDBGRQ. 50 | [4:4] 51 | 52 | 53 | 54 | 55 | 56 | 57 | DHCSR 58 | Debug Halting Control and Status Register 59 | 0xF0 60 | 61 | Read 62 | 0x00 63 | 32 64 | read-only 65 | 66 | 67 | C_DEBUGGEN 68 | [0:0] 69 | 70 | 71 | C_HALT 72 | [1:1] 73 | 74 | 75 | C_STEP 76 | [2:2] 77 | 78 | 79 | C_MASKINTS 80 | [3:3] 81 | 82 | 83 | C_SNAPSTALL 84 | [5:5] 85 | 86 | 87 | S_REGRDY 88 | [16:16] 89 | read-only 90 | 91 | 92 | S_HALT 93 | [17:17] 94 | read-only 95 | 96 | 97 | S_SLEEP 98 | [18:18] 99 | read-only 100 | 101 | 102 | S_LOCKUP 103 | [19:19] 104 | read-only 105 | 106 | 107 | S_RETIRE_ST 108 | [24:24] 109 | read-only 110 | 111 | 112 | S_RESET_ST 113 | [25:25] 114 | read-only 115 | 116 | 117 | 118 | 119 | Write 120 | 0x00 121 | 32 122 | write-only 123 | DHCSR_Read 124 | 125 | 126 | C_DEBUGGEN 127 | [0:0] 128 | 129 | 130 | C_HALT 131 | [1:1] 132 | 133 | 134 | C_STEP 135 | [2:2] 136 | 137 | 138 | C_MASKINTS 139 | [3:3] 140 | 141 | 142 | C_SNAPSTALL 143 | [5:5] 144 | 145 | 146 | S_RESET_ST 147 | Debug Key. The value 0xA05F must be written to 148 | enable write accesses to bits [15:0], otherwise the write 149 | access will be ignored. Read behavior of bits [31:16] is as 150 | listed below. 151 | [31:16] 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | DCRSR 160 | Debug Core Register Selector Register: The DCRSR 161 | write-only register generates a handshake to the core to transfer the 162 | selected register to/from the DCRDR. The DHCSR S_REGRDY bit is 163 | cleared when the DCRSR is written, and remains clear until the core 164 | transaction completes. This register is only accessible from Debug 165 | state. 166 | 0xF4 167 | 32 168 | write-only 169 | 170 | 171 | 172 | HALTED 173 | [4:0] 174 | 175 | 176 | Register_0 177 | 0 178 | 179 | 180 | Register_1 181 | 1 182 | 183 | 184 | Register_2 185 | 2 186 | 187 | 188 | Register_3 189 | 3 190 | 191 | 192 | Register_4 193 | 4 194 | 195 | 196 | Register_5 197 | 5 198 | 199 | 200 | Register_6 201 | 6 202 | 203 | 204 | Register_7 205 | 7 206 | 207 | 208 | Register_8 209 | 8 210 | 211 | 212 | Register_9 213 | 9 214 | 215 | 216 | Register_10 217 | 10 218 | 219 | 220 | Register_11 221 | 11 222 | 223 | 224 | Register_12 225 | 12 226 | 227 | 228 | Current_SP 229 | 13 230 | 231 | 232 | Link_Rregister 233 | 14 234 | 235 | 236 | Debug_Return_Address 237 | 15 238 | 239 | 240 | xPSR 241 | 16 242 | 243 | 244 | MSP 245 | 17 246 | 247 | 248 | PSP 249 | 18 250 | 251 | 252 | CONTROL_FAULTMASK_BASEPRI_PRIMASK 253 | 19 254 | 255 | 256 | 257 | 258 | REGWnR 259 | 260 | [16:16] 261 | 262 | 263 | Write 264 | 1 265 | 266 | 267 | Read 268 | 0 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | DCRDR 278 | Debug Core Register Data Register 279 | 0xF8 280 | 32 281 | read-write 282 | 283 | 284 | 285 | 286 | DEMCR 287 | Debug Exception and Monitor Control Register 288 | 0xFC 289 | 32 290 | read-write 291 | 292 | 293 | 294 | VC_CORERESET 295 | [0:0] 296 | 297 | 298 | VC_MMERR 299 | [4:4] 300 | 301 | 302 | VC_NOCPERR 303 | [5:5] 304 | 305 | 306 | VC_CHKERR 307 | [6:6] 308 | 309 | 310 | VC_STATERR 311 | [7:7] 312 | 313 | 314 | VC_BUSERR 315 | [8:8] 316 | 317 | 318 | VC_INTERR 319 | [9:9] 320 | 321 | 322 | VC_HARDERR 323 | [10:10] 324 | 325 | 326 | MON_EN 327 | [16:16] 328 | 329 | 330 | MON_PEND 331 | [17:17] 332 | 333 | 334 | MON_STEP 335 | [18:18] 336 | 337 | 338 | MON_REQ 339 | [19:19] 340 | 341 | 342 | TRCENA 343 | [24:24] 344 | 345 | 346 | 347 | 348 | 349 | 350 | -------------------------------------------------------------------------------- /src/svd2ada.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2024, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Command_Line; 21 | with Ada.Exceptions; 22 | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; 23 | with Ada.Text_IO; use Ada.Text_IO; 24 | 25 | with GNAT.Command_Line; 26 | with GNAT.Directory_Operations; use GNAT.Directory_Operations; 27 | with GNAT.OS_Lib; 28 | with GNAT.Strings; 29 | 30 | -- XML dependencies 31 | with Input_Sources.File; use Input_Sources.File; 32 | with Sax.Readers; 33 | with Schema.Dom_Readers; use Schema.Dom_Readers; 34 | with Schema.Schema_Readers; use Schema.Schema_Readers; 35 | with Schema.Validators; use Schema.Validators; 36 | with DOM.Core; use DOM.Core; 37 | with DOM.Core.Documents; 38 | 39 | with Ada_Gen; 40 | with Descriptors.Device; 41 | with SVD2Ada_Utils; use SVD2Ada_Utils; 42 | 43 | -- SVD Binding Generator: this tool is meant to handle 44 | -- A SVD file is an xml file representing a specific hardware device, and 45 | -- uses the following layers to describe it: 46 | -- * : the root element. Contains an optional cpu definition, some 47 | -- default properties, and a list of peripherals 48 | -- * : A peripheral descriptor. Each peripheral has a base 49 | -- address, and a list of registers. They also can be grouped into groups 50 | -- of peripherals of similar or interrelated functionalities. 51 | -- When such group exist, this binding generator will group all the 52 | -- peripherals of a given group into the same spec file. 53 | -- * : The description of a specific register of a peripheral. 54 | -- Optionally, the different fields of a register can also be described. 55 | -- * : The field of a descriptor. Each field has a specific name, 56 | -- a size and an offset from the register base address. 57 | -- * : Also optional, the SVD file may contain a description 58 | -- of the valid values that are expected for a given field. If such 59 | -- element is present, then the binding generator will create an enum 60 | -- for the field, and use this enum as type of the field. 61 | 62 | procedure SVD2Ada is 63 | 64 | Doc : Document; 65 | Schema : constant String := GNAT.OS_Lib.Normalize_Pathname 66 | ("schema/CMSIS-SVD_Schema_1_3_1.xsd", 67 | Executable_Location); 68 | 69 | -- The generated Device 70 | Device : Descriptors.Device.Device_T; 71 | SVD_File_Name : Unbounded_String; 72 | 73 | -- Command line parser and switches/arguments 74 | Cmd_Line_Cfg : GNAT.Command_Line.Command_Line_Configuration; 75 | Root_Pkg_Name : aliased GNAT.Strings.String_Access; 76 | Output_Dir : aliased GNAT.Strings.String_Access; 77 | Base_Types_Pkg : aliased GNAT.Strings.String_Access; 78 | Gen_Booleans : aliased Boolean := False; 79 | Gen_UInt_Always : aliased Boolean := False; 80 | No_UInt_Subtype : aliased Boolean := False; 81 | No_Arrays : aliased Boolean := False; 82 | No_Defaults : aliased Boolean := False; 83 | No_VFA_On_Types : aliased Boolean := False; 84 | Gen_IRQ_Support : aliased Boolean := False; 85 | No_Elab_Code_All : aliased Boolean := False; 86 | 87 | use type GNAT.Strings.String_Access; 88 | 89 | procedure Configure_Command_Line; 90 | -- Define the switches used on the command line 91 | 92 | procedure Apply_Command_Line; 93 | -- Set the generation switches and options based on command line settings 94 | 95 | procedure Get_SVD_File_Name (Name : out Unbounded_String); 96 | -- Get the normalized XML input file name 97 | 98 | procedure Parse_XML_Files 99 | (File_Name : String; 100 | Schema : String; 101 | Doc : out Document); 102 | -- Parse the XML in the SVD input file and check for a helper file to 103 | -- give us hints as to how generate some structures 104 | 105 | ---------------------------- 106 | -- Configure_Command_Line -- 107 | ---------------------------- 108 | 109 | procedure Configure_Command_Line is 110 | use GNAT.Command_Line; 111 | begin 112 | Set_Usage 113 | (Cmd_Line_Cfg, 114 | Usage => "[options] -o DIR svd-file", 115 | Help => "Generate Ada bindings from CMSIS-SVD hardware description files"); 116 | Define_Switch 117 | (Cmd_Line_Cfg, 118 | Output => Output_Dir'Access, 119 | Switch => "-o=", 120 | Long_Switch => "--output=", 121 | Help => "directory to contain the generated binding", 122 | Argument => "DIR"); 123 | Define_Switch 124 | (Cmd_Line_Cfg, 125 | Output => Root_Pkg_Name'Access, 126 | Switch => "-p=", 127 | Long_Switch => "--package=", 128 | Help => "the root package name for the generated spec hierarchy", 129 | Argument => "Pkg_Name"); 130 | Define_Switch 131 | (Cmd_Line_Cfg, 132 | Output => Base_Types_Pkg'Access, 133 | Long_Switch => "--base-types-package=", 134 | Help => "the name of the package containing low level types' definitions"); 135 | Define_Switch 136 | (Cmd_Line_Cfg, 137 | Output => Gen_Booleans'Access, 138 | Long_Switch => "--boolean", 139 | Help => "represent single-bit fields as Booleans", 140 | Value => True); 141 | Define_Switch 142 | (Cmd_Line_Cfg, 143 | Output => Gen_IRQ_Support'Access, 144 | Long_Switch => "--gen-interrupts", 145 | Help => "generate trap handlers and package Interrupts.Names", 146 | Value => True); 147 | Define_Switch 148 | (Cmd_Line_Cfg, 149 | Output => Gen_UInt_Always'Access, 150 | Long_Switch => "--gen-uint-always", 151 | Help => "generate UInt* for base types; do not use the Bit and Byte variants", 152 | Value => True); 153 | Define_Switch 154 | (Cmd_Line_Cfg, 155 | Output => No_Arrays'Access, 156 | Long_Switch => "--no-arrays", 157 | Help => "don't generate arrays of registers or arrays of register fields", 158 | Value => True); 159 | Define_Switch 160 | (Cmd_Line_Cfg, 161 | Output => No_Defaults'Access, 162 | Long_Switch => "--no-defaults", 163 | Help => "don't use register reset values for fields' default values", 164 | Value => True); 165 | Define_Switch 166 | (Cmd_Line_Cfg, 167 | Output => No_UInt_Subtype'Access, 168 | Long_Switch => "--no-uint-subtypes", 169 | Help => "use the corresponding UInt type instead of subtypes for fields", 170 | Value => True); 171 | Define_Switch 172 | (Cmd_Line_Cfg, 173 | Output => No_VFA_On_Types'Access, 174 | Long_Switch => "--no-vfa-on-types", 175 | Help => "apply Volatile_Full_Access to fields rather than register types. " & 176 | "Forces --no-arrays", 177 | -- Apply it to individual fields of some enclosing 178 | -- register record type when those fields are 179 | -- themselves represented as register types 180 | Value => True); 181 | Define_Switch 182 | (Cmd_Line_Cfg, 183 | Output => No_Elab_Code_All'Access, 184 | Long_Switch => "--no-elaboration-code-all", 185 | Help => "use pragma No_Elaboration_Code_All", 186 | Value => True); 187 | end Configure_Command_Line; 188 | 189 | ------------------------ 190 | -- Apply_Command_Line -- 191 | ------------------------ 192 | 193 | procedure Apply_Command_Line is 194 | begin 195 | if Root_Pkg_Name.all /= "" then 196 | Set_Root_Package (Root_Pkg_Name.all); 197 | 198 | -- If Pkg is a runtime package, force the generation of Interrupts.Names 199 | -- and IRQ trap vector. 200 | if SVD2Ada_Utils.In_Runtime then 201 | Gen_IRQ_Support := True; 202 | end if; 203 | end if; 204 | 205 | Set_Use_Boolean_For_Bit (Gen_Booleans); 206 | Set_Gen_IRQ_Support (Gen_IRQ_Support); 207 | Set_Use_UInt (Gen_UInt_Always); 208 | Set_Gen_Arrays (not No_Arrays); 209 | Set_No_Defaults (No_Defaults); 210 | Set_No_UInt_Subtype (No_UInt_Subtype); 211 | Set_No_VFA_On_Reg_Types (No_VFA_On_Types); 212 | Set_No_Elaboration_Code_All (No_Elab_Code_All); 213 | 214 | if Base_Types_Pkg.all /= "" then 215 | Set_Base_Types_Package (Base_Types_Pkg.all); 216 | end if; 217 | end Apply_Command_Line; 218 | 219 | ----------------------- 220 | -- Get_SVD_File_Name -- 221 | ----------------------- 222 | 223 | procedure Get_SVD_File_Name (Name : out Unbounded_String) is 224 | SVD : constant String := GNAT.Command_Line.Get_Argument; 225 | begin 226 | if SVD /= "" then 227 | Name := To_Unbounded_String (GNAT.OS_Lib.Normalize_Pathname (SVD)); 228 | end if; 229 | end Get_SVD_File_Name; 230 | 231 | --------------------- 232 | -- Parse_XML_Files -- 233 | --------------------- 234 | 235 | procedure Parse_XML_Files 236 | (File_Name : String; 237 | Schema : String; 238 | Doc : out Document) 239 | is 240 | Input : File_Input; 241 | Reader : Tree_Reader; 242 | Sc_Reader : Schema_Reader; 243 | Grammar : XML_Grammar; 244 | begin 245 | -- Open the schema file 246 | Input_Sources.File.Open (Schema, Input); 247 | Sc_Reader.Parse (Input); 248 | Close (Input); 249 | Grammar := Get_Grammar (Sc_Reader); 250 | 251 | -- Tell the reader to use the schema to validate the SVD file 252 | Reader.Set_Grammar (Grammar); 253 | Set_Feature (Reader, Sax.Readers.Schema_Validation_Feature, False); 254 | Use_Basename_In_Error_Messages (Reader, True); 255 | 256 | Input_Sources.File.Open (File_Name, Input); 257 | Reader.Parse (Input); 258 | Close (Input); 259 | 260 | Doc := Get_Tree (Reader); 261 | 262 | -- Check if we have a helper file to give us hints as to how generate 263 | -- some structures. Rule: if we have both XXXX.svd and XXXX.svd2ada, 264 | -- then the svd2ada file is our helper file 265 | if GNAT.OS_Lib.Is_Regular_File (File_Name & "2ada") then 266 | Input_Sources.File.Open (File_Name & "2ada", Input); 267 | Set_Feature (Reader, Sax.Readers.Schema_Validation_Feature, False); 268 | Use_Basename_In_Error_Messages (Reader, True); 269 | Reader.Parse (Input); 270 | Close (Input); 271 | end if; 272 | exception 273 | when XML_Validation_Error => 274 | Close (Input); 275 | Put_Line ("Invalid SVD file:"); 276 | Put_Line (Reader.Get_Error_Message); 277 | raise; 278 | when E : Sax.Readers.XML_Fatal_Error => 279 | Close (Input); 280 | Put_Line ("Fatal error when parsing the SVD file:"); 281 | Put_Line (Ada.Exceptions.Exception_Message (E)); 282 | raise; 283 | end Parse_XML_Files; 284 | 285 | begin 286 | Configure_Command_Line; 287 | GNAT.Command_Line.Getopt (Cmd_Line_Cfg); 288 | Get_SVD_File_Name (SVD_File_Name); 289 | if SVD_File_Name = Null_Unbounded_String or else 290 | Output_Dir = null or else Output_Dir.all = "" 291 | then 292 | Put_Line (Standard_Error, "Error: missing arguments"); 293 | GNAT.Command_Line.Try_Help; 294 | Ada.Command_Line.Set_Exit_Status (2); 295 | return; 296 | end if; 297 | Apply_Command_Line; 298 | 299 | Ada_Gen.Set_Input_File_Name (Base_Name (To_String (SVD_File_Name))); 300 | 301 | Parse_XML_Files (To_String (SVD_File_Name), Schema, Doc); 302 | 303 | Device := Descriptors.Device.Read_Device 304 | (Documents.Get_Element (Doc), 305 | (if Root_Pkg_Name = null then "" else Root_Pkg_Name.all)); 306 | 307 | Descriptors.Device.Dump (Device, Output_Dir.all); 308 | exception 309 | when GNAT.Command_Line.Invalid_Switch | 310 | GNAT.Command_Line.Invalid_Parameter | 311 | GNAT.Command_Line.Exit_From_Command_Line => 312 | Ada.Command_Line.Set_Exit_Status (1); 313 | 314 | when XML_Validation_Error | Sax.Readers.XML_Fatal_Error => 315 | Ada.Command_Line.Set_Exit_Status (2); 316 | end SVD2Ada; 317 | -------------------------------------------------------------------------------- /src/svd2ada_utils.adb: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- -- 3 | -- SVD Binding Generator -- 4 | -- -- 5 | -- Copyright (C) 2015-2004, AdaCore -- 6 | -- -- 7 | -- SVD2Ada is free software; you can redistribute it and/or modify it -- 8 | -- under terms of the GNU General Public License as published by the Free -- 9 | -- Software Foundation; either version 3, or (at your option) any later -- 10 | -- version. SVD2Ada is distributed in the hope that it will be useful, but -- 11 | -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTA- -- 12 | -- BILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- 13 | -- License for more details. You should have received a copy of the GNU -- 14 | -- General Public License distributed with SVD2Ada; see file COPYING3. If -- 15 | -- not, go to http://www.gnu.org/licenses for a complete copy of the -- 16 | -- license. -- 17 | -- -- 18 | ------------------------------------------------------------------------------ 19 | 20 | with Ada.Command_Line; 21 | with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; 22 | 23 | with GNAT.Case_Util; 24 | with GNAT.OS_Lib; use GNAT.OS_Lib; 25 | 26 | package body SVD2Ada_Utils is 27 | 28 | G_Use_Boolean : Boolean := False; 29 | G_Types_Pkg : Unbounded_String := Null_Unbounded_String; 30 | G_Root_Pkg : Unbounded_String := Null_Unbounded_String; 31 | G_Use_UInt : Boolean := False; 32 | G_Gen_Arrays : Boolean := True; 33 | G_No_VFA_On_Reg_Types : Boolean := False; 34 | G_Gen_IRQ_Support : Boolean := False; 35 | G_Gen_UInt_Subtype : Boolean := True; 36 | G_Gen_Fields_Default : Boolean := True; 37 | G_No_Elaboration_Code_All : Boolean := False; 38 | 39 | function Installation_Dir (Exec_with_Path : String) return String; 40 | -- Exec_with_Path is the executable name preceeded by the absolute or 41 | -- relative path, e.g. "c:\usr\bin\gcc.exe" or "..\bin\gcc". Returns 42 | -- the absolute or relative directory where "bin" lies (in the example 43 | -- "C:\usr" or ".."). If the executable is not a "bin" directory, return 44 | -- "". 45 | 46 | ---------------------------- 47 | -- Is_Directory_Separator -- 48 | ---------------------------- 49 | 50 | function Is_Directory_Separator (C : Character) return Boolean is 51 | (C = Directory_Separator or else C = '/'); 52 | 53 | ------------------------- 54 | -- Executable_Location -- 55 | ------------------------- 56 | 57 | -- Executable_Location is extracted from the gnatcoll library 58 | function Executable_Location return String is 59 | Exec_Name : constant String := Ada.Command_Line.Command_Name; 60 | begin 61 | -- First determine if a path prefix was placed in front of the 62 | -- executable name. 63 | 64 | for J in reverse Exec_Name'Range loop 65 | if Is_Directory_Separator (Exec_Name (J)) then 66 | return Installation_Dir (Exec_Name); 67 | end if; 68 | end loop; 69 | 70 | -- If we are here, the user has typed the executable name with no 71 | -- directory prefix. 72 | -- There is a potential issue here (see K112-046) where GNAT.OS_Lib 73 | -- will in fact return any non-executable file found in the PATH, 74 | -- whereas shells only consider executable files. As a result, the 75 | -- user might end up with a wrong directory, not matching the one 76 | -- found by the shell. 77 | 78 | declare 79 | Ex : GNAT.OS_Lib.String_Access := GNAT.OS_Lib.Locate_Exec_On_Path (Exec_Name); 80 | Dir : constant String := Installation_Dir (Ex.all); 81 | begin 82 | Free (Ex); 83 | return Dir; 84 | end; 85 | end Executable_Location; 86 | 87 | ----------------------------- 88 | -- Set_Use_Boolean_For_Bit -- 89 | ----------------------------- 90 | 91 | procedure Set_Use_Boolean_For_Bit (Value : Boolean) is 92 | begin 93 | G_Use_Boolean := Value; 94 | end Set_Use_Boolean_For_Bit; 95 | 96 | ------------------------- 97 | -- Use_Boolean_For_Bit -- 98 | ------------------------- 99 | 100 | function Use_Boolean_For_Bit return Boolean is 101 | begin 102 | return G_Use_Boolean; 103 | end Use_Boolean_For_Bit; 104 | 105 | ------------------ 106 | -- Set_Use_UInt -- 107 | ------------------ 108 | 109 | procedure Set_Use_UInt (Value : Boolean) is 110 | begin 111 | G_Use_UInt := Value; 112 | end Set_Use_UInt; 113 | 114 | --------------------- 115 | -- Use_UInt_Always -- 116 | --------------------- 117 | 118 | function Use_UInt_Always return Boolean is 119 | begin 120 | return G_Use_UInt; 121 | end Use_UInt_Always; 122 | 123 | ------------------------- 124 | -- Set_No_UInt_Subtype -- 125 | ------------------------- 126 | 127 | procedure Set_No_UInt_Subtype (Value : Boolean) is 128 | begin 129 | G_Gen_UInt_Subtype := not Value; 130 | end Set_No_UInt_Subtype; 131 | 132 | ---------------------- 133 | -- Gen_UInt_Subtype -- 134 | ---------------------- 135 | 136 | function Gen_UInt_Subtype return Boolean is 137 | begin 138 | return G_Gen_UInt_Subtype; 139 | end Gen_UInt_Subtype; 140 | 141 | --------------------- 142 | -- Set_No_Defaults -- 143 | --------------------- 144 | 145 | procedure Set_No_Defaults (Value : Boolean) is 146 | begin 147 | G_Gen_Fields_Default := not Value; 148 | end Set_No_Defaults; 149 | 150 | ------------------------ 151 | -- Gen_Fields_Default -- 152 | ------------------------ 153 | 154 | function Gen_Fields_Default return Boolean is 155 | begin 156 | return G_Gen_Fields_Default; 157 | end Gen_Fields_Default; 158 | 159 | ---------------------------- 160 | -- Set_Base_Types_Package -- 161 | ---------------------------- 162 | 163 | procedure Set_Base_Types_Package (Value : String) is 164 | begin 165 | G_Types_Pkg := To_Unbounded_String (Value); 166 | end Set_Base_Types_Package; 167 | 168 | ------------------------ 169 | -- Base_Types_Package -- 170 | ------------------------ 171 | 172 | function Base_Types_Package return String is 173 | begin 174 | return To_String (G_Types_Pkg); 175 | end Base_Types_Package; 176 | 177 | --------------------------------- 178 | -- External_Base_Types_Package -- 179 | --------------------------------- 180 | 181 | function External_Base_Types_Package return Boolean is 182 | begin 183 | return G_Types_Pkg /= Null_Unbounded_String; 184 | end External_Base_Types_Package; 185 | 186 | ---------------------- 187 | -- Set_Root_Package -- 188 | ---------------------- 189 | 190 | procedure Set_Root_Package (Value : String) is 191 | begin 192 | G_Root_Pkg := To_Unbounded_String (Value); 193 | end Set_Root_Package; 194 | 195 | ------------------ 196 | -- Root_Package -- 197 | ------------------ 198 | 199 | function Root_Package return String is 200 | begin 201 | return To_String (G_Root_Pkg); 202 | end Root_Package; 203 | 204 | ---------------- 205 | -- In_Runtime -- 206 | ---------------- 207 | 208 | function In_Runtime return Boolean is 209 | Intf : constant String := "Interfaces."; 210 | Root : constant String := Root_Package; 211 | begin 212 | if Root'Length <= Intf'Length then 213 | return False; 214 | elsif Root (Root'First .. Root'First + Intf'Length - 1) /= Intf then 215 | return False; 216 | else 217 | return True; 218 | end if; 219 | end In_Runtime; 220 | 221 | ----------------------------- 222 | -- Set_No_VFA_On_Reg_Types -- 223 | ----------------------------- 224 | 225 | procedure Set_No_VFA_On_Reg_Types (Value : Boolean) is 226 | begin 227 | G_No_VFA_On_Reg_Types := Value; 228 | end Set_No_VFA_On_Reg_Types; 229 | 230 | ------------------------- 231 | -- No_VFA_On_Reg_Types -- 232 | ------------------------- 233 | 234 | function No_VFA_On_Reg_Types return Boolean is 235 | begin 236 | return G_No_VFA_On_Reg_Types; 237 | end No_VFA_On_Reg_Types; 238 | 239 | -------------------- 240 | -- Set_Gen_Arrays -- 241 | -------------------- 242 | 243 | procedure Set_Gen_Arrays (Value : Boolean) is 244 | begin 245 | G_Gen_Arrays := Value; 246 | end Set_Gen_Arrays; 247 | 248 | ---------------- 249 | -- Gen_Arrays -- 250 | ---------------- 251 | 252 | function Gen_Arrays return Boolean is 253 | begin 254 | return G_Gen_Arrays; 255 | end Gen_Arrays; 256 | 257 | ------------------------- 258 | -- Set_Gen_IRQ_Support -- 259 | ------------------------- 260 | 261 | procedure Set_Gen_IRQ_Support (Value : Boolean) is 262 | begin 263 | G_Gen_IRQ_Support := Value; 264 | end Set_Gen_IRQ_Support; 265 | 266 | --------------------- 267 | -- Gen_IRQ_Support -- 268 | --------------------- 269 | 270 | function Gen_IRQ_Support return Boolean is 271 | begin 272 | return G_Gen_IRQ_Support or else In_Runtime; 273 | end Gen_IRQ_Support; 274 | 275 | ---------------------- 276 | -- Installation_Dir -- 277 | ---------------------- 278 | 279 | function Installation_Dir (Exec_with_Path : String) return String is 280 | Exec : String := GNAT.OS_Lib.Normalize_Pathname (Exec_with_Path, Resolve_Links => True); 281 | Path_Last : Integer := 0; 282 | begin 283 | for J in reverse Exec'Range loop 284 | if Is_Directory_Separator (Exec (J)) then 285 | Path_Last := J - 1; 286 | exit; 287 | end if; 288 | end loop; 289 | 290 | if Path_Last >= Exec'First + 2 then 291 | GNAT.Case_Util.To_Lower (Exec (Path_Last - 2 .. Path_Last)); 292 | end if; 293 | 294 | -- If we are not in a bin/ directory 295 | 296 | if Path_Last < Exec'First + 2 297 | or else Exec (Path_Last - 2 .. Path_Last) /= "bin" 298 | or else (Path_Last - 3 >= Exec'First 299 | and then not Is_Directory_Separator (Exec (Path_Last - 3))) 300 | then 301 | return Exec (Exec'First .. Path_Last) & GNAT.OS_Lib.Directory_Separator; 302 | else 303 | -- Skip bin/, but keep the last directory separator 304 | return Exec (Exec'First .. Path_Last - 3); 305 | end if; 306 | end Installation_Dir; 307 | 308 | ---------------------- 309 | -- Is_Reserved_Word -- 310 | ---------------------- 311 | 312 | function Is_Reserved_Word (Word : String) return Boolean is 313 | (Word = "abort" 314 | or else Word = "abs" 315 | or else Word = "abstract" 316 | or else Word = "accept" 317 | or else Word = "access" 318 | or else Word = "aliased" 319 | or else Word = "all" 320 | or else Word = "and" 321 | or else Word = "array" 322 | or else Word = "at" 323 | or else Word = "begin" 324 | or else Word = "body" 325 | or else Word = "case" 326 | or else Word = "constant" 327 | or else Word = "declare" 328 | or else Word = "delay" 329 | or else Word = "delta" 330 | or else Word = "digits" 331 | or else Word = "do" 332 | or else Word = "else" 333 | or else Word = "elsif" 334 | or else Word = "end" 335 | or else Word = "entry" 336 | or else Word = "exception" 337 | or else Word = "exit" 338 | or else Word = "for" 339 | or else Word = "function" 340 | or else Word = "generic" 341 | or else Word = "goto" 342 | or else Word = "if" 343 | or else Word = "in" 344 | or else Word = "interface" 345 | or else Word = "is" 346 | or else Word = "limited" 347 | or else Word = "loop" 348 | or else Word = "mod" 349 | or else Word = "new" 350 | or else Word = "not" 351 | or else Word = "null" 352 | or else Word = "of" 353 | or else Word = "or" 354 | or else Word = "others" 355 | or else Word = "out" 356 | or else Word = "overriding" 357 | or else Word = "package" 358 | or else Word = "pragma" 359 | or else Word = "private" 360 | or else Word = "procedure" 361 | or else Word = "protected" 362 | or else Word = "raise" 363 | or else Word = "range" 364 | or else Word = "record" 365 | or else Word = "rem" 366 | or else Word = "renames" 367 | or else Word = "requeue" 368 | or else Word = "return" 369 | or else Word = "reverse" 370 | or else Word = "select" 371 | or else Word = "separate" 372 | or else Word = "some" 373 | or else Word = "subtype" 374 | or else Word = "synchronized" 375 | or else Word = "tagged" 376 | or else Word = "task" 377 | or else Word = "terminate" 378 | or else Word = "then" 379 | or else Word = "type" 380 | or else Word = "until" 381 | or else Word = "use" 382 | or else Word = "when" 383 | or else Word = "while" 384 | or else Word = "with" 385 | or else Word = "xor"); 386 | 387 | ----------------------------- 388 | -- No_Elaboration_Code_All -- 389 | ----------------------------- 390 | 391 | function No_Elaboration_Code_All return Boolean is 392 | begin 393 | return In_Runtime or G_No_Elaboration_Code_All; 394 | end No_Elaboration_Code_All; 395 | 396 | --------------------------------- 397 | -- Set_No_Elaboration_Code_All -- 398 | --------------------------------- 399 | 400 | procedure Set_No_Elaboration_Code_All (Value : Boolean) is 401 | begin 402 | G_No_Elaboration_Code_All := Value; 403 | end Set_No_Elaboration_Code_All; 404 | 405 | end SVD2Ada_Utils; 406 | -------------------------------------------------------------------------------- /CMSIS-SVD/Cortex_M/IPs/mpu.part: -------------------------------------------------------------------------------- 1 | 2 | MPU 3 | Memory Protection Unit 4 | 0xE000ED90 5 | MPU_ 6 | 7 | 8 | 0 9 | 0x30 10 | registers 11 | 12 | 13 | 14 | TYPE 15 | MPU Type Register 16 | 0x0 17 | 32 18 | 0x00000800 19 | 0xFFFFFFFF 20 | 21 | 22 | SEPARATE 23 | Indicates support for unified or separate instruction 24 | and data memory maps. 25 | 0 26 | 1 27 | read-only 28 | 29 | 30 | Unified 31 | Only unified memory maps are supported. 32 | 0x0 33 | 34 | 35 | 36 | 37 | DREGION 38 | Indicates the number of supported MPU data regions depending 39 | on your implementation. 40 | 8 41 | 8 42 | read-only 43 | 44 | 45 | IREGION 46 | Indicates the number of supported MPU instruction regions. Always 47 | contains 0x0: the MPU memory map is unified and is described by the DREGION 48 | field. 49 | 16 50 | 8 51 | read-only 52 | 53 | 54 | 55 | 56 | CTRL 57 | MPU Control Register 58 | 0x4 59 | 32 60 | 0x00000000 61 | 0xFFFFFFFF 62 | 63 | 64 | ENABLE 65 | Enables the optional MPU. 66 | 0 67 | 1 68 | read-write 69 | 70 | 71 | HFNMIENA 72 | Enables the operation of MPU during hard fault, NMI, 73 | and FAULTMASK handlers. 74 | 1 75 | 1 76 | read-write 77 | 78 | 79 | PRIVDEFENA 80 | Enables privileged software access to the default memory map. 81 | 2 82 | 1 83 | read-write 84 | 85 | 86 | 87 | 88 | RNR 89 | MPU Region Number Register 90 | 0x8 91 | 32 92 | 0x00000000 93 | 0xFFFFFFFF 94 | 95 | 96 | REGION 97 | Indicates the MPU region referenced by the MPU_RBAR and MPU_RASR 98 | registers. 99 | 0 100 | 8 101 | read-write 102 | 103 | 104 | 105 | 106 | RBAR 107 | MPU Region Base Address Register 108 | 0xC 109 | 32 110 | 0x00000000 111 | 0xFFFFFFFF 112 | 113 | 114 | REGION 115 | On Write, see the VALID field. On read, specifies the region number. 116 | 0 117 | 4 118 | read-write 119 | 120 | 121 | VALID 122 | MPU Region number valid bit. Depending on your implementation, this has the 123 | following effect: 0 - either updates the base address for the region specified by MPU_RNR or ignores the value of the REGION field. 1 - either updates the value of the MPU_RNR to the value of the REGION field or updates the base address for the region specified in the REGION field. 124 | 4 125 | 1 126 | read-write 127 | 128 | 129 | ADDR 130 | The ADDR field is bits[31:N] of the MPU_RBAR. The region size, as specified by the SIZE field in the MPU_RASR, defines the value of N: 131 | N = Log2(Region size in bytes). 132 | If the region size is configured to 4GB, in the MPU_RASR, there is no valid ADDR field. In 133 | this case, the region occupies the complete memory map, and the base address is 0x00000000. The base address is aligned to the size of the region. For example, a 64KB region must be 134 | aligned on a multiple of 64KB, for example, at 0x00010000 or 0x00020000. 135 | 5 136 | 27 137 | read-write 138 | 139 | 140 | 141 | 142 | RASR 143 | MPU Region Base Attribute and Size Register 144 | 0x10 145 | 32 146 | 0x00000000 147 | 0xFFFFFFFF 148 | 149 | 150 | ENABLE 151 | Region enable bit. 152 | 0 153 | 1 154 | read-write 155 | 156 | 157 | SIZE 158 | Specifies the size of the MPU protection region. Minimum value is 4. 159 | The Region size is defined as (Region size in bytes) = 2^(SIZE+1) 160 | 1 161 | 5 162 | read-write 163 | 164 | 165 | SRD0 166 | Subregion disable bits 167 | 8 168 | 1 169 | read-write 170 | 171 | 172 | SRD1 173 | Subregion disable bits 174 | 9 175 | 1 176 | read-write 177 | 178 | 179 | SRD2 180 | Subregion disable bits 181 | 10 182 | 1 183 | read-write 184 | 185 | 186 | SRD3 187 | Subregion disable bits 188 | 11 189 | 1 190 | read-write 191 | 192 | 193 | SRD4 194 | Subregion disable bits 195 | 12 196 | 1 197 | read-write 198 | 199 | 200 | SRD5 201 | Subregion disable bits. 202 | 13 203 | 1 204 | read-write 205 | 206 | 207 | SRD6 208 | Subregion disable bits. 209 | 14 210 | 1 211 | read-write 212 | 213 | 214 | SRD7 215 | Subregion disable bits. 216 | 15 217 | 1 218 | read-write 219 | 220 | 221 | B 222 | Memory access attribute. 223 | 16 224 | 1 225 | read-write 226 | 227 | 228 | C 229 | Memory access attribute. 230 | 17 231 | 1 232 | read-write 233 | 234 | 235 | S 236 | Shareable bit. Applies to Normal memory only. 237 | 18 238 | 1 239 | read-write 240 | 241 | 242 | TEX 243 | Memory access attribute. 244 | 19 245 | 3 246 | read-write 247 | 248 | 249 | AP 250 | Access permission field 251 | 24 252 | 3 253 | read-write 254 | 255 | 256 | No_Access 257 | All accesses generate a permission fault. 258 | 0x0 259 | 260 | 261 | Privileged_RW 262 | Access from privileged software only. 263 | 0x1 264 | 265 | 266 | Unpriviledged_RO 267 | Writes by unprivileged software generates a permission fault. 268 | 0x2 269 | 270 | 271 | Full_Access 272 | Full Access. 273 | 0x3 274 | 275 | 276 | Privileged_RO 277 | Reads by privileged software only. 278 | 0x5 279 | 280 | 281 | Read_Only 282 | Read_Only by privileged or unprivileged software. 283 | 0x6 284 | 285 | 286 | Read_Only 287 | Read_Only by privileged or unprivileged software. 288 | 0x7 289 | 290 | 291 | 292 | 293 | XN 294 | Instruction access disable bit 295 | 28 296 | 1 297 | read-write 298 | 299 | 300 | I_Enabled 301 | Instruction fetches enabled. 302 | 0x0 303 | 304 | 305 | I_Disabled 306 | Instruction fetches disabled. 307 | 0x1 308 | 309 | 310 | 311 | 312 | 313 | 314 | RBAR_A1 315 | Uses (MPU_RNR[7:2]<<2) + 1 316 | 0x14 317 | 32 318 | 0x00000000 319 | 0xFFFFFFFF 320 | 321 | 322 | RASR_A1 323 | Uses (MPU_RNR[7:2]<<2) + 1 324 | 0x18 325 | 32 326 | 0x00000000 327 | 0xFFFFFFFF 328 | 329 | 330 | RBAR_A2 331 | Uses (MPU_RNR[7:2]<<2) + 2 332 | 0x1C 333 | 32 334 | 0x00000000 335 | 0xFFFFFFFF 336 | 337 | 338 | RASR_A2 339 | Uses (MPU_RNR[7:2]<<2) + 2 340 | 0x20 341 | 32 342 | 0x00000000 343 | 0xFFFFFFFF 344 | 345 | 346 | RBAR_A3 347 | Uses (MPU_RNR[7:2]<<2) + 3 348 | 0x24 349 | 32 350 | 0x00000000 351 | 0xFFFFFFFF 352 | 353 | 354 | RASR_A3 355 | Uses (MPU_RNR[7:2]<<2) + 3 356 | 0x28 357 | 32 358 | 0x00000000 359 | 0xFFFFFFFF 360 | 361 | 362 | 363 | --------------------------------------------------------------------------------