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:
123123 lidt (%rdi )
124124 retq
125125
126+ .global _x86_64_asm_sgdt
127+ .p2align 4
128+ _x86_64_asm_sgdt:
129+ sgdt (%rdi )
130+ retq
131+
126132.global _x86_64_asm_sidt
127133.p2align 4
128134_x86_64_asm_sidt:
Original file line number Diff line number Diff line change @@ -168,6 +168,12 @@ extern "sysv64" {
168168 ) ]
169169 pub ( crate ) fn x86_64_asm_lidt ( idt : * const crate :: instructions:: tables:: DescriptorTablePointer ) ;
170170
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+
171177 #[ cfg_attr(
172178 any( target_env = "gnu" , target_env = "musl" ) ,
173179 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) {
4545 crate :: asm:: x86_64_asm_lidt ( idt as * const _ ) ;
4646}
4747
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+
4865/// Get the address of the current IDT.
4966#[ inline]
5067pub fn sidt ( ) -> DescriptorTablePointer {
You can’t perform that action at this time.
0 commit comments