Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: dev_registry.cc | |
4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
6 | // | |
7 | // The above named program is free software; you can redistribute it and/or | |
8 | // modify it under the terms of the GNU General Public | |
9 | // License version 2 as published by the Free Software Foundation. | |
10 | // | |
11 | // The above named program is distributed in the hope that it will be | |
12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | // General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public | |
17 | // License along with this work; if not, write to the Free Software | |
18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | // | |
20 | // ========== Copyright Header End ============================================ | |
21 | #include "module.h" | |
22 | ||
23 | devRegistry::devRegistry(){ | |
24 | handle = devid_first; | |
25 | assert(pthread_mutex_init(&handleMutex,NULL)==0); | |
26 | } | |
27 | devRegistry::~devRegistry(){} | |
28 | ||
29 | // get the name of the device with id 'handle' | |
30 | const char * devRegistry::getName (SAM_DeviceId handle) { | |
31 | ri = r.find(handle); | |
32 | Module * m = (ri != r.end()) ? ri->second:0; | |
33 | if(m) return m->getName(); | |
34 | return "unknown device"; | |
35 | } | |
36 | // dump the device name<->trace handle mapping into file FP. | |
37 | // FP can be stderr. Can be used by UI or trace dump functions. | |
38 | void devRegistry::dump(FILE * fp){ | |
39 | fprintf(fp," ID DEVICE INSTANCE\n"); | |
40 | for( ri = r.begin(); ri != r.end(); ri++) | |
41 | fprintf(fp,"0x%llx %s\n",ri->first,ri->second->getName()); | |
42 | } |