Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit 88b616c

Browse files
drivers/heci: support the HECI2 protocol
This is a simple implementation binding the new protocol interface to the old one. Change-Id: I643929fabc0e61708bb05d17af9b8b7d29be60bb Signed-off-by: Jeremy Compostella <[email protected]>
1 parent ad140b2 commit 88b616c

File tree

2 files changed

+203
-4
lines changed

2 files changed

+203
-4
lines changed

drivers/heci/heci.c

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,16 @@
4242
#include "ewlog.h"
4343
#include "heci_impl.h"
4444
#include "heci_protocol.h"
45+
#include "heci2_protocol.h"
4546

4647
#define UNUSED_PARAM __attribute__((__unused__))
4748

4849
#define CPMS 19200
4950
#define HPET_BASE_ADDRESS 0xFED00000
5051
#define ClockCycles() read32((void *)(HPET_BASE_ADDRESS + 0xf0))
5152

53+
static EFI_HECI_PROTOCOL *heci;
54+
5255
static void init_timer(void)
5356
{
5457
uint32_t reg;
@@ -574,12 +577,82 @@ static EFI_STATUS EFIAPI HeciSubmitCommand(
574577
return EFI_UNSUPPORTED;
575578
}
576579

580+
static EFIAPI EFI_STATUS
581+
heci2_send_w_ack(UNUSED_PARAM HECI2_DEVICE HeciDev,
582+
UINT32 *Message,
583+
UINT32 Length,
584+
UINT32 *RecLength,
585+
UINT8 HostAddress,
586+
UINT8 MEAddress)
587+
{
588+
return heci->SendwACK(Message, Length, RecLength, HostAddress, MEAddress);
589+
}
590+
591+
static EFIAPI EFI_STATUS
592+
heci2_read_msg(UNUSED_PARAM HECI2_DEVICE HeciDev,
593+
UINT32 Blocking,
594+
UINT32 *MessageBody,
595+
UINT32 *Length)
596+
{
597+
return heci->ReadMsg(Blocking, MessageBody, Length);
598+
}
599+
600+
static EFIAPI EFI_STATUS
601+
heci2_send_msg(UNUSED_PARAM HECI2_DEVICE HeciDev,
602+
UINT32 *Message,
603+
UINT32 Length,
604+
UINT8 HostAddress,
605+
UINT8 MEAddress)
606+
{
607+
return heci->SendMsg(Message, Length, HostAddress, MEAddress);
608+
}
609+
610+
static EFIAPI EFI_STATUS
611+
heci2_reset_heci(UNUSED_PARAM HECI2_DEVICE HeciDev)
612+
{
613+
return heci->ResetHeci();
614+
}
615+
616+
static EFIAPI EFI_STATUS
617+
heci2_init_heci(UNUSED_PARAM HECI2_DEVICE HeciDev)
618+
{
619+
return heci->InitHeci();
620+
}
621+
622+
static EFIAPI EFI_STATUS
623+
heci2_me_reset_wait(UNUSED_PARAM HECI2_DEVICE HeciDev,
624+
UINT32 Delay)
625+
{
626+
return heci->SeCResetWait(Delay);
627+
}
628+
629+
static EFIAPI EFI_STATUS
630+
heci2_re_init_heci(UNUSED_PARAM HECI2_DEVICE HeciDev)
631+
{
632+
return heci->ReInitHeci();
633+
}
634+
635+
static EFIAPI EFI_STATUS
636+
heci2_get_me_status(UNUSED_PARAM UINT32 *Status)
637+
{
638+
return heci->GetSeCStatus(Status);
639+
}
640+
641+
static EFIAPI EFI_STATUS
642+
heci2_get_me_mode(UINT32 *Mode)
643+
{
644+
return heci->GetSeCMode(Mode);
645+
}
577646

578647
static EFI_GUID heci_guid = HECI_PROTOCOL_GUID;
579648
static EFI_HANDLE handle;
649+
static EFI_GUID heci2_guid = EFI_HECI2_PROTOCOL_GUID;
650+
static EFI_HANDLE handle2;
580651

581652
static EFI_STATUS heci_init(EFI_SYSTEM_TABLE * st)
582653
{
654+
EFI_STATUS ret;
655+
583656
static EFI_HECI_PROTOCOL heci_default = {
584657
.SendwACK = HeciSendwACK,
585658
.ReadMsg = HeciReadMsg,
@@ -594,11 +667,37 @@ static EFI_STATUS heci_init(EFI_SYSTEM_TABLE * st)
594667
.EnableSeCPG = HeciEnableSeCPG,
595668
.HeciSubmitCommand = HeciSubmitCommand,
596669
};
597-
EFI_HECI_PROTOCOL *heci_drv;
670+
static struct EFI_HECI2_PROTOCOL_ heci2_default = {
671+
.SendwACK = heci2_send_w_ack,
672+
.ReadMsg = heci2_read_msg,
673+
.SendMsg = heci2_send_msg,
674+
.ResetHeci = heci2_reset_heci,
675+
.InitHeci = heci2_init_heci,
676+
.MeResetWait = heci2_me_reset_wait,
677+
.ReInitHeci = heci2_re_init_heci,
678+
.GetMeStatus = heci2_get_me_status,
679+
.GetMeMode = heci2_get_me_mode
680+
};
681+
682+
EFI_HECI2_PROTOCOL *heci2_drv;
683+
684+
ret = interface_init(st, &heci_guid, &handle,
685+
&heci_default, sizeof(heci_default),
686+
(void **)&heci);
687+
if (EFI_ERROR(ret)) {
688+
ewerr("Failed to register HECI protocol");
689+
return ret;
690+
}
691+
692+
ret = interface_init(st, &heci2_guid, &handle2,
693+
&heci2_default, sizeof(heci2_default),
694+
(void **)&heci2_drv);
695+
if (EFI_ERROR(ret)) {
696+
ewerr("Failed to register HECI2 protocol");
697+
interface_free(st, &heci_guid, handle);
698+
}
598699

599-
return interface_init(st, &heci_guid, &handle,
600-
&heci_default, sizeof(heci_default),
601-
(void **)&heci_drv);
700+
return ret;
602701
}
603702

604703
static EFI_STATUS heci_exit(EFI_SYSTEM_TABLE * st)

drivers/heci/heci2_protocol.h

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/** @file
2+
This protocol provides services for HECI communucation.
3+
See more details in https://github.com/intel/efiwrapper.
4+
5+
Copyright (c) 2019, vit9696. All rights reserved.<BR>
6+
Portions copyright 1999 - 2017 Intel Corporation. All rights reserved.<BR>
7+
SPDX-License-Identifier: BSD-2-Clause
8+
**/
9+
10+
#ifndef EFI_HECI2_H
11+
#define EFI_HECI2_H
12+
13+
#define EFI_HECI2_PROTOCOL_GUID \
14+
{ 0x3C7BC880, 0x41F8, 0x4869, { 0xAE, 0xFC, 0x87, 0x0A, 0x3E, 0xD2, 0x82, 0x99 } }
15+
16+
typedef UINT32 HECI2_DEVICE;
17+
#define HECI_DEFAULT_DEVICE (0)
18+
19+
typedef
20+
EFI_STATUS
21+
(EFIAPI *EFI_HECI2_SENDWACK) (
22+
IN HECI2_DEVICE HeciDev,
23+
IN OUT UINT32 *Message,
24+
IN OUT UINT32 Length,
25+
IN OUT UINT32 *RecLength,
26+
IN UINT8 HostAddress,
27+
IN UINT8 MEAddress
28+
);
29+
30+
typedef
31+
EFI_STATUS
32+
(EFIAPI *EFI_HECI2_READ_MESSAGE) (
33+
IN HECI2_DEVICE HeciDev,
34+
IN UINT32 Blocking,
35+
IN UINT32 *MessageBody,
36+
IN OUT UINT32 *Length
37+
);
38+
39+
typedef
40+
EFI_STATUS
41+
(EFIAPI *EFI_HECI2_SEND_MESSAGE) (
42+
IN HECI2_DEVICE HeciDev,
43+
IN UINT32 *Message,
44+
IN UINT32 Length,
45+
IN UINT8 HostAddress,
46+
IN UINT8 MEAddress
47+
);
48+
49+
typedef
50+
EFI_STATUS
51+
(EFIAPI *EFI_HECI2_RESET) (
52+
IN HECI2_DEVICE HeciDev
53+
);
54+
55+
typedef
56+
EFI_STATUS
57+
(EFIAPI *EFI_HECI2_INIT) (
58+
IN HECI2_DEVICE HeciDev
59+
);
60+
61+
typedef
62+
EFI_STATUS
63+
(EFIAPI *EFI_HECI2_REINIT) (
64+
IN HECI2_DEVICE HeciDev
65+
);
66+
67+
typedef
68+
EFI_STATUS
69+
(EFIAPI *EFI_HECI2_RESET_WAIT) (
70+
IN HECI2_DEVICE HeciDev,
71+
IN UINT32 Delay
72+
);
73+
74+
typedef
75+
EFI_STATUS
76+
(EFIAPI *EFI_HECI2_GET_ME_STATUS) (
77+
OUT UINT32 *Status
78+
);
79+
80+
typedef
81+
EFI_STATUS
82+
(EFIAPI *EFI_HECI2_GET_ME_MODE) (
83+
OUT UINT32 *Mode
84+
);
85+
86+
typedef struct EFI_HECI2_PROTOCOL_ {
87+
EFI_HECI2_SENDWACK SendwACK;
88+
EFI_HECI2_READ_MESSAGE ReadMsg;
89+
EFI_HECI2_SEND_MESSAGE SendMsg;
90+
EFI_HECI2_RESET ResetHeci;
91+
EFI_HECI2_INIT InitHeci;
92+
EFI_HECI2_RESET_WAIT MeResetWait;
93+
EFI_HECI2_REINIT ReInitHeci;
94+
EFI_HECI2_GET_ME_STATUS GetMeStatus;
95+
EFI_HECI2_GET_ME_MODE GetMeMode;
96+
} EFI_HECI2_PROTOCOL;
97+
98+
extern EFI_GUID gEfiHeci2ProtocolGuid;
99+
100+
#endif // EFI_HECI2_H

0 commit comments

Comments
 (0)