DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
include/8255.h
00001 
00002 #include <stdio.h>
00003 #include <stdint.h>
00004 
00018 class Intel8255 {
00019 public:
00023     enum {
00025         PortA=0,        
00027         PortB=1,        
00029         PortC=2         
00030     };
00031 public:
00033                         Intel8255();
00035     virtual            ~Intel8255();
00036 public:
00038     void                reset(void);                    
00039 
00041     void                ackPortA(void);                 
00043     void                ackPortB(void);                 
00044 
00046     virtual void        strobePortA(void);              
00048     virtual void        strobePortB(void);              
00049 
00051     uint8_t             readPortA(void);                
00053     uint8_t             readPortB(void);                
00055     uint8_t             readPortC(void);                
00057     uint8_t             readControl(void);              
00058 
00060     uint8_t             readByPort(const uint8_t p03);  
00061 
00063     void                writePortA(const uint8_t data,uint8_t mask=0xFFU);  
00065     void                writePortB(const uint8_t data,uint8_t mask=0xFFU);  
00067     void                writePortC(const uint8_t data,uint8_t mask=0xFFU);  
00069     void                writeControl(const uint8_t data);                   
00070 
00072     void                writeByPort(const uint8_t p03,const uint8_t data);  
00073 public:
00075     virtual uint8_t     inPortA(void) const;            
00077     virtual uint8_t     inPortB(void) const;            
00079     virtual uint8_t     inPortC(void) const;            
00080 public:
00082     virtual void        outPortA(const uint8_t mask);   
00084     virtual void        outPortB(const uint8_t mask);   
00086     virtual void        outPortC(const uint8_t mask);   
00087 public:
00089     void                updateINTR_A(void);             
00091     void                updateINTR_B(void);             
00092 public:
00094     void                checkINTR_A(void);              
00096     void                checkINTR_B(void);              
00097 public:
00099     virtual void        sigINTR_A(void);                
00101     virtual void        sigINTR_B(void);                
00102 public:
00104     inline const char*  getName(void) const {
00105         return nil_if_null(ppiName);
00106     }
00107 public:
00109     inline const char*  pinName(const unsigned int port,const unsigned int i) const {
00110         return nil_if_null(pinNames[port][i]);
00111     }
00113     inline const char*  portName(const unsigned int port) const {
00114         return nil_if_null(portNames[port]);
00115     }
00116 public:
00118     uint8_t             portAWriteMask = 0;
00120     uint8_t             portBWriteMask = 0;
00122     uint8_t             portCWriteMask = 0;
00123 public:
00125     const char*         ppiName;
00126 public:
00128     const char*         pinNames[3/*port*/][8/*bit*/] = {};
00130     const char*         portNames[3/*port*/] = {};
00131 public:
00133     uint8_t             latchOutPortA = 0;
00135     uint8_t             latchOutPortB = 0;
00137     uint8_t             latchOutPortC = 0;
00139     uint8_t             mode = 0;
00140     /* bit[7:7] = 1             mode set flag
00141      * bit[6:5] = mode select   00=mode 0  01=mode 1  1x=mode 2
00142      * bit[4:4] = Port A        1=input  0=output
00143      * bit[3:3] = Port C upper  1=input  0=output
00144      * bit[2:2] = mode select   0=mode 0   1=mode 1
00145      * bit[1:1] = Port B        1=input  0=output
00146      * bit[0:0] = Port C lower  1=input  0=output */
00147 public:
00149     bool                IBF_A = false;
00151     bool                IBF_B = false;
00153     bool                OBF_A = false;
00155     bool                OBF_B = false;
00156 public:
00158     bool                INTR_A = false;
00160     bool                INTR_B = false;
00162     bool                pINTR_A = false;
00164     bool                pINTR_B = false;
00165 public:
00167     bool                INTE_1 = false;
00169     bool                INTE_2 = false; /* mode 2 */
00171     bool                INTE_A = false;
00173     bool                INTE_B = false;
00174 protected:
00176     static inline const char *nil_if_null(const char *str) {
00177         return (str != NULL) ? str : "";
00178     }
00179 };
00180