tsunami_io.hh revision 773
12SN/A/* 21762SN/A * Copyright (c) 2003 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu */ 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu/* @file 302SN/A * Tsunnami Fake DMA memory map 312SN/A */ 324183Sgblack@eecs.umich.edu 332439SN/A#ifndef __TSUNAMI_DMA_HH__ 348229Snate@binkert.org#define __TSUNAMI_DMA_HH__ 352680Sktlim@umich.edu 368232Snate@binkert.org#include "mem/functional_mem/mmap_device.hh" 378229Snate@binkert.org#include "dev/tsunami.hh" 384183Sgblack@eecs.umich.edu 394183Sgblack@eecs.umich.edu/* 402SN/A * Tsunami I/O device 412201SN/A */ 427678Sgblack@eecs.umich.educlass TsunamiIO : public MmapDevice 432201SN/A{ 447720Sgblack@eecs.umich.edu 452201SN/A private: 462222SN/A struct tm tm; 477678Sgblack@eecs.umich.edu 482222SN/A // In Tsunami RTC only has two i/o ports 497720Sgblack@eecs.umich.edu // one for data and one for address, so you 502680Sktlim@umich.edu // write the address and then read/write the data 512222SN/A uint8_t RTCAddress; 522201SN/A 532612SN/A protected: 547678Sgblack@eecs.umich.edu 552612SN/A class ClockEvent : public Event 566815SLisa.Hsu@amd.com { 572612SN/A protected: 585004Sgblack@eecs.umich.edu Tick interval; 594184Ssaidi@eecs.umich.edu uint8_t mode; 607678Sgblack@eecs.umich.edu uint8_t status; 614183Sgblack@eecs.umich.edu 624183Sgblack@eecs.umich.edu public: 634183Sgblack@eecs.umich.edu ClockEvent(); 648539Sgblack@eecs.umich.edu 654183Sgblack@eecs.umich.edu virtual void process(); 664434Ssaidi@eecs.umich.edu virtual const char *description(); 674183Sgblack@eecs.umich.edu void Program(int count); 685004Sgblack@eecs.umich.edu void ChangeMode(uint8_t mode); 697678Sgblack@eecs.umich.edu uint8_t Status(); 705004Sgblack@eecs.umich.edu 715004Sgblack@eecs.umich.edu }; 725004Sgblack@eecs.umich.edu 734184Ssaidi@eecs.umich.edu class RTCEvent : public Event 74 { 75 public: 76 RTCEvent(); 77 78 virtual void process(); 79 virtual const char *description(); 80 }; 81 82 uint8_t uip; 83 84 uint8_t mask1; 85 uint8_t mask2; 86 uint8_t mode1; 87 uint8_t mode2; 88 89 /* This timer is initilized, but after I wrote the code 90 it doesn't seem to be used again, and best I can tell 91 it too is not connected to any interrupt port */ 92 ClockEvent timer0; 93 94 /* This timer is used to control the speaker, which 95 we normally could care less about, however it is 96 also used to calculated the clockspeed and hense 97 bogomips which is kinda important to the scheduler 98 so we need to implemnt it although after boot I can't 99 imagine we would be playing with the PC speaker much */ 100 ClockEvent timer2; 101 102 RTCEvent rtc; 103 104 uint32_t timerData; 105 106 public: 107 TsunamiIO(const std::string &name, /*Tsunami *t,*/ time_t init_time, 108 Addr addr, Addr mask, MemoryController *mmu); 109 110 void set_time(time_t t); 111 112 virtual Fault read(MemReqPtr req, uint8_t *data); 113 virtual Fault write(MemReqPtr req, const uint8_t *data); 114 115 virtual void serialize(std::ostream &os); 116 virtual void unserialize(Checkpoint *cp, const std::string §ion); 117}; 118 119#endif // __TSUNAMI_IO_HH__ 120