Subversion Repositories shark

Rev

Rev 1152 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1151 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/*
20
 * Copyright (C) 2000 Paolo Gai
21
 *
22
 * This program is free software; you can redistribute it and/or modify
23
 * it under the terms of the GNU General Public License as published by
24
 * the Free Software Foundation; either version 2 of the License, or
25
 * (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
 */
36
 
37
#include "kernel/kern.h"
38
#include "ll/i386/cons.h"
39
 
40
#include "ll/sys/ll/time.h"
41
 
42
#include "drivers/keyb.h"
43
 
44
#define UPDATE_PERIOD   10000
45
#define UPDATE_WCET     1000
46
 
47
extern signed long long clk_per_msec;
48
 
49
extern signed long last_delta_clk_per_msec;
50
extern signed long total_delta_clk_per_msec;
51
 
52
extern unsigned char use_tsc;
53
extern unsigned char use_cmos;
54
 
55
void program_key_end(KEY_EVT *k)
56
{
57
 
58
  sys_end();
59
 
60
}
61
 
62
TASK Update(void *arg)
63
{  
64
  struct timespec actual_timer;
65
  struct timespec s_test,e_test;
66
 
67
  long nsec,sec,min,hrs,day;
68
 
69
  sys_gettime(&s_test);
70
  sys_gettime(&e_test);
71
  SUBTIMESPEC(&e_test,&s_test,&s_test);
72
 
73
  while (1) {
74
 
75
        sys_gettime(&actual_timer);
76
        nsec = actual_timer.tv_nsec;
77
        sec = actual_timer.tv_sec;
78
        min = sec / 60;
79
        sec %= 60;
80
        hrs = min / 60;
81
        min %= 60;
82
        day = hrs / 24;
83
        hrs %= 24;
84
 
85
        if (use_tsc)
86
                if (use_cmos)
87
                        printf_xy(0,4,WHITE,"Timer Mode: TSC + CMOS");
88
                else
89
                        printf_xy(0,4,WHITE,"Timer Mode: TSC");
90
        else
91
                printf_xy(0,4,WHITE,"Timer Mode: 8254");
92
 
93
        printf_xy(0,5,WHITE,"Actual Clk/msec: %12ld",(long)clk_per_msec);  
94
        printf_xy(0,6,WHITE,"Actual Timer: %2ld d %2ld h %2ld m %2ld s %12ld ns",day,hrs,min,sec,(long)nsec);
95
 
96
        printf_xy(0,8,WHITE,"CMOS Adjustment setting");
97
        printf_xy(0,9,WHITE,"CMOS last  delta Clk/msec: %12ld",(long)last_delta_clk_per_msec);
98
        printf_xy(0,10,WHITE,"CMOS total delta Clk/msec: %12ld",(long)total_delta_clk_per_msec);
99
 
100
        printf_xy(0,12,WHITE,"Timer Access Delay: %12ld ns",s_test.tv_nsec/2);
101
 
102
        task_endcycle();
103
 
104
  }
105
 
106
  sys_end();
107
 
108
}
109
 
110
void set_screen()
111
{
112
 
113
        printf_xy(20,0,WHITE,"          Advanced Timer Demo           ");
114
        printf_xy(20,1,WHITE,"Giacomo Guidi <giacomo@gandalf.sssup.it>");
115
        printf_xy(20,2,WHITE,"         Press Alt + c to exit          ");
116
 
117
}
118
 
119
 
120
int main(int argc, char **argv)
121
{
122
 
123
  HARD_TASK_MODEL   mp; //Show current setting
124
  PID               update;
125
  KEY_EVT           k;
126
 
127
  k.flag = ALTL_BIT;
128
  k.scan = KEY_C;
129
  k.ascii = 'c';
130
  keyb_hook(k,program_key_end);
131
 
132
  clear();
133
 
134
  set_screen();
135
 
136
  hard_task_default_model(mp);
137
  hard_task_def_ctrl_jet(mp);
138
  hard_task_def_group(mp, 1);
139
  hard_task_def_wcet(mp,UPDATE_WCET);
140
  hard_task_def_mit(mp,UPDATE_PERIOD);
141
  hard_task_def_usemath(mp);
142
  update = task_create("Update", Update, &mp, NULL);
143
  if (update != NIL) task_activate(update);
144
 
145
  return 0;
146
 
147
}