source: GPL/branches/uniaud32-next/include/stacktoflat.h@ 660

Last change on this file since 660 was 655, checked in by Paul Smedley, 5 years ago

Code cleanups from AlexT

File size: 3.1 KB
Line 
1/* $Id: stacktoflat.h,v 1.1.1.1 2003/07/02 13:56:58 eleph Exp $ */
2/*
3 * Header for SS / DS conversion routines
4 *
5 * (C) 2000-2002 InnoTek Systemberatung GmbH
6 * (C) 2000-2001 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
21 * USA.
22 *
23 */
24
25#ifndef __STACKTOFLAT_H__
26#define __STACKTOFLAT_H__
27
28#ifdef KEE
29extern ULONG stacksel; //16 bits stack selector
30#pragma aux stacksel "stacksel"
31
32extern ULONG stackbase; //32 bits stackbase
33#pragma aux stackbase "stackbase"
34
35#else
36
37extern ULONG TKSSBase;
38#pragma aux TKSSBase "_TKSSBase"
39
40extern ULONG GetTKSSBase();
41#pragma aux GetTKSSBase "GetTKSSBase" \
42 value [eax];
43
44#endif
45
46#ifdef KEE
47//Convert 16:16 stack based address to 0:32 flat addresss
48#define __Stack16ToFlat(addr) (LINEAR)((ULONG)(addr&0xffff) + stackbase)
49#else
50//Convert 16:16 stack based address to 0:32 flat addresss
51#define __Stack16ToFlat(addr) (LINEAR)((((ULONG)addr)&0xffff) + *(ULONG *)TKSSBase)
52#endif
53
54// Convert 16:16 pointer to 16:32
55char FAR48 *MAKE_FARPTR32(FARPTR16 addr1616);
56#pragma aux MAKE_FARPTR32 = \
57 "movzx edx, ax" \
58 "shr eax, 16" \
59 "mov fs, ax" \
60 parm [eax] \
61 value [fs edx];
62
63//Only valid for pointer previously constructed by __Make48Pointer!!
64//(upper 16 bits of 32 bits offset must be 0)
65FARPTR16 MAKE_FARPTR16(void FAR48 *addr1632);
66#pragma aux MAKE_FARPTR16 = \
67 "mov ax, gs" \
68 "shl eax, 16" \
69 "mov ax, dx" \
70 parm [gs edx] \
71 value [eax];
72
73FARPTR16 MAKE_FARPTR16_STACK(LINEAR offset);
74#pragma aux MAKE_FARPTR16_STACK = \
75 "mov ax, ss" \
76 "shl eax, 16" \
77 "mov ax, dx" \
78 parm [edx] \
79 value [eax];
80
81char FAR48 *MAKE_FARPTR32_STACK(LINEAR offset);
82#pragma aux MAKE_FARPTR32_STACK = \
83 "push ss" \
84 "pop fs" \
85 parm [eax] \
86 value [fs eax];
87
88#define MAKE_FP16(sel, offset) ((sel << 16) | (offset & 0xffff) )
89
90USHORT GETFARSEL(char FAR48 *addr1632);
91#pragma aux GETFARSEL = \
92 "mov ax, gs" \
93 parm [gs edx] \
94 value [ax];
95
96ULONG GETFAROFFSET(char FAR48 *addr1632);
97#pragma aux GETFAROFFSET = \
98 "mov eax, edx" \
99 parm [gs edx] \
100 value [eax];
101
102//SvL: Only works for DS & SS ptrs!
103ULONG GETFLATPTR(char FAR48 *ptr);
104
105#define FLATPTR(a) GETFLATPTR((char FAR48 *)a)
106
107#ifdef KEE
108#define FlatToSel(addr32) ((stacksel << 16) | (((ULONG)addr32 - stackbase) & 0xffff))
109#else
110//Only valid for stack based pointer!!
111ULONG FlatToSel(ULONG addr32);
112#endif
113
114#endif
Note: See TracBrowser for help on using the repository browser.