2 * Mesa 3-D graphics library
5 * Copyright (C) 1999 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * DOS/DJGPP device driver v1.4 for Mesa
28 * Copyright (C) 2002 - Borca Daniel
29 * Email : dborca@yahoo.com
30 * Web : http://www.geocities.com/dborca
41 #define MAX(x, y) (((x)<(y))?(y):(x))
46 /* _create_linear_mapping:
47 * Maps a physical address range into linear memory.
49 int _create_linear_mapping (unsigned long *linear
, unsigned long physaddr
, int size
)
51 __dpmi_meminfo meminfo
;
53 if (physaddr
>= 0x100000) {
54 /* map into linear memory */
55 meminfo
.address
= physaddr
;
57 if (__dpmi_physical_address_mapping(&meminfo
) != 0)
60 *linear
= meminfo
.address
;
62 /* exploit 1 -> 1 physical to linear mapping in low megabyte */
71 /* _remove_linear_mapping:
72 * Frees the DPMI resources being used to map a linear address range.
74 void _remove_linear_mapping (unsigned long *linear
)
76 __dpmi_meminfo meminfo
;
79 if (*linear
>= 0x100000) {
80 meminfo
.address
= *linear
;
81 __dpmi_free_physical_address_mapping(&meminfo
);
91 * Allocates a selector to access a region of linear memory.
93 int _create_selector (int *segment
, unsigned long base
, int size
)
95 /* allocate an ldt descriptor */
96 if ((*segment
=__dpmi_allocate_ldt_descriptors(1)) < 0) {
101 /* create the linear mapping */
102 if (_create_linear_mapping(&base
, base
, size
)) {
103 __dpmi_free_ldt_descriptor(*segment
);
108 /* set the descriptor base and limit */
109 __dpmi_set_segment_base_address(*segment
, base
);
110 __dpmi_set_segment_limit(*segment
, MAX(size
-1, 0xFFFF));
118 * Frees a DPMI segment selector.
120 void _remove_selector (int *segment
)
124 __dpmi_get_segment_base_address(*segment
, &base
);
125 _remove_linear_mapping(&base
);
126 __dpmi_free_ldt_descriptor(*segment
);
133 /* Desc: retrieve CPU MMX capability
136 * Out : FALSE if CPU cannot do MMX
143 extern int _mesa_x86_cpu_features
;
144 return (_mesa_x86_cpu_features
& 0x00800000);