86
/* Data and methods for pio_read_8 command */
87
static int cmd_pio_read_8(cmd_arg_t *argv);
88
static cmd_arg_t pio_read_8_argv[] = { { .type = ARG_TYPE_INT } };
89
static cmd_info_t pio_read_8_info = {
91
.description = "pio_read_8 <address> Read 1 byte from memory (or port).",
92
.func = cmd_pio_read_8,
94
.argv = pio_read_8_argv
97
/* Data and methods for pio_read_16 command */
98
static int cmd_pio_read_16(cmd_arg_t *argv);
99
static cmd_arg_t pio_read_16_argv[] = { { .type = ARG_TYPE_INT } };
100
static cmd_info_t pio_read_16_info = {
101
.name = "pio_read_16",
102
.description = "pio_read_16 <address> Read 2 bytes from memory (or port).",
103
.func = cmd_pio_read_16,
105
.argv = pio_read_16_argv
108
/* Data and methods for pio_read_32 command */
109
static int cmd_pio_read_32(cmd_arg_t *argv);
110
static cmd_arg_t pio_read_32_argv[] = { { .type = ARG_TYPE_INT } };
111
static cmd_info_t pio_read_32_info = {
112
.name = "pio_read_32",
113
.description = "pio_read_32 <address> Read 4 bytes from memory (or port).",
114
.func = cmd_pio_read_32,
116
.argv = pio_read_32_argv
119
/* Data and methods for pio_write_8 command */
120
static int cmd_pio_write_8(cmd_arg_t *argv);
121
static cmd_arg_t pio_write_8_argv[] = {
122
{ .type = ARG_TYPE_INT },
123
{ .type = ARG_TYPE_INT }
125
static cmd_info_t pio_write_8_info = {
126
.name = "pio_write_8",
127
.description = "pio_write_8 <address> <value> Write 1 byte to memory (or port).",
128
.func = cmd_pio_write_8,
130
.argv = pio_write_8_argv
133
/* Data and methods for pio_write_16 command */
134
static int cmd_pio_write_16(cmd_arg_t *argv);
135
static cmd_arg_t pio_write_16_argv[] = {
136
{ .type = ARG_TYPE_INT },
137
{ .type = ARG_TYPE_INT }
139
static cmd_info_t pio_write_16_info = {
140
.name = "pio_write_16",
141
.description = "pio_write_16 <address> <value> Write 2 bytes to memory (or port).",
142
.func = cmd_pio_write_16,
144
.argv = pio_write_16_argv
147
/* Data and methods for pio_write_32 command */
148
static int cmd_pio_write_32(cmd_arg_t *argv);
149
static cmd_arg_t pio_write_32_argv[] = {
150
{ .type = ARG_TYPE_INT },
151
{ .type = ARG_TYPE_INT }
153
static cmd_info_t pio_write_32_info = {
154
.name = "pio_write_32",
155
.description = "pio_write_32 <address> <value> Write 4 bytes to memory (or port).",
156
.func = cmd_pio_write_32,
158
.argv = pio_write_32_argv
85
161
/* Data and methods for 'reboot' command. */
86
162
static int cmd_reboot(cmd_arg_t *argv);
87
163
static cmd_info_t reboot_info = {
688
/** Read 1 byte from phys memory or io port.
690
* @param argv Argument vector.
692
* @return 0 on failure, 1 on success.
694
static int cmd_pio_read_8(cmd_arg_t *argv)
698
#ifdef IO_SPACE_BOUNDARY
699
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
700
ptr = (void *) argv[0].intval;
703
ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
706
const uint8_t val = pio_read_8(ptr);
707
printf("read %" PRIxn ": %" PRIx8 "\n", argv[0].intval, val);
709
#ifdef IO_SPACE_BOUNDARY
710
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
714
km_unmap((uintptr_t) ptr, sizeof(uint8_t));
718
/** Read 2 bytes from phys memory or io port.
720
* @param argv Argument vector.
722
* @return 0 on failure, 1 on success.
724
static int cmd_pio_read_16(cmd_arg_t *argv)
726
uint16_t *ptr = NULL;
728
#ifdef IO_SPACE_BOUNDARY
729
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
730
ptr = (void *) argv[0].intval;
733
ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
736
const uint16_t val = pio_read_16(ptr);
737
printf("read %" PRIxn ": %" PRIx16 "\n", argv[0].intval, val);
739
#ifdef IO_SPACE_BOUNDARY
740
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
744
km_unmap((uintptr_t) ptr, sizeof(uint16_t));
748
/** Read 4 bytes from phys memory or io port.
750
* @param argv Argument vector.
752
* @return 0 on failure, 1 on success.
754
static int cmd_pio_read_32(cmd_arg_t *argv)
756
uint32_t *ptr = NULL;
758
#ifdef IO_SPACE_BOUNDARY
759
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
760
ptr = (void *) argv[0].intval;
763
ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
766
const uint32_t val = pio_read_32(ptr);
767
printf("read %" PRIxn ": %" PRIx32 "\n", argv[0].intval, val);
769
#ifdef IO_SPACE_BOUNDARY
770
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
774
km_unmap((uintptr_t) ptr, sizeof(uint32_t));
778
/** Write 1 byte to phys memory or io port.
780
* @param argv Argument vector.
782
* @return 0 on failure, 1 on success.
784
static int cmd_pio_write_8(cmd_arg_t *argv)
788
#ifdef IO_SPACE_BOUNDARY
789
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
790
ptr = (void *) argv[0].intval;
793
ptr = (uint8_t *) km_map(argv[0].intval, sizeof(uint8_t),
796
printf("write %" PRIxn ": %" PRIx8 "\n", argv[0].intval,
797
(uint8_t) argv[1].intval);
798
pio_write_8(ptr, (uint8_t) argv[1].intval);
800
#ifdef IO_SPACE_BOUNDARY
801
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
805
km_unmap((uintptr_t) ptr, sizeof(uint8_t));
809
/** Write 2 bytes to phys memory or io port.
811
* @param argv Argument vector.
813
* @return 0 on failure, 1 on success.
815
static int cmd_pio_write_16(cmd_arg_t *argv)
817
uint16_t *ptr = NULL;
819
#ifdef IO_SPACE_BOUNDARY
820
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
821
ptr = (void *) argv[0].intval;
824
ptr = (uint16_t *) km_map(argv[0].intval, sizeof(uint16_t),
827
printf("write %" PRIxn ": %" PRIx16 "\n", argv[0].intval,
828
(uint16_t) argv[1].intval);
829
pio_write_16(ptr, (uint16_t) argv[1].intval);
831
#ifdef IO_SPACE_BOUNDARY
832
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
836
km_unmap((uintptr_t) ptr, sizeof(uint16_t));
840
/** Write 4 bytes to phys memory or io port.
842
* @param argv Argument vector.
844
* @return 0 on failure, 1 on success.
846
static int cmd_pio_write_32(cmd_arg_t *argv)
848
uint32_t *ptr = NULL;
850
#ifdef IO_SPACE_BOUNDARY
851
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
852
ptr = (void *) argv[0].intval;
855
ptr = (uint32_t *) km_map(argv[0].intval, sizeof(uint32_t),
858
printf("write %" PRIxn ": %" PRIx32 "\n", argv[0].intval,
859
(uint32_t) argv[1].intval);
860
pio_write_32(ptr, (uint32_t) argv[1].intval);
862
#ifdef IO_SPACE_BOUNDARY
863
if ((void *) argv->intval < IO_SPACE_BOUNDARY)
867
km_unmap((uintptr_t) ptr, sizeof(uint32_t));
606
871
/** Reboot the system.
608
873
* @param argv Argument vector.