Skip to content

Commit 9cb851a

Browse files
committed
Cleanup Segment macros
We no longer use the symbols for the external assembly, so we can simplify the macros. Signed-off-by: Joe Richey <[email protected]>
1 parent 3cae23e commit 9cb851a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/instructions/segmentation.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
use core::arch::asm;
1010

1111
macro_rules! get_reg_impl {
12-
($name:literal, $asm_get:ident) => {
12+
($name:literal) => {
1313
fn get_reg() -> SegmentSelector {
1414
let segment: u16;
1515
unsafe {
@@ -21,9 +21,9 @@ macro_rules! get_reg_impl {
2121
}
2222

2323
macro_rules! segment_impl {
24-
($type:ty, $name:literal, $asm_get:ident, $asm_load:ident) => {
24+
($type:ty, $name:literal) => {
2525
impl Segment for $type {
26-
get_reg_impl!($name, $asm_get);
26+
get_reg_impl!($name);
2727

2828
unsafe fn set_reg(sel: SegmentSelector) {
2929
unsafe {
@@ -35,7 +35,7 @@ macro_rules! segment_impl {
3535
}
3636

3737
macro_rules! segment64_impl {
38-
($type:ty, $name:literal, $base:ty, $asm_rd:ident, $asm_wr:ident) => {
38+
($type:ty, $name:literal, $base:ty) => {
3939
impl Segment64 for $type {
4040
const BASE: Msr = <$base>::MSR;
4141
fn read_base() -> VirtAddr {
@@ -56,7 +56,7 @@ macro_rules! segment64_impl {
5656
}
5757

5858
impl Segment for CS {
59-
get_reg_impl!("cs", x86_64_asm_get_cs);
59+
get_reg_impl!("cs");
6060

6161
/// Note this is special since we cannot directly move to [`CS`]; x86 requires the instruction
6262
/// pointer and [`CS`] to be set at the same time. To do this, we push the new segment selector
@@ -82,13 +82,13 @@ impl Segment for CS {
8282
}
8383
}
8484

85-
segment_impl!(SS, "ss", x86_64_asm_get_ss, x86_64_asm_load_ss);
86-
segment_impl!(DS, "ds", x86_64_asm_get_ds, x86_64_asm_load_ds);
87-
segment_impl!(ES, "es", x86_64_asm_get_es, x86_64_asm_load_es);
88-
segment_impl!(FS, "fs", x86_64_asm_get_fs, x86_64_asm_load_fs);
89-
segment64_impl!(FS, "fs", FsBase, x86_64_asm_rdfsbase, x86_64_asm_wrfsbase);
90-
segment_impl!(GS, "gs", x86_64_asm_get_gs, x86_64_asm_load_gs);
91-
segment64_impl!(GS, "gs", GsBase, x86_64_asm_rdgsbase, x86_64_asm_wrgsbase);
85+
segment_impl!(SS, "ss");
86+
segment_impl!(DS, "ds");
87+
segment_impl!(ES, "es");
88+
segment_impl!(FS, "fs");
89+
segment64_impl!(FS, "fs", FsBase);
90+
segment_impl!(GS, "gs");
91+
segment64_impl!(GS, "gs", GsBase);
9292

9393
impl GS {
9494
/// Swap `KernelGsBase` MSR and `GsBase` MSR.

0 commit comments

Comments
 (0)