-
Notifications
You must be signed in to change notification settings - Fork 215
Add a Cargo Feature for Enabling SSE #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
5b4f796
fa61c65
3f84e5c
61b6534
1b59b4d
59e87f2
a05b9cb
81315b6
12b3c8b
e8b3a39
837ea1c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ xmas-elf = { version = "0.6.2", optional = true } | |||||
x86_64 = { version = "0.7.2", optional = true } | ||||||
usize_conversions = { version = "0.2.0", optional = true } | ||||||
fixedvec = { version = "0.2.4", optional = true } | ||||||
bit_field = "*" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, please make this dependency optional like the other dependencies above. |
||||||
|
||||||
[dependencies.font8x8] | ||||||
version = "0.2.4" | ||||||
|
@@ -34,6 +35,7 @@ binary = ["xmas-elf", "x86_64", "usize_conversions", "fixedvec", "llvm-tools", " | |||||
vga_320x200 = ["font8x8"] | ||||||
recursive_page_table = [] | ||||||
map_physical_memory = [] | ||||||
sse = [] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After making the
Suggested change
|
||||||
|
||||||
[profile.dev] | ||||||
panic = "abort" | ||||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,6 +87,30 @@ extern "C" { | |
|
||
#[no_mangle] | ||
pub unsafe extern "C" fn stage_4() -> ! { | ||
#[cfg(feature = "sse")] | ||
{ | ||
use bit_field::BitField; | ||
use x86_64::registers::control::Cr0; | ||
let mut flags = Cr0::read_raw(); | ||
flags.set_bit(2, false); | ||
flags.set_bit(1, true); | ||
flags.set_bit(9, true); | ||
flags.set_bit(10, true); | ||
unsafe { | ||
Cr0::write_raw(flags); | ||
} | ||
// For now, we must use inline ASM here | ||
let mut cr4: u64; | ||
unsafe { | ||
asm!("mov %cr4, $0" : "=r" (cr4)); | ||
} | ||
cr4.set_bit(9, true); | ||
cr4.set_bit(10, true); | ||
unsafe { | ||
asm!("mov $0, %cr4" :: "r" (cr4) : "memory"); | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you move this into an |
||
// Set stack segment | ||
asm!("mov bx, 0x0 | ||
mov ss, bx" ::: "bx" : "intel"); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ edition = "2018" | |
|
||
[dependencies] | ||
x86_64 = "0.3.4" | ||
bootloader = {path = "..", features=["sse"]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is a good way to test it because we no longer test it without the I think the best way forward is to merge this without tests (undoing the modifications to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wildcard dependencies are not recommended because cargo might select an incompatible version. For example, it can lead to compilation failures when another dependency requires a very old version of bit_field. Just set it to the latest version (0.10.0) instead.