INOS
cinoscopmodule.h
Go to the documentation of this file.
1//******************************************************************************
27//******************************************************************************
28
29#ifndef INC_CINOSCOPMODULE_H
30#define INC_CINOSCOPMODULE_H
31
32
33//------------------------------------------------------------------------------
34// defines
35//------------------------------------------------------------------------------
36
38#define DF_INOS_COP_MAX_MODULES 16
39
40#define DF_INOS_COP_PORT_ADDRESS 0x80000000
41#define DF_INOS_COP_PORT_MEMORY_SIZE 256
42
43#define DF_INOS_COP_RAM_ADDRESS 0x00000000UL
44#define DF_INOS_COP_RAM_MEMORY_SIZE 512
45
46// port numbers
47#define DF_INOS_COP_PORT_RAM_ADR 0xF8
48#define DF_INOS_COP_PORT_RAM_DAT 0xF9
49#define DF_INOS_COP_PORT_STATUS 0xFC
50#define DF_INOS_COP_PORT_APPREV 0xFE
51#define DF_INOS_COP_PORT_SEQREV 0xFF
52
53#define DF_INOS_COP_PORT_ENABLE_WRITE 0x4000
54
56#define DF_INOS_COP_FLAG_EEPROM_VALID 0x00000001
58#define DF_INOS_COP_FLAG_XML_MOD_VALID 0x00000002
60#define DF_INOS_COP_FLAG_RAM_PROTECT 0x00000004
62#define DF_INOS_COP_FLAG_LITTLE_ENDIAN 0x00000008
64#define DF_INOS_COP_FLAG_INFO_1 0x00000010
65
66// startup action options
67#define DF_INOS_COP_STRT_OPTION_SLOW 0x00000001
68
69
70//------------------------------------------------------------------------------
71// includes
72//------------------------------------------------------------------------------
73//
74// system
75
76// C++
77#include <vector>
78//
79// project
80#include <xmlparser.h>
81
82class CINOSIncoAction;
83
84
85//------------------------------------------------------------------------------
86// structures
87//------------------------------------------------------------------------------
88
91{
92 enum {
93 eOptSubName = 0x00000001
94 };
95
97 inosName32 m_cName;
99 uint32 m_uAddress;
103 // channel names)
110 char m_cRevision[16];
111
114};
115
118#if INOS_BYTE_ORDER == INOS_LITTLE_ENDIAN
121{
122 // --- start of header ---
132 char m_cCardName[24];
134 char m_cRevision[4];
143};
144#else
147{
148 // --- start of header ---
150 uint16 m_uVersion;
152 uint8 m_uDataOffset;
154 uint8 m_uChecksum;
156 uint32 m_uCardNumber;
158 char m_cCardName[24];
160 char m_cRevision[4];
162 uint32 m_uWorkNumber;
164 uint64 m_uMacNumber;
166 uint32 m_uSeriesNumber;
168 uint32 m_uOptions;
169};
170#endif
171// version 2.00
174{
176 uint8 m_uReserved[8];
177
183 uint8 m_uData[1024-64];
184
185 // methods
187 uint8 GetChecksum(uint32 auLength);
193 void Clear();
194
197};
198//
199//------------------------------------------------------------------------------
200// forwards
201//------------------------------------------------------------------------------
202
203class CINCOCOPDevice;
204class CINOSCOPMaster;
205class CINOSBusPortHandlerRangeCondition;
206
207
208//------------------------------------------------------------------------------
209// class definition
210//------------------------------------------------------------------------------
211
214{
215 //--- user interface ---------------------------------------------------
216
217 public :
219 const char* GetName()
220 { return &m_pDesc->m_cName[0]; };
222 const char* GetInfo()
223 { return m_cTargetInfo; };
225 const char* GetStateText();
227 uint32 GetAddress()
228 { return m_pDesc->m_uAddress; };
230 void* GetEepromAddress(uint32 auOffset)
231 { return (void*)((uintptr)&m_Eeprom+auOffset); };
232 void* GetEepromAddress(const char* apName, uint32 auOffset);
235 { return sizeof(m_Eeprom); };
237 XMLNode GetXmlNode()
238 { return m_CardNode; };
240 CINCOObject* GetInco()
241 { return m_pInco; };
243 virtual const char* GetXmlCompressedAddr();
245 virtual uint32 GetXmlSize();
247 virtual uint32 GetXmlCompressedSize();
248
251 return m_uFlags & DF_INOS_COP_FLAG_RAM_PROTECT;
252 }
253
256 return m_uFlags & DF_INOS_COP_FLAG_LITTLE_ENDIAN;
257 }
258
260 void GetBoardInfo(SINOSCOPModuleEeprom& aBoardInfo, bool& abEepromValid) {
261 aBoardInfo=m_Eeprom;
262 abEepromValid=((m_uFlags&DF_INOS_COP_FLAG_EEPROM_VALID)?true:false);
263 };
266 memcpy(&m_Eeprom, &aBoardInfo, sizeof(aBoardInfo));
268 };
269
274 return m_uFpgaRevision;
275 }
280 return m_uAddressSwitch;
281 }
282
286
288 void Startup();
289
292 { return m_pNext;};
295 { m_pNext = apNext;};
297 void SetDistributionModule(CINOSCOPModule* apDist, char* apXml);
298
305 uint32 PutBlock32(uint32 auDest, uint32* apSource, uint16 auNumber,
306 uint32 auFlags = 0);
307
314 uint32 GetBlock32(uint32 auSource, uint32* apDest, uint16 auNumber,
315 uint32 auFlags = 0);
316
318 uint32 PutBlock16(uint32 auDest, uint16* apSource, uint16 auNumber, uint32 auFlags = 0);
320 uint32 GetBlock16(uint32 auSource, uint16* apDest, uint16 auNumber, uint32 auFlags = 0);
321
328 uint32 PutBlock8(uint32 auDest, uint8* apSource, uint16 auNumber,
329 uint32 auFlags = 0);
330
337 uint32 GetBlock8(uint32 auSource, uint8* apDest, uint16 auNumber,
338 uint32 auFlags = 0);
339
341 uint32 PortPut16(uint16 auNumber, uint16 auValue);
343 uint32 PortGet16(uint16 auNumber, uint16& auValue);
344
346 uint32 PortPut32(uint16 auNumber, uint32 auValue);
348 uint32 PortGet32(uint16 auNumber, uint32& auValue);
349
350 #if defined(INOS_PORTS_64BIT)
352 uint32 PortPut64(uint16 auNumber, uint64 auValue);
354 uint32 PortGet64(uint16 auNumber, uint64& auValue);
355 #endif
356
358 uint32 GetVariable(const char* apName, real64& arValue);
360 uint32 GetVariable(const char* apName, char* apValue, uint32 auLength);
361
363 uint32 GetVariableEx(const char* apName, uint32 auIncoType, void* apValue, uint32 auSize);
364
366 uint32 PutVariable(const char* apName, real64 arValue);
368 uint32 PutVariable(const char* apName, const char* apValue);
369
371 uint32 CallProcedure(const char* apName, long aiNrOfParameters,
372 void* apParameters, void* apResult);
373
374
375 //--- internals --------------------------------------------------------
376
377 friend class CINOSCOPMaster;
378
379 // public member functions but just for internal use
380 public :
390 SINOSCOPModuleEeprom* apEeprom, XMLNode aCardNode,
391 CINCOCOPDevice* apDevice, bool abOnline);
394
396 CINCOCOPDevice* GetDevice() {
397 return m_pDevice;
398 };
399
403
408 bool CheckRangeCondition(CINOSBusPortHandlerRangeCondition* apCond);
409
413 void ResolveEepromValues(XMLNode& aAction);
414
419 template<class T> T GetEepromValue(uint32 auOffset) {
420 // get according address
421 void* p = GetEepromAddress(auOffset);
422 #if INOS_BYTE_ORDER == INOS_LITTLE_ENDIAN
423 // check size
424 switch (sizeof(T)){
425 case 1 : return *((T*) ((uintptr)p^3));
426 case 2 : return *((T*) ((uintptr)p^2));
427 case 4 : return *((T*)p);
428 case 8 : {
429 uint64 u = (uint64(*((T*)p))<<32) + *((T*)((uintptr)p+4));
430 return *((T*)&u);
431 }
432 }
433 #else
434 return *((T*)p);
435 #endif
436 // keep compiler happy
437 return (T)0;
438 }
439
440 // eeprom handling routines
441
444 virtual uint32 EepromRead();
447 virtual uint32 EepromWrite();
451
455 void SetXmlModValid(bool abXmlModValid) {
456 m_uFlags=(m_uFlags&~DF_INOS_COP_FLAG_XML_MOD_VALID)|
457 (abXmlModValid?DF_INOS_COP_FLAG_XML_MOD_VALID:0);
458 }
459
463 void SetXmlMod(const char* apModXml) {
464 m_pModXml=apModXml;
465 }
466
470 bool IsOnline();
471
476 {
477 return (m_uFlags&DF_INOS_COP_FLAG_EEPROM_VALID);
478 }
479
485 void FixPortRegistration(CINCOItem* apItem, uint32* apTable,
486 uint32 auTableSize);
487
491
495
499 void SetupPortCache(uint16 auNumber, uint8 auSize, const char* apType);
500
504 void UpdatePortCache(uint16 auNumber, uint8 auSize);
505
509 bool IsPortCachable(uint16 auNumber)
510 { return m_uPortCachable[auNumber>>5] & (1<<(auNumber&0x1f)); }
511
515 bool IsPortCached(uint16 auNumber)
516 { return (m_ePortCache == ePortCacheEnabled) && (m_uPortCacheValid[auNumber>>5] & (1<<(auNumber&0x1f))); }
517
518 // private members
519 private :
520
521 enum {
522 eCnsUpdateCacheOk = 3, // number of requested successful port reads
523 eCnsUpdateCacheMax = 16, // max. allowed reads
524 };
525
527 CINOSCOPMaster* m_pMaster;
529 CINCOCOPDevice* m_pDevice;
531 SINOSCOPModule* m_pDesc;
533 SINOSCOPModuleEeprom m_Eeprom;
535 uint32 m_uFlags;
537 char m_cEepromInfo[256];
539 uint32 m_uFpgaRevision;
541 uint16 m_uAddressSwitch;
543 char m_cTargetInfo[256];
545 uint16 m_uMemoryPortSize;
546 uint32 m_uMemoryPortBgn;
547 uint32 m_uMemoryPortEnd;
549 uint32 m_uMemoryRam16BitSize;
550 uint32 m_uMemoryRamBgn;
551 uint32 m_uMemoryRamEnd;
553 enum EPortCacheState {
554 ePortCacheDisabled,
555 ePortCacheEnabled
556 } m_ePortCache = ePortCacheEnabled;
558 uint16 m_uPortCache[256]{};
560 uint32 m_uPortCachable[8]{};
562 uint32 m_uPortCacheValid[8]{};
564 uint16 m_uPortStatus;
566 XMLNode m_CardNode;
568 CINOSIncoAction* m_pStartup;
570 CINCOObject* m_pInco;
572 std::vector<CINOSCOPModule *> m_Distribution;
574 CINOSCOPModule* m_pNext;
576 bool m_bOnline;
578 const char* m_pModXml;
580 const char* m_pCardNodeXml;
582 uint32 m_uCardNodeXmlSize;
584 char* m_pCardNodeXmlCompressed;
586 uint32 m_uCardNodeXmlCompressedSize;
587
590};
591
592
593//------------------------------------------------------------------------------
594
595#endif // INC_CINOSCOPMODULE_H
596
597
598//------------------------------------------------------------------------------
599// end of file
#define DF_INOS_COP_FLAG_LITTLE_ENDIAN
Flag if ram is little endian.
Definition cinoscopmodule.h:62
#define DF_INOS_COP_FLAG_EEPROM_VALID
Flag if eeprom could be read and is valid.
Definition cinoscopmodule.h:56
#define DF_INOS_COP_FLAG_RAM_PROTECT
Flag if ram config ports (0xF8/0xF9) need enable flag before writing.
Definition cinoscopmodule.h:60
#define DF_INOS_COP_FLAG_XML_MOD_VALID
Flag if module's xml config file is valid.
Definition cinoscopmodule.h:58
#define DECLARE_DYNAMIC(aClass)
Definition cinospartitionmemory.h:328
The main class handling a COP bus, local or remote (GinLink passive).
Definition cinoscopmaster.h:251
The class handling a single COP module.
Definition cinoscopmodule.h:214
const char * GetName()
get module name
Definition cinoscopmodule.h:219
const char * GetStateText()
Get state text.
uint32 PutBlock16(uint32 auDest, uint16 *apSource, uint16 auNumber, uint32 auFlags=0)
put block of 16 bit values
bool IsPortCached(uint16 auNumber)
Check if port cached.
Definition cinoscopmodule.h:515
void RegisterRam()
Register variables pointing into onboard ram.
void ResolveEepromValues(XMLNode &aAction)
Resolve values with eeprom references (e.g. uint16:Eeprom[80]).
T GetEepromValue(uint32 auOffset)
Get eeprom value with certain type.
Definition cinoscopmodule.h:419
CINOSCOPModule * GetNext()
module pointer to next cop module
Definition cinoscopmodule.h:291
bool IsEepromValid()
Return true if eeprom is valid.
Definition cinoscopmodule.h:475
bool CheckRangeCondition(CINOSBusPortHandlerRangeCondition *apCond)
Check if the condition of a range is met.
void * GetEepromAddress(uint32 auOffset)
get eeprom address
Definition cinoscopmodule.h:230
uint32 GetFpgaRevision()
Get the fpga revision.
Definition cinoscopmodule.h:273
uint32 GetAddress()
get module address
Definition cinoscopmodule.h:227
uint16 GetAddressSwitch()
Get the address switch read after scanning.
Definition cinoscopmodule.h:279
void UpdatePortCache(uint16 auNumber, uint8 auSize)
Update cache of given port.
CINOSCOPModule(CINOSCOPMaster *apMaster, SINOSCOPModule *apDesc, SINOSCOPModuleEeprom *apEeprom, XMLNode aCardNode, CINCOCOPDevice *apDevice, bool abOnline)
Constructor of COP module.
uint32 GetVariable(const char *apName, real64 &arValue)
get variable from module tree
void DisablePortCache()
Disable port cache.
uint32 GetVariableEx(const char *apName, uint32 auIncoType, void *apValue, uint32 auSize)
get variable from module tree
uint32 PortGet32(uint16 auNumber, uint32 &auValue)
get 32 bit value from cop module port
void SetXmlModValid(bool abXmlModValid)
Set validity of module's xml file.
Definition cinoscopmodule.h:455
uint32 GetVariable(const char *apName, char *apValue, uint32 auLength)
get variable from module tree
bool IsOnline()
Return online state of cop module.
bool HasRamPortsProtected()
Check if module needs config enable bit set for writing ram ports F8/F9.
Definition cinoscopmodule.h:250
bool IsPortCachable(uint16 auNumber)
Check if port cachable.
Definition cinoscopmodule.h:509
void FixPortRegistration(CINCOItem *apItem, uint32 *apTable, uint32 auTableSize)
Fix the registration of a write port item (recursively).
void SetXmlMod(const char *apModXml)
Set content of module's xml file.
Definition cinoscopmodule.h:463
void FixPortRegistration()
Adjust the ports registration to show the real value.
void SetBoardInfo(SINOSCOPModuleEeprom &aBoardInfo)
Set board info for target registration.
Definition cinoscopmodule.h:265
virtual const char * GetXmlCompressedAddr()
get address of xml description
void SetNext(CINOSCOPModule *apNext)
set pointer to next cop module
Definition cinoscopmodule.h:294
void UpdateTargetString()
Terminate eeprom strings and update info string.
void GetBoardInfo(SINOSCOPModuleEeprom &aBoardInfo, bool &abEepromValid)
Get board info for target registration.
Definition cinoscopmodule.h:260
virtual uint32 GetXmlSize()
get size of xml description
void SetDistributionModule(CINOSCOPModule *apDist, char *apXml)
set pointer to distribution module
void Startup()
run startup actions
XMLNode GetXmlNode()
Get card node.
Definition cinoscopmodule.h:237
CINCOCOPDevice * GetDevice()
get pointer to cop inco device
Definition cinoscopmodule.h:396
uint32 GetEepromSize()
get eeprom address
Definition cinoscopmodule.h:234
uint32 PortGet16(uint16 auNumber, uint16 &auValue)
get 16 bit value from cop module port
uint32 CallProcedure(const char *apName, long aiNrOfParameters, void *apParameters, void *apResult)
call procedure.
virtual uint32 EepromWrite()
Write cop bus module eeprom.
virtual uint32 EepromRead()
Read cop bus module eeprom.
uint32 GetBlock8(uint32 auSource, uint8 *apDest, uint16 auNumber, uint32 auFlags=0)
Read a number of 8 bit values.
const char * GetInfo()
get module info
Definition cinoscopmodule.h:222
virtual ~CINOSCOPModule()
Destructor.
uint32 PutVariable(const char *apName, const char *apValue)
put variable in module tree
uint32 GetBlock16(uint32 auSource, uint16 *apDest, uint16 auNumber, uint32 auFlags=0)
get block of 16 bit values
uint32 PortPut32(uint16 auNumber, uint32 auValue)
put 32 bit value to cop module port
CINCOObject * GetInco()
get inco
Definition cinoscopmodule.h:240
virtual uint32 GetXmlCompressedSize()
get compressed size of xml description
uint32 PutBlock32(uint32 auDest, uint32 *apSource, uint16 auNumber, uint32 auFlags=0)
Write a number of 32 bit values.
uint32 PutBlock8(uint32 auDest, uint8 *apSource, uint16 auNumber, uint32 auFlags=0)
Write a number of 8 bit values.
void EnablePortCache()
Enable port cache.
uint32 PutVariable(const char *apName, real64 arValue)
put variable in module tree
void SetupPortCache(uint16 auNumber, uint8 auSize, const char *apType)
Check if given port needs to be cached.
uint32 GetBlock32(uint32 auSource, uint32 *apDest, uint16 auNumber, uint32 auFlags=0)
Read a number of 32 bit values.
bool IsRamLittleEndian()
Check if module ram is little endian.
Definition cinoscopmodule.h:255
uint32 PortPut16(uint16 auNumber, uint16 auValue)
put 16 bit value to cop module port
Struct for the COP module board info data.
Definition cinoscopmodule.h:121
char m_cCardName[24]
card name
Definition cinoscopmodule.h:132
uint8 m_uDataOffset
data offset
Definition cinoscopmodule.h:126
uint32 m_uSeriesNumber
series number
Definition cinoscopmodule.h:140
uint32 m_uOptions
options
Definition cinoscopmodule.h:142
uint32 m_uWorkNumber
work number
Definition cinoscopmodule.h:136
char m_cRevision[4]
revision
Definition cinoscopmodule.h:134
uint8 m_uChecksum
check sum
Definition cinoscopmodule.h:124
uint16 m_uVersion
structure revision
Definition cinoscopmodule.h:128
uint64 m_uMacNumber
mac number
Definition cinoscopmodule.h:138
uint32 m_uCardNumber
card number
Definition cinoscopmodule.h:130
Struct of the eeprom data of a COP module.
Definition cinoscopmodule.h:174
DECLARE_DYNAMIC(SINOSCOPModuleEeprom)
Support dynamic object handling.
void SetChecksum()
Insert checksum into structure.
bool ChecksumOk()
Return true if internal checksum is ok.
uint8 m_uReserved[8]
reserved
Definition cinoscopmodule.h:176
void Clear()
Clear data so checksum becomes invalid.
uint8 GetChecksum(uint32 auLength)
Calculate checksum.
uint8 m_uData[1024-64]
Start of data (pointed to by DataOffset).
Definition cinoscopmodule.h:183
Struct with data describing a COP module.
Definition cinoscopmodule.h:91
inosName32 m_cName
module name (modname.subname)
Definition cinoscopmodule.h:97
uint32 m_uAddress
module address
Definition cinoscopmodule.h:99
uint32 m_uEepromSize
eeprom size
Definition cinoscopmodule.h:101
char m_cProductCode[16]
required product code (e.g. 6108386xx) or empty if don't care
Definition cinoscopmodule.h:108
uint32 m_uOptions
module options (Bit 0=1 -> only use sub module name for process image
Definition cinoscopmodule.h:104
char m_cRevision[16]
required revision (e.g. 0x000001xx) or empty if don't care
Definition cinoscopmodule.h:110
DECLARE_DYNAMIC(SINOSCOPModule)
Support dynamic object handling.
uint32 m_uVendorId
vendor id (0x00000000-indel, 0x80000000-custom)
Definition cinoscopmodule.h:106