Release 960114
[wine/gsoc-2012-control.git] / miscemu / ioports.c
blob3ea012a25a9341ceec7c623c678a82a0576a8ae8
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 DWORD inport( int port, int count )
39 DWORD res = 0;
40 BYTE b;
42 dprintf_int(stddeb, "IO: %d bytes from port 0x%02x\n", count, port );
44 while (count-- > 0)
46 switch (port++)
48 case 0x70:
49 b = cmosaddress;
50 break;
51 case 0x71:
52 b = cmosimage[cmosaddress & 0x3f];
53 break;
54 default:
55 b = 0xff;
57 res = (res << 8) | b;
59 return res;
63 void outport( int port, int count, DWORD value )
65 BYTE b;
67 dprintf_int( stddeb, "IO: 0x%lx (%d bytes) to port 0x%02x\n",
68 value, count, port );
70 while (count-- > 0)
72 b = value & 0xff;
73 value >>= 8;
74 switch (port++)
76 case 0x70:
77 cmosaddress = b & 0x7f;
78 break;
79 case 0x71:
80 cmosimage[cmosaddress & 0x3f] = b;
81 break;
82 default:
83 /* Rien du tout. */