Subversion Repositories HelenOS

Rev

Rev 1787 | Rev 2071 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1787 Rev 2015
Line 52... Line 52...
52
#include <adt/list.h>
52
#include <adt/list.h>
53
#include <atomic.h>
53
#include <atomic.h>
54
#include <proc/thread.h>
54
#include <proc/thread.h>
55
#include <sysinfo/sysinfo.h>
55
#include <sysinfo/sysinfo.h>
56
#include <arch/barrier.h>
56
#include <arch/barrier.h>
-
 
57
#include <mm/frame.h>
-
 
58
#include <ddi/ddi.h>
-
 
59
 
-
 
60
/** Physical memory area of the real time clock. */
-
 
61
static parea_t clock_parea;
57
 
62
 
58
/* Pointers to public variables with time */
63
/* Pointers to public variables with time */
59
struct ptime {
64
struct ptime {
60
    unative_t seconds1;
65
    unative_t seconds1;
61
    unative_t useconds;
66
    unative_t useconds;
Line 70... Line 75...
70
/** Initialize realtime clock counter
75
/** Initialize realtime clock counter
71
 *
76
 *
72
 * The applications (and sometimes kernel) need to access accurate
77
 * The applications (and sometimes kernel) need to access accurate
73
 * information about realtime data. We allocate 1 page with these
78
 * information about realtime data. We allocate 1 page with these
74
 * data and update it periodically.
79
 * data and update it periodically.
75
 *
-
 
76
 *
-
 
77
 */
80
 */
78
void clock_counter_init(void)
81
void clock_counter_init(void)
79
{
82
{
80
    void *faddr;
83
    void *faddr;
81
 
84
 
82
    faddr = frame_alloc(0, FRAME_ATOMIC);
85
    faddr = frame_alloc(ONE_FRAME, FRAME_ATOMIC);
83
    if (!faddr)
86
    if (!faddr)
84
        panic("Cannot allocate page for clock");
87
        panic("Cannot allocate page for clock");
85
   
88
   
86
    public_time = (struct ptime *)PA2KA(faddr);
89
    public_time = (struct ptime *) PA2KA(faddr);
87
 
90
 
88
        /* TODO: We would need some arch dependent settings here */
91
        /* TODO: We would need some arch dependent settings here */
89
    public_time->seconds1 = 0;
92
    public_time->seconds1 = 0;
90
    public_time->seconds2 = 0;
93
    public_time->seconds2 = 0;
91
    public_time->useconds = 0;
94
    public_time->useconds = 0;
92
 
95
 
-
 
96
    clock_parea.pbase = (uintptr_t) faddr;
-
 
97
    clock_parea.vbase = (uintptr_t) public_time;
-
 
98
    clock_parea.frames = 1;
-
 
99
    clock_parea.cacheable = true;
-
 
100
    ddi_parea_register(&clock_parea);
-
 
101
 
-
 
102
    /*
-
 
103
     * Prepare information for the userspace so that it can successfully
-
 
104
     * physmem_map() the clock_parea.
-
 
105
     */
-
 
106
    sysinfo_set_item_val("clock.cacheable", NULL, (unative_t) true);
-
 
107
    sysinfo_set_item_val("clock.fcolor", NULL, (unative_t)
-
 
108
        PAGE_COLOR(clock_parea.vbase));
93
    sysinfo_set_item_val("clock.faddr", NULL, (unative_t)faddr);
109
    sysinfo_set_item_val("clock.faddr", NULL, (unative_t) faddr);
94
}
110
}
95
 
111
 
96
 
112
 
97
/** Update public counters
113
/** Update public counters
98
 *
114
 *