1/*
2 * Copyright (c) 2020, Rebecca Cran <rebecca@bsdio.com>
3 * Copyright (c) 2014, Pluribus Networks, Inc.
4 *
5 * SPDX-License-Identifier: BSD-2-Clause-Patent
6 */
7
8#include <IndustryStandard/HighPrecisionEventTimerTable.h>
9
10#include "Platform.h"
11
12#define EFI_ACPI_HPET_DESCRIPTION_TABLE_SIGNATURE  SIGNATURE_32('H', 'P', 'E', 'T')
13#define EFI_ACPI_OEM_TABLE_ID                      SIGNATURE_64('B','V','H','P','E','T',' ',' ')
14
15//
16// Ensure proper structure formats
17//
18#pragma pack (1)
19
20//
21// ACPI HPET structure
22//
23typedef struct {
24  EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER  Header;
25} EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_DESCRIPTION_TABLE;
26
27#pragma pack ()
28
29//
30// HPET Description Table
31//
32EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_DESCRIPTION_TABLE Hpet = {
33  {
34    {
35      EFI_ACPI_HPET_DESCRIPTION_TABLE_SIGNATURE,
36      sizeof (EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_DESCRIPTION_TABLE),
37      EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_REVISION,
38      0x00,                              // Checksum will be updated at runtime
39      {EFI_ACPI_OEM_ID},
40      EFI_ACPI_OEM_TABLE_ID,
41      EFI_ACPI_OEM_REVISION,
42      EFI_ACPI_CREATOR_ID,
43      EFI_ACPI_CREATOR_REVISION
44    },
45
46    //
47    // HPET specific fields
48    //
49    0x0000A400,                          // EventTimerBlockId
50    {
51      EFI_ACPI_2_0_SYSTEM_MEMORY,
52      0,
53      0,
54      EFI_ACPI_RESERVED_BYTE,
55      0xFED00000,
56    },
57    0                                    // HpetNumber
58  }
59};
60
61
62VOID*
63ReferenceAcpiTable (
64  VOID
65  )
66{
67  //
68  // Reference the table being generated to prevent the optimizer from removing the
69  // data structure from the exeutable
70  //
71  return (VOID*)&Hpet;
72}
73