blob: 1e94aeda2c9433adf0997c9488a22f28bab2361c [file]
// Copyright 2026 The Fuchsia Authors
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
#include "vm/vm_object_physical_ffi.h"
#include <stdint.h>
#include <sys/types.h>
#include <fbl/alloc_checker.h>
#include <fbl/ref_ptr.h>
#include <kernel/ffi.h>
#include "vm/vm_object_physical.h"
// TODO(https://fxbug.dev/537458631): Remove the annotations once cross-language inlining works.
extern "C" {
FFI_ALWAYS_INLINE void cpp_vm_object_physical_free(VmObjectPhysical* vmo) { delete vmo; }
FFI_ALWAYS_INLINE VmObjectPhysical* cpp_vm_object_physical_alloc(paddr_t base, uint64_t size,
bool is_slice,
uint64_t parent_user_id) {
fbl::AllocChecker ac;
auto vmo = fbl::AdoptRef<VmObjectPhysical>(
new (&ac) VmObjectPhysical(base, size, is_slice, parent_user_id));
if (!ac.check()) {
return nullptr;
}
return fbl::ExportToRawPtr(&vmo);
}
} // extern "C"