Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-07-2008, 08:35 AM
mickey
 
Posts: n/a
Default Re: HIMEM.SYS strikes back!

On Tue, Apr 01, 2008 at 06:00:38PM +0000, mickey wrote:
> re
> 80s are back and so is HIMEM.SYS now for the modern 32bit
> architecture known as i386 or "that intel crap."
>
> yes as you can have guessed already it gives your >4G
> memory another chance at life reincarnated as scsi disk.
>
> http://mickey.lucifier.net/himem.sys


massive improvelance:
- fake disklabel (so that it is newfs- or dd-ready);
- use less memory overhead (down to 4 pages);
- switch to 512 bytes sectors so that ffs works!
- tested on msdosfs and ffs now.

enjoy.
cu
--
paranoic mickey (my employers have changed but, the name has remained)

Index: arch/i386/conf/GENERIC
================================================== =================
RCS file: /mount/p4/cvs/openbsd/src/sys/arch/i386/conf/GENERIC,v
retrieving revision 1.609
diff -u -r1.609 GENERIC
--- arch/i386/conf/GENERIC 31 Mar 2008 04:17:22 -0000 1.609
+++ arch/i386/conf/GENERIC 1 Apr 2008 19:08:57 -0000
@@ -37,6 +37,8 @@
config bsd swap generic

mainbus0 at root
+himem0 at root # himem.sys
+scsibus* at himem?

cpu0 at mainbus?
bios0 at mainbus0
Index: arch/i386/conf/files.i386
================================================== =================
RCS file: /mount/p4/cvs/openbsd/src/sys/arch/i386/conf/files.i386,v
retrieving revision 1.176
diff -u -r1.176 files.i386
--- arch/i386/conf/files.i386 22 Mar 2008 19:43:09 -0000 1.176
+++ arch/i386/conf/files.i386 28 Mar 2008 14:34:44 -0000
@@ -441,6 +441,10 @@
attach esm at mainbus
file arch/i386/i386/esm.c esm needs-flag

+device himem: scsi
+attach himem at root
+file arch/i386/i386/himem.c himem needs-flag
+
#
# VESA
#
Index: arch/i386/i386/autoconf.c
================================================== =================
RCS file: /mount/p4/cvs/openbsd/src/sys/arch/i386/i386/autoconf.c,v
retrieving revision 1.79
diff -u -r1.79 autoconf.c
--- arch/i386/i386/autoconf.c 19 Mar 2008 05:47:44 -0000 1.79
+++ arch/i386/i386/autoconf.c 28 Mar 2008 15:48:29 -0000
@@ -71,6 +71,7 @@
#include <dev/cons.h>

#include "ioapic.h"
+#include "himem.h"

#if NIOAPIC > 0
#include <machine/i82093var.h>
@@ -117,6 +118,10 @@

if (config_rootfound("mainbus", NULL) == NULL)
panic("cpu_configure: mainbus not configured");
+
+#if NHIMEM > 0
+ config_rootfound("himem", NULL);
+#endif

