3
* Marc Singer, elf@buici.com
5
* SPDX-License-Identifier: GPL-2.0+
11
* Copied from FADS ROM, Dan Malek (dmalek@jlc.net)
17
/* Display values from last command.
18
* Memory modify remembered values are different from display memory.
20
static uint in_last_addr, in_last_size;
21
static uint out_last_addr, out_last_size, out_last_value;
24
int do_portio_out (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
26
uint addr = out_last_addr;
27
uint size = out_last_size;
28
uint value = out_last_value;
33
if ((flag & CMD_FLAG_REPEAT) == 0) {
35
* New command specified. Check for a size specification.
36
* Defaults to long if no or incorrect specification.
38
size = cmd_get_data_size (argv[0], 1);
39
addr = simple_strtoul (argv[1], NULL, 16);
40
value = simple_strtoul (argv[2], NULL, 16);
42
#if defined (CONFIG_X86)
45
unsigned short port = addr;
51
unsigned char ch = value;
52
__asm__ volatile ("out %0, %%dx"::"a" (ch), "d" (port));
57
unsigned short w = value;
58
__asm__ volatile ("out %0, %%dx"::"a" (w), "d" (port));
62
__asm__ volatile ("out %0, %%dx"::"a" (value), "d" (port));
68
#endif /* CONFIG_X86 */
72
out_last_value = value;
78
out, 3, 1, do_portio_out,
79
"write datum to IO port",
80
"[.b, .w, .l] port value\n - output to IO port"
83
int do_portio_in (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
85
uint addr = in_last_addr;
86
uint size = in_last_size;
91
if ((flag & CMD_FLAG_REPEAT) == 0) {
93
* New command specified. Check for a size specification.
94
* Defaults to long if no or incorrect specification.
96
size = cmd_get_data_size (argv[0], 1);
97
addr = simple_strtoul (argv[1], NULL, 16);
99
#if defined (CONFIG_X86)
102
unsigned short port = addr;
109
__asm__ volatile ("in %%dx, %0":"=a" (ch):"d" (port));
111
printf (" %02x\n", ch);
117
__asm__ volatile ("in %%dx, %0":"=a" (w):"d" (port));
119
printf (" %04x\n", w);
125
__asm__ volatile ("in %%dx, %0":"=a" (l):"d" (port));
127
printf (" %08lx\n", l);
132
#endif /* CONFIG_X86 */
141
in, 2, 1, do_portio_in,
142
"read data from an IO port",
143
"[.b, .w, .l] port\n"
144
" - read datum from IO port"