]> Git Repo - qemu.git/blobdiff - hw/pflash_cfi01.c
Fix VGA issue introduced by r6349
[qemu.git] / hw / pflash_cfi01.c
index 6113fa648bc84d9cf005e6325e24269fee532122..e41cf6967b647685b3fdad64407b55a84bdd0c11 100644 (file)
@@ -16,7 +16,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA
  */
 
 /*
@@ -194,6 +194,47 @@ static void pflash_update(pflash_t *pfl, int offset,
     }
 }
 
+static void inline pflash_data_write(pflash_t *pfl, target_ulong offset,
+                          uint32_t value, int width)
+{
+    uint8_t *p = pfl->storage;
+
+    DPRINTF("%s: block write offset " TARGET_FMT_lx
+            " value %x counter " TARGET_FMT_lx "\n",
+            __func__, offset, value, pfl->counter);
+    switch (width) {
+    case 1:
+        p[offset] = value;
+        pflash_update(pfl, offset, 1);
+        break;
+    case 2:
+#if defined(TARGET_WORDS_BIGENDIAN)
+        p[offset] = value >> 8;
+        p[offset + 1] = value;
+#else
+        p[offset] = value;
+        p[offset + 1] = value >> 8;
+#endif
+        pflash_update(pfl, offset, 2);
+        break;
+    case 4:
+#if defined(TARGET_WORDS_BIGENDIAN)
+        p[offset] = value >> 24;
+        p[offset + 1] = value >> 16;
+        p[offset + 2] = value >> 8;
+        p[offset + 3] = value;
+#else
+        p[offset] = value;
+        p[offset + 1] = value >> 8;
+        p[offset + 2] = value >> 16;
+        p[offset + 3] = value >> 24;
+#endif
+        pflash_update(pfl, offset, 4);
+        break;
+    }
+
+}
+
 static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value,
                           int width)
 {
@@ -221,6 +262,10 @@ static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value,
         switch (cmd) {
         case 0x00: /* ??? */
             goto reset_flash;
+        case 0x10: /* Single Byte Program */
+        case 0x40: /* Single Byte Program */
+            DPRINTF(stderr, "%s: Single Byte Program\n", __func__);
+            break;
         case 0x20: /* Block erase */
             p = pfl->storage;
             offset &= ~(pfl->sector_len - 1);
@@ -262,6 +307,13 @@ static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value,
         return;
     case 1:
         switch (pfl->cmd) {
+        case 0x10: /* Single Byte Program */
+        case 0x40: /* Single Byte Program */
+            DPRINTF("%s: Single Byte Program\n", __func__);
+            pflash_data_write(pfl, offset, value, width);
+            pfl->status |= 0x80; /* Ready! */
+            pfl->wcycle = 0;
+        break;
         case 0x20: /* Block erase */
         case 0x28:
             if (cmd == 0xd0) { /* confirm */
@@ -306,40 +358,7 @@ static void pflash_write (pflash_t *pfl, target_ulong offset, uint32_t value,
     case 2:
         switch (pfl->cmd) {
         case 0xe8: /* Block write */
-            p = pfl->storage;
-            DPRINTF("%s: block write offset " TARGET_FMT_lx
-                    " value %x counter " TARGET_FMT_lx "\n",
-                    __func__, offset, value, pfl->counter);
-            switch (width) {
-            case 1:
-                p[offset] = value;
-                pflash_update(pfl, offset, 1);
-                break;
-            case 2:
-#if defined(TARGET_WORDS_BIGENDIAN)
-                p[offset] = value >> 8;
-                p[offset + 1] = value;
-#else
-                p[offset] = value;
-                p[offset + 1] = value >> 8;
-#endif
-                pflash_update(pfl, offset, 2);
-                break;
-            case 4:
-#if defined(TARGET_WORDS_BIGENDIAN)
-                p[offset] = value >> 24;
-                p[offset + 1] = value >> 16;
-                p[offset + 2] = value >> 8;
-                p[offset + 3] = value;
-#else
-                p[offset] = value;
-                p[offset + 1] = value >> 8;
-                p[offset + 2] = value >> 16;
-                p[offset + 3] = value >> 24;
-#endif
-                pflash_update(pfl, offset, 4);
-                break;
-            }
+            pflash_data_write(pfl, offset, value, width);
 
             pfl->status |= 0x80;
 
@@ -500,8 +519,6 @@ pflash_t *pflash_cfi01_register(target_phys_addr_t base, ram_addr_t off,
 
     pfl = qemu_mallocz(sizeof(pflash_t));
 
-    if (pfl == NULL)
-        return NULL;
     pfl->storage = phys_ram_base + off;
     pfl->fl_mem = cpu_register_io_memory(0,
                     pflash_read_ops, pflash_write_ops, pfl);
This page took 0.022765 seconds and 4 git commands to generate.