]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - EmbeddedPkg/Ebl/HwIoDebug.c
EmbeddedPkg: MmcDxe: declare ECSD structure
[mirror_edk2.git] / EmbeddedPkg / Ebl / HwIoDebug.c
... / ...
CommitLineData
1/** @file\r
2 Hardware IO based debug commands\r
3\r
4 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
5 Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
6 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
7\r
8 This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16 Commands useful for debugging hardware. IO commands separated out as not all\r
17 processor architectures support the IO command.\r
18\r
19**/\r
20\r
21#include "Ebl.h"\r
22\r
23\r
24\r
25/**\r
26 Read from IO space\r
27\r
28 Argv[0] - "ioread"[.#] # is optional width 1, 2, or 4. Default 1\r
29 Argv[1] - Hex IO address\r
30\r
31 ior.4 0x3f8 ;Do a 32-bit IO Read from 0x3f8\r
32 ior 0x3f8 ;Do a 8-bit IO Read from 0x3f8\r
33\r
34 @param Argc Number of command arguments in Argv\r
35 @param Argv Array of strings that represent the parsed command line.\r
36 Argv[0] is the command name\r
37\r
38 @return EFI_SUCCESS\r
39\r
40**/\r
41EFI_STATUS\r
42EFIAPI\r
43EblIoReadCmd (\r
44 IN UINTN Argc,\r
45 IN CHAR8 **Argv\r
46 )\r
47{\r
48 UINTN Width;\r
49 UINTN Port;\r
50 UINTN Data;\r
51\r
52 if (Argc < 2) {\r
53 return EFI_INVALID_PARAMETER;\r
54 }\r
55\r
56 Port = AsciiStrHexToUintn (Argv[1]);\r
57 Width = WidthFromCommandName (Argv[0], 1);\r
58\r
59 if (Width == 1) {\r
60 Data = IoRead8 (Port);\r
61 } else if (Width == 2) {\r
62 Data = IoRead16 (Port);\r
63 } else if (Width == 4) {\r
64 Data = IoRead32 (Port);\r
65 } else {\r
66 return EFI_INVALID_PARAMETER;\r
67 }\r
68\r
69 AsciiPrint ("0x%04x = 0x%x", Port, Data);\r
70\r
71 return EFI_SUCCESS;\r
72}\r
73\r
74\r
75/**\r
76 Write to IO space\r
77\r
78 Argv[0] - "iowrite"[.#] # is optional width 1, 2, or 4. Default 1\r
79 Argv[1] - Hex IO address\r
80 Argv[2] - Hex data to write\r
81\r
82 iow.4 0x3f8 af ;Do a 32-bit IO write of af to 0x3f8\r
83 iow 0x3f8 af ;Do an 8-bit IO write of af to 0x3f8\r
84\r
85 @param Argc Number of command arguments in Argv\r
86 @param Argv Array of strings that represent the parsed command line.\r
87 Argv[0] is the command name\r
88\r
89 @return EFI_SUCCESS\r
90\r
91**/\r
92EFI_STATUS\r
93EFIAPI\r
94EblIoWriteCmd (\r
95 IN UINTN Argc,\r
96 IN CHAR8 **Argv\r
97 )\r
98{\r
99 UINTN Width;\r
100 UINTN Port;\r
101 UINTN Data;\r
102\r
103 if (Argc < 3) {\r
104 return EFI_INVALID_PARAMETER;\r
105 }\r
106\r
107 Port = AsciiStrHexToUintn (Argv[1]);\r
108 Data = AsciiStrHexToUintn (Argv[2]);\r
109 Width = WidthFromCommandName (Argv[0], 1);\r
110\r
111 if (Width == 1) {\r
112 IoWrite8 (Port, (UINT8)Data);\r
113 } else if (Width == 2) {\r
114 IoWrite16 (Port, (UINT16)Data);\r
115 } else if (Width == 4) {\r
116 IoWrite32 (Port, (UINT32)Data);\r
117 } else {\r
118 return EFI_INVALID_PARAMETER;\r
119 }\r
120 return EFI_SUCCESS;\r
121}\r
122\r
123\r
124GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHwIoDebugTemplate[] =\r
125{\r
126 {\r
127 "ioread",\r
128 "[.{1|2|4}] Port ; IO read of width byte(s) from Port",\r
129 NULL,\r
130 EblIoReadCmd\r
131 },\r
132 {\r
133 "iowrite",\r
134 "[.{1|2|4}] Port Data ; IO write Data of width byte(s) to Port",\r
135 NULL,\r
136 EblIoWriteCmd\r
137 }\r
138};\r
139\r
140\r
141\r
142/**\r
143 Initialize the commands in this in this file\r
144**/\r
145VOID\r
146EblInitializemdHwIoDebugCmds (\r
147 VOID\r
148 )\r
149{\r
150 if (FeaturePcdGet (PcdEmbeddedIoEnable)) {\r
151 EblAddCommands (mCmdHwIoDebugTemplate, sizeof (mCmdHwIoDebugTemplate)/sizeof (EBL_COMMAND_TABLE));\r
152 }\r
153}\r
154\r