// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: l2csr.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 ============================================
* handle L2CSR (I/O space) T1 addresses for blaze/SAM
* Copyright (c) 2004-2005 by Sun Microsystems, Inc.
#include <sys/syscall.h> // get exec number
#include <sys/types.h> // uid_t
#include <unistd.h> // getuid()
void _init (); // predeclare these to have C naming
void _fini (); // predeclare these to have C naming
int l2csr_access(uint32_t cpuid
, void* obj
, uint64_t paddr
, mmi_bool_t wr
, uint32_t size
, uint64_t* buf
, uint8_t bytemask
);
int l2csr_ld_operation (void *cd
, uint64_t paddr
, uint64_t *buf
, int sz
, uint32_t cpuid
);
int l2csr_st_operation (void *cd
, uint64_t paddr
, uint64_t *buf
, int sz
, uint32_t cpuid
);
extern "C" void l2csr_create_instance (const char *modname
, const char *instance_name
);
if (! mmi_register_instance_creator("l2csr", l2csr_create_instance
) ) {
fprintf(stderr
, "Cannot register instance creator for l2csr\n");
void l2csr_create_instance (const char *modname
, const char *instance_name
)
sam_l2csr_s
* l2csr_obj
= new sam_l2csr_s
;
mmi_instance_t instance
= mmi_register_instance(modname
, instance_name
, (void *) &l2csr_obj
, "l2csr dummy device");
l2csr_obj
->startpa
= 0x0;
// expected syntax: sysconf l2csr l2csr1 startpa=<0xblah> endpa=<0xblah>
int argc
= mmi_argc(instance
);
char * arg
= strdup(mmi_argv(instance
, i
));
char * lv
= strtok_r(arg
, "=", &marker
);
if (strcmp(lv
, "startpa") == 0) {
char * rv
= strtok_r(NULL
, "=", &marker
);
l2csr_obj
->startpa
= strtoull(rv
, NULL
, 0);
perror("l2csr: error parsing startpa");
} else if (strcmp(lv
, "endpa") == 0) {
char * rv
= strtok_r(NULL
, "=", &marker
);
l2csr_obj
->endpa
= strtoull(rv
, NULL
, 0);
perror("l2csr: error parsing startpa");
l2csr_obj
->sz
= l2csr_obj
->endpa
- l2csr_obj
->startpa
+ 1;
if (mmi_map_physio(l2csr_obj
->startpa
, l2csr_obj
->sz
, (void *) l2csr_obj
, l2csr_access
)) {
fprintf(stderr
, " sam l2csr (%s): unable to register IO interceptor @PA=0x%llx size=0x%llx\n", instance_name
, l2csr_obj
->startpa
, l2csr_obj
->sz
);
int l2csr_access(uint32_t cpuid
, void* obj
, uint64_t paddr
, mmi_bool_t wr
, uint32_t size
, uint64_t* buf
, uint8_t bytemask
)
return l2csr_st_operation(obj
, paddr
, buf
, size
, cpuid
);
return l2csr_ld_operation(obj
, paddr
, buf
, size
, cpuid
);
int l2csr_ld_operation (void *obj
, uint64_t paddr
, uint64_t *buf
, int size
, uint32_t cpuid
)
sam_l2csr_s
* l2csr_obj
= (sam_l2csr_s
*) obj
;
uint64_t offset
= paddr
- l2csr_obj
->startpa
;
// fprintf(stderr, "SAM l2csr: ld_operation pa 0x%llx size %d cpu %d\n", paddr, size, cpuid);
// fprintf(stderr, "SAM l2csr: ld from invalid paddr 0x%llx\n", paddr);
} // int l2csr_ld_operation (void *cd, uint64_t paddr, uint64_t *buf, int size, uint32_t cpuid)
int l2csr_st_operation (void *obj
, uint64_t paddr
, uint64_t *buf
, int size
, uint32_t cpuid
)
// fprintf(stderr, "SAM l2csr: st_operation pa 0x%llx size %d cpu %d\n", paddr, size, cpuid);
sam_l2csr_s
* l2csr_obj
= (sam_l2csr_s
*) obj
;
uint64_t offset
= paddr
- l2csr_obj
->startpa
;
// fprintf(stderr, "SAM l2csr: st to invalid paddr 0x%llx\n", paddr);
} // int l2csr_st_operation (void *cd, uint64_t paddr, uint64_t *buf, int size, uint32_t cpuid)
/////////////////////////////////////////////////
/////////////////////////////////////////////////