AliM1543C.h

Go to the documentation of this file.
00001 /* ES40 emulator.
00002  * Copyright (C) 2007-2008 by the ES40 Emulator Project
00003  *
00004  * WWW    : http://sourceforge.net/projects/es40
00005  * E-mail : camiel@camicom.com
00006  * 
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  * 
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020  * 
00021  * Although this is not required, the author would appreciate being notified of, 
00022  * and receiving any modifications you may make to the source code that might serve
00023  * the general public.
00024  */
00025 
00132 #if !defined(INCLUDED_ALIM1543C_H_)
00133 #define INCLUDED_ALIM1543C_H
00134 
00135 #include "PCIDevice.h"
00136 
00148 class CAliM1543C : public CPCIDevice, public Poco::Runnable
00149 {
00150   public:
00151     virtual int   SaveState(FILE* f);
00152     virtual int   RestoreState(FILE* f);
00153 
00154     //    void instant_tick();
00155     //    void interrupt(int number);
00156     virtual void  run();
00157     virtual void  check_state();
00158     virtual void  WriteMem_Legacy(int index, u32 address, int dsize, u32 data);
00159     virtual u32   ReadMem_Legacy(int index, u32 address, int dsize);
00160 
00161     void          do_pit_clock();
00162 
00163     CAliM1543C(CConfigurator* cfg, class CSystem* c, int pcibus, int pcidev);
00164     virtual       ~CAliM1543C();
00165     void          pic_interrupt(int index, int intno);
00166     void          pic_deassert(int index, int intno);
00167 
00168     void          init();
00169     void          start_threads();
00170     void          stop_threads();
00171   private:
00172     Poco::Thread * myThread;
00173     CMutex*   myRegLock;
00174     bool      StopThread;
00175 
00176     // REGISTER 61 (NMI)
00177     u8        reg_61_read();
00178     void      reg_61_write(u8 data);
00179 
00180     // REGISTERS 70 - 73: TOY
00181     u8        toy_read(u32 address);
00182     void      toy_write(u32 address, u8 data);
00183 
00184     // Timer/Counter
00185     u8        pit_read(u32 address);
00186     void      pit_write(u32 address, u8 data);
00187     void      pit_clock();
00188 
00189     // interrupt controller
00190     u8        pic_read(int index, u32 address);
00191     void      pic_write(int index, u32 address, u8 data);
00192     u8        pic_read_vector();
00193     u8        pic_read_edge_level(int index);
00194     void      pic_write_edge_level(int index, u8 data);
00195 
00196     // LPT controller
00197     u8        lpt_read(u32 address);
00198     void      lpt_write(u32 address, u8 data);
00199     void      lpt_reset();
00200 
00202     struct SAli_state
00203     {
00204 
00205       // REGISTER 61 (NMI)
00206       u8    reg_61;
00207 
00208       // REGISTERS 70 - 73: TOY
00209       u8    toy_stored_data[256];
00210       u8    toy_access_ports[4];
00211 
00212       // Timer/Counter
00213       u32   pit_counter[9];
00214 #define PIT_OFFSET_LATCH  3
00215 #define PIT_OFFSET_MAX    6
00216       u8    pit_status[4];
00217       u8    pit_mode[4];
00218 
00219       // interrupt controller
00220       int   pic_mode[2];
00221       u8    pic_intvec[2];
00222       u8    pic_mask[2];
00223       u8    pic_asserted[2];
00224       u8    pic_edge_level[2];
00225 
00226       u8    lpt_data;
00227       u8    lpt_control;
00228       u8    lpt_status;
00229       bool  lpt_init;
00230     } state;
00231 
00232     FILE*   lpt;
00233 };
00234 
00235 extern CAliM1543C*  theAli;
00236 #endif // !defined(INCLUDED_ALIM1543C_H)

SourceForge.net Logo
Project space on SourceForge.net