From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Jybhv-0005My-Oc for qemu-devel@nongnu.org; Tue, 20 May 2008 19:57:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Jybht-0005KM-8O for qemu-devel@nongnu.org; Tue, 20 May 2008 19:57:26 -0400 Received: from [199.232.76.173] (port=47894 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Jybhs-0005Jn-6S for qemu-devel@nongnu.org; Tue, 20 May 2008 19:57:24 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:51753) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Jybhr-0005Yg-6c for qemu-devel@nongnu.org; Tue, 20 May 2008 19:57:23 -0400 Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate02.web.de (Postfix) with ESMTP id B3AD0DD7E838 for ; Wed, 21 May 2008 01:57:22 +0200 (CEST) Received: from [88.64.29.161] (helo=[192.168.1.198]) by smtp07.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1Jybhq-0006TQ-00 for qemu-devel@nongnu.org; Wed, 21 May 2008 01:57:22 +0200 Message-ID: <48336562.7000601@web.de> Date: Wed, 21 May 2008 01:57:22 +0200 From: Jan Kiszka MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 3/3] MusicPal: Add specific -hold-button option Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org [ adapted to new QEMUOptionSet abstraction ] MusicPal's U-Boot is able to start in a special mode (firmware recovery) in case one of the control buttons is pressed during power-up. As with QEMU, there is no chance to achieve this by hand (except for artificially delaying the power-up with sleep()), this patch adds a MusicPal-specific command line option -hold-button. The option takes button codes and simulates those buttons as pressed on power-up. Signed-off-by: Jan Kiszka --- hw/musicpal.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 7 deletions(-) Index: b/hw/musicpal.c =================================================================== --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -62,6 +62,7 @@ static uint32_t gpio_in_state = 0xffffff static uint32_t gpio_isr; static uint32_t gpio_out_state; static ram_addr_t sram_off; +static int powerup_hold_button; /* Address conversion helpers */ static void *target2host_addr(uint32_t addr) @@ -1344,6 +1345,12 @@ static void musicpal_key_event(void *opa uint32_t event = 0; static int kbd_extended; + if (powerup_hold_button) { + powerup_hold_button = 0; + gpio_in_state |= MP_GPIO_BTN_FAVORITS | MP_GPIO_BTN_VOLUME | + MP_GPIO_BTN_NAVIGATION | MP_GPIO_BTN_MENU; + } + if (keycode == KEYCODE_EXTENDED) { kbd_extended = 1; return; @@ -1491,12 +1498,6 @@ static void musicpal_init(ram_addr_t ram qemu_add_kbd_event_handler(musicpal_key_event, pic[MP_GPIO_IRQ]); - /* - * Wait a bit to catch menu button during U-Boot start-up - * (to trigger emergency update). - */ - sleep(1); - mv88w8618_eth_init(&nd_table[0], MP_ETH_BASE, pic[MP_ETH_IRQ]); mixer_i2c = musicpal_audio_init(MP_AUDIO_BASE, pic[MP_AUDIO_IRQ]); @@ -1508,9 +1509,49 @@ static void musicpal_init(ram_addr_t ram arm_load_kernel(env, &musicpal_binfo); } +static void musicpal_parse_options(int index, const char *optarg) +{ + switch (*optarg) { + case 'f': + gpio_in_state &= ~MP_GPIO_BTN_FAVORITS; + break; + case 'm': + gpio_in_state &= ~MP_GPIO_BTN_MENU; + break; + case 'n': + gpio_in_state &= ~MP_GPIO_BTN_NAVIGATION; + break; + case 'v': + gpio_in_state &= ~MP_GPIO_BTN_VOLUME; + break; + default: + fprintf(stderr, "Invalid button specified: %c\n", *optarg); + exit(1); + } + powerup_hold_button = 1; +} + +static const QEMUOption musicpal_options[] = { + { "hold-button", HAS_ARG, 0 }, + { NULL } +}; + +static QEMUOptionSet musicpal_option_set = { + .options = musicpal_options, + .help_string = + "MusicPal specific options:\n" + "-hold-button [f][m][n][v]\n" + " Hold favorits (f), menu (m), navigation (n), or volume(v)\n" + " button on power-up to trigger special services. The button\n" + " is released on next keystroke.\n" + "\n", + .parse_handler = musicpal_parse_options +}; + QEMUMachine musicpal_machine = { "musicpal", "Marvell 88w8618 / MusicPal (ARM926EJ-S)", musicpal_init, - MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED + MP_RAM_DEFAULT_SIZE + MP_SRAM_SIZE + MP_FLASH_SIZE_MAX + RAMSIZE_FIXED, + &musicpal_option_set };