273e66d42cdae563fb01ced29f2aecf4e23962ea
[AROS.git] / arch / ppc-chrp / battclock / writebattclock.c
blob273e66d42cdae563fb01ced29f2aecf4e23962ea
1 /*
2 Copyright � 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: WriteBattClock()
6 Lang: english
7 */
8 #include "battclock_intern.h"
10 static int rtas_call(const char *method, int nargs, int nret, void *output, ...);
12 /*****************************************************************************
14 NAME */
15 #include <proto/battclock.h>
16 #include <proto/utility.h>
17 #include <proto/rtas.h>
18 #include <proto/exec.h>
19 #include <utility/date.h>
20 #include <stdarg.h>
22 AROS_LH1(void, WriteBattClock,
24 /* SYNOPSIS */
25 AROS_LHA(ULONG, time, D0),
27 /* LOCATION */
28 APTR *, BattClockBase, 3, Battclock)
30 /* FUNCTION
31 Set the systems battery backed up clock to the time specified. The
32 value should be the number of seconds since 00:00:00 on 1.1.1978.
34 INPUTS
35 time - The number of seconds elapsed since 00:00:00 1.1.1978
37 RESULT
38 The clock will be set.
40 NOTES
41 This may not do anything on some systems where the battery backed
42 up clock either doesn't exist, or may not be writable.
44 EXAMPLE
46 BUGS
48 SEE ALSO
49 ReadBattClock, ResetBattClock
51 INTERNALS
53 HISTORY
54 27-11-96 digulla automatically created from
55 battclock_lib.fd and clib/battclock_protos.h
57 *****************************************************************************/
59 AROS_LIBFUNC_INIT
61 struct ClockData date;
62 ULONG out[8];
64 Amiga2Date(time, &date);
66 rtas_call("set-time-of-day", 7, 1, NULL, (ULONG)date.year, (ULONG)date.month, (ULONG)date.mday, (ULONG)date.hour, (ULONG)date.min, (ULONG)date.sec, 0);
68 AROS_LIBFUNC_EXIT
69 } /* WriteBattClock */
71 static int rtas_call(const char *method, int nargs, int nret, void *output, ...)
73 va_list args;
74 void *RTASBase = OpenResource("rtas.resource");
75 int retval;
77 va_start(args, output);
78 retval = RTASCall(method, nargs, nret, output, args);
79 va_end(args);
81 return retval;