linux/drivers/mtd/devices/slram.c

// SPDX-License-Identifier: GPL-2.0-only
/*======================================================================

  This driver provides a method to access memory not used by the kernel
  itself (i.e. if the kernel commandline mem=xxx is used). To actually
  use slram at least mtdblock or mtdchar is required (for block or
  character device access).

  Usage:

  if compiled as loadable module:
    modprobe slram map=<name>,<start>,<end/offset>
  if statically linked into the kernel use the following kernel cmd.line
    slram=<name>,<start>,<end/offset>

  <name>: name of the device that will be listed in /proc/mtd
  <start>: start of the memory region, decimal or hex (0xabcdef)
  <end/offset>: end of the memory region. It's possible to use +0x1234
                to specify the offset instead of the absolute address

  NOTE:
  With slram it's only possible to map a contiguous memory region. Therefore
  if there's a device mapped somewhere in the region specified slram will
  fail to load (see kernel log if modprobe fails).

  -

  Jochen Schaeuble <[email protected]>

======================================================================*/


#include <linux/module.h>
#include <linux/uaccess.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/major.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/init.h>
#include <linux/io.h>

#include <linux/mtd/mtd.h>

#define SLRAM_MAX_DEVICES_PARAMS
#define SLRAM_BLK_SZ

#define T(fmt, args...)
#define E(fmt, args...)

slram_priv_t;

slram_mtd_list_t;

#ifdef MODULE
static char *map[SLRAM_MAX_DEVICES_PARAMS];

module_param_array(map, charp, NULL, 0);
MODULE_PARM_DESC(map, "List of memory regions to map. \"map=<name>, <start>, <length / end>\"");
#else
static char *map;
#endif

static slram_mtd_list_t *slram_mtdlist =;

static int slram_erase(struct mtd_info *, struct erase_info *);
static int slram_point(struct mtd_info *, loff_t, size_t, size_t *, void **,
		resource_size_t *);
static int slram_unpoint(struct mtd_info *, loff_t, size_t);
static int slram_read(struct mtd_info *, loff_t, size_t, size_t *, u_char *);
static int slram_write(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);

static int slram_erase(struct mtd_info *mtd, struct erase_info *instr)
{}

static int slram_point(struct mtd_info *mtd, loff_t from, size_t len,
		size_t *retlen, void **virt, resource_size_t *phys)
{}

static int slram_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
{}

static int slram_read(struct mtd_info *mtd, loff_t from, size_t len,
		size_t *retlen, u_char *buf)
{}

static int slram_write(struct mtd_info *mtd, loff_t to, size_t len,
		size_t *retlen, const u_char *buf)
{}

/*====================================================================*/

static int register_device(char *name, unsigned long start, unsigned long length)
{}

static void unregister_devices(void)
{}

static unsigned long handle_unit(unsigned long value, char *unit)
{}

static int parse_cmdline(char *devname, char *szstart, char *szlength)
{}

#ifndef MODULE

static int __init mtd_slram_setup(char *str)
{}

__setup();

#endif

static int __init init_slram(void)
{}

static void __exit cleanup_slram(void)
{}

module_init();
module_exit(cleanup_slram);

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();