Subversion Repositories shark

Rev

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