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