// ========== Copyright Header Begin ==========================================
// OpenSPARC T2 Processor File: tm_mmi.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 ============================================
* Copyright (C) 1991, 2001 Sun Microsystems, Inc.
#pragma ident "@(#)1.4 01/11/06 tm_mmi.cc"
* Copyright (c) 1989, Sun Microsystems, Inc. All Rights Reserved. Sun
* considers its source code as an unpublished, proprietary trade secret, and
* it is available only under strict license provisions. This copyright
* notice is placed here only to protect Sun in the event the source is
* deemed a published work. Disassembly, decompilation, or other means of
* reducing the object code to human readable form is prohibited by the
* license agreement under which this code is provided to the user or company
* in possession of this copy
* RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
* Government is subject to restrictions as set forth in subparagraph
* (c) (1) (ii) of the Rights in Technical Data and Computer Software clause
* at DFARS 52.227-7013 and in similar clauses in the FAR and NASA FAR
#include "blaze_globals.h"
#include "cpu_interface.h"
#include "vtracer_async_queue.h"
typedef void* TM_OPAQUE_DATA
;
void ldm_delete_head_spec ();
volatile bool config_is_done
;
/////////////////////////////////////////////////////////////
MmiVarNode
*pMmiVarList
= NULL
;
mmi_dr_s
* mmi_dr_list
= NULL
;
int mmi_dr_list_count
= 0;
struct property_list
*plist
= NULL
;
uint64_t fkprom_dtinbuf_pa
= 0x50;
int fkprom_dtinbuf_offset
= 0; // offset at which to write device property data
/////////////////////////////////////////////////////////////
mmi_bool_t
mmi_register_instance_creator (const char * modname
, mmi_instance_creator fn
)
// In order to register an instance creator, add the module's name
// into the module list to show it is here.
// ldm_add_spec ((char *)modname, 0); // for module dependency
tracemod_t
*tm
= TM_self_register_spec (modname
, NULL
);
pldm
= (struct ldm_t
*) tm
;
TM_set_mode (tm
, TM_EXT_IO
);
TM_set_type_ext (tm
, TM_TYPE_EXT_DEVICE
);
pldm
->create_instance
= fn
;
} // mmi_register_instance_creator
/////////////////////////////////////////////////////////////
mmi_bool_t
mmi_unregister_instance_creator (mmi_instance_t mod
)
/////////////////////////////////////////////////////////////
int mmi_register_cb_data (module_t
*mod
, void *cb_data
)
TM_register_client_data(pldm
, cb_data
);
mmi_bool_t
mmi_register_asi_cb_data (mmi_instance_t instance
, void *cb_data
)
Ldm
* pldm
= (Ldm
*)instance
;
TM_register_asi_client_data (pldm
, cb_data
);
/////////////////////////////////////////////////////////////
void* mmi_get_cb_data (module_t
*mod
)
void* mmi_get_asi_cb_data (module_t
*mod
)
return mod
->asi_client_data
;
/////////////////////////////////////////////////////////////
void* mmi_register_cb_cycle (mmi_instance_t instance
, mmi_event_cycle handler
, uint64_t repeat
)
void *cb_data
= TM_get_client_data(instance
);
return TM_register_time_intf ((Ldm
*)instance
, cb_data
, handler
, repeat
);
/////////////////////////////////////////////////////////////
void mmi_unregister_cb_cycle (mmi_instance_t mod
, void * intf
)
TM_unregister_time_intf ((Ldm
*)mod
, intf
);
/////////////////////////////////////////////////////////////
int mmi_disable_cb_cycle (void * intf
)
TM_disable_time_intf (intf
);
/////////////////////////////////////////////////////////////
int mmi_enable_cb_cycle (void * intf
, blaze_cycle_t repeat
)
TM_enable_time_intf (intf
, repeat
);
/////////////////////////////////////////////////////////////
/* MMI UI command interface */
void mmi_register_module_cmd(mmi_module_t mod
, const char * helpstring
, mmi_module_cmd_fn fn
)
char * modname
= strdup(pldm
->name
);
TM_ui_register_2(pldm
, modname
, helpstring
, helpstring
, fn
);
} // void mmi_register_module_cmd(mmi_module_t mod, const char * helpstring, mmi_module_cmd_fn fn)
void mmi_register_instance_cmd(mmi_instance_t instance
, const char * helpstring
, mmi_instance_cmd_fn fn
)
Ldm
* pldm
= (Ldm
*) instance
;
char * instancename
= strdup(pldm
->name
);
TM_ui_register_2(pldm
, instancename
, helpstring
, helpstring
, fn
);
} // void mmi_register_instance_cmd(mmi_instance_t instance, const char * helpstring, mmi_instance_cmd_fn fn)
/////////////////////////////////////////////////////////////
extern bool_t
add_asi_module (tracemod_t
* mod
, uint32_t asi
, mmi_ld_asi_action ld_handler
,
mmi_st_asi_action st_handler
);
/////////////////////////////////////////////////////////////
mmi_register_asi_action (mmi_instance_t instance
, uint32_t asi
,
mmi_ld_asi_action ld_handler
, mmi_st_asi_action st_handler
)
AsiHandlerNode
*pnode
= AsiHandlerNode::CreateInstance("ASI handler list");
struct ldm_t
*pldm
= (struct ldm_t
*)instance
;
ui
->error("MMI: Unable to create ASI interceptor for ASI = 0x%x\n", asi
);
ph
->mmi_ld_action
= ld_handler
;
ph
->mmi_st_action
= st_handler
;
if (add_asi_module(pldm
, asi
, ld_handler
, st_handler
)) {
AsiHandlerNode::AddHead ((AsiHandlerNode
**)&pldm
->headAsi
, pnode
);
ui
->error("MMI: unable to register ASI interceptor\n");
/////////////////////////////////////////////////////////////
int mmi_argc(mmi_instance_t instance
)
return ((module_t
*)instance
)->argc
;
char *mmi_argv(mmi_instance_t instance
, int index
)
module_t
* mod
= (module_t
*) instance
;
if (index
< 0 || mod
->argc
<= index
)
/////////////////////////////////////////////////////////////
void set_module_args(Ldm
*pldm
, int argc
, char **argv
)
for (i
= 0; i
< pldm
->argc
; i
++)
pldm
->argv
= (char**) calloc (argc
, sizeof(char*));
for (i
= 0; i
< argc
; i
++)
pldm
->argv
[i
] = (char*)strdup(argv
[i
]);
/////////////////////////////////////////////////////////////
static Ldm
*load_module(char *modname
, char * pathp
, char *soname
)
pldm
= ldm_add_spec (modname
, soname
);
pldm
->so_handle
= mod_dlopen (pathp
, soname
, RTLD_LAZY
|RTLD_GLOBAL
|RTLD_PARENT
);
if (pldm
->so_handle
== NULL
) {
/////////////////////////////////////////////////////////////
int ldm_cmd_action(int argc
, char **argv
)
// ldm <modname> <instance> [<XX.so>]
pldm
= load_module(argv
[1], NULL
, argv
[3]);
set_module_args(pldm
, argc
, argv
);
if (pldm
->create_instance
) {
pldm
->create_instance (argv
[1], argv
[2]);
ui
->error("LDM: MMI device module - instance creator not found !! \n");
// ldm <modname> <instance>
Ldm
*pmod
= TM_find_mod_spec (argv
[1]);
ui
->error("LDM: MMI device module <%s> not found \n", argv
[1]);
if (pmod
->create_instance
) {
pmod
->create_instance (argv
[1], argv
[2]);
ui
->error("LDM: MMI device module - instance creator not found !! \n");
/////////////////////////////////////////////////////////////
int sysconf_usage(const char *msg
)
ui
->error("sysconf: %s\n", msg
);
ui
->error("usage: sysconf [-p <modpath> ] <modname> [ <instance_name> [ args... ] ]\n");
/////////////////////////////////////////////////////////////
extern Vcpu
* init_cpu ( char *path
, int argc
, char **argv
);
int sysconf_cmd_action(int argc
, char **argv
)
char modname
[64], libname
[1024];
static char path
[512] = {"."};
/* arg to load_module, if null the searchlist */
/* with $ORIGIN in it is used, if not this explicit path is used */
// sysconf [-p <modpath> ] <modname> [ <instance_name> [ args... ] ]
return sysconf_usage("missing args");
if (strcmp (argv
[1], "-p") == 0) {
return sysconf_usage("missing args");
mod_addpath (argv
[2]); /* add to generic search path */
/* otherwise, this is a module specific path prefix, handle below */
// XXX should remove it completely
if ( (strcmp(argv
[1], "done") == 0) && (argc
== 2) ) {
// complete_initialization();
if ( strcmp ( argv
[1], "cpu" ) == 0 )
// create a new cpu instance;
// keep a pointer in a global array;
// skip first two args: "sysconf" and "cpu";
// we really do only pass pathp here,
// the fname is derived from the cpu-type attribute
Vcpu
*vcpu
= init_cpu (pathp
, argc
-2, argv
+2);
// configure cpu params in fakeprom;
VCPU_Config
&config_info
= vcpu
->config
;
memwrite64s_nl(mm1
, 0x20, config_info
.cpufreq
);
// system clock frequency
memwrite64s_nl(mm1
, 0x28, the_arch
.stick_freq
);
memwrite32u_nl(mm1
, 0x14, g_nvcpu
);
// TODO: the_arch maybe soon obsolete
the_arch
.cpu_freq
= config_info
.cpufreq
;
// read stickfreq from conf suplied value
config_info
.stickfreq
= the_arch
.stick_freq
;
the_arch
.numcpus
= g_nvcpu
;
for (int i
= 1; i
< argc
; i
++) {
if (strcmp(argv
[i
], "-p") == 0) {
return sysconf_usage("missing -p <modpath>");
strlcpy(path
, argv
[i
], sizeof path
);
pathp
= &path
[0]; /* override the searchlist */
else if (argv
[i
][0] == '-') {
return sysconf_usage(argv
[i
]);
strlcpy(modname
, argv
[i
], sizeof modname
);
sprintf (libname
, "%s.so", modname
);
pldm
= TM_find_mod_spec(modname
);
pldm
= load_module (modname
, pathp
, libname
);
return sysconf_usage("can't load the module");
if (TM_find_mod_spec(argv
[i
]))
return sysconf_usage("module instance already exists");
mmi_instance_t ins
= mmi_register_instance (modname
, argv
[i
], NULL
, argv
[i
]);
return sysconf_usage("failed to create module instance");
set_module_args((module_t
*)ins
, argc
-(i
+1), &argv
[i
+1]);
if (pldm
->create_instance
) {
pldm
->create_instance (modname
, argv
[i
]);
/////////////////////////////////////////////////////////////
void modinfo_list_modules()
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
= pnode
->Next()) {
pldm
= pnode
->GetData ();
ui
->output("<%s>\n", pldm
->name
);
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
=pnode
->Next()) {
pldm
= pnode
->GetData ();
ui
->output("<%s> parent=<%s>\n", pldm
->name
, pldm
->parent
->name
);
void modinfo_print_info(char *name
)
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
=pnode
->Next()) {
pldm
= pnode
->GetData ();
if (!strcmp(pldm
->name
, name
)) {
pldm
->modinfo_cb(pldm
->client_data
);
ui
->error("%s is not loaded\n", name
);
int modinfo_cmd_action(int argc
, char **argv
)
/* modinfo_list_modules();
else if (!strcmp(argv[1], "all") && argc == 2) { */
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
=pnode
->Next()) {
pldm
= pnode
->GetData ();
ui
->output("%s: %s\n", pldm
->name
, pldm
->help
);
pldm
->modinfo_cb(pldm
->client_data
);
for (int i
= 1; i
< argc
; i
++)
modinfo_print_info(argv
[i
]);
/////////////////////////////////////////////////////////////
int mmi_cmd_action (void*, int argc
, char **argv
)
if (SYSTEM_is_running ()) {
ui
->error("mmi_cmd_action(%s) called while in run state!!!\n", argv
[0]);
if (strcmp (argv
[0], "uldm") == NULL
) {
ui
->error("uldm has been deprecated. config specifications are not UI commands\n");
else if (strcmp (argv
[0], "ioa") == NULL
) {
ui
->error("UI:usage : ioa <instance name> <ADDR1> <ADDR2>\n");
sscanf (argv
[2], "%lli", &baddr
);
sscanf (argv
[3], "%lli", &eaddr
);
else if (strcmp(argv
[0], "ldm") == NULL
) {
return ldm_cmd_action(argc
, argv
);
else if (!strcmp(argv
[0], "cfg") || !strcmp(argv
[0], "sysconf")) {
return sysconf_cmd_action(argc
, argv
);
else if (!strcmp(argv
[0], "modinfo")) {
return modinfo_cmd_action(argc
, argv
);
/////////////////////////////////////////////////////////////
mmi_instance_t
mmi_register_instance (const char * modname
, const char *instance_name
, void * instance_data
, const char * help
)
// parent module must exist
Ldm
*pmod
= TM_find_mod_spec ((char*)modname
);
ui
->error("MMI: module <%s> not found \n", modname
);
// create instance, unless already done
Ldm
*pseudo_mod
= TM_find_mod_spec_instance(pmod
, (char*)instance_name
);
pseudo_mod
->help
= strdup(help
);
pseudo_mod
= TM_self_pseudomod_spec (pmod
, (char*)instance_name
, help
, NULL
);
TM_set_mode (pseudo_mod
, TM_EXT_IO
);
TM_set_type_ext (pseudo_mod
, TM_TYPE_EXT_DEVICE
);
mmi_register_cb_data(pseudo_mod
, instance_data
);
return (mmi_instance_t
) pseudo_mod
;
} // mmi_register_instance()
void * mmi_get_instance_data(mmi_instance_t instance
)
return mmi_get_cb_data((module_t
*) instance
);
/////////////////////////////////////////////////////////////
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
=pnode
->Next()) {
pldm
= pnode
->GetData ();
(pldm
->config_cb
)(pldm
->client_data
, pldm
, pldm
->name
, MMI_CONFIG_INIT_DONE
);
// register the atexit function
atexit(TM_run_atexit_cb
);
/////////////////////////////////////////////////////////////
// call the config_cb callback of each registered module with
// the event MMI_CONFIG_DELETE_MODULE. The modules checks to see
// if the deleted module is itself, in which case it calls delete
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
=pnode
->Next()) {
pldm
= pnode
->GetData ();
(pldm
->config_cb
)(pldm
->client_data
, pldm
, pldm
->name
, MMI_CONFIG_DELETE_MODULE
);
/////////////////////////////////////////////////////////////
void TM_run_config_cb (tracemod_t
*mod
, int ev
)
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
=pnode
->Next()) {
pldm
= pnode
->GetData ();
if (pldm
->config_cb
&& pldm
!= mod
)
(pldm
->config_cb
)(pldm
->client_data
, mod
, mod
->name
, (mmi_config_t
)ev
);
// run this mod last, in case it is going away
(mod
->config_cb
)(mod
->client_data
, mod
, mod
->name
, (mmi_config_t
)ev
);
/////////////////////////////////////////////////////////////
int mmi_unregister_module (module_t
*mod
)
// clean out timer callbacks
TM_unregister_time_intf(pldm
, NULL
);
if (pldm
->so_handle
) { // delete instances first
while ((instance
= TM_find_mod_spec_instance(pldm
, NULL
)) != NULL
)
mmi_unregister_module(instance
);
TM_run_config_cb (mod
, MMI_CONFIG_DELETE_MODULE
);
/////////////////////////////////////////////////////////////
module_t
*mmi_get_instance_pointer (const char *modname
, const char *instance_name
)
Ldm
* pldm
= TM_find_mod_spec ((char*)modname
);
if (instance_name
== NULL
) {
pldm
= TM_find_mod_spec_instance (pldm
, (char*)instance_name
);
/////////////////////////////////////////////////////////////
module_t
*mmi_get_module (const char *modname
)
char * s
= strdup(modname
);
module_t
* module
= TM_find_mod_spec(s
);
mmi_instance_t
mmi_get_instance(const char * instancename
)
char * s
= strdup(instancename
);
mmi_instance_t instance
= TM_find_mod_spec(s
);
/////////////////////////////////////////////////////////////
mmi_bool_t
mmi_register_interface_cb (mmi_instance_t instance
, mmi_interface_cb fn
)
module_t
* mod
= (module_t
*) instance
;
/////////////////////////////////////////////////////////////
mmi_bool_t
mmi_register_modinfo_cb (mmi_instance_t instance
, mmi_modinfo_cb fn
)
module_t
* mod
= (module_t
*) instance
;
/////////////////////////////////////////////////////////////
mmi_register_config_cb (mmi_instance_t instance
, mmi_config_cb fn
)
module_t
*mod
= (module_t
*) instance
;
// report the modules that exist
for (pnode
=head_spec_ldm
; pnode
!=NULL
; pnode
=pnode
->Next()) {
pldm
= pnode
->GetData ();
fn(mod
->client_data
, pldm
, pldm
->name
, MMI_CONFIG_NEW_MODULE
);
// report this module to the others that exist
TM_run_config_cb(mod
, MMI_CONFIG_NEW_MODULE
);
/////////////////////////////////////////////////////////////
mmi_get_interface (mmi_instance_t instance
, const char *name
)
module_t
*mod
= (module_t
*) instance
;
return mod
->interface_cb(mod
->client_data
, name
);
if (mod
->parent
&& mod
->parent
->interface_cb
)
return mod
->parent
->interface_cb(mod
->client_data
, name
);
/////////////////////////////////////////////////////////////
void mmi_memread(uint64_t paddr
, uint8_t * data
, uint64_t size
,SAM_DeviceId sam_id
)
assert((size
>>32) == 0); // FIXME: need to fix this in Memory::block_read(). 2007.10.23
mm1
->block_read(paddr
,data
,(int)size
);
TRACE_DMA(/*is_write?*/ 0, size
, paddr
, sam_id
);
} // void mmi_memread(uint64_t paddr, uint8_t * data, uint64_t size, SAM_DeviceId sam_id)
/////////////////////////////////////////////////////////////
void mmi_memwrite(uint64_t paddr
, const uint8_t * data
, uint64_t size
,SAM_DeviceId sam_id
)
assert((size
>>32) == 0); // FIXME: need to fix this in Memory::block_write(). 2007.10.23
mm1
->block_write(paddr
,data
,(int)size
);
TRACE_DMA(/*is_write?*/ 1, size
, paddr
, sam_id
);
} // void mmi_memwrite(uint64_t paddr, const uint8_t * data, uint64_t size, SAM_DeviceId sam_id)
/////////////////////////////////////////////////////////////
void mmi_register_start_stop(mmi_start_stop_cb start_action
, mmi_start_stop_cb stop_action
, void * userdata
)
SYSTEM_ss_register((ss_action
)stop_action
, (ss_action
) start_action
, userdata
);
} // void mmi_register_start_stop(mmi_start_stop_cb start_action, mmi_start_stop_cb stop_action, void * userdata)
/////////////////////////////////////////////////////////////
bool_t
tm_mmi_dump(DR_OPAQUE drh
) {
int i
; char file_name
[PATH_MAX
];
for (i
=0; i
<mmi_dr_list_count
; i
++) {
ui
->output("Dumping <%s> ...\n", mmi_dr_list
[i
].name
);
snprintf(file_name
, PATH_MAX
, "%s/%s.dmp", DR_get_dir(), mmi_dr_list
[i
].name
);
if (! mmi_dr_list
[i
].dump_fn(mmi_dr_list
[i
].userdata
, file_name
)) {
ui
->error("dump failed\n");
/////////////////////////////////////////////////////////////
bool_t
tm_mmi_restore(DR_OPAQUE drh
) {
int i
; char file_name
[PATH_MAX
];
for (i
=0; i
<mmi_dr_list_count
; i
++) {
ui
->output("Restoring <%s> ...", mmi_dr_list
[i
].name
);
snprintf(file_name
, PATH_MAX
, "%s/%s.dmp", DR_get_rdir(drh
), mmi_dr_list
[i
].name
);
if (!mmi_dr_list
[i
].restore_fn(mmi_dr_list
[i
].userdata
, file_name
)) {
ui
->error("restore failed\n");
/////////////////////////////////////////////////////////////
mmi_bool_t
mmi_register_dump_restore(const char *name
, mmi_dump_cb dump_fn
, mmi_restore_cb restore_fn
, void *userdata
)
if (mmi_dr_list
== NULL
) {
mmi_dr_list
= new mmi_dr_s
[mmi_dr_list_sz
];
DR_register("MMI:DR", tm_mmi_dump
, tm_mmi_restore
, NULL
);
if (mmi_dr_list_count
== mmi_dr_list_sz
) {
int newsz
= 2*mmi_dr_list_sz
;
mmi_dr_s
* newlist
= new mmi_dr_s
[newsz
];
size_t nbytes
= mmi_dr_list_sz
*sizeof(mmi_dr_s
);
memcpy(newlist
, mmi_dr_list
, nbytes
);
memset(newlist
+ mmi_dr_list_sz
, 0, nbytes
);
mmi_dr_list
[mmi_dr_list_count
].userdata
= userdata
;
mmi_dr_list
[mmi_dr_list_count
].name
= strdup(name
);
mmi_dr_list
[mmi_dr_list_count
].dump_fn
= dump_fn
;
mmi_dr_list
[mmi_dr_list_count
].restore_fn
= restore_fn
;
} // mmi_bool_t mmi_register_dump_restore(void * userdata, mmi_dump_cb dump_fn, mmi_restore_cb restore_fn)
/////////////////////////////////////////////////////////////
int64_t mmi_get_time() // simulated microseconds, since boot
return SYSTEM_get_time(TW_CURRENT
);
// event-queue based internal synchonization
mmi_bool_t
mmi_register_event (int64_t when
,
mmi_event_cb event_fn
, void * userdata1
, void * userdata2
)
SYSTEM_register_event (when
, (EventFunc_T
*)event_fn
, userdata1
, userdata2
,
(UnloadFunc_T
*)NULL
, "mmi-unknown");
/////////////////////////////////////////////////////////////
int mmi_register_cb_instr (module_t
*mod
, fn_event_cpu handler
)
ui
->error("SAM MMI: mmi_register_cb_instr no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_register_cb_memop (module_t
*mod
, fn_event_cpu handler
)
ui
->error("SAM MMI: mmi_register_cb_memop no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_register_cb_trap (module_t
*mod
, fn_event_cpu handler
)
ui
->error("SAM MMI: mmi_register_cb_trap no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_register_cb_trapexit (module_t
*mod
, fn_event_cpu handler
)
ui
->error("SAM MMI: mmi_register_cb_trapexit no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_register_cb_tlb (module_t
*mod
, fn_event_cpu handler
)
ui
->error("SAM MMI: mmi_register_cb_tlb no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_register_cb_cpustate (module_t
*mod
, fn_event_cpu handler
)
ui
->error("SAM MMI: mmi_register_cb_cpustate no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_register_cb_dma (module_t
*mod
, fn_event_dma handler
)
ui
->error("SAM MMI: mmi_register_cb_dma no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_set_cb_mask (module_t
*mod
, uint32_t mask
)
ui
->error("SAM MMI: mmi_set_cb_mask no longer supported (called from module %s)\n", mod
->name
);
/////////////////////////////////////////////////////////////
int mmi_register_io_action (module_t
*mod
, mmi_io_action ld_handler
, mmi_io_action st_handler
)
if ((mod
== 0) || (ld_handler
== 0) || (st_handler
== 0))
TM_register_io_mmi_action ((tracemod_t
*)mod
, (fn_misc
)ld_handler
, (fn_misc
)st_handler
);
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
mem_t
* mmi_get_memobj (cpu_t
*)
/////////////////////////////////////////////////////////////
// TODO : Might be a subject of MODULE REDIRECTION itself
int mmi_iommu_va2pa (module_t
*, int is_read
, uint64_t va
, uint64_t *)
return local_pa
? 0 : (-1);
/////////////////////////////////////////////////////////////
// review of Sun4u Mondo interrupts:
// (tgt_AgentID<<14) => IDCR--->---IRSR => bits-<5:0> = src_AgentID
// (tgt_AgentID<<26 | src_AgentID<<6 | dev_INO) =>...
// ...=> INR--->---IRSR => bits-<5:0> = src_AgentID
// (*) IRDR => bits-<10:0> = (AID<<6) | INO
// *-> idata[0] must be supplied by schizo HW _!!!_
int mmi_interrupt_packet (int dst_aid
, int src_aid
, uint64_t *idata
)
intrT intr
; // recently typedef'ed to "cpu_lib_intf.h"/InterruptRequest
intr
.data
[2] = idata
[2]; // data[3..7] not part of original mondo spec
// and never referenced by solaris :-!.
SYSTEM_interrupt_by_sid (dst_aid
, src_aid
, &intr
);
/////////////////////////////////////////////////////////////
int mmi_interrupt_vector (int dest_cpuid
, void *src
, int src_iscpu
, uint32_t vnum
, int traptype
)
intr
.isid
= 0xF00 | traptype
; // Patch - to distinguish between
SYSTEM_interrupt_by_sid (dest_cpuid
, 0, &intr
);
/////////////////////////////////////////////////////////////
int mmi_reset (cpu_t
*, void *, resettype_t
)
ui
->error("MMI: RESET is not implemented yet \n");
/////////////////////////////////////////////////////////////
return SYSTEM_get_ncpu ();
int mmi_get_cpu_sid (cpu_t
*sp
)
cpu_t
*mmi_get_cpuptr_by_sid (int id
)
uint64_t mmi_get_cpufreq ()
return SYSTEM_get_cpufreq();
char *mmi_get_comment_string (void *, objtype_t
)
return (char*)strdup("unimplemented");
int mmi_complete_delayed_load (cpu_t
*, uint64_t )
ui
->error("MMI: complete delayed load is not implemented yet \n");
int mmi_delay_execution (cpu_t
*sp
, blaze_cycle_t delay
)
SYSTEM_cycle_delay (sp
->id(), (uint32_t)delay
);
//////////////////////////////////////////////////
int mmi_register_ui_variable (module_t
*module
, const char *varname
,
vartype_t vartype
, void *varptr
, int writable
, fn_setvar writer
)
MmiVarNode
*pnode
= MmiVarNode::CreateInstance ("MMI Varlist");
ui
->error("MMI:Unable to register UI VARIABLE <%s>\n", varname
);
ui
->error("MMI: Uknown variable type <%d> \n", vartype
);
pvar
= pnode
->GetData ();
pvar
->name
= (const char*)strdup(varname
);
pvar
->writable
= writable
;
MmiVarNode::AddHead (&pMmiVarList
, pnode
);
//////////////////////////////////////////////////
int mmi_set_ui_variable (module_t
*module
, const char *varname
, void *val
)
MmiVarNode
*pnode
= pMmiVarList
;
for (;pnode
; pnode
= pnode
->Next()) {
pvar
= pnode
->GetData ();
if (strcmp (varname
, pvar
->name
) == NULL
) {
if (module
== pvar
->module
) {
if (pvar
->writable
&& pvar
->action
) {
void *cb_data
= TM_get_client_data ((void *)module
);
pvar
->action(cb_data
, val
);
else if (pvar
->writable
) {
*((uint32_t*) pvar
->varptr
) = *( (uint32_t*) val
);
*((uint64_t*) pvar
->varptr
) = *( (uint64_t*) val
);
pq
= (char**)&(pvar
->varptr
);
*pq
= (char*)strdup((char*)val
);
*((uint8_t*) pvar
->varptr
) = *( (uint8_t*) val
);
//////////////////////////////////////////////////
/////////////////////////////////
// FlexConfig-related additions
/////////////////////////////////
char *ldm_get_instanceof(char *modname
) {
LdmNode
*pnode
= head_spec_ldm
;
if ( strstr(pldm
->name
, modname
) )