tsunami_io.hh revision 775
1768SN/A/* 21762SN/A * Copyright (c) 2003 The Regents of The University of Michigan 3768SN/A * All rights reserved. 4768SN/A * 5768SN/A * Redistribution and use in source and binary forms, with or without 6768SN/A * modification, are permitted provided that the following conditions are 7768SN/A * met: redistributions of source code must retain the above copyright 8768SN/A * notice, this list of conditions and the following disclaimer; 9768SN/A * redistributions in binary form must reproduce the above copyright 10768SN/A * notice, this list of conditions and the following disclaimer in the 11768SN/A * documentation and/or other materials provided with the distribution; 12768SN/A * neither the name of the copyright holders nor the names of its 13768SN/A * contributors may be used to endorse or promote products derived from 14768SN/A * this software without specific prior written permission. 15768SN/A * 16768SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17768SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18768SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19768SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20768SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21768SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22768SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23768SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24768SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25768SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26768SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665SN/A */ 282665SN/A 292665SN/A/* @file 302665SN/A * Tsunnami Fake DMA memory map 31768SN/A */ 32768SN/A 331722SN/A#ifndef __TSUNAMI_DMA_HH__ 341722SN/A#define __TSUNAMI_DMA_HH__ 35768SN/A 36768SN/A#include "mem/functional_mem/mmap_device.hh" 371401SN/A#include "dev/tsunami.hh" 381401SN/A 39768SN/A/* 40909SN/A * Tsunami I/O device 413540Sgblack@eecs.umich.edu */ 425443Sgblack@eecs.umich.educlass TsunamiIO : public MmapDevice 435392Sgblack@eecs.umich.edu{ 444762Snate@binkert.org 454762Snate@binkert.org private: 46932SN/A struct tm tm; 47768SN/A 481722SN/A // In Tsunami RTC only has two i/o ports 49885SN/A // one for data and one for address, so you 50885SN/A // write the address and then read/write the data 51768SN/A uint8_t RTCAddress; 522542SN/A 53768SN/A protected: 54809SN/A 55773SN/A class ClockEvent : public Event 56773SN/A { 57768SN/A protected: 585392Sgblack@eecs.umich.edu Tick interval; 595392Sgblack@eecs.umich.edu uint8_t mode; 601854SN/A uint8_t status; 615392Sgblack@eecs.umich.edu 625392Sgblack@eecs.umich.edu public: 635392Sgblack@eecs.umich.edu ClockEvent(); 645392Sgblack@eecs.umich.edu 655392Sgblack@eecs.umich.edu virtual void process(); 665392Sgblack@eecs.umich.edu virtual const char *description(); 671854SN/A void Program(int count); 685392Sgblack@eecs.umich.edu void ChangeMode(uint8_t mode); 695392Sgblack@eecs.umich.edu uint8_t Status(); 705392Sgblack@eecs.umich.edu 711817SN/A }; 72771SN/A 73885SN/A class RTCEvent : public Event 74803SN/A { 75885SN/A protected: 76885SN/A Tsunami* tsunami; 77803SN/A public: 78885SN/A RTCEvent(Tsunami* t); 79885SN/A 80803SN/A virtual void process(); 81885SN/A virtual const char *description(); 82885SN/A }; 83803SN/A 84769SN/A uint8_t uip; 85885SN/A 86885SN/A uint8_t mask1; 87885SN/A uint8_t mask2; 88885SN/A uint8_t mode1; 89777SN/A uint8_t mode2; 90777SN/A 91885SN/A Tsunami *tsunami; 92775SN/A 93775SN/A /* This timer is initilized, but after I wrote the code 941817SN/A it doesn't seem to be used again, and best I can tell 955443Sgblack@eecs.umich.edu it too is not connected to any interrupt port */ 96773SN/A ClockEvent timer0; 975392Sgblack@eecs.umich.edu 985392Sgblack@eecs.umich.edu /* This timer is used to control the speaker, which 995392Sgblack@eecs.umich.edu we normally could care less about, however it is 100773SN/A also used to calculated the clockspeed and hense 101885SN/A bogomips which is kinda important to the scheduler 102885SN/A so we need to implemnt it although after boot I can't 103885SN/A imagine we would be playing with the PC speaker much */ 104885SN/A ClockEvent timer2; 1051817SN/A 106771SN/A RTCEvent rtc; 107768SN/A 108891SN/A uint32_t timerData; 109891SN/A 110891SN/A uint32_t freq; 111891SN/A 1121634SN/A public: 113775SN/A uint32_t frequency() const { return freq; } 1142539SN/A 1154762Snate@binkert.org TsunamiIO(const std::string &name, Tsunami *t, time_t init_time, 116885SN/A Addr addr, Addr mask, uint32_t f, MemoryController *mmu); 117885SN/A 1182539SN/A void set_time(time_t t); 119885SN/A 1204762Snate@binkert.org virtual Fault read(MemReqPtr req, uint8_t *data); 1214762Snate@binkert.org virtual Fault write(MemReqPtr req, const uint8_t *data); 1224762Snate@binkert.org 1234762Snate@binkert.org virtual void serialize(std::ostream &os); 1244762Snate@binkert.org virtual void unserialize(Checkpoint *cp, const std::string §ion); 1254762Snate@binkert.org}; 1264762Snate@binkert.org 127768SN/A#endif // __TSUNAMI_IO_HH__ 1283349SN/A