libn64/os: Add a libn64_time() syscall.
authorTyler J. Stachecki <stachecki.tyler@gmail.com>
Sat, 2 Dec 2017 11:17:09 +0000 (06:17 -0500)
committerTyler J. Stachecki <stachecki.tyler@gmail.com>
Sat, 2 Dec 2017 11:36:10 +0000 (06:36 -0500)
commite441cc2a7f6d96ee689cdc8179cc9ef844499ecd
tree6b93e142884afd7698f9ff47a3eb7bd1e2c737ed
parent46bd7d95234010ecd5b0109733230273d14359ba
libn64/os: Add a libn64_time() syscall.

The syscall returns a timespec struct that has two fields
populated: tv_sec and tv_usec. Since the N64 doesn't have a
RTC, this function does the "next best thing" and returns
the time offset since libn64 started.

The syscall uses the COUNT register to precisely measure
time. It can effectively count upto a couple hundred years
before it "rolls over".

Since the COUNT register is effectively driven at "only",
46.875MHz the time source is just barely accurate within a
hundred usec or so.

Signed-off-by: Tyler J. Stachecki <stachecki.tyler@gmail.com>
libn64/Makefile
libn64/include/syscall.h
libn64/include/time.h [new file with mode: 0644]
libn64/os/asm/exception.s
libn64/os/asm/syscall.s
libn64/os/main.c
libn64/os/thread.c
libn64/os/time.c [new file with mode: 0644]
libn64/priv_include/os/time.h [new file with mode: 0644]