Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / system / tracemod / tm_impl.cc
CommitLineData
920dae64
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: tm_impl.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/*
22 * Copyright (C) 1991, 2001 Sun Microsystems, Inc.
23 * All rights reserved.
24 */
25#pragma ident "@(#)1.4 01/11/06 tm_impl.cc"
26
27/*
28 * Copyright (c) 1989, Sun Microsystems, Inc. All Rights Reserved. Sun
29 * considers its source code as an unpublished, proprietary trade secret, and
30 * it is available only under strict license provisions. This copyright
31 * notice is placed here only to protect Sun in the event the source is
32 * deemed a published work. Disassembly, decompilation, or other means of
33 * reducing the object code to human readable form is prohibited by the
34 * license agreement under which this code is provided to the user or company
35 * in possession of this copy
36 *
37 * RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
38 * Government is subject to restrictions as set forth in subparagraph
39 * (c) (1) (ii) of the Rights in Technical Data and Computer Software clause
40 * at DFARS 52.227-7013 and in similar clauses in the FAR and NASA FAR
41 * Supplement
42 */
43
44//
45// tm_impl.c
46// ---------
47// This module contains an implementation of TRACING in blaze v4
48//
49
50#include <sys/types.h>
51#include <assert.h>
52#include <stdio.h>
53#include <stdlib.h>
54#include <string.h>
55#include <synch.h>
56#include <dlfcn.h>
57
58#include "types.h"
59#include "blaze_globals.h"
60#include "ui.h"
61
62//#include "cpu.h"
63#include "cpu_interface.h"
64
65#include "dr.h"
66#include "schizo_module.h"
67#include "system.h"
68
69
70typedef void* TM_OPAQUE_DATA;
71#include "tracemod.h"
72
73#include "tm_impl.h"
74#include <set>
75
76//////////////////////////////////////////////////////////
77
78//////////////////////////////////////////////////////////
79
80
81
82void TM_time_interval (uint64_t time)
83{
84 LdmNode *pnode;
85 for (pnode=head_ldm; pnode != NULL; pnode=pnode->Next()) {
86 Ldm * pldm = pnode->GetData();
87 if (pldm->ti_action) {
88 pldm->ti_action ((TM_OPAQUE_DATA)pldm->client_data, time);
89 }
90 }
91 tm_time_target += tm_time_interval;
92}
93
94
95void TM_context (cpuT *sp)
96{
97
98}
99
100
101//////////////////////////////////////////////////////////////////
102//////////////////////////////////////////////////////////////////
103
104typedef struct {
105 void *obj;
106 mmi_access access;
107 uint64_t base, size, end;
108} PhysioMap;
109
110typedef List1Node<PhysioMap> PhysioMapNode;
111PhysioMapNode* headPhysioMap;
112
113static std::set<uint64_t> unmapped_addresses;
114
115int SYSTEM_physio_access(uint32_t cpu_id, void* /* obj */, uint64_t paddr, bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask)
116{PhysioMap* pmap;
117 uint64_t end = paddr+size;
118 for (PhysioMapNode *pnode = headPhysioMap; pnode; pnode = pnode->Next()) {
119 pmap = pnode->GetData();
120 if (pmap->base <= paddr && end <= pmap->end)
121 return pmap->access(cpu_id, pmap->obj, paddr, (mmi_bool_t)wr, size, buf, bytemask);
122 }
123
124 if (unmapped_addresses.find(paddr) == unmapped_addresses.end())
125 {
126 ui->warning("unmapped SYSTEM_physio_access: [%llx %llx], %s \n", paddr, end,wr?"write":"read" );
127 unmapped_addresses.insert(paddr);
128 }
129
130 if(!wr)
131 *buf = 0;
132 return 0;
133}
134
135int mmi_map_physio(uint64_t base, uint64_t size, void* obj, mmi_access access)
136{
137 PhysioMapNode *pnode = PhysioMapNode::CreateInstance("physio map");
138 PhysioMap *ph;
139
140 if (pnode == NULL) {
141 ui->error("%s(L%d): Unable to create physio map\n", __FILE__, __LINE__);
142 } else {
143 ph = pnode->GetData ();
144 ph->base = base;
145 ph->size = size;
146 ph->end = base + size;
147 ph->obj = obj;
148 ph->access = access;
149 PhysioMapNode::AddHead (&headPhysioMap, pnode);
150 }
151 return pnode ? 0 : -1;
152}
153
154void mmi_unmap_physio(uint64_t base, uint64_t size, void* obj)
155{
156 PhysioMapNode *pnode, *prev;
157 for (prev = NULL, pnode = headPhysioMap; pnode; pnode = pnode->Next()) {
158 PhysioMap* pmap = pnode->GetData();
159 if (pmap->obj == obj && pmap->base == base && pmap->size == size) {
160 PhysioMapNode::DeleteNode(&headPhysioMap, prev);
161 break;
162 }
163 prev = pnode;
164 }
165}
166