From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JmHBn-0004XH-Gl for qemu-devel@nongnu.org; Wed, 16 Apr 2008 19:37:19 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JmHBm-0004X5-1H for qemu-devel@nongnu.org; Wed, 16 Apr 2008 19:37:18 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JmHBl-0004X2-SG for qemu-devel@nongnu.org; Wed, 16 Apr 2008 19:37:17 -0400 Received: from savannah.gnu.org ([199.232.41.3] helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JmHBl-0005Yd-Kl for qemu-devel@nongnu.org; Wed, 16 Apr 2008 19:37:17 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1JmHBk-0006Nz-Nm for qemu-devel@nongnu.org; Wed, 16 Apr 2008 23:37:16 +0000 Received: from balrog by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1JmHBk-0006Nv-G8 for qemu-devel@nongnu.org; Wed, 16 Apr 2008 23:37:16 +0000 MIME-Version: 1.0 Errors-To: balrog Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Andrzej Zaborowski Message-Id: Date: Wed, 16 Apr 2008 23:37:16 +0000 Subject: [Qemu-devel] [4218] Allow a custom unlock address in CFI02 flash (Jan Kiszka). 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 Revision: 4218 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4218 Author: balrog Date: 2008-04-16 23:37:15 +0000 (Wed, 16 Apr 2008) Log Message: ----------- Allow a custom unlock address in CFI02 flash (Jan Kiszka). Modified Paths: -------------- trunk/hw/flash.h trunk/hw/pflash_cfi02.c trunk/hw/ppc405_boards.c Modified: trunk/hw/flash.h =================================================================== --- trunk/hw/flash.h 2008-04-16 23:17:02 UTC (rev 4217) +++ trunk/hw/flash.h 2008-04-16 23:37:15 UTC (rev 4218) @@ -13,7 +13,8 @@ BlockDriverState *bs, uint32_t sector_len, int nb_blocs, int width, uint16_t id0, uint16_t id1, - uint16_t id2, uint16_t id3); + uint16_t id2, uint16_t id3, + uint16_t unlock_addr0, uint16_t unlock_addr1); /* nand.c */ struct nand_flash_s; Modified: trunk/hw/pflash_cfi02.c =================================================================== --- trunk/hw/pflash_cfi02.c 2008-04-16 23:17:02 UTC (rev 4217) +++ trunk/hw/pflash_cfi02.c 2008-04-16 23:37:15 UTC (rev 4218) @@ -63,6 +63,7 @@ uint8_t cmd; uint8_t status; uint16_t ident[4]; + uint16_t unlock_addr[2]; uint8_t cfi_len; uint8_t cfi_table[0x52]; QEMUTimer *timer; @@ -246,9 +247,9 @@ pfl->cmd = 0x98; return; } - if (boff != 0x555 || cmd != 0xAA) { + if (boff != pfl->unlock_addr[0] || cmd != 0xAA) { DPRINTF("%s: unlock0 failed " TARGET_FMT_lx " %02x %04x\n", - __func__, boff, cmd, 0x555); + __func__, boff, cmd, pfl->unlock_addr[0]); goto reset_flash; } DPRINTF("%s: unlock sequence started\n", __func__); @@ -256,7 +257,7 @@ case 1: /* We started an unlock sequence */ check_unlock1: - if (boff != 0x2AA || cmd != 0x55) { + if (boff != pfl->unlock_addr[1] || cmd != 0x55) { DPRINTF("%s: unlock1 failed " TARGET_FMT_lx " %02x\n", __func__, boff, cmd); goto reset_flash; @@ -265,7 +266,7 @@ break; case 2: /* We finished an unlock sequence */ - if (!pfl->bypass && boff != 0x555) { + if (!pfl->bypass && boff != pfl->unlock_addr[0]) { DPRINTF("%s: command failed " TARGET_FMT_lx " %02x\n", __func__, boff, cmd); goto reset_flash; @@ -361,7 +362,7 @@ case 5: switch (cmd) { case 0x10: - if (boff != 0x555) { + if (boff != pfl->unlock_addr[0]) { DPRINTF("%s: chip erase: invalid address " TARGET_FMT_lx "\n", __func__, offset); goto reset_flash; @@ -528,7 +529,8 @@ BlockDriverState *bs, uint32_t sector_len, int nb_blocs, int width, uint16_t id0, uint16_t id1, - uint16_t id2, uint16_t id3) + uint16_t id2, uint16_t id3, + uint16_t unlock_addr0, uint16_t unlock_addr1) { pflash_t *pfl; int32_t total_len; @@ -573,6 +575,8 @@ pfl->ident[1] = id1; pfl->ident[2] = id2; pfl->ident[3] = id3; + pfl->unlock_addr[0] = unlock_addr0; + pfl->unlock_addr[1] = unlock_addr1; /* Hardcoded CFI table (mostly from SG29 Spansion flash) */ pfl->cfi_len = 0x52; /* Standard "QRY" string */ Modified: trunk/hw/ppc405_boards.c =================================================================== --- trunk/hw/ppc405_boards.c 2008-04-16 23:17:02 UTC (rev 4217) +++ trunk/hw/ppc405_boards.c 2008-04-16 23:37:15 UTC (rev 4218) @@ -236,7 +236,7 @@ #endif pflash_cfi02_register((uint32_t)(-bios_size), bios_offset, drives_table[index].bdrv, 65536, fl_sectors, 2, - 0x0001, 0x22DA, 0x0000, 0x0000); + 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA); fl_idx++; } else #endif @@ -553,7 +553,7 @@ #endif pflash_cfi02_register((uint32_t)(-bios_size), bios_offset, drives_table[index].bdrv, 65536, fl_sectors, 4, - 0x0001, 0x22DA, 0x0000, 0x0000); + 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA); fl_idx++; } else #endif @@ -589,7 +589,7 @@ #endif pflash_cfi02_register(0xfc000000, bios_offset, drives_table[index].bdrv, 65536, fl_sectors, 4, - 0x0001, 0x22DA, 0x0000, 0x0000); + 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA); fl_idx++; } /* Register CLPD & LCD display */