From 27722c2705ffa6a353dd05712d7a26550ff80f37 Mon Sep 17 00:00:00 2001 From: Oliver Lehmann Date: Mon, 10 Aug 2009 20:18:59 +0000 Subject: [PATCH] working version! --- .../cmd/standalone/sa.timer/common/gmtime.c | 8 +--- .../src/cmd/standalone/sa.timer/common/u130.c | 25 +++------- .../src/cmd/standalone/sa.timer/common/u130.h | 4 +- .../cmd/standalone/sa.timer/kernel/makefile | 6 +-- WEGA/src/cmd/standalone/sa.timer/makefile | 6 +-- .../standalone/sa.timer/standalone/makefile | 6 +-- .../standalone/sa.timer/standalone/sa.timer.c | 46 +++++++------------ 7 files changed, 32 insertions(+), 69 deletions(-) diff --git a/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c b/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c index 2cce1c9..10c9aeb 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c +++ b/WEGA/src/cmd/standalone/sa.timer/common/gmtime.c @@ -23,17 +23,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: gmtime.c,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $ + * $Id: gmtime.c,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $ */ #define dysize(A) (((A)%4)? 365: 366) #include -struct tm *gmtime(); - -static char cbuf[26]; -static int dmsize[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; - struct tm * gmtime(tim) long *tim; @@ -41,6 +36,7 @@ long *tim; register int d0, d1; long hms, day; static struct tm xtime; + static int dmsize[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; /* * break initial number into days diff --git a/WEGA/src/cmd/standalone/sa.timer/common/u130.c b/WEGA/src/cmd/standalone/sa.timer/common/u130.c index 016fe07..80e4a14 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/u130.c +++ b/WEGA/src/cmd/standalone/sa.timer/common/u130.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: u130.c,v 1.3 2009/08/07 20:02:59 olivleh1 Exp $ + * $Id: u130.c,v 1.4 2009/08/10 20:18:59 olivleh1 Exp $ */ #include @@ -32,9 +32,8 @@ int rdvalue(); int invalue(); void outvalue(); -extern long timegm(); -extern struct tm *gmtime(); - +long timegm(); +struct tm *gmtime(); int u130_init() @@ -42,8 +41,7 @@ u130_init() return(0); } - -int +void u130_set(time) long time; { @@ -98,7 +96,6 @@ long time; ; outvalue(0x01); /* Korrektur Stop */ outvalue(0x00); - return(0); } void @@ -129,21 +126,11 @@ u130_get() while ((clktime->tm_sec = rdvalue(U130SSx1)) == 59); clktime->tm_min = rdvalue(U130MIx1); clktime->tm_hour = rdvalue(U130HHx1); -#ifdef DEBUG - printf("u130_get\n"); - printf("year %d\n",clktime->tm_year); - printf("month %d\n",clktime->tm_mon); - printf("day %d\n",clktime->tm_mday); - printf("hour %d\n",clktime->tm_hour); - printf("min %d\n",clktime->tm_min); - printf("sec %d\n",clktime->tm_sec); -#endif - time = timegm(clktime); + time = timegm(clktime); return(time); } - void outvalue(t) register t; @@ -203,5 +190,5 @@ int rdvalue(addr) unsigned addr; { - return(invalue(addr,0) + invalue(addr+2,0)*10); + return(invalue(addr,0) + invalue(addr+2,0)*10); } diff --git a/WEGA/src/cmd/standalone/sa.timer/common/u130.h b/WEGA/src/cmd/standalone/sa.timer/common/u130.h index f8cf384..c529b47 100644 --- a/WEGA/src/cmd/standalone/sa.timer/common/u130.h +++ b/WEGA/src/cmd/standalone/sa.timer/common/u130.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: u130.h,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $ + * $Id: u130.h,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $ */ #ifndef U130_H @@ -48,7 +48,7 @@ int u130_init(); long u130_get(); -int u130_set(); +void u130_set(); void u130_start(); #endif diff --git a/WEGA/src/cmd/standalone/sa.timer/kernel/makefile b/WEGA/src/cmd/standalone/sa.timer/kernel/makefile index 60b973f..4b2e3d1 100644 --- a/WEGA/src/cmd/standalone/sa.timer/kernel/makefile +++ b/WEGA/src/cmd/standalone/sa.timer/kernel/makefile @@ -1,12 +1,10 @@ -OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a +OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o CC= cc LD= ld -DEBUG= +DEBUG= CFLAGS= -O $(DEBUG) all: sa.timer -sa.timer.o: - $(CC) -c $(DEBUG) sa.timer.c sa.timer: $(OBJ) $(LD) -s -o $@ $(OBJ) chmod 400 $@ diff --git a/WEGA/src/cmd/standalone/sa.timer/makefile b/WEGA/src/cmd/standalone/sa.timer/makefile index 60b973f..4b2e3d1 100644 --- a/WEGA/src/cmd/standalone/sa.timer/makefile +++ b/WEGA/src/cmd/standalone/sa.timer/makefile @@ -1,12 +1,10 @@ -OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a +OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o CC= cc LD= ld -DEBUG= +DEBUG= CFLAGS= -O $(DEBUG) all: sa.timer -sa.timer.o: - $(CC) -c $(DEBUG) sa.timer.c sa.timer: $(OBJ) $(LD) -s -o $@ $(OBJ) chmod 400 $@ diff --git a/WEGA/src/cmd/standalone/sa.timer/standalone/makefile b/WEGA/src/cmd/standalone/sa.timer/standalone/makefile index 60b973f..4b2e3d1 100644 --- a/WEGA/src/cmd/standalone/sa.timer/standalone/makefile +++ b/WEGA/src/cmd/standalone/sa.timer/standalone/makefile @@ -1,12 +1,10 @@ -OBJ= sa.timer.o u130.o rtc72421.o gmtime.o timegm.o libb.a +OBJ= sa.timer.o libb.a u130.o gmtime.o timegm.o CC= cc LD= ld -DEBUG= +DEBUG= CFLAGS= -O $(DEBUG) all: sa.timer -sa.timer.o: - $(CC) -c $(DEBUG) sa.timer.c sa.timer: $(OBJ) $(LD) -s -o $@ $(OBJ) chmod 400 $@ diff --git a/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c b/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c index ec64314..f16507e 100644 --- a/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c +++ b/WEGA/src/cmd/standalone/sa.timer/standalone/sa.timer.c @@ -23,27 +23,29 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: sa.timer.c,v 1.2 2009/08/07 20:02:59 olivleh1 Exp $ + * $Id: sa.timer.c,v 1.3 2009/08/10 20:18:59 olivleh1 Exp $ */ -#include -#include + +char estring[20]; +long u130_get(); + +#define dysize(A) (((A)%4)? 365: 366) +#include "time.h" #include "u130.h" #include "rtc72421.h" #include "timer.h" -extern long timegm(); -extern struct tm *gmtime(); +long timegm(); +struct tm *gmtime(); main() { register long time; register i,timer_found; struct clock_type *t; - int a; - t = clock_devs; - +#ifdef foo for( i = 0 ; i < sizeof(clock_devs) / sizeof(clock_devs[0]); i++, t++) { if((inb(t->clock_addr)&~t->clock_det_msk) == t->clock_det_str) { printf("%s found\n",t->clock_name); @@ -52,6 +54,9 @@ main() break; } } +#else + timer_found=1; +#endif if (timer_found != 1) { /* Uhrmodul vorhanden ? */ printf("Timer not available\n"); exit(1); @@ -88,11 +93,8 @@ long time; clktime = gmtime(&time); -#ifdef DEBUG - print_tm("outtime",clktime); -#endif - (clktime->tm_year) += 1900; - clktime->tm_mon++; + clktime->tm_year += 1900; + clktime->tm_mon ++; printf("Date is: %d/%d/%d\n", clktime->tm_mon, clktime->tm_mday, clktime->tm_year); printf("Time is: %d:%d:%d GMT\n", clktime->tm_hour, clktime->tm_min, clktime->tm_sec); } @@ -101,7 +103,7 @@ settimer() { struct tm *clktime; long time; - int i; + register i; loop1: printf("Enter new Date (MM/DD/YY) : "); gets(estring, sizeof estring); @@ -132,20 +134,4 @@ loop2: printf("Enter Return to start time : "); gets(estring, 1); u130_start(); - } - -#ifdef DEBUG -print_tm(func,clktime) -char *func; -struct tm *clktime; -{ - printf("%s\n", func); - printf("year %d\n",clktime->tm_year); - printf("month %d\n",clktime->tm_mon); - printf("day %d\n",clktime->tm_mday); - printf("hour %d\n",clktime->tm_hour); - printf("min %d\n",clktime->tm_min); - printf("sec %d\n",clktime->tm_sec); -} -#endif