Subversion Repositories shark

Rev

Rev 242 | Rev 301 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
120 giacomo 1
/* Project:     OSLib
2
 * Description: The OS Construction Kit
3
 * Date:                1.6.2000
4
 * Idea by:             Luca Abeni & Gerardo Lamastra
5
 *
6
 * OSLib is an SO project aimed at developing a common, easy-to-use
7
 * low-level infrastructure for developing OS kernels and Embedded
8
 * Applications; it partially derives from the HARTIK project but it
9
 * currently is independently developed.
10
 *
11
 * OSLib is distributed under GPL License, and some of its code has
12
 * been derived from the Linux kernel source; also some important
13
 * ideas come from studying the DJGPP go32 extender.
14
 *
15
 * We acknowledge the Linux Community, Free Software Foundation,
16
 * D.J. Delorie and all the other developers who believe in the
17
 * freedom of software and ideas.
18
 *
19
 * For legalese, check out the included GPL license.
20
 */
21
 
22
/*      Advanced Timer
23
 *      Date: 8.4.2003
24
 *      Author: Giacomo Guidi <giacomo@gandalf.sssup.it>
25
 *
26
 */
27
 
28
#ifndef __ADVTIMER_H__
29
#define __ADVTIMER_H__
30
 
31
#include <ll/i386/defs.h>
32
BEGIN_DEF
33
 
34
/* TSC */
35
 
36
#define rdtsc(low,high) \
239 giacomo 37
     __asm__ __volatile__("xorl %%eax,%%eax\n\t" \
242 giacomo 38
                          "cpuid\n\t"            \
39
                          "rdtsc\n\t"            \
40
                          "movl %%eax,%%esi\n\t" \
41
                          "movl %%edx,%%edi\n\t" \
42
                          "xorl %%eax,%%eax\n\t" \
43
                          "cpuid"                \
44
                          : "=S" (low), "=D" (high) \
239 giacomo 45
                          :: "ebx", "ecx")
120 giacomo 46
 
47
#define rdtscll(val) \
239 giacomo 48
     __asm__ __volatile__("xorl %%eax,%%eax\n\t" \
242 giacomo 49
                          "cpuid\n\t"            \
50
                          "rdtsc\n\t"            \
51
                          "pushl %%eax\n\t"      \
52
                          "pushl %%edx\n\t"      \
53
                          "xorl %%eax,%%eax\n\t" \
54
                          "cpuid\n\t"            \
55
                          "popl %%edx\n\t"       \
56
                          "popl %%eax\n\t"       \
57
                          : "=A" (val)           \
239 giacomo 58
                          :: "ebx","ecx")
120 giacomo 59
 
299 giacomo 60
#define rdmsr(msr,val1,val2) \
61
     __asm__ __volatile__("rdmsr" \
62
                          : "=a" (val1), "=d" (val2) \
63
                          : "c" (msr))
64
 
65
#define wrmsr(msr,val1,val2) \
66
     __asm__ __volatile__("wrmsr" \
67
                          : /* no outputs */ \
68
                          : "c" (msr), "a" (val1), "d" (val2))
69
 
120 giacomo 70
/* RTC */
71
 
72
#define RTC_PORT(x)     (0x70 + (x))
73
 
74
#define CMOS_READ(addr,val)     \
75
{                               \
76
outp(RTC_PORT(0),(addr));       \
77
val = inp(RTC_PORT(1));         \
78
}
79
 
80
#define CMOS_WRITE(addr,val)    \
81
{                               \
82
outp(RTC_PORT(0),(addr));       \
83
outp(RTC_PORT(1),(val));        \
84
}
85
 
86
#define RTC_IRQ 8
87
 
131 giacomo 88
void ll_init_advtimer(void);
89
void ll_restore_CMOS(void);
90
 
120 giacomo 91
END_DEF
92
#endif