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