aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-09-02 22:18:26 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-09-02 22:18:26 -0700
commitda43022002dcc6e660d473bda2a1400e97a3fc3a (patch)
tree5c24bb669b6ca7ae911fd228af6a43bcfd181e4b
parent14b82edb040c794b0aee61c9a422a6f8266b4916 (diff)
downloadbak.git-da43022002dcc6e660d473bda2a1400e97a3fc3a.tar.gz
bak.git-da43022002dcc6e660d473bda2a1400e97a3fc3a.tar.xz
bak.git-da43022002dcc6e660d473bda2a1400e97a3fc3a.zip
Use jiffies() to implement times(); create <core/*.h> namespace
Use the core function jiffies() to implement times(), instead of poking at the BIOS variable. This creates a new need for a include file namespace for items exported from the core for the purpose of the library (not intended for direct use by applications). Use the <core/*.h> namespace for that. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/include/core/jiffies.h15
-rw-r--r--com32/include/sys/times.h10
-rw-r--r--com32/lib/Makefile2
-rw-r--r--com32/lib/sys/times.c44
-rw-r--r--core/include/core.h10
5 files changed, 24 insertions, 57 deletions
diff --git a/com32/include/core/jiffies.h b/com32/include/core/jiffies.h
new file mode 100644
index 00000000..ed843625
--- /dev/null
+++ b/com32/include/core/jiffies.h
@@ -0,0 +1,15 @@
+/*
+ * Core fundamental timer interface
+ */
+#ifndef _CORE_JIFFIES_H
+#define _CORE_JIFFIES_H
+
+#define HZ 18
+
+extern const volatile uint32_t __jiffies;
+static inline uint32_t jiffies(void)
+{
+ return __jiffies;
+}
+
+#endif
diff --git a/com32/include/sys/times.h b/com32/include/sys/times.h
index 961c7b6d..f988add1 100644
--- a/com32/include/sys/times.h
+++ b/com32/include/sys/times.h
@@ -6,16 +6,20 @@
#define _SYS_TIMES_H
#include <stdint.h>
+#include <core/jiffies.h>
struct tms {
/* Empty */
};
-#define HZ 18 /* Piddly resolution... */
#define CLK_TCK HZ
-typedef uint16_t clock_t;
+typedef uint32_t clock_t;
-clock_t times(struct tms *);
+static inline clock_t times(struct tms *__dummy)
+{
+ (void)__dummy;
+ return jiffies();
+}
#endif /* _SYS_TIMES_H */
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 2adb59bf..672d6807 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -72,7 +72,7 @@ DYNENTRY_OBJS = \
## CORE OBJECTS, INCLUDED IN THE ROOT COM32 MODULE
LIBENTRY_OBJS = \
sys/intcall.o sys/farcall.o sys/cfarcall.o sys/zeroregs.o \
- sys/argv.o sys/times.o \
+ sys/argv.o \
sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \
sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \
sys/openmem.o sys/unread.o \
diff --git a/com32/lib/sys/times.c b/com32/lib/sys/times.c
deleted file mode 100644
index 12ed671c..00000000
--- a/com32/lib/sys/times.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ----------------------------------------------------------------------- *
- *
- * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom
- * the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall
- * be included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * ----------------------------------------------------------------------- */
-
-/*
- * sys/times.c
- *
- * Returns something like a clock.
- */
-
-#include <sys/times.h>
-#include <inttypes.h>
-#include <com32.h>
-
-clock_t times(struct tms * buf)
-{
- (void)buf; /* Ignored */
-
- /* Should we get this via INT 1Ah? */
- return *(uint16_t *) 0x46c;
-}
diff --git a/core/include/core.h b/core/include/core.h
index dbcbff1c..63a1ee34 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -3,6 +3,7 @@
#include <klibc/compiler.h>
#include <com32.h>
+#include <core/jiffies.h>
extern char core_xfer_buf[65536];
extern char core_cache_buf[65536];
@@ -43,13 +44,4 @@ void call16(void (*)(void), const com32sys_t *, com32sys_t *);
__noreturn _kaboom(void);
#define kaboom() _kaboom()
-/*
- * Basic timer function...
- */
-extern const volatile uint32_t __jiffies;
-static inline uint32_t jiffies(void)
-{
- return __jiffies;
-}
-
#endif /* CORE_H */