~kris/9p

9hist

ref: 17dd2cf113bef1c53c47f29940e331ed6980b631 9hist/pc/vgamga2164w.c -rw-r--r-- 1.4 KiB
17dd2cf1 — David du Colombier Plan 9 from Bell Labs 1998-03-25 28 years ago
                                                                                
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
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
#include "../port/error.h"

#define	Image	IMAGE
#include <draw.h>
#include <memdraw.h>
#include "screen.h"

static void
mga2164wenable(VGAscr*)
{
	Pcidev *p;
	Physseg *s;
/*
	ulong mmio;
	uchar *rp;
	int i;
*/

	if((p = pcimatch(nil, 0x102B, 0x051B)) == nil)
		return;

	for(s = physseg; s->name; s++)
		if(strcmp("pcivctl", s->name) == 0)
			s->pa = p->mem[1].bar & ~0x0F;

/*
	mmio = p->mem[1].bar & ~0x0F;
	mmio = upamalloc(mmio, 16*1024, 0);
	if(mmio == 0){
		print("mmio == 0\n");
		return;
	}

	rp = (uchar*)(mmio+0x3C00);
	for(i = 0; i < 16; i++){
		print("%2.2uX ", *rp);
		rp++;
	}
	print("\n");
*/
}

static ulong
mga2164wlinear(VGAscr* scr, int* size, int* align)
{
	ulong aperture, oaperture;
	int oapsize, wasupamem;
	Pcidev *p;

	oaperture = scr->aperture;
	oapsize = scr->apsize;
	wasupamem = scr->isupamem;
	if(wasupamem)
		upafree(oaperture, oapsize);
	scr->isupamem = 0;

	if(p = pcimatch(nil, 0x102B, 0x051B)){
		aperture = p->mem[0].bar & ~0x0F;
		*size = p->mem[0].size;
	}
	else
		aperture = 0;

	aperture = upamalloc(aperture, *size, *align);
	if(aperture == 0){
		if(wasupamem && upamalloc(oaperture, oapsize, 0))
			scr->isupamem = 1;
	}
	else
		scr->isupamem = 1;

	return aperture;
}

VGAdev vgamga2164wdev = {
	"mga2164w",

	mga2164wenable,			/* enable */
	0,				/* disable */
	0,				/* page */
	mga2164wlinear,			/* linear */
};