Update GitHub action for new Meson based build
[qemu/ar7.git] / hw / block / pflash.c
blob1a909a32e2a30e494aa4be820a92f2eb9b55c5cd
1 /*
2 * QEMU interface to CFI1 und CFI2 flash emulation.
4 * Copyright (c) 2006-2011 Stefan Weil
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "qemu/osdep.h"
22 #include "hw/hw.h"
23 #include "block/block.h"
24 #include "pflash.h"
26 #ifdef PFLASH_DEBUG
27 static int traceflag;
28 #endif
30 PFlash *pflash_device_register(hwaddr base,
31 const char *name,
32 hwaddr size,
33 BlockBackend *bs, int width,
34 uint16_t flash_manufacturer,
35 uint16_t flash_type,
36 int be)
38 /* The values for blocksize and nblocks are defaults which must be
39 replaced by the correct values based on flash manufacturer and type.
40 This is done by the cfi1 and cfi2 emulation code. */
41 const uint32_t blocksize = 0x10000;
42 const uint32_t nblocks = size / blocksize;
43 const uint16_t id2 = 0x33;
44 const uint16_t id3 = 0x44;
45 PFlash *pf;
47 #ifdef PFLASH_DEBUG
48 if (getenv("DEBUG_FLASH")) {
49 traceflag = strtoul(getenv("DEBUG_FLASH"), 0, 0);
51 //~ DPRINTF("Logging enabled for FLASH in %s\n", __func__);
52 #endif
54 switch (flash_manufacturer) {
55 case MANUFACTURER_AMD:
56 case MANUFACTURER_FUJITSU:
57 case MANUFACTURER_MACRONIX:
58 #if MANUFACTURER_AMD != MANUFACTURER_SPANSION
59 case MANUFACTURER_SPANSION:
60 #endif
61 case MANUFACTURER_004A: /* Which manufacturer is this? */
62 #if 0
63 pf = pflash_amd_register(base, qdev, name, size, bs,
64 blocksize, nblocks, width,
65 flash_manufacturer, flash_type,
66 id2, id3, be);
67 #else
68 pf = (PFlash *)pflash_cfi02_register(base, name, size, bs,
69 blocksize, nblocks, 1, width,
70 flash_manufacturer, flash_type,
71 id2, id3, 0, 0, be);
72 #endif
73 break;
74 case MANUFACTURER_INTEL:
75 PFlashCFI01 *pflash_cfi01_register(hwaddr base,
76 const char *name,
77 hwaddr size,
78 BlockBackend *blk,
79 uint32_t sector_len,
80 int width,
81 uint16_t id0, uint16_t id1,
82 uint16_t id2, uint16_t id3,
83 int be);
84 pf = (PFlash *)pflash_cfi01_register(base, name, size, bs,
85 blocksize, nblocks, width,
86 flash_manufacturer, flash_type,
87 id2, id3, be);
88 break;
89 default:
90 /* TODO: fix new parameters (0) */
91 pf = (PFlash *)pflash_cfi02_register(base, name, size, bs,
92 blocksize, nblocks, 1, width,
93 flash_manufacturer, flash_type,
94 id2, id3, 0, 0, be);
96 return pf;