x86/bits32/segmentation.rs
1#[allow(unused_imports)]
2use crate::segmentation::SegmentSelector;
3
4#[cfg(target_arch = "x86")]
5use core::arch::asm;
6
7/// Reload code segment register.
8/// Note this is special since we can not directly move
9/// to %cs. Instead we push the new segment selector
10/// and return value on the stack and use lretl
11/// to reload cs and continue at 1:.
12#[cfg(target_arch = "x86")]
13pub unsafe fn load_cs(sel: SegmentSelector) {
14 asm!("pushl {0}; \
15 pushl $1f; \
16 lretl; \
17 1:", in(reg) sel.bits() as u32, options(att_syntax));
18}