Commit 21839329f4a3c356429cf931b4d7ef573a2b8039

Authored by Grzegorz Jabłoński
1 parent f93de95a

Added set_gpio command

hw/at91_pio.c
@@ -86,7 +86,7 @@ typedef struct PIOState { @@ -86,7 +86,7 @@ typedef struct PIOState {
86 uint32_t unknown_state; 86 uint32_t unknown_state;
87 } PIOState; 87 } PIOState;
88 88
89 -static void at91_pio_set_pin(void *opaque, int pin, int level) 89 +void at91_pio_set_pin(void *opaque, int pin, int level)
90 { 90 {
91 PIOState *s = opaque; 91 PIOState *s = opaque;
92 int mask = 1 << (pin % PIO_PINS); 92 int mask = 1 << (pin % PIO_PINS);
@@ -322,9 +322,12 @@ static void at91_pio_reset(void *opaque) @@ -322,9 +322,12 @@ static void at91_pio_reset(void *opaque)
322 s->unknown_state = 0xffffffff; 322 s->unknown_state = 0xffffffff;
323 } 323 }
324 324
  325 +void* at91_io_state = NULL;
  326 +
325 static void at91_pio_init(SysBusDevice *dev) 327 static void at91_pio_init(SysBusDevice *dev)
326 { 328 {
327 PIOState *s = FROM_SYSBUS(typeof (*s), dev); 329 PIOState *s = FROM_SYSBUS(typeof (*s), dev);
  330 + at91_io_state = s;
328 int pio_regs; 331 int pio_regs;
329 332
330 sysbus_init_irq(dev, &s->parent_irq); 333 sysbus_init_irq(dev, &s->parent_irq);
monitor.c
@@ -519,6 +519,20 @@ static void do_screen_dump(Monitor *mon, const char *filename) @@ -519,6 +519,20 @@ static void do_screen_dump(Monitor *mon, const char *filename)
519 vga_hw_screen_dump(filename); 519 vga_hw_screen_dump(filename);
520 } 520 }
521 521
  522 +static void do_set_gpio(Monitor* mon, const char* port, const char* value)
  523 +{
  524 + extern void* at91_io_state;
  525 + extern void at91_pio_set_pin(void *opaque, int pin, int level);
  526 + if (at91_io_state)
  527 + {
  528 + printf("Setting gpio: %s %s\n", port, value);
  529 + at91_pio_set_pin(at91_io_state, atoi(port), atoi(value));
  530 + }
  531 + else
  532 + printf("Cannot set pin: device pointer is NULL\n");
  533 +
  534 +}
  535 +
522 static void do_logfile(Monitor *mon, const char *filename) 536 static void do_logfile(Monitor *mon, const char *filename)
523 { 537 {
524 cpu_set_log_filename(filename); 538 cpu_set_log_filename(filename);
qemu-monitor.hx
@@ -646,6 +646,15 @@ Close the file descriptor previously assigned to @var{fdname} using the @@ -646,6 +646,15 @@ Close the file descriptor previously assigned to @var{fdname} using the
646 used by another monitor command. 646 used by another monitor command.
647 ETEXI 647 ETEXI
648 648
  649 +
  650 + { "set_gpio", "ss", do_set_gpio, "set_gpio pin value",
  651 + "set a value of a given gpio pio" },
  652 +STEXI
  653 +@item set_gpio @var{pin} @var{value}
  654 +Set the value of the given gpio pin to a specific value
  655 +ETEXI
  656 +
  657 +
649 STEXI 658 STEXI
650 @end table 659 @end table
651 ETEXI 660 ETEXI