/* SPDX-License-Identifier: MIT */ #include "NativeAdrenoGmuPlatform.h" #include int NativeAdrenoGmuPlatform::read32(void *cookie,unsigned window,size_t at,uint32_t *out) { if(!cookie || !out || window>=ShengGmuWindows)return 1; NativeAdrenoGmuPlatform *self=static_cast(cookie); const NativeAdrenoGmuWindow &bounds=self->windows_[window]; if(!bounds.base || (at&3) || at+4>bounds.bytes)return 1; *out=*reinterpret_cast(bounds.base+at); return 0; } int NativeAdrenoGmuPlatform::write32(void *cookie,unsigned window,size_t at,uint32_t value) { if(!cookie || window>=ShengGmuWindows)return 1; NativeAdrenoGmuPlatform *self=static_cast(cookie); const NativeAdrenoGmuWindow &bounds=self->windows_[window]; if(!bounds.base || (at&3) || at+4>bounds.bytes)return 1; *reinterpret_cast(bounds.base+at)=value; return 0; } int NativeAdrenoGmuPlatform::barrier(void *cookie) { if(!cookie)return 1; __atomic_thread_fence(__ATOMIC_SEQ_CST); return 0; } IOReturn NativeAdrenoGmuPlatform::bind(const NativeAdrenoGmuWindow windows[ShengGmuWindows], ShengGmuIo *io) { if(!windows || !io)return kIOReturnBadArgument; for(unsigned index=0;indexUINT32_MAX) return kIOReturnBadArgument; } for(unsigned index=0;index(bytes),length,digest); return 0; } IOReturn NativeAdrenoGmuPlatform::services(const NativeAdrenoGmuTime *time, ShengGmuServices *services) { if(!services)return kIOReturnBadArgument; *services={}; if(!time || !time->now_us || !time->wait_us)return kIOReturnBadArgument; services->cookie=time->cookie; services->sha256=sha256; services->now_us=time->now_us; services->wait_us=time->wait_us; return kIOReturnSuccess; }