Skip to content

Commit

Permalink
drivers/heci: support the HECI2 protocol
Browse files Browse the repository at this point in the history
This is a simple implementation binding the new protocol interface to
the old one.

Change-Id: I643929fabc0e61708bb05d17af9b8b7d29be60bb
Signed-off-by: Jeremy Compostella <[email protected]>
  • Loading branch information
jeremy-compostella committed Sep 25, 2020
1 parent cabbba7 commit 0f0d3b3
Show file tree
Hide file tree
Showing 2 changed files with 201 additions and 4 deletions.
105 changes: 101 additions & 4 deletions drivers/heci/heci.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,16 @@
#include "ewlog.h"
#include "heci_impl.h"
#include "heci_protocol.h"
#include "heci2_protocol.h"

#define UNUSED_PARAM __attribute__((__unused__))

#define CPMS 19200
#define HPET_BASE_ADDRESS 0xFED00000
#define ClockCycles() read32((void *)(HPET_BASE_ADDRESS + 0xf0))

static EFI_HECI_PROTOCOL *heci;

static void init_timer(void)
{
uint32_t reg;
Expand Down Expand Up @@ -574,9 +577,77 @@ static EFI_STATUS EFIAPI HeciSubmitCommand(
return EFI_UNSUPPORTED;
}

static EFIAPI EFI_STATUS
heci2_send_w_ack(UNUSED_PARAM HECI2_DEVICE HeciDev,
UINT32 *Message,
UINT32 Length,
UINT32 *RecLength,
UINT8 HostAddress,
UINT8 MEAddress)
{
return heci->SendwACK(Message, Length, RecLength, HostAddress, MEAddress);
}

static EFIAPI EFI_STATUS
heci2_read_msg(UNUSED_PARAM HECI2_DEVICE HeciDev,
UINT32 Blocking,
UINT32 *MessageBody,
UINT32 *Length)
{
return heci->ReadMsg(Blocking, MessageBody, Length);
}

static EFIAPI EFI_STATUS
heci2_send_msg(UNUSED_PARAM HECI2_DEVICE HeciDev,
UINT32 *Message,
UINT32 Length,
UINT8 HostAddress,
UINT8 MEAddress)
{
return heci->SendMsg(Message, Length, HostAddress, MEAddress);
}

static EFIAPI EFI_STATUS
heci2_reset_heci(UNUSED_PARAM HECI2_DEVICE HeciDev)
{
return heci->ResetHeci();
}

static EFIAPI EFI_STATUS
heci2_init_heci(UNUSED_PARAM HECI2_DEVICE HeciDev)
{
return heci->InitHeci();
}

static EFIAPI EFI_STATUS
heci2_me_reset_wait(UNUSED_PARAM HECI2_DEVICE HeciDev,
UINT32 Delay)
{
return heci->SeCResetWait(Delay);
}

static EFIAPI EFI_STATUS
heci2_re_init_heci(UNUSED_PARAM HECI2_DEVICE HeciDev)
{
return heci->ReInitHeci();
}

static EFIAPI EFI_STATUS
heci2_get_me_status(UNUSED_PARAM UINT32 *Status)
{
return heci->GetSeCStatus(Status);
}

static EFIAPI EFI_STATUS
heci2_get_me_mode(UINT32 *Mode)
{
return heci->GetSeCMode(Mode);
}

static EFI_GUID heci_guid = HECI_PROTOCOL_GUID;
static EFI_HANDLE handle;
static EFI_GUID heci2_guid = EFI_HECI2_PROTOCOL_GUID;
static EFI_HANDLE handle2;

static EFI_STATUS heci_init(EFI_SYSTEM_TABLE * st)
{
Expand All @@ -594,11 +665,37 @@ static EFI_STATUS heci_init(EFI_SYSTEM_TABLE * st)
.EnableSeCPG = HeciEnableSeCPG,
.HeciSubmitCommand = HeciSubmitCommand,
};
EFI_HECI_PROTOCOL *heci_drv;
static struct EFI_HECI2_PROTOCOL_ heci2_default = {
.SendwACK = heci2_send_w_ack,
.ReadMsg = heci2_read_msg,
.SendMsg = heci2_send_msg,
.ResetHeci = heci2_reset_heci,
.InitHeci = heci2_init_heci,
.MeResetWait = heci2_me_reset_wait,
.ReInitHeci = heci2_re_init_heci,
.GetMeStatus = heci2_get_me_status,
.GetMeMode = heci2_get_me_mode
};
EFI_STATUS ret;
EFI_HECI2_PROTOCOL *heci2_drv;

ret = interface_init(st, &heci_guid, &handle,
&heci_default, sizeof(heci_default),
(void **)&heci);
if (EFI_ERROR(ret)) {
ewerr("Failed to register HECI protocol");
return ret;
}

ret = interface_init(st, &heci2_guid, &handle2,
&heci2_default, sizeof(heci2_default),
(void **)&heci2_drv);
if (EFI_ERROR(ret)) {
ewerr("Failed to register HECI2 protocol");
interface_free(st, &heci_guid, handle);
}

return interface_init(st, &heci_guid, &handle,
&heci_default, sizeof(heci_default),
(void **)&heci_drv);
return ret;
}

