rust-osdev/acpi

AML: Change Handler::read_u8(&self, ...) to read_u8(&mut self, ...)

rw-vanc opened this issue · 2 comments

Currently, the AML handler functions for accessing physical addresses are &mut self for write functions, and &self for read functions. For Redox, there is a desire to map physical addresses to virtual addresses, and then keep track of those mapped addresses. Since read_u8, etc. are &self, it is not possible to keep any record of mapped addresses. A quick check of changing to &mut self seems to have a pretty big impact, although there might be some tricks to reduce the impact. This is not a show-stopper for us right now, but I think in general it should be expected that the Handler may want to do some housekeeping and therefore read_u8 etc. should be &mut self.

After some discussion with others, I'm just going to use RefCell for the cache, so it's not worth changing the Handler interface.

Hm yep I feel a good solution to this would be to use interior mutability as you've done.

Otherwise, if I'm remembering correctly, this has the same implementation complexities as #155, so this may be possible once that is sorted. But yeah I imagine it won't be a particularly small diff and needs some careful consideration.