tsunami_io.hh revision 9235:5aa4896ed55a
1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; 9 * redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution; 12 * neither the name of the copyright holders nor the names of its 13 * contributors may be used to endorse or promote products derived from 14 * this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * Authors: Ali Saidi 29 * Andrew Schultz 30 * Miguel Serrano 31 */ 32 33/** @file 34 * Tsunami I/O Space mapping including RTC/timer interrupts 35 */ 36 37#ifndef __DEV_TSUNAMI_IO_HH__ 38#define __DEV_TSUNAMI_IO_HH__ 39 40#include "dev/alpha/tsunami.hh" 41#include "dev/intel_8254_timer.hh" 42#include "dev/io_device.hh" 43#include "dev/mc146818.hh" 44#include "params/TsunamiIO.hh" 45#include "sim/eventq.hh" 46 47/** 48 * Tsunami I/O device is a catch all for all the south bridge stuff we care 49 * to implement. 50 */ 51class TsunamiIO : public BasicPioDevice 52{ 53 private: 54 struct tm tm; 55 56 protected: 57 58 class RTC : public MC146818 59 { 60 public: 61 Tsunami *tsunami; 62 RTC(const std::string &n, const TsunamiIOParams *p); 63 64 protected: 65 void handleEvent() 66 { 67 //Actually interrupt the processor here 68 tsunami->cchip->postRTC(); 69 } 70 }; 71 72 /** Mask of the PIC1 */ 73 uint8_t mask1; 74 75 /** Mask of the PIC2 */ 76 uint8_t mask2; 77 78 /** Mode of PIC1. Not used for anything */ 79 uint8_t mode1; 80 81 /** Mode of PIC2. Not used for anything */ 82 uint8_t mode2; 83 84 /** Raw PIC interrupt register before masking */ 85 uint8_t picr; //Raw PIC interrput register 86 87 /** Is the pic interrupting right now or not. */ 88 bool picInterrupting; 89 90 /** A pointer to the Tsunami device which be belong to */ 91 Tsunami *tsunami; 92 93 /** Intel 8253 Periodic Interval Timer */ 94 Intel8254Timer pitimer; 95 96 RTC rtc; 97 98 uint8_t rtcAddr; 99 100 /** The interval is set via two writes to the PIT. 101 * This variable contains a flag as to how many writes have happened, and 102 * the time so far. 103 */ 104 uint16_t timerData; 105 106 public: 107 /** 108 * Return the freqency of the RTC 109 * @return interrupt rate of the RTC 110 */ 111 Tick frequency() const; 112 113 public: 114 typedef TsunamiIOParams Params; 115 /** 116 * Initialize all the data for devices supported by Tsunami I/O. 117 * @param p pointer to Params struct 118 */ 119 TsunamiIO(const Params *p); 120 121 const Params * 122 params() const 123 { 124 return dynamic_cast<const Params *>(_params); 125 } 126 127 virtual Tick read(PacketPtr pkt); 128 virtual Tick write(PacketPtr pkt); 129 130 /** 131 * Post an PIC interrupt to the CPU via the CChip 132 * @param bitvector interrupt to post. 133 */ 134 void postPIC(uint8_t bitvector); 135 136 /** 137 * Clear a posted interrupt 138 * @param bitvector interrupt to clear 139 */ 140 void clearPIC(uint8_t bitvector); 141 142 /** 143 * Serialize this object to the given output stream. 144 * @param os The stream to serialize to. 145 */ 146 virtual void serialize(std::ostream &os); 147 148 /** 149 * Reconstruct the state of this object from a checkpoint. 150 * @param cp The checkpoint use. 151 * @param section The section name of this object 152 */ 153 virtual void unserialize(Checkpoint *cp, const std::string §ion); 154 155}; 156 157#endif // __DEV_TSUNAMI_IO_HH__ 158