add support devctl properties

This commit is contained in:
jnemeth 2007-03-03 02:44:44 +00:00
parent d4fbe368ec
commit 7cab5bde24
1 changed files with 48 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sd.c,v 1.259 2007/02/21 23:00:01 thorpej Exp $ */
/* $NetBSD: sd.c,v 1.260 2007/03/03 02:44:44 jnemeth Exp $ */
/*-
* Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@ -54,7 +54,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.259 2007/02/21 23:00:01 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.260 2007/03/03 02:44:44 jnemeth Exp $");
#include "opt_scsi.h"
#include "rnd.h"
@ -90,6 +90,8 @@ __KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.259 2007/02/21 23:00:01 thorpej Exp $");
#include <dev/scsipi/scsipi_base.h>
#include <dev/scsipi/sdvar.h>
#include <prop/proplib.h>
#define SDUNIT(dev) DISKUNIT(dev)
#define SDPART(dev) DISKPART(dev)
#define SDMINOR(unit, part) DISKMINOR(unit, part)
@ -131,6 +133,7 @@ static int sdmatch(struct device *, struct cfdata *, void *);
static void sdattach(struct device *, struct device *, void *);
static int sdactivate(struct device *, enum devact);
static int sddetach(struct device *, int);
static void sd_set_properties(struct sd_softc *);
CFATTACH_DECL(sd, sizeof(struct sd_softc), sdmatch, sdattach, sddetach,
sdactivate);
@ -327,6 +330,8 @@ sdattach(struct device *parent, struct device *self, void *aux)
/* Discover wedges on this disk. */
dkwedge_discover(&sd->sc_dk);
sd_set_properties(sd);
}
static int
@ -2230,3 +2235,44 @@ sd_setcache(struct sd_softc *sd, int bits)
sizeof(struct scsi_mode_page_header) +
pages->caching_params.pg_length, 0, big));
}
static void
sd_set_properties(struct sd_softc *sd)
{
prop_dictionary_t disk_info, odisk_info, geom;
disk_info = prop_dictionary_create();
geom = prop_dictionary_create();
prop_dictionary_set_uint64(geom, "sectors-per-unit",
sd->params.disksize);
prop_dictionary_set_uint32(geom, "sector-size",
sd->params.blksize);
prop_dictionary_set_uint16(geom, "sectors-per-track",
sd->params.sectors);
prop_dictionary_set_uint16(geom, "tracks-per-cylinder",
sd->params.heads);
prop_dictionary_set_uint64(geom, "cylinders-per-unit",
sd->params.cyls);
prop_dictionary_set(disk_info, "geometry", geom);
prop_object_release(geom);
prop_dictionary_set(device_properties(&sd->sc_dev),
"disk-info", disk_info);
/*
* Don't release disk_info here; we keep a reference to it.
* disk_detach() will release it when we go away.
*/
odisk_info = sd->sc_dk.dk_info;
sd->sc_dk.dk_info = disk_info;
if (odisk_info)
prop_object_release(odisk_info);
}