winecfg: Move controls on "Desktop Integration" tab to make more room for the next...
[wine] / dlls / winedos / int11.c
1 /*
2  * BIOS interrupt 11h handler
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "dosexe.h"
32 #include "wine/unicode.h"
33 #include "wine/debug.h"
34
35
36 /**********************************************************************
37  *          DOSVM_Int11Handler (WINEDOS16.117)
38  *
39  * Handler for int 11h (get equipment list).
40  *
41  *
42  * Borrowed from Ralph Brown's interrupt lists:
43  *
44  *   bits 15-14: number of parallel devices
45  *   bit     13: [Conv] Internal modem
46  *   bit     12: reserved
47  *   bits 11- 9: number of serial devices
48  *   bit      8: reserved
49  *   bits  7- 6: number of diskette drives minus one
50  *   bits  5- 4: Initial video mode:
51  *                 00b = EGA,VGA,PGA
52  *                 01b = 40 x 25 color
53  *                 10b = 80 x 25 color
54  *                 11b = 80 x 25 mono
55  *   bit      3: reserved
56  *   bit      2: [PS] =1 if pointing device
57  *               [non-PS] reserved
58  *   bit      1: =1 if math co-processor
59  *   bit      0: =1 if diskette available for boot
60  *
61  *
62  * Currently the only of these bits correctly set are:
63  *
64  *   bits 15-14   } Added by William Owen Smith,
65  *   bits 11-9    } wos@dcs.warwick.ac.uk
66  *   bits 7-6
67  *   bit  2       (always set)  ( bit 2 = 4 )
68  *   bit  1       } Robert 'Admiral' Coeyman
69  *                  All *nix systems either have a math processor or
70  *                   emulate one.
71  */
72 void WINAPI DOSVM_Int11Handler( CONTEXT86 *context )
73 {
74     int diskdrives = 0;
75     int parallelports = 0;
76     int serialports = 0;
77     int x;
78
79     if (GetDriveTypeA("A:\\") == DRIVE_REMOVABLE) diskdrives++;
80     if (GetDriveTypeA("B:\\") == DRIVE_REMOVABLE) diskdrives++;
81     if (diskdrives) diskdrives--;
82
83     for (x=0; x < 9; x++)
84     {
85         HANDLE handle;
86         char file[10];
87
88         /* serial port name */
89         sprintf( file, "\\\\.\\COM%d", x+1 );
90         handle = CreateFileA( file, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
91         if (handle != INVALID_HANDLE_VALUE)
92         {
93             CloseHandle( handle );
94             serialports++;
95         }
96
97         sprintf( file, "\\\\.\\LPT%d", x+1 );
98         handle = CreateFileA( file, 0, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
99         if (handle != INVALID_HANDLE_VALUE)
100         {
101             CloseHandle( handle );
102             parallelports++;
103         }
104     }
105
106     if (serialports > 7) /* 3 bits -- maximum value = 7 */
107         serialports = 7;
108
109     if (parallelports > 3) /* 2 bits -- maximum value = 3 */
110         parallelports = 3;
111
112     SET_AX( context, 
113             (diskdrives << 6) | (serialports << 9) | (parallelports << 14) | 0x06 );
114 }