cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

ccs-data.h (6717B)


      1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
      2/*
      3 * CCS static data in-memory data structure definitions
      4 *
      5 * Copyright 2019--2020 Intel Corporation
      6 */
      7
      8#ifndef __CCS_DATA_H__
      9#define __CCS_DATA_H__
     10
     11#include <linux/types.h>
     12
     13struct device;
     14
     15/**
     16 * struct ccs_data_block_version - CCS static data version
     17 * @version_major: Major version number
     18 * @version_minor: Minor version number
     19 * @date_year: Year
     20 * @date_month: Month
     21 * @date_day: Day
     22 */
     23struct ccs_data_block_version {
     24	u16 version_major;
     25	u16 version_minor;
     26	u16 date_year;
     27	u8 date_month;
     28	u8 date_day;
     29};
     30
     31/**
     32 * struct ccs_reg - CCS register value
     33 * @addr: The 16-bit address of the register
     34 * @len: Length of the data
     35 * @value: Data
     36 */
     37struct ccs_reg {
     38	u16 addr;
     39	u16 len;
     40	u8 *value;
     41};
     42
     43/**
     44 * struct ccs_if_rule - CCS static data if rule
     45 * @addr: Register address
     46 * @value: Register value
     47 * @mask: Value applied to both actual register value and @value
     48 */
     49struct ccs_if_rule {
     50	u16 addr;
     51	u8 value;
     52	u8 mask;
     53};
     54
     55/**
     56 * struct ccs_frame_format_desc - CCS frame format descriptor
     57 * @pixelcode: The pixelcode; CCS_DATA_BLOCK_FFD_PIXELCODE_*
     58 * @value: Value related to the pixelcode
     59 */
     60struct ccs_frame_format_desc {
     61	u8 pixelcode;
     62	u16 value;
     63};
     64
     65/**
     66 * struct ccs_frame_format_descs - A series of CCS frame format descriptors
     67 * @num_column_descs: Number of column descriptors
     68 * @num_row_descs: Number of row descriptors
     69 * @column_descs: Column descriptors
     70 * @row_descs: Row descriptors
     71 */
     72struct ccs_frame_format_descs {
     73	u8 num_column_descs;
     74	u8 num_row_descs;
     75	struct ccs_frame_format_desc *column_descs;
     76	struct ccs_frame_format_desc *row_descs;
     77};
     78
     79/**
     80 * struct ccs_pdaf_readout - CCS PDAF data readout descriptor
     81 * @pdaf_readout_info_order: PDAF readout order
     82 * @ffd: Frame format of PDAF data
     83 */
     84struct ccs_pdaf_readout {
     85	u8 pdaf_readout_info_order;
     86	struct ccs_frame_format_descs *ffd;
     87};
     88
     89/**
     90 * struct ccs_rule - A CCS static data rule
     91 * @num_if_rules: Number of if rules
     92 * @if_rules: If rules
     93 * @num_read_only_regs: Number of read-only registers
     94 * @read_only_regs: Read-only registers
     95 * @num_manufacturer_regs: Number of manufacturer-specific registers
     96 * @manufacturer_regs: Manufacturer-specific registers
     97 * @frame_format: Frame format
     98 * @pdaf_readout: PDAF readout
     99 */
    100struct ccs_rule {
    101	size_t num_if_rules;
    102	struct ccs_if_rule *if_rules;
    103	size_t num_read_only_regs;
    104	struct ccs_reg *read_only_regs;
    105	size_t num_manufacturer_regs;
    106	struct ccs_reg *manufacturer_regs;
    107	struct ccs_frame_format_descs *frame_format;
    108	struct ccs_pdaf_readout *pdaf_readout;
    109};
    110
    111/**
    112 * struct ccs_pdaf_pix_loc_block_desc - PDAF pixel location block descriptor
    113 * @block_type_id: Block type identifier, from 0 to n
    114 * @repeat_x: Number of times this block is repeated to right
    115 */
    116struct ccs_pdaf_pix_loc_block_desc {
    117	u8 block_type_id;
    118	u16 repeat_x;
    119};
    120
    121/**
    122 * struct ccs_pdaf_pix_loc_block_desc_group - PDAF pixel location block
    123 *					      descriptor group
    124 * @repeat_y: Number of times the group is repeated down
    125 * @num_block_descs: Number of block descriptors in @block_descs
    126 * @block_descs: Block descriptors
    127 */
    128struct ccs_pdaf_pix_loc_block_desc_group {
    129	u8 repeat_y;
    130	u16 num_block_descs;
    131	struct ccs_pdaf_pix_loc_block_desc *block_descs;
    132};
    133
    134/**
    135 * struct ccs_pdaf_pix_loc_pixel_desc - PDAF pixel location block descriptor
    136 * @pixel_type: Type of the pixel; CCS_DATA_PDAF_PIXEL_TYPE_*
    137 * @small_offset_x: offset X coordinate
    138 * @small_offset_y: offset Y coordinate
    139 */
    140struct ccs_pdaf_pix_loc_pixel_desc {
    141	u8 pixel_type;
    142	u8 small_offset_x;
    143	u8 small_offset_y;
    144};
    145
    146/**
    147 * struct ccs_pdaf_pix_loc_pixel_desc_group - PDAF pixel location pixel
    148 *					      descriptor group
    149 * @num_descs: Number of descriptors in @descs
    150 * @descs: PDAF pixel location pixel descriptors
    151 */
    152struct ccs_pdaf_pix_loc_pixel_desc_group {
    153	u8 num_descs;
    154	struct ccs_pdaf_pix_loc_pixel_desc *descs;
    155};
    156
    157/**
    158 * struct ccs_pdaf_pix_loc - PDAF pixel locations
    159 * @main_offset_x: Start X coordinate of PDAF pixel blocks
    160 * @main_offset_y: Start Y coordinate of PDAF pixel blocks
    161 * @global_pdaf_type: PDAF pattern type
    162 * @block_width: Width of a block in pixels
    163 * @block_height: Heigth of a block in pixels
    164 * @num_block_desc_groups: Number of block descriptor groups
    165 * @block_desc_groups: Block descriptor groups
    166 * @num_pixel_desc_grups: Number of pixel descriptor groups
    167 * @pixel_desc_groups: Pixel descriptor groups
    168 */
    169struct ccs_pdaf_pix_loc {
    170	u16 main_offset_x;
    171	u16 main_offset_y;
    172	u8 global_pdaf_type;
    173	u8 block_width;
    174	u8 block_height;
    175	u16 num_block_desc_groups;
    176	struct ccs_pdaf_pix_loc_block_desc_group *block_desc_groups;
    177	u8 num_pixel_desc_grups;
    178	struct ccs_pdaf_pix_loc_pixel_desc_group *pixel_desc_groups;
    179};
    180
    181/**
    182 * struct ccs_data_container - In-memory CCS static data
    183 * @version: CCS static data version
    184 * @num_sensor_read_only_regs: Number of the read-only registers for the sensor
    185 * @sensor_read_only_regs: Read-only registers for the sensor
    186 * @num_sensor_manufacturer_regs: Number of the manufacturer-specific registers
    187 *				  for the sensor
    188 * @sensor_manufacturer_regs: Manufacturer-specific registers for the sensor
    189 * @num_sensor_rules: Number of rules for the sensor
    190 * @sensor_rules: Rules for the sensor
    191 * @num_module_read_only_regs: Number of the read-only registers for the module
    192 * @module_read_only_regs: Read-only registers for the module
    193 * @num_module_manufacturer_regs: Number of the manufacturer-specific registers
    194 *				  for the module
    195 * @module_manufacturer_regs: Manufacturer-specific registers for the module
    196 * @num_module_rules: Number of rules for the module
    197 * @module_rules: Rules for the module
    198 * @sensor_pdaf: PDAF data for the sensor
    199 * @module_pdaf: PDAF data for the module
    200 * @license_length: Lenght of the license data
    201 * @license: License data
    202 * @end: Whether or not there's an end block
    203 * @backing: Raw data, pointed to from elsewhere so keep it around
    204 */
    205struct ccs_data_container {
    206	struct ccs_data_block_version *version;
    207	size_t num_sensor_read_only_regs;
    208	struct ccs_reg *sensor_read_only_regs;
    209	size_t num_sensor_manufacturer_regs;
    210	struct ccs_reg *sensor_manufacturer_regs;
    211	size_t num_sensor_rules;
    212	struct ccs_rule *sensor_rules;
    213	size_t num_module_read_only_regs;
    214	struct ccs_reg *module_read_only_regs;
    215	size_t num_module_manufacturer_regs;
    216	struct ccs_reg *module_manufacturer_regs;
    217	size_t num_module_rules;
    218	struct ccs_rule *module_rules;
    219	struct ccs_pdaf_pix_loc *sensor_pdaf;
    220	struct ccs_pdaf_pix_loc *module_pdaf;
    221	size_t license_length;
    222	char *license;
    223	bool end;
    224	void *backing;
    225};
    226
    227int ccs_data_parse(struct ccs_data_container *ccsdata, const void *data,
    228		   size_t len, struct device *dev, bool verbose);
    229
    230#endif /* __CCS_DATA_H__ */