Release 970202
[wine/multimedia.git] / msdos / ioports.c
blob7e41ce82169120d9abfa75769dcd15bc93c1b573
1 /*
2 * Emulation of processor ioports.
4 * Copyright 1995 Morten Welinder
5 */
7 /* Known problems:
8 - only a few ports are emulated.
9 - real-time clock in "cmos" is bogus. A nifty alarm() setup could
10 fix that, I guess.
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <time.h>
17 #include "windows.h"
18 #include "stddebug.h"
19 /* #define DEBUG_INT */
20 #include "debug.h"
22 static BYTE cmosaddress;
24 static BYTE cmosimage[64] =
26 0x27, 0x34, 0x31, 0x47, 0x16, 0x15, 0x00, 0x01,
27 0x04, 0x94, 0x26, 0x02, 0x50, 0x80, 0x00, 0x00,
28 0x40, 0xb1, 0x00, 0x9c, 0x01, 0x80, 0x02, 0x00,
29 0x1c, 0x00, 0x00, 0xad, 0x02, 0x10, 0x00, 0x00,
30 0x08, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x03, 0x58,
32 0x00, 0x1c, 0x19, 0x81, 0x00, 0x0e, 0x00, 0x80,
33 0x1b, 0x7b, 0x21, 0x00, 0x00, 0x00, 0x05, 0x5f
37 /**********************************************************************
38 * IO_inport
40 DWORD IO_inport( int port, int count )
42 DWORD res = 0;
43 BYTE b;
45 dprintf_int(stddeb, "IO: %d bytes from port 0x%02x\n", count, port );
47 while (count-- > 0)
49 switch (port++)
51 case 0x70:
52 b = cmosaddress;
53 break;
54 case 0x71:
55 b = cmosimage[cmosaddress & 0x3f];
56 break;
57 default:
58 fprintf( stderr, "Direct I/O read attempted from port %x\n", port);
59 b = 0xff;
60 break;
62 res = (res << 8) | b;
64 return res;
68 /**********************************************************************
69 * IO_outport
71 void IO_outport( int port, int count, DWORD value )
73 BYTE b;
75 dprintf_int( stddeb, "IO: 0x%lx (%d bytes) to port 0x%02x\n",
76 value, count, port );
78 while (count-- > 0)
80 b = value & 0xff;
81 value >>= 8;
82 switch (port++)
84 case 0x70:
85 cmosaddress = b & 0x7f;
86 break;
87 case 0x71:
88 cmosimage[cmosaddress & 0x3f] = b;
89 break;
90 default:
91 fprintf( stderr, "Direct I/O write attempted to port %x\n", port );
92 break;