rust-osdev / acpi

Rust library for parsing ACPI tables and interpreting AML
Apache License 2.0
200 stars 61 forks source link

Kernel Example with ACPI #125

Open asensio-project opened 1 year ago

asensio-project commented 1 year ago

Hello everyone,

I am developing a little kernel based on Phil's Blog, I want to add support to ACPI by using this crate but It's a little bit confusing starting from zero.

Is there any minimal example for using it?

Thanks!

IsaacWoods commented 1 year ago

Hi!

There's not currently an example kernel, although this would potentially be a good idea for helping to get people started. Just a fair warning that ACPI is fairly 'in the weeds' of x86 and so if you're getting started with OS dev you might find other things easier or more fun to start adapting from Phil's tutorials.

That being said, getting started is not too hard: you'll need to write an implementation of AcpiHandler to map and unmap regions of memory - iirc Phil uses a direct mapping so this should be relatively simple. You can see an example from my kernel here. The bootloader will then need to give you the RSDP address somehow (I'm not using bootloader so I can't tell you how this works I'm afraid) - with that you can initialise the Acpi struct (read this for some guidance).

Finally, have a look at the docs for the various things you can get from an Acpi - you can either parse tables yourself, or read the PlatformInfo data for a nicer parsed form of some of it.

asensio-project commented 1 year ago

Thank you so much!

I will keep it in mind.

rsribeiro commented 1 year ago

You can also find an example on the MOROS Project. It also started from Phil's tutorial.