From owner-svn-src-user@FreeBSD.ORG Mon Dec 29 21:43:04 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 23E109F3; Mon, 29 Dec 2014 21:43:04 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0516B177B; Mon, 29 Dec 2014 21:43:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBTLh3af073062; Mon, 29 Dec 2014 21:43:03 GMT (envelope-from nwhitehorn@FreeBSD.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBTLh3ZS073056; Mon, 29 Dec 2014 21:43:03 GMT (envelope-from nwhitehorn@FreeBSD.org) Message-Id: <201412292143.sBTLh3ZS073056@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: nwhitehorn set sender to nwhitehorn@FreeBSD.org using -f From: Nathan Whitehorn Date: Mon, 29 Dec 2014 21:43:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r276380 - user/nwhitehorn/kboot/powerpc/kboot X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Dec 2014 21:43:04 -0000 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