Skip to content
This repository was archived by the owner on Sep 18, 2021. It is now read-only.

Commit 4052e5d

Browse files
author
micko
committed
patch fixes the txp4 bios crash by Carl (nw)
1 parent b4e1109 commit 4052e5d

File tree

1 file changed

+109
-68
lines changed

1 file changed

+109
-68
lines changed

src/mess/machine/i82371ab.c

+109-68
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
typedef struct _i82371ab_state i82371ab_state;
3131
struct _i82371ab_state
3232
{
33-
UINT32 regs[4][0x100/4];
33+
UINT8 regs[4][0x100];
3434
};
3535

3636

@@ -54,7 +54,10 @@ INLINE i82371ab_state *get_safe_token(device_t *device)
5454
static UINT32 i82371ab_pci_isa_r(device_t *busdevice, device_t *device, int offset, UINT32 mem_mask)
5555
{
5656
i82371ab_state *i82371ab = get_safe_token(device);
57-
UINT32 result = i82371ab->regs[0][offset];
57+
UINT32 result = i82371ab->regs[0][offset] |
58+
i82371ab->regs[0][offset+1] << 8 |
59+
i82371ab->regs[0][offset+2] << 16|
60+
i82371ab->regs[0][offset+3] << 24;
5861

5962
logerror("i82371ab_pci_isa_r, offset = %02x, mem_mask = %08x\n", offset, mem_mask);
6063

@@ -63,29 +66,39 @@ static UINT32 i82371ab_pci_isa_r(device_t *busdevice, device_t *device, int offs
6366

6467
static void i82371ab_pci_isa_w(device_t *busdevice, device_t *device, int offset, UINT32 data, UINT32 mem_mask)
6568
{
69+
UINT32 cdata = 0;
70+
int i;
6671
i82371ab_state *i82371ab = get_safe_token(device);
72+
COMBINE_DATA(&cdata);
6773

6874
logerror("i82371ab_pci_isa_w, offset = %02x, data = %08x, mem_mask = %08x\n", offset, data, mem_mask);
6975

70-
switch (offset)
76+
for(i = 0; i < 4; i++, offset++, cdata >>= 8)
7177
{
72-
case 0x04:
73-
COMBINE_DATA(&i82371ab->regs[0][offset]);
74-
75-
/* clear reserved bits */
76-
i82371ab->regs[0][offset] &= 0x00000005;
77-
78-
/* set new status */
79-
i82371ab->regs[0][offset] |= 0x02800000;
80-
81-
break;
78+
switch (offset)
79+
{
80+
case 0x04:
81+
/* clear reserved bits */
82+
i82371ab->regs[0][offset] = cdata & 0x05;
83+
break;
84+
case 0x06:
85+
/* set new status */
86+
i82371ab->regs[0][offset] |= 0x80;
87+
break;
88+
case 0x07:
89+
i82371ab->regs[0][offset] |= 0x02;
90+
break;
91+
}
8292
}
8393
}
8494

8595
static UINT32 i82371ab_pci_ide_r(device_t *busdevice, device_t *device, int offset, UINT32 mem_mask)
8696
{
8797
i82371ab_state *i82371ab = get_safe_token(device);
88-
UINT32 result = i82371ab->regs[1][offset];
98+
UINT32 result = i82371ab->regs[1][offset] |
99+
i82371ab->regs[1][offset+1] << 8 |
100+
i82371ab->regs[1][offset+2] << 16|
101+
i82371ab->regs[1][offset+3] << 24;
89102

90103
logerror("i82371ab_pci_ide_r, offset = %02x, mem_mask = %08x\n", offset, mem_mask);
91104

@@ -94,29 +107,39 @@ static UINT32 i82371ab_pci_ide_r(device_t *busdevice, device_t *device, int offs
94107

95108
static void i82371ab_pci_ide_w(device_t *busdevice, device_t *device, int offset, UINT32 data, UINT32 mem_mask)
96109
{
110+
UINT32 cdata = 0;
111+
int i;
97112
i82371ab_state *i82371ab = get_safe_token(device);
113+
COMBINE_DATA(&cdata);
98114

99-
logerror("i82371ab_pci_ide_w, offset = %02x, data = %08x, mem_mask = %08x\n", offset, data, mem_mask);
115+
logerror("i82371ab_pci_isa_w, offset = %02x, data = %08x, mem_mask = %08x\n", offset, data, mem_mask);
100116

101-
switch (offset)
117+
for(i = 0; i < 4; i++, offset++, cdata >>= 8)
102118
{
103-
case 0x04:
104-
COMBINE_DATA(&i82371ab->regs[1][offset]);
105-
106-
/* clear reserved bits */
107-
i82371ab->regs[1][offset] &= 0x00000005;
108-
109-
/* set new status */
110-
i82371ab->regs[1][offset] |= 0x02800000;
111-
112-
break;
119+
switch (offset)
120+
{
121+
case 0x04:
122+
/* clear reserved bits */
123+
i82371ab->regs[1][offset] = cdata & 0x05;
124+
break;
125+
case 0x06:
126+
/* set new status */
127+
i82371ab->regs[1][offset] |= 0x80;
128+
break;
129+
case 0x07:
130+
i82371ab->regs[1][offset] |= 0x02;
131+
break;
132+
}
113133
}
114134
}
115135

116136
static UINT32 i82371ab_pci_usb_r(device_t *busdevice, device_t *device, int offset, UINT32 mem_mask)
117137
{
118138
i82371ab_state *i82371ab = get_safe_token(device);
119-
UINT32 result = i82371ab->regs[2][offset];
139+
UINT32 result = i82371ab->regs[2][offset] |
140+
i82371ab->regs[2][offset+1] << 8 |
141+
i82371ab->regs[2][offset+2] << 16|
142+
i82371ab->regs[2][offset+3] << 24;
120143

121144
logerror("i82371ab_pci_usb_r, offset = %02x, mem_mask = %08x\n", offset, mem_mask);
122145

@@ -125,29 +148,39 @@ static UINT32 i82371ab_pci_usb_r(device_t *busdevice, device_t *device, int offs
125148

126149
static void i82371ab_pci_usb_w(device_t *busdevice, device_t *device, int offset, UINT32 data, UINT32 mem_mask)
127150
{
151+
UINT32 cdata = 0;
152+
int i;
128153
i82371ab_state *i82371ab = get_safe_token(device);
154+
COMBINE_DATA(&cdata);
129155

130-
logerror("i82371ab_pci_usb_w, offset = %02x, data = %08x, mem_mask = %08x\n", offset, data, mem_mask);
156+
logerror("i82371ab_pci_isa_w, offset = %02x, data = %08x, mem_mask = %08x\n", offset, data, mem_mask);
131157

132-
switch (offset)
158+
for(i = 0; i < 4; i++, offset++, cdata >>= 8)
133159
{
134-
case 0x04:
135-
COMBINE_DATA(&i82371ab->regs[2][offset]);
136-
137-
/* clear reserved bits */
138-
i82371ab->regs[2][offset] &= 0x00000005;
139-
140-
/* set new status */
141-
i82371ab->regs[2][offset] |= 0x02800000;
142-
143-
break;
160+
switch (offset)
161+
{
162+
case 0x04:
163+
/* clear reserved bits */
164+
i82371ab->regs[2][offset] = cdata & 0x05;
165+
break;
166+
case 0x06:
167+
/* set new status */
168+
i82371ab->regs[2][offset] |= 0x80;
169+
break;
170+
case 0x07:
171+
i82371ab->regs[2][offset] |= 0x02;
172+
break;
173+
}
144174
}
145175
}
146176

147177
static UINT32 i82371ab_pci_acpi_r(device_t *busdevice, device_t *device, int offset, UINT32 mem_mask)
148178
{
149179
i82371ab_state *i82371ab = get_safe_token(device);
150-
UINT32 result = i82371ab->regs[3][offset];
180+
UINT32 result = i82371ab->regs[3][offset] |
181+
i82371ab->regs[3][offset+1] << 8 |
182+
i82371ab->regs[3][offset+2] << 16|
183+
i82371ab->regs[3][offset+3] << 24;
151184

152185
logerror("i82371ab_pci_acpi_r, offset = %02x, mem_mask = %08x\n", offset, mem_mask);
153186

@@ -156,22 +189,29 @@ static UINT32 i82371ab_pci_acpi_r(device_t *busdevice, device_t *device, int off
156189

157190
static void i82371ab_pci_acpi_w(device_t *busdevice, device_t *device, int offset, UINT32 data, UINT32 mem_mask)
158191
{
192+
UINT32 cdata = 0;
193+
int i;
159194
i82371ab_state *i82371ab = get_safe_token(device);
195+
COMBINE_DATA(&cdata);
160196

161-
logerror("i82371ab_pci_acpi_w, offset = %02x, data = %08x, mem_mask = %08x\n", offset, data, mem_mask);
197+
logerror("i82371ab_pci_isa_w, offset = %02x, data = %08x, mem_mask = %08x\n", offset, data, mem_mask);
162198

163-
switch (offset)
199+
for(i = 0; i < 4; i++, offset++, cdata >>= 8)
164200
{
165-
case 0x04:
166-
COMBINE_DATA(&i82371ab->regs[3][offset]);
167-
168-
/* clear reserved bits */
169-
i82371ab->regs[3][offset] &= 0x00000005;
170-
171-
/* set new status */
172-
i82371ab->regs[3][offset] |= 0x02800000;
173-
174-
break;
201+
switch (offset)
202+
{
203+
case 0x04:
204+
/* clear reserved bits */
205+
i82371ab->regs[3][offset] = cdata & 0x05;
206+
break;
207+
case 0x06:
208+
/* set new status */
209+
i82371ab->regs[3][offset] |= 0x80;
210+
break;
211+
case 0x07:
212+
i82371ab->regs[3][offset] |= 0x02;
213+
break;
214+
}
175215
}
176216
}
177217

@@ -217,30 +257,31 @@ static DEVICE_START( i82371ab )
217257
static DEVICE_RESET( i82371ab )
218258
{
219259
i82371ab_state *i82371ab = get_safe_token(device);
260+
UINT32 (*regs32)[64] = (UINT32 (*)[64])(i82371ab->regs);
220261

221262
/* isa */
222-
i82371ab->regs[0][0x00] = 0x71108086;
223-
i82371ab->regs[0][0x04] = 0x00000000;
224-
i82371ab->regs[0][0x08] = 0x06010000;
225-
i82371ab->regs[0][0x0c] = 0x00800000;
263+
regs32[0][0x00] = 0x71108086;
264+
regs32[0][0x04] = 0x00000000;
265+
regs32[0][0x08] = 0x06010000;
266+
regs32[0][0x0c] = 0x00800000;
226267

227268
/* ide */
228-
i82371ab->regs[1][0x00] = 0x71118086;
229-
i82371ab->regs[1][0x04] = 0x02800000;
230-
i82371ab->regs[1][0x08] = 0x01018000;
231-
i82371ab->regs[1][0x0c] = 0x00000000;
269+
regs32[1][0x00] = 0x71118086;
270+
regs32[1][0x04] = 0x02800000;
271+
regs32[1][0x08] = 0x01018000;
272+
regs32[1][0x0c] = 0x00000000;
232273

233274
/* usb */
234-
i82371ab->regs[2][0x00] = 0x71128086;
235-
i82371ab->regs[2][0x04] = 0x02800000;
236-
i82371ab->regs[2][0x08] = 0x0c030000;
237-
i82371ab->regs[2][0x0c] = 0x00000000;
275+
regs32[2][0x00] = 0x71128086;
276+
regs32[2][0x04] = 0x02800000;
277+
regs32[2][0x08] = 0x0c030000;
278+
regs32[2][0x0c] = 0x00000000;
238279

239280
/* acpi */
240-
i82371ab->regs[3][0x00] = 0x71138086;
241-
i82371ab->regs[3][0x04] = 0x02800000;
242-
i82371ab->regs[3][0x08] = 0x06800000;
243-
i82371ab->regs[3][0x0c] = 0x02800000;
281+
regs32[3][0x00] = 0x71138086;
282+
regs32[3][0x04] = 0x02800000;
283+
regs32[3][0x08] = 0x06800000;
284+
regs32[3][0x0c] = 0x02800000;
244285
}
245286

246287

0 commit comments

Comments
 (0)