Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / devices / tod_4v / include / tod.h
CommitLineData
920dae64
AT
1/*
2* ========== Copyright Header Begin ==========================================
3*
4* OpenSPARC T2 Processor File: tod.h
5* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
6* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
7*
8* The above named program is free software; you can redistribute it and/or
9* modify it under the terms of the GNU General Public
10* License version 2 as published by the Free Software Foundation.
11*
12* The above named program is distributed in the hope that it will be
13* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15* General Public License for more details.
16*
17* You should have received a copy of the GNU General Public
18* License along with this work; if not, write to the Free Software
19* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20*
21* ========== Copyright Header End ============================================
22*/
23#ifndef __TOD_4V__
24#define __TOD_4V__
25
26
27#include "module.h"
28#include "arg.h"
29#include "types.h"
30#include <time.h>
31#include <assert.h>
32#include "dr.h"
33
34extern "C"{
35 int tod_4v_ui_cmd(void*, int argc, char * argv[]);
36 void tod_1sec_callback(void * todobj, void * );
37}
38
39class tod4v:public Module{
40
41 uint64_t start_pa;
42 uint64_t end_pa;
43 uint64_t size;
44 bool set_fake_tod;
45 struct tm time_str;
46 time_t tod;
47 const char * todstr;
48 // simulated time. will match with Solaris sim time only if stick freq
49 // in Solaris and SAM are same
50 int32_t sim_time;
51 uint64_t event_fire_time;
52public:
53 const char *get_help();
54 bool parse_arg(const char *);
55 bool check_args();
56 void init_done();
57 void module_added(mmi_instance_t, const char*){return; }
58 void module_deleted(mmi_instance_t, const char*){return;}
59 void modinfo(){
60 printf("%s: sun4v tod module\n",getName());
61 printf("%s: IOMAP <0x%llx> to <0x%llx>\n",getName(),start_pa, end_pa);
62 printf("%s: current time of day is %s", getName(), ctime(&tod));
63 }
64 void *get_interface(const char*){return 0;}
65
66
67 static int tod4v_physio_access(uint32_t cpuid, void* obj, uint64_t paddr,
68 mmi_bool_t wr, uint32_t size, uint64_t* buf, uint8_t bytemask);
69 void tod4v_ld (uint64_t paddr, uint64_t *buf, int size);
70 void tod4v_st(uint64_t paddr, uint64_t *buf, int size);
71 tod4v(const char *, const char *);
72 ~tod4v(){}
73
74 void timer_callback();
75
76 bool dump(FILE *fp){
77 fprintf(fp,"tod 0x%lx\n",tod);
78 fprintf(fp,"sim_time %i\n",sim_time);
79 fprintf(fp,"event_fire_time 0x%llx\n",event_fire_time);
80 return true;
81 }
82
83 bool restore(FILE *fp) {
84 fscanf(fp,"tod 0x%lx\n",&tod);
85 fscanf(fp,"sim_time %i\n",&sim_time);
86 fscanf(fp,"event_fire_time 0x%llx\n",&event_fire_time);
87 mmi_register_event(event_fire_time,tod_1sec_callback,(void*)this,0);
88 return true;
89 }
90
91 void handle_ui(int argc, char * argv[]);
92 void ui_cmd_usage(){
93 printf("ui format: %s <command> <command args> ... \n",getName());
94 printf("%s supports following UI commands\n",getName());
95 printf(" debug [<level>]\n\
96 set the debug level for debug prints to \'level\'\n\
97 prints current tod every simulated second, and total simulated time.\n\
98 Note:Solaris sim time and tod sim time match, only if Solaris stick\n\
99 frequency is same as SAM stick frequency\n\
100 if \'level\' not provided, print current debug level\n\
101 \'level\' = [0|2]\n");
102 }
103
104};
105
106#endif //__TOD_4V__
107