aboutsummaryrefslogtreecommitdiffstats
path: root/drvlib.c
blob: f25db8af0768368767135fb57dc02e03fdd0e852 (plain) (blame)
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
#include <string.h>
#include "winhack.h"

#include "drvlib.h"
#include "dpmi.h"

#pragma code_seg( _INIT )

void drv_memcpy(void __far *dst, void __far *src, long size)
{
	unsigned char __far *psrc = src;
	unsigned char __far *pdst = dst;
	
	
	while(size-- > 0)
	{
		*pdst = *psrc;
		
		psrc++;
		pdst++;
	}
}


void __far *drv_malloc(DWORD dwSize, DWORD __far *lpLinear)
{
	WORD    wSel;
	DWORD   dwLin;

	wSel = DPMI_AllocLDTDesc(1);
	if(!wSel)
		return NULL;

	/* Map the framebuffer physical memory. */
	dwLin = DPMI_AllocMemBlk(dwSize);
    
	if(dwLin)
	{
		DPMI_SetSegBase(wSel, dwLin);
		DPMI_SetSegLimit(wSel, dwSize - 1);
    
    *lpLinear = dwLin;
    
		return wSel :> 0;
	}

	return NULL;
}