dmi.hh revision 13521:74fa3ac44057
12810SN/A/***************************************************************************** 212724Snikos.nikoleris@arm.com 38856Sandreas.hansson@arm.com Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 48856Sandreas.hansson@arm.com more contributor license agreements. See the NOTICE file distributed 58856Sandreas.hansson@arm.com with this work for additional information regarding copyright ownership. 68856Sandreas.hansson@arm.com Accellera licenses this file to you under the Apache License, Version 2.0 78856Sandreas.hansson@arm.com (the "License"); you may not use this file except in compliance with the 88856Sandreas.hansson@arm.com License. You may obtain a copy of the License at 98856Sandreas.hansson@arm.com 108856Sandreas.hansson@arm.com http://www.apache.org/licenses/LICENSE-2.0 118856Sandreas.hansson@arm.com 128856Sandreas.hansson@arm.com Unless required by applicable law or agreed to in writing, software 138856Sandreas.hansson@arm.com distributed under the License is distributed on an "AS IS" BASIS, 142810SN/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 152810SN/A implied. See the License for the specific language governing 162810SN/A permissions and limitations under the License. 172810SN/A 182810SN/A *****************************************************************************/ 192810SN/A 202810SN/A#ifndef __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_DMI_HH__ 212810SN/A#define __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_DMI_HH__ 222810SN/A 232810SN/A#include <systemc> 242810SN/A 252810SN/Anamespace tlm 262810SN/A{ 272810SN/A 282810SN/Aclass tlm_dmi 292810SN/A{ 302810SN/A public: 312810SN/A // Enum for indicating the access granted to the initiator. 322810SN/A // The initiator uses gp.m_command to indicate it intention (read/write) 332810SN/A // The target is allowed to promote DMI_ACCESS_READ or DMI_ACCESS_WRITE 342810SN/A // requests to dmi_access_read_write. 352810SN/A 362810SN/A enum dmi_access_e { 372810SN/A DMI_ACCESS_NONE = 0x00, // no access 382810SN/A DMI_ACCESS_READ = 0x01, // read access 392810SN/A DMI_ACCESS_WRITE = 0x02, // write access 402810SN/A DMI_ACCESS_READ_WRITE = DMI_ACCESS_READ | DMI_ACCESS_WRITE 4112724Snikos.nikoleris@arm.com // read/write access 422810SN/A }; 432810SN/A 442810SN/A tlm_dmi() { init(); } 452810SN/A 462810SN/A void 472810SN/A init() 482810SN/A { 4911486Snikos.nikoleris@arm.com m_dmi_ptr = nullptr; 5011486Snikos.nikoleris@arm.com m_dmi_start_address = 0x0; 5112724Snikos.nikoleris@arm.com m_dmi_end_address = (sc_dt::uint64)(-1); 5212724Snikos.nikoleris@arm.com m_dmi_access = DMI_ACCESS_NONE; 538232Snate@binkert.org m_dmi_read_latency = sc_core::SC_ZERO_TIME; 5412724Snikos.nikoleris@arm.com m_dmi_write_latency = sc_core::SC_ZERO_TIME; 5513222Sodanrc@yahoo.com.br } 5612724Snikos.nikoleris@arm.com 5711486Snikos.nikoleris@arm.com unsigned char *get_dmi_ptr() const { return m_dmi_ptr; } 5812724Snikos.nikoleris@arm.com sc_dt::uint64 get_start_address() const { return m_dmi_start_address; } 5912724Snikos.nikoleris@arm.com sc_dt::uint64 get_end_address() const { return m_dmi_end_address; } 6012724Snikos.nikoleris@arm.com sc_core::sc_time get_read_latency() const { return m_dmi_read_latency; } 6113352Snikos.nikoleris@arm.com sc_core::sc_time get_write_latency() const { return m_dmi_write_latency; } 6212724Snikos.nikoleris@arm.com dmi_access_e get_granted_access() const { return m_dmi_access; } 6312724Snikos.nikoleris@arm.com bool is_none_allowed() const { return m_dmi_access == DMI_ACCESS_NONE; } 6412724Snikos.nikoleris@arm.com bool 6512724Snikos.nikoleris@arm.com is_read_allowed() const 662810SN/A { 672810SN/A return (m_dmi_access & DMI_ACCESS_READ) == DMI_ACCESS_READ; 682810SN/A } 698856Sandreas.hansson@arm.com bool 708856Sandreas.hansson@arm.com is_write_allowed() const 718856Sandreas.hansson@arm.com { 7213564Snikos.nikoleris@arm.com return (m_dmi_access & DMI_ACCESS_WRITE) == DMI_ACCESS_WRITE; 7313564Snikos.nikoleris@arm.com } 7412084Sspwilson2@wisc.edu bool 7512084Sspwilson2@wisc.edu is_read_write_allowed() const 768856Sandreas.hansson@arm.com { 778856Sandreas.hansson@arm.com return (m_dmi_access & DMI_ACCESS_READ_WRITE) == DMI_ACCESS_READ_WRITE; 784475SN/A } 7911053Sandreas.hansson@arm.com 805034SN/A void set_dmi_ptr(unsigned char *p) { m_dmi_ptr = p; } 8112724Snikos.nikoleris@arm.com void set_start_address(sc_dt::uint64 addr) { m_dmi_start_address = addr; } 8212724Snikos.nikoleris@arm.com void set_end_address(sc_dt::uint64 addr) { m_dmi_end_address = addr; } 8311377Sandreas.hansson@arm.com void set_read_latency(sc_core::sc_time t) { m_dmi_read_latency = t; } 8411377Sandreas.hansson@arm.com void set_write_latency(sc_core::sc_time t) { m_dmi_write_latency = t; } 8512724Snikos.nikoleris@arm.com void set_granted_access(dmi_access_e a) { m_dmi_access = a; } 8612724Snikos.nikoleris@arm.com void allow_none() { m_dmi_access = DMI_ACCESS_NONE; } 8713352Snikos.nikoleris@arm.com void allow_read() { m_dmi_access = DMI_ACCESS_READ; } 8812724Snikos.nikoleris@arm.com void allow_write() { m_dmi_access = DMI_ACCESS_WRITE; } 8912724Snikos.nikoleris@arm.com void allow_read_write() { m_dmi_access = DMI_ACCESS_READ_WRITE; } 9012724Snikos.nikoleris@arm.com 9112724Snikos.nikoleris@arm.com private: 9212724Snikos.nikoleris@arm.com // If the forward call is successful, the target returns the dmi_ptr, 9311053Sandreas.hansson@arm.com // which must point to the data element corresponding to the 9411722Ssophiane.senni@gmail.com // dmi_start_address. The data is organized as a byte array with the 9511722Ssophiane.senni@gmail.com // endianness of the target (endianness member of the tlm_dmi struct). 9611722Ssophiane.senni@gmail.com 9711722Ssophiane.senni@gmail.com unsigned char *m_dmi_ptr; 989263Smrinmoy.ghosh@arm.com 9913418Sodanrc@yahoo.com.br // The absolute start and end addresses of the DMI region. If the decoder 1005034SN/A // logic in the interconnect changes the address field e.g. by masking, the 10111331Sandreas.hansson@arm.com // interconnect is responsible to transform the relative address back to an 10212724Snikos.nikoleris@arm.com // absolute address again. 10310884Sandreas.hansson@arm.com 1044626SN/A sc_dt::uint64 m_dmi_start_address; 10510360Sandreas.hansson@arm.com sc_dt::uint64 m_dmi_end_address; 10611484Snikos.nikoleris@arm.com 1075034SN/A // Granted access 1088883SAli.Saidi@ARM.com 1098833Sdam.sunwoo@arm.com dmi_access_e m_dmi_access; 1104458SN/A 11111377Sandreas.hansson@arm.com // These members define the latency of read/write transactions. The 11211377Sandreas.hansson@arm.com // initiator must initialize these members to zero before requesting a 11311377Sandreas.hansson@arm.com // dmi pointer, because both the interconnect as well as the target can 11411377Sandreas.hansson@arm.com // add to the total transaction latency. 11511377Sandreas.hansson@arm.com // Depending on the 'type' attribute only one, or both of these attributes 11611377Sandreas.hansson@arm.com // will be valid. 11711331Sandreas.hansson@arm.com 11811331Sandreas.hansson@arm.com sc_core::sc_time m_dmi_read_latency; 11912724Snikos.nikoleris@arm.com sc_core::sc_time m_dmi_write_latency; 12012843Srmk35@cl.cam.ac.uk}; 12112724Snikos.nikoleris@arm.com 12213419Sodanrc@yahoo.com.br} // namespace tlm 12312724Snikos.nikoleris@arm.com 12412724Snikos.nikoleris@arm.com#endif /* __SYSTEMC_EXT_TLM_CORE_2_INTERFACES_DMI_HH__ */ 12512724Snikos.nikoleris@arm.com