18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * access_tokenid.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2022-2023 Huawei Technologies Co., Ltd. All rights reserved. 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _ACCESS_TOKEN_ID_H 108c2ecf20Sopenharmony_ci#define _ACCESS_TOKEN_ID_H 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <linux/ioctl.h> 138c2ecf20Sopenharmony_ci#include <linux/types.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#define ACCESS_TOKEN_ID_IOCTL_BASE 'A' 168c2ecf20Sopenharmony_ci#define MAX_PERM_GROUP_NUM 64 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cienum { 198c2ecf20Sopenharmony_ci GET_TOKEN_ID = 1, 208c2ecf20Sopenharmony_ci SET_TOKEN_ID, 218c2ecf20Sopenharmony_ci GET_FTOKEN_ID, 228c2ecf20Sopenharmony_ci SET_FTOKEN_ID, 238c2ecf20Sopenharmony_ci ADD_PERMISSIONS, 248c2ecf20Sopenharmony_ci REMOVE_PERMISSIONS, 258c2ecf20Sopenharmony_ci GET_PERMISSION, 268c2ecf20Sopenharmony_ci SET_PERMISSION, 278c2ecf20Sopenharmony_ci ACCESS_TOKENID_MAX_NR 288c2ecf20Sopenharmony_ci}; 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_citypedef struct { 318c2ecf20Sopenharmony_ci unsigned int token_uniqueid : 20; 328c2ecf20Sopenharmony_ci unsigned int res : 5; 338c2ecf20Sopenharmony_ci unsigned int render_flag : 1; 348c2ecf20Sopenharmony_ci unsigned int dlp_flag : 1; 358c2ecf20Sopenharmony_ci unsigned int type : 2; 368c2ecf20Sopenharmony_ci unsigned int version : 3; 378c2ecf20Sopenharmony_ci} access_tokenid_inner; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_citypedef struct { 408c2ecf20Sopenharmony_ci uint32_t token; 418c2ecf20Sopenharmony_ci uint32_t op_code; 428c2ecf20Sopenharmony_ci bool is_granted; 438c2ecf20Sopenharmony_ci} ioctl_set_get_perm_data; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_citypedef struct { 468c2ecf20Sopenharmony_ci uint32_t token; 478c2ecf20Sopenharmony_ci uint32_t perm[MAX_PERM_GROUP_NUM]; 488c2ecf20Sopenharmony_ci} ioctl_add_perm_data; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistruct token_perm_node { 518c2ecf20Sopenharmony_ci ioctl_add_perm_data perm_data; 528c2ecf20Sopenharmony_ci struct token_perm_node *left; 538c2ecf20Sopenharmony_ci struct token_perm_node *right; 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_GET_TOKENID \ 578c2ecf20Sopenharmony_ci _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_TOKEN_ID, unsigned long long) 588c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_SET_TOKENID \ 598c2ecf20Sopenharmony_ci _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_TOKEN_ID, unsigned long long) 608c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_GET_FTOKENID \ 618c2ecf20Sopenharmony_ci _IOR(ACCESS_TOKEN_ID_IOCTL_BASE, GET_FTOKEN_ID, unsigned long long) 628c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_SET_FTOKENID \ 638c2ecf20Sopenharmony_ci _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_FTOKEN_ID, unsigned long long) 648c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_ADD_PERMISSIONS \ 658c2ecf20Sopenharmony_ci _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, ADD_PERMISSIONS, ioctl_add_perm_data) 668c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_REMOVE_PERMISSIONS \ 678c2ecf20Sopenharmony_ci _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, REMOVE_PERMISSIONS, uint32_t) 688c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_GET_PERMISSION \ 698c2ecf20Sopenharmony_ci _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, GET_PERMISSION, ioctl_set_get_perm_data) 708c2ecf20Sopenharmony_ci#define ACCESS_TOKENID_SET_PERMISSION \ 718c2ecf20Sopenharmony_ci _IOW(ACCESS_TOKEN_ID_IOCTL_BASE, SET_PERMISSION, ioctl_set_get_perm_data) 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#endif /* _ACCESS_TOKEN_ID_H */ 74