mirror of
https://github.com/drasko/codezero.git
synced 2026-02-04 06:03:12 +01:00
Changed time representation to posix style struct timeval/ gettimeofday.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include <kdata.h>
|
||||
#include <syscalls.h>
|
||||
#include <task.h>
|
||||
#include <posix/sys/time.h>
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
@@ -99,7 +100,7 @@ void handle_fs_requests(void)
|
||||
|
||||
void main(void)
|
||||
{
|
||||
struct time_info ti;
|
||||
struct timeval tv;
|
||||
|
||||
printf("\n%s: Started with tid: %d\n", __TASKNAME__, self_tid());
|
||||
|
||||
@@ -107,12 +108,11 @@ void main(void)
|
||||
|
||||
wait_pager(PAGER_TID);
|
||||
|
||||
if (l4_time(&ti, 0) < 0) {
|
||||
if (gettimeofday(&tv, 0) < 0) {
|
||||
printf("Reading the time has failed.\n");
|
||||
} else {
|
||||
printf("Current time since system started: %u ticks, "
|
||||
"%u seconds, %u minutes, %u hours, %llu days.\n",
|
||||
ti.thz, ti.sec, ti.min, ti.hour, ti.day);
|
||||
printf("Current time since system started: %u useconds, "
|
||||
"%u seconds.\n", tv.tv_usec, tv.tv_sec);
|
||||
}
|
||||
|
||||
printf("%s: Listening requests.\n", __TASKNAME__);
|
||||
|
||||
@@ -68,20 +68,9 @@ typedef int (*__l4_kmem_control_t)(unsigned long pfn, int npages, int grant);
|
||||
extern __l4_kmem_control_t __l4_kmem_control;
|
||||
int l4_kmem_control(unsigned long pfn, int npages, int grant);
|
||||
|
||||
/* Represents time since epoch, a c0 specific structure. */
|
||||
struct time_info {
|
||||
int reader;
|
||||
u32 thz; /* Ticks in this hertz so far */
|
||||
u32 sec;
|
||||
u32 min;
|
||||
u32 hour;
|
||||
u64 day;
|
||||
};
|
||||
|
||||
typedef int (*__l4_time_t)(struct time_info *ti, int set);
|
||||
typedef int (*__l4_time_t)(void *timeval, int set);
|
||||
extern __l4_time_t __l4_time;
|
||||
int l4_time(void *time_info, int set);
|
||||
|
||||
int l4_time(void *timeval, int set);
|
||||
|
||||
|
||||
/* To be supplied by server tasks. */
|
||||
|
||||
@@ -16,6 +16,7 @@ config_h = join(project_root, "include/l4/config.h")
|
||||
env = Environment(CC = 'arm-none-linux-gnueabi-gcc',
|
||||
CCFLAGS = ['-g', '-std=gnu99', '-nostdlib', '-ffreestanding'],
|
||||
LINKFLAGS = ['-nostdlib'],
|
||||
CPPPATH = ['#include'],
|
||||
ENV = {'PATH' : os.environ['PATH']},
|
||||
LIBS = 'gcc')
|
||||
|
||||
|
||||
17
tasks/libposix/time.c
Normal file
17
tasks/libposix/time.c
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
#include <l4lib/arch/syscalls.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
int ret = l4_time(tv, 0);
|
||||
|
||||
/* If error, return positive error code */
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
return -1;
|
||||
}
|
||||
/* else return value */
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user