| 1 | /* |
| 2 | * ========== Copyright Header Begin ========================================== |
| 3 | * |
| 4 | * OpenSPARC T2 Processor File: RieslingInterface.h |
| 5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
| 7 | * |
| 8 | * The above named program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public |
| 10 | * License version 2 as published by the Free Software Foundation. |
| 11 | * |
| 12 | * The above named program is distributed in the hope that it will be |
| 13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public |
| 18 | * License along with this work; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 20 | * |
| 21 | * ========== Copyright Header End ============================================ |
| 22 | */ |
| 23 | #ifndef _RIESLINGINTERFACE_H |
| 24 | #define _RIESLINGINTERFACE_H |
| 25 | /************************************************************************ |
| 26 | ** |
| 27 | ** Copyright (C) 2002, Sun Microsystems, Inc. |
| 28 | ** |
| 29 | ** Sun considers its source code as an unpublished, proprietary |
| 30 | ** trade secret and it is available only under strict license provisions. |
| 31 | ** This copyright notice is placed here only to protect Sun in the event |
| 32 | ** the source is deemed a published work. Disassembly, decompilation, |
| 33 | ** or other means of reducing the object code to human readable form |
| 34 | ** is prohibited by the license agreement under which this code is |
| 35 | ** provided to the user or company in possession of this copy." |
| 36 | ** |
| 37 | *************************************************************************/ |
| 38 | |
| 39 | #define N2MODEL something_sane |
| 40 | |
| 41 | #include <iostream> |
| 42 | #include "MemoryTransaction.h" |
| 43 | #include "MemorySyncDefs.h" |
| 44 | #include "MemorySyncMessage.h" |
| 45 | #include "SS_Io.h" |
| 46 | |
| 47 | class RieslingInterface{ |
| 48 | public: |
| 49 | static int max_strands; |
| 50 | static int strands_per_core; |
| 51 | static int cores_per_cpu; |
| 52 | /** |
| 53 | * Default constructor |
| 54 | */ |
| 55 | RieslingInterface() |
| 56 | :io(&SS_Io::io) |
| 57 | {}; |
| 58 | |
| 59 | /** |
| 60 | * Destructor |
| 61 | */ |
| 62 | virtual ~RieslingInterface(){}; |
| 63 | |
| 64 | uint64_t readMemory(uint32_t cid, uint32_t tid, uint64_t addr, uint_t size, int convert=1); |
| 65 | void writeMemory(uint32_t cid, uint32_t tid, uint64_t addr, uint64_t data, uint_t size, int convert=1); |
| 66 | void slamMemory(uint32_t cid, uint32_t tid, uint64_t addr, uint64_t data, uint_t size, int convert=1); |
| 67 | |
| 68 | uint64_t convertPA(int cid, int tid, uint64_t pa); |
| 69 | |
| 70 | void setMaxStrands(int strands) { max_strands= strands; } |
| 71 | void setCoreStrands(int strands) { strands_per_core= strands; } |
| 72 | void setCpuCores(int cores) { cores_per_cpu = cores; } |
| 73 | |
| 74 | uint64_t getBits(uint64_t data, int ubit, int lbit, bool shift=false) { |
| 75 | if (((ubit - lbit) >= 63) || (ubit < lbit)) { |
| 76 | return data; |
| 77 | } |
| 78 | else { |
| 79 | uint64_t newData = (data >> lbit) & ((1ULL << (ubit - lbit + 1)) - 1); |
| 80 | if (shift == true) { |
| 81 | // shift data back to its original bit-location |
| 82 | newData = newData << lbit; |
| 83 | } |
| 84 | //std::cerr << "DBX: data=0x" << std::hex << data << " (ub=" << std::dec << ubit << " lb=" << lbit << ") newData=0x" << std::hex << newData << std::endl;//DBX |
| 85 | return newData; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | |
| 90 | private: |
| 91 | SS_Io *io; |
| 92 | |
| 93 | }; |
| 94 | |
| 95 | #endif /* _RIESLINGINTERFACE_H */ |