tsunami_io.hh revision 773
12632Sstever@eecs.umich.edu/*
22632Sstever@eecs.umich.edu * Copyright (c) 2003 The Regents of The University of Michigan
32632Sstever@eecs.umich.edu * All rights reserved.
42632Sstever@eecs.umich.edu *
52632Sstever@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
62632Sstever@eecs.umich.edu * modification, are permitted provided that the following conditions are
72632Sstever@eecs.umich.edu * met: redistributions of source code must retain the above copyright
82632Sstever@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
92632Sstever@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
102632Sstever@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
112632Sstever@eecs.umich.edu * documentation and/or other materials provided with the distribution;
122632Sstever@eecs.umich.edu * neither the name of the copyright holders nor the names of its
132632Sstever@eecs.umich.edu * contributors may be used to endorse or promote products derived from
142632Sstever@eecs.umich.edu * this software without specific prior written permission.
152632Sstever@eecs.umich.edu *
162632Sstever@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172632Sstever@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182632Sstever@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192632Sstever@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202632Sstever@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212632Sstever@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222632Sstever@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232632Sstever@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242632Sstever@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252632Sstever@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262632Sstever@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272632Sstever@eecs.umich.edu */
282632Sstever@eecs.umich.edu
292632Sstever@eecs.umich.edu/* @file
302632Sstever@eecs.umich.edu * Tsunnami Fake DMA memory map
3112SN/A */
3212SN/A
3312SN/A#ifndef __TSUNAMI_DMA_HH__
3412SN/A#define __TSUNAMI_DMA_HH__
3512SN/A
3612SN/A#include "mem/functional_mem/mmap_device.hh"
3712SN/A#include "dev/tsunami.hh"
3812SN/A
3912SN/A/*
4012SN/A * Tsunami I/O device
4112SN/A */
4212SN/Aclass TsunamiIO : public MmapDevice
4312SN/A{
4412SN/A
4512SN/A  private:
4612SN/A    struct tm tm;
4712SN/A
4812SN/A    // In Tsunami RTC only has two i/o ports
4912SN/A    // one  for data and one for address, so you
5012SN/A    // write the address and then read/write the data
5112SN/A    uint8_t RTCAddress;
5212SN/A
5312SN/A  protected:
5412SN/A
5512SN/A    class ClockEvent : public Event
5612SN/A    {
5712SN/A        protected:
5812SN/A            Tick interval;
5912SN/A            uint8_t mode;
6012SN/A            uint8_t status;
6112SN/A
625543Ssaidi@eecs.umich.edu        public:
635543Ssaidi@eecs.umich.edu            ClockEvent();
645543Ssaidi@eecs.umich.edu
655543Ssaidi@eecs.umich.edu            virtual void process();
6612SN/A            virtual const char *description();
6712SN/A            void Program(int count);
685543Ssaidi@eecs.umich.edu            void ChangeMode(uint8_t mode);
6912SN/A            uint8_t Status();
705543Ssaidi@eecs.umich.edu
7112SN/A    };
7212SN/A
735543Ssaidi@eecs.umich.edu    class RTCEvent : public Event
745543Ssaidi@eecs.umich.edu    {
755543Ssaidi@eecs.umich.edu      public:
765543Ssaidi@eecs.umich.edu        RTCEvent();
775543Ssaidi@eecs.umich.edu
785543Ssaidi@eecs.umich.edu        virtual void process();
795543Ssaidi@eecs.umich.edu        virtual const char *description();
805543Ssaidi@eecs.umich.edu    };
815543Ssaidi@eecs.umich.edu
825543Ssaidi@eecs.umich.edu      uint8_t uip;
835543Ssaidi@eecs.umich.edu
845543Ssaidi@eecs.umich.edu      uint8_t mask1;
855543Ssaidi@eecs.umich.edu      uint8_t mask2;
8612SN/A      uint8_t mode1;
8712SN/A      uint8_t mode2;
8812SN/A
8912SN/A      /* This timer is initilized, but after I wrote the code
9012SN/A         it doesn't seem to be used again, and best I can tell
9112SN/A         it too is not connected to any interrupt port */
9212SN/A      ClockEvent timer0;
935543Ssaidi@eecs.umich.edu
945543Ssaidi@eecs.umich.edu      /* This timer is used to control the speaker, which
955543Ssaidi@eecs.umich.edu         we normally could care less about, however it is
965543Ssaidi@eecs.umich.edu         also used to calculated the clockspeed and hense
975543Ssaidi@eecs.umich.edu         bogomips which is kinda important to the scheduler
985543Ssaidi@eecs.umich.edu         so we need to implemnt it although after boot I can't
995543Ssaidi@eecs.umich.edu         imagine we would be playing with the PC speaker much */
1005543Ssaidi@eecs.umich.edu      ClockEvent timer2;
1015543Ssaidi@eecs.umich.edu
1025543Ssaidi@eecs.umich.edu      RTCEvent rtc;
1035543Ssaidi@eecs.umich.edu
1045543Ssaidi@eecs.umich.edu      uint32_t timerData;
1055543Ssaidi@eecs.umich.edu
1065543Ssaidi@eecs.umich.edu  public:
1075543Ssaidi@eecs.umich.edu    TsunamiIO(const std::string &name, /*Tsunami *t,*/ time_t init_time,
1085543Ssaidi@eecs.umich.edu               Addr addr, Addr mask, MemoryController *mmu);
1095543Ssaidi@eecs.umich.edu
1105543Ssaidi@eecs.umich.edu    void set_time(time_t t);
1115543Ssaidi@eecs.umich.edu
1125543Ssaidi@eecs.umich.edu    virtual Fault read(MemReqPtr req, uint8_t *data);
1135543Ssaidi@eecs.umich.edu    virtual Fault write(MemReqPtr req, const uint8_t *data);
1145543Ssaidi@eecs.umich.edu
1155543Ssaidi@eecs.umich.edu    virtual void serialize(std::ostream &os);
1165543Ssaidi@eecs.umich.edu    virtual void unserialize(Checkpoint *cp, const std::string &section);
1175543Ssaidi@eecs.umich.edu};
11812SN/A
11912SN/A#endif // __TSUNAMI_IO_HH__
12012SN/A