Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / dev / rom / src / SS_Rom.cc
CommitLineData
920dae64
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: SS_Rom.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#include <sys/socket.h>
23#include <unistd.h>
24#include "SS_Rom.h"
25
26SS_Rom::SS_Rom( SS_AddressMap* map, SS_Paddr lo, SS_Paddr hi )/*{{{*/
27 :
28 base(lo),
29 ram(&SS_Memory::memory)
30{
31 map->add(lo,hi,this,SS_AddressMap::REL,SS_Rom::access);
32}
33/*}}}*/
34SS_Rom::~SS_Rom()/*{{{*/
35{
36}
37/*}}}*/
38
39void SS_Rom::access( void* obj, uint_t sid, SS_Access::Type type, SS_Paddr pa, uint_t size, uint64_t* data )/*{{{*/
40{
41 SS_Rom* self = (SS_Rom*)obj;
42
43 pa += self->base;
44
45 if (type == SS_Access::LOAD)
46 {
47#if defined(MEMORY_MSYNC)
48 self->ram->msync_info(sid,pa);
49#elif defined(MEMORY_EXTERNAL)
50 self->ram->set_strand_id(sid);
51#endif
52 switch (size)
53 {
54 case 1: *data = self->ram->ld8u(pa); break;
55 case 2: *data = self->ram->ld16u(pa); break;
56 case 4: *data = self->ram->ld32u(pa); break;
57 case 8: *data = self->ram->ld64(pa); break;
58 case 16: self->ram->ld128(pa,data); break;
59 case 64: self->ram->ld512(pa,data); break;
60 default: assert(0);
61 }
62 }
63 else
64 {
65 fprintf(stderr,"ROM: Non load access detected\n");
66 }
67}
68/*}}}*/
69
70
71
72
73
74