-
Notifications
You must be signed in to change notification settings - Fork 231
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5b4f796
The bootloader now implements SSE and AVX support and enables AVX if …
ethindp fa61c65
Rewrote SSE code in rust using inline ASM and made SSE and AVX features.
ethindp 3f84e5c
Deleted SSE assembly and formatted code.
ethindp 61b6534
Aded a use statement to fix a compile error.
ethindp 1b59b4d
Removed AVX support.
ethindp 59e87f2
Tested SSE support and formatted code.
ethindp a05b9cb
Formatted code and ensured that the bootloader *actually* built.
ethindp 81315b6
Got SSE t ofinally work (haven't committed in a while because of lack…
ethindp 12b3c8b
Aded bit_field dependency. Formatted code.
ethindp e8b3a39
Moved SSE into its own module. Made deps for SSE entirely optional. R…
ethindp 837ea1c
Added function call to enable SSE if SSE feature is enabled
ethindp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| .section .boot, "awx" | ||
| .intel_syntax noprefix | ||
| .code64 | ||
|
|
||
| # This asm file enables AVX support before the OS starts. | ||
| # AVX is not a requirement for an OS to boot. | ||
| # This file should be loaded after stage 3 and just before stage 4. | ||
| enable_avx: | ||
| push rax | ||
| push rcx | ||
| xor rcx, rcx | ||
| xgetbv | ||
| or eax, 7 | ||
| xsetbv | ||
| pop rcx | ||
| pop rax | ||
| ret |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| .section .boot, "awx" | ||
| .intel_syntax noprefix | ||
| .code32 | ||
|
|
||
| # Checks for SSE support and enables it. Should be loaded after stage 2. | ||
| no_sse_msg: .asciz "This system does not support SSE" | ||
| no_sse2_msg: .asciz "This system does not support SSE 2" | ||
| no_xsave_msg: .asciz "This system does not support XSAVE" | ||
|
|
||
| # As a part of the implementation of x86-64, AMD demands a minimum amount of SSE support. | ||
| # This function will fail if SSE, SSE2 and XSAVE support are not found together. | ||
| enable_sse: | ||
| mov eax, 0x1 | ||
| cpuid | ||
| test edx, 1 << 25 | ||
| jz .no_sse | ||
| mov eax, 0x1 | ||
| cpuid | ||
| test edx, 1 << 26 | ||
| jz .no_sse2 | ||
| mov eax, 0x1 | ||
| cpuid | ||
| test ecx, 1 << 26 | ||
| jz .no_xsave | ||
| mov eax, cr0 | ||
| # clear coprocessor emulation CR0.EM | ||
| and ax, 0xFFFB | ||
| # set coprocessor monitoring CR0.MP | ||
| or ax, 0x2 | ||
| mov cr0, eax | ||
| mov eax, cr4 | ||
| # set CR4.OSFXSR and CR4.OSXMMEXCPT at the same time | ||
| or ax, 3 << 9 | ||
| mov cr4, eax | ||
| ret | ||
|
|
||
| .no_sse: | ||
| lea si, [no_sse_msg] | ||
| call real_mode_println | ||
| .no_sse_spin: | ||
| jmp .no_sse_spin | ||
|
|
||
| .no_sse2: | ||
| lea si, [no_sse2_msg] | ||
| call real_mode_println | ||
| .no_sse2_spin: | ||
| jmp .no_sse2_spin | ||
|
|
||
| .no_xsave: | ||
| lea si, [no_xsave_msg] | ||
| call real_mode_println | ||
| .no_xsave_spin: | ||
| jmp .no_xsave_spin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
indentation