git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refactor: rewrite kernel's make script
[lunaix-os.git]
/
lunaix-os
/
includes
/
hal
/
cpu.h
diff --git
a/lunaix-os/includes/hal/cpu.h
b/lunaix-os/includes/hal/cpu.h
index b155d4b57496e67a93b99e6ddd7a58432b599789..694d678afd52d5a7a5388d5056c42d02f12e092c 100644
(file)
--- a/
lunaix-os/includes/hal/cpu.h
+++ b/
lunaix-os/includes/hal/cpu.h
@@
-1,7
+1,9
@@
#ifndef __LUNAIX_CPU_H
#define __LUNAIX_CPU_H
#ifndef __LUNAIX_CPU_H
#define __LUNAIX_CPU_H
-#include <stdint.h>
+#include <lunaix/types.h>
+
+#define SEL_RPL(selector) ((selector)&0x3)
typedef unsigned int reg32;
typedef unsigned short reg16;
typedef unsigned int reg32;
typedef unsigned short reg16;
@@
-20,12
+22,10
@@
typedef struct
typedef struct
{
typedef struct
{
- reg16 ss;
- reg16 es;
reg16 ds;
reg16 ds;
+ reg16 es;
reg16 fs;
reg16 gs;
reg16 fs;
reg16 gs;
- reg16 cs;
} __attribute__((packed)) sg_reg;
void
} __attribute__((packed)) sg_reg;
void
@@
-39,35
+39,42
@@
cpu_has_apic();
static inline reg32
cpu_rcr0()
{
static inline reg32
cpu_rcr0()
{
-
uint
ptr_t val;
- asm volatile("movl %%cr0,%0" : "=r"
(val));
+ ptr_t val;
+ asm volatile("movl %%cr0,%0" : "=r"(val));
return val;
}
static inline reg32
cpu_rcr2()
{
return val;
}
static inline reg32
cpu_rcr2()
{
-
uint
ptr_t val;
- asm volatile("movl %%cr2,%0" : "=r"
(val));
+ ptr_t val;
+ asm volatile("movl %%cr2,%0" : "=r"(val));
return val;
}
static inline reg32
cpu_rcr3()
{
return val;
}
static inline reg32
cpu_rcr3()
{
- uintptr_t val;
- asm volatile("movl %%cr3,%0" : "=r" (val));
+ ptr_t val;
+ asm volatile("movl %%cr3,%0" : "=r"(val));
+ return val;
+}
+
+static inline reg32
+cpu_rcr4()
+{
+ ptr_t val;
+ asm volatile("movl %%cr4,%0" : "=r"(val));
return val;
}
static inline reg32
cpu_reflags()
{
return val;
}
static inline reg32
cpu_reflags()
{
- uintptr_t val;
- asm volatile(
- "pushf\n"
- "popl %0\n"
- :"=r"(val)::);
+ ptr_t val;
+ asm volatile("pushf\n"
+ "popl %0\n"
+ : "=r"(val)::);
return val;
}
#pragma GCC diagnostic pop
return val;
}
#pragma GCC diagnostic pop
@@
-91,9
+98,9
@@
cpu_lcr3(reg32 v)
}
static inline void
}
static inline void
-cpu_invplg(
void*
va)
+cpu_invplg(
ptr_t
va)
{
{
- asm volatile("invlpg (%0)" ::"r"(
(uintptr_t)
va) : "memory");
+ asm volatile("invlpg (%0)" ::"r"(va) : "memory");
}
static inline void
}
static inline void
@@
-118,10
+125,16
@@
cpu_invtlb()
: "r"(interm));
}
: "r"(interm));
}
+static inline void
+cpu_int(int vect)
+{
+ asm("int %0" ::"i"(vect));
+}
+
void
void
-cpu_rdmsr(u
int32_t msr_idx, uint32_t* reg_high, uint
32_t* reg_low);
+cpu_rdmsr(u
32_t msr_idx, u32_t* reg_high, u
32_t* reg_low);
void
void
-cpu_wrmsr(u
int32_t msr_idx, uint32_t reg_high, uint
32_t reg_low);
+cpu_wrmsr(u
32_t msr_idx, u32_t reg_high, u
32_t reg_low);
#endif
\ No newline at end of file
#endif
\ No newline at end of file