Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Use naked fn and define all interrupts in Rust #49

Merged
merged 10 commits into from
Jun 13, 2016
Merged

Conversation

steveklabnik
Copy link
Member

@steveklabnik steveklabnik commented Jun 13, 2016

Sooooo more "Steve is doing coding on a plane."

In #33, both @ticki and @eddyb suggested moving to naked fns for the interrupt handlers. Given that Rust was so nice to implement this feature just for OSdev, why not?

So I started hacking away. I realized that if I had the trampoline in Rust, I really didn't want to copy it over and over. But each function would need to be able to call into the right one... so a macro. So I started working on a macro-based solution... and then I thought, hmmm, this code seems familiar... and turns out, @Ericson2314 introduced me to this technique a few weeks ago. I guess it percolated in my brain until now. It's not the exact same code, but the same basic strategy: use a macro to generate an IDTEntry, and go from there.

🎊

@nxnfufunezn
Copy link
Contributor

I have been waiting for this... Awesome..

Now, if you don't pass a body, we'll just assume it's not handled. Rock.
@phil-opp
Copy link
Contributor

Wow, this is impressive!

I really like the approach of combining naked functions with macros. Maybe you should fly more often ;)

@nxnfufunezn
Copy link
Contributor

nxnfufunezn commented Jun 13, 2016

@phil-opp yup @steveklabnik should fly more often... 😆

waiting for next steve_was_on_a_plane PR..

@steveklabnik
Copy link
Member Author

maybe you should fly on a plane more often

hahahah


idt.set_isr(32, make_idt_entry!(isr32, {
// timer, do nothing for now
pic::eoi_for(32);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay so, i added send_eoi_for because i was getting compile errors. But now, this line is here and works. Must investigate...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new commit that removes the other function. Guess it's not needed now!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahaha what? Compiler just woke up on the wrong side of the bed this morning.

[[package]]
name = "spin"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two spins? Is Cargo supposed to allow that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Cargo attempts to unify versions, but if it cannot, it will include both.

I will send a PR to update the versions to be the same; no reason for it, really.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I thought it would error. Well, learn something now every day!

@steveklabnik steveklabnik merged commit ed2a1e3 into master Jun 13, 2016
@steveklabnik steveklabnik deleted the naked_fn branch June 13, 2016 21:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants