mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
bswap: Add new stn_*_p() and ldn_*_p() memory access functions
There's a common pattern in QEMU where a function needs to perform a data load or store of an N byte integer in a particular endianness. At the moment this is handled by doing a switch() on the size and calling the appropriate ld*_p or st*_p function for each size. Provide a new family of functions ldn_*_p() and stn_*_p() which take the size as an argument and do the switch() themselves. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20180611171007.4165-2-peter.maydell@linaro.org
This commit is contained in:
parent
2948f0cde3
commit
afa4f6653d
3 changed files with 71 additions and 0 deletions
|
@ -53,9 +53,24 @@ The ``_{endian}`` infix is omitted for target-endian accesses.
|
|||
The target endian accessors are only available to source
|
||||
files which are built per-target.
|
||||
|
||||
There are also functions which take the size as an argument:
|
||||
|
||||
load: ``ldn{endian}_p(ptr, sz)``
|
||||
|
||||
which performs an unsigned load of ``sz`` bytes from ``ptr``
|
||||
as an ``{endian}`` order value and returns it in a uint64_t.
|
||||
|
||||
store: ``stn{endian}_p(ptr, sz, val)``
|
||||
|
||||
which stores ``val`` to ``ptr`` as an ``{endian}`` order value
|
||||
of size ``sz`` bytes.
|
||||
|
||||
|
||||
Regexes for git grep
|
||||
- ``\<ldf\?[us]\?[bwlq]\(_[hbl]e\)\?_p\>``
|
||||
- ``\<stf\?[bwlq]\(_[hbl]e\)\?_p\>``
|
||||
- ``\<ldn_\([hbl]e\)?_p\>``
|
||||
- ``\<stn_\([hbl]e\)?_p\>``
|
||||
|
||||
``cpu_{ld,st}_*``
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue