Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright (C) 2012 - 2014 Cisco Systems
0004  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
0005  */
0006 
0007 #ifndef __TIMER_INTERNAL_H__
0008 #define __TIMER_INTERNAL_H__
0009 #include <linux/list.h>
0010 #include <asm/bug.h>
0011 #include <shared/timetravel.h>
0012 
0013 #define TIMER_MULTIPLIER 256
0014 #define TIMER_MIN_DELTA  500
0015 
0016 #ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT
0017 struct time_travel_event {
0018     unsigned long long time;
0019     void (*fn)(struct time_travel_event *d);
0020     struct list_head list;
0021     bool pending, onstack;
0022 };
0023 
0024 void time_travel_sleep(void);
0025 
0026 static inline void
0027 time_travel_set_event_fn(struct time_travel_event *e,
0028              void (*fn)(struct time_travel_event *d))
0029 {
0030     e->fn = fn;
0031 }
0032 
0033 void __time_travel_propagate_time(void);
0034 
0035 static inline void time_travel_propagate_time(void)
0036 {
0037     if (time_travel_mode == TT_MODE_EXTERNAL)
0038         __time_travel_propagate_time();
0039 }
0040 
0041 void __time_travel_wait_readable(int fd);
0042 
0043 static inline void time_travel_wait_readable(int fd)
0044 {
0045     if (time_travel_mode == TT_MODE_EXTERNAL)
0046         __time_travel_wait_readable(fd);
0047 }
0048 
0049 void time_travel_add_irq_event(struct time_travel_event *e);
0050 void time_travel_add_event_rel(struct time_travel_event *e,
0051                    unsigned long long delay_ns);
0052 bool time_travel_del_event(struct time_travel_event *e);
0053 #else
0054 struct time_travel_event {
0055 };
0056 
0057 static inline void time_travel_sleep(void)
0058 {
0059 }
0060 
0061 /* this is a macro so the event/function need not exist */
0062 #define time_travel_set_event_fn(e, fn) do {} while (0)
0063 
0064 static inline void time_travel_propagate_time(void)
0065 {
0066 }
0067 
0068 static inline void time_travel_wait_readable(int fd)
0069 {
0070 }
0071 
0072 static inline void time_travel_add_irq_event(struct time_travel_event *e)
0073 {
0074     WARN_ON(1);
0075 }
0076 
0077 /*
0078  * not inlines so the data structure need not exist,
0079  * cause linker failures
0080  */
0081 extern void time_travel_not_configured(void);
0082 #define time_travel_add_event_rel(...) time_travel_not_configured()
0083 #define time_travel_del_event(...) time_travel_not_configured()
0084 #endif /* CONFIG_UML_TIME_TRAVEL_SUPPORT */
0085 
0086 /*
0087  * Without CONFIG_UML_TIME_TRAVEL_SUPPORT this is a linker error if used,
0088  * which is intentional since we really shouldn't link it in that case.
0089  */
0090 void time_travel_ndelay(unsigned long nsec);
0091 #endif /* __TIMER_INTERNAL_H__ */