hc
2024-03-25 edb30157bad0c0001c32b854271ace01d3b9a16a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/** @file
  BeepMap implementation.
 
  Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent
 
**/
 
#include <Base.h>
#include <Uefi.h>
 
#include "PlatformStatusCodesInternal.h"
 
STATUS_CODE_TO_DATA_MAP mBeepProgressMap[] = {
  //
  // PEI
  //
  // Recovery
  { PEI_RECOVERY_STARTED, 2 },
 
  //
  // DXE
  //
 
  {0,0}
};
 
STATUS_CODE_TO_DATA_MAP mBeepErrorMap[] = {
  //
  // PEI
  //
  // Regular boot
  { PEI_MEMORY_NOT_DETECTED, 1 },
  { PEI_MEMORY_INSTALLED_TWICE, 1 },
  { PEI_DXEIPL_NOT_FOUND, 3 },
  { PEI_DXE_CORE_NOT_FOUND, 3 },
  { PEI_RESET_NOT_AVAILABLE, 7 },
  // Recovery
  { PEI_RECOVERY_FAILED, 4 },
  // S3 Resume
  { PEI_S3_RESUME_FAILED, 4 },
 
  //
  // DXE
  //
  { DXE_ARCH_PROTOCOL_NOT_AVAILABLE, 4 },
  { DXE_NO_CON_OUT, 5 },
  { DXE_NO_CON_IN, 5 },
  { DXE_INVALID_PASSWORD, 1 },
  { DXE_FLASH_UPDATE_FAILED, 6 },
  { DXE_RESET_NOT_AVAILABLE, 7 },
 
  {0,0}
};
 
STATUS_CODE_TO_DATA_MAP *mBeepStatusCodesMap[] = {
  //#define EFI_PROGRESS_CODE 0x00000001
  mBeepProgressMap,
  //#define EFI_ERROR_CODE 0x00000002
  mBeepErrorMap
  //#define EFI_DEBUG_CODE 0x00000003
};
 
/**
  Find the beep data from status code value.
 
  @param  Map              The map used to find in.
  @param  Value            The status code value.
 
  @return BeepValue        0 for not found.
 
**/
UINT32
FindBeepData (
  IN STATUS_CODE_TO_DATA_MAP *Map,
  IN EFI_STATUS_CODE_VALUE   Value
  )
{
  while (Map->Value != 0) {
    if (Map->Value == Value) {
      return Map->Data;
    }
    Map++;
  }
  return 0;
}
 
/**
  Get BeepValue from status code type and value.
 
  @param  CodeType         Indicates the type of status code being reported.
  @param  Value            Describes the current status of a hardware or
                           software entity. This includes information about the class and
                           subclass that is used to classify the entity as well as an operation.
                           For progress codes, the operation is the current activity.
                           For error codes, it is the exception.For debug codes,it is not defined at this time.
 
  @return BeepValue
**/
UINT32
EFIAPI
GetBeepValueFromStatusCode (
  IN EFI_STATUS_CODE_TYPE           CodeType,
  IN EFI_STATUS_CODE_VALUE          Value
  )
{
  UINT32 CodeTypeIndex;
 
  CodeTypeIndex = STATUS_CODE_TYPE (CodeType) - 1;
 
  if (CodeTypeIndex >= sizeof (mBeepStatusCodesMap) / sizeof(mBeepStatusCodesMap[0])) {
    return 0;
  }
 
  return FindBeepData (mBeepStatusCodesMap[CodeTypeIndex], Value);
}