root/trunk/libffado/src/libieee1394/configrom.cpp

Revision 2803, 22.9 kB (checked in by jwoithe, 1 year ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Jonathan Woithe
4  * Copyright (C) 2005-2008 by Pieter Palmers
5  *
6  * This file is part of FFADO
7  * FFADO = Free FireWire (pro-)audio drivers for Linux
8  *
9  * FFADO is based upon FreeBoB
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 2 of the License, or
14  * (at your option) version 3 of the License.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25
26 #include "config.h"
27
28 #include "configrom.h"
29 #include "ieee1394service.h"
30
31 #include "vendor_model_ids.h"
32
33 #include "libutil/SystemTimeSource.h"
34
35 #include <stdio.h>
36 #include <string.h>
37
38 #include <iostream>
39 #include <iomanip>
40
41 using namespace std;
42
43 IMPL_DEBUG_MODULE( ConfigRom, ConfigRom, DEBUG_LEVEL_NORMAL );
44
45 static int busRead( struct csr1212_csr* csr,
46                     u_int64_t addr,
47                     u_int16_t length,
48                     void* buffer,
49                     void* private_data );
50
51 static int getMaxRom( u_int32_t* bus_info_data,
52                       void* private_data );
53
54 static struct csr1212_bus_ops configrom_csr1212_ops = {
55     busRead,
56     0,
57     0,
58     getMaxRom
59 };
60
61 struct config_csr_info {
62     Ieee1394Service* service;
63     fb_nodeid_t      nodeId;
64 };
65
66 //-------------------------------------------------------------
67
68 ConfigRom::ConfigRom( Ieee1394Service& ieee1394service, fb_nodeid_t nodeId )
69     : Control::Element(NULL, "ConfigRom")
70     , m_1394Service( ieee1394service )
71     , m_nodeId( nodeId )
72     , m_avcDevice( false ) // FIXME: this does not seem veryu
73     , m_guid( 0 )
74     , m_vendorName( "" )
75     , m_modelName( "" )
76     , m_vendorId( 0 )
77     , m_modelId( 0 )
78     , m_unit_specifier_id( 0 )
79     , m_unit_version( 0 )
80     , m_isIsoResourceManager( false )
81     , m_isCycleMasterCapable( false )
82     , m_isSupportIsoOperations( false )
83     , m_isBusManagerCapable( false )
84     , m_cycleClkAcc( 0 )
85     , m_maxRec( 0 )
86     , m_nodeVendorId( 0 )
87     , m_chipIdHi( 0 )
88     , m_chipIdLow( 0 )
89     , m_vendorNameKv( 0 )
90     , m_modelNameKv( 0 )
91     , m_csr( 0 )
92 {
93 }
94
95 ConfigRom::ConfigRom()
96     : Control::Element(NULL, "ConfigRom")
97     , m_1394Service( *(new Ieee1394Service()) )
98     , m_nodeId( -1 )
99     , m_avcDevice( false ) // FIXME: this does not seem veryu
100     , m_guid( 0 )
101     , m_vendorName( "" )
102     , m_modelName( "" )
103     , m_vendorId( 0 )
104     , m_modelId( 0 )
105     , m_unit_specifier_id( 0 )
106     , m_unit_version( 0 )
107     , m_isIsoResourceManager( false )
108     , m_isCycleMasterCapable( false )
109     , m_isSupportIsoOperations( false )
110     , m_isBusManagerCapable( false )
111     , m_cycleClkAcc( 0 )
112     , m_maxRec( 0 )
113     , m_nodeVendorId( 0 )
114     , m_chipIdHi( 0 )
115     , m_chipIdLow( 0 )
116     , m_vendorNameKv( 0 )
117     , m_modelNameKv( 0 )
118     , m_csr( 0 )
119 {
120 }
121
122 Ieee1394Service&
123 ConfigRom::get1394Service()
124 {
125     return m_1394Service;
126 }
127
128 bool
129 ConfigRom::operator == ( const ConfigRom& rhs )
130 {
131     return m_guid == rhs.m_guid;
132 }
133
134 bool
135 ConfigRom::compareGUID( const ConfigRom& a, const ConfigRom& b ) {
136     return a.getGuid() > b.getGuid();
137 }
138
139 bool
140 ConfigRom::initialize()
141 {
142      struct config_csr_info csr_info;
143      csr_info.service = &m_1394Service;
144      csr_info.nodeId = 0xffc0 | m_nodeId;
145
146      m_csr = csr1212_create_csr( &configrom_csr1212_ops,
147                                  5 * sizeof(fb_quadlet_t),   // XXX Why 5 ?!?
148                                  &csr_info );
149     if (!m_csr || csr1212_parse_csr( m_csr ) != CSR1212_SUCCESS) {
150         debugOutput(DEBUG_LEVEL_INFO, "Could not parse config rom of node %d on port %d\n", m_nodeId, m_1394Service.getPort() );
151         if (m_csr) {
152             csr1212_destroy_csr(m_csr);
153             m_csr = 0;
154         }
155         return false;
156     }
157
158     // Process Bus_Info_Block
159     m_isIsoResourceManager = CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 31;
160     m_isCycleMasterCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 30 ) & 0x1;
161     m_isSupportIsoOperations = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 29 ) & 0x1;
162     m_isBusManagerCapable = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 28 ) & 0x1;
163     m_cycleClkAcc = ( CSR1212_BE32_TO_CPU(m_csr->bus_info_data[2] ) >> 16 ) & 0xff;
164     m_maxRec = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[2] ) >> 12 ) & 0xf;
165     m_nodeVendorId = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) >> 8 );
166     m_chipIdHi = ( CSR1212_BE32_TO_CPU( m_csr->bus_info_data[3] ) ) & 0xff;
167     m_chipIdLow = CSR1212_BE32_TO_CPU( m_csr->bus_info_data[4] );
168
169     // Process Root Directory
170     processRootDirectory(m_csr);
171
172     if ( m_vendorNameKv ) {
173         int len = ( m_vendorNameKv->value.leaf.len - 2) * sizeof( quadlet_t );
174         char* buf = new char[len+2];
175         memcpy( buf,
176                 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_vendorNameKv ),
177                 len );
178
179         while (*(buf + len - 1) == '\0') {
180                 len--;
181         }
182         // Ensure vendor string is null terminated
183         buf[len] = '\0';
184
185
186         debugOutput( DEBUG_LEVEL_VERBOSE, "Vendor name: '%s'\n", buf );
187         m_vendorName = buf;
188         delete[] buf;
189     }
190     if ( m_modelNameKv ) {
191         int len = ( m_modelNameKv->value.leaf.len - 2) * sizeof( quadlet_t );
192         char* buf = new char[len+2];
193         memcpy( buf,
194                 ( void* )CSR1212_TEXTUAL_DESCRIPTOR_LEAF_DATA( m_modelNameKv ),
195                 len );
196         while (*(buf + len - 1) == '\0') {
197                 len--;
198         }
199         // Ensure model name string is null terminated
200         buf[len] = '\0';
201
202         debugOutput( DEBUG_LEVEL_VERBOSE, "Model name: '%s'\n", buf);
203         m_modelName = buf;
204         delete[] buf;
205     }
206
207     m_guid = ((u_int64_t)CSR1212_BE32_TO_CPU(m_csr->bus_info_data[3]) << 32)
208              | CSR1212_BE32_TO_CPU(m_csr->bus_info_data[4]);
209
210     if ( m_vendorNameKv ) {
211         csr1212_release_keyval( m_vendorNameKv );
212         m_vendorNameKv = 0;
213     }
214     if ( m_modelNameKv ) {
215         csr1212_release_keyval( m_modelNameKv );
216         m_modelNameKv = 0;
217     }
218     if ( m_csr ) {
219         csr1212_destroy_csr(m_csr);
220         m_csr = 0;
221     }
222     return true;
223 }
224
225 static int
226 busRead( struct csr1212_csr* csr,
227          u_int64_t addr,
228          u_int16_t length,
229          void* buffer,
230          void* private_data )
231 {
232     struct config_csr_info* csr_info = (struct config_csr_info*) private_data;
233
234     int nb_retries = 5;
235
236     while ( nb_retries--
237             && !csr_info->service->read( csr_info->nodeId,
238                                          addr,
239                                          (size_t)length/4,
240                                          ( quadlet_t* )buffer)  )
241     {// failed, retry
242         Util::SystemTimeSource::SleepUsecRelative(IEEE1394SERVICE_CONFIGROM_READ_WAIT_USECS);
243     }
244     Util::SystemTimeSource::SleepUsecRelative(IEEE1394SERVICE_CONFIGROM_READ_WAIT_USECS);
245
246     if (nb_retries > -1) return 0; // success
247     else return -1; // failure
248 }
249
250 static int
251 getMaxRom( u_int32_t* bus_info_data,
252            void* /*private_data*/)
253 {
254     return (CSR1212_BE32_TO_CPU( bus_info_data[2] ) >> 8) & 0x3;
255 }
256
257
258 void
259 ConfigRom::processUnitDirectory( struct csr1212_csr* csr,
260                                  struct csr1212_keyval* ud_kv,
261                                  unsigned int *id )
262 {
263     struct csr1212_dentry *dentry;
264     struct csr1212_keyval *kv;
265     unsigned int last_key_id = 0;
266
267     debugOutput( DEBUG_LEVEL_VERBOSE, "process unit directory:\n" );
268     csr1212_for_each_dir_entry(csr, kv, ud_kv, dentry) {
269     switch (kv->key.id) {
270         case CSR1212_KV_ID_VENDOR:
271         if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
272                     debugOutput( DEBUG_LEVEL_VERBOSE,
273                                  "\tvendor_id = 0x%08x\n",
274                                  kv->value.immediate);
275                     m_vendorId = kv->value.immediate;
276         }
277         break;
278
279         case CSR1212_KV_ID_MODEL:
280                 debugOutput( DEBUG_LEVEL_VERBOSE,
281                              "\tmodel_id = 0x%08x\n",
282                              kv->value.immediate);
283                 m_modelId = kv->value.immediate;
284         break;
285
286         case CSR1212_KV_ID_SPECIFIER_ID:
287                 debugOutput( DEBUG_LEVEL_VERBOSE,
288                              "\tspecifier_id = 0x%08x\n",
289                              kv->value.immediate);
290                 m_unit_specifier_id = kv->value.immediate;
291         break;
292
293         case CSR1212_KV_ID_VERSION:
294                 debugOutput( DEBUG_LEVEL_VERBOSE,
295                              "\tversion = 0x%08x\n",
296                              kv->value.immediate);
297                 m_unit_version = kv->value.immediate;
298                 if ( m_unit_specifier_id == 0x0000a02d ) // XXX
299                 {
300                     m_avcDevice = true; // FIXME: disable this check for the moment
301                     if ( kv->value.immediate == 0x14001 ) {
302                         m_avcDevice = true;
303                     }
304                 }
305         break;
306
307         case CSR1212_KV_ID_DESCRIPTOR:
308         if (kv->key.type == CSR1212_KV_TYPE_LEAF &&
309             CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&
310             CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&
311             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&
312             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
313             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)
314         {
315             switch (last_key_id) {
316             case CSR1212_KV_ID_VENDOR:
317                 csr1212_keep_keyval(kv);
318                             m_vendorNameKv = kv;
319                 break;
320
321             case CSR1212_KV_ID_MODEL:
322                             m_modelNameKv = kv;
323                 csr1212_keep_keyval(kv);
324                 break;
325
326             }
327         } /* else if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) ... */
328         break;
329
330         case CSR1212_KV_ID_DEPENDENT_INFO:
331         if (kv->key.type == CSR1212_KV_TYPE_DIRECTORY) {
332             /* This should really be done in SBP2 as this is
333              * doing SBP2 specific parsing. */
334             processUnitDirectory(csr, kv, id);
335         }
336
337         break;
338
339         default:
340         break;
341     }
342     last_key_id = kv->key.id;
343     }
344 }
345
346 void
347 ConfigRom::processRootDirectory(struct csr1212_csr* csr)
348 {
349     unsigned int ud_id = 0;
350     struct csr1212_dentry *dentry;
351     struct csr1212_keyval *kv;
352     unsigned int last_key_id = 0;
353
354     csr1212_for_each_dir_entry(csr, kv, csr->root_kv, dentry) {
355     switch (kv->key.id) {
356         case CSR1212_KV_ID_VENDOR:
357                 debugOutput( DEBUG_LEVEL_VERBOSE,
358                              "vendor id = 0x%08x\n", kv->value.immediate);
359         break;
360
361         case CSR1212_KV_ID_NODE_CAPABILITIES:
362                 debugOutput( DEBUG_LEVEL_VERBOSE,
363                              "capabilities = 0x%08x\n", kv->value.immediate);
364         break;
365
366         case CSR1212_KV_ID_UNIT:
367         processUnitDirectory(csr, kv, &ud_id);
368         break;
369
370         case CSR1212_KV_ID_DESCRIPTOR:
371         if (last_key_id == CSR1212_KV_ID_VENDOR) {
372             if (kv->key.type == CSR1212_KV_TYPE_LEAF &&
373             CSR1212_DESCRIPTOR_LEAF_TYPE(kv) == 0 &&
374             CSR1212_DESCRIPTOR_LEAF_SPECIFIER_ID(kv) == 0 &&
375             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&
376             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
377             CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0)
378                     {
379                         m_vendorNameKv = kv;
380             csr1212_keep_keyval(kv);
381             }
382         }
383         break;
384     }
385     last_key_id = kv->key.id;
386     }
387
388 }
389
390 const fb_nodeid_t
391 ConfigRom::getNodeId() const
392 {
393     return m_nodeId;
394 }
395
396 const fb_octlet_t
397 ConfigRom::getGuid() const
398 {
399     return m_guid;
400 }
401
402 const std::string
403 ConfigRom::getGuidString() const
404 {
405     char* buf;
406     asprintf( &buf, "%08x%08x",
407               ( unsigned int ) ( getGuid() >> 32 ),
408               ( unsigned int ) ( getGuid() & 0xffffffff ) );
409     std::string result = buf;
410     free( buf );
411     return result;
412 }
413  
414 const std::string
415 ConfigRom::getModelName() const
416 {
417     // HACK:
418     // workarounds for devices that don't fill a correct model name
419     switch(m_vendorId) {
420         case FW_VENDORID_MOTU:
421             switch(m_unit_specifier_id) {
422                 case 0x00000001:
423                     return "828MkI";
424                 case 0x00000003:
425                     return "828MkII";
426                 case 0x00000005:
427                     return "896HD";
428                 case 0x00000009:
429                     return "Traveler";
430                 case 0x0000000d:
431                     return "UltraLite";
432                 case 0x0000000f:
433                     return "8pre";
434                 case 0x00000015:
435                     return "828Mk3";
436                 case 0x00000017:
437                     return "896Mk3";
438                 case 0x00000019:
439                     return "UltraliteMk3";
440                 case 0x0000001b:
441                     return "TravelerMk3";
442                 case 0x00000021:
443                     return "V4HD subdevice 0";
444                 case 0x00000022:
445                     return "V4HD subdevice 1";
446                 case 0x00000023:
447                     return "V4HD subdevice 2";
448                 case 0x00000024:
449                     return "V4HD subdevice 3";
450                 case 0x00000030:
451                     return "UltraLiteMk3-hybrid";
452                 default:
453                     return "unknown";
454             }
455             break;
456         default:
457             break;
458     }
459     // Note: m_nodeVendorId is not the same as m_vendorId; some devices use
460     // one, others use the other.
461     switch (m_nodeVendorId) {
462         case FW_VENDORID_RME:
463             switch (m_unit_version) {
464                 case 0x0001:
465                     return "Fireface 800";
466                 case 0x0002:
467                     return "Fireface 400";
468                 default:
469                     return "unknown";
470             }
471             break;
472         default:
473             break;
474     }
475     return m_modelName;
476 }
477
478 const std::string
479 ConfigRom::getVendorName() const
480 {
481     // HACK:
482     // workarounds for devices that don't fill a correct vendor name
483     switch(m_vendorId) {
484         case FW_VENDORID_MOTU:
485             return "MOTU";
486         default:
487             break;
488     }
489     switch (m_nodeVendorId) {
490         case FW_VENDORID_RME:
491             return "RME";
492         default:
493             break;
494     }
495     return m_vendorName;
496 }
497
498 const unsigned int
499 ConfigRom::getModelId() const
500 {
501     return m_modelId;
502 }
503
504 const unsigned int
505 ConfigRom::getVendorId() const
506 {
507     return m_vendorId;
508 }
509
510 const unsigned int
511 ConfigRom::getUnitSpecifierId() const
512 {
513     return m_unit_specifier_id;
514 }
515
516 const unsigned int
517 ConfigRom::getUnitVersion() const
518 {
519     return m_unit_version;
520 }
521
522 bool
523 ConfigRom::updatedNodeId()
524 {
525     debugOutput( DEBUG_LEVEL_VERBOSE,
526                  "Checking for updated node id for device with GUID 0x%016" PRIX64 "...\n",
527                  getGuid());
528
529     struct csr1212_csr* csr = NULL;
530     for ( fb_nodeid_t nodeId = 0;
531           nodeId < m_1394Service.getNodeCount();
532           ++nodeId )
533     {
534         struct config_csr_info csr_info;
535         csr_info.service = &m_1394Service;
536         csr_info.nodeId = 0xffc0 | nodeId;
537         debugOutput( DEBUG_LEVEL_VERBOSE, "Looking at node %d...\n", nodeId);
538
539         csr = csr1212_create_csr( &configrom_csr1212_ops,
540                                   5 * sizeof(fb_quadlet_t),   // XXX Why 5 ?!?
541                                   &csr_info );
542
543         if (!csr || csr1212_parse_csr( csr ) != CSR1212_SUCCESS) {
544             debugWarning( "Failed to get/parse CSR\n");
545             if (csr) {
546                 csr1212_destroy_csr(csr);
547                 csr = NULL;
548             }
549             continue;
550         }
551
552         octlet_t guid =
553             ((u_int64_t)CSR1212_BE32_TO_CPU(csr->bus_info_data[3]) << 32)
554             | CSR1212_BE32_TO_CPU(csr->bus_info_data[4]);
555
556         debugOutput( DEBUG_LEVEL_VERBOSE,
557                         " Node has GUID 0x%016" PRIX64 "\n",
558                         guid);
559
560         if ( guid == getGuid() ) {
561             debugOutput( DEBUG_LEVEL_VERBOSE, "GUID matches ours\n");
562             if ( nodeId != getNodeId() ) {
563                 debugOutput( DEBUG_LEVEL_VERBOSE,
564                              "Device with GUID 0x%016" PRIX64 " changed node id "
565                              "from %d to %d\n",
566                              getGuid(),
567                              getNodeId(),
568                              nodeId );
569                 m_nodeId = nodeId;
570             } else {
571                 debugOutput( DEBUG_LEVEL_VERBOSE,
572                              "Device with GUID 0x%016" PRIX64 " kept node id %d\n",
573                              getGuid(),
574                              getNodeId());
575             }
576             if (csr) {
577                 csr1212_destroy_csr(csr);
578                 csr = NULL;
579             }
580             return true;
581         }
582     }
583
584     if (csr) {
585         csr1212_destroy_csr(csr);
586     }
587
588     debugOutput( DEBUG_LEVEL_VERBOSE,
589                  "Device with GUID 0x%016" PRIX64 " could not be found on "
590                  "the bus anymore (removed?)\n",
591                  getGuid() );
592     m_nodeId = INVALID_NODE_ID;
593     return false;
594 }
595
596 void
597 ConfigRom::printConfigRomDebug() const
598 {
599     using namespace std;
600     debugOutput(DEBUG_LEVEL_NORMAL, "Config ROM\n" );
601     debugOutput(DEBUG_LEVEL_NORMAL, "\tCurrent Node Id:\t%d\n",       getNodeId() );
602     debugOutput(DEBUG_LEVEL_NORMAL, "\tGUID:\t\t\t0x%016" PRIX64 "\n",       getGuid());
603     debugOutput(DEBUG_LEVEL_NORMAL, "\tVendor Name:\t\t%s\n",         getVendorName().c_str() );
604     debugOutput(DEBUG_LEVEL_NORMAL, "\tModel Name:\t\t%s\n",          getModelName().c_str() );
605     debugOutput(DEBUG_LEVEL_NORMAL, "\tNode Vendor ID:\t\t0x%06x\n",  getNodeVendorId() );
606     debugOutput(DEBUG_LEVEL_NORMAL, "\tModel Id:\t\t0x%08x\n",        getModelId() );
607     debugOutput(DEBUG_LEVEL_NORMAL, "\tUnit Specifier ID:\t0x%06x\n", getUnitSpecifierId() );
608     debugOutput(DEBUG_LEVEL_NORMAL, "\tUnit version:\t\t0x%08x\n",    getUnitVersion() );
609     debugOutput(DEBUG_LEVEL_NORMAL, "\tISO resource manager:\t%d\n",  isIsoResourseManager() );
610     debugOutput(DEBUG_LEVEL_NORMAL, "\tCycle master capable:\t%d\n",  isSupportsIsoOperations() );
611     debugOutput(DEBUG_LEVEL_NORMAL, "\tBus manager capable:\t%d\n",   isBusManagerCapable() );
612     debugOutput(DEBUG_LEVEL_NORMAL, "\tCycle clock accuracy:\t%d\n",  getCycleClockAccurancy() );
613     debugOutput(DEBUG_LEVEL_NORMAL, "\tMax rec:\t\t%d (max asy payload: %d bytes)\n",
614             getMaxRec(), getAsyMaxPayload() );
615 }
616
617 void
618 ConfigRom::printConfigRom() const
619 {
620     using namespace std;
621     printMessage("Config ROM\n" );
622     printMessage("\tCurrent Node Id:\t%d\n",       getNodeId() );
623     printMessage("\tGUID:\t\t\t0x%016" PRIX64 "\n",       getGuid());
624     printMessage("\tVendor Name:\t\t%s\n",         getVendorName().c_str() );
625     printMessage("\tModel Name:\t\t%s\n",          getModelName().c_str() );
626     printMessage("\tNode Vendor ID:\t\t0x%06x\n",  getNodeVendorId() );
627     printMessage("\tModel Id:\t\t0x%08x\n",        getModelId() );
628     printMessage("\tUnit Specifier ID:\t0x%06x\n", getUnitSpecifierId() );
629     printMessage("\tUnit version:\t\t0x%08x\n",    getUnitVersion() );
630     printMessage("\tISO resource manager:\t%d\n",  isIsoResourseManager() );
631     printMessage("\tCycle master capable:\t%d\n",  isSupportsIsoOperations() );
632     printMessage("\tBus manager capable:\t%d\n",   isBusManagerCapable() );
633     printMessage("\tCycle clock accuracy:\t%d\n",  getCycleClockAccurancy() );
634     printMessage("\tMax rec:\t\t%d (max asy payload: %d bytes)\n", getMaxRec(), getAsyMaxPayload() );
635 }
636
637 unsigned short
638 ConfigRom::getAsyMaxPayload() const
639 {
640     // XXX use pow instead?
641     return 1 << ( m_maxRec + 1 );
642 }
643
644 bool
645 ConfigRom::serialize( std::string path, Util::IOSerialize& ser )
646 {
647     bool result;
648     result  = ser.write( path + "m_nodeId", m_nodeId );
649     result &= ser.write( path + "m_avcDevice",  m_avcDevice );
650     result &= ser.write( path + "m_guid", m_guid );
651     result &= ser.write( path + "m_vendorName", std::string( m_vendorName ) );
652     result &= ser.write( path + "m_modelName", std::string( m_modelName ) );
653     result &= ser.write( path + "m_vendorId", m_vendorId );
654     result &= ser.write( path + "m_modelId", m_modelId );
655     result &= ser.write( path + "m_unit_specifier_id", m_unit_specifier_id );
656     result &= ser.write( path + "m_unit_version",  m_unit_version );
657     result &= ser.write( path + "m_isIsoResourceManager", m_isIsoResourceManager );
658     result &= ser.write( path + "m_isCycleMasterCapable", m_isCycleMasterCapable );
659     result &= ser.write( path + "m_isSupportIsoOperations", m_isSupportIsoOperations );
660     result &= ser.write( path + "m_isBusManagerCapable", m_isBusManagerCapable );
661     result &= ser.write( path + "m_cycleClkAcc", m_cycleClkAcc );
662     result &= ser.write( path + "m_maxRec", m_maxRec );
663     result &= ser.write( path + "m_nodeVendorId", m_nodeVendorId );
664     result &= ser.write( path + "m_chipIdHi", m_chipIdHi );
665     result &= ser.write( path + "m_chipIdLow", m_chipIdLow );
666     return result;
667 }
668
669 ConfigRom*
670 ConfigRom::deserialize( std::string path, Util::IODeserialize& deser, Ieee1394Service& ieee1394Service )
671 {
672     ConfigRom* pConfigRom = new ConfigRom;
673     if ( !pConfigRom ) {
674         return 0;
675     }
676
677     pConfigRom->m_1394Service = ieee1394Service;
678
679     bool result;
680     result  = deser.read( path + "m_nodeId", pConfigRom->m_nodeId );
681     result &= deser.read( path + "m_avcDevice", pConfigRom->m_avcDevice );
682     result &= deser.read( path + "m_guid", pConfigRom->m_guid );
683     result &= deser.read( path + "m_vendorName", pConfigRom->m_vendorName );
684     result &= deser.read( path + "m_modelName", pConfigRom->m_modelName );
685     result &= deser.read( path + "m_vendorId", pConfigRom->m_vendorId );
686     result &= deser.read( path + "m_modelId", pConfigRom->m_modelId );
687     result &= deser.read( path + "m_unit_specifier_id", pConfigRom->m_unit_specifier_id );
688     result &= deser.read( path + "m_unit_version", pConfigRom->m_unit_version );
689     result &= deser.read( path + "m_isIsoResourceManager", pConfigRom->m_isIsoResourceManager );
690     result &= deser.read( path + "m_isCycleMasterCapable", pConfigRom->m_isCycleMasterCapable );
691     result &= deser.read( path + "m_isSupportIsoOperations", pConfigRom->m_isSupportIsoOperations );
692     result &= deser.read( path + "m_isBusManagerCapable", pConfigRom->m_isBusManagerCapable );
693     result &= deser.read( path + "m_cycleClkAcc", pConfigRom->m_cycleClkAcc );
694     result &= deser.read( path + "m_maxRec", pConfigRom->m_maxRec );
695     result &= deser.read( path + "m_nodeVendorId", pConfigRom->m_nodeVendorId );
696     result &= deser.read( path + "m_chipIdHi", pConfigRom->m_chipIdHi );
697     result &= deser.read( path + "m_chipIdLow", pConfigRom->m_chipIdLow );
698
699     if ( !result ) {
700         delete pConfigRom;
701         return 0;
702     }
703
704     return pConfigRom;
705 }
706
707 bool
708 ConfigRom::setNodeId( fb_nodeid_t nodeId )
709 {
710     m_nodeId = nodeId;
711     return true;
712 }
Note: See TracBrowser for help on using the browser.