162306a36Sopenharmony_ci/* SPDX-License-Identifier: MIT */ 262306a36Sopenharmony_ci/* Copyright (C) 2006-2017 Oracle Corporation */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef __HGSMI_DEFS_H__ 562306a36Sopenharmony_ci#define __HGSMI_DEFS_H__ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci/* Buffer sequence type mask. */ 862306a36Sopenharmony_ci#define HGSMI_BUFFER_HEADER_F_SEQ_MASK 0x03 962306a36Sopenharmony_ci/* Single buffer, not a part of a sequence. */ 1062306a36Sopenharmony_ci#define HGSMI_BUFFER_HEADER_F_SEQ_SINGLE 0x00 1162306a36Sopenharmony_ci/* The first buffer in a sequence. */ 1262306a36Sopenharmony_ci#define HGSMI_BUFFER_HEADER_F_SEQ_START 0x01 1362306a36Sopenharmony_ci/* A middle buffer in a sequence. */ 1462306a36Sopenharmony_ci#define HGSMI_BUFFER_HEADER_F_SEQ_CONTINUE 0x02 1562306a36Sopenharmony_ci/* The last buffer in a sequence. */ 1662306a36Sopenharmony_ci#define HGSMI_BUFFER_HEADER_F_SEQ_END 0x03 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* 16 bytes buffer header. */ 1962306a36Sopenharmony_cistruct hgsmi_buffer_header { 2062306a36Sopenharmony_ci u32 data_size; /* Size of data that follows the header. */ 2162306a36Sopenharmony_ci u8 flags; /* HGSMI_BUFFER_HEADER_F_* */ 2262306a36Sopenharmony_ci u8 channel; /* The channel the data must be routed to. */ 2362306a36Sopenharmony_ci u16 channel_info; /* Opaque to the HGSMI, used by the channel. */ 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci union { 2662306a36Sopenharmony_ci /* Opaque placeholder to make the union 8 bytes. */ 2762306a36Sopenharmony_ci u8 header_data[8]; 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci /* HGSMI_BUFFER_HEADER_F_SEQ_SINGLE */ 3062306a36Sopenharmony_ci struct { 3162306a36Sopenharmony_ci u32 reserved1; /* A reserved field, initialize to 0. */ 3262306a36Sopenharmony_ci u32 reserved2; /* A reserved field, initialize to 0. */ 3362306a36Sopenharmony_ci } buffer; 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci /* HGSMI_BUFFER_HEADER_F_SEQ_START */ 3662306a36Sopenharmony_ci struct { 3762306a36Sopenharmony_ci /* Must be the same for all buffers in the sequence. */ 3862306a36Sopenharmony_ci u32 sequence_number; 3962306a36Sopenharmony_ci /* The total size of the sequence. */ 4062306a36Sopenharmony_ci u32 sequence_size; 4162306a36Sopenharmony_ci } sequence_start; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci /* 4462306a36Sopenharmony_ci * HGSMI_BUFFER_HEADER_F_SEQ_CONTINUE and 4562306a36Sopenharmony_ci * HGSMI_BUFFER_HEADER_F_SEQ_END 4662306a36Sopenharmony_ci */ 4762306a36Sopenharmony_ci struct { 4862306a36Sopenharmony_ci /* Must be the same for all buffers in the sequence. */ 4962306a36Sopenharmony_ci u32 sequence_number; 5062306a36Sopenharmony_ci /* Data offset in the entire sequence. */ 5162306a36Sopenharmony_ci u32 sequence_offset; 5262306a36Sopenharmony_ci } sequence_continue; 5362306a36Sopenharmony_ci } u; 5462306a36Sopenharmony_ci} __packed; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* 8 bytes buffer tail. */ 5762306a36Sopenharmony_cistruct hgsmi_buffer_tail { 5862306a36Sopenharmony_ci /* Reserved, must be initialized to 0. */ 5962306a36Sopenharmony_ci u32 reserved; 6062306a36Sopenharmony_ci /* 6162306a36Sopenharmony_ci * One-at-a-Time Hash: https://www.burtleburtle.net/bob/hash/doobs.html 6262306a36Sopenharmony_ci * Over the header, offset and for first 4 bytes of the tail. 6362306a36Sopenharmony_ci */ 6462306a36Sopenharmony_ci u32 checksum; 6562306a36Sopenharmony_ci} __packed; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/* 6862306a36Sopenharmony_ci * The size of the array of channels. Array indexes are u8. 6962306a36Sopenharmony_ci * Note: the value must not be changed. 7062306a36Sopenharmony_ci */ 7162306a36Sopenharmony_ci#define HGSMI_NUMBER_OF_CHANNELS 0x100 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci#endif 74