* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: buffer.H
* 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 ============================================
// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: buffer.H
// 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 ============================================
RstzipBuffer(int bufsize) {
rstbuf = (rstf_unionT*) malloc((bufsize + PADDING) * sizeof(rstf_unionT));
int fillBuffer(rstf_unionT* buf, int bufrecs) {
if (nrecs + bufrecs < buffersize + PADDING) {
memcpy(&rstbuf[nrecs], buf, bufrecs * sizeof(rstf_unionT));
fprintf(stderr, "Error: in FillRstBuffer::fillBuffer(): nrecs=%d, bufrecs=%d, max buffersize is %d\n",
nrecs, bufrecs, buffersize + PADDING);
int getLastCpuRecIndex() {
for (i = nrecs - 1; i >= 0; i--) {
if (rstbuf[i].proto.rtype == CPU_T) {
int shiftBuffer(int index) {
fprintf(stderr, "Error: in RstzipBuffer::shiftBuffer() index (%d) > nrecs (%d)\n", index, nrecs);
// Only do this if we have something to move.
// index = 0 when we flush this buffer; index = -1 when we're done decompressing.
memmove(&rstbuf[0], &rstbuf[index], nrecs * sizeof(rstf_unionT));