-- Semantic analysis. -- Copyright (C) 2002, 2003, 2004, 2005 Tristan Gingold -- -- GHDL 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, or (at your option) any later -- version. -- -- GHDL 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 GHDL; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with Iirs; use Iirs; with Types; use Types; package Sem_Scopes is -- The purpose of SEM_NAME package is to handle association between -- identifiers and declarations. -- Roughly speacking, it implements ch10 of LRM: scope and visibility. -- -- Basic elements are: declarations and declarative region. -- Declaration should be understood in the large meaning: any textual -- construction declaring an identifier, which can be a label. -- A declarative region contains declarations and possibly other -- declarative regions. -- -- Rules are scope, visibility and overloading. -- -- Create and close a declarative region. -- By closing a declarative region, all declarations made in this region -- are discarded. procedure Open_Declarative_Region; procedure Close_Declarative_Region; -- Add meaning DECL for its identifier to the current declarative region. procedure Add_Name (Decl: Iir); pragma Inline (Add_Name); -- Add meaning DECL to the identifier IDENT. -- POTENTIALLY is true if the identifier comes from a use clause. procedure Add_Name (Decl: Iir; Ident : Name_Id; Potentially: Boolean); -- Set the visible_flag of DECL to true. procedure Name_Visible (Decl : Iir); -- Replace the interpretation OLD of ID by DECL. -- ID must have a uniq interpretation OLD (ie, it must not be overloaded). -- The interpretation must have been done in the current scope. -- -- This procedure is used when the meaning of a name is changed due to its -- analysis, eg: when a concurrent_procedure_call_statement becomes -- a component_instantiation_statement. procedure Replace_Name (Id: Name_Id; Old : Iir; Decl: Iir); -- Interpretation is a simply linked list of what an identifier means. -- In LRM08 12.3 Visibility, the sentence is 'the declaration defines a -- possible meaning of this occurrence'. -- FIXME: replace Interpretation by Meaning. type Name_Interpretation_Type is private; -- Return true if INTER is a valid interpretation, ie has a corresponding -- declaration. There are only two invalids interpretations, which -- are declared just below as constants. function Valid_Interpretation (Inter : Name_Interpretation_Type) return Boolean; pragma Inline (Valid_Interpretation); -- Get the first interpretation of identifier ID. function Get_Interpretation (Id: Name_Id) return Name_Interpretation_Type; -- Get the next interpretation from an interpretation. function Get_Next_Interpretation (Ni: Name_Interpretation_Type) return Name_Interpretation_Type; -- Get a declaration associated with an interpretation. function Get_Declaration (Ni: Name_Interpretation_Type) return Iir; pragma Inline (Get_Declaration); -- Same as Get_Declaration, but get the name of non-object alias. -- (ie, can never returns an object alias). function Get_Non_Alias_Declaration (Ni: Name_Interpretation_Type) return Iir; -- Get the previous interpretation of identifier ID, ie the interpretation -- for ID before the current interpretation of ID. function Get_Under_Interpretation (Id : Name_Id) return Name_Interpretation_Type; -- Return TRUE if INTER was made directly visible via a use clause. function Is_Potentially_Visible (Inter: Name_Interpretation_Type) return Boolean; pragma Inline (Is_Potentially_Visible); -- Return TRUE if INTER was made direclty visible in the current -- declarative region. Note this is different from being declared in the -- current declarative region because of use clauses. function Is_In_Current_Declarative_Region (Inter: Name_Interpretation_Type) return Boolean; pragma Inline (Is_In_Current_Declarative_Region); -- Push and pop all interpretations. -- This can be used to suspend name interpretation, in case of recursive -- semantics. -- After a push, all names have
/* Copyright 2019 Nick Brassel (tzarc)
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include "eeprom_driver.h"
#include "eeprom_transient.h"
__attribute__((aligned(4))) static uint8_t transientBuffer[TRANSIENT_EEPROM_SIZE] = {0};
size_t clamp_length(intptr_t offset, size_t len) {
if (offset + len > TRANSIENT_EEPROM_SIZE) {
len = TRANSIENT_EEPROM_SIZE - offset;
}
return len;
}
void eeprom_driver_init(void) { eeprom_driver_erase(); }
void eeprom_driver_erase(void) { memset(transientBuffer, 0x00, TRANSIENT_EEPROM_SIZE); }
void eeprom_read_block(void *buf, const void *addr, size_t len) {
intptr_t offset = (intptr_t)addr;
memset(buf, 0x00, len);
len = clamp_length(offset, len);
if (len > 0) {
memcpy(buf, &transientBuffer[offset], len);
}
}
void eeprom_write_block(const void *buf, void *addr, size_t len) {
intptr_t offset = (intptr_t)addr;
len = clamp_length(offset, len);
if (len > 0) {
memcpy(&transientBuffer[offset], buf, len);
}
}