qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

hw: register: Run post_write hook on reset

Ensure that the post write hook is called during reset. This allows us
to rely on the post write functions instead of having to call them from
the reset() function.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: d131e24b911653a945e46ca2d8f90f572469e1dd.1517856214.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

authored by

Alistair Francis and committed by
Peter Maydell
4e5f0fb7 66974397

+11 -3
+8
hw/core/register.c
··· 159 159 160 160 void register_reset(RegisterInfo *reg) 161 161 { 162 + const RegisterAccessInfo *ac; 163 + 162 164 g_assert(reg); 163 165 164 166 if (!reg->data || !reg->access) { 165 167 return; 166 168 } 169 + 170 + ac = reg->access; 167 171 168 172 register_write_val(reg, reg->access->reset); 173 + 174 + if (ac->post_write) { 175 + ac->post_write(reg, reg->access->reset); 176 + } 169 177 } 170 178 171 179 void register_init(RegisterInfo *reg)
+3 -3
include/hw/register.h
··· 34 34 * immediately before the actual write. The returned value is what is written, 35 35 * giving the handler a chance to modify the written value. 36 36 * @post_write: Post write callback. Passed the written value. Most write side 37 - * effects should be implemented here. 37 + * effects should be implemented here. This is called during device reset. 38 38 * 39 39 * @post_read: Post read callback. Passes the value that is about to be returned 40 40 * for a read. The return value from this function is what is ultimately read, ··· 135 135 bool debug); 136 136 137 137 /** 138 - * reset a register 139 - * @reg: register to reset 138 + * Resets a register. This will also call the post_write hook if it exists. 139 + * @reg: The register to reset. 140 140 */ 141 141 142 142 void register_reset(RegisterInfo *reg);