Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 May 1998 22:09:08 -0500 (EST)
From:      "John S. Dyson" <toor@dyson.iquest.net>
To:        nirva@ishiboo.com (Danny Dulai)
Cc:        doconnor@gsoft.com.au, freebsd-multimedia@FreeBSD.ORG, freebsd-current@FreeBSD.ORG
Subject:   Re: Fastvid..
Message-ID:  <199805300309.WAA05164@dyson.iquest.net>
In-Reply-To: <19980527232341.65268@bleep.ishiboo.com> from Danny Dulai at "May 27, 98 11:23:41 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> Quoting Daniel O'Connor (doconnor@gsoft.com.au):
> > 
> > The speedup factor is 1.89, mmm :)
> 
> 
> The vm_map.h problems are solved by #including <sys/lock.h>, but the
> MOD_SYSCALL on line 103 and the problem at line 234 I do not understand.
> 
> Does anyone have copy of this module for -current?
> 
This is a copy of the original code that I submitted to someone who
cleaned it up (I am sorry that I forgot who actually took ownership.)

This code works on my display adaptor, and compiles under -current.

#include <sys/param.h>
#include <sys/systm.h>
#include <sys/exec.h>
#include <sys/sysent.h>
#include <sys/lkm.h>
#include <sys/lock.h>
#include <sys/proc.h>
#include <vm/vm.h>
#include <vm/vm_prot.h>
#include <vm/vm_page.h>
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
#include <vm/pmap.h>

#define I586_CPU			/* XXX for i586_ctr_freq */
#include <machine/clock.h>

static int load(struct lkm_table *lkmtp, int cmd);
static int mycall(struct proc *p, void *uap, int *retval);
extern int newsyscall_mod(struct lkm_table *lkmtp, int cmd, int ver);
static int unload(struct lkm_table *lkmtp, int cmd);
vm_offset_t contigaddr;
struct proc *curproc;

static struct sysent newent = {
	0,	mycall			/* # of args, function pointer*/
};

MOD_SYSCALL(newsyscall_mod, -1, &newent);

static struct {
	int	address;
	char *name;
} ranges[] = {
	{0x250, "MTRRfix64K_00000"},
	{0x258, "MTRRfix16K_80000"},
	{0x259, "MTRRfix16K_A0000"},
	{0x268, "MTRRfix4K_C0000"},
	{0x269, "MTRRfix4K_C8000"},
	{0x26a, "MTRRfix4K_D0000"},
	{0x26b, "MTRRfix4K_D8000"},
	{0x26c, "MTRRfix4K_E0000"},
	{0x26d, "MTRRfix4K_E8000"},
	{0x26e, "MTRRfix4K_F0000"},
	{0x26f, "MTRRfix4K_F8000"},
	{0x0, NULL}
};
	

static int load(struct lkm_table *lkmtp, int cmd)
{
	int i;
	long long base;
	long long mask;
	vm_offset_t kernaddr;
	struct proc *otherp;
	int tbase, tmask, type;
	unsigned long long newval;
	pmap_t pmap;
	base = rdmsr(0x2ff);
	tbase = base & 0xfff;
	printf("default: type: 0x%x\n", tbase);

	wrmsr(0x259, 0x0101010101010101ULL);
/*
 * Add in an Memory type register entry here, after
 * reviewing the output of your X server.
 * My video ram is at phys addr 0xfe000000, size 8MB
 */
#define VIDPHYSADDR (0xfe000000)
#define VIDPHYSSIZE (0x800000)
#define MSRINDEX 5

	base = VIDPHYSADDR | 0x1;
	mask = (long long) (0xfffffffffLL - ((long) VIDPHYSSIZE - 1)) | (long long) 0x800;
	wrmsr(0x200 + MSRINDEX * 2, base);
	wrmsr(0x201 + MSRINDEX * 2, mask);

	for(i=0;i<8;i++) {
		int basehi, baselo;
		int maskhi, masklo;
		base = rdmsr(0x200 + i * 2);
		basehi = (unsigned long long) base >> 32;
		baselo = (unsigned long long) base & 0xffffffffL;
		type = base & 0xff;
		base >>= 12;
		tbase = base;
		mask = rdmsr(0x201 + i * 2);
		if ((mask & 0x800) == 0)
			continue;
		maskhi = (unsigned long long) mask >> 32;
		masklo = (unsigned long long) mask & 0xffffffffL;
		mask >>= 12;
		tmask = mask;
		printf("%d: type: %d, addr: 0x%x000, mask: 0x%x000\n     basehi: 0x%8.8x, baselo: 0x%8.8x\n     maskhi: 0x%8.8x, masklo: 0x%8.8x\n",
			i, type, tbase, tmask, basehi, baselo, maskhi, masklo);
	}


	for(i=0;ranges[i].address;i++) {
		int maskhi, masklo;
		mask = rdmsr(ranges[i].address);
		maskhi = (unsigned long long) mask >> 32;
		masklo = (unsigned long long) mask & 0xffffffffL;
		printf("%s: 0x%8.8x 0x%8.8x\n",
			ranges[i].name, maskhi, masklo);
	}
		
	tbase = rdmsr(0x1e0);
	printf("BKUPTMPDR6: %x\n", tbase);
	tbase = rdmsr(0x2a);
	printf("BKUPTMPDR6: %x\n", tbase);

	pmap = &curproc->p_vmspace->vm_pmap;

	for(i=0;i<1024;i++) {
		unsigned entry;

		entry = (unsigned) curproc->p_vmspace->vm_pmap.pm_pdir[i];
		if (entry & PG_PS) {
			printf("4MB page: 0x%x(%x)\n", entry, i << 22);
		}
	}

	otherp = pfind(153);
	if (otherp) {
	for(i=0;i<1024;i++) {
		unsigned entry;

		entry = (unsigned) otherp->p_vmspace->vm_pmap.pm_pdir[i];
		if (entry & PG_PS) {
			printf("4MB page: 0x%x(%x)\n", entry, i << 22);
		}
	}
	}

		

	return 0;
}

static int mycall(struct proc *p, void *uap, int *retval)
{
	return ENODEV;
}

int newsyscall_mod(struct lkm_table *lkmtp, int cmd, int ver)
{
#if 0
	DISPATCH(lkmtp, cmd, ver, load, unload, lkm_nullcmd)
#endif
	MOD_DISPATCH(newsyscall_mod,
		lkmtp, cmd, ver, load, unload, lkm_nullcmd)
#if 0
	MOD_DISPATCH(newsyscall_mod, lkmtp, cmd, ver,
	    newsyscall_load, lkm_nullcmd, lkm_nullcmd)
#endif
}

static int unload(struct lkm_table *lkmtp, int cmd)
{
    return 0;
}

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805300309.WAA05164>