Giter Site home page Giter Site logo

Extend some explanations about blog_os HOT 7 CLOSED

phil-opp avatar phil-opp commented on May 3, 2024
Extend some explanations

from blog_os.

Comments (7)

mtnygard avatar mtnygard commented on May 3, 2024

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.

from blog_os.

mtnygard avatar mtnygard commented on May 3, 2024

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. :-)

from blog_os.

phil-opp avatar phil-opp commented on May 3, 2024

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

from blog_os.

sarahhodne avatar sarahhodne commented on May 3, 2024

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

from blog_os.

mtnygard avatar mtnygard commented on May 3, 2024

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

from blog_os.

phil-opp avatar phil-opp commented on May 3, 2024

@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!

from blog_os.

sarahhodne avatar sarahhodne commented on May 3, 2024

@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.

from blog_os.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.