forked from Sepanta/pcie-driver
				
			
			
			
				Browse Source
			
			
			
			
				
		Add short and long operations Add extra files and folders to git ignore Change bar size schema for test purposesv1.0
				 3 changed files with 125 additions and 28 deletions
			
			
		| @ -1,21 +1,47 @@ | |||||
| #include "stdint.h" | #include "stdint.h" | ||||
|  | #include <exception> | ||||
| 
 | 
 | ||||
| #define BAR_NUM 3 | #define BAR_NUM 3 | ||||
| #define DEV_NAME  "usd_reg" | #define DEV_NAME  "usd_reg" | ||||
| 
 | 
 | ||||
|  | typedef struct bar_t{ | ||||
|  |     void* ptr; | ||||
|  |     int file; | ||||
|  |     uint32_t size; | ||||
|  | }bar_t; | ||||
|  | 
 | ||||
|  | class myexception: public std::exception | ||||
|  | { | ||||
|  | private: | ||||
|  |     char* _message; | ||||
|  | public: | ||||
|  |   myexception(char* message) { _message = message; } | ||||
|  |   virtual const char* what() const noexcept | ||||
|  |   { | ||||
|  |     return _message; | ||||
|  |   } | ||||
|  | }; | ||||
|  | 
 | ||||
| class UltraSoundDevice  | class UltraSoundDevice  | ||||
| { | { | ||||
| private: | private: | ||||
|   void* bars[BAR_NUM]; |   bar_t bars[BAR_NUM]; | ||||
|   int files[BAR_NUM]; | 
 | ||||
|  |   void sanityCheck(uint32_t address, uint32_t bar); | ||||
| 
 | 
 | ||||
| public: | public: | ||||
|   UltraSoundDevice(); |   UltraSoundDevice(); | ||||
|   ~UltraSoundDevice(); |   ~UltraSoundDevice(); | ||||
| 
 | 
 | ||||
|   uint8_t readByte(uint32_t address, uint32_t bar); |   uint8_t readByte(uint32_t address, uint32_t bar); | ||||
|  |   uint16_t readShort(uint32_t address, uint32_t bar); | ||||
|   uint32_t readWord(uint32_t address, uint32_t bar); |   uint32_t readWord(uint32_t address, uint32_t bar); | ||||
|  |   uint64_t readLong(uint32_t address, uint32_t bar); | ||||
| 
 | 
 | ||||
|   void writeByte(uint32_t address, uint32_t bar, uint8_t data); |   void writeByte(uint32_t address, uint32_t bar, uint8_t data); | ||||
|  |   void writeShort(uint32_t address, uint32_t bar, uint16_t data); | ||||
|   void writeWord(uint32_t address, uint32_t bar, uint32_t data); |   void writeWord(uint32_t address, uint32_t bar, uint32_t data); | ||||
| }; |   void writeLong(uint32_t address, uint32_t bar, uint64_t data); | ||||
|  | }; | ||||
|  | 
 | ||||
|  | 
 | ||||
|  | |||||
					Loading…
					
					
				
		Reference in new issue