Attention is currently required from: Anastasia Klimchuk. Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/flashrom/+/52604 )
Change subject: [RFC] tests: Abstract port I/O and factor mec1308 specifics out ......................................................................
Patch Set 1:
(2 comments)
File tests/init_shutdown.c:
https://review.coreboot.org/c/flashrom/+/52604/comment/cc11e331_0aa7f976 PS1, Line 63: .outb = mec1308_outb,
I think, maybe I could get away with a default implementation of outx functions, and only customise […]
I'm actually not familiar with our port-i/o using programmer drivers. Without looking into them, it could work or not. It boils down to what the return value of an inb/inw/inl call would depend on. If it's more than the very last outb/outw/outl, we would obviously have to cache more information than that.
Thinking really far ahead: For more than just testing initialization, e.g. test flashing procedures as well, we may have to implement more sophisticated state machines to mock the programmers. That would very likely need the outb/outw/outl pointers and a private data structure.
tl;dr I can imagine we may need all the pointers.
File tests/tests.c:
https://review.coreboot.org/c/flashrom/+/52604/comment/694b35dd_5b34c7da PS1, Line 23: const struct io_mock *current_io = NULL;
Do you think it would work if I try to swap this line with extern definition in io_mock. […]
I guess I'm just used to specify `extern` in header files because it has some implications with incomplete types. We can also add `extern` here. But I would keep the `= NULL` here because this compilation unit is where it is consumed and the initialization actually matters.
A good rule to live by: Any global should be either declared `static` or be used somewhere else. If something is not `static`, you have to expect it to be referenced elsewhere.
Alternative: Make it `static` and add a setter function to be called from the other compilation units.