Skip to content

Commit 0ef7df9

Browse files
committed
Try to make the chrome header compile
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 86bb51e commit 0ef7df9

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

FrameworkArgb/EcCommunication.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ extern "C" {
3030
#include <wdf.h>
3131
#include "trace.h"
3232

33+
#include "ec_compat_win.h"
34+
#pragma pack(push, 1)
3335
#include "ec_commands.h"
36+
#pragma pack(pop)
37+
#pragma warning(pop) /* matches push in ec_compat_win.h */
3438

3539
#define FILE_DEVICE_CROS_EMBEDDED_CONTROLLER 0x80EC
3640

FrameworkArgb/ec_commands.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#ifndef __CROS_EC_EC_COMMANDS_H
99
#define __CROS_EC_EC_COMMANDS_H
1010

11-
#if !defined(__ACPI__) && !defined(__KERNEL__)
11+
#if !defined(__ACPI__) && !defined(__KERNEL__) && !defined(_MSC_VER)
1212
#include <stdint.h>
1313
#endif
1414

FrameworkArgb/ec_compat_win.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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

Comments
 (0)