Release 950620
[wine] / miscemu / ioports.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <time.h>
4 #include "registers.h"
5 #include "wine.h"
6 #include "stddebug.h"
7 /* #define DEBUG_INT */
8 #include "debug.h"
9
10 static BYTE cmosaddress;
11
12 static BYTE cmosimage[64] = {
13         0x27, 0x34, 0x31, 0x47, 0x16, 0x15, 0x00, 0x01,
14         0x04, 0x94, 0x26, 0x02, 0x50, 0x80, 0x00, 0x00,
15         0x40, 0xb1, 0x00, 0x9c, 0x01, 0x80, 0x02, 0x00,
16         0x1c, 0x00, 0x00, 0xad, 0x02, 0x10, 0x00, 0x00,
17         0x08, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00,
18         0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x03, 0x58,
19         0x00, 0x1c, 0x19, 0x81, 0x00, 0x0e, 0x00, 0x80,
20         0x1b, 0x7b, 0x21, 0x00, 0x00, 0x00, 0x05, 0x5f };
21
22 void inportb(struct sigcontext_struct *context)
23 {
24         dprintf_int(stddeb, "IO: inb (%x)\n", DX);
25
26         switch(DX) {
27                 case 0x70:
28                         AL = cmosaddress;
29                         break;
30                 case 0x71:
31                         AL = cmosimage[cmosaddress & 0x3f];
32                         break;
33                 default:
34         }
35 }
36
37 void inport( struct sigcontext_struct *context, int long_op )
38 {
39     dprintf_int(stdnimp, "IO: in (%x)\n", DX);
40     if (long_op) EAX = 0xffffffff;
41     else AX = 0xffff;
42 }
43
44 void inportb_abs(struct sigcontext_struct *context)
45 {
46         dprintf_int(stdnimp, "IO: in (%x)\n", *(BYTE *)(EIP+1));
47         AL = 0xff;
48 }
49
50 void inport_abs( struct sigcontext_struct *context, int long_op )
51 {
52     dprintf_int(stdnimp, "IO: in (%x)\n", *(BYTE *)(EIP+1));
53     if (long_op) EAX = 0xffffffff;
54     else AX = 0xffff;
55 }
56
57 void outportb(struct sigcontext_struct *context)
58 {
59         dprintf_int(stdnimp, "IO: outb (%x), %x\n", DX, AX);
60
61         switch (EDX & 0xffff)
62         {
63                 case 0x70:
64                         cmosaddress = AL & 0x7f;
65                         break;
66                 case 0x71:
67                         cmosimage[cmosaddress & 0x3f] = AL;
68                         break;
69                 default:
70         }
71 }
72
73 void outport( struct sigcontext_struct *context, int long_op )
74 {
75     dprintf_int(stdnimp, "IO: out (%x), %lx\n", DX, long_op ? EAX : AX);
76 }
77
78 void outportb_abs(struct sigcontext_struct *context)
79 {
80     dprintf_int(stdnimp, "IO: out (%x), %x\n", *(BYTE *)(EIP+1), AL);
81 }
82
83 void outport_abs( struct sigcontext_struct *context, int long_op )
84 {
85     dprintf_int(stdnimp, "IO: out (%x), %lx\n", *(BYTE *)(EIP+1),
86                 long_op ? EAX : AX);
87 }