mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
Kernel: Add read_gs_value() and write_gs_value()
Co-authored-by: Tom <tomut@yahoo.com>
This commit is contained in:
parent
6ae60137d7
commit
249d6a490d
1 changed files with 19 additions and 0 deletions
|
@ -62,6 +62,25 @@ ALWAYS_INLINE u16 get_gs()
|
|||
}
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE T read_gs_value(FlatPtr offset)
|
||||
{
|
||||
T val;
|
||||
asm volatile(
|
||||
"mov %%gs:%a[off], %[val]"
|
||||
: [val] "=r"(val)
|
||||
: [off] "ir"(offset));
|
||||
return val;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
ALWAYS_INLINE void write_gs_value(FlatPtr offset, T val)
|
||||
{
|
||||
asm volatile(
|
||||
"mov %[val], %%gs:%a[off]" ::[off] "ir"(offset), [val] "r"(val)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE FlatPtr read_gs_ptr(FlatPtr offset)
|
||||
{
|
||||
FlatPtr val;
|
||||
|
|
Loading…
Add table
Reference in a new issue