Release 950122
[wine/multimedia.git] / loader / ldt.c
blob45b6ae43aa634a5a7187e30fe88568e0edae9128
1 #ifndef WINELIB
2 /*
3 static char RCSId[] = "$Id: ldt.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
4 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <errno.h>
10 #include "prototypes.h"
12 #if defined(__NetBSD__) || defined(__FreeBSD__)
13 #include <machine/segments.h>
14 #endif
16 /**********************************************************************
17 * print_ldt
19 /* XXX These are *real* 386 descriptors !! */
20 void
21 print_ldt()
23 char buffer[0x10000];
24 unsigned long *lp;
25 unsigned long base_addr, limit;
26 int type, dpl, i;
27 #if defined(__NetBSD__) || defined(__FreeBSD__)
28 struct segment_descriptor *sd;
29 #endif
31 if (get_ldt(buffer) < 0)
32 exit(1);
34 lp = (unsigned long *) buffer;
35 #if defined(__NetBSD__) || defined(__FreeBSD__)
36 sd = (struct segment_descriptor *) buffer;
37 #endif
39 for (i = 0; i < 32; i++, lp++)
41 /* First 32 bits of descriptor */
42 base_addr = (*lp >> 16) & 0x0000FFFF;
43 limit = *lp & 0x0000FFFF;
44 lp++;
46 /* First 32 bits of descriptor */
47 base_addr |= (*lp & 0xFF000000) | ((*lp << 16) & 0x00FF0000);
48 limit |= (*lp & 0x000F0000);
49 #ifdef linux
50 type = (*lp >> 10) & 5;
51 dpl = (*lp >> 13) & 3;
52 #endif
53 #if defined(__NetBSD__) || defined(__FreeBSD__)
54 type = sd->sd_type;
55 dpl = sd->sd_dpl;
56 sd++;
57 #endif
58 if (*lp & 1000)
60 printf("Entry %2d: Base %08lx, Limit %05lx, DPL %d, Type %d\n",
61 i, base_addr, limit, dpl, type);
62 printf(" ");
63 if (*lp & 0x100)
64 printf("Accessed, ");
65 if (*lp & 8000)
66 printf("Present, ");
67 if (*lp & 0x100000)
68 printf("User, ");
69 if (*lp & 0x200000)
70 printf("X, ");
71 if (*lp & 0x400000)
72 printf("32, ");
73 else
74 printf("16, ");
75 if (*lp & 0x800000)
76 printf("page limit, ");
77 else
78 printf("byte limit, ");
79 printf("\n");
80 printf(" %08lx %08lx\n", *(lp), *(lp-1));
82 else
84 printf("Entry %2d: Base %08lx, Limit %05lx, DPL %d, Type %d\n",
85 i, base_addr, limit, dpl, type);
86 printf(" SYSTEM: %08lx %08lx\n", *lp, *(lp-1));
91 #endif /* ifndef WINELIB */