Changeset 4b662f8c in mainline for kernel/generic/src/time/clock.c
- Timestamp:
- 2007-04-20T18:43:49Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ea63704
- Parents:
- cc85fb9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/time/clock.c
rcc85fb9 r4b662f8c 42 42 #include <time/clock.h> 43 43 #include <time/timeout.h> 44 #include <arch/types.h>45 44 #include <config.h> 46 45 #include <synch/spinlock.h> … … 58 57 #include <ddi/ddi.h> 59 58 60 /** Physical memory area of the real time clock. */ 59 /* Pointer to variable with uptime */ 60 uptime_t *uptime; 61 62 /** Physical memory area of the real time clock */ 61 63 static parea_t clock_parea; 62 64 63 /* Pointers to public variables with time */64 struct ptime {65 unative_t seconds1;66 unative_t useconds;67 unative_t seconds2;68 };69 struct ptime *public_time;70 65 /* Variable holding fragment of second, so that we would update 71 66 * seconds correctly … … 87 82 panic("Cannot allocate page for clock"); 88 83 89 public_time = (struct ptime *) PA2KA(faddr); 90 91 /* TODO: We would need some arch dependent settings here */ 92 public_time->seconds1 = 0; 93 public_time->seconds2 = 0; 94 public_time->useconds = 0; 84 uptime = (uptime_t *) PA2KA(faddr); 85 86 uptime->seconds1 = 0; 87 uptime->seconds2 = 0; 88 uptime->useconds = 0; 95 89 96 90 clock_parea.pbase = (uintptr_t) faddr; 97 clock_parea.vbase = (uintptr_t) public_time;91 clock_parea.vbase = (uintptr_t) uptime; 98 92 clock_parea.frames = 1; 99 93 clock_parea.cacheable = true; … … 117 111 { 118 112 if (CPU->id == 0) { 119 secfrag += 1000000 /HZ;113 secfrag += 1000000 / HZ; 120 114 if (secfrag >= 1000000) { 121 115 secfrag -= 1000000; 122 public_time->seconds1++;116 uptime->seconds1++; 123 117 write_barrier(); 124 public_time->useconds = secfrag;118 uptime->useconds = secfrag; 125 119 write_barrier(); 126 public_time->seconds2 = public_time->seconds1;120 uptime->seconds2 = uptime->seconds1; 127 121 } else 128 public_time->useconds += 1000000/HZ;122 uptime->useconds += 1000000 / HZ; 129 123 } 130 124 }
Note:
See TracChangeset
for help on using the changeset viewer.