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

qemu/bitops.h: Add extract8 and extract16

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20200212130311.127515-3-ysato@users.sourceforge.jp>
Message-Id: <20200225124710.14152-14-alex.bennee@linaro.org>

authored by

Yoshinori Sato and committed by
Alex Bennée
ed04c8b1 41336861

+38
+38
include/qemu/bitops.h
··· 302 302 } 303 303 304 304 /** 305 + * extract8: 306 + * @value: the value to extract the bit field from 307 + * @start: the lowest bit in the bit field (numbered from 0) 308 + * @length: the length of the bit field 309 + * 310 + * Extract from the 8 bit input @value the bit field specified by the 311 + * @start and @length parameters, and return it. The bit field must 312 + * lie entirely within the 8 bit word. It is valid to request that 313 + * all 8 bits are returned (ie @length 8 and @start 0). 314 + * 315 + * Returns: the value of the bit field extracted from the input value. 316 + */ 317 + static inline uint8_t extract8(uint8_t value, int start, int length) 318 + { 319 + assert(start >= 0 && length > 0 && length <= 8 - start); 320 + return extract32(value, start, length); 321 + } 322 + 323 + /** 324 + * extract16: 325 + * @value: the value to extract the bit field from 326 + * @start: the lowest bit in the bit field (numbered from 0) 327 + * @length: the length of the bit field 328 + * 329 + * Extract from the 16 bit input @value the bit field specified by the 330 + * @start and @length parameters, and return it. The bit field must 331 + * lie entirely within the 16 bit word. It is valid to request that 332 + * all 16 bits are returned (ie @length 16 and @start 0). 333 + * 334 + * Returns: the value of the bit field extracted from the input value. 335 + */ 336 + static inline uint16_t extract16(uint16_t value, int start, int length) 337 + { 338 + assert(start >= 0 && length > 0 && length <= 16 - start); 339 + return extract32(value, start, length); 340 + } 341 + 342 + /** 305 343 * extract64: 306 344 * @value: the value to extract the bit field from 307 345 * @start: the lowest bit in the bit field (numbered from 0)