[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/9] pc-bios: s390x: Consolidate timing functions into tim
From: |
David Hildenbrand |
Subject: |
Re: [PATCH v2 2/9] pc-bios: s390x: Consolidate timing functions into time.h |
Date: |
Mon, 18 May 2020 14:01:10 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 |
[...]
>
> -static inline void yield(void)
> -{
> - asm volatile ("diag 0,0,0x44"
> - : :
> - : "memory", "cc");
> -}
> -
Nit: Looks weird that yield() is moved to time.h
Wonder if there is a better fit for this function.
> #define MAX_SECTOR_SIZE 4096
>
> -static inline void sleep(unsigned int seconds)
> -{
> - ulong target = get_second() + seconds;
> -
> - while (get_second() < target) {
> - yield();
> - }
> -}
> -
> static inline void IPL_assert(bool term, const char *message)
> {
> if (!term) {
> diff --git a/pc-bios/s390-ccw/time.h b/pc-bios/s390-ccw/time.h
> new file mode 100644
> index 0000000000..899de83ae7
> --- /dev/null
> +++ b/pc-bios/s390-ccw/time.h
> @@ -0,0 +1,39 @@
> +#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;
return get_time_ms() / 1000;
--
Thanks,
David / dhildenb
[PATCH v2 9/9] pc-bios: s390x: Make u32 ptr check explicit, Janosch Frank, 2020/05/14
Re: [PATCH v2 0/9] pc-bios: s390x: Cleanup part 1, no-reply, 2020/05/14
Re: [PATCH v2 0/9] pc-bios: s390x: Cleanup part 1, Cornelia Huck, 2020/05/20