blob: 8d7a60a77b7be937f478cd3d9091f4317a3341a6 [file] [log] [blame]
// Copyright 2020 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
#ifndef ZIRCON_KERNEL_PHYS_TEST_CODE_PATCHING_TEST_H_
#define ZIRCON_KERNEL_PHYS_TEST_CODE_PATCHING_TEST_H_
// This file will be included into test.cc, add-one.S, and the generated
// `mutiply_by_factor` assembly stub.
// Concocted patch case IDs.
#define CASE_ID_ADD_ONE 17
#define CASE_ID_MULTIPLY_BY_FACTOR 35
#if defined(__aarch64__)
#define PATCH_SIZE_ADD_ONE 4
#define PATCH_SIZE_MULTIPLY_BY_FACTOR 12
#elif defined(__x86_64__)
#define PATCH_SIZE_ADD_ONE 4
#define PATCH_SIZE_MULTIPLY_BY_FACTOR 8
#else
#error "unknown architecture"
#endif
#ifndef __ASSEMBLER__
#include <cstddef>
#include <cstdint>
#include <ktl/byte.h>
#include <ktl/span.h>
#include <ktl/string_view.h>
constexpr uint32_t kAddOneCaseId = CASE_ID_ADD_ONE;
constexpr size_t kAddOnePatchSize = PATCH_SIZE_ADD_ONE;
constexpr uint32_t kMultiplyByFactorCaseId = CASE_ID_MULTIPLY_BY_FACTOR;
constexpr size_t kMultiplyByFactorPatchSize = PATCH_SIZE_MULTIPLY_BY_FACTOR;
#endif // #ifndef __ASSEMBLER__
#endif // ZIRCON_KERNEL_PHYS_TEST_CODE_PATCHING_TEST_H_