Lines Matching +full:dp +full:- +full:bridge
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
67 static int mambodisk_open(struct disk *dp);
68 static int mambodisk_close(struct disk *dp);
72 #define MBODISK_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
73 #define MBODISK_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
75 mtx_init(&_sc->sc_mtx, device_get_nameunit(_sc->dev), \
77 #define MBODISK_LOCK_DESTROY(_sc) mtx_destroy(&_sc->sc_mtx);
78 #define MBODISK_ASSERT_LOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_OWNED);
79 #define MBODISK_ASSERT_UNLOCKED(_sc) mtx_assert(&_sc->sc_mtx, MA_NOTOWNED);
106 sc->dev = dev; in mambodisk_attach()
109 d = sc->disk = disk_alloc(); in mambodisk_attach()
110 d->d_open = mambodisk_open; in mambodisk_attach()
111 d->d_close = mambodisk_close; in mambodisk_attach()
112 d->d_strategy = mambodisk_strategy; in mambodisk_attach()
113 d->d_name = "mambodisk"; in mambodisk_attach()
114 d->d_drv1 = sc; in mambodisk_attach()
115 d->d_maxsize = maxphys; /* Maybe ask bridge? */ in mambodisk_attach()
117 d->d_sectorsize = 512; in mambodisk_attach()
118 sc->maxblocks = mambocall(MAMBO_DISK_INFO,MAMBO_INFO_BLKSZ,d->d_unit) in mambodisk_attach()
121 d->d_unit = device_get_unit(dev); in mambodisk_attach()
122 d->d_mediasize = mambocall(MAMBO_DISK_INFO,MAMBO_INFO_DEVSZ,d->d_unit) in mambodisk_attach()
125 mb = d->d_mediasize >> 20; /* 1MiB == 1 << 20 */ in mambodisk_attach()
132 d->d_sectorsize); in mambodisk_attach()
134 bioq_init(&sc->bio_queue); in mambodisk_attach()
136 sc->running = 1; in mambodisk_attach()
137 kproc_create(&mambodisk_task, sc, &sc->p, 0, 0, "task: mambo hd"); in mambodisk_attach()
149 sc->running = 0; in mambodisk_detach()
153 /* wait for thread to finish. XXX probably want timeout. -sorbo */ in mambodisk_detach()
155 while (sc->running != -1) in mambodisk_detach()
156 msleep(sc, &sc->sc_mtx, PRIBIO, "detach", 0); in mambodisk_detach()
160 disk_destroy(sc->disk); in mambodisk_detach()
169 mambodisk_open(struct disk *dp) in mambodisk_open() argument
175 mambodisk_close(struct disk *dp) in mambodisk_close() argument
185 sc = (struct mambodisk_softc *)bp->bio_disk->d_drv1; in mambodisk_strategy()
187 bioq_disksort(&sc->bio_queue, bp); in mambodisk_strategy()
203 dev = sc->dev; in mambodisk_task()
206 while (sc->running) { in mambodisk_task()
209 bp = bioq_first(&sc->bio_queue); in mambodisk_task()
211 msleep(sc, &sc->sc_mtx, PRIBIO, "jobqueue", 0); in mambodisk_task()
212 } while (bp == NULL && sc->running); in mambodisk_task()
214 bioq_remove(&sc->bio_queue, bp); in mambodisk_task()
216 if (!sc->running) in mambodisk_task()
218 sz = sc->disk->d_sectorsize; in mambodisk_task()
219 end = bp->bio_pblkno + (bp->bio_bcount / sz); in mambodisk_task()
220 for (block = bp->bio_pblkno; block < end;) { in mambodisk_task()
222 char *vaddr = bp->bio_data + in mambodisk_task()
223 (block - bp->bio_pblkno) * sz; in mambodisk_task()
225 numblocks = end - block; in mambodisk_task()
226 if (numblocks > sc->maxblocks) in mambodisk_task()
227 numblocks = sc->maxblocks; in mambodisk_task()
229 if (bp->bio_cmd == BIO_READ) { in mambodisk_task()
232 } else if (bp->bio_cmd == BIO_WRITE) { in mambodisk_task()
245 bp->bio_error = EIO; in mambodisk_task()
246 bp->bio_resid = (end - block) * sz; in mambodisk_task()
247 bp->bio_flags |= BIO_ERROR; in mambodisk_task()
254 sc->running = -1; in mambodisk_task()