forked from xt-sys/exectos
Add more intrinsic routines
This commit is contained in:
parent
bff460a879
commit
fb60625abc
@ -75,6 +75,23 @@ XTCDECL
|
|||||||
VOID
|
VOID
|
||||||
HlSetInterruptFlag();
|
HlSetInterruptFlag();
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreGlobalDescriptorTable(OUT PVOID Destination);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreInterruptDescriptorTable(OUT PVOID Destination);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreSegment(IN USHORT Segment,
|
||||||
|
OUT PVOID Destination);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreTaskRegister(OUT PVOID Destination);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
HlWriteControlRegister(IN USHORT ControlRegister,
|
HlWriteControlRegister(IN USHORT ControlRegister,
|
||||||
|
@ -49,6 +49,14 @@
|
|||||||
#define CR4_XSAVE 0x00020000
|
#define CR4_XSAVE 0x00020000
|
||||||
#define CR4_RESERVED3 0xFFFC0000
|
#define CR4_RESERVED3 0xFFFC0000
|
||||||
|
|
||||||
|
/* Segment defintions */
|
||||||
|
#define SEGMENT_CS 0x2E
|
||||||
|
#define SEGMENT_DS 0x3E
|
||||||
|
#define SEGMENT_ES 0x26
|
||||||
|
#define SEGMENT_SS 0x36
|
||||||
|
#define SEGMENT_FS 0x64
|
||||||
|
#define SEGMENT_GS 0x65
|
||||||
|
|
||||||
/* CPUID features enumeration list */
|
/* CPUID features enumeration list */
|
||||||
typedef enum _CPUID_FEATURES
|
typedef enum _CPUID_FEATURES
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,23 @@ XTCDECL
|
|||||||
VOID
|
VOID
|
||||||
HlSetInterruptFlag();
|
HlSetInterruptFlag();
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreGlobalDescriptorTable(OUT PVOID Destination);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreInterruptDescriptorTable(OUT PVOID Destination);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreSegment(IN USHORT Segment,
|
||||||
|
OUT PVOID Destination);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreTaskRegister(OUT PVOID Destination);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
HlWriteControlRegister(IN USHORT ControlRegister,
|
HlWriteControlRegister(IN USHORT ControlRegister,
|
||||||
|
@ -49,6 +49,14 @@
|
|||||||
#define CR4_XSAVE 0x00020000
|
#define CR4_XSAVE 0x00020000
|
||||||
#define CR4_RESERVED3 0xFFFC0000
|
#define CR4_RESERVED3 0xFFFC0000
|
||||||
|
|
||||||
|
/* Segment defintions */
|
||||||
|
#define SEGMENT_CS 0x2E
|
||||||
|
#define SEGMENT_DS 0x3E
|
||||||
|
#define SEGMENT_ES 0x26
|
||||||
|
#define SEGMENT_SS 0x36
|
||||||
|
#define SEGMENT_FS 0x64
|
||||||
|
#define SEGMENT_GS 0x65
|
||||||
|
|
||||||
/* CPUID features enumeration list */
|
/* CPUID features enumeration list */
|
||||||
typedef enum _CPUID_FEATURES
|
typedef enum _CPUID_FEATURES
|
||||||
{
|
{
|
||||||
|
@ -357,6 +357,116 @@ HlSetInterruptFlag()
|
|||||||
asm volatile("sti");
|
asm volatile("sti");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores GDT register into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where GDT will be stored.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreGlobalDescriptorTable(OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
asm volatile("sgdt %0"
|
||||||
|
:
|
||||||
|
: "m" (*(PSHORT)Destination)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores IDT register into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where IDT will be stored.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreInterruptDescriptorTable(OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
asm volatile("sidt %0"
|
||||||
|
:
|
||||||
|
: "m" (*(PSHORT)Destination)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores specified segment into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Segment
|
||||||
|
* Supplies a segment identification.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where segment data will be stored.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreSegment(IN USHORT Segment,
|
||||||
|
OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
switch(Segment)
|
||||||
|
{
|
||||||
|
case SEGMENT_CS:
|
||||||
|
asm volatile("movl %%cs, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_DS:
|
||||||
|
asm volatile("movl %%ds, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_ES:
|
||||||
|
asm volatile("movl %%es, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_FS:
|
||||||
|
asm volatile("movl %%fs, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_GS:
|
||||||
|
asm volatile("movl %%gs, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_SS:
|
||||||
|
asm volatile("movl %%ss, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Destination = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores TR into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where TR will be stores.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreTaskRegister(OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
asm volatile("str %0"
|
||||||
|
:
|
||||||
|
: "m" (*(PULONG)Destination)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a value to the specified CPU control register.
|
* Writes a value to the specified CPU control register.
|
||||||
*
|
*
|
||||||
|
@ -348,6 +348,116 @@ HlSetInterruptFlag()
|
|||||||
asm volatile("sti");
|
asm volatile("sti");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores GDT register into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where GDT will be stored.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreGlobalDescriptorTable(OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
asm volatile("sgdt %0"
|
||||||
|
:
|
||||||
|
: "m" (*(PSHORT)Destination)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores IDT register into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where IDT will be stored.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreInterruptDescriptorTable(OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
asm volatile("sidt %0"
|
||||||
|
:
|
||||||
|
: "m" (*(PSHORT)Destination)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores specified segment into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Segment
|
||||||
|
* Supplies a segment identification.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where segment data will be stored.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreSegment(IN USHORT Segment,
|
||||||
|
OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
switch(Segment)
|
||||||
|
{
|
||||||
|
case SEGMENT_CS:
|
||||||
|
asm volatile("movl %%cs, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_DS:
|
||||||
|
asm volatile("movl %%ds, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_ES:
|
||||||
|
asm volatile("movl %%es, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_FS:
|
||||||
|
asm volatile("movl %%fs, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_GS:
|
||||||
|
asm volatile("movl %%gs, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
case SEGMENT_SS:
|
||||||
|
asm volatile("movl %%ss, %0"
|
||||||
|
: "=r" (*(PUINT)Destination));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Destination = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores TR into the given memory area.
|
||||||
|
*
|
||||||
|
* @param Destination
|
||||||
|
* Supplies a pointer to the memory area where TR will be stores.
|
||||||
|
*
|
||||||
|
* @return This routine does not return any value.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
VOID
|
||||||
|
HlStoreTaskRegister(OUT PVOID Destination)
|
||||||
|
{
|
||||||
|
asm volatile("str %0"
|
||||||
|
:
|
||||||
|
: "m" (*(PULONG)Destination)
|
||||||
|
: "memory");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a value to the specified CPU control register.
|
* Writes a value to the specified CPU control register.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user