summaryrefslogtreecommitdiff
path: root/Source/Kernel/TaskManager/V86/V86.ns.h
blob: cdeef25dbbc1e78e4cd4f633b813754c26bd7f6b (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
#ifndef DEF_V86_NS_H
#define DEF_V86_NS_H

#include <TaskManager/V86/V86Thread.class.h>

//For tweaking with far/linear pointers
typedef u32int FARPTR;
#define MK_FP(seg, off) ((FARPTR)(((u32int)(seg) << 16) | (u16int) (off)))
#define FP_SEG(fp) (((FARPTR)fp) >> 16)
#define FP_OFF(fp) (((FARPTR)fp) & 0xFFFF)
#define LIN_SEG(ptr) (((size_t) ptr >> 4) & 0xFFFF)
#define LIN_OFF(ptr) (((size_t) ptr) & 0xF)
#define FP_TO_LINEAR(seg, off) ((void*)((((u16int)(seg)) << 4) + ((u16int)(off))))
inline FARPTR LINEAR_TO_FP(void* ptr) {
	u32int seg, off;
	off = LIN_OFF(ptr);
	seg = LIN_SEG(ptr);
	return MK_FP(seg, off);
}

// (in segments)
#define V86_ALLOC_START 0x1000
#define V86_ALLOC_END 0x9000

namespace V86 {
	void run(v86_function_t& entry, registers_t &regs, u32int data);

	u16int allocSeg(u16int size, Process* p = 0);
	void* alloc(u16int size, Process* p = 0);
}

#endif