mknod /tmp/mtdblock0 b 31 0
modprobe mtdblock
modprobe mtdram total_size=65536 erase_size=256
modprobe jffs2
dd if=image.jffs2 of=/tmp/mtdblock0
mkdir /mnt/jffs2dd if=image.jffs2 of=/tmp/mtdblock0
mount -t jffs2 /tmp/mtdblock0 /mnt/jffs2
void show_pte(struct mm_struct *mm, unsigned long addr)
{
pgd_t *pgd;
if (!mm)
mm = &init_mm;
printk(KERN_ALERT "pgd = %p\n", mm->pgd);
pgd = pgd_offset(mm, addr);
printk(KERN_ALERT "[%08lx] *pgd=%08lx", addr, pgd_val(*pgd));
do {
pmd_t *pmd;
pte_t *pte;
if (pgd_none(*pgd))
break;
if (pgd_bad(*pgd)) {
printk("(bad)");
break;
}
pmd = pmd_offset(pgd, addr);
#if PTRS_PER_PMD != 1
printk(", *pmd=%08lx", pmd_val(*pmd));
#endif
if (pmd_none(*pmd))
break;
if (pmd_bad(*pmd)) {
printk("(bad)");
break;
}
#ifndef CONFIG_HIGHMEM
/* We must not map this if we have highmem enabled */
pte = pte_offset_map(pmd, addr);
printk(", *pte=%08lx", pte_val(*pte));
printk(", *ppte=%08lx", pte_val(pte[-PTRS_PER_PTE]));
pte_unmap(pte);
#endif
} while(0);
printk("\n");
}
| Entry | Description | Equivalent To |
|---|---|---|
| @reboot | Run once, at startup. | None |
| @yearly | Run once a year | 0 0 1 1 * |
| @annually | (same as @yearly) | 0 0 1 1 * |
| @monthly | Run once a month | 0 0 1 * * |
| @weekly | Run once a week | 0 0 * * 0 |
| @daily | Run once a day | 0 0 * * * |
| @midnight | (same as @daily) | 0 0 * * * |
| @hourly | Run once an hour | 0 * * * * |
# .---------------- minute (0 - 59) |
| min | hour | day/month | month | day/week | Execution time |
| 30 | 0 | 1 | 1,6,12 | * | -- 00:30 Hrs on 1st of Jan, June & Dec. |
: | |||||
| 0 | 20 | * | 10 | 1-5 | --8.00 PM every weekday (Mon-Fri) only in Oct. |
: | |||||
| 0 | 0 | 1,10,15 | * | * | -- midnight on 1st ,10th & 15th of month |
: | |||||
| 5,10 | 0 | 10 | * | 1 | -- At 12.05,12.10 every Monday & on 10th of every month |
| : | |||||
| */8 * * * * root init 6 | After 8 minutes , execute "reboot" command |
#include <linux/module.h>
#include <linux/config.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <asm/io.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>
typedef struct
{
void **data;
struct cdev *cdev ;
}DBG_Dev_Tag;
#define DBG_MAJOR 111
#define DBG_MINOR 1
#define MAXDEVICENUM 1
#define DEBUG_IOC_MAGIC 'D'
#define DEBUG_IOCSHOWDEB _IOR(DEBUG_IOC_MAGIC, 1, int)
DBG_Dev_Tag *DBG_devices;
int dbg_major = DBG_MAJOR;
int dbg_minor;
static struct file_operations DBG_fops =
{
.ioctl = DBG_ioctl,
.read = DBG_read,
.write = DBG_write,
.open = DBG_open,
.release = DBG_release,
};
int DBG_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg)
{
struct net_device *dev = &_wpcm450_netdevice;
switch (cmd)
{
case DEBUG_IOCSHOWDEB:
//show something
break;
default:
break;
}
return 0;
}
ssize_t DBG_read (struct file *filp, char *buf, size_t count, loff_t *offset)
{
return 0;
}
ssize_t DBG_write (struct file *file, const char *buf, size_t count, loff_t *offset)
{
return 0;
}
static int DBG_open(struct inode *inode, struct file *filp)
{
DBG_Dev_Tag *dev;
dev = container_of (inode->i_cdev,DBG_Dev_Tag,cdev);
filp-> private_data = dev;
return 0;
}
static int DBG_release(struct inode *inode, struct file *filp)
{
return 0;
}
static void dbg_setup_cdev(DBG_Dev_Tag *dev,int index)
{
int err;
int dev_id = MKDEV(dbg_major,dbg_minor + index );
cdev_init(dev->cdev,&DBG_fops);
dev->cdev->owner = THIS_MODULE;
dev->cdev->ops = &DBG_fops;
err = cdev_add(dev->cdev,dev_id,1);
if (err)
printk ("error %x adding dbg%x\n",err,index);
}
static int __init DBG_init(void)
{
int result;
dev_t dev_id;
DBG_devices = kmalloc (sizeof (DBG_Dev_Tag) * MAXDEVICENUM ,GFP_KERNEL);
if (DBG_devices == NULL)
{
result = -ENOMEM;
return result;
}
memset(DBG_devices, 0, MAXDEVICENUM * sizeof(DBG_Dev_Tag));
if (dbg_major)
{
dev_id = MKDEV(dbg_major,dbg_minor);
result = register_chrdev_region(dev_id, 1, "debug");
}
else
{
result = alloc_chrdev_region(&dev_id,DBG_MINOR,1,"dbg");
dbg_major = MAJOR(dev_id);
}
if (result < 0 )
{
printk ("can't get major %d\n",dbg_major);
return result;
}
DBG_devices->cdev = cdev_alloc();
dbg_setup_cdev(DBG_devices,1);
return 0;
}
static void __exit DBG_exit(void)
{
dev_t dev_id;
kfree(DBG_devices);
cdev_del(DBG_devices ->cdev);
dev_id = MKDEV(dbg_major,dbg_minor);
unregister_chrdev_region(dev_id,1);
return;
}
MODULE_AUTHOR("XXXXXXXXXX");
MODULE_DESCRIPTION("Debug driver");
MODULE_LICENSE("GPL");
module_init(DBG_init);
module_exit(DBG_exit);
//**************************Makefile *******************************
KERNELDIR = obj-m := test_drv.o
#combine two drivers into the one. #test_drv-objs := testA_drv.o testB_drv.o ifneq ($(KERNELRELEASE),)
CFLAGS += -D__KERNEL__ -DMODULE -Wall -DEXPORT_SYMTAB -O2
else
all:
$(MAKE) -C $(KERNELDIR) M=$(shell pwd) modules endif