From patchwork Fri Sep 9 19:52:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 668214 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sW7CK20MTz9s4n for ; Sat, 10 Sep 2016 05:52:29 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sW7CK0gF6zDrqj for ; Sat, 10 Sep 2016 05:52:29 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3sW7C718qFzDrqg for ; Sat, 10 Sep 2016 05:52:19 +1000 (AEST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 83FAF61E61; Fri, 9 Sep 2016 19:52:17 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u89Jq9Yt006604; Fri, 9 Sep 2016 15:52:16 -0400 From: Thomas Huth To: slof@lists.ozlabs.org Date: Fri, 9 Sep 2016 21:52:02 +0200 Message-Id: <1473450729-19359-5-git-send-email-thuth@redhat.com> In-Reply-To: <1473450729-19359-1-git-send-email-thuth@redhat.com> References: <1473450729-19359-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 09 Sep 2016 19:52:17 +0000 (UTC) Subject: [SLOF] [PATCH 04/11] paflof: Provide get_timer() and set_timer() helper functions X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" They are needed for libnet, too. This implementation uses SLOF_GetTimer() instead of using the decrementer like it is done in the net-snk functions. Signed-off-by: Thomas Huth --- lib/libnet/time.h | 6 ++++++ slof/helpers.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 lib/libnet/time.h diff --git a/lib/libnet/time.h b/lib/libnet/time.h new file mode 100644 index 0000000..fcd5cd5 --- /dev/null +++ b/lib/libnet/time.h @@ -0,0 +1,6 @@ + +extern void set_timer(int); +extern int get_timer(void); +extern int get_sec_ticks(void); + +#define TICKS_SEC get_sec_ticks() diff --git a/slof/helpers.c b/slof/helpers.c index 3f411b9..eab334d 100644 --- a/slof/helpers.c +++ b/slof/helpers.c @@ -18,6 +18,7 @@ #include #include "helpers.h" #include "paflof.h" +#include "../lib/libnet/time.h" /* TODO: Get rid of old timer code */ /** * get msec-timer value @@ -46,6 +47,23 @@ void SLOF_usleep(uint32_t time) forth_eval("us"); } +static unsigned int dest_timer; + +void set_timer(int val) +{ + dest_timer = SLOF_GetTimer() + val; +} + +int get_timer() +{ + return dest_timer - SLOF_GetTimer(); +} + +int get_sec_ticks(void) +{ + return 1000; /* number of ticks in 1 second */ +} + void *SLOF_dma_alloc(long size) { forth_push(size);