PCIDevice.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 
00045 #if !defined(__PCIDEVICE_H__)
00046 #define __PCIDEVICE_H__
00047 
00048 #define MAX_DEV_RANGES  50
00049 
00050 #define PCI_RANGE_BASE  0x0800
00051 
00052 #include "SystemComponent.h"
00053 
00057 class CPCIDevice : public CSystemComponent
00058 {
00059   public:
00060     CPCIDevice(class CConfigurator*  cfg, class CSystem*  c, int pcibus,
00061                int pcidev);
00062     ~             CPCIDevice(void);
00063     virtual int   SaveState(FILE* f);
00064     virtual int   RestoreState(FILE* f);
00065     virtual void  ResetPCI();
00066     virtual u64   ReadMem(int index, u64 address, int dsize);
00067     virtual void  WriteMem(int index, u64 address, int dsize, u64 data);
00068 
00069     virtual u32   ReadMem_Legacy(int index, u32 address, int dsize);
00070     virtual void  WriteMem_Legacy(int index, u32 address, int dsize, u32 data);
00071 
00072     virtual u32   ReadMem_Bar(int func, int bar, u32 address, int dsize);
00073     virtual void  WriteMem_Bar(int func, int bar, u32 address, int dsize,
00074                                u32 data);
00075 
00076     u32           config_read(int func, u32 address, int dsize);
00077     void          config_write(int func, u32 address, int dsize, u32 data);
00078 
00079     virtual u32 config_read_custom(int func, u32 address, int dsize, u32 data)
00080     {
00081       return data;
00082     };
00083     virtual void config_write_custom(int func, u32 address, int dsize,
00084                                      u32 old_data, u32 new_data, u32 data)
00085     { };
00086     void  register_bar(int func, int bar, u32 data, u32 mask);
00087   protected:
00088     bool  do_pci_interrupt(int func, bool asserted);
00089     void  do_pci_read(u32 address, void*  dest, size_t element_size,
00090                       size_t element_count);
00091     void  do_pci_write(u32 address, void*  source, size_t element_size,
00092                        size_t element_count);
00093 
00094     void  add_function(int func, u32 data[64], u32 mask[64]);
00095     void  add_legacy_io(int id, u32 base, u32 length);
00096     void  add_legacy_mem(int id, u32 base, u32 length);
00097 
00098     int   myPCIBus;
00099     int   myPCIDev;
00100 
00101     u32   std_config_data[8][64];
00102     u32   std_config_mask[8][64];
00103     bool  device_at[8];
00104 
00105     bool  dev_range_is_io[MAX_DEV_RANGES];
00106     bool  pci_range_is_io[8][8];
00107 
00109     struct SPCI_state
00110     {
00111       u32 config_data[8][64];
00112       u32 config_mask[8][64];
00113     } pci_state;
00114 };
00115 #endif 

SourceForge.net Logo
Project space on SourceForge.net