1 //===-- mem_map_fuchsia.h ---------------------------------------*- C++ -*-===//
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-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef SCUDO_MEM_MAP_FUCHSIA_H_
10 #define SCUDO_MEM_MAP_FUCHSIA_H_
12 #include "mem_map_base.h"
17 #include <zircon/types.h>
21 class MemMapFuchsia final
: public MemMapBase
<MemMapFuchsia
> {
23 constexpr MemMapFuchsia() = default;
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
);
33 void releaseAndZeroPagesToOSImpl(uptr From
, uptr Size
);
34 uptr
getBaseImpl() { return WindowBase
; }
35 uptr
getCapacityImpl() { return WindowSize
; }
38 friend class ReservedMemoryFuchsia
;
40 // Used by ReservedMemoryFuchsia::dispatch.
41 MemMapFuchsia(uptr Base
, uptr Capacity
);
43 // Virtual memory address corresponding to VMO offset 0.
46 // Virtual memory base address and size of the VMO subrange that is still in
47 // use. unmapImpl() can shrink this range, either at the beginning or at the
52 zx_handle_t Vmo
= ZX_HANDLE_INVALID
;
55 class ReservedMemoryFuchsia final
56 : public ReservedMemory
<ReservedMemoryFuchsia
, MemMapFuchsia
> {
58 constexpr ReservedMemoryFuchsia() = default;
60 bool createImpl(uptr Addr
, uptr Size
, const char *Name
, uptr Flags
);
62 MemMapT
dispatchImpl(uptr Addr
, uptr Size
);
63 uptr
getBaseImpl() { return Base
; }
64 uptr
getCapacityImpl() { return Capacity
; }
73 #endif // SCUDO_FUCHSIA
75 #endif // SCUDO_MEM_MAP_FUCHSIA_H_