|
| 1 | +/*++ |
| 2 | +
|
| 3 | +SPDX-License-Identifier: MS-PL |
| 4 | +
|
| 5 | +Copyright (C) Framework Computer Inc, All Rights Reserved. |
| 6 | +
|
| 7 | +Module Name: |
| 8 | +
|
| 9 | + ec_compat_win.h |
| 10 | +
|
| 11 | +Abstract: |
| 12 | +
|
| 13 | + Windows compatibility layer for ec_commands.h from ChromiumOS EC. |
| 14 | + Include this header BEFORE ec_commands.h to provide the necessary |
| 15 | + type definitions and compiler attributes for MSVC. |
| 16 | +
|
| 17 | +Environment: |
| 18 | +
|
| 19 | + User-mode Driver Framework 2 |
| 20 | +
|
| 21 | +--*/ |
| 22 | + |
| 23 | +#pragma once |
| 24 | + |
| 25 | +#include <windows.h> |
| 26 | + |
| 27 | +/* |
| 28 | + * Suppress MSVC warnings that are unavoidable in ec_commands.h: |
| 29 | + * C4200: nonstandard extension - zero-sized array in struct/union |
| 30 | + * (used for flexible array members) |
| 31 | + */ |
| 32 | +#pragma warning(push) |
| 33 | +#pragma warning(disable: 4200) |
| 34 | + |
| 35 | +/* |
| 36 | + * Provide stdint.h-compatible type definitions using Windows types. |
| 37 | + * These must be defined before ec_commands.h is included. |
| 38 | + */ |
| 39 | +#ifndef _STDINT_WIN_COMPAT |
| 40 | +#define _STDINT_WIN_COMPAT |
| 41 | + |
| 42 | +typedef UINT8 uint8_t; |
| 43 | +typedef UINT16 uint16_t; |
| 44 | +typedef UINT32 uint32_t; |
| 45 | +typedef UINT64 uint64_t; |
| 46 | +typedef INT8 int8_t; |
| 47 | +typedef INT16 int16_t; |
| 48 | +typedef INT32 int32_t; |
| 49 | +typedef INT64 int64_t; |
| 50 | + |
| 51 | +#ifndef UINT16_MAX |
| 52 | +#define UINT16_MAX 0xFFFF |
| 53 | +#endif |
| 54 | + |
| 55 | +#endif /* _STDINT_WIN_COMPAT */ |
| 56 | + |
| 57 | +/* |
| 58 | + * MSVC doesn't support __attribute__((packed)) or __attribute__((aligned(n))). |
| 59 | + * We define __packed as empty and rely on #pragma pack() in the including file. |
| 60 | + * For __aligned, MSVC uses __declspec(align(n)). |
| 61 | + */ |
| 62 | +#ifndef __packed |
| 63 | +#define __packed |
| 64 | +#endif |
| 65 | + |
| 66 | +#ifndef __aligned |
| 67 | +#define __aligned(x) __declspec(align(x)) |
| 68 | +#endif |
| 69 | + |
| 70 | +/* |
| 71 | + * Suppress the BUILD_ASSERT macro from ec_commands.h since it may use |
| 72 | + * constructs not available in MSVC. |
| 73 | + */ |
| 74 | +#ifndef BUILD_ASSERT |
| 75 | +#define BUILD_ASSERT(_cond) |
| 76 | +#endif |
0 commit comments