Line data Source code
1 : /* SPDX-License-Identifier: GPL-2.0 */ 2 : /* 3 : * Copyright (C) 2012 - 2014 Cisco Systems 4 : * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 5 : */ 6 : 7 : #ifndef __TIMER_INTERNAL_H__ 8 : #define __TIMER_INTERNAL_H__ 9 : #include <linux/list.h> 10 : #include <asm/bug.h> 11 : #include <shared/timetravel.h> 12 : 13 : #define TIMER_MULTIPLIER 256 14 : #define TIMER_MIN_DELTA 500 15 : 16 : #ifdef CONFIG_UML_TIME_TRAVEL_SUPPORT 17 : struct time_travel_event { 18 : unsigned long long time; 19 : void (*fn)(struct time_travel_event *d); 20 : struct list_head list; 21 : bool pending, onstack; 22 : }; 23 : 24 : void time_travel_sleep(void); 25 : 26 : static inline void 27 : time_travel_set_event_fn(struct time_travel_event *e, 28 : void (*fn)(struct time_travel_event *d)) 29 : { 30 : e->fn = fn; 31 : } 32 : 33 : void __time_travel_propagate_time(void); 34 : 35 : static inline void time_travel_propagate_time(void) 36 : { 37 : if (time_travel_mode == TT_MODE_EXTERNAL) 38 : __time_travel_propagate_time(); 39 : } 40 : 41 : void __time_travel_wait_readable(int fd); 42 : 43 : static inline void time_travel_wait_readable(int fd) 44 : { 45 : if (time_travel_mode == TT_MODE_EXTERNAL) 46 : __time_travel_wait_readable(fd); 47 : } 48 : 49 : void time_travel_add_irq_event(struct time_travel_event *e); 50 : void time_travel_add_event_rel(struct time_travel_event *e, 51 : unsigned long long delay_ns); 52 : bool time_travel_del_event(struct time_travel_event *e); 53 : #else 54 : struct time_travel_event { 55 : }; 56 : 57 : static inline void time_travel_sleep(void) 58 : { 59 : } 60 : 61 : /* this is a macro so the event/function need not exist */ 62 : #define time_travel_set_event_fn(e, fn) do {} while (0) 63 : 64 : static inline void time_travel_propagate_time(void) 65 : { 66 : } 67 : 68 : static inline void time_travel_wait_readable(int fd) 69 : { 70 : } 71 : 72 : static inline void time_travel_add_irq_event(struct time_travel_event *e) 73 : { 74 0 : WARN_ON(1); 75 : } 76 : 77 : /* 78 : * not inlines so the data structure need not exist, 79 : * cause linker failures 80 : */ 81 : extern void time_travel_not_configured(void); 82 : #define time_travel_add_event_rel(...) time_travel_not_configured() 83 : #define time_travel_del_event(...) time_travel_not_configured() 84 : #endif /* CONFIG_UML_TIME_TRAVEL_SUPPORT */ 85 : 86 : /* 87 : * Without CONFIG_UML_TIME_TRAVEL_SUPPORT this is a linker error if used, 88 : * which is intentional since we really shouldn't link it in that case. 89 : */ 90 : void time_travel_ndelay(unsigned long nsec); 91 : #endif /* __TIMER_INTERNAL_H__ */