Mercurial > mplayer.hg
annotate loader/wine/ldt.h @ 26858:2c3eb1dbca94
codecs2html and codec-cfg-test are removed by toolsclean. Do not remove
them redundantly upon distclean.
author | diego |
---|---|
date | Tue, 27 May 2008 11:22:55 +0000 |
parents | a8ea87c71d18 |
children | 9e739bdb049c |
rev | line source |
---|---|
1 | 1 /* |
2 * LDT copy | |
3 * | |
4 * Copyright 1995 Alexandre Julliard | |
5 */ | |
6 | |
26045 | 7 #ifndef MPLAYER_LDT_H |
8 #define MPLAYER_LDT_H | |
1 | 9 |
10 #include "windef.h" | |
11 enum seg_type | |
12 { | |
13 SEGMENT_DATA = 0, | |
14 SEGMENT_STACK = 1, | |
15 SEGMENT_CODE = 2 | |
16 }; | |
17 | |
18 /* This structure represents a real LDT entry. */ | |
19 /* It is used by get_ldt_entry() and set_ldt_entry(). */ | |
20 typedef struct | |
21 { | |
22 unsigned long base; /* base address */ | |
23 unsigned long limit; /* segment limit (in pages or bytes) */ | |
24 int seg_32bit; /* is segment 32-bit? */ | |
25 int read_only; /* is segment read-only? */ | |
26 int limit_in_pages; /* is the limit in pages or bytes? */ | |
27 enum seg_type type; /* segment type */ | |
28 } ldt_entry; | |
29 #ifdef __cplusplus | |
30 extern "C" | |
31 { | |
32 #endif | |
33 extern void LDT_BytesToEntry( const unsigned long *buffer, ldt_entry *content); | |
34 extern void LDT_EntryToBytes( unsigned long *buffer, const ldt_entry *content); | |
35 extern int LDT_GetEntry( int entry, ldt_entry *content ); | |
36 extern int LDT_SetEntry( int entry, const ldt_entry *content ); | |
37 extern void LDT_Print( int start, int length ); | |
38 | |
39 | |
40 /* This structure is used to build the local copy of the LDT. */ | |
41 typedef struct | |
42 { | |
43 unsigned long base; /* base address or 0 if entry is free */ | |
44 unsigned long limit; /* limit in bytes or 0 if entry is free */ | |
45 } ldt_copy_entry; | |
46 | |
47 #define LDT_SIZE 8192 | |
48 | |
49 extern ldt_copy_entry ldt_copy[LDT_SIZE]; | |
50 | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
51 #define AHSHIFT 3 /* don't change! */ |
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
52 #define AHINCR (1 << AHSHIFT) |
1 | 53 |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
54 #define SELECTOR_TO_ENTRY(sel) (((int)(sel) & 0xffff) >> AHSHIFT) |
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
55 #define ENTRY_TO_SELECTOR(i) ((i) ? (((int)(i) << AHSHIFT) | 7) : 0) |
1 | 56 #define IS_LDT_ENTRY_FREE(i) (!(ldt_flags_copy[(i)] & LDT_FLAGS_ALLOCATED)) |
57 #define IS_SELECTOR_FREE(sel) (IS_LDT_ENTRY_FREE(SELECTOR_TO_ENTRY(sel))) | |
58 #define GET_SEL_BASE(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].base) | |
59 #define GET_SEL_LIMIT(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].limit) | |
60 | |
61 /* Convert a segmented ptr (16:16) to a linear (32) pointer */ | |
62 | |
63 #define PTR_SEG_OFF_TO_LIN(seg,off) \ | |
64 ((void*)(GET_SEL_BASE(seg) + (unsigned int)(off))) | |
65 #define PTR_SEG_TO_LIN(ptr) \ | |
66 PTR_SEG_OFF_TO_LIN(SELECTOROF(ptr),OFFSETOF(ptr)) | |
67 #define PTR_SEG_OFF_TO_SEGPTR(seg,off) \ | |
68 ((SEGPTR)MAKELONG(off,seg)) | |
69 #define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \ | |
25794
2c8cdb9123b8
Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents:
24422
diff
changeset
|
70 PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << AHSHIFT), LOWORD(off) ) |
1 | 71 |
72 #define W32S_APPLICATION() (PROCESS_Current()->flags & PDB32_WIN32S_PROC) | |
73 #define W32S_OFFSET 0x10000 | |
74 #define W32S_APP2WINE(addr, offset) ((addr)? (DWORD)(addr) + (DWORD)(offset) : 0) | |
75 #define W32S_WINE2APP(addr, offset) ((addr)? (DWORD)(addr) - (DWORD)(offset) : 0) | |
76 | |
77 extern unsigned char ldt_flags_copy[LDT_SIZE]; | |
78 | |
79 #define LDT_FLAGS_TYPE 0x03 /* Mask for segment type */ | |
80 #define LDT_FLAGS_READONLY 0x04 /* Segment is read-only (data) */ | |
81 #define LDT_FLAGS_EXECONLY 0x04 /* Segment is execute-only (code) */ | |
82 #define LDT_FLAGS_32BIT 0x08 /* Segment is 32-bit (code or stack) */ | |
83 #define LDT_FLAGS_BIG 0x10 /* Segment is big (limit is in pages) */ | |
84 #define LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */ | |
85 | |
86 #define GET_SEL_FLAGS(sel) (ldt_flags_copy[SELECTOR_TO_ENTRY(sel)]) | |
87 | |
88 #define FIRST_LDT_ENTRY_TO_ALLOC 17 | |
89 | |
90 /* Determine if sel is a system selector (i.e. not managed by Wine) */ | |
91 #define IS_SELECTOR_SYSTEM(sel) \ | |
92 (!((sel) & 4) || (SELECTOR_TO_ENTRY(sel) < FIRST_LDT_ENTRY_TO_ALLOC)) | |
93 #define IS_SELECTOR_32BIT(sel) \ | |
94 (IS_SELECTOR_SYSTEM(sel) || (GET_SEL_FLAGS(sel) & LDT_FLAGS_32BIT)) | |
95 #ifdef __cplusplus | |
96 } | |
97 #endif | |
26045 | 98 |
99 #endif /* MPLAYER_LDT_H */ |