tsunami_io.hh revision 809
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 302665Ssaidi@eecs.umich.edu * Tsunami Fake I/O Space mapping including RTC/timer interrupts 312SN/A */ 322SN/A 332623SN/A#ifndef __TSUNAMI_DMA_HH__ 342623SN/A#define __TSUNAMI_DMA_HH__ 352SN/A 361354SN/A#define RTC_RATE 1024 371858SN/A 381717SN/A#include "mem/functional_mem/functional_memory.hh" 392683Sktlim@umich.edu#include "dev/tsunami.hh" 401354SN/A 411354SN/A/* 422387SN/A * Tsunami I/O device 432387SN/A */ 442387SN/Aclass TsunamiIO : public FunctionalMemory 4556SN/A{ 462SN/A private: 472SN/A Addr addr; 481858SN/A static const Addr size = 0xff; 492SN/A 503453Sgblack@eecs.umich.edu struct tm tm; 513453Sgblack@eecs.umich.edu 523453Sgblack@eecs.umich.edu // In Tsunami RTC only has two i/o ports 533453Sgblack@eecs.umich.edu // one for data and one for address, so you 543453Sgblack@eecs.umich.edu // write the address and then read/write the data 552462SN/A uint8_t RTCAddress; 562SN/A 572SN/A protected: 582SN/A 59715SN/A class ClockEvent : public Event 60715SN/A { 61715SN/A protected: 62715SN/A Tick interval; 63715SN/A uint8_t mode; 642SN/A uint8_t status; 652SN/A 662680Sktlim@umich.edu public: 67237SN/A ClockEvent(); 682SN/A 692SN/A virtual void process(); 702SN/A virtual const char *description(); 712SN/A void Program(int count); 722SN/A void ChangeMode(uint8_t mode); 732420SN/A uint8_t Status(); 742623SN/A 752SN/A }; 762107SN/A 772107SN/A class RTCEvent : public Event 782159SN/A { 792455SN/A protected: 802455SN/A Tsunami* tsunami; 812386SN/A public: 822623SN/A RTCEvent(Tsunami* t); 832SN/A 841371SN/A virtual void process(); 852SN/A virtual const char *description(); 862SN/A }; 872SN/A 882SN/A uint8_t uip; 892SN/A 902SN/A uint8_t mask1; 912SN/A uint8_t mask2; 922SN/A uint8_t mode1; 932SN/A uint8_t mode2; 942SN/A 952SN/A uint8_t picr; //Raw PIC interrput register, before masking 961400SN/A bool picInterrupting; 971400SN/A 981400SN/A Tsunami *tsunami; 991858SN/A 1003453Sgblack@eecs.umich.edu /* 1013453Sgblack@eecs.umich.edu * This timer is initilized, but after I wrote the code 1022SN/A * it doesn't seem to be used again, and best I can tell 1031400SN/A * it too is not connected to any interrupt port 1042SN/A */ 1051400SN/A ClockEvent timer0; 1062623SN/A 1072623SN/A /* 1082SN/A * This timer is used to control the speaker, which 1091400SN/A * we normally could care less about, however it is 1102683Sktlim@umich.edu * also used to calculated the clockspeed and hense 1112683Sktlim@umich.edu * bogomips which is kinda important to the scheduler 1122190SN/A * so we need to implemnt it although after boot I can't 1132683Sktlim@umich.edu * imagine we would be playing with the PC speaker much 1142683Sktlim@umich.edu */ 1152683Sktlim@umich.edu ClockEvent timer2; 1162680Sktlim@umich.edu 1172SN/A RTCEvent rtc; 1181858SN/A 1192SN/A uint32_t timerData; 1202SN/A 1212SN/A 1222SN/A public: 1232SN/A uint32_t frequency() const { return RTC_RATE; } 1242SN/A 1252SN/A TsunamiIO(const std::string &name, Tsunami *t, time_t init_time, 1262SN/A Addr a, MemoryController *mmu); 1272566SN/A 1282566SN/A void set_time(time_t t); 1292566SN/A 1302107SN/A virtual Fault read(MemReqPtr &req, uint8_t *data); 1313276Sgblack@eecs.umich.edu virtual Fault write(MemReqPtr &req, const uint8_t *data); 1321469SN/A 1332623SN/A void postPIC(uint8_t bitvector); 1342662Sstever@eecs.umich.edu void clearPIC(uint8_t bitvector); 1352623SN/A 1362623SN/A virtual void serialize(std::ostream &os); 1372623SN/A virtual void unserialize(Checkpoint *cp, const std::string §ion); 138180SN/A}; 139393SN/A 140393SN/A#endif // __TSUNAMI_IO_HH__ 1412SN/A