#if NIOAPIC > 0
if (nioapics > 0)
Index: arch/i386/i386/himem.c
================================================== =================
RCS file: arch/i386/i386/himem.c
diff -N arch/i386/i386/himem.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ arch/i386/i386/himem.c 3 Apr 2008 20:04:23 -0000
@@ -0,0 +1,476 @@
+/* $OpenBSD$ */
+
+/*
+ * Copyright (c) 2008 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/kthread.h>
+#include <sys/queue.h>
+#include <sys/mutex.h>
+#include <sys/buf.h>
+#include <sys/disk.h>
+#include <sys/disklabel.h>
+
+#include <scsi/scsi_all.h>
+#include <scsi/scsi_disk.h>
+#include <scsi/scsiconf.h>
+#include <scsi/sdvar.h>
+
+#include <uvm/uvm.h>
+
+/* arbitrary numbers */
+#define HIMEM_MAXCMDS 256 /* each one is a page */
+
+/* derived from page table structure */
+#define HIMEM_OFFSET ((sizeof(struct hibuf) + 7) / 8)
+#define HIMEM_MAXSEGS (512 - HIMEM_OFFSET - 2)
+#define HIMEM_MAXPHYS (HIMEM_MAXSEGS * PAGE_SIZE)
+
+#define HIMEM_PDE (8)
+#define HIMEM_VA (HIMEM_PDE << 21)
+#define HIMEM_LOW (HIMEM_VA + (PAGE_SIZE * HIMEM_OFFSET))
+#define HIMEM_HIGH (HIMEM_VA + (PAGE_SIZE * 512))
+#define PDE_MASK ((512 * (PAGE_SIZE / DEV_BSIZE)) - 1)
+
+void himem_zefix(u_int64_t *, void *, void *, u_int); /* locore.s */
+
+struct hibuf {
+ TAILQ_ENTRY(hibuf) hb_list;
+ paddr_t hb_pa;
+ struct scsi_xfer *hb_xs;
+ void *hb_src, *hb_dst;
+ u_int hb_bno, hb_len;
+ int hb_flags;
+#define HIMEM_WAKE 0x0001
+};
+
+struct himem_softc {
+ struct device sc_dev;
+ struct scsi_link sc_link;
+
+ int sc_flags;
+#define HIMEM_RDONLY 0x0001
+#define HIMEM_DISKLABEL 0x0002
+ int sc_size; /* blocks */
+
+ struct proc *sc_kthread;
+ u_int64_t *sc_pdir;
+ paddr_t sc_paddr;
+ struct mutex sc_inmtx;
+ struct mutex sc_freemtx;
+ TAILQ_HEAD(hibuf_head, hibuf) sc_free, sc_in;
+};
+
+int himem_scsi_cmd(struct scsi_xfer *);
+int himem_scsi_ioctl(struct scsi_link *, u_long, caddr_t, int, struct proc *);
+void himeminphys(struct buf *bp);
+
+struct scsi_adapter himem_switch = {
+ himem_scsi_cmd, himeminphys, 0, 0, himem_scsi_ioctl
+};
+
+struct scsi_device himem_dev = {
+ NULL, NULL, NULL, NULL
+};
+
+int himem_match(struct device *, void *, void *);
+void himem_attach(struct device *, struct device *, void *);
+
+struct cfattach himem_ca = {
+ sizeof(struct himem_softc), himem_match, himem_attach
+};
+
+struct cfdriver himem_cd = {
+ NULL, "himem", DV_DULL
+};
+
+void himem(void *);
+void himem_create(void *);
+
+int
+himem_match(struct device *parent, void *match, void *aux)
+{
+ extern u_int64_t avail_end, avail_end2;
+ struct cfdata *cf = match;
+
+ if (cf->cf_unit)
+ return 0;
+
+ /* if no PAE or too little memory then screw it */
+ if (!(cpu_feature & CPUID_PAE) ||
+ (avail_end2 - avail_end) < 4 * HIMEM_MAXCMDS * PAGE_SIZE)
+ return 0;
+
+ return 1;
+}
+
+void
+himem_attach(struct device *parent, struct device *self, void *aux)
+{
+ extern u_int64_t avail_end2;
+ struct himem_softc *sc = (struct himem_softc *)self;
+ struct disklabel *lp;
+ struct hibuf *bp;
+ paddr_t pa;
+ vaddr_t va;
+ int i, pdsize;
+
+ TAILQ_INIT(&sc->sc_in);
+ TAILQ_INIT(&sc->sc_free);
+ mtx_init(&sc->sc_inmtx, IPL_SCHED);
+ mtx_init(&sc->sc_freemtx, IPL_BIO);
+
+ pdsize = 4 * PAGE_SIZE;
+ sc->sc_pdir = (u_int64_t *)uvm_km_alloc1(kernel_map, pdsize,
+ PAGE_SIZE, 1);
+ if (!sc->sc_pdir) {
+ printf(": cannot allocate page index\n");
+ return;
+ }
+
+#define vatopa(va) pmap_extract(pmap_kernel(), (vaddr_t)va, &pa)
+ /* we do know like for sure there ain't no like user space */
+ vatopa((vaddr_t)sc->sc_pdir + 0 * PAGE_SIZE); sc->sc_paddr = pa;
+ sc->sc_pdir[0] = pa | PG_V;
+ vatopa((vaddr_t)sc->sc_pdir + 1 * PAGE_SIZE);
+ sc->sc_pdir[1] = pa | PG_V;
+ vatopa((vaddr_t)sc->sc_pdir + 2 * PAGE_SIZE);
+ sc->sc_pdir[2] = pa | PG_V;
+ vatopa((vaddr_t)sc->sc_pdir + 3 * PAGE_SIZE);
+ sc->sc_pdir[3] = pa | PG_V;
+
+ /* 8M of kernel code is ment to be enough for everbody */
+ sc->sc_pdir[(KERNBASE >> 21) + 0] = 0x000000 |
+ PG_KW | PG_M | PG_U | PG_V | PG_PS;
+ sc->sc_pdir[(KERNBASE >> 21) + 1] = 0x200000 |
+ PG_KW | PG_M | PG_U | PG_V | PG_PS;
+ sc->sc_pdir[(KERNBASE >> 21) + 2] = 0x400000 |
+ PG_KW | PG_M | PG_U | PG_V | PG_PS;
+ sc->sc_pdir[(KERNBASE >> 21) + 3] = 0x600000 |
+ PG_KW | PG_M | PG_U | PG_V | PG_PS;
+
+ bp = (struct hibuf *)uvm_km_alloc1(kernel_map,
+ HIMEM_MAXCMDS * PAGE_SIZE, PAGE_SIZE, 1);
+ if (!bp) {
+ uvm_km_free(kmem_map, (vaddr_t)sc->sc_pdir, pdsize);
+ printf(": no memory for buffers\n");
+ return;
+ }
+
+ /* each buf is a page table and hibuf in one! */
+ for (i = HIMEM_MAXCMDS, va = (vaddr_t)bp; i--; va += PAGE_SIZE) {
+ bp = (struct hibuf *)va;
+ TAILQ_INSERT_TAIL(&sc->sc_free, bp, hb_list);
+ pmap_extract(pmap_kernel(), va, &bp->hb_pa);
+ }
+
+ sc->sc_size = (avail_end2 - 0x100000000ULL) / DEV_BSIZE;
+ printf(": size %uMB\n", sc->sc_size / 2048);
+
+ /* set a fake diskalbel */
+ lp = (void *)uvm_km_zalloc(kernel_map, round_page(sizeof(*lp)));
+ if (lp) {
+ lp->d_secsize = DEV_BSIZE;
+ lp->d_ntracks = 255;
+ lp->d_nsectors = 63;
+ lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
+ lp->d_ncylinders = sc->sc_size / lp->d_secpercyl;
+ lp->d_type = DTYPE_SCSI;
+ strncpy(lp->d_typename, "SCSI disk", sizeof(lp->d_typename));
+ strncpy(lp->d_packname, "HIMEM drive", sizeof(lp->d_packname));
+ DL_SETDSIZE(lp, sc->sc_size);
+ lp->d_rpm = 32768;
+ lp->d_interleave = 1;
+ lp->d_version = 1;
+ lp->d_flags = 0;
+ lp->d_bbsize = 8192;
+ lp->d_sbsize = 65536;
+ lp->d_magic = DISKMAGIC;
+ lp->d_magic2 = DISKMAGIC;
+
+ lp->d_npartitions = MAXPARTITIONS;
+ lp->d_partitions[0].p_fstype = FS_BSDFFS;
+ DL_SETPSIZE(&lp->d_partitions[0], sc->sc_size);
+ DL_SETPOFFSET(&lp->d_partitions[0], 0);
+ lp->d_partitions[0].p_fragblock =
+ DISKLABELV1_FFS_FRAGBLOCK(4096, 4);
+ DL_SETPSIZE(&lp->d_partitions[RAW_PART], sc->sc_size);
+ DL_SETPOFFSET(&lp->d_partitions[RAW_PART], 0);
+
+ lp->d_checksum = dkcksum(lp);
+
+ /* write out the label */
+ vatopa(lp);
+ sc->sc_pdir[HIMEM_PDE] = PG_KW | PG_U | PG_M | PG_V | PG_PS |
+ (pa & ~(0x200000 - 1));
+ sc->sc_pdir[HIMEM_PDE+1] = PG_KW | PG_U | PG_M | PG_V | PG_PS |
+ 0x100000000ULL;
+
+ himem_zefix(sc->sc_pdir,
+ (char *)HIMEM_VA + (pa & (0x200000 - 1)),
+ (char *)HIMEM_HIGH + LABELSECTOR * DEV_BSIZE, DEV_BSIZE);
+
+ sc->sc_pdir[HIMEM_PDE] = 0;
+ sc->sc_pdir[HIMEM_PDE+1] = 0;
+ uvm_km_free(kernel_map, (vaddr_t)lp, round_page(sizeof(*lp)));
+ }
+#undef vatopa
+
+ kthread_create_deferred(himem_create, sc);
+}
+
+void
+himem_create(void *v)
+{
+ struct himem_softc *sc = v;
+
+ kthread_create(himem, sc, &sc->sc_kthread, "himem.sys");
+}
+
+int
+himem_scsi_cmd(struct scsi_xfer *xs)
+{
+ struct scsi_link *link = xs->sc_link;
+ struct himem_softc *sc = link->adapter_softc;
+ struct scsi_read_cap_data rcd;
+ struct scsi_inquiry_data inq;
+ struct hibuf *bp;
+ u_int64_t *ptes;
+ paddr_t pa;
+ vaddr_t va, eva;
+ u_int bno, bcnt;
+ int s, res;
+
+ s = splbio();
+ if (link->target > 0 || !sc->sc_size || link->lun != 0) {
+ bzero(&xs->sense, sizeof(xs->sense));
+ xs->sense.error_code = SSD_ERRCODE_VALID | 0x70;
+ xs->sense.flags = SKEY_ILLEGAL_REQUEST;
+ xs->sense.add_sense_code = 0x20; /* illcmd, 0x24 illfield */
+ xs->error = XS_SENSE;
+ scsi_done(xs);
+ splx(s);
+ return (COMPLETE);
+ }
+
+ xs->error = XS_NOERROR;
+ switch (xs->cmd->opcode) {
+ default:
+ xs->sense.error_code = SSD_ERRCODE_VALID | 0x70;
+ xs->sense.flags = SKEY_ILLEGAL_REQUEST;
+ xs->sense.add_sense_code = 0x20; /* illcmd, 0x24 illfield */
+ xs->error = XS_SENSE;
+ scsi_done(xs);
+ splx(s);
+ return (COMPLETE);
+
+ case TEST_UNIT_READY:
+ case START_STOP:
+ case PREVENT_ALLOW:
+ splx(s);
+ return COMPLETE;
+
+ case INQUIRY:
+ bzero(&inq, sizeof(inq));
+ inq.device = T_DIRECT;
+ inq.dev_qual2 = 0;
+ inq.version = 2;
+ inq.response_format = 2;
+ inq.additional_length = 32;
+ strlcpy(inq.vendor, "McIkye ", sizeof(inq.vendor));
+ strlcpy(inq.product, "HIMEM drive ", sizeof(inq.product));
+ strlcpy(inq.revision, "1.1", sizeof(inq.revision));
+ bcopy(&inq, xs->data, MIN(sizeof(inq), xs->datalen));
+ scsi_done(xs);
+ splx(s);
+ return COMPLETE;
+
+ case READ_CAPACITY:
+ bzero(&rcd, sizeof(rcd));
+ _lto4b(sc->sc_size - 1, rcd.addr);
+ _lto4b(DEV_BSIZE, rcd.length);
+ bcopy(&rcd, xs->data, MIN(sizeof(rcd), xs->datalen));
+ scsi_done(xs);
+ splx(s);
+ return COMPLETE;
+
+ case SYNCHRONIZE_CACHE:
+ mtx_enter(&sc->sc_inmtx);
+ if (!TAILQ_EMPTY(&sc->sc_in)) {
+ bp = TAILQ_LAST(&sc->sc_in, hibuf_head);
+ bp->hb_flags |= HIMEM_WAKE;
+ msleep(bp, &sc->sc_inmtx, PRIBIO, "himem.sync", 0);
+ }
+ mtx_leave(&sc->sc_inmtx);
+ scsi_done(xs);
+ splx(s);
+ return COMPLETE;
+
+ case WRITE_COMMAND:
+ case WRITE_BIG:
+ if (sc->sc_flags & HIMEM_RDONLY) {
+ xs->sense.error_code = SSD_ERRCODE_VALID | 0x70;
+ xs->sense.flags = SKEY_WRITE_PROTECT;
+ xs->sense.add_sense_code = 0;
+ xs->error = XS_SENSE;
+ scsi_done(xs);
+ splx(s);
+ return COMPLETE;
+ }
+ case READ_COMMAND:
+ case READ_BIG:
+ if (xs->cmdlen == 6) {
+ struct scsi_rw *rw = (struct scsi_rw *)xs->cmd;
+ bno = _3btol(rw->addr) & (SRW_TOPADDR << 16 | 0xffff);
+ bcnt = rw->length ? rw->length : 0x100;
+ } else {
+ struct scsi_rw_big *rwb = (struct scsi_rw_big *)xs->cmd;
+ bno = _4btol(rwb->addr);
+ bcnt = _2btol(rwb->length);
+ }
+
+ if (bno >= sc->sc_size || bno + bcnt > sc->sc_size) {
+ xs->error = XS_DRIVER_STUFFUP;
+ scsi_done(xs);
+ splx(s);
+ return COMPLETE;
+ }
+
+ mtx_enter(&sc->sc_freemtx);
+ bp = TAILQ_FIRST(&sc->sc_free);
+ TAILQ_REMOVE(&sc->sc_free, bp, hb_list);
+ mtx_leave(&sc->sc_freemtx);
+ splx(s);
+
+ bp->hb_xs = xs;
+ res = (vaddr_t)xs->data & PAGE_MASK;
+ if (xs->cmd->opcode == READ_COMMAND ||
+ xs->cmd->opcode == READ_BIG) {
+ bp->hb_dst = (char *)HIMEM_LOW + res;
+ bp->hb_src = (char *)HIMEM_HIGH +
+ ((bno & PDE_MASK) * DEV_BSIZE);
+ } else {
+ bp->hb_src = (char *)HIMEM_LOW + res;
+ bp->hb_dst = (char *)HIMEM_HIGH +
+ ((bno & PDE_MASK) * DEV_BSIZE);
+ }
+
+ bp->hb_len = xs->datalen;
+ bp->hb_bno = bno;
+ bp->hb_flags = 0;
+
+ ptes = (u_int64_t *)bp + HIMEM_OFFSET;
+ for (va = (vaddr_t)xs->data - res,
+ eva = (vaddr_t)xs->data + xs->datalen + PAGE_SIZE - 1;
+ va < eva; va += PAGE_SIZE) {
+ pmap_extract(pmap_kernel(), va, &pa);
+ *ptes++ = pa | PG_KW | PG_U | PG_M | PG_V;
+ }
+
+ if (xs->flags & SCSI_POLL)
+ bp->hb_flags |= HIMEM_WAKE;
+
+ mtx_enter(&sc->sc_inmtx);
+ TAILQ_INSERT_TAIL(&sc->sc_in, bp, hb_list);
+ mtx_leave(&sc->sc_inmtx);
+ wakeup(&sc->sc_in);
+ if (xs->flags & SCSI_POLL) {
+ tsleep(bp, PRIBIO, "himem.poll", 0);
+ return COMPLETE;
+ } else
+ return SUCCESSFULLY_QUEUED;
+ }
+}
+
+int
+himem_scsi_ioctl(struct scsi_link *link, u_long cmd, caddr_t addr, int flag,
+ struct proc *p)
+{
+ /* struct himem_softc *sc = link->adapter_softc; */
+
+ /* TODO implement set-rdonly */
+ return ENOTTY;
+}
+
+void
+himeminphys(struct buf *bp)
+{
+ if (bp->b_bcount > HIMEM_MAXPHYS)
+ bp->b_bcount = HIMEM_MAXPHYS;
+ minphys(bp);
+}
+
+void
+himem(void *v)
+{
+ struct scsibus_attach_args saa;
+ struct himem_softc *sc = v;
+ struct scsi_xfer *xs;
+ struct hibuf *bp;
+ int s, wake;
+
+ sc->sc_link.device = &himem_dev;
+ sc->sc_link.device_softc = sc;
+ sc->sc_link.adapter = &himem_switch;
+ sc->sc_link.adapter_softc = sc;
+ sc->sc_link.adapter_target = 1;
+ sc->sc_link.adapter_buswidth = 1;
+ sc->sc_link.openings = HIMEM_MAXCMDS;
+ bzero(&saa, sizeof(saa));
+ saa.saa_sc_link = &sc->sc_link;
+ config_found(&sc->sc_dev, &saa, scsiprint);
+
+ KERNEL_PROC_UNLOCK(curproc);
+
+ for (; {
+ mtx_enter(&sc->sc_inmtx);
+ while (TAILQ_EMPTY(&sc->sc_in))
+ msleep(&sc->sc_in, &sc->sc_inmtx, PRIBIO, "himem.sys", 0);
+
+ bp = TAILQ_FIRST(&sc->sc_in);
+ TAILQ_REMOVE(&sc->sc_in, bp, hb_list);
+ mtx_leave(&sc->sc_inmtx);
+
+ sc->sc_pdir[HIMEM_PDE] = bp->hb_pa | PG_KW | PG_U | PG_M | PG_V;
+ sc->sc_pdir[HIMEM_PDE+1] = PG_KW | PG_U | PG_M | PG_V | PG_PS |
+ (0x100000000ULL + (bp->hb_bno & ~PDE_MASK) * DEV_BSIZE);
+ sc->sc_pdir[HIMEM_PDE+2] = sc->sc_pdir[HIMEM_PDE+1] + 0x200000;
+
+ himem_zefix(sc->sc_pdir, bp->hb_src, bp->hb_dst, bp->hb_len);
+
+ sc->sc_pdir[HIMEM_PDE] = 0;
+ sc->sc_pdir[HIMEM_PDE+1] = 0;
+
+ xs = bp->hb_xs;
+ xs->resid -= bp->hb_len;
+ xs->flags |= ITSDONE;
+ wake = bp->hb_flags & HIMEM_WAKE;
+ mtx_enter(&sc->sc_freemtx);
+ TAILQ_INSERT_HEAD(&sc->sc_free, bp, hb_list);
+ mtx_leave(&sc->sc_freemtx);
+
+ KERNEL_PROC_LOCK(curproc);
+ s = splbio();
+ scsi_done(xs);
+ splx(s);
+ if (wake)
+ wakeup(bp);
+ KERNEL_PROC_UNLOCK(curproc);
+ }
+}
Index: arch/i386/i386/locore.s
================================================== =================
RCS file: /mount/p4/cvs/openbsd/src/sys/arch/i386/i386/locore.s,v
retrieving revision 1.122
diff -u -r1.122 locore.s
--- arch/i386/i386/locore.s 22 Mar 2008 16:25:08 -0000 1.122
+++ arch/i386/i386/locore.s 1 Apr 2008 18:54:03 -0000
@@ -44,6 +44,7 @@
#include "pctr.h"
#include "ksyms.h"
#include "acpi.h"
+#include "himem.h"

#include <sys/errno.h>
#include <sys/syscall.h>
@@ -1847,6 +1848,70 @@

popl %ebx
popl %edi
+ ret
+#endif
+
+#if NHIMEM > 0
+/*
+ * void
+ * himem_zefix(vaddr_t pdir, void *src, void *dst, int len)
+ *
+ * switch to PAE mode and copy some pages. come back before xmas.
+ * hafta be some serious splipi() or bad shitz would happenz.
+ *
+ */
+ENTRY(himem_zefix)
+#ifdef DDB
+ pushl %ebp
+ movl %esp,%ebp
+#endif
+ pushf
+ cli
+ pushl %esi
+ pushl %edi
+ movl 8(%ebp), %edi
+ movl %cr3, %esi
+ addl $KERNBASE, %esi
+ addl $4*8, %edi /* save current PD content */
+ movl $8, %ecx
+ cld
+ rep
+ movsl
+ movl 8(%ebp), %esi /* install our PDI */
+ movl %cr3, %edi
+ addl $KERNBASE, %edi
+ movl $8, %ecx
+ cld
+ rep
+ movsl
+ movl 12(%ebp), %esi
+ movl 16(%ebp), %edi
+ movl 20(%ebp), %ecx
+ shrl $2, %ecx
+ movl %cr4, %eax
+ orl $(CR4_PAE|CR4_PSE), %eax
+ movl %eax, %cr4 /* also flushes the hell out of TLBs */
+ cld
+ rep
+ movsl
+ movl %cr4, %eax
+ andl $~(CR4_PAE|CR4_PSE), %eax
+ movl %eax, %cr4 /* again flushes the hell out of TLBs */
+ xorl %eax, %eax
+ movl 8(%ebp), %esi /* restore original PD contents */
+ movl %cr3, %edi
+ addl $KERNBASE, %edi
+ addl $4*8, %esi
+ movl $8, %ecx
+ cld
+ rep
+ movsl
+ popl %edi
+ popl %esi
+ popf
+#ifdef DDB
+ leave
+#endif
ret
#endif

Index: arch/i386/i386/machdep.c
================================================== =================
RCS file: /mount/p4/cvs/openbsd/src/sys/arch/i386/i386/machdep.c,v
retrieving revision 1.420
diff -u -r1.420 machdep.c
--- arch/i386/i386/machdep.c 30 Mar 2008 14:09:20 -0000 1.420
+++ arch/i386/i386/machdep.c 1 Apr 2008 19:08:59 -0000
@@ -234,7 +234,7 @@
int i386_has_xcrypt;

bootarg_t *bootargp;
-paddr_t avail_end;
+u_int64_t avail_end, avail_end2;

struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL;
@@ -2970,7 +2970,7 @@
* account all the memory passed in the map from /boot
* calculate avail_end and count the physmem.
*/
- avail_end = 0;
+ avail_end = avail_end2 = 0;
physmem = 0;
#ifdef DEBUG
printf("memmap:");
@@ -2986,6 +2986,8 @@
#ifdef DEBUG
printf("-H");
#endif
+ avail_end2 = MAX(avail_end2,
+ trunc_page(im->addr + im->size));
continue;
}