static EFI_STATUS heci_exit(EFI_SYSTEM_TABLE * st)
Expand Down
100 changes: 100 additions & 0 deletions drivers/heci/heci2_protocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/** @file
This protocol provides services for HECI communucation.
See more details in https://github.com/intel/efiwrapper.
Copyright (c) 2019, vit9696. All rights reserved.<BR>
Portions copyright 1999 - 2017 Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause
**/

#ifndef EFI_HECI2_H
#define EFI_HECI2_H

#define EFI_HECI2_PROTOCOL_GUID \
{ 0x3C7BC880, 0x41F8, 0x4869, { 0xAE, 0xFC, 0x87, 0x0A, 0x3E, 0xD2, 0x82, 0x99 } }

typedef UINT32 HECI2_DEVICE;
#define HECI_DEFAULT_DEVICE (0)

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_SENDWACK) (
IN HECI2_DEVICE HeciDev,
IN OUT UINT32 *Message,
IN OUT UINT32 Length,
IN OUT UINT32 *RecLength,
IN UINT8 HostAddress,
IN UINT8 MEAddress
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_READ_MESSAGE) (
IN HECI2_DEVICE HeciDev,
IN UINT32 Blocking,
IN UINT32 *MessageBody,
IN OUT UINT32 *Length
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_SEND_MESSAGE) (
IN HECI2_DEVICE HeciDev,
IN UINT32 *Message,
IN UINT32 Length,
IN UINT8 HostAddress,
IN UINT8 MEAddress
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_RESET) (
IN HECI2_DEVICE HeciDev
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_INIT) (
IN HECI2_DEVICE HeciDev
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_REINIT) (
IN HECI2_DEVICE HeciDev
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_RESET_WAIT) (
IN HECI2_DEVICE HeciDev,
IN UINT32 Delay
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_GET_ME_STATUS) (
OUT UINT32 *Status
);

typedef
EFI_STATUS
(EFIAPI *EFI_HECI2_GET_ME_MODE) (
OUT UINT32 *Mode
);

typedef struct EFI_HECI2_PROTOCOL_ {
EFI_HECI2_SENDWACK SendwACK;
EFI_HECI2_READ_MESSAGE ReadMsg;
EFI_HECI2_SEND_MESSAGE SendMsg;
EFI_HECI2_RESET ResetHeci;
EFI_HECI2_INIT InitHeci;
EFI_HECI2_RESET_WAIT MeResetWait;
EFI_HECI2_REINIT ReInitHeci;
EFI_HECI2_GET_ME_STATUS GetMeStatus;
EFI_HECI2_GET_ME_MODE GetMeMode;
} EFI_HECI2_PROTOCOL;

extern EFI_GUID gEfiHeci2ProtocolGuid;

#endif // EFI_HECI2_H

0 comments on commit 0f0d3b3

Please sign in to comment.