Skip to contentSkip to conversation

why MTD model ?

DISCUSSION Stephan Linke 1 participant 1 message Jun 14, 2002 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hi!

Quoted 4 lines

Can somehow we treat(emulate) memory device as a block device and treat memory device like a hard disk ?

Maybe I didn't got the point. But if you like to use some (maybe battery backuped) memory with a filesystem on it you could setup your MTD device just like this:

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

static void* memremap;

static struct mtd_info *myrammtd;

__u8 my_ram_read8(struct map_info *map, unsigned long ofs)

{
    return *(__u8 *)(memremap  + ofs);
}

...

struct map_info my_ram_map = {
    name: "MY bbram    ",
    size: RAM_WINDOW_SIZE,
    buswidth: 4,
    read8: my_ram_read8,
    read16: my_ram_read16,
    read32: my_ram_read32,
    copy_from: my_ram_copy_from,
    write8: my_ram_write8,
    write16: my_ram_write16,
    write32: my_ram_write32,
    copy_to: my_ram_copy_to
};

...

        myrammtd = do_map_probe("map_ram", &my_ram_map);          
            
        if (myrammtd) {
            memremap = ioremap (RAM_WINDOW_ADDR, RAM_WINDOW_SIZE);
            add_mtd_device (myrammtd);
        } else {
            printk ("mtd/my.o: error installing bbdram device!\n");
        }
        return 0;

...

<<<<
(If someone thinks that this is the wrong way, feel free to send comments.) :o)

Stephan Linke

Quoted 1 line