qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using bit-field to define a qom register


From: Peter Maydell
Subject: Re: using bit-field to define a qom register
Date: Sun, 11 Jul 2021 10:12:56 +0100

On Sun, 11 Jul 2021 at 09:12, Hiroko Shimizu <hiroko07168@gmail.com> wrote:
>
> >If you mean the MemoryRegionOps read and write functions,
> Yes, I mean that. I understand that "MemoryRegionOps read and write 
> functions, those work only with byte offsets."
> But, I must set a value into a qom register using C bit fields in the guest 
> source code.

What the guest *source code* is doing doesn't matter. You care
about what the guest *binary* does, which for bitfields
probably looks like a "read byte or word from the device into a
CPU register; modify it; write the byte or word back to the device",
because that's what the C compiler will emit for bitfield accesses.
(Side note, if the guest OS code is using bitfield accesses to
touch device registers that's a bit flaky, because it means the
guest OS code isn't being careful to control how it touches the
hardware. But unless you're also writing the OS code then that's
not your problem :-))

More generally, you don't really want to worry too much about
what specific guest code is doing. You should implement the
device emulation to match the specification of the device
(ie its documentation), not just "do something that works
for the particular guest OS code I have".

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]