cpu_ldst.h, cpu-all.h, bswap.h: Update documentation on ld/st accessors

Add documentation of what the cpu_*_* accessors look like.
Correct some minor errors in the existing documentation of the
direct _p accessor family. Remove the near-duplicate comment
on the _p accessors from cpu-all.h and replace it with a reference
to the comment in bswap.h.

Backports commit db5fd8d709fd57f4d4f11edfca9f421f657f4508 from qemu
This commit is contained in:
Lioncash 2019-04-22 07:39:02 -04:00
parent 84eafc0cf6
commit e75b32ca4b
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
3 changed files with 31 additions and 37 deletions

View file

@ -117,43 +117,10 @@ static inline void tswap64s(uint64_t *s)
#define bswaptls(s) bswap64s(s) #define bswaptls(s) bswap64s(s)
#endif #endif
/* CPU memory access without any memory or io remapping */ /* Target-endianness CPU memory access functions. These fit into the
* {ld,st}{type}{sign}{size}{endian}_p naming scheme described in bswap.h.
/*
* the generic syntax for the memory accesses is:
*
* load: ld{type}{sign}{size}{endian}_{access_type}(ptr)
*
* store: st{type}{size}{endian}_{access_type}(ptr, val)
*
* type is:
* (empty): integer access
* f : float access
*
* sign is:
* (empty): for floats or 32 bit size
* u : unsigned
* s : signed
*
* size is:
* b: 8 bits
* w: 16 bits
* l: 32 bits
* q: 64 bits
*
* endian is:
* (empty): target cpu endianness or 8 bit access
* r : reversed target cpu endianness (not implemented yet)
* be : big endian (not implemented yet)
* le : little endian (not implemented yet)
*
* access_type is:
* raw : host memory access
* user : user mode access using soft MMU
* kernel : kernel mode access using soft MMU
*/ */
/* target-endianness CPU memory access functions */
#if defined(TARGET_WORDS_BIGENDIAN) #if defined(TARGET_WORDS_BIGENDIAN)
#define lduw_p(p) lduw_be_p(p) #define lduw_p(p) lduw_be_p(p)
#define ldsw_p(p) ldsw_be_p(p) #define ldsw_p(p) ldsw_be_p(p)

View file

@ -23,7 +23,26 @@
* *
* Used by target op helpers. * Used by target op helpers.
* *
* MMU mode suffixes are defined in target cpu.h. * The syntax for the accessors is:
*
* load: cpu_ld{sign}{size}_{mmusuffix}(env, ptr)
*
* store: cpu_st{sign}{size}_{mmusuffix}(env, ptr, val)
*
* sign is:
* (empty): for 32 and 64 bit sizes
* u : unsigned
* s : signed
*
* size is:
* b: 8 bits
* w: 16 bits
* l: 32 bits
* q: 64 bits
*
* mmusuffix is one of the generic suffixes "data" or "code", or
* (for softmmu configs) a target-specific MMU mode suffix as defined
* in target cpu.h.
*/ */
#ifndef CPU_LDST_H #ifndef CPU_LDST_H
#define CPU_LDST_H #define CPU_LDST_H

View file

@ -251,7 +251,7 @@ typedef union {
* f : float access * f : float access
* *
* sign is: * sign is:
* (empty): for floats or 32 bit size * (empty): for 32 or 64 bit sizes (including floats and doubles)
* u : unsigned * u : unsigned
* s : signed * s : signed
* *
@ -265,6 +265,7 @@ typedef union {
* he : host endian * he : host endian
* be : big endian * be : big endian
* le : little endian * le : little endian
* te : target endian
* (except for byte accesses, which have no endian infix). * (except for byte accesses, which have no endian infix).
* *
* The target endian accessors are obviously only available to source * The target endian accessors are obviously only available to source
@ -274,6 +275,13 @@ typedef union {
* For accessors that take a guest address rather than a * For accessors that take a guest address rather than a
* host address, see the cpu_{ld,st}_* accessors defined in * host address, see the cpu_{ld,st}_* accessors defined in
* cpu_ldst.h. * cpu_ldst.h.
* The target endian accessors are obviously only available to source
* files which are built per-target; they are defined in cpu-all.h.
*
* In all cases these functions take a host pointer.
* For accessors that take a guest address rather than a
* host address, see the cpu_{ld,st}_* accessors defined in
* cpu_ldst.h.
* *
* For cases where the size to be used is not fixed at compile time, * For cases where the size to be used is not fixed at compile time,
* there are * there are