blob: 12fa374a8ba23716e838ab71e592a3bbb0eb587d [file] [log] [blame]
Neeti Desai8dcc3642015-03-17 18:20:35 -07001/*
Sudarshan Rajagopalanc9342282017-05-18 00:11:06 -07002 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Neeti Desai8dcc3642015-03-17 18:20:35 -07003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __QCOM_SECURE_BUFFER_H__
16#define __QCOM_SECURE_BUFFER_H__
17
Mitchel Humpherys5f2e3432015-10-12 18:13:06 -070018#include <linux/scatterlist.h>
Neeti Desai8dcc3642015-03-17 18:20:35 -070019
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070020/*
21 * if you add a secure VMID here make sure you update
Patrick Daly152e05a2016-07-08 14:34:44 -070022 * msm_secure_vmid_to_string.
23 * Make sure to keep the VMID_LAST as the last entry in the enum.
24 * This is needed in ion to create a list and it's sized using VMID_LAST.
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070025 */
Patrick Daly152e05a2016-07-08 14:34:44 -070026enum vmid {
27 VMID_HLOS = 0x3,
28 VMID_CP_TOUCH = 0x8,
29 VMID_CP_BITSTREAM = 0x9,
30 VMID_CP_PIXEL = 0xA,
31 VMID_CP_NON_PIXEL = 0xB,
32 VMID_CP_CAMERA = 0xD,
33 VMID_HLOS_FREE = 0xE,
34 VMID_MSS_MSA = 0xF,
35 VMID_MSS_NONMSA = 0x10,
36 VMID_CP_SEC_DISPLAY = 0x11,
37 VMID_CP_APP = 0x12,
38 VMID_WLAN = 0x18,
39 VMID_WLAN_CE = 0x19,
Sudarshan Rajagopalanc9342282017-05-18 00:11:06 -070040 VMID_CP_SPSS_SP = 0x1A,
Liam Markd9a50852016-09-22 11:30:51 -070041 VMID_CP_CAMERA_PREVIEW = 0x1D,
Sudarshan Rajagopalan8e206792017-06-28 17:45:57 -070042 VMID_CP_SPSS_SP_SHARED = 0x22,
Sudarshan Rajagopalane08afb62017-07-13 11:19:46 -070043 VMID_CP_SPSS_HLOS_SHARED = 0x24,
Patrick Daly152e05a2016-07-08 14:34:44 -070044 VMID_LAST,
45 VMID_INVAL = -1
46};
Neeti Desai0e64e702015-03-31 15:33:54 -070047
48#define PERM_READ 0x4
49#define PERM_WRITE 0x2
Shrenuj Bansal395a3122015-07-02 16:08:53 -070050#define PERM_EXEC 0x1
Neeti Desai0e64e702015-03-31 15:33:54 -070051
Neeti Desai8dcc3642015-03-17 18:20:35 -070052#ifdef CONFIG_QCOM_SECURE_BUFFER
Neeti Desai0e64e702015-03-31 15:33:54 -070053int hyp_assign_table(struct sg_table *table,
54 u32 *source_vm_list, int source_nelems,
55 int *dest_vmids, int *dest_perms,
56 int dest_nelems);
Sarada Prasanna Garnayak31539162017-03-14 19:14:05 +053057extern int hyp_assign_phys(phys_addr_t addr, u64 size,
Neeti Desaif85f5662015-06-05 18:44:24 -070058 u32 *source_vmlist, int source_nelems,
59 int *dest_vmids, int *dest_perms, int dest_nelems);
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070060const char *msm_secure_vmid_to_string(int secure_vmid);
Neeti Desai8dcc3642015-03-17 18:20:35 -070061#else
Jeremy Gebben33b9a212016-02-10 10:38:11 -070062static inline int hyp_assign_table(struct sg_table *table,
Neeti Desai0e64e702015-03-31 15:33:54 -070063 u32 *source_vm_list, int source_nelems,
64 int *dest_vmids, int *dest_perms,
65 int dest_nelems)
66{
67 return -EINVAL;
68}
Neeti Desaif85f5662015-06-05 18:44:24 -070069
70static inline int hyp_assign_phys(phys_addr_t addr, u64 size,
71 u32 *source_vmlist, int source_nelems,
72 int *dest_vmids, int *dest_perms, int dest_nelems)
Neeti Desai8dcc3642015-03-17 18:20:35 -070073{
74 return -EINVAL;
75}
Neeti Desaif85f5662015-06-05 18:44:24 -070076
Jeremy Gebben33b9a212016-02-10 10:38:11 -070077static inline const char *msm_secure_vmid_to_string(int secure_vmid)
Mitchel Humpherys5b8290a2015-07-30 19:24:15 -070078{
79 return "N/A";
80}
Neeti Desai8dcc3642015-03-17 18:20:35 -070081#endif
82#endif