summaryrefslogtreecommitdiffstats
path: root/zpu/sw/startup/time.c
diff options
context:
space:
mode:
authoroharboe <oharboe>2008-08-18 12:00:34 +0000
committeroharboe <oharboe>2008-08-18 12:00:34 +0000
commit431a1bf775d468bcd788c3dd716b97cc0fca1f34 (patch)
treed327dae59d556908d6b90f6de2d2cf199ca8c323 /zpu/sw/startup/time.c
parent3c919f795b78bacdb9b3b7396ac5761f7457224a (diff)
downloadzpu-431a1bf775d468bcd788c3dd716b97cc0fca1f34.zip
zpu-431a1bf775d468bcd788c3dd716b97cc0fca1f34.tar.gz
* duplicated crt0.s and some other stuff from libgloss into
sw/startup. This makes it easier to tinker w/startup code.
Diffstat (limited to 'zpu/sw/startup/time.c')
-rw-r--r--zpu/sw/startup/time.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/zpu/sw/startup/time.c b/zpu/sw/startup/time.c
new file mode 100644
index 0000000..767b62f
--- /dev/null
+++ b/zpu/sw/startup/time.c
@@ -0,0 +1,32 @@
+#include <_ansi.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+extern long long _readCycles();
+
+
+extern volatile int *MHZ;
+
+long long _readMicroseconds()
+{
+ int Hz;
+ long long clock;
+ Hz=(*MHZ&0xff);
+ clock=_readCycles();
+ return clock/(long long)Hz;
+}
+
+
+
+
+time_t
+time (time_t *tloc)
+{
+ time_t t;
+ t=(time_t)(_readMicroseconds()/(long long )1000000);
+ if (tloc!=NULL)
+ {
+ *tloc=t;
+ }
+ return t;
+}
OpenPOWER on IntegriCloud