| 1 | // ========== Copyright Header Begin ========================================== |
| 2 | // |
| 3 | // OpenSPARC T2 Processor File: SS_Cpu.cc |
| 4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. |
| 6 | // |
| 7 | // The above named program is free software; you can redistribute it and/or |
| 8 | // modify it under the terms of the GNU General Public |
| 9 | // License version 2 as published by the Free Software Foundation. |
| 10 | // |
| 11 | // The above named program is distributed in the hope that it will be |
| 12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | // General Public License for more details. |
| 15 | // |
| 16 | // You should have received a copy of the GNU General Public |
| 17 | // License along with this work; if not, write to the Free Software |
| 18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. |
| 19 | // |
| 20 | // ========== Copyright Header End ============================================ |
| 21 | |
| 22 | #include "SS_Cpu.h" |
| 23 | #include "SS_Strand.h" |
| 24 | #include "SS_Model.h" |
| 25 | #include "SS_Signal.h" |
| 26 | |
| 27 | SS_Cpu::SS_Cpu( SS_Model& _model, const char* _name )/*{{{*/ |
| 28 | : |
| 29 | SS_Node(_model,_name), |
| 30 | model(_model), |
| 31 | strand_count(0) |
| 32 | { |
| 33 | clr_stepping(); |
| 34 | } |
| 35 | /*}}}*/ |
| 36 | |
| 37 | void SS_Cpu::flush( SS_Paddr pa )/*{{{*/ |
| 38 | { |
| 39 | for (uint_t i = 0; i < strand_count; i++) |
| 40 | strand[i]->flush(pa); |
| 41 | } |
| 42 | /*}}}*/ |
| 43 | void SS_Cpu::flush( SS_Strand* s, SS_Paddr pa, uint_t size )/*{{{*/ |
| 44 | { |
| 45 | SS_Signal::Type type; |
| 46 | |
| 47 | // Currently we support three sizes, 8b (sun sparc standard) |
| 48 | // page flush (8k) and infinite (size == ~0). The page flush |
| 49 | // and infinite flush (all decode caches) are handled with |
| 50 | // the FLUSH_8K as that is flush all decode caches. |
| 51 | |
| 52 | if (size == 8) |
| 53 | type = SS_Signal::FLUSH_8B; |
| 54 | else if (size == 8192) |
| 55 | type = SS_Signal::FLUSH_8K; |
| 56 | else |
| 57 | type = SS_Signal::FLUSH_ALL; |
| 58 | |
| 59 | for (uint_t i = 0; i < strand_count; i++) |
| 60 | { |
| 61 | if (is_stepping(i)) |
| 62 | { |
| 63 | SS_Signal* sgn = s->msg.make_signal(type); |
| 64 | sgn->flush_pa = pa; |
| 65 | strand[i]->post_signal(sgn); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | /*}}}*/ |
| 70 | void SS_Cpu::ras_flush( SS_Strand* requesting_strand, SS_Paddr pa, uint64_t size, SS_MemErrDetector::CacheType type )/*{{{*/ |
| 71 | { |
| 72 | for (uint_t i = 0; i < strand_count; i++) |
| 73 | strand[i]->mem_err_detector.ras_flush(strand[i], requesting_strand, pa, size, type); |
| 74 | } |
| 75 | /*}}}*/ |
| 76 | |
| 77 | void SS_Cpu::snapshot( SS_SnapShot& ss )/*{{{*/ |
| 78 | { |
| 79 | char prefix[32]; |
| 80 | get_name(prefix); |
| 81 | |
| 82 | // Before any snapshot is saved or loaded we ensure that the signal |
| 83 | // queues are handled with first. That way we don't have to snapshot |
| 84 | // those queues when we save and on load we don't have to restore |
| 85 | // them. Note that this is functioanlly correct behaviour. |
| 86 | |
| 87 | for (uint_t i = 0; i < strand_count; i++) |
| 88 | strand[i]->peek_signal(); |
| 89 | |
| 90 | uint_t flush_count = 0; // Leave here so snapshot is ok |
| 91 | uint_t flush_strand = 0; // Leave here so snapshot is ok |
| 92 | uint_t strand_count_ = 0; // Regenerated during restore |
| 93 | uint_t strand_stepping_ = 0; // Regenerated during restore |
| 94 | |
| 95 | sprintf(ss.tag,"%s.strand_count",prefix); ss.val(&strand_count); |
| 96 | sprintf(ss.tag,"%s.strand_stepping",prefix); ss.val(&strand_stepping[0]); |
| 97 | if (ss.get_version() >= 4) |
| 98 | { |
| 99 | sprintf(ss.tag,"%s.strand_stepping.1",prefix); ss.val(&strand_stepping[1]); |
| 100 | } |
| 101 | sprintf(ss.tag,"%s.flush_strand",prefix); ss.val(&flush_strand); |
| 102 | sprintf(ss.tag,"%s.flush_count",prefix); ss.val(&flush_count); |
| 103 | } |
| 104 | /*}}}*/ |
| 105 | void SS_Cpu::ras_enable(char* cmd)/*{{{*/ |
| 106 | { |
| 107 | for (uint_t i = 0; i < strand_count; i++) |
| 108 | { |
| 109 | strand[i]->ras_enable(strand[i], cmd); |
| 110 | } |
| 111 | } |
| 112 | /*}}}*/ |