[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 10/14] pc-bios/s390-ccw: Add timer code for the
From: |
Thomas Huth |
Subject: |
[Qemu-devel] [RFC PATCH 10/14] pc-bios/s390-ccw: Add timer code for the libnet |
Date: |
Tue, 27 Jun 2017 13:48:16 +0200 |
The libnet expects certain timer functions to exist, so that it
is able to deal with timeouts etc.
This patch implements these timer functions via the STORE CLOCK (stck)
CPU instruction.
Signed-off-by: Thomas Huth <address@hidden>
---
pc-bios/s390-ccw/libnet/Makefile | 2 +-
pc-bios/s390-ccw/libnet/timer.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 1 deletion(-)
create mode 100644 pc-bios/s390-ccw/libnet/timer.c
diff --git a/pc-bios/s390-ccw/libnet/Makefile b/pc-bios/s390-ccw/libnet/Makefile
index 72e12d7..c8235f3 100644
--- a/pc-bios/s390-ccw/libnet/Makefile
+++ b/pc-bios/s390-ccw/libnet/Makefile
@@ -24,7 +24,7 @@ QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS),
-fno-stack-protector)
LDFLAGS += -Wl,-pie -nostdlib
SRCS = ethernet.c ipv4.c udp.c tcp.c dns.c dhcp.c tftp.c \
- ipv6.c dhcpv6.c icmpv6.c ndp.c netload.c args.c
+ ipv6.c dhcpv6.c icmpv6.c ndp.c netload.c args.c timer.c
OBJS = $(SRCS:%.c=%.o)
diff --git a/pc-bios/s390-ccw/libnet/timer.c b/pc-bios/s390-ccw/libnet/timer.c
new file mode 100644
index 0000000..ddbd7a2
--- /dev/null
+++ b/pc-bios/s390-ccw/libnet/timer.c
@@ -0,0 +1,40 @@
+/*
+ * Timer functions for libnet
+ *
+ * Copyright 2017 Thomas Huth, Red Hat Inc.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <stdint.h>
+#include "time.h"
+
+static uint64_t dest_timer;
+
+static uint64_t get_timer_ms(void)
+{
+ uint64_t clk;
+
+ asm volatile(" stck %0 " : : "Q"(clk) : "memory");
+
+ /* Bit 51 is incrememented each microsecond */
+ return (clk >> (63 - 51)) / 1000;
+}
+
+void set_timer(int val)
+{
+ dest_timer = get_timer_ms() + val;
+}
+
+int get_timer(void)
+{
+ return dest_timer - get_timer_ms();
+}
+
+int get_sec_ticks(void)
+{
+ return 1000; /* number of ticks in 1 second */
+}
--
1.8.3.1
- [Qemu-devel] [RFC PATCH 00/14] Implement network booting directly into the s390-ccw BIOS, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 03/14] pc-bios/s390-ccw: Add a write() function for stdio, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 02/14] pc-bios/s390-ccw: Start using the libc from SLOF, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 04/14] pc-bios/s390-ccw: Add implementation of sbrk(), Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 06/14] libnet: Remove remainders of netsave code, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 01/14] pc-bios/s390-ccw: Add the libc from the SLOF firmware, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 07/14] libnet: Rework error message printing, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 08/14] libnet: Refactor some code of netload() into a separate function, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 10/14] pc-bios/s390-ccw: Add timer code for the libnet,
Thomas Huth <=
- [Qemu-devel] [RFC PATCH 11/14] pc-bios/s390-ccw: Add virtio-net driver code, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 09/14] pc-bios/s390-ccw: Make the basic libnet code compilable, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 12/14] pc-bios/s390-ccw: Load file via an intermediate .INS file, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 13/14] pc-bios/s390-ccw: Allow loading to address 0, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 14/14] pc-bios/s390-ccw: Wire up the netload code, Thomas Huth, 2017/06/27
- [Qemu-devel] [RFC PATCH 05/14] pc-bios/s390-ccw: Add the TFTP network loading stack from SLOF, Thomas Huth, 2017/06/27
- Re: [Qemu-devel] [RFC PATCH 00/14] Implement network booting directly into the s390-ccw BIOS, Farhan Ali, 2017/06/27
- Re: [Qemu-devel] [RFC PATCH 00/14] Implement network booting directly into the s390-ccw BIOS, Viktor Mihajlovski, 2017/06/27