------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2016, Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Caches; use Caches; with Objects; use Objects; with Objects.extended; use Objects.extended; with Text_IO; use Text_IO; with Translate; use Translate; with sets; with initialize_framework; use initialize_framework; with Caches; use Caches.Cache_Blocks_Table_Package; package body Cache_Access_Profile_Set is ------------------------------------------------------ -- CACHE ACCESS PROFILE ------------------------------------------------------ procedure Check_Cache_Access_Profile (my_cache_access_profiles : in out Cache_Access_Profiles_Set; a_cache_access_profile : in out Cache_Access_Profile_Ptr; name : in Unbounded_String; ucbs : in Cache_Blocks_Table; ecbs : in Cache_Blocks_Table) is begin if (name = "") then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Cache_Access_Profile_Name (Current_Language) & Lb_Mandatory (Current_Language))); end if; if not Is_A_Valid_Identifier (Name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Cache_Access_Profile (Current_Language) & Name & " : " & Lb_Cache_Access_Profile_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; if (ecbs.Nb_Entries <= 0) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Cache_Access_Profile (Current_Language) & Name & " : " & Lb_ECBs_Nb_Entries (Current_Language) & Lb_Must_Be (Current_Language) & Lb_greater_or_equal_than (Current_Language) & "0")); end if; if (ucbs.Nb_Entries > ecbs.Nb_Entries) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Cache_Access_Profile (Current_Language) & Name & " : " & Lb_ECBs_Nb_Entries (Current_Language) & Lb_Must_Be (Current_Language) & Lb_UCBs_Nb_Entries (Current_Language))); end if; end Check_Cache_Access_Profile; procedure Add_Cache_Access_Profile (my_cache_access_profiles : in out Cache_Access_Profiles_Set; a_cache_access_profile : in out Cache_Access_Profile_Ptr; name : in Unbounded_String; ucbs : in Cache_Blocks_Table; ecbs : in Cache_Blocks_Table) is my_iterator : Cache_Access_Profiles_Iterator; begin check_initialize; Check_Cache_Access_Profile(my_cache_access_profiles => my_cache_access_profiles, a_cache_access_profile => a_cache_access_profile, name => name, ucbs => ucbs, ecbs => ecbs); if (get_number_of_elements (my_cache_access_profiles) > 0) then reset_iterator(my_cache_access_profiles,my_iterator); loop current_element(my_cache_access_profiles,a_cache_access_profile,my_iterator); if(name = a_cache_access_profile.name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Cache_Access_Profile (Current_Language) & " " & Name & " : " & Lb_Cache_Access_Profile_Name (Current_Language) & Lb_Already_Defined (Current_Language))); end if; exit when is_last_element (my_cache_access_profiles, my_iterator); next_element (my_cache_access_profiles, my_iterator); end loop; end if; a_cache_access_profile := new Cache_Access_Profile; a_cache_access_profile.name := name; a_cache_access_profile.UCBs := ucbs; a_cache_access_profile.ECBs := ecbs; add (my_cache_access_profiles, a_cache_access_profile); exception when Cache_Access_Profile_Set.full_set => Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Can_Not_Define_More_Cache_Access_Profiles (Current_Language))); end Add_Cache_Access_Profile; procedure Add_Cache_Access_Profile (my_cache_access_profiles : in out Cache_Access_Profiles_Set; name : in Unbounded_String; ucbs : in Cache_Blocks_Table; ecbs : in Cache_Blocks_Table) is a_cache_access_profile : Cache_Access_Profile_Ptr; begin Add_Cache_Access_Profile(my_cache_access_profiles => my_cache_access_profiles, a_cache_access_profile => a_cache_access_profile, name => name, ucbs => ucbs, ecbs => ecbs); end Add_Cache_Access_Profile; procedure Update_Cache_Access_Profile (my_cache_access_profiles : in out Cache_Access_Profiles_Set; name : in Unbounded_String; ucbs : in Cache_Blocks_Table; ecbs : in Cache_Blocks_Table) is a_cache_access_profile : Cache_Access_Profile_Ptr; begin Check_Cache_Access_Profile(my_cache_access_profiles => my_cache_access_profiles, a_cache_access_profile => a_cache_access_profile, name => name, ucbs => ucbs, ecbs => ecbs); a_cache_access_profile := Search_Cache_Access_Profile(my_cache_access_profiles,name); Delete(my_cache_access_profiles,a_cache_access_profile); Add_Cache_Access_Profile(my_cache_access_profiles => my_cache_access_profiles, a_cache_access_profile => a_cache_access_profile, name => name, ucbs => ucbs, ecbs => ecbs); end Update_Cache_Access_Profile; procedure Delete_Cache_Access_Profile (my_cache_access_profiles : in out Cache_Access_Profiles_Set; name : in Unbounded_String) is a_cache_access_profile : Cache_Access_Profile_Ptr; begin a_cache_access_profile := Search_Cache_Access_Profile(my_cache_access_profiles,name); Delete(my_cache_access_profiles,a_cache_access_profile); end Delete_Cache_Access_Profile; function Search_Cache_Access_Profile (my_cache_access_profiles : in Cache_Access_Profiles_Set; name : in Unbounded_String) return Cache_Access_Profile_Ptr is my_iterator : Cache_Access_Profiles_Iterator; a_cache_access_profile : Cache_Access_Profile_Ptr; result : Cache_Access_Profile_Ptr; found : Boolean := False; begin reset_iterator(my_cache_access_profiles,my_iterator); loop current_element (my_cache_access_profiles, a_cache_access_profile, my_iterator); if (a_cache_access_profile.name = name) then found := True; result := a_cache_access_profile; end if; exit when is_last_element (my_cache_access_profiles,my_iterator); next_element (my_cache_access_profiles,my_iterator); end loop; if not Found then Raise_Exception (Cache_Access_Profile_Not_Found'Identity, To_String (Lb_Cache_Access_Profile (Current_Language) & "=" & Name)); end if; return Result; end Search_Cache_Access_Profile; end Cache_Access_Profile_Set;