Stubs for EnumServiceStatus32, small changes.
[wine/multimedia.git] / include / ldt.h
blob0f46d9a0bce77f947b2e369e5cca90b1482ba7bf
1 /*
2 * LDT copy
4 * Copyright 1995 Alexandre Julliard
5 */
7 #ifndef __WINE_LDT_H
8 #define __WINE_LDT_H
10 #include "wintypes.h"
12 enum seg_type
14 SEGMENT_DATA = 0,
15 SEGMENT_STACK = 1,
16 SEGMENT_CODE = 2
19 /* This structure represents a real LDT entry. */
20 /* It is used by get_ldt_entry() and set_ldt_entry(). */
21 typedef struct
23 unsigned long base; /* base address */
24 unsigned long limit; /* segment limit (in pages or bytes) */
25 int seg_32bit; /* is segment 32-bit? */
26 int read_only; /* is segment read-only? */
27 int limit_in_pages; /* is the limit in pages or bytes? */
28 enum seg_type type; /* segment type */
29 } ldt_entry;
31 extern void LDT_BytesToEntry( const unsigned long *buffer, ldt_entry *content);
32 extern void LDT_EntryToBytes( unsigned long *buffer, const ldt_entry *content);
33 extern int LDT_GetEntry( int entry, ldt_entry *content );
34 extern int LDT_SetEntry( int entry, const ldt_entry *content );
35 extern void LDT_Print( int start, int length );
38 /* This structure is used to build the local copy of the LDT. */
39 typedef struct
41 unsigned long base; /* base address or 0 if entry is free */
42 unsigned long limit; /* limit in bytes or 0 if entry is free */
43 } ldt_copy_entry;
45 #define LDT_SIZE 8192
47 extern ldt_copy_entry ldt_copy[LDT_SIZE];
49 #define __AHSHIFT 3 /* don't change! */
50 #define __AHINCR (1 << __AHSHIFT)
52 #define SELECTOR_TO_ENTRY(sel) (((int)(sel) & 0xffff) >> __AHSHIFT)
53 #define ENTRY_TO_SELECTOR(i) ((i) ? (((int)(i) << __AHSHIFT) | 7) : 0)
54 #define IS_LDT_ENTRY_FREE(i) (!(ldt_flags_copy[(i)] & LDT_FLAGS_ALLOCATED))
55 #define IS_SELECTOR_FREE(sel) (IS_LDT_ENTRY_FREE(SELECTOR_TO_ENTRY(sel)))
56 #define GET_SEL_BASE(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].base)
57 #define GET_SEL_LIMIT(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].limit)
59 /* Convert a segmented ptr (16:16) to a linear (32) pointer */
61 #define PTR_SEG_OFF_TO_LIN(seg,off) \
62 ((void*)(GET_SEL_BASE(seg) + (unsigned int)(off)))
63 #define PTR_SEG_TO_LIN(ptr) \
64 PTR_SEG_OFF_TO_LIN(SELECTOROF(ptr),OFFSETOF(ptr))
65 #define PTR_SEG_OFF_TO_SEGPTR(seg,off) \
66 ((SEGPTR)MAKELONG(off,seg))
67 #define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \
68 PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << __AHSHIFT), LOWORD(off) )
70 extern unsigned char ldt_flags_copy[LDT_SIZE];
72 #define LDT_FLAGS_TYPE 0x03 /* Mask for segment type */
73 #define LDT_FLAGS_READONLY 0x04 /* Segment is read-only (data) */
74 #define LDT_FLAGS_EXECONLY 0x04 /* Segment is execute-only (code) */
75 #define LDT_FLAGS_32BIT 0x08 /* Segment is 32-bit (code or stack) */
76 #define LDT_FLAGS_BIG 0x10 /* Segment is big (limit is in pages) */
77 #define LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
79 #define GET_SEL_FLAGS(sel) (ldt_flags_copy[SELECTOR_TO_ENTRY(sel)])
81 #define FIRST_LDT_ENTRY_TO_ALLOC 17
83 /* Determine if sel is a system selector (i.e. not managed by Wine) */
84 #define IS_SELECTOR_SYSTEM(sel) \
85 (!((sel) & 4) || (SELECTOR_TO_ENTRY(sel) < FIRST_LDT_ENTRY_TO_ALLOC))
86 #define IS_SELECTOR_32BIT(sel) \
87 (IS_SELECTOR_SYSTEM(sel) || (GET_SEL_FLAGS(sel) & LDT_FLAGS_32BIT))
89 #endif /* __WINE_LDT_H */