~vcs-imports/qemu/git

« back to all changes in this revision

Viewing changes to hw/nand.c

  • Committer: ths
  • Date: 2007-06-17 15:32:30 UTC
  • Revision ID: git-v1:ffb04fcf089865952592f1f8855c2848d4514a89
Allow relative paths for the interpreter prefix in linux-user emulation.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2984 c046a42c-6fe2-441c-8c8c-71466251a162

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
#ifndef NAND_IO
13
13
 
14
 
# include "hw.h"
15
 
# include "flash.h"
16
 
# include "block.h"
17
 
/* FIXME: Pass block device as an argument.  */
18
 
# include "sysemu.h"
 
14
# include "vl.h"
19
15
 
20
16
# define NAND_CMD_READ0         0x00
21
17
# define NAND_CMD_READ1         0x01
106
102
# include "nand.c"
107
103
 
108
104
/* Information based on Linux drivers/mtd/nand/nand_ids.c */
109
 
static const struct nand_info_s {
 
105
struct nand_info_s {
110
106
    int size;
111
107
    int width;
112
108
    int page_shift;
319
315
    return 0;
320
316
}
321
317
 
 
318
static int nand_iid = 0;
 
319
 
322
320
/*
323
321
 * Chip inputs are CLE, ALE, CE, WP, GND and eight I/O pins.  Chip
324
322
 * outputs are R/B and eight I/O pins.
325
323
 *
326
324
 * CE, WP and R/B are active low.
327
325
 */
328
 
void nand_setpins(struct nand_flash_s *s,
 
326
void nand_setpins(struct nand_flash_s *s, 
329
327
                int cle, int ale, int ce, int wp, int gnd)
330
328
{
331
329
    s->cle = cle;
418
416
uint8_t nand_getio(struct nand_flash_s *s)
419
417
{
420
418
    int offset;
421
 
 
 
419
 
422
420
    /* Allow sequential reading */
423
421
    if (!s->iolen && s->cmd == NAND_CMD_READ0) {
424
422
        offset = (s->addr & ((1 << s->addr_shift) - 1)) + s->offset;
442
440
{
443
441
    int pagesize;
444
442
    struct nand_flash_s *s;
445
 
    int index;
446
443
 
447
444
    if (nand_flash_ids[chip_id].size == 0) {
448
445
        cpu_abort(cpu_single_env, "%s: Unsupported NAND chip ID.\n",
450
447
    }
451
448
 
452
449
    s = (struct nand_flash_s *) qemu_mallocz(sizeof(struct nand_flash_s));
453
 
    index = drive_get_index(IF_MTD, 0, 0);
454
 
    if (index != -1)
455
 
        s->bdrv = drives_table[index].bdrv;
 
450
    s->bdrv = mtd_bdrv;
456
451
    s->manf_id = manf_id;
457
452
    s->chip_id = chip_id;
458
453
    s->size = nand_flash_ids[s->chip_id].size << 20;
493
488
        s->storage = (uint8_t *) memset(qemu_malloc(s->pages * pagesize),
494
489
                        0xff, s->pages * pagesize);
495
490
 
496
 
    register_savevm("nand", -1, 0, nand_save, nand_load, s);
 
491
    register_savevm("nand", nand_iid ++, 0, nand_save, nand_load, s);
497
492
 
498
493
    return s;
499
494
}