svn commit: r276380 - user/nwhitehorn/kboot/powerpc/kboot
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Mon Dec 29 21:43:04 UTC 2014
Author: nwhitehorn
Date: Mon Dec 29 21:43:02 2014
New Revision: 276380
URL: https://svnweb.freebsd.org/changeset/base/276380
Log:
Make countdown, and interrupting the countdown, work.
Modified:
user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S
user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h
user/nwhitehorn/kboot/powerpc/kboot/hostcons.c
user/nwhitehorn/kboot/powerpc/kboot/main.c
Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S
==============================================================================
--- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 21:38:00 2014 (r276379)
+++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.S Mon Dec 29 21:43:02 2014 (r276380)
@@ -30,3 +30,13 @@ ENTRY(host_mmap)
sc
blr
+ENTRY(host_gettimeofday)
+ li %r0, 116 # SYS_gettimeofday
+ sc
+ blr
+
+ENTRY(host_select)
+ li %r0, 93 # SYS_select
+ sc
+ blr
+
Modified: user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h
==============================================================================
--- user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 21:38:00 2014 (r276379)
+++ user/nwhitehorn/kboot/powerpc/kboot/host_syscall.h Mon Dec 29 21:43:02 2014 (r276380)
@@ -37,5 +37,12 @@ int host_open(char *path, int flags, int
int host_close(int fd);
void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t);
#define host_getmem(size) host_mmap(0, size, 3 /* RW */, 0x1000 /* ANON */, -1, 0);
+struct host_timeval {
+ int tv_sec;
+ int tv_usec;
+};
+int host_gettimeofday(struct host_timeval *a, void *b);
+int host_select(int nfds, long *readfds, long *writefds, long *exceptfds,
+ struct host_timeval *timeout);
#endif
Modified: user/nwhitehorn/kboot/powerpc/kboot/hostcons.c
==============================================================================
--- user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Mon Dec 29 21:38:00 2014 (r276379)
+++ user/nwhitehorn/kboot/powerpc/kboot/hostcons.c Mon Dec 29 21:43:02 2014 (r276380)
@@ -75,14 +75,22 @@ static int
hostcons_getchar()
{
uint8_t ch;
+ int rv;
- host_read(0, &ch, 1);
- return (ch);
+ rv = host_read(0, &ch, 1);
+ if (rv == 1)
+ return (ch);
+ return (-1);
}
static int
hostcons_poll()
{
- return (0);
+ struct host_timeval tv = {0,0};
+ long fds = 1 << 0;
+ int ret;
+
+ ret = host_select(32, &fds, NULL, NULL, &tv);
+ return (ret > 0);
}
Modified: user/nwhitehorn/kboot/powerpc/kboot/main.c
==============================================================================
--- user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 21:38:00 2014 (r276379)
+++ user/nwhitehorn/kboot/powerpc/kboot/main.c Mon Dec 29 21:43:02 2014 (r276380)
@@ -135,14 +135,22 @@ exit(int code)
void
delay(int usecs)
{
- /* XXX */
+ struct host_timeval tvi, tv;
+ uint64_t ti, t;
+ host_gettimeofday(&tvi, NULL);
+ ti = tvi.tv_sec*1000000 + tvi.tv_usec;
+ do {
+ host_gettimeofday(&tv, NULL);
+ t = tv.tv_sec*1000000 + tv.tv_usec;
+ } while (t < ti + usecs);
}
int
getsecs()
{
- /* XXX */
- return (0);
+ struct host_timeval tv;
+ host_gettimeofday(&tv, NULL);
+ return (tv.tv_sec);
}
time_t
More information about the svn-src-user
mailing list