~kris/9p

9hist

ref: b1beaa16e1e4f6ab50aaf756d291286c407d10e6 9hist/pc/vga3dfx.c -rw-r--r-- 1.3 KiB
b1beaa16 — David du Colombier Plan 9 from Bell Labs 2000-09-04 26 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
#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 <cursor.h>
#include "screen.h"

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

	oaperture = scr->aperture;
	oapsize = scr->apsize;
	wasupamem = scr->isupamem;

	aperture = 0;
	if(p = pcimatch(nil, 0x121A, 0)){
		switch(p->did){
		case 0x0005:		/* Voodoo 3 3000 */
			aperture = p->mem[1].bar & ~0x0F;
			*size = p->mem[1].size;
			break;
		default:
			break;
		}
	}

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

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

	return aperture;
}

VGAdev vga3dfxdev = {
	"3dfx",

	nil,				/* enable */
	nil,				/* disable */
	nil,				/* page */
	tdfxlinear,			/* linear */
	nil,				/* drawinit */
	nil,				/* fill */
};

VGAcur vga3dfxcur = {
	"3dfxhwgc",

	nil,				/* enable */
	nil,				/* disable */
	nil,				/* load */
	nil,				/* move */
};