/**
 * @file       kaslr.h
 * @brief      API to get KASLR
 * @author     Ivan Vorobiov (i.vorobiov@samsung.com)
 * @version    1.0
 * @date       Created Mar 30, 2017
 * @copyright  In Samsung Ukraine R&D Center (SURC) under a contract between
 * @copyright  LLC "Samsung Electronics Ukraine Company" (Kiev, Ukraine) and
 * @copyright  "Samsung Electronics Co", Ltd (Seoul, Republic of Korea)
 * @copyright  Copyright: (c) Samsung Electronics Co, Ltd 2017. All rights reserved.
**/

#ifndef PA_TZ_DRV_ARCH_KASLR_H_
#define PA_TZ_DRV_ARCH_KASLR_H_

#include <pa_tz_api.h>

/**
 * KASLR structure
 * First 4 bytes is magic number (We should check it to prove that
 * we really read KASLR structure otherwise trash).
 * Second 4 bytes is offset that added to initial address of kernel image to
 * randomize address space.
 */
typedef struct {
  uint32_t magic;  //!< Magic number
  uint32_t offset; //!< KASLR offset
} Kaslr;

/* KASLR structure should have this MAGIC code */
static const uint32_t kKaslrMagicCode = 0xcdefcdef;

/**
 * @brief Return KASLR offset
 * @param [out] kaslr_offset KASLR offset or 0 if KASLR is disabled
 * @return ::PA_TZ_SUCCESS, ::PA_TZ_GENERAL_ERROR
 */
PaTzResult KernelGetKaslrOffset(uint32_t *kaslr_offset);

#endif // PA_TZ_DRV_ARCH_KASLR_H_
