blob: 8f6451b0bc88ec59b27ed58b79c3e35f08020ff6 [file] [log] [blame] [edit]
/*
* arch/arm/include/asm/arch-txl/bl31_apis.h
*
* Copyright (C) 2015 Amlogic, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* Trustzone API
*
* Copyright (C) 2012 Amlogic, Inc.
*
* Author: Platform-SH@amlogic.com
*
*/
#ifndef __GXBB_BL31_APIS_H
#define __GXBB_BL31_APIS_H
#include <asm/arch/io.h>
/*#define SRAM_READ 0x82000010
#define CORE_RD_REV1 0x82000011
#define SRAM_ACS_READ 0x82000012
#define SRAM_ACS_INDIRECT_READ 0x82000013*/
#define GET_SHARE_MEM_INPUT_BASE 0x82000020
#define GET_SHARE_MEM_OUTPUT_BASE 0x82000021
#define GET_REBOOT_REASON 0x82000022
#define GET_SHARE_STORAGE_IN_BASE 0x82000023
#define GET_SHARE_STORAGE_OUT_BASE 0x82000024
#define GET_SHARE_STORAGE_BLOCK_BASE 0x82000025
#define GET_SHARE_STORAGE_MESSAGE_BASE 0x82000026
#define GET_SHARE_STORAGE_BLOCK_SIZE 0x82000027
#define SET_STORAGE_INFO 0x82000028
/* Set Reboot Reason then Reboot*/
#define PSCI_SYS_REBOOT 0x84000009
/* SECUREOS DEFINITION*/
/* SMC Identifiers for non-secure world functions */
#define CALL_TRUSTZONE_HAL_API 0x5
/* EFUSE */
#define EFUSE_READ 0x82000030
#define EFUSE_WRITE 0x82000031
#define EFUSE_WRITE_PATTERN 0x82000032
#define EFUSE_USER_MAX 0x82000033
#define DEBUG_EFUSE_WRITE_PATTERN 0x820000F0
#define DEBUG_EFUSE_READ_PATTERN 0x820000F1
/* JTAG*/
#define JTAG_ON 0x82000040
#define JTAG_OFF 0x82000041
#define SET_USB_BOOT_FUNC 0x82000043
/* USB BOOT FUNC sub command list*/
#define CLEAR_USB_BOOT 1
#define FORCE_USB_BOOT 2
#define RUN_COMD_USB_BOOT 3
#define PANIC_DUMP_USB_BOOT 4
#define GET_CHIP_ID 0x82000044
/* Security Key*/
#define SECURITY_KEY_QUERY 0x82000060
#define SECURITY_KEY_READ 0x82000061
#define SECURITY_KEY_WRITE 0x82000062
#define SECURITY_KEY_TELL 0x82000063
#define SECURITY_KEY_VERIFY 0x82000064
#define SECURITY_KEY_STATUS 0x82000065
#define SECURITY_KEY_NOTIFY 0x82000066
#define SECURITY_KEY_LIST 0x82000067
#define SECURITY_KEY_REMOVE 0x82000068
#define SECURITY_KEY_NOTIFY_EX 0x82000069
#define SECURITY_KEY_SET_ENCTYPE 0x8200006A
#define SECURITY_KEY_GET_ENCTYPE 0x8200006B
#define SECURITY_KEY_VERSION 0x8200006C
/*viu probe en*/
#define VIU_PREOBE_EN 0x82000080
/* Secure HAL APIs */
#define TRUSTZONE_HAL_API_SRAM 0x400
#define SRAM_HAL_API_CHECK_EFUSE 0x403
struct sram_hal_api_arg {
unsigned int cmd;
unsigned int req_len;
unsigned int res_len;
unsigned long req_phy_addr;
unsigned long res_phy_addr;
unsigned long ret_phy_addr;
};
#define JTAG_STATE_ON 0
#define JTAG_STATE_OFF 1
#define JTAG_M3_AO 0
#define JTAG_M3_EE 1
#define JTAG_A53_AO 2
#define JTAG_A53_EE 3
#define CLUSTER_BIT 2
/////////////////////////////////////////////////////////////////////////////////
#define AML_DATA_PROCESS (0x820000FF)
#define AML_D_P_W_EFUSE_SECURE_BOOT (0x10)
#define AML_D_P_W_EFUSE_PASSWORD (0x11)
#define AML_D_P_W_EFUSE_CUSTOMER_ID (0x12)
#define AML_D_P_W_EFUSE_AMLOGIC (0x20)
#define AML_D_P_IMG_DECRYPT (0x40)
#define AML_D_P_IMG_DECRYPT_V3 (0x41)
#define AML_D_P_EXT_IMG_DECRYPT_V3 (0x51)
#define AML_D_P_UPGRADE_CHECK (0x80)
/* Verified execution */
#define PERMANENT_ATTRIBUTES_READ 0x82000090
#define PERMANENT_ATTRIBUTES_SIZE 1052
#define PERMANENT_ATTRIBUTES_HASH_SIZE 32
/* Returns the bootloader lock state in X0.
*
* Important: to protect against bitflip attacks/errors, always require the
* state match the expectation exactly; for example, if an operation is only
* allowed when unlocked, do this:
* if (state == VX_BOOTLOADER_LOCK_STATE_UNLOCKED) { privilegedOp(); }
* not this:
* if (state != VX_BOOTLOADER_LOCK_STATE_LOCKED) { privilegedOp(); }
* so that anything other than an exact match defaults to the lower-privilege
* state. */
#define VX_GET_BOOTLOADER_LOCK_STATE 0x82000091
#define VX_BOOTLOADER_LOCK_STATE_LOCKED 0xDE64135Au
#define VX_BOOTLOADER_LOCK_STATE_UNLOCKED 0xC9FD41C3u
/* Unlocks the bootloader. Returns 0 in X0 on success. */
#define VX_UNLOCK_BOOTLOADER 0x82000092
/* Exits the bootloader. Returns 0 in X0 on success.
* Must be called successfully before jumping to Zircon. */
#define VX_EXIT_BOOTLOADER 0x82000093
#define GXB_EFUSE_PATTERN_SIZE (0x500)
#define GXB_IMG_SIZE (24<<20)
#define GXB_IMG_LOAD_ADDR (0x1080000)
#define GXB_IMG_DEC_KNL (1<<0)
#define GXB_IMG_DEC_RMD (1<<1)
#define GXB_IMG_DEC_DTB (1<<2)
#define GXB_IMG_DEC_ALL (GXB_IMG_DEC_KNL|GXB_IMG_DEC_RMD|GXB_IMG_DEC_DTB)
#define __asmeq(x, y) ".ifnc " x "," y " ; .err ; .endif\n\t"
void aml_set_jtag_state(unsigned state, unsigned select);
unsigned aml_get_reboot_reason(void);
unsigned aml_reboot(uint64_t function_id, uint64_t arg0, uint64_t arg1, uint64_t arg2);
unsigned long aml_sec_boot_check(unsigned long ,unsigned long ,unsigned long,unsigned long );
long get_sharemem_info(unsigned long);
void set_usb_boot_function(unsigned long command);
void aml_system_off(void);
void bl31_get_chipid(unsigned int *, unsigned int *,
unsigned int *, unsigned int *);
void set_viu_probe_enable(void);
/* Queries BL31 for permanent attributes.
*
* @in_hash: SHA256 identifying which attributes to return. Must be at least
* PERMANENT_ATTRIBUTES_HASH_SIZE in length.
* @out_attrs: full attributes will be written here if found. Must be at least
* PERMANENT_ATTRIBUTES_SIZE in length.
*
* Returns 0 on success, nonzero on failure.
*/
int bl31_get_permanent_attributes(const void *in_hash, void *out_attrs);
/* BL31 VX SIP wrappers. See documentation above. */
uint64_t bl31_vx_get_bootloader_lock_state(void);
int bl31_vx_unlock_bootloader(void);
int bl31_vx_exit_bootloader(void);
#endif