fix case when no timer is installed at all

This commit is contained in:
Oliver Lehmann 2016-07-02 10:46:38 +02:00
parent 0f11ff363a
commit 675e2feb8c
2 changed files with 16 additions and 12 deletions

10
WEGA/src/cmd/standalone/sa.timer/kernel/timer.c Normal file → Executable file
View File

@ -25,7 +25,7 @@
*
* $Id: timer.c,v 1.6 2009/08/22 15:45:33 olivleh1 Exp $
*/
#include <time.h>
#include "rtc72421.h"
@ -38,13 +38,14 @@ gettime()
register long time = 0;
register i;
struct clock_type *t;
int a,b;
int a,b;
int clock_min_year;
int clock_max_year;
int (*clock_finit)();
long (*clock_fget)();
void (*clock_fset)();
void (*clock_fstart)();
int clock_found = 0;
t = clock_devs;
@ -53,6 +54,7 @@ gettime()
b = t->clock_det_str;
if(a == b) {
printf("%s found\n",t->clock_name);
clock_found = 1;
clock_finit = t->clock_finit;
clock_fget = t->clock_fget;
clock_fset = t->clock_fset;
@ -64,8 +66,8 @@ gettime()
}
/* function pointer assigned? => RTC found?*/
if (clock_finit > 0) {
clock_finit();
if (clock_found == 1) {
clock_finit();
time = clock_fget();
}

18
WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c Normal file → Executable file
View File

@ -25,7 +25,7 @@
*
* $Id: sa.timer.c,v 1.12 2009/08/16 14:52:52 olivleh1 Exp $
*/
#include "time.h"
#include "u130.h"
@ -49,7 +49,8 @@ main()
register long time;
register i;
struct clock_type *t;
int a,b;
int a,b;
int clock_found = 0;
t = clock_devs;
@ -58,6 +59,7 @@ main()
b = t->clock_det_str;
if(a == b) {
printf("%s found\n",t->clock_name);
clock_found = 1;
clock_finit = t->clock_finit;
clock_fget = t->clock_fget;
clock_fset = t->clock_fset;
@ -69,13 +71,13 @@ main()
}
/* function pointer assigned? => RTC found?*/
if (clock_finit > 0) {
clock_finit();
if (clock_found == 1) {
clock_finit();
time = clock_fget();
outtime(time);
settimer(time);
outtime(time);
settimer(time);
time = clock_fget();
outtime(time);
outtime(time);
exit(0);
} else {
printf("Timer not available\n");
@ -149,7 +151,7 @@ loop1:
if (tm_mon<0 || tm_mon>11 || tm_mday<1 || tm_mday>31 || tm_year<clock_min_year || tm_year>clock_max_year)
goto loop1;
loop2:
printf("Enter new Time in GMT (HH:MM) : ");
gets(estring, sizeof estring);