brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 2e66f89 Raw
76 lines · c
1//===-- mem_map_fuchsia.h ---------------------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef SCUDO_MEM_MAP_FUCHSIA_H_10#define SCUDO_MEM_MAP_FUCHSIA_H_11 12#include "mem_map_base.h"13 14#if SCUDO_FUCHSIA15 16#include <stdint.h>17#include <zircon/types.h>18 19namespace scudo {20 21class MemMapFuchsia final : public MemMapBase<MemMapFuchsia> {22public:23  constexpr MemMapFuchsia() = default;24 25  // Impls for base functions.26  bool mapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);27  void unmapImpl(uptr Addr, uptr Size);28  bool remapImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);29  void setMemoryPermissionImpl(uptr Addr, uptr Size, uptr Flags);30  void releasePagesToOSImpl(uptr From, uptr Size) {31    return releaseAndZeroPagesToOSImpl(From, Size);32  }33  void releaseAndZeroPagesToOSImpl(uptr From, uptr Size);34  uptr getBaseImpl() { return WindowBase; }35  uptr getCapacityImpl() { return WindowSize; }36 37private:38  friend class ReservedMemoryFuchsia;39 40  // Used by ReservedMemoryFuchsia::dispatch.41  MemMapFuchsia(uptr Base, uptr Capacity);42 43  // Virtual memory address corresponding to VMO offset 0.44  uptr MapAddr = 0;45 46  // Virtual memory base address and size of the VMO subrange that is still in47  // use. unmapImpl() can shrink this range, either at the beginning or at the48  // end.49  uptr WindowBase = 0;50  uptr WindowSize = 0;51 52  zx_handle_t Vmo = ZX_HANDLE_INVALID;53};54 55class ReservedMemoryFuchsia final56    : public ReservedMemory<ReservedMemoryFuchsia, MemMapFuchsia> {57public:58  constexpr ReservedMemoryFuchsia() = default;59 60  bool createImpl(uptr Addr, uptr Size, const char *Name, uptr Flags);61  void releaseImpl();62  MemMapT dispatchImpl(uptr Addr, uptr Size);63  uptr getBaseImpl() { return Base; }64  uptr getCapacityImpl() { return Capacity; }65 66private:67  uptr Base = 0;68  uptr Capacity = 0;69};70 71} // namespace scudo72 73#endif // SCUDO_FUCHSIA74 75#endif // SCUDO_MEM_MAP_FUCHSIA_H_76