/* * Copyright (C) 2022 Apple Inc. All rights reserved. * * This document is the property of Apple Inc. * It is considered confidential and proprietary. * * This document may not be reproduced or transmitted in any form, * in whole or in part, without the express written permission of * Apple Inc. */ #pragma once #if defined(KERNEL) || defined(XRT_HOSTED_INCLUDE) #include #include #include #include #include /** @section Types in shared memory */ /** @brief Global state for the hosted scheduler */ typedef struct { /** @brief Version 1 attributes */ struct { /** @brief Initialisation word set by the XNU proxy */ XrtHosted_Word_t proxyInit; /** @brief Scheduling context ID of the XNU proxy server */ XrtHosted_Word_t proxyId; } XrtHosted_AttrStruct v1; /** @brief Version 2 attributes */ struct { /** @brief SMP status of the scheduler */ XrtHosted_SmpStatus_t smpStatus; } XrtHosted_AttrStruct v2; /** @brief Version 3 attributes */ struct { /** @brief The timeout of the earliest sleeper waiting for an absolute * time */ XrtHosted_Word_t timeoutAbsolute; /** @brief The timeout of the earliest sleeper waiting for a continuous * time */ XrtHosted_Word_t timeoutContinuous; } XrtHosted_AttrStruct v3; /** @brief Version 4 attributes */ struct { /** @brief whether to skip returns following preemptions time */ XrtHosted_Word_t skipPreemptedReturns; } XrtHosted_AttrStruct v4; /** @brief Version 5 attributes */ struct { /** @brief address space ID of the scheduler */ XrtHosted_Word_t schedulerAsid; } XrtHosted_AttrStruct v5; } XrtHosted_AttrStruct XrtHosted_Global_t; /** @brief Per-core state for the hosted scheduler */ typedef struct { /** @brief Version 1 attributes */ struct { /** @brief ID of context servicing the core*/ XrtHosted_Word_t contextId; } XrtHosted_AttrStruct v1; /** @brief Version 2 attributes */ struct { /** @brief Hardware ID if the given core from device tree */ XrtHosted_Word_t hardwareId; } XrtHosted_AttrStruct v2; } XrtHosted_AttrStruct XrtHosted_Core_t; /** @section Accesseding shared memory */ /** @brief Location of error */ typedef struct { /** @brief Instruction address of error */ uintptr_t address; /** @brief Function at which error occurred */ const char * _Nullable function; /** @brief File in which error occured */ const char * _Nullable file; /** @brief Line at which error occured */ int line; /** @brief Expression which trifggered error */ const char * _Nullable expression; } XrtHosted_Error_t; /** @brief Mapped shared region in virtual memory */ typedef struct { /** @brief Mapped region is contiguous */ bool isContiguous; union { /** @brief Single contiguous virtual mapping */ struct { size_t count; XrtHosted_Mapped_t * _Nonnull XrtHosted__Counted(count) base; } contiguous; /** @brief Scattered page mapping */ struct { size_t count; XrtHosted_Mapped_t * _Nonnull * _Nonnull XrtHosted__Counted(count) base; } scattered; }; } XrtHosted_Region_t; static inline XrtHosted_Region_t XrtHosted_Region_contiguous( size_t count, XrtHosted_Mapped_t * _Nonnull XrtHosted__Counted(count) base ) { return (XrtHosted_Region_t) { .isContiguous = true, .contiguous = { .count = count, .base = base, }, }; } static inline XrtHosted_Region_t XrtHosted_Region_scattered( size_t count, XrtHosted_Mapped_t * _Nonnull * _Nonnull XrtHosted__Counted(count) base ) { return (XrtHosted_Region_t) { .isContiguous = false, .scattered = { .count = count, .base = base, }, }; } static inline size_t XrtHosted_Region_count(XrtHosted_Region_t region) { if (region.isContiguous) { return region.contiguous.count; } else { return region.scattered.count; } } #endif /* defined(KERNEL) || defined(XRT_HOSTED_INCLUDE) */