Index: arch/i386/isa/isa_machdep.c
================================================== =================
RCS file: /mount/p4/cvs/openbsd/src/sys/arch/i386/isa/isa_machdep.c,v
retrieving revision 1.61
diff -u -r1.61 isa_machdep.c
--- arch/i386/isa/isa_machdep.c 7 Sep 2007 15:00:19 -0000 1.61
+++ arch/i386/isa/isa_machdep.c 28 Mar 2008 15:26:59 -0000
@@ -105,7 +105,7 @@

#include "isadma.h"

-extern paddr_t avail_end;
+extern u_int64_t avail_end;

#define IDTVEC(name) __CONCAT(X,name)
/* default interrupt vector table entries */
Index: arch/i386/pci/pci_addr_fixup.c
================================================== =================
RCS file: /mount/p4/cvs/openbsd/src/sys/arch/i386/pci/pci_addr_fixup.c,v
retrieving revision 1.21
diff -u -r1.21 pci_addr_fixup.c
--- arch/i386/pci/pci_addr_fixup.c 20 Feb 2007 21:15:01 -0000 1.21
+++ arch/i386/pci/pci_addr_fixup.c 28 Mar 2008 15:27:35 -0000
@@ -80,7 +80,7 @@
void
pci_addr_fixup(struct pcibios_softc *sc, pci_chipset_tag_t pc, int maxbus)
{
- extern paddr_t avail_end;
+ extern u_int64_t avail_end;
const char *verbose_header =
"[%s]-----------------------\n"
" device vendor product\n"
@@ -136,8 +136,9 @@
start = PCIADDR_ISAMEM_RESERVE;
sc->mem_alloc_start = (start + 0x100000 + 1) & ~(0x100000 - 1);
sc->port_alloc_start = PCIADDR_ISAPORT_RESERVE;
- PCIBIOS_PRINTV((" Physical memory end: 0x%08x\n PCI memory mapped I/O "
- "space start: 0x%08x\n", avail_end, sc->mem_alloc_start));
+ PCIBIOS_PRINTV((" Physical memory end: 0x%08llx\n"
+ " PCI memory mapped I/O space start: 0x%08x\n",
+ avail_end, sc->mem_alloc_start));

/*
* 4. do fixup

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:46 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942