Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/uebayasi-xip]: src/sys/dev Implement DIOCGPHYSADDR, a special block devi...
details: https://anonhg.NetBSD.org/src/rev/7d16babcd834
branches: uebayasi-xip
changeset: 751597:7d16babcd834
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Wed Feb 24 01:19:37 2010 +0000
description:
Implement DIOCGPHYSADDR, a special block device ioctl for block devices that
can be directly memory-mapped. When such a device is mounted, VFS checks
the backing store is XIP capable by querying this ioctl.
Add struct disk to struct flash_softc and let it do common bdev tasks.
diffstat:
sys/dev/flash.c | 47 ++++++++++++++++++++++++++++++++++++++++++++---
sys/dev/flashvar.h | 5 ++++-
2 files changed, 48 insertions(+), 4 deletions(-)
diffs (116 lines):
diff -r 5217c143dd95 -r 7d16babcd834 sys/dev/flash.c
--- a/sys/dev/flash.c Tue Feb 23 15:38:30 2010 +0000
+++ b/sys/dev/flash.c Wed Feb 24 01:19:37 2010 +0000
@@ -1,4 +1,4 @@
-/* $Id: flash.c,v 1.1.2.1 2010/02/12 01:36:02 uebayasi Exp $ */
+/* $Id: flash.c,v 1.1.2.2 2010/02/24 01:19:37 uebayasi Exp $ */
/*-
* Copyright (c) 2010 Tsubai Masanari. All rights reserved.
@@ -26,6 +26,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "opt_xip.h"
+
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/conf.h>
@@ -44,7 +46,7 @@
struct bdevsw flash_bdevsw = {
flash_open, flash_close, flash_strategy, flash_ioctl,
- nodump, flash_size, D_DISK
+ nodump, flash_size, D_DISK | D_MPSAFE
};
struct cdevsw flash_cdevsw = {
@@ -56,10 +58,23 @@
flash_open(dev_t dev, int flags, int fmt, struct lwp *l)
{
struct flash_softc *sc = device_lookup_private(&flash_cd, minor(dev));
+ struct disk *dk = &sc->sc_dkdev;
if (sc == NULL)
return ENXIO;
+ mutex_enter(&dk->dk_openlock);
+ switch (fmt) {
+ case S_IFCHR:
+ dk->dk_copenmask |= pmask;
+ break;
+ case S_IFBLK:
+ dk->dk_bopenmask |= pmask;
+ break;
+ }
+ dk->dk_openmask = dk->dk_copenmask | dk->dk_bopenmask;
+ mutex_exit(&dk->dk_openlock);
+
return 0;
}
@@ -74,11 +89,37 @@
{
struct flash_softc *sc = device_lookup_private(&flash_cd, minor(dev));
struct flash_program *fp;
+ int error = 0;
if (sc == NULL)
return -1;
- return EPASSTHROUGH;
+ switch (cmd) {
+#ifdef XIP
+ case DIOCGPHYSADDR:
+ if (sc->sc_addr == 0)
+ error = EINVAL;
+ else
+ *(paddr_t *)data = sc->sc_addr;
+ break;
+#endif
+
+ case DIOCGDINFO:
+ *(struct disklabel *)data = *sc->sc_dkdev.dk_label;
+ break;
+
+ case DIOCGPART:
+ ((struct partinfo *)data)->disklab = sc->sc_dkdev.dk_label;
+ ((struct partinfo *)data)->part =
+ &sc->sc_dkdev.dk_label->d_partitions[part];
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ return error;
}
int
diff -r 5217c143dd95 -r 7d16babcd834 sys/dev/flashvar.h
--- a/sys/dev/flashvar.h Tue Feb 23 15:38:30 2010 +0000
+++ b/sys/dev/flashvar.h Wed Feb 24 01:19:37 2010 +0000
@@ -1,4 +1,4 @@
-/* $Id: flashvar.h,v 1.1.2.1 2010/02/12 01:36:02 uebayasi Exp $ */
+/* $Id: flashvar.h,v 1.1.2.2 2010/02/24 01:19:37 uebayasi Exp $ */
/*-
* Copyright (c) 2010 Tsubai Masanari. All rights reserved.
@@ -29,6 +29,8 @@
#ifndef _DEV_FLASH_FLASHVAR_H_
#define _DEV_FLASH_FLASHVAR_H_
+#include <sys/disk.h>
+
struct flash_product {
u_char manuId;
u_char devId1, devId2, devId3;
@@ -38,6 +40,7 @@
struct flash_softc {
struct device sc_dev;
+ struct disk sc_dkdev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_baseioh;
bus_space_handle_t sc_ioh;
Home |
Main Index |
Thread Index |
Old Index