Rev 1434 | Rev 1457 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1434 | Rev 1438 | ||
---|---|---|---|
Line 51... | Line 51... | ||
51 | #include <sysinfo/sysinfo.h> |
51 | #include <sysinfo/sysinfo.h> |
52 | #include <arch/barrier.h> |
52 | #include <arch/barrier.h> |
53 | 53 | ||
54 | /* Pointers to public variables with time */ |
54 | /* Pointers to public variables with time */ |
55 | struct ptime { |
55 | struct ptime { |
56 | __native seconds; |
56 | __native seconds1; |
57 | __native useconds; |
57 | __native useconds; |
58 | __native useconds2; |
58 | __native seconds2; |
59 | }; |
59 | }; |
60 | struct ptime *public_time; |
60 | struct ptime *public_time; |
61 | /* Variable holding fragment of second, so that we would update |
61 | /* Variable holding fragment of second, so that we would update |
62 | * seconds correctly |
62 | * seconds correctly |
63 | */ |
63 | */ |
Line 80... | Line 80... | ||
80 | panic("Cannot allocate page for clock"); |
80 | panic("Cannot allocate page for clock"); |
81 | 81 | ||
82 | public_time = (struct ptime *)PA2KA(faddr); |
82 | public_time = (struct ptime *)PA2KA(faddr); |
83 | 83 | ||
84 | /* TODO: We would need some arch dependent settings here */ |
84 | /* TODO: We would need some arch dependent settings here */ |
- | 85 | public_time->seconds1 = 0; |
|
85 | public_time->seconds = 0; |
86 | public_time->seconds2 = 0; |
86 | public_time->useconds = 0; |
87 | public_time->useconds = 0; |
87 | 88 | ||
88 | sysinfo_set_item_val("clock.faddr", NULL, (__native)faddr); |
89 | sysinfo_set_item_val("clock.faddr", NULL, (__native)faddr); |
89 | } |
90 | } |
90 | 91 | ||
Line 97... | Line 98... | ||
97 | static void clock_update_counters(void) |
98 | static void clock_update_counters(void) |
98 | { |
99 | { |
99 | if (CPU->id == 0) { |
100 | if (CPU->id == 0) { |
100 | secfrag += 1000000/HZ; |
101 | secfrag += 1000000/HZ; |
101 | if (secfrag >= 1000000) { |
102 | if (secfrag >= 1000000) { |
- | 103 | secfrag -= 1000000; |
|
102 | public_time->useconds = 0; |
104 | public_time->seconds1++; |
103 | write_barrier(); |
105 | write_barrier(); |
104 | public_time->seconds++; |
106 | public_time->useconds = secfrag; |
105 | secfrag = 0; |
107 | write_barrier(); |
- | 108 | public_time->seconds2 = public_time->seconds1; |
|
106 | } else |
109 | } else |
107 | public_time->useconds += 1000000/HZ; |
110 | public_time->useconds += 1000000/HZ; |
108 | write_barrier(); |
- | |
109 | public_time->useconds2 = public_time->useconds; |
- | |
110 | write_barrier(); |
- | |
111 | } |
111 | } |
112 | } |
112 | } |
113 | 113 | ||
114 | /** Clock routine |
114 | /** Clock routine |
115 | * |
115 | * |