You can subscribe to this list here.
2001 |
Jan
|
Feb
(4) |
Mar
(47) |
Apr
(27) |
May
(113) |
Jun
|
Jul
|
Aug
(1) |
Sep
(15) |
Oct
(25) |
Nov
|
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(17) |
Feb
(5) |
Mar
(5) |
Apr
(2) |
May
(16) |
Jun
|
Jul
|
Aug
(15) |
Sep
(28) |
Oct
(78) |
Nov
(39) |
Dec
|
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Adrian M. <zx8...@us...> - 2002-09-18 22:49:17
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices In directory usw-pr-cvs1:/tmp/cvs-serv2545/drivers/mtd/devices Modified Files: Config.in vmublk.c Log Message: vmublk code tidied up Index: Config.in =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices/Config.in,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Config.in 18 Sep 2002 20:17:56 -0000 1.1 +++ Config.in 18 Sep 2002 22:49:14 -0000 1.2 @@ -51,8 +51,8 @@ fi fi -if ["$CONFIG_MTD_VMU" = "y"]; then - dep_tristate ' SEGA Dreamcast VMU block device driver' CONFIG_MTD_VMUBLK -fi +comment 'SEGA Dreamcast Visual Memory Unit' + dep_tristate ' SEGA Dreamcast VMU block device driver' CONFIG_MTD_VMUBLK $CONFIG_MTD_VMU + endmenu Index: vmublk.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices/vmublk.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- vmublk.c 18 Sep 2002 20:06:28 -0000 1.1 +++ vmublk.c 18 Sep 2002 22:49:14 -0000 1.2 @@ -1,7 +1,7 @@ /* * * - * VMU Flash File System Driver for LinuxDC + * VMU Flash Block Driver for LinuxDC * http://sourceforge.net/projects/linuxdc * * Copyright, Adrian McMenamin, 2002 @@ -20,8 +20,6 @@ * */ -#define VMUFS_DEBUG -#define CONFIG_DEVFS_FS @@ -35,7 +33,7 @@ #include <linux/fs.h> #include <linux/blkdev.h> -#define DEVICE_NAME "vmufs" +#define DEVICE_NAME "vmublk" #define DEVICE_NR(device) (device) #define MAJOR_NR MTD_BLOCK_MAJOR #define DEVICE_NO_RANDOM @@ -110,7 +108,7 @@ struct mtd_info *mtd; int dev; - DEBUG(MTD_DEBUG_LEVEL1, "vmuflash_fs_open\n"); + DEBUG(MTD_DEBUG_LEVEL1, "vmublk_open\n"); if (!inode) return -EINVAL; @@ -182,7 +180,7 @@ { int dev; struct vmublk_dev *vmublk; - DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); + DEBUG(MTD_DEBUG_LEVEL1, "vmublock_release\n"); if (inode == NULL) release_return(-ENODEV); @@ -295,7 +293,7 @@ static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING - "vmufs: requested an unknown device: %i\n", + "vmublk: requested an unknown device: %i\n", devno); return -1; } @@ -321,7 +319,7 @@ static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING - "vmufs: failed on read\n"); + "vmublk: failed on read\n"); break; } @@ -406,13 +404,13 @@ vmublk_size[i] = 0; vmublksize_size[i] = 0; /* Not fixed (in theory) for DC vmu flash */ } - /* init_waitqueue_head(&vmufs_wq); */ + blksize_size[MAJOR_NR] = vmublksize_size; blk_size[MAJOR_NR] = vmublk_size; blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), &vmufs_request); -/*kernel_thread (vmufs_thread, NULL, CLONE_FS|CLONE_FILES|CLONE_SIGHAND); *//* Do I need this? */ + return 0; } @@ -420,9 +418,6 @@ static void __exit exit_vmufs(void) { - /* leaving = 1; - wake_up(&thr_wq); - down(&thread_sem); */ #ifdef CONFIG_DEVFS_FS unregister_mtd_user(¬ifier); devfs_unregister(devfs_dir_handle); |
From: Adrian M. <zx8...@us...> - 2002-09-18 20:23:28
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv14369 Modified Files: ChangeLog.dc Log Message: Makefile support for vmublk added Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- ChangeLog.dc 18 Sep 2002 20:17:56 -0000 1.51 +++ ChangeLog.dc 18 Sep 2002 20:23:25 -0000 1.52 @@ -1,6 +1,8 @@ 2002-09-18 Adrian McMenamin <ad...@mc...> - *drivers/mtd/devices/config.in: support for vmu + * drivers/mtd/devices/Makefile: Makefile support + + *drivers/mtd/devices/Config.in: support for vmu block device added *drivers/mtd/devices/vmublk.c: vmu block device |
From: Adrian M. <zx8...@us...> - 2002-09-18 20:23:28
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices In directory usw-pr-cvs1:/tmp/cvs-serv14369/drivers/mtd/devices Added Files: Makefile Log Message: Makefile support for vmublk added --- NEW FILE: Makefile --- # # linux/drivers/devices/Makefile # # $Id: Makefile,v 1.1 2002/09/18 20:23:25 zx80user Exp $ O_TARGET := devlink.o # *** BIG UGLY NOTE *** # # The removal of get_module_symbol() and replacement with # inter_module_register() et al has introduced a link order dependency # here where previously there was none. We now have to ensure that # doc200[01].o are linked before docprobe.o obj-$(CONFIG_MTD_DOC1000) += doc1000.o obj-$(CONFIG_MTD_DOC2000) += doc2000.o obj-$(CONFIG_MTD_DOC2001) += doc2001.o obj-$(CONFIG_MTD_DOCPROBE) += docprobe.o docecc.o obj-$(CONFIG_MTD_SLRAM) += slram.o obj-$(CONFIG_MTD_PMC551) += pmc551.o obj-$(CONFIG_MTD_MTDRAM) += mtdram.o obj-$(CONFIG_MTD_LART) += lart.o obj-$(CONFIG_MTD_BLKMTD) += blkmtd.o obj-$(CONFIG_MTD_VMUBLK) += vmublk.o include $(TOPDIR)/Rules.make |
From: Adrian M. <zx8...@us...> - 2002-09-18 20:18:00
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv12487 Modified Files: ChangeLog.dc Log Message: Configuration support for vmublk added Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- ChangeLog.dc 18 Sep 2002 20:06:28 -0000 1.50 +++ ChangeLog.dc 18 Sep 2002 20:17:56 -0000 1.51 @@ -1,5 +1,8 @@ 2002-09-18 Adrian McMenamin <ad...@mc...> + *drivers/mtd/devices/config.in: support for vmu + block device added + *drivers/mtd/devices/vmublk.c: vmu block device driver added |
From: Adrian M. <zx8...@us...> - 2002-09-18 20:18:00
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices In directory usw-pr-cvs1:/tmp/cvs-serv12487/drivers/mtd/devices Added Files: Config.in Log Message: Configuration support for vmublk added --- NEW FILE: Config.in --- # drivers/mtd/maps/Config.in # $Id: Config.in,v 1.1 2002/09/18 20:17:56 zx80user Exp $ mainmenu_option next_comment comment 'Self-contained MTD device drivers' dep_tristate ' Ramix PMC551 PCI Mezzanine RAM card support' CONFIG_MTD_PMC551 $CONFIG_MTD $CONFIG_PCI if [ "$CONFIG_MTD_PMC551" = "y" -o "$CONFIG_MTD_PMC551" = "m" ]; then bool ' PMC551 256M DRAM Bugfix' CONFIG_MTD_PMC551_BUGFIX bool ' PMC551 Debugging' CONFIG_MTD_PMC551_DEBUG fi dep_tristate ' Uncached system RAM' CONFIG_MTD_SLRAM $CONFIG_MTD if [ "$CONFIG_SA1100_LART" = "y" ]; then dep_tristate ' 28F160xx flash driver for LART' CONFIG_MTD_LART $CONFIG_MTD fi dep_tristate ' Test driver using RAM' CONFIG_MTD_MTDRAM $CONFIG_MTD if [ "$CONFIG_MTD_MTDRAM" = "y" -o "$CONFIG_MTD_MTDRAM" = "m" ]; then int 'MTDRAM device size in KiB' CONFIG_MTDRAM_TOTAL_SIZE 4096 int 'MTDRAM erase block size in KiB' CONFIG_MTDRAM_ERASE_SIZE 128 if [ "$CONFIG_MTD_MTDRAM" = "y" ]; then #If not a module (I don't want to test it as a module) hex 'SRAM Hexadecimal Absolute position or 0' CONFIG_MTDRAM_ABS_POS 0 fi fi dep_tristate ' MTD emulation using block device' CONFIG_MTD_BLKMTD $CONFIG_MTD comment 'Disk-On-Chip Device Drivers' dep_tristate ' M-Systems Disk-On-Chip 1000' CONFIG_MTD_DOC1000 $CONFIG_MTD dep_tristate ' M-Systems Disk-On-Chip 2000 and Millennium' CONFIG_MTD_DOC2000 $CONFIG_MTD dep_tristate ' M-Systems Disk-On-Chip Millennium-only alternative driver (see help)' CONFIG_MTD_DOC2001 $CONFIG_MTD if [ "$CONFIG_MTD_DOC2001" = "y" -o "$CONFIG_MTD_DOC2000" = "y" ]; then define_bool CONFIG_MTD_DOCPROBE y else if [ "$CONFIG_MTD_DOC2001" = "m" -o "$CONFIG_MTD_DOC2000" = "m" ]; then define_bool CONFIG_MTD_DOCPROBE m else define_bool CONFIG_MTD_DOCPROBE n fi fi if [ "$CONFIG_MTD_DOCPROBE" = "y" -o "$CONFIG_MTD_DOCPROBE" = "m" ]; then bool ' Advanced detection options for DiskOnChip' CONFIG_MTD_DOCPROBE_ADVANCED if [ "$CONFIG_MTD_DOCPROBE_ADVANCED" = "n" ]; then define_hex CONFIG_MTD_DOCPROBE_ADDRESS 0 define_bool CONFIG_MTD_DOCPROBE_HIGH n define_bool CONFIG_MTD_DOCPROBE_55AA n else hex ' Physical address of DiskOnChip' CONFIG_MTD_DOCPROBE_ADDRESS 0x0000 bool ' Probe high addresses' CONFIG_MTD_DOCPROBE_HIGH bool ' Probe for 0x55 0xAA BIOS Extension Signature' CONFIG_MTD_DOCPROBE_55AA fi fi if ["$CONFIG_MTD_VMU" = "y"]; then dep_tristate ' SEGA Dreamcast VMU block device driver' CONFIG_MTD_VMUBLK fi endmenu |
From: Adrian M. <zx8...@us...> - 2002-09-18 20:06:31
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv8532 Modified Files: ChangeLog.dc Log Message: vmu block device driver added Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- ChangeLog.dc 18 Sep 2002 19:53:31 -0000 1.49 +++ ChangeLog.dc 18 Sep 2002 20:06:28 -0000 1.50 @@ -1,5 +1,10 @@ 2002-09-18 Adrian McMenamin <ad...@mc...> + *drivers/mtd/devices/vmublk.c: vmu block device + driver added + + *drivers/mtd/devices: directory added + *fs/vmuflash-fs.c: File removed |
From: Adrian M. <zx8...@us...> - 2002-09-18 20:06:30
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices In directory usw-pr-cvs1:/tmp/cvs-serv8532/drivers/mtd/devices Added Files: vmublk.c Log Message: vmu block device driver added --- NEW FILE: vmublk.c --- /* * * * VMU Flash File System Driver for LinuxDC * http://sourceforge.net/projects/linuxdc * * Copyright, Adrian McMenamin, 2002 * ad...@mc... * * Licenced under version 2 of the * Free Software Foundation's * General Public Licence * http://www.gnu.org * * Much of this driver is modelled * on existing mtd block drivers. * Particularly the mtdblock driver... * All copyrights acknowledged. * * */ #define VMUFS_DEBUG #define CONFIG_DEVFS_FS #include <linux/config.h> #include <linux/types.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/mtd/mtd.h> #include <linux/fs.h> #include <linux/blkdev.h> #define DEVICE_NAME "vmufs" #define DEVICE_NR(device) (device) #define MAJOR_NR MTD_BLOCK_MAJOR #define DEVICE_NO_RANDOM #include <linux/blk.h> #ifdef CONFIG_DEVFS_FS #include <linux/devfs_fs_kernel.h> static void vmufs_notify_add(struct mtd_info *mtd); static void vmufs_notify_remove(struct mtd_info *mtd); static struct mtd_notifier notifier = { vmufs_notify_add, vmufs_notify_remove, NULL }; static devfs_handle_t devfs_dir_handle = NULL; static devfs_handle_t devfs_rw_handle[MAX_MTD_DEVICES]; #endif static spinlock_t vmublks_lock; static int vmublk_size[MAX_MTD_DEVICES]; static int vmublksize_size[MAX_MTD_DEVICES]; static struct vmublk_dev { struct mtd_info *mtd; /* Locked */ int count; } *vmublks[MAX_MTD_DEVICES]; static struct block_device_operations vmufs_bdops; #ifdef CONFIG_DEVFS_FS /* Notification that a new device has been added. Create the devfs entry for * it. */ static void vmufs_notify_add(struct mtd_info *mtd) { char name[8]; if (!mtd || mtd->type == MTD_ABSENT) return; sprintf(name, "%d", mtd->index); devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, DEVFS_FL_DEFAULT, MTD_BLOCK_MAJOR, mtd->index, S_IFBLK | S_IRUGO | S_IWUGO, &vmufs_bdops, NULL); } static void vmufs_notify_remove(struct mtd_info *mtd) { if (!mtd || mtd->type == MTD_ABSENT) return; devfs_unregister(devfs_rw_handle[mtd->index]); } #endif /******************************************** * Define the block operations for the vmufs* ********************************************/ int vmufs_open(struct inode *inode, struct file *filp) { struct vmublk_dev *vmublk; struct mtd_info *mtd; int dev; DEBUG(MTD_DEBUG_LEVEL1, "vmuflash_fs_open\n"); if (!inode) return -EINVAL; dev = MINOR(inode->i_rdev); if (dev >= MAX_MTD_DEVICES) return -EINVAL; mtd = get_mtd_device(NULL, dev); if (!mtd) return -ENODEV; if (MTD_ABSENT == mtd->type) { put_mtd_device(mtd); return -ENODEV; } spin_lock(&vmublks_lock); /* If it's already open.... */ if (vmublks[dev]) { vmublks[dev]->count++; spin_unlock(&vmublks_lock); return 0; } /* OK, it's not open. Try to find it */ /* First we have to drop the lock, because we have to to things which might sleep. */ spin_unlock(&vmublks_lock); vmublk = kmalloc(sizeof(struct vmublk_dev), GFP_KERNEL); if (!vmublk) { put_mtd_device(mtd); return -ENOMEM; } memset(vmublk, 0, sizeof(*vmublk)); vmublk->count = 1; vmublk->mtd = mtd; /* OK, we've created a new one. Add it to the list. */ spin_lock(&vmublks_lock); vmublks[dev] = vmublk; vmublk_size[dev] = vmublk->mtd->size / 1024; if (vmublk->mtd->erasesize) vmublksize_size[dev] = vmublk->mtd->erasesize; if (vmublksize_size[dev] > PAGE_SIZE) vmublksize_size[dev] = PAGE_SIZE; set_device_ro(inode->i_rdev, !(vmublk->mtd->flags & MTD_WRITEABLE)); spin_unlock(&vmublks_lock); DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); return 0; } int vmufs_release(struct inode *inode, struct file *filp) { int dev; struct vmublk_dev *vmublk; DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); if (inode == NULL) release_return(-ENODEV); invalidate_device(inode->i_rdev, 1); dev = MINOR(inode->i_rdev); vmublk = vmublks[dev]; spin_lock(&vmublks_lock); if (!--vmublk->count) { /* It was the last usage. Free the device */ vmublks[dev] = NULL; spin_unlock(&vmublks_lock); if (vmublk->mtd->sync) vmublk->mtd->sync(vmublk->mtd); put_mtd_device(vmublk->mtd); kfree(vmublk); } else { spin_unlock(&vmublks_lock); } DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); release_return(0); } int vmufs_ioctl(struct inode *inode, struct file *filp, unsigned int command, unsigned long argument) { struct vmublk_dev *vmublk; vmublk = vmublks[MINOR(inode->i_rdev)]; if (!vmublk) BUG(); switch (command) { case BLKGETSIZE: /* Return device size */ return put_user((vmublk->mtd->size >> 9), (unsigned long *) argument); case BLKGETSIZE64: return put_user((u64) vmublk->mtd->size, (u64 *) argument); case BLKFLSBUF: if (!capable(CAP_SYS_ADMIN)) return -EACCES; fsync_dev(inode->i_rdev); invalidate_buffers(inode->i_rdev); if (vmublk->mtd->sync) vmublk->mtd->sync(vmublk->mtd); return 0; default: return -EINVAL; } } int vmufs_check_change(kdev_t dev) { /* Has the device been removed or replaced? */ int minor = MINOR(dev); struct mtd_info *mtd = get_mtd_device(NULL, minor); if (!mtd) return 1; /* No device */ /* Have a device, but is it the same one? */ struct vmublk_dev *vmublk; vmublk = vmublks[minor]; if (vmublk->mtd != mtd) { put_mtd_device(mtd); return 1; } put_mtd_device(mtd); return 0; /*Same device */ } int vmufs_revalidate(kdev_t dev) { return 0; /*Doing nothing at present */ } static int get_vmu_device(const struct request *req) { int devno; devno = MINOR(req->rq_dev); /* Is there an mtd device for this? */ struct mtd_info *mtd = get_mtd_device(NULL, devno); if (!mtd) { static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING "vmufs: requested an unknown device: %i\n", devno); return -1; } put_mtd_device(mtd); return devno; } static int vmufs_transfer(int devno, const struct request *req) { struct mtd_info *mtd = get_mtd_device(NULL, devno); spin_unlock_irq(&io_request_lock); int size, retsize, retvalue = 1; u8 *ptr = NULL; size = req->current_nr_sectors * mtd->erasesize; switch (req->cmd) { case READ: ptr = kmalloc(size, GFP_KERNEL); if (((mtd->read) (mtd, req->sector * mtd->erasesize, size, &retsize, ptr)) < 0) { /* Failed */ retvalue = -1; static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING "vmufs: failed on read\n"); break; } memcpy(req->buffer, ptr, retsize); break; case WRITE: ptr = kmalloc(size, GFP_KERNEL); memcpy(ptr, req->buffer, size); if (((mtd->write) (mtd, req->sector * mtd->erasesize, size, &retsize, ptr)) < 0) { /* Failed */ retvalue = -1; static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING "vmufs: failed on write\n"); break; } default: retvalue = 0; } if (ptr) kfree(ptr); put_mtd_device(mtd); spin_lock_irq(&io_request_lock); return retvalue; } void vmufs_request(request_queue_t * q) { int device, status; while (1) { INIT_REQUEST; /* Check we have a real device */ device = get_vmu_device(CURRENT); if (device < 0) { end_request(0); continue; } status = vmufs_transfer(device, CURRENT); DEBUG(MTD_DEBUG_LEVEL2, "request %p: cmd %i sec %li (nr. %li)\n", CURRENT, CURRENT->cmd, CURRENT->sector, CURRENT->current_nr_sectors); end_request(1); } } int __init init_vmufs(void) { int i; spin_lock_init(&vmufs_lock); #ifdef CONFIG_DEVFS_FS if (devfs_register_blkdev (MTD_BLOCK_MAJOR, DEVICE_NAME, &vmufs_bdops)) { printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", MTD_BLOCK_MAJOR); return -EAGAIN; } devfs_dir_handle = devfs_mk_dir(NULL, DEVICE_NAME, NULL); register_mtd_user(¬ifier); #else if (register_blkdev(MAJOR_NR, DEVICE_NAME, &vmufs_bdops)) { printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", MTD_BLOCK_MAJOR); return -EAGAIN; } #endif /* We fill it in at open() time. */ for (i = 0; i < MAX_MTD_DEVICES; i++) { vmublk_size[i] = 0; vmublksize_size[i] = 0; /* Not fixed (in theory) for DC vmu flash */ } /* init_waitqueue_head(&vmufs_wq); */ blksize_size[MAJOR_NR] = vmublksize_size; blk_size[MAJOR_NR] = vmublk_size; blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), &vmufs_request); /*kernel_thread (vmufs_thread, NULL, CLONE_FS|CLONE_FILES|CLONE_SIGHAND); *//* Do I need this? */ return 0; } static void __exit exit_vmufs(void) { /* leaving = 1; wake_up(&thr_wq); down(&thread_sem); */ #ifdef CONFIG_DEVFS_FS unregister_mtd_user(¬ifier); devfs_unregister(devfs_dir_handle); devfs_unregister_blkdev(MTD_BLOCK_MAJOR, DEVICE_NAME); #else unregister_blkdev(MAJOR_NR, DEVICE_NAME); #endif blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blksize_size[MAJOR_NR] = NULL; blk_size[MAJOR_NR] = NULL; } static struct block_device_operations vmufs_bdops = { open:vmufs_open, release:vmufs_release, ioctl:vmufs_ioctl, check_media_change:vmufs_check_change, revalidate:vmufs_revalidate, }; module_init(init_vmufs); module_exit(exit_vmufs); MODULE_DESCRIPTION("VMUFS - Dreamcast VMU File System"); MODULE_AUTHOR("Adrian McMenamin"); MODULE_LICENSE("GPL"); |
From: Adrian M. <zx8...@us...> - 2002-09-18 20:02:40
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices In directory usw-pr-cvs1:/tmp/cvs-serv7076/drivers/mtd/devices Log Message: Directory /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/devices added to the repository |
From: Adrian M. <zx8...@us...> - 2002-09-18 19:53:57
|
Update of /cvsroot/linuxdc/linux-sh-dc/fs In directory usw-pr-cvs1:/tmp/cvs-serv4129/fs Removed Files: vmuflash-fs.c Log Message: Restrucuring vmu block driver --- vmuflash-fs.c DELETED --- |
From: Adrian M. <zx8...@us...> - 2002-09-18 19:53:34
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv3993 Modified Files: ChangeLog.dc Log Message: Restrucuring vmu block driver Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- ChangeLog.dc 16 Sep 2002 22:43:08 -0000 1.48 +++ ChangeLog.dc 18 Sep 2002 19:53:31 -0000 1.49 @@ -1,3 +1,8 @@ +2002-09-18 Adrian McMenamin <ad...@mc...> + + *fs/vmuflash-fs.c: File removed + + 2002-09-16 Adrian McMenamin <ad...@mc...> *fs/vmuflash-fs.c: Module can now be removed as |
From: Adrian M. <zx8...@us...> - 2002-09-16 22:43:11
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv2238 Modified Files: ChangeLog.dc Log Message: vmuflash fs module now removable Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- ChangeLog.dc 15 Sep 2002 22:49:26 -0000 1.47 +++ ChangeLog.dc 16 Sep 2002 22:43:08 -0000 1.48 @@ -1,3 +1,9 @@ +2002-09-16 Adrian McMenamin <ad...@mc...> + + *fs/vmuflash-fs.c: Module can now be removed as + well as loaded + + 2002-09-15 Adrian McMenamin <ad...@mc...> *fs/vmuflash-fs.c : Cleaned and improved |
From: Adrian M. <zx8...@us...> - 2002-09-16 22:43:11
|
Update of /cvsroot/linuxdc/linux-sh-dc/fs In directory usw-pr-cvs1:/tmp/cvs-serv2238/fs Modified Files: vmuflash-fs.c Log Message: vmuflash fs module now removable Index: vmuflash-fs.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/fs/vmuflash-fs.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- vmuflash-fs.c 15 Sep 2002 22:49:27 -0000 1.2 +++ vmuflash-fs.c 16 Sep 2002 22:43:08 -0000 1.3 @@ -180,9 +180,41 @@ int vmufs_release(struct inode *inode, struct file *filp) { + int dev; + struct vmublk_dev *vmublk; + DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); + + if (inode == NULL) + release_return(-ENODEV); + + invalidate_device(inode->i_rdev, 1); + + dev = MINOR(inode->i_rdev); + vmublk = vmublks[dev]; + + + spin_lock(&vmublks_lock); + if (!--vmublk->count) { + /* It was the last usage. Free the device */ + vmublks[dev] = NULL; + spin_unlock(&vmublks_lock); + if (vmublk->mtd->sync) + vmublk->mtd->sync(vmublk->mtd); + put_mtd_device(vmublk->mtd); + + kfree(vmublk); + } else { + spin_unlock(&vmublks_lock); + } + + DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); + + release_return(0); + + + - return 1; } @@ -225,9 +257,24 @@ int vmufs_check_change(kdev_t dev) { + /* Has the device been removed or replaced? */ + int minor = MINOR(dev); + struct mtd_info *mtd = get_mtd_device(NULL, minor); + if (!mtd) + return 1; /* No device */ + /* Have a device, but is it the same one? */ + struct vmublk_dev *vmublk; + + vmublk = vmublks[minor]; + if (vmublk->mtd != mtd) { + put_mtd_device(mtd); + return 1; + } + put_mtd_device(mtd); + - return 1; + return 0; /*Same device */ } @@ -235,8 +282,7 @@ { - - return 1; + return 0; /*Doing nothing at present */ } static int get_vmu_device(const struct request *req) @@ -320,9 +366,10 @@ continue; } status = vmufs_transfer(device, CURRENT); - printk("request %p: cmd %i sec %li (nr. %li)\n", CURRENT, - CURRENT->cmd, CURRENT->sector, - CURRENT->current_nr_sectors); + DEBUG(MTD_DEBUG_LEVEL2, + "request %p: cmd %i sec %li (nr. %li)\n", CURRENT, + CURRENT->cmd, CURRENT->sector, + CURRENT->current_nr_sectors); end_request(1); } } |
From: Adrian M. <zx8...@us...> - 2002-09-15 22:49:30
|
Update of /cvsroot/linuxdc/linux-sh-dc/fs In directory usw-pr-cvs1:/tmp/cvs-serv16853/fs Modified Files: vmuflash-fs.c Log Message: vmu flash fs code cleaned and improved Index: vmuflash-fs.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/fs/vmuflash-fs.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- vmuflash-fs.c 14 Sep 2002 23:50:32 -0000 1.1 +++ vmuflash-fs.c 15 Sep 2002 22:49:27 -0000 1.2 @@ -12,8 +12,9 @@ * General Public Licence * http://www.gnu.org * - * Much of this driver is based + * Much of this driver is modelled * on existing mtd block drivers. + * Particularly the mtdblock driver... * All copyrights acknowledged. * * @@ -37,19 +38,19 @@ #define DEVICE_NAME "vmufs" #define DEVICE_NR(device) (device) #define MAJOR_NR MTD_BLOCK_MAJOR - -#include <linux/blk.h> +#define DEVICE_NO_RANDOM +#include <linux/blk.h> #ifdef CONFIG_DEVFS_FS #include <linux/devfs_fs_kernel.h> -static void vmufs_notify_add(struct mtd_info* mtd); -static void vmufs_notify_remove(struct mtd_info* mtd); +static void vmufs_notify_add(struct mtd_info *mtd); +static void vmufs_notify_remove(struct mtd_info *mtd); static struct mtd_notifier notifier = { - vmufs_notify_add, - vmufs_notify_remove, - NULL + vmufs_notify_add, + vmufs_notify_remove, + NULL }; static devfs_handle_t devfs_dir_handle = NULL; static devfs_handle_t devfs_rw_handle[MAX_MTD_DEVICES]; @@ -60,10 +61,10 @@ static int vmublksize_size[MAX_MTD_DEVICES]; static struct vmublk_dev { - struct mtd_info *mtd; /* Locked */ + struct mtd_info *mtd; /* Locked */ int count; - + } *vmublks[MAX_MTD_DEVICES]; @@ -75,26 +76,27 @@ /* Notification that a new device has been added. Create the devfs entry for * it. */ -static void vmufs_notify_add(struct mtd_info* mtd) +static void vmufs_notify_add(struct mtd_info *mtd) { - char name[8]; + char name[8]; - if (!mtd || mtd->type == MTD_ABSENT) - return; + if (!mtd || mtd->type == MTD_ABSENT) + return; - sprintf(name, "%d", mtd->index); - devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, - DEVFS_FL_DEFAULT, MTD_BLOCK_MAJOR, mtd->index, - S_IFBLK | S_IRUGO | S_IWUGO, - &vmufs_bdops, NULL); + sprintf(name, "%d", mtd->index); + devfs_rw_handle[mtd->index] = + devfs_register(devfs_dir_handle, name, DEVFS_FL_DEFAULT, + MTD_BLOCK_MAJOR, mtd->index, + S_IFBLK | S_IRUGO | S_IWUGO, &vmufs_bdops, + NULL); } -static void vmufs_notify_remove(struct mtd_info* mtd) +static void vmufs_notify_remove(struct mtd_info *mtd) { - if (!mtd || mtd->type == MTD_ABSENT) - return; + if (!mtd || mtd->type == MTD_ABSENT) + return; - devfs_unregister(devfs_rw_handle[mtd->index]); + devfs_unregister(devfs_rw_handle[mtd->index]); } #endif @@ -108,11 +110,11 @@ struct mtd_info *mtd; int dev; - DEBUG(MTD_DEBUG_LEVEL1,"vmuflash_fs_open\n"); - + DEBUG(MTD_DEBUG_LEVEL1, "vmuflash_fs_open\n"); + if (!inode) return -EINVAL; - + dev = MINOR(inode->i_rdev); if (dev >= MAX_MTD_DEVICES) return -EINVAL; @@ -124,7 +126,7 @@ put_mtd_device(mtd); return -ENODEV; } - + spin_lock(&vmublks_lock); /* If it's already open.... */ @@ -133,12 +135,12 @@ spin_unlock(&vmublks_lock); return 0; } - + /* OK, it's not open. Try to find it */ /* First we have to drop the lock, because we have to to things which might sleep. - */ + */ spin_unlock(&vmublks_lock); vmublk = kmalloc(sizeof(struct vmublk_dev), GFP_KERNEL); @@ -159,15 +161,16 @@ vmublks[dev] = vmublk; - vmublk_size[dev] = vmublk->mtd->size/1024; + vmublk_size[dev] = vmublk->mtd->size / 1024; if (vmublk->mtd->erasesize) vmublksize_size[dev] = vmublk->mtd->erasesize; if (vmublksize_size[dev] > PAGE_SIZE) vmublksize_size[dev] = PAGE_SIZE; - set_device_ro (inode->i_rdev, !(vmublk->mtd->flags & MTD_WRITEABLE)); - + set_device_ro(inode->i_rdev, + !(vmublk->mtd->flags & MTD_WRITEABLE)); + spin_unlock(&vmublks_lock); - + DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); return 0; @@ -179,15 +182,43 @@ { - return 1; + return 1; } -int vmufs_ioctl(struct inode *inode, struct file *filp, unsigned int command, unsigned long argument) +int vmufs_ioctl(struct inode *inode, struct file *filp, + unsigned int command, unsigned long argument) { + struct vmublk_dev *vmublk; + + vmublk = vmublks[MINOR(inode->i_rdev)]; + + if (!vmublk) + BUG(); + + switch (command) { + case BLKGETSIZE: /* Return device size */ + return put_user((vmublk->mtd->size >> 9), + (unsigned long *) argument); + case BLKGETSIZE64: + return put_user((u64) vmublk->mtd->size, (u64 *) argument); + + case BLKFLSBUF: + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + fsync_dev(inode->i_rdev); + invalidate_buffers(inode->i_rdev); + + if (vmublk->mtd->sync) + vmublk->mtd->sync(vmublk->mtd); + return 0; + + default: + return -EINVAL; + } - return 1; } @@ -196,7 +227,7 @@ - return 1; + return 1; } @@ -205,84 +236,95 @@ - return 1; + return 1; } static int get_vmu_device(const struct request *req) { - int devno; - devno = MINOR(req->rq_dev); - /* Is there an mtd device for this? */ - struct mtd_info *mtd = get_mtd_device(NULL, devno); - if (!mtd){ - static int count = 0; - if (count++ < 45) /* TO DO: Lower this for production driver */ - printk(KERN_WARNING "vmufs: requested an unknown device: %i\n", devno); - return -1; - } - put_mtd_device(mtd); - return devno; + int devno; + devno = MINOR(req->rq_dev); + /* Is there an mtd device for this? */ + struct mtd_info *mtd = get_mtd_device(NULL, devno); + if (!mtd) { + static int count = 0; + if (count++ < 45) /* TO DO: Lower this for production driver */ + printk(KERN_WARNING + "vmufs: requested an unknown device: %i\n", + devno); + return -1; + } + put_mtd_device(mtd); + return devno; } static int vmufs_transfer(int devno, const struct request *req) { - struct mtd_info *mtd = get_mtd_device(NULL, devno); - - int size, retsize, retvalue = 1; - u8 *ptr = NULL; - size = req->current_nr_sectors * mtd->erasesize; + struct mtd_info *mtd = get_mtd_device(NULL, devno); + spin_unlock_irq(&io_request_lock); + int size, retsize, retvalue = 1; + u8 *ptr = NULL; + size = req->current_nr_sectors * mtd->erasesize; - switch(req->cmd){ - case READ: - ptr = kmalloc(size, GFP_KERNEL); - if (((mtd->read)(mtd, req->sector * mtd->erasesize, size, &retsize, ptr)) < 0){ - /* Failed */ - retvalue = -1; - static int count = 0; - if (count++ < 45) /* TO DO: Lower this for production driver */ - printk(KERN_WARNING "vmufs: failed on read\n"); - break; - } + switch (req->cmd) { + case READ: + ptr = kmalloc(size, GFP_KERNEL); + if (((mtd->read) (mtd, req->sector * mtd->erasesize, size, + &retsize, ptr)) < 0) { + /* Failed */ + retvalue = -1; + static int count = 0; + if (count++ < 45) /* TO DO: Lower this for production driver */ + printk(KERN_WARNING + "vmufs: failed on read\n"); + break; + } - memcpy(req->buffer, ptr, retsize); + memcpy(req->buffer, ptr, retsize); - break; - case WRITE: - ptr = kmalloc(size, GFP_KERNEL); - memcpy(ptr, req->buffer, size); - if (((mtd->write)(mtd, req->sector * mtd->erasesize, size, &retsize, ptr)) < 0){ - /* Failed */ - retvalue = -1; - static int count = 0; - if (count++ < 45) /* TO DO: Lower this for production driver */ - printk(KERN_WARNING "vmufs: failed on write\n"); - break; - } - default: - retvalue = 0; - } - if (ptr) kfree(ptr); - put_mtd_device(mtd); - return retvalue; + break; + case WRITE: + ptr = kmalloc(size, GFP_KERNEL); + memcpy(ptr, req->buffer, size); + if (((mtd->write) (mtd, req->sector * mtd->erasesize, size, + &retsize, ptr)) < 0) { + /* Failed */ + retvalue = -1; + static int count = 0; + if (count++ < 45) /* TO DO: Lower this for production driver */ + printk(KERN_WARNING + "vmufs: failed on write\n"); + break; + } + default: + retvalue = 0; + } + if (ptr) + kfree(ptr); + put_mtd_device(mtd); + spin_lock_irq(&io_request_lock); + return retvalue; } -void vmufs_request(request_queue_t *q) +void vmufs_request(request_queue_t * q) { - int device, status; + int device, status; - while (1){ - INIT_REQUEST; - /* Check we have a real device */ - device = get_vmu_device(CURRENT); - if (device < 0){ - end_request(0); - continue; - } - status = vmufs_transfer(device, CURRENT); - printk("request %p: cmd %i sec %li (nr. %li)\n", CURRENT, CURRENT->cmd, CURRENT->sector, CURRENT->current_nr_sectors); - end_request(1); - } + while (1) { + INIT_REQUEST; + + /* Check we have a real device */ + device = get_vmu_device(CURRENT); + if (device < 0) { + end_request(0); + continue; + } + status = vmufs_transfer(device, CURRENT); + printk("request %p: cmd %i sec %li (nr. %li)\n", CURRENT, + CURRENT->cmd, CURRENT->sector, + CURRENT->current_nr_sectors); + end_request(1); + } } @@ -290,56 +332,57 @@ int __init init_vmufs(void) { - int i; + int i; - spin_lock_init(&vmufs_lock); + spin_lock_init(&vmufs_lock); #ifdef CONFIG_DEVFS_FS - if (devfs_register_blkdev(MTD_BLOCK_MAJOR, DEVICE_NAME, &vmufs_bdops)) - { - printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", - MTD_BLOCK_MAJOR); - return -EAGAIN; - } + if (devfs_register_blkdev + (MTD_BLOCK_MAJOR, DEVICE_NAME, &vmufs_bdops)) { + printk(KERN_NOTICE + "Can't allocate major number %d for Memory Technology Devices.\n", + MTD_BLOCK_MAJOR); + return -EAGAIN; + } - devfs_dir_handle = devfs_mk_dir(NULL, DEVICE_NAME, NULL); - register_mtd_user(¬ifier); + devfs_dir_handle = devfs_mk_dir(NULL, DEVICE_NAME, NULL); + register_mtd_user(¬ifier); #else - if (register_blkdev(MAJOR_NR,DEVICE_NAME,&vmufs_bdops)) { - printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", - MTD_BLOCK_MAJOR); - return -EAGAIN; - } - + if (register_blkdev(MAJOR_NR, DEVICE_NAME, &vmufs_bdops)) { + printk(KERN_NOTICE + "Can't allocate major number %d for Memory Technology Devices.\n", + MTD_BLOCK_MAJOR); + return -EAGAIN; + } #endif - /* We fill it in at open() time. */ - for (i=0; i< MAX_MTD_DEVICES; i++) { - vmublk_size[i] = 0; - vmublksize_size[i] = 0; /* Not fixed (in theory) for DC vmu flash */ - } + /* We fill it in at open() time. */ + for (i = 0; i < MAX_MTD_DEVICES; i++) { + vmublk_size[i] = 0; + vmublksize_size[i] = 0; /* Not fixed (in theory) for DC vmu flash */ + } /* init_waitqueue_head(&vmufs_wq); */ - blksize_size[MAJOR_NR] = vmublksize_size; - blk_size[MAJOR_NR] = vmublk_size; + blksize_size[MAJOR_NR] = vmublksize_size; + blk_size[MAJOR_NR] = vmublk_size; - blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), &vmufs_request); - /*kernel_thread (vmufs_thread, NULL, CLONE_FS|CLONE_FILES|CLONE_SIGHAND); */ /* Do I need this? */ - return 0; + blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), &vmufs_request); +/*kernel_thread (vmufs_thread, NULL, CLONE_FS|CLONE_FILES|CLONE_SIGHAND); *//* Do I need this? */ + return 0; } static void __exit exit_vmufs(void) { - /* leaving = 1; - wake_up(&thr_wq); - down(&thread_sem); */ + /* leaving = 1; + wake_up(&thr_wq); + down(&thread_sem); */ #ifdef CONFIG_DEVFS_FS unregister_mtd_user(¬ifier); devfs_unregister(devfs_dir_handle); devfs_unregister_blkdev(MTD_BLOCK_MAJOR, DEVICE_NAME); #else - unregister_blkdev(MAJOR_NR,DEVICE_NAME); + unregister_blkdev(MAJOR_NR, DEVICE_NAME); #endif blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blksize_size[MAJOR_NR] = NULL; @@ -349,11 +392,11 @@ static struct block_device_operations vmufs_bdops = { - open: vmufs_open, - release: vmufs_release, - ioctl: vmufs_ioctl, - check_media_change: vmufs_check_change, - revalidate: vmufs_revalidate, + open:vmufs_open, + release:vmufs_release, + ioctl:vmufs_ioctl, + check_media_change:vmufs_check_change, + revalidate:vmufs_revalidate, }; |
From: Adrian M. <zx8...@us...> - 2002-09-15 22:49:30
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv16853 Modified Files: ChangeLog.dc Log Message: vmu flash fs code cleaned and improved Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- ChangeLog.dc 14 Sep 2002 23:50:32 -0000 1.46 +++ ChangeLog.dc 15 Sep 2002 22:49:26 -0000 1.47 @@ -1,5 +1,7 @@ 2002-09-15 Adrian McMenamin <ad...@mc...> + *fs/vmuflash-fs.c : Cleaned and improved + Initial check-in of vmu flash file system *fs : directory added |
From: Adrian M. <zx8...@us...> - 2002-09-14 23:50:35
|
Update of /cvsroot/linuxdc/linux-sh-dc/fs In directory usw-pr-cvs1:/tmp/cvs-serv2915/fs Added Files: vmuflash-fs.c Log Message: initial check-in of vmu flash filesystem driver --- NEW FILE: vmuflash-fs.c --- /* * * * VMU Flash File System Driver for LinuxDC * http://sourceforge.net/projects/linuxdc * * Copyright, Adrian McMenamin, 2002 * ad...@mc... * * Licenced under version 2 of the * Free Software Foundation's * General Public Licence * http://www.gnu.org * * Much of this driver is based * on existing mtd block drivers. * All copyrights acknowledged. * * */ #define VMUFS_DEBUG #define CONFIG_DEVFS_FS #include <linux/config.h> #include <linux/types.h> #include <linux/module.h> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/mtd/mtd.h> #include <linux/fs.h> #include <linux/blkdev.h> #define DEVICE_NAME "vmufs" #define DEVICE_NR(device) (device) #define MAJOR_NR MTD_BLOCK_MAJOR #include <linux/blk.h> #ifdef CONFIG_DEVFS_FS #include <linux/devfs_fs_kernel.h> static void vmufs_notify_add(struct mtd_info* mtd); static void vmufs_notify_remove(struct mtd_info* mtd); static struct mtd_notifier notifier = { vmufs_notify_add, vmufs_notify_remove, NULL }; static devfs_handle_t devfs_dir_handle = NULL; static devfs_handle_t devfs_rw_handle[MAX_MTD_DEVICES]; #endif static spinlock_t vmublks_lock; static int vmublk_size[MAX_MTD_DEVICES]; static int vmublksize_size[MAX_MTD_DEVICES]; static struct vmublk_dev { struct mtd_info *mtd; /* Locked */ int count; } *vmublks[MAX_MTD_DEVICES]; static struct block_device_operations vmufs_bdops; #ifdef CONFIG_DEVFS_FS /* Notification that a new device has been added. Create the devfs entry for * it. */ static void vmufs_notify_add(struct mtd_info* mtd) { char name[8]; if (!mtd || mtd->type == MTD_ABSENT) return; sprintf(name, "%d", mtd->index); devfs_rw_handle[mtd->index] = devfs_register(devfs_dir_handle, name, DEVFS_FL_DEFAULT, MTD_BLOCK_MAJOR, mtd->index, S_IFBLK | S_IRUGO | S_IWUGO, &vmufs_bdops, NULL); } static void vmufs_notify_remove(struct mtd_info* mtd) { if (!mtd || mtd->type == MTD_ABSENT) return; devfs_unregister(devfs_rw_handle[mtd->index]); } #endif /******************************************** * Define the block operations for the vmufs* ********************************************/ int vmufs_open(struct inode *inode, struct file *filp) { struct vmublk_dev *vmublk; struct mtd_info *mtd; int dev; DEBUG(MTD_DEBUG_LEVEL1,"vmuflash_fs_open\n"); if (!inode) return -EINVAL; dev = MINOR(inode->i_rdev); if (dev >= MAX_MTD_DEVICES) return -EINVAL; mtd = get_mtd_device(NULL, dev); if (!mtd) return -ENODEV; if (MTD_ABSENT == mtd->type) { put_mtd_device(mtd); return -ENODEV; } spin_lock(&vmublks_lock); /* If it's already open.... */ if (vmublks[dev]) { vmublks[dev]->count++; spin_unlock(&vmublks_lock); return 0; } /* OK, it's not open. Try to find it */ /* First we have to drop the lock, because we have to to things which might sleep. */ spin_unlock(&vmublks_lock); vmublk = kmalloc(sizeof(struct vmublk_dev), GFP_KERNEL); if (!vmublk) { put_mtd_device(mtd); return -ENOMEM; } memset(vmublk, 0, sizeof(*vmublk)); vmublk->count = 1; vmublk->mtd = mtd; /* OK, we've created a new one. Add it to the list. */ spin_lock(&vmublks_lock); vmublks[dev] = vmublk; vmublk_size[dev] = vmublk->mtd->size/1024; if (vmublk->mtd->erasesize) vmublksize_size[dev] = vmublk->mtd->erasesize; if (vmublksize_size[dev] > PAGE_SIZE) vmublksize_size[dev] = PAGE_SIZE; set_device_ro (inode->i_rdev, !(vmublk->mtd->flags & MTD_WRITEABLE)); spin_unlock(&vmublks_lock); DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); return 0; } int vmufs_release(struct inode *inode, struct file *filp) { return 1; } int vmufs_ioctl(struct inode *inode, struct file *filp, unsigned int command, unsigned long argument) { return 1; } int vmufs_check_change(kdev_t dev) { return 1; } int vmufs_revalidate(kdev_t dev) { return 1; } static int get_vmu_device(const struct request *req) { int devno; devno = MINOR(req->rq_dev); /* Is there an mtd device for this? */ struct mtd_info *mtd = get_mtd_device(NULL, devno); if (!mtd){ static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING "vmufs: requested an unknown device: %i\n", devno); return -1; } put_mtd_device(mtd); return devno; } static int vmufs_transfer(int devno, const struct request *req) { struct mtd_info *mtd = get_mtd_device(NULL, devno); int size, retsize, retvalue = 1; u8 *ptr = NULL; size = req->current_nr_sectors * mtd->erasesize; switch(req->cmd){ case READ: ptr = kmalloc(size, GFP_KERNEL); if (((mtd->read)(mtd, req->sector * mtd->erasesize, size, &retsize, ptr)) < 0){ /* Failed */ retvalue = -1; static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING "vmufs: failed on read\n"); break; } memcpy(req->buffer, ptr, retsize); break; case WRITE: ptr = kmalloc(size, GFP_KERNEL); memcpy(ptr, req->buffer, size); if (((mtd->write)(mtd, req->sector * mtd->erasesize, size, &retsize, ptr)) < 0){ /* Failed */ retvalue = -1; static int count = 0; if (count++ < 45) /* TO DO: Lower this for production driver */ printk(KERN_WARNING "vmufs: failed on write\n"); break; } default: retvalue = 0; } if (ptr) kfree(ptr); put_mtd_device(mtd); return retvalue; } void vmufs_request(request_queue_t *q) { int device, status; while (1){ INIT_REQUEST; /* Check we have a real device */ device = get_vmu_device(CURRENT); if (device < 0){ end_request(0); continue; } status = vmufs_transfer(device, CURRENT); printk("request %p: cmd %i sec %li (nr. %li)\n", CURRENT, CURRENT->cmd, CURRENT->sector, CURRENT->current_nr_sectors); end_request(1); } } int __init init_vmufs(void) { int i; spin_lock_init(&vmufs_lock); #ifdef CONFIG_DEVFS_FS if (devfs_register_blkdev(MTD_BLOCK_MAJOR, DEVICE_NAME, &vmufs_bdops)) { printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", MTD_BLOCK_MAJOR); return -EAGAIN; } devfs_dir_handle = devfs_mk_dir(NULL, DEVICE_NAME, NULL); register_mtd_user(¬ifier); #else if (register_blkdev(MAJOR_NR,DEVICE_NAME,&vmufs_bdops)) { printk(KERN_NOTICE "Can't allocate major number %d for Memory Technology Devices.\n", MTD_BLOCK_MAJOR); return -EAGAIN; } #endif /* We fill it in at open() time. */ for (i=0; i< MAX_MTD_DEVICES; i++) { vmublk_size[i] = 0; vmublksize_size[i] = 0; /* Not fixed (in theory) for DC vmu flash */ } /* init_waitqueue_head(&vmufs_wq); */ blksize_size[MAJOR_NR] = vmublksize_size; blk_size[MAJOR_NR] = vmublk_size; blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), &vmufs_request); /*kernel_thread (vmufs_thread, NULL, CLONE_FS|CLONE_FILES|CLONE_SIGHAND); */ /* Do I need this? */ return 0; } static void __exit exit_vmufs(void) { /* leaving = 1; wake_up(&thr_wq); down(&thread_sem); */ #ifdef CONFIG_DEVFS_FS unregister_mtd_user(¬ifier); devfs_unregister(devfs_dir_handle); devfs_unregister_blkdev(MTD_BLOCK_MAJOR, DEVICE_NAME); #else unregister_blkdev(MAJOR_NR,DEVICE_NAME); #endif blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); blksize_size[MAJOR_NR] = NULL; blk_size[MAJOR_NR] = NULL; } static struct block_device_operations vmufs_bdops = { open: vmufs_open, release: vmufs_release, ioctl: vmufs_ioctl, check_media_change: vmufs_check_change, revalidate: vmufs_revalidate, }; module_init(init_vmufs); module_exit(exit_vmufs); MODULE_DESCRIPTION("VMUFS - Dreamcast VMU File System"); MODULE_AUTHOR("Adrian McMenamin"); MODULE_LICENSE("GPL"); |
From: Adrian M. <zx8...@us...> - 2002-09-14 23:50:35
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv2915 Modified Files: ChangeLog.dc Log Message: initial check-in of vmu flash filesystem driver Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- ChangeLog.dc 11 Sep 2002 20:09:07 -0000 1.45 +++ ChangeLog.dc 14 Sep 2002 23:50:32 -0000 1.46 @@ -1,3 +1,11 @@ +2002-09-15 Adrian McMenamin <ad...@mc...> + + Initial check-in of vmu flash file system + + *fs : directory added + *fs/vmuflash-fs.c : initial check-in + + 2002-09-11 Adrian McMenamin <ad...@mc...> * drivers/mtd/maps/vmu-flash.c: Code cleaned-up |
From: Adrian M. <zx8...@us...> - 2002-09-14 23:50:04
|
Update of /cvsroot/linuxdc/linux-sh-dc/fs In directory usw-pr-cvs1:/tmp/cvs-serv2731/fs Log Message: Directory /cvsroot/linuxdc/linux-sh-dc/fs added to the repository |
From: Adrian M. <zx8...@us...> - 2002-09-11 20:09:10
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps In directory usw-pr-cvs1:/tmp/cvs-serv23652/drivers/mtd/maps Modified Files: vmu-flash.c Log Message: Code cleaned up Index: vmu-flash.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps/vmu-flash.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- vmu-flash.c 10 Sep 2002 22:55:51 -0000 1.10 +++ vmu-flash.c 11 Sep 2002 20:09:07 -0000 1.11 @@ -23,7 +23,6 @@ #include <asm/io.h> -static int VMU_NUM_BLOCKS; /* This is a dynamic property */ static int VMU_BLOCK_SIZE; #define _DEBUG_ @@ -54,6 +53,7 @@ long writecnt; long readcnt; long removable; + long numblocks; struct mtd_info *mtd; } memcard_t; @@ -91,8 +91,8 @@ /* Sanity check */ if (!mtd) { - DEBGM(KERN_WARNING - "VMU FLASH: Attempting to read data without having set up mtd.\n"); + DEBGM + ("VMU FLASH: Attempting to read data without having set up mtd.\n"); return -1; } @@ -111,7 +111,7 @@ ((unsigned long *) (mqu->recvbuf))[1] = num << 24; mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { - DEBGM(KERN_WARNING "VMU FLASH: Could not add packet\n"); + DEBGM("VMU FLASH: Could not add packet\n"); return -1; } @@ -130,46 +130,46 @@ return 0; } - DEBGM(KERN_WARNING - "VMU FLASH: Read has failed - return is 0x%X\n", + DEBGM("VMU FLASH: Read has failed - return is 0x%X\n", lastmq->recvbuf[0]); - DEBGM(KERN_WARNING "ERROR code is 0x%X\n", lastmq->recvbuf[1]); + DEBGM("ERROR code is 0x%X\n", lastmq->recvbuf[1]); return -1; } -static int maple_vmu_write_block(unsigned int num, u_char * buf, struct mtd_info *mtd) +static int maple_vmu_write_block(unsigned int num, u_char * buf, + struct mtd_info *mtd) { - - /* Sanity check */ if (!mtd) { printk(KERN_WARNING "VMU FLASH: Attempting to write data without having set up mtd.\n"); return -1; } + struct maple_driver_data *d = + (struct maple_driver_data *) (mtd->priv); + memcard_t *memcard = (memcard_t *) (d->private_data); + vmu_cache->valid = 0; /* Writing so any cache may be invalid */ - struct maple_driver_data *mdd = - (struct maple_driver_data *) (mtd->priv); - struct mapleq *mqu = (struct mapleq *) &(mdd->mq); - memcard_t *memcard = (memcard_t *) mdd->private_data; + + struct mapleq *mqu = (struct mapleq *) &(d->mq); /* Writing is phased */ int x; for (x = 0; x < memcard->writecnt; x++) { mqu->command = MAPLE_COMMAND_BWRITE; mqu->length = - (VMU_BLOCK_SIZE / (memcard->writecnt * 4)) + 2; + (memcard->blocklen / (memcard->writecnt * 4)) + 2; ((unsigned long *) (mqu->recvbuf))[0] = cpu_to_be32(MAPLE_FUNC_MEMCARD); ((unsigned long *) (mqu->recvbuf))[1] = num << 24 | x << 8; memcpy(mqu->recvbuf + 8, - buf + (VMU_BLOCK_SIZE / memcard->writecnt) * x, - VMU_BLOCK_SIZE / memcard->writecnt); + buf + (memcard->blocklen / memcard->writecnt) * x, + memcard->blocklen / memcard->writecnt); mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { @@ -201,15 +201,19 @@ * offset within the block. * */ -static block_t *__ofs_to_block(unsigned long src_ofs) +static block_t *__ofs_to_block(unsigned long src_ofs, struct mtd_info *mtd) { block_t *block; + struct maple_driver_data *d = + (struct maple_driver_data *) (mtd->priv); + memcard_t *card = (memcard_t *) (d->private_data); + block = kmalloc(sizeof(struct block_s), GFP_KERNEL); /* Validate we've got allocated memory */ if (!block) { - DEBGM(KERN_WARNING "Can't allocate block\n"); + DEBGM("Can't allocate block\n"); return NULL; } @@ -217,25 +221,24 @@ memset(block, 0, sizeof(struct block_s)); /* Make sure we don't overstep our boundaries */ - if (src_ofs >= VMU_NUM_BLOCKS * VMU_BLOCK_SIZE) { - DEBGM(KERN_WARNING "Source offset exceeds total offset\n"); + if (src_ofs >= card->numblocks * card->blocklen) { + DEBGM("Source offset exceeds total offset\n"); kfree(block); return NULL; } /* Find the block number */ - block->num = (unsigned int) (src_ofs / VMU_BLOCK_SIZE); + block->num = (unsigned int) (src_ofs / card->blocklen); /* Validate we've got a valid block */ - if (block->num > VMU_NUM_BLOCKS) { - DEBGM(KERN_WARNING - "Block number exceeds number of blocks\n"); + if (block->num > card->numblocks) { + DEBGM("Block number exceeds number of blocks\n"); kfree(block); return NULL; } /* Calculate remaining offset in block */ - block->ofs = (unsigned int) (src_ofs % VMU_BLOCK_SIZE); + block->ofs = (unsigned int) (src_ofs % card->blocklen); return block; } @@ -256,13 +259,16 @@ { block_t *block; *retval = 0; - u_char *buf = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); + struct maple_driver_data *d = + (struct maple_driver_data *) (mtd->priv); + memcard_t *card = (memcard_t *) (d->private_data); + u_char *buf = kmalloc(card->blocklen, GFP_KERNEL); /* Find the block */ - block = __ofs_to_block(ofs); + block = __ofs_to_block(ofs, mtd); /* Validate it was found */ if (!block) { - DEBGM(KERN_WARNING "Got an invalid block\n"); + DEBGM("Got an invalid block\n"); *retval = 1; return -1; } @@ -272,7 +278,7 @@ if (vmu_cache->block == block->num) { if ((vmu_cache->jiffies_atc + 10) >= jiffies) { /* short lifespan */ memcpy(buf, vmu_cache->buffer, - VMU_BLOCK_SIZE); + card->blocklen); u_char *buf2 = buf; buf2 += block->ofs; @@ -290,7 +296,7 @@ /* Read the block */ if (maple_vmu_read_block(block->num, buf, mtd) == -1) { - DEBGM(KERN_WARNING "Can't read block: %d\n", block->num); + DEBGM("Can't read block: %d\n", block->num); kfree(block); *retval = 2; return -1; @@ -320,21 +326,24 @@ struct mtd_info *mtd) { block_t *block; - u_char *buf = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); + struct maple_driver_data *dx = + (struct maple_driver_data *) (mtd->priv); + memcard_t *card = (memcard_t *) (dx->private_data); + u_char *buf = kmalloc(card->blocklen, GFP_KERNEL); /* Find the block */ - block = __ofs_to_block(ofs); + block = __ofs_to_block(ofs, mtd); /* Validate it was found */ if (!block) { - DEBGM(KERN_WARNING "Got an invalid block\n"); + DEBGM("Got an invalid block\n"); return; } /* Read the block */ if (maple_vmu_read_block(block->num, buf, mtd)) { - DEBGM(KERN_WARNING "Can't read block: %d\n", block->num); + DEBGM("Can't read block: %d\n", block->num); kfree(block); return; } @@ -361,11 +370,14 @@ { /* printk("Reading from %llx with length %llx\n", from, len); */ + struct maple_driver_data *d = + (struct maple_driver_data *) (mtd->priv); + memcard_t *card = (memcard_t *) (d->private_data); if (len < 1) return -1; - if (len > (VMU_NUM_BLOCKS * VMU_BLOCK_SIZE)) - len = VMU_NUM_BLOCKS * VMU_BLOCK_SIZE; + if (len > (card->numblocks * card->blocklen)) + len = card->numblocks * card->blocklen; int start_here = (int) (from & 0xffffffff); long retval = 0; int index = 0; @@ -383,7 +395,6 @@ } - static int vmu_flash_write(struct mtd_info *mtd, loff_t from, size_t len, size_t * retlen, const u_char * buf) { @@ -395,13 +406,17 @@ *retlen = 1; return 0; } + struct maple_driver_data *d = + (struct maple_driver_data *) (mtd->priv); + memcard_t *card = (memcard_t *) (d->private_data); + /* Cached write */ int index = 0; block_t *block; /* Find the block */ - block = __ofs_to_block(from); + block = __ofs_to_block(from, mtd); /* Validate it was found */ if (!block) { @@ -412,12 +427,11 @@ do { - u_char *buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); + u_char *buffer = kmalloc(card->blocklen, GFP_KERNEL); /* Read the block */ if (maple_vmu_read_block(block->num, buffer, mtd)) { - DEBGM(KERN_WARNING "Can't read block: %d\n", - block->num); + DEBGM("Can't read block: %d\n", block->num); kfree(block); *retlen = 0; return -1; @@ -429,7 +443,7 @@ index++; if (index >= len) break; - } while (block->ofs < VMU_BLOCK_SIZE); + } while (block->ofs < card->blocklen); maple_vmu_write_block(block->num, buffer, mtd); kfree(buffer); (block->num)++; @@ -439,8 +453,6 @@ kfree(block); return 0; - - } static int vmu_flash_erase(struct mtd_info *mtd, struct erase_info *erase) @@ -474,7 +486,6 @@ } - /** * vmu_flash_map_exit - Cleanup * @@ -487,7 +498,7 @@ maple_unregister_driver(&dc_flashmap_driver); /* See if there's anything to unregister */ if (!vmu_flash_mtd) { - DEBGM(KERN_WARNING "Nothing to unregister\n"); + DEBGM("Nothing to unregister\n"); return; } @@ -498,7 +509,6 @@ /***********Maple functions***************/ - void dc_flashmap_callback(struct maple_driver_data *data) { struct mapleq *mq = &data->mq; @@ -517,6 +527,9 @@ } if (mq->recvbuf[0] == MAPLE_RESPONSE_DATATRF) { + + + memcard_t *card = (memcard_t *) (data->private_data); /* int res = mq->recvbuf[0]; printk @@ -529,11 +542,11 @@ */ block_buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); /* Copy over */ - memcpy(block_buffer, mq->recvbuf + 12, VMU_BLOCK_SIZE); + memcpy(block_buffer, mq->recvbuf + 12, card->blocklen); lastmq = mq; wake_up_interruptible(&wq_mq); /* Wake sleeping code */ - memcpy(vmu_cache->buffer, block_buffer, VMU_BLOCK_SIZE); + memcpy(vmu_cache->buffer, block_buffer, card->blocklen); vmu_cache->block = mq->recvbuf[11] & 0xff; vmu_cache->jiffies_atc = jiffies; /* Mark the creation time */ vmu_cache->valid = 1; /* Block is now valid */ @@ -542,8 +555,6 @@ lastmq = mq; } - - static int dc_flashmap_connect(struct maple_driver_data *d) { DEBGM @@ -559,8 +570,7 @@ lastmq = NULL; mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { - DEBGM(KERN_WARNING - "VMU FLASH: Could not add packet to query device\n"); + DEBGM("VMU FLASH: Could not add packet to query device\n"); return -1; } @@ -586,10 +596,8 @@ be32_to_cpu(((unsigned long *) (lastmq->recvbuf))[1 + bit_cnt - controller_here]); - - /* Create a permanent record */ - - /* With thanks to Marcus Comstedt */ + /* Create a permanent record + * With thanks to Marcus Comstedt */ memcard_t *card = kmalloc(sizeof(memcard_t), GFP_KERNEL); card->partitions = ((basic_flash_data >> 24) & 0xff) + 1; @@ -619,8 +627,7 @@ lastmq = NULL; mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { - DEBGM(KERN_WARNING - "VMU FLASH: Could not add packet to query device\n"); + DEBGM("VMU FLASH: Could not add packet to query device\n"); return -1; } @@ -634,10 +641,7 @@ DEBGM(" Flash device has %d blocks available to user\n", user_blocks); DEBGM(" Flash root block is at block %d\n", root_block); - VMU_NUM_BLOCKS = root_block + 1; - - - + card->numblocks = root_block + 1; /* Register the flash with mtd subsystem */ @@ -651,8 +655,8 @@ vmu_flash_mtd->flags = MTD_CLEAR_BITS | MTD_SET_BITS | MTD_ERASEABLE | MTD_WRITEB_WRITEABLE; - vmu_flash_mtd->size = VMU_NUM_BLOCKS * VMU_BLOCK_SIZE; - vmu_flash_mtd->erasesize = VMU_BLOCK_SIZE; + vmu_flash_mtd->size = card->numblocks * card->blocklen; + vmu_flash_mtd->erasesize = card->blocklen; /* Mandatory functions */ vmu_flash_mtd->write = vmu_flash_write; @@ -660,9 +664,7 @@ vmu_flash_mtd->erase = vmu_flash_erase; vmu_flash_mtd->sync = vmu_flash_sync; /* Use private data to point to d */ - vmu_flash_mtd->priv = d; /* TO DO: Fix this */ - - + vmu_flash_mtd->priv = d; vmu_flash_mtd->module = THIS_MODULE; @@ -671,14 +673,14 @@ /* Lock the device in */ vmu_flash_mtd = get_mtd_device(vmu_flash_mtd, -1); if (!vmu_flash_mtd) { - DEBGM(KERN_ERR "VMU Flash driver initialisation failed\n"); + DEBGM("VMU Flash driver initialisation failed\n"); return -1; } card->mtd = vmu_flash_mtd; /* Create the cache */ vmu_cache = kmalloc(64, GFP_KERNEL); - vmu_cache->buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); + vmu_cache->buffer = kmalloc(card->blocklen, GFP_KERNEL); vmu_cache->valid = 0; return 0; @@ -693,7 +695,7 @@ /* See if there's anything to unregister */ if (!(card->mtd)) { - DEBGM(KERN_WARNING "Nothing to unregister\n"); + DEBGM("Nothing to unregister\n"); return; } @@ -716,7 +718,6 @@ } - /***********Maple device*****************/ static struct maple_driver dc_flashmap_driver = { function:MAPLE_FUNC_MEMCARD, @@ -727,10 +728,6 @@ }; - - - - module_init(vmu_flash_map_init); |
From: Adrian M. <zx8...@us...> - 2002-09-11 20:09:10
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv23652 Modified Files: ChangeLog.dc Log Message: Code cleaned up Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- ChangeLog.dc 10 Sep 2002 22:55:50 -0000 1.44 +++ ChangeLog.dc 11 Sep 2002 20:09:07 -0000 1.45 @@ -1,3 +1,8 @@ +2002-09-11 Adrian McMenamin <ad...@mc...> + + * drivers/mtd/maps/vmu-flash.c: Code cleaned-up + + 2002-09-10 Adrian McMenamin <ad...@mc...> * drivers/mtd/maps/vmu-flash.c: Multiple |
From: Adrian M. <zx8...@us...> - 2002-09-10 22:55:54
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps In directory usw-pr-cvs1:/tmp/cvs-serv5751/drivers/mtd/maps Modified Files: vmu-flash.c Log Message: Multiple VMU devices now supported Index: vmu-flash.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps/vmu-flash.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- vmu-flash.c 3 Sep 2002 21:46:31 -0000 1.9 +++ vmu-flash.c 10 Sep 2002 22:55:51 -0000 1.10 @@ -26,6 +26,15 @@ static int VMU_NUM_BLOCKS; /* This is a dynamic property */ static int VMU_BLOCK_SIZE; +#define _DEBUG_ + +#ifdef _DEBUG_ +#define DEBGM(fmt, args...) (printk(KERN_INFO fmt, ##args)) +#else +#define DEBGM(fmt, args...) ((void) 0) +#endif + + /* MTD Information */ static struct mtd_info *vmu_flash_mtd = NULL; @@ -45,6 +54,7 @@ long writecnt; long readcnt; long removable; + struct mtd_info *mtd; } memcard_t; @@ -69,10 +79,9 @@ wait_queue_head_t wq_mq; DECLARE_WAIT_QUEUE_HEAD(wq_mq); - -/*************************************/ /**********Read and write routines*************/ -static int maple_vmu_read_block(unsigned int num, u_char * buf) +static int maple_vmu_read_block(unsigned int num, u_char * buf, + struct mtd_info *mtd) { /* async maple call @@ -81,14 +90,14 @@ /* Sanity check */ - if (!vmu_flash_mtd) { - printk(KERN_WARNING - "VMU FLASH: Attempting to read data without having set up mtd.\n"); + if (!mtd) { + DEBGM(KERN_WARNING + "VMU FLASH: Attempting to read data without having set up mtd.\n"); return -1; } struct maple_driver_data *mdd = - (struct maple_driver_data *) (vmu_flash_mtd->priv); + (struct maple_driver_data *) (mtd->priv); memcard_t *memcard = (memcard_t *) (mdd->private_data); struct mapleq *mqu = (struct mapleq *) &(mdd->mq); mqu->command = MAPLE_COMMAND_BREAD; @@ -102,7 +111,7 @@ ((unsigned long *) (mqu->recvbuf))[1] = num << 24; mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { - printk(KERN_WARNING "VMU FLASH: Could not add packet\n"); + DEBGM(KERN_WARNING "VMU FLASH: Could not add packet\n"); return -1; } @@ -121,21 +130,21 @@ return 0; } - printk(KERN_WARNING - "VMU FLASH: Read has failed - return is 0x%X\n", - lastmq->recvbuf[0]); - printk(KERN_WARNING "ERROR code is 0x%X\n", lastmq->recvbuf[1]); + DEBGM(KERN_WARNING + "VMU FLASH: Read has failed - return is 0x%X\n", + lastmq->recvbuf[0]); + DEBGM(KERN_WARNING "ERROR code is 0x%X\n", lastmq->recvbuf[1]); return -1; } -static int maple_vmu_write_block(unsigned int num, u_char * buf) +static int maple_vmu_write_block(unsigned int num, u_char * buf, struct mtd_info *mtd) { /* Sanity check */ - if (!vmu_flash_mtd) { + if (!mtd) { printk(KERN_WARNING "VMU FLASH: Attempting to write data without having set up mtd.\n"); return -1; @@ -143,7 +152,7 @@ vmu_cache->valid = 0; /* Writing so any cache may be invalid */ struct maple_driver_data *mdd = - (struct maple_driver_data *) (vmu_flash_mtd->priv); + (struct maple_driver_data *) (mtd->priv); struct mapleq *mqu = (struct mapleq *) &(mdd->mq); memcard_t *memcard = (memcard_t *) mdd->private_data; @@ -200,7 +209,7 @@ /* Validate we've got allocated memory */ if (!block) { - printk(KERN_WARNING "Can't allocate block\n"); + DEBGM(KERN_WARNING "Can't allocate block\n"); return NULL; } @@ -209,8 +218,7 @@ /* Make sure we don't overstep our boundaries */ if (src_ofs >= VMU_NUM_BLOCKS * VMU_BLOCK_SIZE) { - printk(KERN_WARNING - "Source offset exceeds total offset\n"); + DEBGM(KERN_WARNING "Source offset exceeds total offset\n"); kfree(block); return NULL; } @@ -220,8 +228,8 @@ /* Validate we've got a valid block */ if (block->num > VMU_NUM_BLOCKS) { - printk(KERN_WARNING - "Block number exceeds number of blocks\n"); + DEBGM(KERN_WARNING + "Block number exceeds number of blocks\n"); kfree(block); return NULL; } @@ -243,7 +251,8 @@ * */ -static __u8 vmu_flash_read8(unsigned long ofs, long *retval) +static __u8 vmu_flash_read8(unsigned long ofs, long *retval, + struct mtd_info *mtd) { block_t *block; *retval = 0; @@ -253,7 +262,7 @@ /* Validate it was found */ if (!block) { - printk(KERN_WARNING "Got an invalid block\n"); + DEBGM(KERN_WARNING "Got an invalid block\n"); *retval = 1; return -1; } @@ -280,8 +289,8 @@ /* Read the block */ - if (maple_vmu_read_block(block->num, buf) == -1) { - printk(KERN_WARNING "Can't read block: %d\n", block->num); + if (maple_vmu_read_block(block->num, buf, mtd) == -1) { + DEBGM(KERN_WARNING "Can't read block: %d\n", block->num); kfree(block); *retval = 2; return -1; @@ -307,7 +316,8 @@ * Writes a byte to a VMU at the specified offset. * */ -static void vmu_flash_write8(__u8 d, unsigned long ofs) +static void vmu_flash_write8(__u8 d, unsigned long ofs, + struct mtd_info *mtd) { block_t *block; u_char *buf = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); @@ -317,14 +327,14 @@ /* Validate it was found */ if (!block) { - printk(KERN_WARNING "Got an invalid block\n"); + DEBGM(KERN_WARNING "Got an invalid block\n"); return; } /* Read the block */ - if (maple_vmu_read_block(block->num, buf)) { - printk(KERN_WARNING "Can't read block: %d\n", block->num); + if (maple_vmu_read_block(block->num, buf, mtd)) { + DEBGM(KERN_WARNING "Can't read block: %d\n", block->num); kfree(block); return; } @@ -333,7 +343,7 @@ (__u8) (*(buf + block->ofs)) = d; /* Write the block */ - if (maple_vmu_write_block(block->num, buf)) { + if (maple_vmu_write_block(block->num, buf, mtd)) { printk(KERN_WARNING "Can't write block: %d\n", block->num); kfree(block); return; @@ -360,7 +370,7 @@ long retval = 0; int index = 0; do { - u8 cx = vmu_flash_read8(start_here + index, &retval); + u8 cx = vmu_flash_read8(start_here + index, &retval, mtd); if (retval) { *retlen = index; return -1; @@ -381,7 +391,7 @@ return -1; if (len == 1) { /* Simple one char write */ - vmu_flash_write8(buf[0], from); + vmu_flash_write8(buf[0], from, mtd); *retlen = 1; return 0; } @@ -402,16 +412,12 @@ do { - u_char *buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); - - - /* Read the block */ - if (maple_vmu_read_block(block->num, buffer)) { - printk(KERN_WARNING "Can't read block: %d\n", - block->num); + if (maple_vmu_read_block(block->num, buffer, mtd)) { + DEBGM(KERN_WARNING "Can't read block: %d\n", + block->num); kfree(block); *retlen = 0; return -1; @@ -424,7 +430,7 @@ if (index >= len) break; } while (block->ofs < VMU_BLOCK_SIZE); - maple_vmu_write_block(block->num, buffer); + maple_vmu_write_block(block->num, buffer, mtd); kfree(buffer); (block->num)++; block->ofs = 0; @@ -435,14 +441,16 @@ - - } static int vmu_flash_erase(struct mtd_info *mtd, struct erase_info *erase) { int z; + erase->state = MTD_ERASING; vmu_flash_write(mtd, erase->addr, erase->len, &z, "\0"); + erase->state = MTD_ERASE_DONE; + if (erase->callback) + (erase->callback) (erase); return 0; } @@ -461,12 +469,7 @@ static int __init vmu_flash_map_init(void) { printk(KERN_NOTICE "VMU flash driver available\n"); - maple_register_driver(&dc_flashmap_driver); - /* FIXME: We need to do something with the vmu_flash_mdev */ - - - return 0; } @@ -484,7 +487,7 @@ maple_unregister_driver(&dc_flashmap_driver); /* See if there's anything to unregister */ if (!vmu_flash_mtd) { - printk(KERN_WARNING "Nothing to unregister\n"); + DEBGM(KERN_WARNING "Nothing to unregister\n"); return; } @@ -543,7 +546,7 @@ static int dc_flashmap_connect(struct maple_driver_data *d) { - printk + DEBGM ("Registering VMU Flash mapping and loading VMU Flash driver\n"); /* What are the characteristics of the flash we have? */ @@ -556,8 +559,8 @@ lastmq = NULL; mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { - printk(KERN_WARNING - "VMU FLASH: Could not add packet to query device\n"); + DEBGM(KERN_WARNING + "VMU FLASH: Could not add packet to query device\n"); return -1; } @@ -566,7 +569,6 @@ } while (lastmq == NULL); /* Read off the flash data */ - /* How many devices are here? */ int bit_cnt = 0; unsigned long test_flash_data = @@ -591,21 +593,17 @@ memcard_t *card = kmalloc(sizeof(memcard_t), GFP_KERNEL); card->partitions = ((basic_flash_data >> 24) & 0xff) + 1; - printk(KERN_NOTICE " Flash device has %ld partitions\n", - card->partitions); + DEBGM(" Flash device has %ld partitions\n", card->partitions); card->blocklen = (((basic_flash_data >> 16) & 0xff) + 1) << 5; - printk(KERN_NOTICE - " Flash device has block length of %ld bytes\n", - card->blocklen); + DEBGM(" Flash device has block length of %ld bytes\n", + card->blocklen); card->writecnt = (basic_flash_data >> 12) & 0xf; - printk(KERN_NOTICE " Flash device has write count of %ld\n", - card->writecnt); + DEBGM(" Flash device has write count of %ld\n", card->writecnt); card->readcnt = (basic_flash_data >> 8) & 0xf; - printk(KERN_NOTICE " Flash device has read count of %ld\n", - card->readcnt); + DEBGM(" Flash device has read count of %ld\n", card->readcnt); card->removable = (basic_flash_data >> 7) & 1; - printk(KERN_NOTICE " Flash device removable status is %ld\n", - card->removable); + DEBGM(" Flash device removable status is %ld\n", + card->removable); VMU_BLOCK_SIZE = card->blocklen; d->private_data = card; @@ -616,13 +614,13 @@ mqu->length = 2; ((unsigned long *) (mqu->recvbuf))[0] = cpu_to_be32(MAPLE_FUNC_MEMCARD); - ((unsigned long *) (mqu->recvbuf))[1] = 0; // Assuming only have one partition + ((unsigned long *) (mqu->recvbuf))[1] = 0; /* Assuming only have one partition */ lastmq = NULL; mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { - printk(KERN_WARNING - "VMU FLASH: Could not add packet to query device\n"); + DEBGM(KERN_WARNING + "VMU FLASH: Could not add packet to query device\n"); return -1; } @@ -631,13 +629,11 @@ interruptible_sleep_on_timeout(&wq_mq, 1); } while (lastmq == NULL); - int user_blocks = ((unsigned short *) (lastmq->recvbuf))[12]; // User accessible blocks - int root_block = ((unsigned short *) (lastmq->recvbuf))[6]; // Root block location - printk(KERN_INFO - " Flash device has %d blocks available to user\n", - user_blocks); - printk(KERN_INFO " Flash root block is at block %d\n", - root_block); + int user_blocks = ((unsigned short *) (lastmq->recvbuf))[12]; /* User accessible blocks */ + int root_block = ((unsigned short *) (lastmq->recvbuf))[6]; /* Root block location */ + DEBGM(" Flash device has %d blocks available to user\n", + user_blocks); + DEBGM(" Flash root block is at block %d\n", root_block); VMU_NUM_BLOCKS = root_block + 1; @@ -645,27 +641,27 @@ /* Register the flash with mtd subsystem */ - if (!vmu_flash_mtd) { - /* Populate a mtd_info */ - vmu_flash_mtd = kmalloc(512, GFP_KERNEL); - vmu_flash_mtd->name = "Dreamcast VMU Flash"; - /* This is 'other' */ - vmu_flash_mtd->type = MTD_OTHER; - vmu_flash_mtd->flags = - MTD_CLEAR_BITS | MTD_SET_BITS | MTD_ERASEABLE | - MTD_WRITEB_WRITEABLE; - vmu_flash_mtd->size = VMU_NUM_BLOCKS * VMU_BLOCK_SIZE; - vmu_flash_mtd->erasesize = VMU_BLOCK_SIZE; + /* Populate a mtd_info */ + vmu_flash_mtd = kmalloc(512, GFP_KERNEL); + vmu_flash_mtd->name = "Dreamcast VMU Flash"; + + /* This is 'other' */ + vmu_flash_mtd->type = MTD_OTHER; + vmu_flash_mtd->flags = + MTD_CLEAR_BITS | MTD_SET_BITS | MTD_ERASEABLE | + MTD_WRITEB_WRITEABLE; + vmu_flash_mtd->size = VMU_NUM_BLOCKS * VMU_BLOCK_SIZE; + vmu_flash_mtd->erasesize = VMU_BLOCK_SIZE; + + /* Mandatory functions */ + vmu_flash_mtd->write = vmu_flash_write; + vmu_flash_mtd->read = vmu_flash_read; + vmu_flash_mtd->erase = vmu_flash_erase; + vmu_flash_mtd->sync = vmu_flash_sync; + /* Use private data to point to d */ + vmu_flash_mtd->priv = d; /* TO DO: Fix this */ - /* Mandatory functions */ - vmu_flash_mtd->write = vmu_flash_write; - vmu_flash_mtd->read = vmu_flash_read; - vmu_flash_mtd->erase = vmu_flash_erase; - vmu_flash_mtd->sync = vmu_flash_sync; - /* Use private data to point to d */ - vmu_flash_mtd->priv = d; - } vmu_flash_mtd->module = THIS_MODULE; @@ -675,12 +671,11 @@ /* Lock the device in */ vmu_flash_mtd = get_mtd_device(vmu_flash_mtd, -1); if (!vmu_flash_mtd) { - printk(KERN_ERR - "VMU Flash driver initialisation failed\n"); + DEBGM(KERN_ERR "VMU Flash driver initialisation failed\n"); return -1; } - + card->mtd = vmu_flash_mtd; /* Create the cache */ vmu_cache = kmalloc(64, GFP_KERNEL); vmu_cache->buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); @@ -693,19 +688,22 @@ { printk(KERN_NOTICE "Unregistering VMU flash mapping\n"); + /* Reead off the relevant mtd */ + memcard_t *card = (memcard_t *) (d->private_data); + /* See if there's anything to unregister */ - if (!vmu_flash_mtd) { - printk(KERN_WARNING "Nothing to unregister\n"); + if (!(card->mtd)) { + DEBGM(KERN_WARNING "Nothing to unregister\n"); return; } - if (vmu_flash_mtd) { + if (card->mtd) { /* Unregister from MTD */ - put_mtd_device(vmu_flash_mtd); - del_mtd_device(vmu_flash_mtd); - kfree(vmu_flash_mtd); - vmu_flash_mtd = NULL; + put_mtd_device(card->mtd); + del_mtd_device(card->mtd); + kfree(card->mtd); + card->mtd = NULL; } /* Clear the cache */ |
From: Adrian M. <zx8...@us...> - 2002-09-10 22:55:54
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv5751 Modified Files: ChangeLog.dc Log Message: Multiple VMU devices now supported Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.43 retrieving revision 1.44 diff -u -d -r1.43 -r1.44 --- ChangeLog.dc 3 Sep 2002 21:46:31 -0000 1.43 +++ ChangeLog.dc 10 Sep 2002 22:55:50 -0000 1.44 @@ -1,3 +1,9 @@ +2002-09-10 Adrian McMenamin <ad...@mc...> + + * drivers/mtd/maps/vmu-flash.c: Multiple + vmu devices now supported + + 2002-09-03 Adrian McMenamin <ad...@mc...> * drivers/mtd/maps/vmu-flash.c: Writes now |
From: Adrian M. <zx8...@us...> - 2002-09-03 21:46:34
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv6320 Modified Files: ChangeLog.dc Log Message: VMU writes cached Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- ChangeLog.dc 1 Sep 2002 21:26:05 -0000 1.42 +++ ChangeLog.dc 3 Sep 2002 21:46:31 -0000 1.43 @@ -1,3 +1,9 @@ +2002-09-03 Adrian McMenamin <ad...@mc...> + + * drivers/mtd/maps/vmu-flash.c: Writes now + cached + + 2002-09-01 Adrian McMenamin <ad...@mc...> VMU writes now working - but slowly and code |
From: Adrian M. <zx8...@us...> - 2002-09-03 21:46:34
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps In directory usw-pr-cvs1:/tmp/cvs-serv6320/drivers/mtd/maps Modified Files: vmu-flash.c Log Message: VMU writes cached Index: vmu-flash.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps/vmu-flash.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- vmu-flash.c 1 Sep 2002 21:26:05 -0000 1.8 +++ vmu-flash.c 3 Sep 2002 21:46:31 -0000 1.9 @@ -89,7 +89,7 @@ struct maple_driver_data *mdd = (struct maple_driver_data *) (vmu_flash_mtd->priv); - memcard_t *memcard = (memcard_t *)(mdd->private_data); + memcard_t *memcard = (memcard_t *) (mdd->private_data); struct mapleq *mqu = (struct mapleq *) &(mdd->mq); mqu->command = MAPLE_COMMAND_BREAD; mqu->length = 2; @@ -141,36 +141,40 @@ return -1; } + vmu_cache->valid = 0; /* Writing so any cache may be invalid */ struct maple_driver_data *mdd = (struct maple_driver_data *) (vmu_flash_mtd->priv); struct mapleq *mqu = (struct mapleq *) &(mdd->mq); - memcard_t *memcard = (memcard_t *)mdd->private_data; + memcard_t *memcard = (memcard_t *) mdd->private_data; /* Writing is phased */ int x; - for (x = 0; x < memcard->writecnt; x++) - { - mqu->command = MAPLE_COMMAND_BWRITE; - mqu->length = (VMU_BLOCK_SIZE/(memcard->writecnt * 4)) + 2; + for (x = 0; x < memcard->writecnt; x++) { + mqu->command = MAPLE_COMMAND_BWRITE; + mqu->length = + (VMU_BLOCK_SIZE / (memcard->writecnt * 4)) + 2; - ((unsigned long *) (mqu->recvbuf))[0] = - cpu_to_be32(MAPLE_FUNC_MEMCARD); + ((unsigned long *) (mqu->recvbuf))[0] = + cpu_to_be32(MAPLE_FUNC_MEMCARD); - ((unsigned long *) (mqu->recvbuf))[1] = num << 24 | x << 8; - memcpy(mqu->recvbuf + 8, buf + (VMU_BLOCK_SIZE/memcard->writecnt)* x, VMU_BLOCK_SIZE/memcard->writecnt); + ((unsigned long *) (mqu->recvbuf))[1] = num << 24 | x << 8; + memcpy(mqu->recvbuf + 8, + buf + (VMU_BLOCK_SIZE / memcard->writecnt) * x, + VMU_BLOCK_SIZE / memcard->writecnt); - mqu->sendbuf = mqu->recvbuf; - if (maple_add_packet(mqu) != 0) { - printk(KERN_WARNING "VMU FLASH: Could not add packet\n"); - return -1; - } + mqu->sendbuf = mqu->recvbuf; + if (maple_add_packet(mqu) != 0) { + printk(KERN_WARNING + "VMU FLASH: Could not add packet\n"); + return -1; + } - lastmq = NULL; - /* Wait */ - do { - interruptible_sleep_on_timeout(&wq_mq, 1); - } while (lastmq == NULL); - } + lastmq = NULL; + /* Wait */ + do { + interruptible_sleep_on_timeout(&wq_mq, 1); + } while (lastmq == NULL); + } return 0; } @@ -258,7 +262,8 @@ if (vmu_cache->valid) { if (vmu_cache->block == block->num) { if ((vmu_cache->jiffies_atc + 10) >= jiffies) { /* short lifespan */ - memcpy(buf, vmu_cache->buffer, VMU_BLOCK_SIZE); + memcpy(buf, vmu_cache->buffer, + VMU_BLOCK_SIZE); u_char *buf2 = buf; buf2 += block->ofs; @@ -375,13 +380,63 @@ if (len < 1) return -1; + if (len == 1) { /* Simple one char write */ + vmu_flash_write8(buf[0], from); + *retlen = 1; + return 0; + } + + /* Cached write */ int index = 0; + + block_t *block; + /* Find the block */ + block = __ofs_to_block(from); + + /* Validate it was found */ + if (!block) { + printk(KERN_WARNING "Got an invalid block\n"); + *retlen = 0; + return -1; + } + do { - vmu_flash_write8(buf[index], from + index); - index++; + + + u_char *buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); + + + + + /* Read the block */ + if (maple_vmu_read_block(block->num, buffer)) { + printk(KERN_WARNING "Can't read block: %d\n", + block->num); + kfree(block); + *retlen = 0; + return -1; + } + + do { + buffer[block->ofs] = buf[index]; + (block->ofs)++; + index++; + if (index >= len) + break; + } while (block->ofs < VMU_BLOCK_SIZE); + maple_vmu_write_block(block->num, buffer); + kfree(buffer); + (block->num)++; + block->ofs = 0; } while (len > index); *retlen = index; + kfree(block); return 0; + + + + + } static int vmu_flash_erase(struct mtd_info *mtd, struct erase_info *erase) @@ -557,7 +612,7 @@ /* Now query flash partition 0 to find definitve block size */ mqu = (struct mapleq *) &(d->mq); - mqu->command = MAPLE_COMMAND_GETMINFO ; + mqu->command = MAPLE_COMMAND_GETMINFO; mqu->length = 2; ((unsigned long *) (mqu->recvbuf))[0] = cpu_to_be32(MAPLE_FUNC_MEMCARD); @@ -597,7 +652,9 @@ /* This is 'other' */ vmu_flash_mtd->type = MTD_OTHER; - vmu_flash_mtd->flags = MTD_CLEAR_BITS|MTD_SET_BITS|MTD_ERASEABLE|MTD_WRITEB_WRITEABLE; + vmu_flash_mtd->flags = + MTD_CLEAR_BITS | MTD_SET_BITS | MTD_ERASEABLE | + MTD_WRITEB_WRITEABLE; vmu_flash_mtd->size = VMU_NUM_BLOCKS * VMU_BLOCK_SIZE; vmu_flash_mtd->erasesize = VMU_BLOCK_SIZE; |
From: Adrian M. <zx8...@us...> - 2002-09-01 21:26:08
|
Update of /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps In directory usw-pr-cvs1:/tmp/cvs-serv13970/drivers/mtd/maps Modified Files: vmu-flash.c Log Message: VMU driver now supports writing Index: vmu-flash.c =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/drivers/mtd/maps/vmu-flash.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- vmu-flash.c 31 Aug 2002 18:17:13 -0000 1.7 +++ vmu-flash.c 1 Sep 2002 21:26:05 -0000 1.8 @@ -26,8 +26,7 @@ static int VMU_NUM_BLOCKS; /* This is a dynamic property */ static int VMU_BLOCK_SIZE; -/* Maple Device */ -static struct maple_device *vmu_flash_mdev = NULL; + /* MTD Information */ static struct mtd_info *vmu_flash_mtd = NULL; @@ -90,8 +89,9 @@ struct maple_driver_data *mdd = (struct maple_driver_data *) (vmu_flash_mtd->priv); + memcard_t *memcard = (memcard_t *)(mdd->private_data); struct mapleq *mqu = (struct mapleq *) &(mdd->mq); - mqu->command = 11; + mqu->command = MAPLE_COMMAND_BREAD; mqu->length = 2; ((unsigned long *) (mqu->recvbuf))[0] = @@ -99,8 +99,7 @@ /* With thanks to KOS */ - ((unsigned long *) (mqu->recvbuf))[1] = - /*((num & 0xff) << 24) | ((num >> 8) << 16) */ num << 24; + ((unsigned long *) (mqu->recvbuf))[1] = num << 24; mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { printk(KERN_WARNING "VMU FLASH: Could not add packet\n"); @@ -116,7 +115,7 @@ /* Now check if we've got a proper return */ if (block_buffer) { - memcpy(buf, block_buffer, 512); + memcpy(buf, block_buffer, memcard->blocklen); kfree(block_buffer); block_buffer = NULL; return 0; @@ -134,7 +133,6 @@ static int maple_vmu_write_block(unsigned int num, u_char * buf) { - /* This function does not have to sleep */ /* Sanity check */ if (!vmu_flash_mtd) { @@ -146,14 +144,20 @@ struct maple_driver_data *mdd = (struct maple_driver_data *) (vmu_flash_mtd->priv); struct mapleq *mqu = (struct mapleq *) &(mdd->mq); - mqu->command = 12; - mqu->length = 514; + memcard_t *memcard = (memcard_t *)mdd->private_data; + + /* Writing is phased */ + int x; + for (x = 0; x < memcard->writecnt; x++) + { + mqu->command = MAPLE_COMMAND_BWRITE; + mqu->length = (VMU_BLOCK_SIZE/(memcard->writecnt * 4)) + 2; ((unsigned long *) (mqu->recvbuf))[0] = cpu_to_be32(MAPLE_FUNC_MEMCARD); - ((unsigned long *) (mqu->recvbuf))[1] = num; - memcpy(buf, (mqu->recvbuf) + 8, 512); + ((unsigned long *) (mqu->recvbuf))[1] = num << 24 | x << 8; + memcpy(mqu->recvbuf + 8, buf + (VMU_BLOCK_SIZE/memcard->writecnt)* x, VMU_BLOCK_SIZE/memcard->writecnt); mqu->sendbuf = mqu->recvbuf; if (maple_add_packet(mqu) != 0) { @@ -161,6 +165,12 @@ return -1; } + lastmq = NULL; + /* Wait */ + do { + interruptible_sleep_on_timeout(&wq_mq, 1); + } while (lastmq == NULL); + } return 0; } @@ -233,7 +243,7 @@ { block_t *block; *retval = 0; - u_char *buf = kmalloc(512, GFP_KERNEL); + u_char *buf = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); /* Find the block */ block = __ofs_to_block(ofs); @@ -248,7 +258,7 @@ if (vmu_cache->valid) { if (vmu_cache->block == block->num) { if ((vmu_cache->jiffies_atc + 10) >= jiffies) { /* short lifespan */ - memcpy(buf, vmu_cache->buffer, 512); + memcpy(buf, vmu_cache->buffer, VMU_BLOCK_SIZE); u_char *buf2 = buf; buf2 += block->ofs; @@ -295,7 +305,7 @@ static void vmu_flash_write8(__u8 d, unsigned long ofs) { block_t *block; - u_char *buf = kmalloc(512, GFP_KERNEL); + u_char *buf = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); /* Find the block */ block = __ofs_to_block(ofs); @@ -335,10 +345,12 @@ size_t * retlen, u_char * buf) { /* printk("Reading from %llx with length %llx\n", from, len); */ + + if (len < 1) return -1; - if (len > (128 * 1024)) - len = 128 * 1024; + if (len > (VMU_NUM_BLOCKS * VMU_BLOCK_SIZE)) + len = VMU_NUM_BLOCKS * VMU_BLOCK_SIZE; int start_here = (int) (from & 0xffffffff); long retval = 0; int index = 0; @@ -362,6 +374,7 @@ { if (len < 1) return -1; + int index = 0; do { vmu_flash_write8(buf[index], from + index); @@ -432,11 +445,11 @@ { struct mapleq *mq = &data->mq; if (flash_queried == 0) { - if (mq->recvbuf[0] == 5) { + if (mq->recvbuf[0] == MAPLE_RESPONSE_DEVINFO) { lastmq = mq; wake_up_interruptible(&wq_mq); /* Wake sleeping code */ return; - } else if (mq->recvbuf[0] == 8) { + } else if (mq->recvbuf[0] == MAPLE_RESPONSE_DATATRF) { lastmq = mq; wake_up_interruptible(&wq_mq); /* Wake sleeping code */ flash_queried = 1; @@ -445,7 +458,7 @@ } - if (mq->recvbuf[0] == 8) { + if (mq->recvbuf[0] == MAPLE_RESPONSE_DATATRF) { /* int res = mq->recvbuf[0]; printk @@ -456,13 +469,13 @@ mq->recvbuf[8], mq->recvbuf[9], mq->recvbuf[10], mq->recvbuf[11]); */ - block_buffer = kmalloc(512, GFP_KERNEL); + block_buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); /* Copy over */ - memcpy(block_buffer, mq->recvbuf + 12, 512); + memcpy(block_buffer, mq->recvbuf + 12, VMU_BLOCK_SIZE); lastmq = mq; wake_up_interruptible(&wq_mq); /* Wake sleeping code */ - memcpy(vmu_cache->buffer, block_buffer, 512); + memcpy(vmu_cache->buffer, block_buffer, VMU_BLOCK_SIZE); vmu_cache->block = mq->recvbuf[11] & 0xff; vmu_cache->jiffies_atc = jiffies; /* Mark the creation time */ vmu_cache->valid = 1; /* Block is now valid */ @@ -482,7 +495,7 @@ struct mapleq *mqu = (struct mapleq *) &(d->mq); - mqu->command = 1; + mqu->command = MAPLE_COMMAND_DEVINFO; mqu->length = 0; lastmq = NULL; @@ -544,7 +557,7 @@ /* Now query flash partition 0 to find definitve block size */ mqu = (struct mapleq *) &(d->mq); - mqu->command = 10; + mqu->command = MAPLE_COMMAND_GETMINFO ; mqu->length = 2; ((unsigned long *) (mqu->recvbuf))[0] = cpu_to_be32(MAPLE_FUNC_MEMCARD); @@ -584,9 +597,9 @@ /* This is 'other' */ vmu_flash_mtd->type = MTD_OTHER; - vmu_flash_mtd->flags = 0; + vmu_flash_mtd->flags = MTD_CLEAR_BITS|MTD_SET_BITS|MTD_ERASEABLE|MTD_WRITEB_WRITEABLE; vmu_flash_mtd->size = VMU_NUM_BLOCKS * VMU_BLOCK_SIZE; - vmu_flash_mtd->erasesize = VMU_BLOCK_SIZE / card->writecnt; + vmu_flash_mtd->erasesize = VMU_BLOCK_SIZE; /* Mandatory functions */ vmu_flash_mtd->write = vmu_flash_write; @@ -613,7 +626,7 @@ /* Create the cache */ vmu_cache = kmalloc(64, GFP_KERNEL); - vmu_cache->buffer = kmalloc(512, GFP_KERNEL); + vmu_cache->buffer = kmalloc(VMU_BLOCK_SIZE, GFP_KERNEL); vmu_cache->valid = 0; return 0; |
From: Adrian M. <zx8...@us...> - 2002-09-01 21:26:08
|
Update of /cvsroot/linuxdc/linux-sh-dc In directory usw-pr-cvs1:/tmp/cvs-serv13970 Modified Files: ChangeLog.dc Log Message: VMU driver now supports writing Index: ChangeLog.dc =================================================================== RCS file: /cvsroot/linuxdc/linux-sh-dc/ChangeLog.dc,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- ChangeLog.dc 31 Aug 2002 18:17:13 -0000 1.41 +++ ChangeLog.dc 1 Sep 2002 21:26:05 -0000 1.42 @@ -1,3 +1,13 @@ +2002-09-01 Adrian McMenamin <ad...@mc...> + + VMU writes now working - but slowly and code + needs to be cleaned. Beware of writing over + saved game data! + + * drivers/mtd/maps/vmu-flash.c: Phased writing + now in place and appears to work using kernel + 'flat' char and cached block drivers. + 2002-08-31 Adrian McMenamin <ad...@mc...> VMU reads now work |