File: overview.html

package info (click to toggle)
mtd 20050122-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,244 kB
  • ctags: 9,869
  • sloc: ansic: 97,013; asm: 1,055; sh: 558; makefile: 356; cpp: 68
file content (73 lines) | stat: -rw-r--r-- 2,683 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
  <head>
    <title>MTD internal API documentation - overview</title>
  </head>

  <body bgcolor="white">
    <h1 align="center">MTD internal API documentation - overview</h1>

    <H2>Structure</H2>

    <P>The MTD system is divided into two types of module: 
      <I>&quot;users&quot;</I> and <I>&quot;drivers&quot;.</I></P>
    
    <P><I>Drivers</I> are the modules which provide raw read/write/erase 
      access to physical memory devices.</P>
    
    <P><I>Users</I> are the modules which use MTD drivers and provide a
      higher-level interface to user-space.</P>


    <P>We currently have four 'user' 
      modules available: FTL, NFTL, JFFS and MTDBLOCK. FTL and NFTL both 
      provide a pseudo-block device on which a 'normal' filesystem is
      placed. JFFS is a filesystem which runs directly on the flash, and 
      MTDBLOCK performs no translation - just provides a block device
      interface directly to the underlying MTD driver.
    </P>

    <P>Just because I use the word 'module', it doesn't mean that these
      have to be loadable modules. You can link them statically into your
      kernel.</P>

    <H2>Writing a driver module</H2>
    
    <P>Instructions for writing a driver are very simple:</P>
    
    <UL>
      <LI>Allocate and populate a <A HREF="mtd_info.html"><TT>struct 
	    mtd_info</TT></A> with information
	about your device, and pointers to your access routines.</LI>
      <LI>Register it by calling <A HREF="core.html#add_mtd_device">
	  <TT>add_mtd_device</TT></A></LI>
    </UL>
    
    <P>Oh yes - you have to actually write the access routines too, which
      have to conform to <A HREF="mtd_info.html#read">the rules</A>.</P>

    <H2>Writing a user module</H2>

    <P>This is only slightly more complex:</P>

    <UL>
      <LI>Write a pair of <A HREF="core.html#mtd_notifier">
	  <TT>notifier</TT></A>
	<TT>add</TT> and <TT>remove</TT> functions, which will be called 
	whenever a driver is added to, or removed from, the system, 
	respectively.</LI>
      <LI>Register them by calling <A HREF="core.html#register_mtd_notifier">
	  <TT>register_mtd_notifier</TT></A></LI>
    </UL>
    
    <P>This <EM>ought</EM> to call your notifier function immediately for
      all drivers which are already present in the system. But it doesn't 
      yet. Currently, drivers scan through calling <TT>get_mtd_device()</TT>
      to find previously-loaded drivers. This is bad and will be fixed soon.
    </P>


    <address><a href="mailto:dwmw2@infradead.org">David Woodhouse</a></address>
$Id: overview.html,v 1.1 2000/03/30 10:38:14 dwmw2 Exp $
  </body>
</html>