/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* $Source: src/usr/runtime/tce.H $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ /* COPYRIGHT International Business Machines Corp. 2013,2014 */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ /* you may not use this file except in compliance with the License. */ /* You may obtain a copy of the License at */ /* */ /* http://www.apache.org/licenses/LICENSE-2.0 */ /* */ /* Unless required by applicable law or agreed to in writing, software */ /* distributed under the License is distributed on an "AS IS" BASIS, */ /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ /* implied. See the License for the specific language governing */ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ #ifndef __TCE_H #define __TCE_H #include #include #include #include struct TceEntry { // TCE Table union { uint64_t WholeTceEntry; struct { uint64_t realPageNumber :52; // real page number uint64_t valid :1; // The tces is valid for IO uint64_t reserved :9; // reserved bits uint64_t writeAccess :1; // Write access allowed uint64_t readAccess :1; // Read access allowed }; }; }; /** @class TceMgr * @brief Responsible for managing the TCE entries * */ class TceMgr { private: /** Indicator of TCEs being intialized */ int tceEntryInit; /** Pointer to the Mapped TCE Table */ TceEntry *tceTableVaPtr; /** physical address of the TCE Table */ uint64_t tceTablePhysAddr; //** Max number of TCE entries - via size*/ uint64_t maxTceEntries; /** size of the Tce Table */ uint64_t tceTableSize; /** * @brief Responsible for mapping the TCE Table * * @return errlHndl_t - Return error log if unsuccessful * */ errlHndl_t mapTceTable(void); public: /** * @brief Constructor. Initializes instance variables. * @param[in/default] i_tableAddr - Starting address of the TCE * table.. Default address is TCE_TABLE_ADDR. This was added * for testing TCE entries and not using the "real" table * @param[in/default] i_tableSize - Size of the TCE table. Default value * is TCE_TABLE_SIZE */ TceMgr(uint64_t i_tableAddr = TCE_TABLE_ADDR, uint64_t i_tableSize = TCE_TABLE_SIZE); /** * Destructor. * No action necessary. */ ~TceMgr(); /** Max TCE Entries for the TCE Table */ enum { NUM_TCE_TABLE_ENTRIES = 0x80000, // 512k entries }; enum { INVALID_TOKEN_ENTRY = 0xFFFFFFFFFFFFFFFF, }; /** * @brief Responsible for initalizing the TCE Table and mapping the * TCEtable * * @return errlHndl_t - Return error log if unsuccessful * */ errlHndl_t createTceTable(); /** * @brief Responsible for setting up the Processors to point to the TCE * table * * @return errlHndl_t - Return error log if unsuccessful * */ errlHndl_t initTceInHdw(); /** * @brief Responsible for allocating TCE Entries * * @param[in] i_startingAddress - Starting address to TCE * @param[in] i_size - Size of the address space * @param[out] startingToken - Starting Entry into the table. * (this is an offset into the array based on the * TCE index * PAGESIZE. Each TCE entry maps to a * pagesize of memory) * * @return errl - Return Error Handle if failed. * */ errlHndl_t allocateTces(uint64_t i_startingAddress, uint64_t i_size, uint64_t& o_startingToken); /** * @brief Responsible for deallocating TCE Entries * * @param[in] i_startingToken - Token indicating the starting entry to * remove * @param[in] i_size - Size of memory space to remove TCE entries * associated * * @return errl - Return Error Handle if fatal failure occurred. * */ errlHndl_t deallocateTces(uint64_t i_startingToken, uint64_t i_size); }; #endif