On Mon, 19 Aug 2019, Jd Lyons wrote:
How would I go about overriding the reg property?
Not sure, look for "reg" (with quotes) an see how it's done elsewhere. Looks like there are two ways via C function:
set_property(phandle, "reg", (char *)props, ncells * sizeof(props[0]));
which needs a phandle from somewhere and an array to hold the property value. Don't know how to get those but there should be examples in the code.
Or using Forth:
PUSH(0); fword("encode-int"); push_str("reg"); fword("property");
but that needs to be done during the device is created, between new-device and finish-device. When after cpu init func that called finish-device and you want to modify existing node you'd need to call find-device instead of new-device like :
push_str("/cpus/PowerPC,whatever"); fword("find-device");
but if both of your CPUs are called the same how do you get a path to the second one? So it looks like it's already botched by the cpu init function and there may not be an easy way to fix up after that (or I don't know how) so you may need to add a parameter to the init func to tell it to set reg property from that, but then you'd need to modify all init functions as the function pointer definition will change so if we're back to hacking and just to try if it would work you may add a global cpunum variable (well, static to qemu/init.c, outside all functions) and pass cpu number to init func via that, then think about how to clean it up later (of course this won't be acceptable as a solution just for testing the idea).
Actually it seems all cpu init functions add a reg property but those that don't set it to 0 set it to the PIR of the CPU which is some kind of ID register:
https://qemu-devel.nongnu.narkive.com/sCLUgMqF/patch-ppc-add-pir-register-to...
I don't know how all this works or should work so can't tell what will break by modifying it.
Regards, BALATON Zoltan