asahi: add sparse emu helpers

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34486>
This commit is contained in:
Alyssa Rosenzweig 2025-04-11 11:57:56 -04:00 committed by Marge Bot
parent c2d00c94b1
commit 546bc893f1

View file

@ -177,6 +177,27 @@ struct agx_device {
struct u_printf_ctx printf;
};
/*
* Determine if an address is in the read-only section. See the documentation
* for sparse_ro_offset.
*/
static inline bool
agx_addr_is_ro(struct agx_device *dev, uint64_t addr)
{
return (addr & dev->sparse_ro_offset);
}
/*
* Convert a read-write address to its read-only shadow address. See the
* documentation for sparse_ro_offset.
*/
static inline uint64_t
agx_rw_addr_to_ro(struct agx_device *dev, uint64_t addr)
{
assert(!agx_addr_is_ro(dev, addr));
return addr + dev->sparse_ro_offset;
}
static inline void *
agx_bo_map(struct agx_bo *bo)
{