tsunami_cchip.cc revision 4870
1892SN/A/*
21762SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
3892SN/A * All rights reserved.
4892SN/A *
5892SN/A * Redistribution and use in source and binary forms, with or without
6892SN/A * modification, are permitted provided that the following conditions are
7892SN/A * met: redistributions of source code must retain the above copyright
8892SN/A * notice, this list of conditions and the following disclaimer;
9892SN/A * redistributions in binary form must reproduce the above copyright
10892SN/A * notice, this list of conditions and the following disclaimer in the
11892SN/A * documentation and/or other materials provided with the distribution;
12892SN/A * neither the name of the copyright holders nor the names of its
13892SN/A * contributors may be used to endorse or promote products derived from
14892SN/A * this software without specific prior written permission.
15892SN/A *
16892SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17892SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18892SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19892SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20892SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21892SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22892SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23892SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24892SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25892SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26892SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665SN/A *
282665SN/A * Authors: Ali Saidi
292665SN/A *          Ron Dreslinski
30892SN/A */
31767SN/A
321730SN/A/** @file
33798SN/A * Emulation of the Tsunami CChip CSRs
34767SN/A */
35767SN/A
36767SN/A#include <deque>
37767SN/A#include <string>
38767SN/A#include <vector>
39767SN/A
402432SN/A#include "arch/alpha/ev5.hh"
41767SN/A#include "base/trace.hh"
423348SN/A#include "cpu/intr_control.hh"
433348SN/A#include "cpu/thread_context.hh"
443540Sgblack@eecs.umich.edu#include "dev/alpha/tsunami.hh"
453540Sgblack@eecs.umich.edu#include "dev/alpha/tsunami_cchip.hh"
463540Sgblack@eecs.umich.edu#include "dev/alpha/tsunamireg.h"
473348SN/A#include "mem/packet.hh"
483348SN/A#include "mem/packet_access.hh"
492523SN/A#include "mem/port.hh"
50767SN/A#include "sim/builder.hh"
51767SN/A#include "sim/system.hh"
52767SN/A
53767SN/Ausing namespace std;
542107SN/A//Should this be AlphaISA?
552107SN/Ausing namespace TheISA;
56767SN/A
572523SN/ATsunamiCChip::TsunamiCChip(Params *p)
582523SN/A    : BasicPioDevice(p), tsunami(p->tsunami)
59767SN/A{
603846Shsul@eecs.umich.edu    pioSize = 0x10000000;
61909SN/A
62767SN/A    drir = 0;
631290SN/A    ipint = 0;
641290SN/A    itint = 0;
651290SN/A
661290SN/A    for (int x = 0; x < Tsunami::Max_CPUs; x++)
671290SN/A    {
681290SN/A        dim[x] = 0;
691290SN/A        dir[x] = 0;
701290SN/A    }
71775SN/A
72775SN/A    //Put back pointer in tsunami
73775SN/A    tsunami->cchip = this;
74767SN/A}
75767SN/A
762523SN/ATick
773349SN/ATsunamiCChip::read(PacketPtr pkt)
78767SN/A{
792641SN/A    DPRINTF(Tsunami, "read  va=%#x size=%d\n", pkt->getAddr(), pkt->getSize());
80767SN/A
812641SN/A    assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
821290SN/A
832641SN/A    Addr regnum = (pkt->getAddr() - pioAddr) >> 6;
842641SN/A    Addr daddr = (pkt->getAddr() - pioAddr);
85767SN/A
862630SN/A    pkt->allocate();
872641SN/A    switch (pkt->getSize()) {
88767SN/A
89767SN/A      case sizeof(uint64_t):
903875Sbinkertn@umich.edu          pkt->set<uint64_t>(0);
913875Sbinkertn@umich.edu
921290SN/A          if (daddr & TSDEV_CC_BDIMS)
931290SN/A          {
942630SN/A              pkt->set(dim[(daddr >> 4) & 0x3F]);
952523SN/A              break;
961290SN/A          }
971290SN/A
981290SN/A          if (daddr & TSDEV_CC_BDIRS)
991290SN/A          {
1002630SN/A              pkt->set(dir[(daddr >> 4) & 0x3F]);
1012523SN/A              break;
1021290SN/A          }
1031290SN/A
1041290SN/A          switch(regnum) {
105767SN/A              case TSDEV_CC_CSR:
1062630SN/A                  pkt->set(0x0);
1072523SN/A                  break;
108767SN/A              case TSDEV_CC_MTR:
109767SN/A                  panic("TSDEV_CC_MTR not implemeted\n");
1102523SN/A                   break;
111767SN/A              case TSDEV_CC_MISC:
1122630SN/A                  pkt->set((ipint << 8) & 0xF | (itint << 4) & 0xF |
1132630SN/A                                     (pkt->req->getCpuNum() & 0x3));
1142523SN/A                  break;
115767SN/A              case TSDEV_CC_AAR0:
116767SN/A              case TSDEV_CC_AAR1:
117767SN/A              case TSDEV_CC_AAR2:
118767SN/A              case TSDEV_CC_AAR3:
1192630SN/A                  pkt->set(0);
1202523SN/A                  break;
121767SN/A              case TSDEV_CC_DIM0:
1222630SN/A                  pkt->set(dim[0]);
1232523SN/A                  break;
124767SN/A              case TSDEV_CC_DIM1:
1252630SN/A                  pkt->set(dim[1]);
1262523SN/A                  break;
127767SN/A              case TSDEV_CC_DIM2:
1282630SN/A                  pkt->set(dim[2]);
1292523SN/A                  break;
130767SN/A              case TSDEV_CC_DIM3:
1312630SN/A                  pkt->set(dim[3]);
1322523SN/A                  break;
133767SN/A              case TSDEV_CC_DIR0:
1342630SN/A                  pkt->set(dir[0]);
1352523SN/A                  break;
136767SN/A              case TSDEV_CC_DIR1:
1372630SN/A                  pkt->set(dir[1]);
1382523SN/A                  break;
139767SN/A              case TSDEV_CC_DIR2:
1402630SN/A                  pkt->set(dir[2]);
1412523SN/A                  break;
142767SN/A              case TSDEV_CC_DIR3:
1432630SN/A                  pkt->set(dir[3]);
1442523SN/A                  break;
145767SN/A              case TSDEV_CC_DRIR:
1462630SN/A                  pkt->set(drir);
1472523SN/A                  break;
148767SN/A              case TSDEV_CC_PRBEN:
149767SN/A                  panic("TSDEV_CC_PRBEN not implemented\n");
1502523SN/A                  break;
151767SN/A              case TSDEV_CC_IIC0:
152767SN/A              case TSDEV_CC_IIC1:
153767SN/A              case TSDEV_CC_IIC2:
154767SN/A              case TSDEV_CC_IIC3:
155767SN/A                  panic("TSDEV_CC_IICx not implemented\n");
1562523SN/A                  break;
157767SN/A              case TSDEV_CC_MPR0:
158767SN/A              case TSDEV_CC_MPR1:
159767SN/A              case TSDEV_CC_MPR2:
160767SN/A              case TSDEV_CC_MPR3:
161767SN/A                  panic("TSDEV_CC_MPRx not implemented\n");
1622523SN/A                  break;
1631290SN/A              case TSDEV_CC_IPIR:
1642630SN/A                  pkt->set(ipint);
1652523SN/A                  break;
1661290SN/A              case TSDEV_CC_ITIR:
1672630SN/A                  pkt->set(itint);
1682523SN/A                  break;
169768SN/A              default:
170768SN/A                  panic("default in cchip read reached, accessing 0x%x\n");
171767SN/A           } // uint64_t
172767SN/A
173767SN/A      break;
174767SN/A      case sizeof(uint32_t):
175767SN/A      case sizeof(uint16_t):
176767SN/A      case sizeof(uint8_t):
177767SN/A      default:
178768SN/A        panic("invalid access size(?) for tsunami register!\n");
179767SN/A    }
1802549SN/A    DPRINTF(Tsunami, "Tsunami CChip: read  regnum=%#x size=%d data=%lld\n",
1812641SN/A            regnum, pkt->getSize(), pkt->get<uint64_t>());
182767SN/A
1834870Sstever@eecs.umich.edu    pkt->makeAtomicResponse();
1842523SN/A    return pioDelay;
185767SN/A}
186767SN/A
1872523SN/ATick
1883349SN/ATsunamiCChip::write(PacketPtr pkt)
189767SN/A{
1902641SN/A    assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
1912641SN/A    Addr daddr = pkt->getAddr() - pioAddr;
1922641SN/A    Addr regnum = (pkt->getAddr() - pioAddr) >> 6 ;
1932539SN/A
1942523SN/A
1952641SN/A    assert(pkt->getSize() == sizeof(uint64_t));
1962523SN/A
1972641SN/A    DPRINTF(Tsunami, "write - addr=%#x value=%#x\n", pkt->getAddr(), pkt->get<uint64_t>());
198767SN/A
199830SN/A    bool supportedWrite = false;
200830SN/A
201767SN/A
2022539SN/A    if (daddr & TSDEV_CC_BDIMS)
2032539SN/A    {
2042539SN/A        int number = (daddr >> 4) & 0x3F;
2051290SN/A
2062539SN/A        uint64_t bitvector;
2072539SN/A        uint64_t olddim;
2082539SN/A        uint64_t olddir;
2091290SN/A
2102539SN/A        olddim = dim[number];
2112539SN/A        olddir = dir[number];
2122630SN/A        dim[number] = pkt->get<uint64_t>();
2132539SN/A        dir[number] = dim[number] & drir;
2142539SN/A        for(int x = 0; x < Tsunami::Max_CPUs; x++)
2152539SN/A        {
2162539SN/A            bitvector = ULL(1) << x;
2172539SN/A            // Figure out which bits have changed
2182539SN/A            if ((dim[number] & bitvector) != (olddim & bitvector))
2192539SN/A            {
2202539SN/A                // The bit is now set and it wasn't before (set)
2212539SN/A                if((dim[number] & bitvector) && (dir[number] & bitvector))
2222539SN/A                {
2232539SN/A                    tsunami->intrctrl->post(number, TheISA::INTLEVEL_IRQ1, x);
2242539SN/A                    DPRINTF(Tsunami, "dim write resulting in posting dir"
2252539SN/A                            " interrupt to cpu %d\n", number);
2262539SN/A                }
2272539SN/A                else if ((olddir & bitvector) &&
2282539SN/A                        !(dir[number] & bitvector))
2292539SN/A                {
2302539SN/A                    // The bit was set and now its now clear and
2312539SN/A                    // we were interrupting on that bit before
2322539SN/A                    tsunami->intrctrl->clear(number, TheISA::INTLEVEL_IRQ1, x);
2332539SN/A                    DPRINTF(Tsunami, "dim write resulting in clear"
2342539SN/A                            " dir interrupt to cpu %d\n", number);
2351290SN/A
2361074SN/A                }
2371074SN/A
2382539SN/A
2392539SN/A            }
2402539SN/A        }
2412539SN/A    } else {
2422539SN/A        switch(regnum) {
2432539SN/A          case TSDEV_CC_CSR:
2442539SN/A              panic("TSDEV_CC_CSR write\n");
2452539SN/A          case TSDEV_CC_MTR:
2462539SN/A              panic("TSDEV_CC_MTR write not implemented\n");
2472539SN/A          case TSDEV_CC_MISC:
2482539SN/A            uint64_t ipreq;
2492630SN/A            ipreq = (pkt->get<uint64_t>() >> 12) & 0xF;
2502539SN/A            //If it is bit 12-15, this is an IPI post
2512539SN/A            if (ipreq) {
2522539SN/A                reqIPI(ipreq);
2532539SN/A                supportedWrite = true;
2542539SN/A            }
2552539SN/A
2562539SN/A            //If it is bit 8-11, this is an IPI clear
2572539SN/A            uint64_t ipintr;
2582630SN/A            ipintr = (pkt->get<uint64_t>() >> 8) & 0xF;
2592539SN/A            if (ipintr) {
2602539SN/A                clearIPI(ipintr);
2612539SN/A                supportedWrite = true;
2622539SN/A            }
2632539SN/A
2642539SN/A            //If it is the 4-7th bit, clear the RTC interrupt
2652539SN/A            uint64_t itintr;
2662630SN/A              itintr = (pkt->get<uint64_t>() >> 4) & 0xF;
2672539SN/A            if (itintr) {
2682539SN/A                  clearITI(itintr);
2692539SN/A                supportedWrite = true;
2702539SN/A            }
2712539SN/A
2722539SN/A              // ignore NXMs
2732630SN/A              if (pkt->get<uint64_t>() & 0x10000000)
2742539SN/A                  supportedWrite = true;
2752539SN/A
2762539SN/A            if(!supportedWrite)
2772539SN/A                  panic("TSDEV_CC_MISC write not implemented\n");
2782539SN/A
2792549SN/A            break;
2802539SN/A            case TSDEV_CC_AAR0:
2812539SN/A            case TSDEV_CC_AAR1:
2822539SN/A            case TSDEV_CC_AAR2:
2832539SN/A            case TSDEV_CC_AAR3:
2842539SN/A                panic("TSDEV_CC_AARx write not implemeted\n");
2852539SN/A            case TSDEV_CC_DIM0:
2862539SN/A            case TSDEV_CC_DIM1:
2872539SN/A            case TSDEV_CC_DIM2:
2882539SN/A            case TSDEV_CC_DIM3:
2892539SN/A                int number;
2902539SN/A                if(regnum == TSDEV_CC_DIM0)
2912539SN/A                    number = 0;
2922539SN/A                else if(regnum == TSDEV_CC_DIM1)
2932539SN/A                    number = 1;
2942539SN/A                else if(regnum == TSDEV_CC_DIM2)
2952539SN/A                    number = 2;
2962539SN/A                else
2972539SN/A                    number = 3;
2982539SN/A
2992539SN/A                uint64_t bitvector;
3002539SN/A                uint64_t olddim;
3012539SN/A                uint64_t olddir;
3022539SN/A
3032539SN/A                olddim = dim[number];
3042539SN/A                olddir = dir[number];
3052630SN/A                dim[number] = pkt->get<uint64_t>();
3062539SN/A                dir[number] = dim[number] & drir;
3072539SN/A                for(int x = 0; x < 64; x++)
3082539SN/A                {
3092539SN/A                    bitvector = ULL(1) << x;
3102539SN/A                    // Figure out which bits have changed
3112539SN/A                    if ((dim[number] & bitvector) != (olddim & bitvector))
3122539SN/A                    {
3132539SN/A                        // The bit is now set and it wasn't before (set)
3142539SN/A                        if((dim[number] & bitvector) && (dir[number] & bitvector))
3152539SN/A                        {
3162539SN/A                          tsunami->intrctrl->post(number, TheISA::INTLEVEL_IRQ1, x);
3172539SN/A                          DPRINTF(Tsunami, "posting dir interrupt to cpu 0\n");
3182539SN/A                        }
3192539SN/A                        else if ((olddir & bitvector) &&
3202539SN/A                                !(dir[number] & bitvector))
3212539SN/A                        {
3222539SN/A                            // The bit was set and now its now clear and
3232539SN/A                            // we were interrupting on that bit before
3242539SN/A                            tsunami->intrctrl->clear(number, TheISA::INTLEVEL_IRQ1, x);
3252539SN/A                          DPRINTF(Tsunami, "dim write resulting in clear"
3262539SN/A                                    " dir interrupt to cpu %d\n",
3272539SN/A                                    x);
3282539SN/A
3292539SN/A                        }
3302539SN/A
3312539SN/A
3322539SN/A                    }
3331074SN/A                }
3342539SN/A                break;
3352539SN/A            case TSDEV_CC_DIR0:
3362539SN/A            case TSDEV_CC_DIR1:
3372539SN/A            case TSDEV_CC_DIR2:
3382539SN/A            case TSDEV_CC_DIR3:
3392539SN/A                panic("TSDEV_CC_DIR write not implemented\n");
3402539SN/A            case TSDEV_CC_DRIR:
3412539SN/A                panic("TSDEV_CC_DRIR write not implemented\n");
3422539SN/A            case TSDEV_CC_PRBEN:
3432539SN/A                panic("TSDEV_CC_PRBEN write not implemented\n");
3442539SN/A            case TSDEV_CC_IIC0:
3452539SN/A            case TSDEV_CC_IIC1:
3462539SN/A            case TSDEV_CC_IIC2:
3472539SN/A            case TSDEV_CC_IIC3:
3482539SN/A                panic("TSDEV_CC_IICx write not implemented\n");
3492539SN/A            case TSDEV_CC_MPR0:
3502539SN/A            case TSDEV_CC_MPR1:
3512539SN/A            case TSDEV_CC_MPR2:
3522539SN/A            case TSDEV_CC_MPR3:
3532539SN/A                panic("TSDEV_CC_MPRx write not implemented\n");
3542539SN/A            case TSDEV_CC_IPIR:
3552630SN/A                clearIPI(pkt->get<uint64_t>());
3562539SN/A                break;
3572539SN/A            case TSDEV_CC_ITIR:
3582630SN/A                clearITI(pkt->get<uint64_t>());
3592539SN/A                break;
3602539SN/A            case TSDEV_CC_IPIQ:
3612630SN/A                reqIPI(pkt->get<uint64_t>());
3622539SN/A                break;
3632539SN/A            default:
3642539SN/A              panic("default in cchip read reached, accessing 0x%x\n");
3652539SN/A        }  // swtich(regnum)
3662539SN/A    } // not BIG_TSUNAMI write
3674870Sstever@eecs.umich.edu    pkt->makeAtomicResponse();
3682539SN/A    return pioDelay;
369767SN/A}
370767SN/A
371767SN/Avoid
3721290SN/ATsunamiCChip::clearIPI(uint64_t ipintr)
3731290SN/A{
3744103Ssaidi@eecs.umich.edu    int numcpus = sys->threadContexts.size();
3751290SN/A    assert(numcpus <= Tsunami::Max_CPUs);
3761290SN/A
3771290SN/A    if (ipintr) {
3781290SN/A        for (int cpunum=0; cpunum < numcpus; cpunum++) {
3791290SN/A            // Check each cpu bit
3801290SN/A            uint64_t cpumask = ULL(1) << cpunum;
3811290SN/A            if (ipintr & cpumask) {
3821290SN/A                // Check if there is a pending ipi
3831290SN/A                if (ipint & cpumask) {
3841290SN/A                    ipint &= ~cpumask;
3851290SN/A                    tsunami->intrctrl->clear(cpunum, TheISA::INTLEVEL_IRQ3, 0);
3861290SN/A                    DPRINTF(IPI, "clear IPI IPI cpu=%d\n", cpunum);
3871290SN/A                }
3881290SN/A                else
3891290SN/A                    warn("clear IPI for CPU=%d, but NO IPI\n", cpunum);
3901290SN/A            }
3911290SN/A        }
3921290SN/A    }
3931290SN/A    else
3941290SN/A        panic("Big IPI Clear, but not processors indicated\n");
3951290SN/A}
3961290SN/A
3971290SN/Avoid
3981290SN/ATsunamiCChip::clearITI(uint64_t itintr)
3991290SN/A{
4004103Ssaidi@eecs.umich.edu    int numcpus = sys->threadContexts.size();
4011290SN/A    assert(numcpus <= Tsunami::Max_CPUs);
4021290SN/A
4031290SN/A    if (itintr) {
4041290SN/A        for (int i=0; i < numcpus; i++) {
4051290SN/A            uint64_t cpumask = ULL(1) << i;
4061290SN/A            if (itintr & cpumask & itint) {
4071290SN/A                tsunami->intrctrl->clear(i, TheISA::INTLEVEL_IRQ2, 0);
4081290SN/A                itint &= ~cpumask;
4091290SN/A                DPRINTF(Tsunami, "clearing rtc interrupt to cpu=%d\n", i);
4101290SN/A            }
4111290SN/A        }
4121290SN/A    }
4131290SN/A    else
4141290SN/A        panic("Big ITI Clear, but not processors indicated\n");
4151290SN/A}
4161290SN/A
4171290SN/Avoid
4181290SN/ATsunamiCChip::reqIPI(uint64_t ipreq)
4191290SN/A{
4204103Ssaidi@eecs.umich.edu    int numcpus = sys->threadContexts.size();
4211290SN/A    assert(numcpus <= Tsunami::Max_CPUs);
4221290SN/A
4231290SN/A    if (ipreq) {
4241290SN/A        for (int cpunum=0; cpunum < numcpus; cpunum++) {
4251290SN/A            // Check each cpu bit
4261290SN/A            uint64_t cpumask = ULL(1) << cpunum;
4271290SN/A            if (ipreq & cpumask) {
4281290SN/A                // Check if there is already an ipi (bits 8:11)
4291290SN/A                if (!(ipint & cpumask)) {
4301290SN/A                    ipint  |= cpumask;
4311290SN/A                    tsunami->intrctrl->post(cpunum, TheISA::INTLEVEL_IRQ3, 0);
4321290SN/A                    DPRINTF(IPI, "send IPI cpu=%d\n", cpunum);
4331290SN/A                }
4341290SN/A                else
4351290SN/A                    warn("post IPI for CPU=%d, but IPI already\n", cpunum);
4361290SN/A            }
4371290SN/A        }
4381290SN/A    }
4391290SN/A    else
4401290SN/A        panic("Big IPI Request, but not processors indicated\n");
4411290SN/A}
4421290SN/A
4431290SN/A
4441290SN/Avoid
445831SN/ATsunamiCChip::postRTC()
446831SN/A{
4474103Ssaidi@eecs.umich.edu    int size = sys->threadContexts.size();
4481290SN/A    assert(size <= Tsunami::Max_CPUs);
449831SN/A
450831SN/A    for (int i = 0; i < size; i++) {
4511290SN/A        uint64_t cpumask = ULL(1) << i;
4522539SN/A       if (!(cpumask & itint)) {
4532539SN/A           itint |= cpumask;
4542539SN/A           tsunami->intrctrl->post(i, TheISA::INTLEVEL_IRQ2, 0);
4552539SN/A           DPRINTF(Tsunami, "Posting RTC interrupt to cpu=%d", i);
4562539SN/A       }
457831SN/A    }
458831SN/A
459831SN/A}
460831SN/A
461831SN/Avoid
462817SN/ATsunamiCChip::postDRIR(uint32_t interrupt)
463777SN/A{
4641290SN/A    uint64_t bitvector = ULL(1) << interrupt;
4654103Ssaidi@eecs.umich.edu    uint64_t size = sys->threadContexts.size();
4661290SN/A    assert(size <= Tsunami::Max_CPUs);
467777SN/A    drir |= bitvector;
4681290SN/A
469831SN/A    for(int i=0; i < size; i++) {
470817SN/A        dir[i] = dim[i] & drir;
4712539SN/A       if (dim[i] & bitvector) {
4722539SN/A              tsunami->intrctrl->post(i, TheISA::INTLEVEL_IRQ1, interrupt);
4732539SN/A              DPRINTF(Tsunami, "posting dir interrupt to cpu %d,"
474817SN/A                        "interrupt %d\n",i, interrupt);
4752539SN/A       }
476777SN/A    }
477777SN/A}
478777SN/A
479777SN/Avoid
480817SN/ATsunamiCChip::clearDRIR(uint32_t interrupt)
481777SN/A{
4821290SN/A    uint64_t bitvector = ULL(1) << interrupt;
4834103Ssaidi@eecs.umich.edu    uint64_t size = sys->threadContexts.size();
4841290SN/A    assert(size <= Tsunami::Max_CPUs);
4851290SN/A
486817SN/A    if (drir & bitvector)
487817SN/A    {
488817SN/A        drir &= ~bitvector;
489831SN/A        for(int i=0; i < size; i++) {
4902539SN/A           if (dir[i] & bitvector) {
4912539SN/A               tsunami->intrctrl->clear(i, TheISA::INTLEVEL_IRQ1, interrupt);
4922539SN/A               DPRINTF(Tsunami, "clearing dir interrupt to cpu %d,"
493817SN/A                    "interrupt %d\n",i, interrupt);
494777SN/A
4952539SN/A           }
4962539SN/A           dir[i] = dim[i] & drir;
497777SN/A        }
498777SN/A    }
499817SN/A    else
500817SN/A        DPRINTF(Tsunami, "Spurrious clear? interrupt %d\n", interrupt);
501777SN/A}
502777SN/A
503909SN/A
504777SN/Avoid
505767SN/ATsunamiCChip::serialize(std::ostream &os)
506767SN/A{
507811SN/A    SERIALIZE_ARRAY(dim, Tsunami::Max_CPUs);
508811SN/A    SERIALIZE_ARRAY(dir, Tsunami::Max_CPUs);
5091290SN/A    SERIALIZE_SCALAR(ipint);
5101290SN/A    SERIALIZE_SCALAR(itint);
511811SN/A    SERIALIZE_SCALAR(drir);
512767SN/A}
513767SN/A
514767SN/Avoid
515767SN/ATsunamiCChip::unserialize(Checkpoint *cp, const std::string &section)
516767SN/A{
517811SN/A    UNSERIALIZE_ARRAY(dim, Tsunami::Max_CPUs);
518811SN/A    UNSERIALIZE_ARRAY(dir, Tsunami::Max_CPUs);
5191290SN/A    UNSERIALIZE_SCALAR(ipint);
5201290SN/A    UNSERIALIZE_SCALAR(itint);
521811SN/A    UNSERIALIZE_SCALAR(drir);
522767SN/A}
523767SN/A
524767SN/ABEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiCChip)
525767SN/A
5262539SN/A    Param<Addr> pio_addr;
5272539SN/A    Param<Tick> pio_latency;
5282539SN/A    SimObjectParam<Platform *> platform;
5292539SN/A    SimObjectParam<System *> system;
530775SN/A    SimObjectParam<Tsunami *> tsunami;
531767SN/A
532767SN/AEND_DECLARE_SIM_OBJECT_PARAMS(TsunamiCChip)
533767SN/A
534767SN/ABEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiCChip)
535767SN/A
5362539SN/A    INIT_PARAM(pio_addr, "Device Address"),
5372539SN/A    INIT_PARAM(pio_latency, "Programmed IO latency"),
5382539SN/A    INIT_PARAM(platform, "platform"),
5392539SN/A    INIT_PARAM(system, "system object"),
5402539SN/A    INIT_PARAM(tsunami, "Tsunami")
541767SN/A
542767SN/AEND_INIT_SIM_OBJECT_PARAMS(TsunamiCChip)
543767SN/A
544767SN/ACREATE_SIM_OBJECT(TsunamiCChip)
545767SN/A{
5462539SN/A    TsunamiCChip::Params *p = new TsunamiCChip::Params;
5472539SN/A    p->name = getInstanceName();
5482539SN/A    p->pio_addr = pio_addr;
5492539SN/A    p->pio_delay = pio_latency;
5502539SN/A    p->platform = platform;
5512539SN/A    p->system = system;
5522539SN/A    p->tsunami = tsunami;
5532539SN/A    return new TsunamiCChip(p);
554767SN/A}
555767SN/A
556767SN/AREGISTER_SIM_OBJECT("TsunamiCChip", TsunamiCChip)
557