Skip to content

Conversation

michaelmelanson
Copy link
Contributor

@michaelmelanson michaelmelanson commented Sep 21, 2020

This PR works toward #51 by adding parsers for several descriptor types found in _CRS packages. I basically ran through all the devices that QEMU provided on my machine, and kept adding parsers until it stopped hitting unimplemented!() blocks. This is what I got. In my OS it parses all the Buffer type CRS entries provided by QEMU.

With this, you can parse many Current Resource Settings blocks with code like this:

        if let Ok((name, handle)) = context.namespace.search(&AmlName::from_str("_CRS").unwrap(), &device) {
          let value = context.namespace.get(handle).unwrap();
          let crs = aml::resource::resource_descriptor_list(&value);
          println!("{}: {:X?}", name, crs);
        }

I checked and this appears to merge cleanly against #75 with only minor changes, so it shouldn't be any trouble to merge this either before or after v2.

- Fixed memory descriptor
- Address space descriptor (WORD, DWORD, QWORD)
- Extended interrupt descriptor
- IRQ format descriptor
- DMA format descriptor
- IO port descriptor
@michaelmelanson
Copy link
Contributor Author

@IsaacWoods I'm not quite done yet, but when you get a chance would you mind taking a look at this and letting me know if I'm on the right track here.

Copy link
Member

@IsaacWoods IsaacWoods left a comment

Choose a reason for hiding this comment

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

Great stuff, thanks for working on this :)

I think the broad strokes of this are on the right tracks. I've left some review comments from my initial reading, but I'm afraid I won't have time this week to sit down and get my head around resource descriptors again to check this properly. I'll let you finish and try to make some time then.

@IsaacWoods
Copy link
Member

The result looks reasonably correct but I don't know how to really validate that it parses these descriptors properly. Some advice for testing would be appreciated there.

The long-term vision for testing is to flesh out our AML test suite with a bunch of stuff. For this, we'd have a bunch of devices with _CRS objects that covered a range of resource descriptors, and their combinations. In aml_tester, we should then enumerate each device and check that its _CRS parses nicely. However, that's a fair way off yet and definitely beyond the scope of this PR.

For now, I'm happy as long as they seem to produce sensible results. You could also either dump the ACPI tables and decompile them using iasl, or look to see if what you're looking for is in this (this won't be exactly the same as your particular tables, but is usually pretty close).

Please ask if anything I've said isn't clear, and I'll try and get back when I can :)

@michaelmelanson
Copy link
Contributor Author

Thanks for the feedback! I'll work on fixing up the things you've mentioned as soon as I get a chance.

@michaelmelanson michaelmelanson marked this pull request as ready for review September 26, 2020 19:48
@michaelmelanson
Copy link
Contributor Author

Thanks for your feedback! I've addressed all your comments from before and I think it's in shape for a proper review now when you get a chance.

Copy link
Member

@IsaacWoods IsaacWoods left a comment

Choose a reason for hiding this comment

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

Great, this looks good now. Thanks very much!

@IsaacWoods IsaacWoods merged commit c75f4b0 into rust-osdev:master Sep 27, 2020
@michaelmelanson michaelmelanson deleted the add-more-resources branch September 28, 2020 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants