Subversion Repositories HelenOS-historic

Rev

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

Rev 195 Rev 348
Line 28... Line 28...
28
 
28
 
29
#ifndef __ia32_ASM_H__
29
#ifndef __ia32_ASM_H__
30
#define __ia32_ASM_H__
30
#define __ia32_ASM_H__
31
 
31
 
32
#include <arch/types.h>
32
#include <arch/types.h>
33
#include <typedefs.h>
-
 
34
#include <config.h>
-
 
35
#include <synch/spinlock.h>
-
 
36
#include <arch/boot/memmap.h>
-
 
37
#include <config.h>
33
#include <config.h>
38
 
34
 
39
extern __u32 interrupt_handler_size;
35
extern __u32 interrupt_handler_size;
40
 
36
 
41
extern void paging_on(void);
37
extern void paging_on(void);
Line 59... Line 55...
59
 
55
 
60
/** Halt CPU
56
/** Halt CPU
61
 *
57
 *
62
 * Halt the current CPU until interrupt event.
58
 * Halt the current CPU until interrupt event.
63
 */
59
 */
64
static inline void cpu_halt(void) { __asm__("hlt"); };
60
static inline void cpu_halt(void) { __asm__("hlt\n"); };
65
static inline void cpu_sleep(void) { __asm__("hlt"); };
61
static inline void cpu_sleep(void) { __asm__("hlt\n"); };
66
 
62
 
67
/** Read CR2
63
/** Read CR2
68
 *
64
 *
69
 * Return value in CR2
65
 * Return value in CR2
70
 *
66
 *
71
 * @return Value read.
67
 * @return Value read.
72
 */
68
 */
73
static inline __u32 read_cr2(void) { __u32 v; __asm__ volatile ("movl %%cr2,%0" : "=r" (v)); return v; }
69
static inline __u32 read_cr2(void) { __u32 v; __asm__ volatile ("movl %%cr2,%0\n" : "=r" (v)); return v; }
74
 
70
 
75
/** Write CR3
71
/** Write CR3
76
 *
72
 *
77
 * Write value to CR3.
73
 * Write value to CR3.
78
 *
74
 *
Line 84... Line 80...
84
 *
80
 *
85
 * Return value in CR3
81
 * Return value in CR3
86
 *
82
 *
87
 * @return Value read.
83
 * @return Value read.
88
 */
84
 */
89
static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0" : "=r" (v)); return v; }
85
static inline __u32 read_cr3(void) { __u32 v; __asm__ volatile ("movl %%cr3,%0\n" : "=r" (v)); return v; }
90
 
86
 
91
/** Set priority level low
87
/** Set priority level low
92
 *
88
 *
93
 * Enable interrupts and return previous
89
 * Enable interrupts and return previous
94
 * value of EFLAGS.
90
 * value of EFLAGS.
Line 159... Line 155...
159
    __asm__ volatile ("andl %%esp, %0\n" : "=r" (v) : "0" (~(STACK_SIZE-1)));
155
    __asm__ volatile ("andl %%esp, %0\n" : "=r" (v) : "0" (~(STACK_SIZE-1)));
160
   
156
   
161
    return v;
157
    return v;
162
}
158
}
163
 
159
 
-
 
160
static inline __u64 rdtsc(void)
-
 
161
{
-
 
162
    __u64 v;
-
 
163
   
-
 
164
    __asm__ volatile("rdtsc\n" : "=A" (v));
-
 
165
   
-
 
166
    return v;
-
 
167
}
-
 
168
 
164
#endif
169
#endif