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_JITTER_ACT 0xF0
48#define DF_INOS_COP_PORT_JITTER_MIN 0xF1
49#define DF_INOS_COP_PORT_JITTER_MAX 0xF2
50#define DF_INOS_COP_PORT_JITTER_RESET 0xF3
51#define DF_INOS_COP_PORT_RAM_ADR 0xF8
52#define DF_INOS_COP_PORT_RAM_DAT 0xF9
53#define DF_INOS_COP_PORT_STATUS 0xFC
54#define DF_INOS_COP_PORT_APPREV 0xFE
55#define DF_INOS_COP_PORT_SEQREV 0xFF
56
57#define DF_INOS_COP_PORT_ENABLE_WRITE 0x4000
58
60#define DF_INOS_COP_FLAG_EEPROM_VALID 0x00000001
62#define DF_INOS_COP_FLAG_XML_MOD_VALID 0x00000002
64#define DF_INOS_COP_FLAG_RAM_PROTECT 0x00000004
66#define DF_INOS_COP_FLAG_LITTLE_ENDIAN 0x00000008
68#define DF_INOS_COP_FLAG_INFO_1 0x00000010
69
70// startup action options
71#define DF_INOS_COP_STRT_OPTION_SLOW 0x00000001
72
73
74//------------------------------------------------------------------------------
75// includes
76//------------------------------------------------------------------------------
77//
78// system
79
80// C++
81#include <vector>
82//
83// project
84#include <xmlparser.h>
85
86class CINOSIncoAction;
87
88
89//------------------------------------------------------------------------------
90// structures
91//------------------------------------------------------------------------------
92
95{
96 enum {
97 eOptSubName = 0x00000001
98 };
99
101 inosName32 m_cName;
107 // channel names)
114 char m_cRevision[16];
115
118};
119
122#if INOS_BYTE_ORDER == INOS_LITTLE_ENDIAN
125{
126 // --- start of header ---
136 char m_cCardName[24];
138 char m_cRevision[4];
147};
148#else
151{
152 // --- start of header ---
154 uint16 m_uVersion;
156 uint8 m_uDataOffset;
158 uint8 m_uChecksum;
160 uint32 m_uCardNumber;
162 char m_cCardName[24];
164 char m_cRevision[4];
166 uint32 m_uWorkNumber;
168 uint64 m_uMacNumber;
170 uint32 m_uSeriesNumber;
172 uint32 m_uOptions;
173};
174#endif
175// version 2.00
178{
180 uint8 m_uReserved[8];
181
187 uint8 m_uData[1024-64];
188
189 // methods
191 uint8 GetChecksum(uint32 auLength);
193 uint8 GetChecksum_old_style(uint32 auLength);
199 void Clear();
200
203};
204//
205//------------------------------------------------------------------------------
206// forwards
207//------------------------------------------------------------------------------
208
209class CINCOCOPDevice;
210class CINOSCOPMaster;
211class CINOSBusPortHandlerRangeCondition;
212
213
214//------------------------------------------------------------------------------
215// class definition
216//------------------------------------------------------------------------------
217
220{
221 //--- user interface ---------------------------------------------------
222
223 public :
225 const char* GetName()
226 { return &m_pDesc->m_cName[0]; };
228 const char* GetInfo()
229 { return m_cTargetInfo; };
231 const char* GetStateText();
233 uint32 GetAddress()
234 { return m_pDesc->m_uAddress; };
236 void* GetEepromAddress(uint32 auOffset)
237 { return (void*)((uintptr)&m_Eeprom+auOffset); };
238 void* GetEepromAddress(const char* apName, uint32 auOffset);
241 { return sizeof(m_Eeprom); };
243 XMLNode GetXmlNode()
244 { return m_CardNode; };
246 CINCOObject* GetInco()
247 { return m_pInco; };
249 virtual const char* GetXmlCompressedAddr();
251 virtual uint32 GetXmlSize();
253 virtual uint32 GetXmlCompressedSize();
254
257 return m_uFlags & DF_INOS_COP_FLAG_RAM_PROTECT;
258 }
259
262 return m_uFlags & DF_INOS_COP_FLAG_LITTLE_ENDIAN;
263 }
264
266 void GetBoardInfo(SINOSCOPModuleEeprom& aBoardInfo, bool& abEepromValid) {
267 aBoardInfo=m_Eeprom;
268 abEepromValid=((m_uFlags&DF_INOS_COP_FLAG_EEPROM_VALID)?true:false);
269 };
272 memcpy(&m_Eeprom, &aBoardInfo, sizeof(aBoardInfo));
274 };
275
280 return m_uFpgaRevision;
281 }
286 return m_uAddressSwitch;
287 }
288
292
294 void Startup();
295
298 { return m_pNext;};
301 { m_pNext = apNext;};
303 void SetDistributionModule(CINOSCOPModule* apDist, char* apXml);
304
311 uint32 PutBlock32(uint32 auDest, uint32* apSource, uint16 auNumber,
312 uint32 auFlags = 0);
313
320 uint32 GetBlock32(uint32 auSource, uint32* apDest, uint16 auNumber,
321 uint32 auFlags = 0);
322
324 uint32 PutBlock16(uint32 auDest, uint16* apSource, uint16 auNumber, uint32 auFlags = 0);
326 uint32 GetBlock16(uint32 auSource, uint16* apDest, uint16 auNumber, uint32 auFlags = 0);
327
334 uint32 PutBlock8(uint32 auDest, uint8* apSource, uint16 auNumber,
335 uint32 auFlags = 0);
336
343 uint32 GetBlock8(uint32 auSource, uint8* apDest, uint16 auNumber,
344 uint32 auFlags = 0);
345
347 uint32 PortPut16(uint16 auNumber, uint16 auValue);
349 uint32 PortGet16(uint16 auNumber, uint16& auValue);
350
352 uint32 PortPut32(uint16 auNumber, uint32 auValue);
354 uint32 PortGet32(uint16 auNumber, uint32& auValue);
355
356 #if defined(INOS_PORTS_64BIT)
358 uint32 PortPut64(uint16 auNumber, uint64 auValue);
360 uint32 PortGet64(uint16 auNumber, uint64& auValue);
361 #endif
362
364 uint32 GetVariable(const char* apName, real64& arValue);
366 uint32 GetVariable(const char* apName, char* apValue, uint32 auLength);
367
369 uint32 GetVariableEx(const char* apName, uint32 auIncoType, void* apValue, uint32 auSize);
370
372 uint32 PutVariable(const char* apName, real64 arValue);
374 uint32 PutVariable(const char* apName, const char* apValue);
375
377 uint32 CallProcedure(const char* apName, long aiNrOfParameters,
378 void* apParameters, void* apResult);
379
380
381 //--- internals --------------------------------------------------------
382
383 friend class CINOSCOPMaster;
384
385 // public member functions but just for internal use
386 public :
396 SINOSCOPModuleEeprom* apEeprom, XMLNode aCardNode,
397 CINCOCOPDevice* apDevice, bool abOnline);
400
402 CINCOCOPDevice* GetDevice() {
403 return m_pDevice;
404 };
405
409
414 bool CheckRangeCondition(CINOSBusPortHandlerRangeCondition* apCond);
415
419 void ResolveEepromValues(XMLNode& aAction);
420
425 template<class T> T GetEepromValue(uint32 auOffset) {
426 // get according address
427 void* p = GetEepromAddress(auOffset);
428 #if INOS_BYTE_ORDER == INOS_LITTLE_ENDIAN
429 // check size
430 switch (sizeof(T)){
431 case 1 : return *((T*) ((uintptr)p^3));
432 case 2 : return *((T*) ((uintptr)p^2));
433 case 4 : return *((T*)p);
434 case 8 : {
435 uint64 u = (uint64(*((T*)p))<<32) + *((T*)((uintptr)p+4));
436 return *((T*)&u);
437 }
438 }
439 #else
440 return *((T*)p);
441 #endif
442 // keep compiler happy
443 return (T)0;
444 }
445
446 // eeprom handling routines
447
450 virtual uint32 EepromRead();
453 virtual uint32 EepromWrite();
457
461 void SetXmlModValid(bool abXmlModValid) {
462 m_uFlags=(m_uFlags&~DF_INOS_COP_FLAG_XML_MOD_VALID)|
463 (abXmlModValid?DF_INOS_COP_FLAG_XML_MOD_VALID:0);
464 }
465
469 void SetXmlMod(const char* apModXml) {
470 m_pModXml=apModXml;
471 }
472
476 bool IsOnline();
477
482 {
483 return (m_uFlags&DF_INOS_COP_FLAG_EEPROM_VALID);
484 }
485
491 void FixPortRegistration(CINCOItem* apItem, uint32* apTable,
492 uint32 auTableSize);
493
497
501
505 void SetupPortCache(uint16 auNumber, uint8 auSize, const char* apType);
506
510 void UpdatePortCache(uint16 auNumber, uint8 auSize);
511
515 bool IsPortCachable(uint16 auNumber)
516 { return m_uPortCachable[auNumber>>5] & (1<<(auNumber&0x1f)); }
517
521 bool IsPortCached(uint16 auNumber)
522 { return (m_ePortCache == ePortCacheEnabled) && (m_uPortCacheValid[auNumber>>5] & (1<<(auNumber&0x1f))); }
523
524 // private members
525 private :
526
527 enum {
528 eCnsUpdateCacheOk = 3, // number of requested successful port reads
529 eCnsUpdateCacheMax = 16, // max. allowed reads
530 };
531
533 CINOSCOPMaster* m_pMaster;
535 CINCOCOPDevice* m_pDevice;
537 SINOSCOPModule* m_pDesc;
539 SINOSCOPModuleEeprom m_Eeprom;
541 uint32 m_uFlags;
543 char m_cEepromInfo[256];
545 uint32 m_uFpgaRevision;
547 uint16 m_uAddressSwitch;
549 char m_cTargetInfo[256];
551 uint16 m_uMemoryPortSize;
552 uint32 m_uMemoryPortBgn;
553 uint32 m_uMemoryPortEnd;
555 uint32 m_uMemoryRam16BitSize;
556 uint32 m_uMemoryRamBgn;
557 uint32 m_uMemoryRamEnd;
559 enum EPortCacheState {
560 ePortCacheDisabled,
561 ePortCacheEnabled
562 } m_ePortCache = ePortCacheEnabled;
564 uint16 m_uPortCache[256]{};
566 uint32 m_uPortCachable[8]{};
568 uint32 m_uPortCacheValid[8]{};
570 uint16 m_uPortStatus;
572 XMLNode m_CardNode;
574 CINOSIncoAction* m_pStartup;
576 CINCOObject* m_pInco;
578 std::vector<CINOSCOPModule *> m_Distribution;
580 CINOSCOPModule* m_pNext;
582 bool m_bOnline;
584 const char* m_pModXml;
586 const char* m_pCardNodeXml;
588 uint32 m_uCardNodeXmlSize;
590 char* m_pCardNodeXmlCompressed;
592 uint32 m_uCardNodeXmlCompressedSize;
593
596};
597
598
599//------------------------------------------------------------------------------
600
601#endif // INC_CINOSCOPMODULE_H
602
603
604//------------------------------------------------------------------------------
605// end of file
#define DF_INOS_COP_FLAG_LITTLE_ENDIAN
Flag if ram is little endian.
Definition cinoscopmodule.h:66
#define DF_INOS_COP_FLAG_EEPROM_VALID
Flag if eeprom could be read and is valid.
Definition cinoscopmodule.h:60
#define DF_INOS_COP_FLAG_RAM_PROTECT
Flag if ram config ports (0xF8/0xF9) need enable flag before writing.
Definition cinoscopmodule.h:64
#define DF_INOS_COP_FLAG_XML_MOD_VALID
Flag if module's xml config file is valid.
Definition cinoscopmodule.h:62
#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:220
const char * GetName()
get module name
Definition cinoscopmodule.h:225
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:521
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:425
CINOSCOPModule * GetNext()
module pointer to next cop module
Definition cinoscopmodule.h:297
bool IsEepromValid()
Return true if eeprom is valid.
Definition cinoscopmodule.h:481
bool CheckRangeCondition(CINOSBusPortHandlerRangeCondition *apCond)
Check if the condition of a range is met.
void * GetEepromAddress(uint32 auOffset)
get eeprom address
Definition cinoscopmodule.h:236
uint32 GetFpgaRevision()
Get the fpga revision.
Definition cinoscopmodule.h:279
uint32 GetAddress()
get module address
Definition cinoscopmodule.h:233
uint16 GetAddressSwitch()
Get the address switch read after scanning.
Definition cinoscopmodule.h:285
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:461
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:256
bool IsPortCachable(uint16 auNumber)
Check if port cachable.
Definition cinoscopmodule.h:515
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:469
void FixPortRegistration()
Adjust the ports registration to show the real value.
void SetBoardInfo(SINOSCOPModuleEeprom &aBoardInfo)
Set board info for target registration.
Definition cinoscopmodule.h:271
virtual const char * GetXmlCompressedAddr()
get address of xml description
void SetNext(CINOSCOPModule *apNext)
set pointer to next cop module
Definition cinoscopmodule.h:300
void UpdateTargetString()
Terminate eeprom strings and update info string.
void GetBoardInfo(SINOSCOPModuleEeprom &aBoardInfo, bool &abEepromValid)
Get board info for target registration.
Definition cinoscopmodule.h:266
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:243
CINCOCOPDevice * GetDevice()
get pointer to cop inco device
Definition cinoscopmodule.h:402
uint32 GetEepromSize()
get eeprom address
Definition cinoscopmodule.h:240
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:228
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:246
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:261
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:125
char m_cCardName[24]
card name
Definition cinoscopmodule.h:136
uint8 m_uDataOffset
data offset
Definition cinoscopmodule.h:130
uint32 m_uSeriesNumber
series number
Definition cinoscopmodule.h:144
uint32 m_uOptions
options
Definition cinoscopmodule.h:146
uint32 m_uWorkNumber
work number
Definition cinoscopmodule.h:140
char m_cRevision[4]
revision
Definition cinoscopmodule.h:138
uint8 m_uChecksum
check sum
Definition cinoscopmodule.h:128
uint16 m_uVersion
structure revision
Definition cinoscopmodule.h:132
uint64 m_uMacNumber
mac number
Definition cinoscopmodule.h:142
uint32 m_uCardNumber
card number
Definition cinoscopmodule.h:134
Struct of the eeprom data of a COP module.
Definition cinoscopmodule.h:178
DECLARE_DYNAMIC(SINOSCOPModuleEeprom)
Support dynamic object handling.
void SetChecksum()
Insert checksum into structure.
bool ChecksumOk()
Return true if internal checksum is ok.
uint8 GetChecksum_old_style(uint32 auLength)
Calculate checksum old style (before r9963, 18.10.2019)
uint8 m_uReserved[8]
reserved
Definition cinoscopmodule.h:180
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:187
Struct with data describing a COP module.
Definition cinoscopmodule.h:95
inosName32 m_cName
module name (modname.subname)
Definition cinoscopmodule.h:101
uint32 m_uAddress
module address
Definition cinoscopmodule.h:103
uint32 m_uEepromSize
eeprom size
Definition cinoscopmodule.h:105
char m_cProductCode[16]
required product code (e.g. 6108386xx) or empty if don't care
Definition cinoscopmodule.h:112
uint32 m_uOptions
module options (Bit 0=1 -> only use sub module name for process image
Definition cinoscopmodule.h:108
char m_cRevision[16]
required revision (e.g. 0x000001xx) or empty if don't care
Definition cinoscopmodule.h:114
DECLARE_DYNAMIC(SINOSCOPModule)
Support dynamic object handling.
uint32 m_uVendorId
vendor id (0x00000000-indel, 0x80000000-custom)
Definition cinoscopmodule.h:110