// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: SS_AsiSpace.cc
// Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
// The above named program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License version 2 as published by the Free Software Foundation.
// The above named program is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// You should have received a copy of the GNU General Public
// License along with this work; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
// ========== Copyright Header End ============================================
#include "SS_AsiCtrReg.h"
SS_AsiSpace::SS_AsiSpace()/*{{{*/
fail(0,mask
,0,0,no_rd
,no_wr
,no_rd
,no_wr
),
SS_AsiSpace::~SS_AsiSpace()/*{{{*/
SS_AsiSpace::Error
SS_AsiSpace::no_rd( SS_Node
*, void*, SS_Strand
*, SS_Vaddr
, uint64_t* )/*{{{*/
return SS_AsiSpace::NO_READ
;
SS_AsiSpace::Error
SS_AsiSpace::no_wr( SS_Node
*, void*, SS_Strand
*, SS_Vaddr
, uint64_t )/*{{{*/
return SS_AsiSpace::NO_WRITE
;
SS_AsiSpace::Error
SS_AsiSpace::ld64( SS_Strand
* s
, SS_Vaddr addr
, uint64_t* data
)/*{{{*/
return (r
->ld
)(r
->obj
,r
->reg
,s
,addr
,data
);
SS_AsiSpace::Error
SS_AsiSpace::st64( SS_Strand
* s
, SS_Vaddr addr
, uint64_t data
)/*{{{*/
return (r
->st
)(r
->obj
,r
->reg
,s
,addr
,data
);
SS_AsiSpace::Error
SS_AsiSpace::rd64( SS_Strand
* s
, SS_Vaddr addr
, uint64_t* data
)/*{{{*/
return (r
->rd
)(r
->obj
,r
->reg
,s
,addr
,data
);
SS_AsiSpace::Error
SS_AsiSpace::wr64( SS_Strand
* s
, SS_Vaddr addr
, uint64_t data
)/*{{{*/
return (r
->wr
)(r
->obj
,r
->reg
,s
,addr
,data
);
void SS_AsiSpace::merge( SS_AsiSpace
& asi_space
)/*{{{*/
// If there is ranges defined in this space then we need to
// do some merging. If this is the first merge then we assume
// that the ranges associated with this ASI are defined at one
// level (SS_Node) only. If so then we can do a cheap copy.
// Else we need to do a quick copy and poper insert the rest
if (size
== 0) // do cheap copy first
if (table_copy
) // real copy first, then insert proper
Range
** old_table
= table
;
table
= (Range
**)malloc(sizeof(Range
*) * alloc
);
for (uint_t i
=0; i
< size
; i
++)
for (uint_t i
=0; i
< asi_space
.size
; i
++)
void SS_AsiSpace::add( SS_Vaddr va
, SS_Node
* obj
, SS_AsiCtrReg
& reg
)/*{{{*/
add(va
,va
,obj
,®
,SS_AsiCtrReg::ld64
,SS_AsiCtrReg::st64
,SS_AsiCtrReg::rd64
,SS_AsiCtrReg::wr64
);
void SS_AsiSpace::add( SS_Vaddr va
, SS_Node
* obj
, SS_SharedAsiCtrReg
& reg
)/*{{{*/
add(va
,va
,obj
,®
,SS_SharedAsiCtrReg::ld64
,SS_SharedAsiCtrReg::st64
,
SS_SharedAsiCtrReg::rd64
,SS_SharedAsiCtrReg::wr64
);
void SS_AsiSpace::add( SS_Vaddr va
, SS_Node
* obj
, void* reg
, Read ld
, Write st
, Read rd
, Write wr
)/*{{{*/
add(va
,va
,obj
,reg
,ld
,st
,rd
,wr
);
void SS_AsiSpace::add( SS_Vaddr lo
, SS_Vaddr hi
, SS_Node
* obj
, void* reg
, Read ld
, Write st
, Read rd
, Write wr
)/*{{{*/
table
= (Range
**)realloc(table
,sizeof(Range
*) * alloc
);
if (free_range_index
== ALLOC
)
// Allocate a new block of Range object. Avoid the C++ constructor
// call as each range will be initialised below anyways.
Block
* new_block
= (Block
*)malloc(sizeof(Block
));
Range
* new_range
= &block
->page
[free_range_index
++];
new(new_range
) Range(lo
,hi
,obj
,reg
,ld
,st
,rd
,wr
);
void SS_AsiSpace::add( Range
* new_range
)/*{{{*/
table
= (Range
**)realloc(table
,sizeof(Range
*) * alloc
);
SS_Vaddr hi
= new_range
->hi
;
SS_Vaddr lo
= new_range
->lo
;
// Check if we can just append the new range first.
// This will save a lot of time binary searching and
// moving part of the table around.
if ((size
== 0) || (table
[size
- 1]->hi
< new_range
->lo
))
((hi
< r
->lo
) ? h
: l
) = m
;
for (uint_t i
=size
; i
> m
; i
--)
for (uint_t i
=size
; i
> (m
+ 1); i
--)
fprintf(stderr
,"SS_AsiSpace: asi 0x%x add with lo=0x%llx and hi=0x%llx overlaps with lo=0x%llx and hi=0x%llx\n",asi(),lo
,hi
,r
->lo
,r
->hi
);