diff --git a/sys/arch/sparc64/dev/fdc.c b/sys/arch/sparc64/dev/fdc.c index d342480ee263..cd79cce28c7e 100644 --- a/sys/arch/sparc64/dev/fdc.c +++ b/sys/arch/sparc64/dev/fdc.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdc.c,v 1.3 2007/03/02 07:17:19 jnemeth Exp $ */ +/* $NetBSD: fdc.c,v 1.4 2007/03/02 09:17:00 jnemeth Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -108,7 +108,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.3 2007/03/02 07:17:19 jnemeth Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.4 2007/03/02 09:17:00 jnemeth Exp $"); #include "opt_ddb.h" #include "opt_md.h" @@ -154,6 +154,8 @@ __KERNEL_RCSID(0, "$NetBSD: fdc.c,v 1.3 2007/03/02 07:17:19 jnemeth Exp $"); #include #endif +#include + #define FDUNIT(dev) (minor(dev) / 8) #define FDTYPE(dev) (minor(dev) % 8) @@ -397,6 +399,7 @@ static void establish_chip_type( bus_addr_t, bus_size_t, bus_space_handle_t); +static void fd_set_properties(struct fd_softc *); #ifdef MEMORY_DISK_HOOKS int fd_read_md_image(size_t *, caddr_t *); @@ -976,6 +979,8 @@ fdattach(struct device *parent, struct device *self, void *aux) */ mountroothook_establish(fd_mountroot_hook, &fd->sc_dv); + fd_set_properties(fd); + /* Make sure the drive motor gets turned off at shutdown time. */ fd->sc_sdhook = shutdownhook_establish(fd_motor_off, fd); } @@ -2551,3 +2556,59 @@ fd_read_md_image(size_t *sizep, caddr_t *addrp) return 0; } #endif /* MEMORY_DISK_HOOKS */ + +static void +fd_set_properties(struct fd_softc *fd) +{ + prop_dictionary_t disk_info, odisk_info, geom; + struct fd_type *fdt; + int secsize; + + fdt = fd->sc_deftype; + + disk_info = prop_dictionary_create(); + + geom = prop_dictionary_create(); + + prop_dictionary_set_uint64(geom, "sectors-per-unit", + fdt->size); + + switch (fdt->secsize) { + case 2: + secsize = 512; + break; + case 3: + secsize = 1024; + break; + default: + secsize = 0; + } + + prop_dictionary_set_uint32(geom, "sector-size", + secsize); + + prop_dictionary_set_uint16(geom, "sectors-per-track", + fdt->sectrac); + + prop_dictionary_set_uint16(geom, "tracks-per-cylinder", + fdt->heads); + + prop_dictionary_set_uint64(geom, "cylinders-per-unit", + fdt->cylinders); + + prop_dictionary_set(disk_info, "geometry", geom); + prop_object_release(geom); + + prop_dictionary_set(device_properties(&fd->sc_dv), + "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 = fd->sc_dk.dk_info; + fd->sc_dk.dk_info = disk_info; + if (odisk_info) + prop_object_release(odisk_info); +}