11cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci// CPU specific code for arm independent of OS goes here.
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci#include <sys/syscall.h>
81cb0ef41Sopenharmony_ci#include <unistd.h>
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_RISCV64
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci#include "src/codegen/cpu-features.h"
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_cinamespace v8 {
151cb0ef41Sopenharmony_cinamespace internal {
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_civoid CpuFeatures::FlushICache(void* start, size_t size) {
181cb0ef41Sopenharmony_ci#if !defined(USE_SIMULATOR)
191cb0ef41Sopenharmony_ci  char* end = reinterpret_cast<char*>(start) + size;
201cb0ef41Sopenharmony_ci  // The definition of this syscall is
211cb0ef41Sopenharmony_ci  // SYSCALL_DEFINE3(riscv_flush_icache, uintptr_t, start,
221cb0ef41Sopenharmony_ci  //                 uintptr_t, end, uintptr_t, flags)
231cb0ef41Sopenharmony_ci  // The flag here is set to be SYS_RISCV_FLUSH_ICACHE_LOCAL, which is
241cb0ef41Sopenharmony_ci  // defined as 1 in the Linux kernel.
251cb0ef41Sopenharmony_ci  syscall(SYS_riscv_flush_icache, start, end, 1);
261cb0ef41Sopenharmony_ci#endif  // !USE_SIMULATOR.
271cb0ef41Sopenharmony_ci}
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci}  // namespace internal
301cb0ef41Sopenharmony_ci}  // namespace v8
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci#endif  // V8_TARGET_ARCH_RISCV64
33