From owner-p4-projects@FreeBSD.ORG Sat Oct 7 16:52:26 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id DD10716A494; Sat, 7 Oct 2006 16:52:25 +0000 (UTC) X-Original-To: perforce@freebsd.org 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 AE52A16A40F for ; Sat, 7 Oct 2006 16:52:25 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5546A43D49 for ; Sat, 7 Oct 2006 16:52:25 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k97GqPm7021107 for ; Sat, 7 Oct 2006 16:52:25 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k97GqPhV021099 for perforce@freebsd.org; Sat, 7 Oct 2006 16:52:25 GMT (envelope-from imp@freebsd.org) Date: Sat, 7 Oct 2006 16:52:25 GMT Message-Id: <200610071652.k97GqPhV021099@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 107427 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Oct 2006 16:52:26 -0000 http://perforce.freebsd.org/chv.cgi?CH=107427 Change 107427 by imp@imp_lighthouse on 2006/10/07 16:51:55 Add stubs for disk goo. Need to fill them in. Affected files ... .. //depot/projects/arm/src/sys/dev/flash/at45d.c#6 edit Differences ... ==== //depot/projects/arm/src/sys/dev/flash/at45d.c#6 (text+ko) ==== @@ -27,15 +27,18 @@ #include #include +#include #include #include #include #include +#include #include #include #include #include #include +#include #include #include "spibus_if.h" @@ -45,7 +48,9 @@ struct intr_config_hook config_intrhook; device_t dev; struct mtx sc_mtx; - int dummy; + struct disk *disk; + struct proc *p; + struct bio_queue_head bio_queue; }; #define AT45D_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) @@ -59,6 +64,12 @@ static void at45d_delayed_attach(void *xsc); +/* disk routines */ +static int at45d_open(struct disk *dp); +static int at45d_close(struct disk *dp); +static void at45d_strategy(struct bio *bp); +static void at45d_task(void *arg); + #define CONTINUOUS_ARRAY_READ 0xE8 #define CONTINUOUS_ARRAY_READ_HF 0x0B #define CONTINUOUS_ARRAY_READ_LF 0x03 @@ -343,9 +354,67 @@ printf("Reply is %#x %#x %#x %#x\n", buf[0], buf[1], buf[2], buf[3]); at45d_wait_for_device_ready(sc->dev); printf("Status is %#x\b", at45d_get_status(sc->dev)); + + sc->disk = disk_alloc(); + sc->disk->d_open = at45d_open; + sc->disk->d_close = at45d_close; + sc->disk->d_strategy = at45d_strategy; + sc->disk->d_name = "flash/spi"; + sc->disk->d_drv1 = sc; + sc->disk->d_maxsize = DFLTPHYS; + sc->disk->d_sectorsize = 1056; // XXX + sc->disk->d_mediasize = 8192 * 1056; // XXX + sc->disk->d_unit = device_get_unit(sc->dev); + disk_create(sc->disk, DISK_VERSION); + bioq_init(&sc->bio_queue); + kthread_create(&at45d_task, sc, &sc->p, 0, 0, "task: at45d flash"); + config_intrhook_disestablish(&sc->config_intrhook); } +static int +at45d_open(struct disk *dp) +{ + return 0; +} + +static int +at45d_close(struct disk *dp) +{ + return 0; +} + +static void +at45d_strategy(struct bio *bp) +{ + struct at45d_softc *sc; + + sc = (struct at45d_softc *)bp->bio_disk->d_drv1; + AT45D_LOCK(sc); + bioq_disksort(&sc->bio_queue, bp); + wakeup(sc); + AT45D_UNLOCK(sc); +} + +static void +at45d_task(void *arg) +{ + struct at45d_softc *sc = (struct at45d_softc*)arg; + struct bio *bp; + + for (;;) { + AT45D_LOCK(sc); + do { + bp = bioq_first(&sc->bio_queue); + if (bp == NULL) + msleep(sc, &sc->sc_mtx, PRIBIO, "jobqueue", 0); + } while (bp == NULL); + bioq_remove(&sc->bio_queue, bp); + AT45D_UNLOCK(sc); + } +} + + static devclass_t at45d_devclass; static device_method_t at45d_methods[] = {