xref: /DragonStub/lib/error.c (revision 99730f29b2f8874bc7bfad383ea8eb52679e8897)
1 /*++
2 
3 Copyright (c) 1998  Intel Corporation
4 
5 Module Name:
6 
7     error.c
8 
9 Abstract:
10 
11 
12 
13 
14 Revision History
15 
16 --*/
17 
18 #include "lib.h"
19 
20 
21 typedef struct {
22     EFI_STATUS	Code;
23     WCHAR		*Desc;
24 } ErrorCodeTable_Type;
25 ErrorCodeTable_Type ErrorCodeTable[] = {
26 	{  EFI_SUCCESS,                L"Success"},
27 	{  EFI_LOAD_ERROR,             L"Load Error"},
28 	{  EFI_INVALID_PARAMETER,      L"Invalid Parameter"},
29 	{  EFI_UNSUPPORTED,            L"Unsupported"},
30 	{  EFI_BAD_BUFFER_SIZE,        L"Bad Buffer Size"},
31 	{  EFI_BUFFER_TOO_SMALL,       L"Buffer Too Small"},
32 	{  EFI_NOT_READY,              L"Not Ready"},
33 	{  EFI_DEVICE_ERROR,           L"Device Error"},
34 	{  EFI_WRITE_PROTECTED,        L"Write Protected"},
35 	{  EFI_OUT_OF_RESOURCES,       L"Out of Resources"},
36 	{  EFI_VOLUME_CORRUPTED,       L"Volume Corrupt"},
37 	{  EFI_VOLUME_FULL,            L"Volume Full"},
38 	{  EFI_NO_MEDIA,               L"No Media"},
39 	{  EFI_MEDIA_CHANGED,          L"Media changed"},
40 	{  EFI_NOT_FOUND,              L"Not Found"},
41 	{  EFI_ACCESS_DENIED,          L"Access Denied"},
42 	{  EFI_NO_RESPONSE,            L"No Response"},
43 	{  EFI_NO_MAPPING,             L"No mapping"},
44 	{  EFI_TIMEOUT,                L"Time out"},
45 	{  EFI_NOT_STARTED,            L"Not started"},
46 	{  EFI_ALREADY_STARTED,        L"Already started"},
47 	{  EFI_ABORTED,                L"Aborted"},
48 	{  EFI_ICMP_ERROR,             L"ICMP Error"},
49 	{  EFI_TFTP_ERROR,             L"TFTP Error"},
50 	{  EFI_PROTOCOL_ERROR,         L"Protocol Error"},
51 	{  EFI_INCOMPATIBLE_VERSION,   L"Incompatible Version"},
52 	{  EFI_SECURITY_VIOLATION,     L"Security Policy Violation"},
53 	{  EFI_CRC_ERROR,              L"CRC Error"},
54 	{  EFI_END_OF_MEDIA,           L"End of Media"},
55 	{  EFI_END_OF_FILE,            L"End of File"},
56 	{  EFI_INVALID_LANGUAGE,       L"Invalid Languages"},
57 	{  EFI_COMPROMISED_DATA,       L"Compromised Data"},
58 
59 	// warnings
60 	{  EFI_WARN_UNKNOWN_GLYPH,     L"Warning Unknown Glyph"},
61 	{  EFI_WARN_DELETE_FAILURE,    L"Warning Delete Failure"},
62 	{  EFI_WARN_WRITE_FAILURE,     L"Warning Write Failure"},
63 	{  EFI_WARN_BUFFER_TOO_SMALL,  L"Warning Buffer Too Small"},
64 	{  0, NULL}
65 } ;
66 
67 
68 VOID
69 StatusToString (
70     OUT CHAR16          *Buffer,
71     IN EFI_STATUS       Status
72     )
73 {
74     UINTN           Index;
75 
76     for (Index = 0; ErrorCodeTable[Index].Desc; Index +=1) {
77         if (ErrorCodeTable[Index].Code == Status) {
78 	    StrCpy (Buffer, ErrorCodeTable[Index].Desc);
79             return;
80         }
81     }
82 
83     UnicodeSPrint (Buffer, 0, L"%X", Status);
84 }
85