2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
7 * ----------------------------------------------------------------------------
16 #include <sys/param.h>
17 #include <sys/systm.h>
20 #include <sys/kernel.h>
21 #include <sys/linker.h>
23 #include <sys/malloc.h>
24 #include <sys/mutex.h>
25 #include <sys/queue.h>
26 #include <sys/sysctl.h>
29 #include <vm/vm_kern.h>
30 #include <vm/vm_page.h>
31 #include <vm/vm_map.h>
32 #include <vm/vm_extern.h>
33 #include <vm/vm_object.h>
34 #include <vm/vm_pager.h>
35 #include <machine/md_var.h>
36 #include <geom/geom_disk.h>
38 #ifndef SKI_ROOT_FILESYSTEM
39 #define SKI_ROOT_FILESYSTEM "ia64-root.fs"
46 #define SSC_GET_COMPLETION 54
47 #define SSC_WAIT_COMPLETION 55
60 ssc(u_int64_t in0, u_int64_t in1, u_int64_t in2, u_int64_t in3, int which)
62 register u_int64_t ret0 __asm("r8");
64 __asm __volatile("mov r15=%1\n\t"
67 : "r"(which), "r"(in0), "r"(in1), "r"(in2), "r"(in3));
72 #define SSC_NSECT 409600
75 MALLOC_DEFINE(M_SSC, "ssc_disk", "Simulator Disk");
77 static int sscrootready;
79 static d_strategy_t sscstrategy;
81 static LIST_HEAD(, ssc_s) ssc_softc_list = LIST_HEAD_INITIALIZER(&ssc_softc_list);
85 LIST_ENTRY(ssc_s) list;
86 struct bio_queue_head bio_queue;
96 sscstrategy(struct bio *bp)
101 struct disk_stat stat;
104 sc = bp->bio_disk->d_drv1;
108 bioq_disksort(&sc->bio_queue, bp);
118 bp = bioq_takefirst(&sc->bio_queue);
123 va = (u_long) bp->bio_data;
124 len = bp->bio_bcount;
125 off = bp->bio_pblkno << DEV_BSHIFT;
128 if ((va & PAGE_MASK) + len > PAGE_SIZE)
129 t = PAGE_SIZE - (va & PAGE_MASK);
133 req.addr = ia64_tpa(va);
134 ssc(sc->fd, 1, ia64_tpa((long) &req), off,
135 (bp->bio_cmd == BIO_READ) ? SSC_READ : SSC_WRITE);
137 ssc(ia64_tpa((long)&stat), 0, 0, 0,
138 SSC_WAIT_COMPLETION);
152 static struct ssc_s *
158 fd = ssc(ia64_tpa((u_int64_t) SKI_ROOT_FILESYSTEM),
165 /* Make sure this unit isn't already in action */
166 LIST_FOREACH(sc, &ssc_softc_list, list) {
167 if (sc->unit == unit)
170 MALLOC(sc, struct ssc_s *,sizeof(*sc), M_SSC, M_WAITOK | M_ZERO);
171 LIST_INSERT_HEAD(&ssc_softc_list, sc, list);
173 bioq_init(&sc->bio_queue);
175 sc->disk = disk_alloc();
176 sc->disk->d_drv1 = sc;
177 sc->disk->d_fwheads = 0;
178 sc->disk->d_fwsectors = 0;
179 sc->disk->d_maxsize = DFLTPHYS;
180 sc->disk->d_mediasize = (off_t)SSC_NSECT * DEV_BSIZE;
181 sc->disk->d_name = "sscdisk";
182 sc->disk->d_sectorsize = DEV_BSIZE;
183 sc->disk->d_strategy = sscstrategy;
184 sc->disk->d_unit = sc->unit;
185 sc->disk->d_flags = DISKFLAG_NEEDSGIANT;
186 disk_create(sc->disk, DISK_VERSION);
194 ssc_drvinit(void *unused)
199 SYSINIT(sscdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE, ssc_drvinit,NULL);
202 ssc_takeroot(void *junk)
205 rootdevnames[0] = "ufs:/dev/sscdisk0";
208 SYSINIT(ssc_root, SI_SUB_MOUNT_ROOT, SI_ORDER_FIRST, ssc_takeroot, NULL);