#include "libc.h"
#include "s390-ccw.h"
#include "sclp.h"
+#include "s390-time.h"
#define KEYCODE_NO_INP '\0'
#define KEYCODE_ESCAPE '\033'
#include "s390-ccw.h"
#include "cio.h"
#include "virtio.h"
+#include "s390-time.h"
#define DEFAULT_BOOT_RETRIES 10
#define DEFAULT_TFTP_RETRIES 20
static uint8_t mac[6];
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 incremented each microsecond */
- return (clk >> (63 - 51)) / 1000;
-}
-
void set_timer(int val)
{
- dest_timer = get_timer_ms() + val;
+ dest_timer = get_time_ms() + val;
}
int get_timer(void)
{
- return dest_timer - get_timer_ms();
+ return dest_timer - get_time_ms();
}
int get_sec_ticks(void)
bool virtio_is_supported(SubChannelId schid);
void virtio_blk_setup_device(SubChannelId schid);
int virtio_read(ulong sector, void *load_addr);
-u64 get_clock(void);
-ulong get_second(void);
/* bootmap.c */
void zipl_load(void);
#define MAX_SECTOR_SIZE 4096
+#include "s390-time.h"
+
static inline void sleep(unsigned int seconds)
{
- ulong target = get_second() + seconds;
+ ulong target = get_time_seconds() + seconds;
- while (get_second() < target) {
+ while (get_time_seconds() < target) {
yield();
}
}
--- /dev/null
+#ifndef TIME_H
+#define TIME_H
+
+static inline u64 get_clock(void)
+{
+ u64 r;
+
+ asm volatile("stck %0" : "=Q" (r) : : "cc");
+ return r;
+}
+
+static inline u64 get_time_ms(void)
+{
+ /* Bit 51 is incremented each microsecond */
+ return (get_clock() >> 12) / 1000;
+}
+
+static inline u64 get_time_seconds(void)
+{
+ return get_time_ms() / 1000;
+}
+
+#endif
#include <ethernet.h>
#include "s390-ccw.h"
#include "virtio.h"
+#include "s390-time.h"
#ifndef DEBUG_VIRTIO_NET
#define DEBUG_VIRTIO_NET 0
#include "virtio.h"
#include "scsi.h"
#include "virtio-scsi.h"
+#include "s390-time.h"
static ScsiDevice default_scsi_device;
static VirtioScsiCmdReq req;
#include "virtio-scsi.h"
#include "bswap.h"
#include "helper.h"
+#include "s390-time.h"
#define VRING_WAIT_REPLY_TIMEOUT 30
}
}
-u64 get_clock(void)
-{
- u64 r;
-
- asm volatile("stck %0" : "=Q" (r) : : "cc");
- return r;
-}
-
-ulong get_second(void)
-{
- return (get_clock() >> 12) / 1000000;
-}
-
int vr_poll(VRing *vr)
{
if (vr->used->idx == vr->used_idx) {
*/
int vring_wait_reply(void)
{
- ulong target_second = get_second() + vdev.wait_reply_timeout;
+ ulong target_second = get_time_seconds() + vdev.wait_reply_timeout;
/* Wait for any queue to be updated by the host */
do {
if (r) {
return 0;
}
- } while (!vdev.wait_reply_timeout || (get_second() < target_second));
+ } while (!vdev.wait_reply_timeout || (get_time_seconds() < target_second));
return 1;
}