From owner-p4-projects@FreeBSD.ORG Sat Mar 19 21:30:18 2005 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5A39916A4D0; Sat, 19 Mar 2005 21:30:18 +0000 (GMT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 02B7A16A4CE for ; Sat, 19 Mar 2005 21:30:18 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id C78BE43D3F for ; Sat, 19 Mar 2005 21:30:17 +0000 (GMT) (envelope-from jmallett@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j2JLUHK3045080 for ; Sat, 19 Mar 2005 21:30:17 GMT (envelope-from jmallett@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j2JLUHEH045077 for perforce@freebsd.org; Sat, 19 Mar 2005 21:30:17 GMT (envelope-from jmallett@freebsd.org) Date: Sat, 19 Mar 2005 21:30:17 GMT Message-Id: <200503192130.j2JLUHEH045077@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmallett@freebsd.org using -f From: Juli Mallett To: Perforce Change Reviews Subject: PERFORCE change 73540 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Mar 2005 21:30:19 -0000 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 @@ -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 @@ -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;