1 #include <stdint.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4
5 #define __TEST__
6 #include <timer.h>
7 #include <skiboot.h>
8
9 #define mftb() (stamp)
10 #define sync()
11 #define smt_lowest()
12 #define smt_medium()
13
14 enum proc_gen proc_gen = proc_gen_p9;
15
16 static uint64_t stamp, last;
17 struct lock;
lock_caller(struct lock * l,const char * caller)18 static inline void lock_caller(struct lock *l, const char *caller)
19 {
20 (void)caller;
21 (void)l;
22 }
unlock(struct lock * l)23 static inline void unlock(struct lock *l) { (void)l; }
24
25 unsigned long tb_hz = 512000000;
26
27 #include "../timer.c"
28
29 #define NUM_TIMERS 100
30
31 static struct timer timers[NUM_TIMERS];
32 static unsigned int rand_shift, count;
33
init_rand(void)34 static void init_rand(void)
35 {
36 unsigned long max = RAND_MAX;
37
38 /* Get something reasonably small */
39 while(max > 0x10000) {
40 rand_shift++;
41 max >>= 1;
42 }
43 }
44
expiry(struct timer * t,void * data,uint64_t now)45 static void expiry(struct timer *t, void *data, uint64_t now)
46 {
47 (void)data;
48 (void)now;
49 assert(t->target >= last);
50 count--;
51 }
52
p8_sbe_update_timer_expiry(uint64_t new_target)53 void p8_sbe_update_timer_expiry(uint64_t new_target)
54 {
55 (void)new_target;
56 /* FIXME: do intersting SLW timer sim */
57 }
58
p9_sbe_update_timer_expiry(uint64_t new_target)59 void p9_sbe_update_timer_expiry(uint64_t new_target)
60 {
61 (void)new_target;
62 }
63
main(void)64 int main(void)
65 {
66 unsigned int i;
67
68 init_rand();
69 for (i = 0; i < NUM_TIMERS; i++) {
70 init_timer(&timers[i], expiry, NULL);
71 schedule_timer(&timers[i], random() >> rand_shift);
72 }
73 count = NUM_TIMERS;
74 while(count) {
75 check_timers(false);
76 stamp++;
77 }
78 return 0;
79 }
80