Previous 15994 Revisions Next

r6934 Tuesday 5th January, 2010 at 12:02:44 UTC by Dirk Best
Converted i82439tx to a device, more cleanups
[src/mess/drivers]at.c
[src/mess/machine]at.c i82439tx.c i82439tx.h

src/mess/machine/at.c
r6933r6934
766766   pc_mouse_set_serial_port( devtag_get_device(machine, "ns16450_0") );
767767   pc_hdc_set_dma8237_device( st->dma8237_1 );
768768}
769
770MACHINE_START( at586 )
771{
772   MACHINE_START_CALL(at);
773   intel82439tx_init(machine);
774}
775
776MACHINE_RESET( at586 )
777{
778   MACHINE_RESET_CALL(at);
779   intel82439tx_reset(machine);
780}
src/mess/machine/i82439tx.c
r6933r6934
11/***************************************************************************
22
3    machine/i82439tx.c
3    Intel 82439TX System Controller (MTXC)
44
5    Intel 82439TX PCI Bridge
6
75***************************************************************************/
86
97#include "driver.h"
10#include "machine/i82439tx.h"
11#include "machine/pci.h"
8#include "i82439tx.h"
129
1310
14struct intel82439tx_info
11/***************************************************************************
12    TYPE DEFINITIONS
13***************************************************************************/
14
15typedef struct _i82439tx_state i82439tx_state;
16struct _i82439tx_state
1517{
18   const address_space *space;
19   UINT8 *rom;
20
1621   UINT32 regs[8];
1722   UINT32 bios_ram[0x40000 / 4];
1823};
1924
20static struct intel82439tx_info *i82439tx;
2125
26/*****************************************************************************
27    INLINE FUNCTIONS
28*****************************************************************************/
2229
23UINT32 intel82439tx_pci_read(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 mem_mask)
30INLINE i82439tx_state *get_safe_token(const device_config *device)
2431{
32   assert(device != NULL);
33   assert(device->token != NULL);
34   assert(device->type == I82439TX);
35
36   return (i82439tx_state *)device->token;
37}
38
39
40/***************************************************************************
41    IMPLEMENTATION
42***************************************************************************/
43
44static void i82439tx_configure_memory(const device_config *device, UINT8 val, offs_t begin, offs_t end)
45{
46   i82439tx_state *i82439tx = get_safe_token(device);
47
48   switch (val & 0x03)
49   {
50   case 0:
51      memory_install_rom(i82439tx->space, begin, end, 0, 0, i82439tx->rom + (begin - 0xc0000));
52      memory_nop_write(i82439tx->space, begin, end, 0, 0);
53      break;
54   case 1:
55      memory_install_rom(i82439tx->space, begin, end, 0, 0, i82439tx->bios_ram + (begin - 0xc0000) / 4);
56      memory_nop_write(i82439tx->space, begin, end, 0, 0);
57      break;
58   case 2:
59      memory_install_rom(i82439tx->space, begin, end, 0, 0, i82439tx->rom + (begin - 0xc0000));
60      memory_install_writeonly(i82439tx->space, begin, end, 0, 0, i82439tx->bios_ram + (begin - 0xc0000) / 4);
61      break;
62   case 3:
63      memory_install_ram(i82439tx->space, begin, end, 0, 0, i82439tx->bios_ram + (begin - 0xc0000) / 4);
64      break;
65   }
66}
67
68
69/***************************************************************************
70    PCI INTERFACE
71***************************************************************************/
72
73UINT32 i82439tx_pci_read(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 mem_mask)
74{
75   i82439tx_state *i82439tx = get_safe_token(device);
2576   UINT32 result = 0;
2677
2778   if (function != 0)
r6933r6934
66117         break;
67118
68119      default:
69         fatalerror("intel82439tx_pci_read(): Unexpected PCI read 0x%02X\n", offset);
120         fatalerror("i82439tx_pci_read(): Unexpected PCI read 0x%02X\n", offset);
70121         break;
71122   }
72123   return result;
73124}
74125
75
76
77static void intel82439tx_configure_memory(running_machine *machine, UINT8 val, offs_t begin, offs_t end)
126void i82439tx_pci_write(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 data, UINT32 mem_mask)
78127{
79   const address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM);
128   i82439tx_state *i82439tx = get_safe_token(device);
80129
81   char read_bank[10];
82   sprintf(read_bank, "%05x_r", begin);
83
84   memory_install_read_bank(space, begin, end, 0, 0, read_bank);
85
86   if (BIT(val, 0))
87      memory_set_bankptr(machine, read_bank, i82439tx->bios_ram + (begin - 0xc0000) / 4);
88   else
89      memory_set_bankptr(machine, read_bank, memory_region(machine, "user1") + (begin - 0xc0000));
90
91   /* write enabled? */
92   if (BIT(val, 1))
93   {
94      char write_bank[10];
95      sprintf(write_bank, "%05x_w", begin);
96
97      memory_install_write_bank(space, begin, end, 0, 0, write_bank);
98      memory_set_bankptr(machine, write_bank, i82439tx->bios_ram + (begin - 0xc0000) / 4);
99   }
100   else
101      memory_nop_write(space, begin, end, 0, 0);
102}
103
104
105
106void intel82439tx_pci_write(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 data, UINT32 mem_mask)
107{
108   running_machine *machine = busdevice->machine;
109
110130   if (function != 0)
111131      return;
112132
r6933r6934
145165         {
146166            case 0x58:
147167               if ((mem_mask & 0x0000f000))
148                  intel82439tx_configure_memory(machine, data >> 12, 0xF0000, 0xFFFFF);
168                  i82439tx_configure_memory(device, data >> 12, 0xf0000, 0xfffff);
149169               if ((mem_mask & 0x000f0000))
150                  intel82439tx_configure_memory(machine, data >> 16, 0xC0000, 0xC3FFF);
170                  i82439tx_configure_memory(device, data >> 16, 0xc0000, 0xc3fff);
151171               if ((mem_mask & 0x00f00000))
152                  intel82439tx_configure_memory(machine, data >> 20, 0xC4000, 0xC7FFF);
172                  i82439tx_configure_memory(device, data >> 20, 0xc4000, 0xc7fff);
153173               if ((mem_mask & 0x0f000000))
154                  intel82439tx_configure_memory(machine, data >> 24, 0xC8000, 0xCCFFF);
174                  i82439tx_configure_memory(device, data >> 24, 0xc8000, 0xccfff);
155175               if ((mem_mask & 0xf0000000))
156                  intel82439tx_configure_memory(machine, data >> 28, 0xCC000, 0xCFFFF);
176                  i82439tx_configure_memory(device, data >> 28, 0xcc000, 0xcffff);
157177               break;
158178
159179            case 0x5C:
160180               if ((mem_mask & 0x0000000f))
161                  intel82439tx_configure_memory(machine, data >>  0, 0xD0000, 0xD3FFF);
181                  i82439tx_configure_memory(device, data >>  0, 0xd0000, 0xd3fff);
162182               if ((mem_mask & 0x000000f0))
163                  intel82439tx_configure_memory(machine, data >>  4, 0xD4000, 0xD7FFF);
183                  i82439tx_configure_memory(device, data >>  4, 0xd4000, 0xd7fff);
164184               if ((mem_mask & 0x00000f00))
165                  intel82439tx_configure_memory(machine, data >>  8, 0xD8000, 0xDBFFF);
185                  i82439tx_configure_memory(device, data >>  8, 0xd8000, 0xdbfff);
166186               if ((mem_mask & 0x0000f000))
167                  intel82439tx_configure_memory(machine, data >> 12, 0xDC000, 0xDFFFF);
187                  i82439tx_configure_memory(device, data >> 12, 0xdc000, 0xdffff);
168188               if ((mem_mask & 0x000f0000))
169                  intel82439tx_configure_memory(machine, data >> 16, 0xE0000, 0xE3FFF);
189                  i82439tx_configure_memory(device, data >> 16, 0xe0000, 0xe3fff);
170190               if ((mem_mask & 0x00f00000))
171                  intel82439tx_configure_memory(machine, data >> 20, 0xE4000, 0xE7FFF);
191                  i82439tx_configure_memory(device, data >> 20, 0xe4000, 0xe7fff);
172192               if ((mem_mask & 0x0f000000))
173                  intel82439tx_configure_memory(machine, data >> 24, 0xE8000, 0xECFFF);
193                  i82439tx_configure_memory(device, data >> 24, 0xe8000, 0xecfff);
174194               if ((mem_mask & 0xf0000000))
175                  intel82439tx_configure_memory(machine, data >> 28, 0xEC000, 0xEFFFF);
195                  i82439tx_configure_memory(device, data >> 28, 0xec000, 0xeffff);
176196               break;
177197         }
178198
r6933r6934
180200         break;
181201
182202      default:
183         fatalerror("intel82439tx_pci_write(): Unexpected PCI write 0x%02X <-- 0x%08X\n", offset, data);
203         fatalerror("i82439tx_pci_write(): Unexpected PCI write 0x%02X <-- 0x%08X\n", offset, data);
184204         break;
185205   }
186206}
187207
188208
189void intel82439tx_init(running_machine *machine)
209/*****************************************************************************
210    DEVICE INTERFACE
211*****************************************************************************/
212
213static DEVICE_START( i82439tx )
190214{
191   i82439tx = auto_alloc(machine, struct intel82439tx_info);
215   i82439tx_state *i82439tx = get_safe_token(device);
216   i82439tx_config *config = device->inline_config;
217
218   /* get address space we are working on */
219   const device_config *cpu = devtag_get_device(device->machine, config->cputag);
220   assert(cpu != NULL);
221
222   i82439tx->space = cpu_get_address_space(cpu, ADDRESS_SPACE_PROGRAM);
223
224   /* get rom region */
225   i82439tx->rom = memory_region(device->machine, config->rom_region);
226
227   /* setup save states */
228   state_save_register_device_item_array(device, 0, i82439tx->regs);
229   state_save_register_device_item_array(device, 0, i82439tx->bios_ram);
192230}
193231
194void intel82439tx_reset(running_machine *machine)
232static DEVICE_RESET( i82439tx )
195233{
196   /* setup PCI */
197   memset(i82439tx, 0, sizeof(*i82439tx));
234   i82439tx_state *i82439tx = get_safe_token(device);
235
236   /* setup initial values */
198237   i82439tx->regs[0x00] = 0x14020000;
199238   i82439tx->regs[0x01] = 0x01520000;
200239   i82439tx->regs[0x02] = 0x00000000;
240   i82439tx->regs[0x03] = 0x00000000;
201241   i82439tx->regs[0x04] = 0x02020202;
202242   i82439tx->regs[0x05] = 0x00000002;
243   i82439tx->regs[0x06] = 0x00000000;
244   i82439tx->regs[0x07] = 0x00000000;
203245
204   intel82439tx_configure_memory(machine, 0, 0xF0000, 0xFFFFF);
205   intel82439tx_configure_memory(machine, 0, 0xC0000, 0xC3FFF);
206   intel82439tx_configure_memory(machine, 0, 0xC4000, 0xC7FFF);
207   intel82439tx_configure_memory(machine, 0, 0xC8000, 0xCCFFF);
208   intel82439tx_configure_memory(machine, 0, 0xCC000, 0xCFFFF);
209   intel82439tx_configure_memory(machine, 0, 0xD0000, 0xD3FFF);
210   intel82439tx_configure_memory(machine, 0, 0xD4000, 0xD7FFF);
211   intel82439tx_configure_memory(machine, 0, 0xD8000, 0xDBFFF);
212   intel82439tx_configure_memory(machine, 0, 0xDC000, 0xDFFFF);
213   intel82439tx_configure_memory(machine, 0, 0xE0000, 0xE3FFF);
214   intel82439tx_configure_memory(machine, 0, 0xE4000, 0xE7FFF);
215   intel82439tx_configure_memory(machine, 0, 0xE8000, 0xECFFF);
216   intel82439tx_configure_memory(machine, 0, 0xEC000, 0xEFFFF);
246   /* configure initial memory state */
247   i82439tx_configure_memory(device, 0, 0xf0000, 0xfffff);
248   i82439tx_configure_memory(device, 0, 0xc0000, 0xc3fff);
249   i82439tx_configure_memory(device, 0, 0xc4000, 0xc7fff);
250   i82439tx_configure_memory(device, 0, 0xc8000, 0xccfff);
251   i82439tx_configure_memory(device, 0, 0xcc000, 0xcffff);
252   i82439tx_configure_memory(device, 0, 0xd0000, 0xd3fff);
253   i82439tx_configure_memory(device, 0, 0xd4000, 0xd7fff);
254   i82439tx_configure_memory(device, 0, 0xd8000, 0xdbfff);
255   i82439tx_configure_memory(device, 0, 0xdc000, 0xdffff);
256   i82439tx_configure_memory(device, 0, 0xe0000, 0xe3fff);
257   i82439tx_configure_memory(device, 0, 0xe4000, 0xe7fff);
258   i82439tx_configure_memory(device, 0, 0xe8000, 0xecfff);
259   i82439tx_configure_memory(device, 0, 0xec000, 0xeffff);
217260}
261
262
263/***************************************************************************
264    DEVICE GETINFO
265***************************************************************************/
266
267static const char DEVTEMPLATE_SOURCE[] = __FILE__;
268
269#define DEVTEMPLATE_ID(p,s)            p##i82439tx##s
270#define DEVTEMPLATE_FEATURES         DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG
271#define DEVTEMPLATE_NAME            "Intel 82439TX"
272#define DEVTEMPLATE_FAMILY            "System controller"
273#define DEVTEMPLATE_CLASS            DEVICE_CLASS_OTHER
274#define DEVTEMPLATE_VERSION            "1.0"
275#define DEVTEMPLATE_CREDITS            "Copyright MESS Team"
276#include "devtempl.h"
src/mess/machine/i82439tx.h
r6933r6934
11/***************************************************************************
22
3    machine/i82439tx.h
3    Intel 82439TX System Controller (MTXC)
44
5    Intel 82439TX PCI Bridge
5    Part of the Intel 430TX chipset
66
77***************************************************************************/
88
9#ifndef I82439TX_H
10#define I82439TX_H
9#ifndef __I82439TX_H__
10#define __I82439TX_H__
1111
12void intel82439tx_init(running_machine *machine);
13void intel82439tx_reset(running_machine *machine);
14UINT32 intel82439tx_pci_read(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 mem_mask);
15void intel82439tx_pci_write(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 data, UINT32 mem_mask);
1612
17#endif /* I82439TX_H */
13/***************************************************************************
14    TYPE DEFINITIONS
15***************************************************************************/
16
17typedef struct _i82439tx_config i82439tx_config;
18struct _i82439tx_config
19{
20   const char *cputag;
21   const char *rom_region;
22};
23
24
25/***************************************************************************
26    FUNCTION PROTOTYPES
27***************************************************************************/
28
29DEVICE_GET_INFO( i82439tx );
30
31UINT32 i82439tx_pci_read(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 mem_mask);
32void i82439tx_pci_write(const device_config *busdevice, const device_config *device, int function, int offset, UINT32 data, UINT32 mem_mask);
33
34
35/***************************************************************************
36    DEVICE CONFIGURATION MACROS
37***************************************************************************/
38
39#define I82439TX DEVICE_GET_INFO_NAME(i82439tx)
40
41#define MDRV_I82439TX_ADD(_tag, _cputag, _rom_region) \
42   MDRV_DEVICE_ADD(_tag, I82439TX, 0) \
43   MDRV_DEVICE_CONFIG_DATAPTR(i82439tx_config, cputag, _cputag) \
44   MDRV_DEVICE_CONFIG_DATAPTR(i82439tx_config, rom_region, _rom_region)
45
46
47#endif /* __I82439TX_H__ */
src/mess/drivers/at.c
r6933r6934
164164   write32le_with_write8_handler(at_kbdc8042_w, space, offset, data, mem_mask);
165165}
166166
167
167168static ADDRESS_MAP_START(at16_io, ADDRESS_SPACE_IO, 16)
168169   AM_RANGE(0x0000, 0x001f) AM_DEVREADWRITE8("dma8237_1", i8237_r, i8237_w, 0xffff)
169170   AM_RANGE(0x0020, 0x003f) AM_DEVREADWRITE8("pic8259_master", pic8259_r, pic8259_w, 0xffff)
r6933r6934
833834static MACHINE_DRIVER_START( at586 )
834835   MDRV_IMPORT_FROM( at386 )
835836
836   MDRV_MACHINE_START( at586 )
837   MDRV_MACHINE_RESET( at586 )
838   
839837   MDRV_CPU_REPLACE("maincpu", PENTIUM, 60000000)
840838   MDRV_CPU_PROGRAM_MAP(at586_map)
841839   MDRV_CPU_IO_MAP(at586_io)
842840
841   MDRV_I82439TX_ADD("i82439tx", "maincpu", "user1")
842
843843   MDRV_PCI_BUS_ADD("pcibus", 0)
844   MDRV_PCI_BUS_DEVICE(0, NULL, intel82439tx_pci_read, intel82439tx_pci_write)
844   MDRV_PCI_BUS_DEVICE(0, "i82439tx", i82439tx_pci_read, i82439tx_pci_write)
845845MACHINE_DRIVER_END
846846
847847
r6933r6934
10011001
10021002ROM_START( at )
10031003    ROM_REGION(0x1000000,"maincpu", 0)
1004    ROM_LOAD("wdbios.rom",  0xc8000, 0x02000, CRC(8e9e2bd4) SHA1(601d7ceab282394ebab50763c267e915a6a2166a))   
1004    ROM_LOAD("wdbios.rom",  0xc8000, 0x02000, CRC(8e9e2bd4) SHA1(601d7ceab282394ebab50763c267e915a6a2166a))
10051005   ROM_SYSTEM_BIOS(0, "at", "PC 286")
10061006    ROMX_LOAD("at110387.1", 0xf0001, 0x8000, CRC(679296a7) SHA1(ae891314cac614dfece686d8e1d74f4763cf40e3),ROM_SKIP(1) | ROM_BIOS(1) )
10071007    ROMX_LOAD("at110387.0", 0xf0000, 0x8000, CRC(65ae1f97) SHA1(91a29c7deecf7a9afbba330e64e0eee9aafee4d1),ROM_SKIP(1) | ROM_BIOS(1) )
r6933r6934
12061206   ROM_LOAD("et4000.bin",  0x00000, 0x08000, CRC(f01e4be0) SHA1(95d75ff41bcb765e50bd87a8da01835fd0aa01d5))
12071207    ROM_LOAD("wdbios.rom",  0x08000, 0x02000, CRC(8e9e2bd4) SHA1(601d7ceab282394ebab50763c267e915a6a2166a))
12081208   ROM_SYSTEM_BIOS(0, "sptx", "SP-586TX")
1209    ROMX_LOAD("sp586tx.bin",   0x20000, 0x20000, CRC(1003d72c) SHA1(ec9224ff9b0fdfd6e462cb7bbf419875414739d6), ROM_BIOS(1))     
1209    ROMX_LOAD("sp586tx.bin",   0x20000, 0x20000, CRC(1003d72c) SHA1(ec9224ff9b0fdfd6e462cb7bbf419875414739d6), ROM_BIOS(1))
12101210   ROM_SYSTEM_BIOS(1, "unisys", "Unisys 586") // probably bad dump due to need of hac in i82439tx to work
12111211    ROMX_LOAD("at586.bin",     0x20000, 0x20000, CRC(717037f5) SHA1(1d49d1b7a4a40d07d1a897b7f8c827754d76f824), ROM_BIOS(2))
12121212   /* 8042 keyboard controller */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team