Skip to content
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

Extend some explanations #98

Closed
5 of 6 tasks
phil-opp opened this issue Dec 30, 2015 · 7 comments
Closed
5 of 6 tasks

Extend some explanations #98

phil-opp opened this issue Dec 30, 2015 · 7 comments
Labels
enhancement Potential improvements for the code or the blog. help wanted We could use help for this issue/pull request!

Comments

@phil-opp
Copy link
Owner

Some issues that were brought up by rylev on IRC:

  • "CPUID check" too fast
  • more assembly explanations, especially cmp and jmp

Update: below @mtnygard mentioned some issues with Printing to Screen:

  • too quick
  • unclear code fragments (which file? function or impl method?)
  • better document the lib.rs and Cargo.toml changes required for Unique and spin
  • type conflict: byte strings vs definition of write_str
@mtnygard
Copy link

The part titled "Printing to Screen" also goes very quickly. The code fragments could use some more context: which file does it go in, is it top-level or inside a type? (E.g., the text doesn't state that write_str should be inside the Writer type definition.)

Using Unique and sping also require changes to the crate attributes and Cargo.toml. The text could use some clarification there as well.

@mtnygard
Copy link

Section "Printing Strings" talks about adding b to make something a byte string, but then there is a type conflict with the definition of write_str.

I suspect this part assumes more Rust knowledge than I have here on day 3 of my journey. :-)

@phil-opp
Copy link
Owner Author

Thanks a lot! I'll try to clarify these things.

@sarahhodne
Copy link

I was going through the CPUID check myself to try to understand what was going on, and here's the version I ended up with, with some different comments:

check_cpuid:
    ; Check if CPUID is supported by attempting to flip the ID bit (bit 21) in
    ; the FLAGS register. If we can flip it, CPUID is available.

    ; Copy FLAGS in to EAX via stack
    pushfd
    pop eax

    ; Copy to ECX as well for comparing later on
    mov ecx, eax

    ; Flip the ID bit
    xor eax, 1 << 21

    ; Copy EAX to FLAGS via the stack
    push eax
    popfd

    ; Copy FLAGS back to EAX (with the flipped bit if CPUID is supported)
    pushfd
    pop eax

    ; Restore FLAGS from the old version stored in ECX (i.e. flipping the ID bit
    ; back if it was ever flipped).
    push ecx
    popfd

    ; Compare EAX and ECX. If they are equal then that means the bit wasn't
    ; flipped, and CPUID isn't supported.
    xor eax, ecx
    jz .no_cpuid
    ret
.no_cpuid:
    mov al, "1"
    jmp error

@mtnygard
Copy link

@henrikhodne I had to do something similar. The comments in the original code didn't explain why the operations were being done that way.

@phil-opp
Copy link
Owner Author

@henrikhodne This is very useful! Mind if I include it in the tutorial?

I think you should also update the page in the OSDev Wiki. Your comments are way better!

@sarahhodne
Copy link

@henrikhodne This is very useful! Mind if I include it in the tutorial?

Not at all, go ahead.

And I'll see if I can update the wiki page too.

@phil-opp phil-opp added enhancement Potential improvements for the code or the blog. help wanted We could use help for this issue/pull request! labels Jan 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Potential improvements for the code or the blog. help wanted We could use help for this issue/pull request!
Projects
None yet
Development

No branches or pull requests

3 participants