File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -123,6 +123,12 @@ _x86_64_asm_lidt:
123
123
lidt (%rdi )
124
124
retq
125
125
126
+ .global _x86_64_asm_sgdt
127
+ .p2align 4
128
+ _x86_64_asm_sgdt:
129
+ sgdt (%rdi )
130
+ retq
131
+
126
132
.global _x86_64_asm_sidt
127
133
.p2align 4
128
134
_x86_64_asm_sidt:
Original file line number Diff line number Diff line change @@ -168,6 +168,12 @@ extern "sysv64" {
168
168
) ]
169
169
pub ( crate ) fn x86_64_asm_lidt ( idt : * const crate :: instructions:: tables:: DescriptorTablePointer ) ;
170
170
171
+ #[ cfg_attr(
172
+ any( target_env = "gnu" , target_env = "musl" ) ,
173
+ link_name = "_x86_64_asm_sgdt"
174
+ ) ]
175
+ pub ( crate ) fn x86_64_asm_sgdt ( gdt : * mut crate :: instructions:: tables:: DescriptorTablePointer ) ;
176
+
171
177
#[ cfg_attr(
172
178
any( target_env = "gnu" , target_env = "musl" ) ,
173
179
link_name = "_x86_64_asm_sidt"
Original file line number Diff line number Diff line change @@ -45,6 +45,23 @@ pub unsafe fn lidt(idt: &DescriptorTablePointer) {
45
45
crate :: asm:: x86_64_asm_lidt ( idt as * const _ ) ;
46
46
}
47
47
48
+ /// Get the address of the current GDT.
49
+ #[ inline]
50
+ pub fn sgdt ( ) -> DescriptorTablePointer {
51
+ let mut gdt: DescriptorTablePointer = DescriptorTablePointer {
52
+ limit : 0 ,
53
+ base : VirtAddr :: new ( 0 ) ,
54
+ } ;
55
+ unsafe {
56
+ #[ cfg( feature = "inline_asm" ) ]
57
+ asm ! ( "sgdt [{}]" , in( reg) & mut gdt, options( nostack, preserves_flags) ) ;
58
+
59
+ #[ cfg( not( feature = "inline_asm" ) ) ]
60
+ crate :: asm:: x86_64_asm_sgdt ( & mut gdt as * mut _ ) ;
61
+ }
62
+ gdt
63
+ }
64
+
48
65
/// Get the address of the current IDT.
49
66
#[ inline]
50
67
pub fn sidt ( ) -> DescriptorTablePointer {
You can’t perform that action at this time.
0 commit comments