Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / tod_4v / include / tod.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: tod.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 ============================================
*/
#ifndef __TOD_4V__
#define __TOD_4V__
#include "module.h"
#include "arg.h"
#include "types.h"
#include <time.h>
#include <assert.h>
#include "dr.h"
extern "C"{
int tod_4v_ui_cmd(void*, int argc, char * argv[]);
void tod_1sec_callback(void * todobj, void * );
}
class tod4v:public Module{
uint64_t start_pa;
uint64_t end_pa;
uint64_t size;
bool set_fake_tod;
struct tm time_str;
time_t tod;
const char * todstr;
// simulated time. will match with Solaris sim time only if stick freq
// in Solaris and SAM are same
int32_t sim_time;
uint64_t event_fire_time;
public:
const char *get_help();
bool parse_arg(const char *);
bool check_args();
void init_done();
void module_added(mmi_instance_t, const char*){return; }
void module_deleted(mmi_instance_t, const char*){return;}
void modinfo(){
printf("%s: sun4v tod module\n",getName());
printf("%s: IOMAP <0x%llx> to <0x%llx>\n",getName(),start_pa, end_pa);
printf("%s: current time of day is %s", getName(), ctime(&tod));
}
void *get_interface(const char*){return 0;}
static int tod4v_physio_access(uint32_t cpuid, void* obj, uint64_t paddr,
mmi_bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask);
void tod4v_ld (uint64_t paddr, uint64_t *buf, int size);
void tod4v_st(uint64_t paddr, uint64_t *buf, int size);
tod4v(const char *, const char *);
~tod4v(){}
void timer_callback();
bool dump(FILE *fp){
fprintf(fp,"tod 0x%lx\n",tod);
fprintf(fp,"sim_time %i\n",sim_time);
fprintf(fp,"event_fire_time 0x%llx\n",event_fire_time);
return true;
}
bool restore(FILE *fp) {
fscanf(fp,"tod 0x%lx\n",&tod);
fscanf(fp,"sim_time %i\n",&sim_time);
fscanf(fp,"event_fire_time 0x%llx\n",&event_fire_time);
mmi_register_event(event_fire_time,tod_1sec_callback,(void*)this,0);
return true;
}
void handle_ui(int argc, char * argv[]);
void ui_cmd_usage(){
printf("ui format: %s <command> <command args> ... \n",getName());
printf("%s supports following UI commands\n",getName());
printf(" debug [<level>]\n\
set the debug level for debug prints to \'level\'\n\
prints current tod every simulated second, and total simulated time.\n\
Note:Solaris sim time and tod sim time match, only if Solaris stick\n\
frequency is same as SAM stick frequency\n\
if \'level\' not provided, print current debug level\n\
\'level\' = [0|2]\n");
}
};
#endif //__TOD_4V__