Date: Sat, 19 Mar 2005 21:30:17 GMT From: Juli Mallett <jmallett@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 73540 for review Message-ID: <200503192130.j2JLUHEH045077@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=73540 Change 73540 by jmallett@jmallett_windward on 2005/03/19 21:29:55 Use GetFileInformation to figure out disk size. This panics in interesting ways now. Probably because of the pointer size difference with ARCS. Affected files ... .. //depot/projects/mips/sys/dev/arcs/arcs.c#8 edit .. //depot/projects/mips/sys/dev/arcs/arcs.h#8 edit .. //depot/projects/mips/sys/dev/arcs/arcs_disk.c#6 edit Differences ... ==== //depot/projects/mips/sys/dev/arcs/arcs.c#8 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/mips/sys/dev/arcs/arcs.c#7 $ + * $P4: //depot/projects/mips/sys/dev/arcs/arcs.c#8 $ */ #include <sys/param.h> @@ -59,6 +59,7 @@ #define ARCS_FV_Write_Offset (27 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_Seek_Offset (28 * sizeof (ARCS_Pointer_t)) #define ARCS_FV_GetEnvironmentVariable_Offset (30 * sizeof (ARCS_Pointer_t)) +#define ARCS_FV_GetFileInformation_Offset (32 * sizeof (ARCS_Pointer_t)) int arcs_init(void *arcs_base) @@ -289,3 +290,20 @@ next = (struct ARCS_Component *)(intptr_t)nextd; return (next); } + +int +ARCS_GetFileInformation(int fd, struct ARCS_FileInformation *info) +{ + uint32_t (*GetFileInformation)(uint32_t, ARCS_Pointer_t); + int error; + uint32_t errord; + uint32_t fdd; + ARCS_Pointer_t infod; + + GetFileInformation = (uint32_t (*)(uint32_t, ARCS_Pointer_t))(intptr_t)*(ARCS_Pointer_t *)&ARCS_FV[ARCS_FV_GetFileInformation_Offset]; + fdd = (uint32_t)fd; + infod = (ARCS_Pointer_t)(intptr_t)info; + errord = (*GetFileInformation)(fdd, infod); + error = (int)errord; + return (error); +} ==== //depot/projects/mips/sys/dev/arcs/arcs.h#8 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/mips/sys/dev/arcs/arcs.h#7 $ + * $P4: //depot/projects/mips/sys/dev/arcs/arcs.h#8 $ */ #ifndef _DEV_ARCS_ARCS_H_ @@ -144,6 +144,17 @@ ARCS_Pointer_t Identifier; } __packed; +/* Used to store file information. */ +struct ARCS_FileInformation { + uint64_t StartingAddress; + uint64_t EndingAddress; + uint64_t CurrentAddress; + uint32_t Type; + uint32_t FileNameLength; + uint8_t Attributes; + u_char Filename[32]; +} __packed; + /* * Firmware hooks. */ @@ -159,5 +170,6 @@ int ARCS_Seek(int, off_t *, int); struct ARCS_Component *ARCS_GetPeer(const struct ARCS_Component *); struct ARCS_Component *ARCS_GetChild(const struct ARCS_Component *); +int ARCS_GetFileInformation(int, struct ARCS_FileInformation *); #endif /* _DEV_ARCS_ARCS_H_ */ ==== //depot/projects/mips/sys/dev/arcs/arcs_disk.c#6 (text+ko) ==== @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/mips/sys/dev/arcs/arcs_disk.c#5 $ + * $P4: //depot/projects/mips/sys/dev/arcs/arcs_disk.c#6 $ */ #include <sys/param.h> @@ -119,7 +119,9 @@ static int arcs_disk_attach(device_t dev) { + struct ARCS_FileInformation info; struct arcs_disk_softc *sc; + uint64_t size; int error; sc = device_get_softc(dev); @@ -127,13 +129,20 @@ error = ARCS_Open("scsi(0)disk(0)", ARCS_O_RDWR, &sc->sc_fd); if (error != 0) return (error); + + error = ARCS_GetFileInformation(sc->sc_fd, &info); + if (error != 0) + return (error); + size = info.EndingAddress - info.StartingAddress; + size %= ARCS_DISK_BSIZE; + device_printf(dev, "ARCS Disk scsi(0)disk(0) opened\n"); sc->sc_disk = disk_alloc(); sc->sc_disk->d_strategy = arcs_disk_strategy; sc->sc_disk->d_name = "arcs_disk"; sc->sc_disk->d_sectorsize = ARCS_DISK_BSIZE; - sc->sc_disk->d_mediasize = (off_t)8/*XXX*/ * ARCS_DISK_BSIZE; + sc->sc_disk->d_mediasize = (off_t)size; sc->sc_disk->d_fwsectors = 0; sc->sc_disk->d_fwheads = 0; sc->sc_disk->d_drv1 = sc;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503192130.j2JLUHEH045077>