Previous 15994 Revisions Next

r2187 Monday 31st March, 2008 at 20:38:30 UTC by Wilbert Pol
Moved most mess specific code from the mame pcshare code to the mess code. Also submitted to mamedev.
[src/mame/machine]pcshare.c
[src/mess/includes]pc.h
[src/mess/machine]at.c pc.c

src/mame/machine/pcshare.c
r2186r2187
3434#include "machine/pckeybrd.h"
3535
3636#ifdef MESS
37#include "machine/uart8250.h"
38#include "video/pc_vga.h"
39#include "video/pc_cga.h"
40#include "video/pc_mda.h"
41#include "video/pc_aga.h"
42
43#include "includes/pc_mouse.h"
4437#include "machine/pc_fdc.h"
45
46#include "includes/pclpt.h"
47#include "machine/centroni.h"
48
4938#include "machine/pc_hdc.h"
50#include "machine/nec765.h"
5139#include "audio/pc.h"
52
53#include "mscommon.h"
5440#endif /* MESS */
5541
5642#define VERBOSE_DBG 0       /* general debug messages */
r2186r2187
6147#define JOY_LOG(N,M,A) \
6248   if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; }
6349
64#define FDC_DMA 2
6550
66
6751static emu_timer *pc_keyboard_timer;
6852
6953static TIMER_CALLBACK( pc_keyb_timer );
r2186r2187
7155#define LOG_PORT80 0
7256
7357
74
75/* ---------------------------------------------------------------------- */
76
77#ifdef MESS
78/* called when a interrupt is set/cleared from com hardware */
79static void pc_com_interrupt(int nr, int state)
80{
81   static const int irq[4] = {4, 3, 4, 3};
82
83   /* issue COM1/3 IRQ4, COM2/4 IRQ3 */
84   pic8259_set_irq_line(0, irq[nr], state);
85}
86
87/* called when com registers read/written - used to update peripherals that
88are connected */
89static void pc_com_refresh_connected(int n, int data)
90{
91   /* mouse connected to this port? */
92   if (readinputport(3) & (0x80>>n))
93      pc_mouse_handshake_in(n,data);
94}
95
96/* PC interface to PC-com hardware. Done this way because PCW16 also
97uses PC-com hardware and doesn't have the same setup! */
98static const uart8250_interface com_interface[4]=
99{
100   {
101      TYPE8250,
102      1843200,
103      pc_com_interrupt,
104      NULL,
105      pc_com_refresh_connected
106   },
107   {
108      TYPE8250,
109      1843200,
110      pc_com_interrupt,
111      NULL,
112      pc_com_refresh_connected
113   },
114   {
115      TYPE8250,
116      1843200,
117      pc_com_interrupt,
118      NULL,
119      pc_com_refresh_connected
120   },
121   {
122      TYPE8250,
123      1843200,
124      pc_com_interrupt,
125      NULL,
126      pc_com_refresh_connected
127   }
128};
129#endif /* MESS */
130
131
132
13358static void pc_timer0_w(int state)
13459{
13560   pic8259_set_irq_line(0, 0, state);
13661}
13762
13863
139
14064/*
14165 * timer0   heartbeat IRQ
14266 * timer1   DRAM refresh (ignored)
r2186r2187
191115};
192116
193117
194#ifdef MESS
195static const PC_LPT_CONFIG lpt_config[3]={
196   {
197      1,
198      LPT_UNIDIRECTIONAL,
199      NULL
200   },
201   {
202      1,
203      LPT_UNIDIRECTIONAL,
204      NULL
205   },
206   {
207      1,
208      LPT_UNIDIRECTIONAL,
209      NULL
210   }
211};
212118
213static const CENTRONICS_CONFIG cent_config[3]={
214   {
215      PRINTER_IBM,
216      pc_lpt_handshake_in
217   },
218   {
219      PRINTER_IBM,
220      pc_lpt_handshake_in
221   },
222   {
223      PRINTER_IBM,
224      pc_lpt_handshake_in
225   }
226};
227#endif
228
229
230
231119/*************************************************************************
232120 *
233121 *      PC DMA stuff
r2186r2187
381269
382270/* ----------------------------------------------------------------------- */
383271
384#ifdef MESS
385static void pc_fdc_interrupt(int state)
386{
387   pic8259_set_irq_line(0, 6, state);
388}
389
390
391
392static void pc_fdc_dma_drq(int state, int read_)
393{
394   dma8237_drq_write(0, FDC_DMA, state);
395}
396
397
398
399static const struct pc_fdc_interface fdc_interface =
400{
401   NEC765A,
402   NEC765_RDY_PIN_CONNECTED,
403   pc_fdc_interrupt,
404   pc_fdc_dma_drq,
405};
406
407static const struct pc_fdc_interface fdc_interface_nc =
408{
409   NEC765A,
410   NEC765_RDY_PIN_NOT_CONNECTED,
411   pc_fdc_interrupt,
412   pc_fdc_dma_drq,
413};
414#endif /* MESS */
415
416
417
418/* ----------------------------------------------------------------------- */
419
420272static void pc_pic_set_int_line(int which, int interrupt)
421273{
422274   switch(which)
r2186r2187
437289
438290void init_pc_common(UINT32 flags)
439291{
440#ifdef MESS
441   /* MESS managed RAM */
442   if (mess_ram)
443      memory_set_bankptr(10, mess_ram);
444#endif /* MESS */
445
446292   /* PIT */
447293   if (flags & PCCOMMON_TIMER_8254)
448294      pit8253_init(1, &pc_pit8254_config);
449295   else if (flags & PCCOMMON_TIMER_8253)
450296      pit8253_init(1, &pc_pit8253_config);
451297
452#ifdef MESS
453   /* FDC/HDC hardware */
454   pc_fdc_init( ( flags & PCCOMMON_NEC765_RDY_NC ) ? &fdc_interface_nc : &fdc_interface);
455   pc_hdc_setup();
456
457   /* com hardware */
458   uart8250_init(0, com_interface);
459   uart8250_reset(0);
460   uart8250_init(1, com_interface+1);
461   uart8250_reset(1);
462   uart8250_init(2, com_interface+2);
463   uart8250_reset(2);
464   uart8250_init(3, com_interface+3);
465   uart8250_reset(3);
466
467   pc_lpt_config(0, lpt_config);
468   centronics_config(0, cent_config);
469   pc_lpt_set_device(0, &CENTRONICS_PRINTER_DEVICE);
470   pc_lpt_config(1, lpt_config+1);
471   centronics_config(1, cent_config+1);
472   pc_lpt_set_device(1, &CENTRONICS_PRINTER_DEVICE);
473   pc_lpt_config(2, lpt_config+2);
474   centronics_config(2, cent_config+2);
475   pc_lpt_set_device(2, &CENTRONICS_PRINTER_DEVICE);
476
477   /* serial mouse */
478   pc_mouse_set_serial_port(0);
479   pc_mouse_initialise();
480#endif /* MESS */
481
482298   /* PC-XT keyboard */
483299   if (flags & PCCOMMON_KEYBOARD_AT)
484300      at_keyboard_init(AT_KEYBOARD_TYPE_AT);
src/mess/includes/pc.h
r2186r2187
99
1010/*----------- defined in machine/pc.c -----------*/
1111
12void mess_init_pc_common(UINT32 flags);
13
1214DRIVER_INIT( pccga );
1315DRIVER_INIT( pcmda );
1416DRIVER_INIT( europc );
src/mess/machine/at.c
r2186r2187
2020#include "machine/pit8253.h"
2121#include "machine/pcshare.h"
2222#include "machine/8042kbdc.h"
23#include "includes/pc.h"
2324#include "includes/at.h"
2425#include "machine/pckeybrd.h"
2526#include "audio/sblaster.h"
r2186r2187
3940
4041static void init_at_common(const struct kbdc8042_interface *at8042)
4142{
42   init_pc_common(PCCOMMON_KEYBOARD_AT | PCCOMMON_DMA8237_AT | PCCOMMON_TIMER_8254);
43   mess_init_pc_common(PCCOMMON_KEYBOARD_AT | PCCOMMON_DMA8237_AT | PCCOMMON_TIMER_8254);
4344   mc146818_init(MC146818_STANDARD);
4445   soundblaster_config(&soundblaster);
4546   kbdc8042_init(at8042);
src/mess/machine/pc.c
r2186r2187
3636#include "includes/pclpt.h"
3737#include "machine/centroni.h"
3838
39#include "machine/pc_fdc.h"
3940#include "machine/pc_hdc.h"
4041#include "machine/nec765.h"
4142#include "includes/amstr_pc.h"
r2186r2187
4748#include "machine/8237dma.h"
4849
4950
51/**********************************************************
52 *
53 * COM hardware
54 *
55 **********************************************************/
56
57/* called when a interrupt is set/cleared from com hardware */
58static void pc_com_interrupt(int nr, int state)
59{
60   static const int irq[4] = {4, 3, 4, 3};
61
62   /* issue COM1/3 IRQ4, COM2/4 IRQ3 */
63   pic8259_set_irq_line(0, irq[nr], state);
64}
65
66/* called when com registers read/written - used to update peripherals that
67are connected */
68static void pc_com_refresh_connected(int n, int data)
69{
70   /* mouse connected to this port? */
71   if (readinputport(3) & (0x80>>n))
72      pc_mouse_handshake_in(n,data);
73}
74
75/* PC interface to PC-com hardware. Done this way because PCW16 also
76uses PC-com hardware and doesn't have the same setup! */
77static const uart8250_interface com_interface[4]=
78{
79   {
80      TYPE8250,
81      1843200,
82      pc_com_interrupt,
83      NULL,
84      pc_com_refresh_connected
85   },
86   {
87      TYPE8250,
88      1843200,
89      pc_com_interrupt,
90      NULL,
91      pc_com_refresh_connected
92   },
93   {
94      TYPE8250,
95      1843200,
96      pc_com_interrupt,
97      NULL,
98      pc_com_refresh_connected
99   },
100   {
101      TYPE8250,
102      1843200,
103      pc_com_interrupt,
104      NULL,
105      pc_com_refresh_connected
106   }
107};
108
109
110/**********************************************************
111 *
112 * LPT interface
113 *
114 **********************************************************/
115
116static const PC_LPT_CONFIG lpt_config[3]={
117   {
118      1,
119      LPT_UNIDIRECTIONAL,
120      NULL
121   },
122   {
123      1,
124      LPT_UNIDIRECTIONAL,
125      NULL
126   },
127   {
128      1,
129      LPT_UNIDIRECTIONAL,
130      NULL
131   }
132};
133
134static const CENTRONICS_CONFIG cent_config[3]={
135   {
136      PRINTER_IBM,
137      pc_lpt_handshake_in
138   },
139   {
140      PRINTER_IBM,
141      pc_lpt_handshake_in
142   },
143   {
144      PRINTER_IBM,
145      pc_lpt_handshake_in
146   }
147};
148
149
150
151/**********************************************************
152 *
153 * NEC uPD765 floppy interface
154 *
155 **********************************************************/
156
157#define FDC_DMA 2
158
159static void pc_fdc_interrupt(int state)
160{
161   pic8259_set_irq_line(0, 6, state);
162}
163
164static void pc_fdc_dma_drq(int state, int read_)
165{
166   dma8237_drq_write(0, FDC_DMA, state);
167}
168
169static const struct pc_fdc_interface fdc_interface =
170{
171   NEC765A,
172   NEC765_RDY_PIN_CONNECTED,
173   pc_fdc_interrupt,
174   pc_fdc_dma_drq,
175};
176
177static const struct pc_fdc_interface fdc_interface_nc =
178{
179   NEC765A,
180   NEC765_RDY_PIN_NOT_CONNECTED,
181   pc_fdc_interrupt,
182   pc_fdc_dma_drq,
183};
184
185
186void mess_init_pc_common(UINT32 flags) {
187   init_pc_common(flags);
188
189   /* MESS managed RAM */
190   if ( mess_ram )
191      memory_set_bankptr( 10, mess_ram );
192
193   /* FDC/HDC hardware */
194   pc_fdc_init( ( flags & PCCOMMON_NEC765_RDY_NC ) ? &fdc_interface_nc : &fdc_interface);
195   pc_hdc_setup();
196
197   /* com hardware */
198   uart8250_init(0, com_interface);
199   uart8250_reset(0);
200   uart8250_init(1, com_interface+1);
201   uart8250_reset(1);
202   uart8250_init(2, com_interface+2);
203   uart8250_reset(2);
204   uart8250_init(3, com_interface+3);
205   uart8250_reset(3);
206
207   pc_lpt_config(0, lpt_config);
208   centronics_config(0, cent_config);
209   pc_lpt_set_device(0, &CENTRONICS_PRINTER_DEVICE);
210   pc_lpt_config(1, lpt_config+1);
211   centronics_config(1, cent_config+1);
212   pc_lpt_set_device(1, &CENTRONICS_PRINTER_DEVICE);
213   pc_lpt_config(2, lpt_config+2);
214   centronics_config(2, cent_config+2);
215   pc_lpt_set_device(2, &CENTRONICS_PRINTER_DEVICE);
216
217   /* serial mouse */
218   pc_mouse_set_serial_port(0);
219   pc_mouse_initialise();
220}
221
50222DRIVER_INIT( pccga )
51223{
52   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
224   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
53225   ppi8255_init(&pc_ppi8255_interface);
54226   pc_rtc_init();
55227   pc_turbo_setup(0, 3, 0x02, 4.77/12, 1);
r2186r2187
57229
58230DRIVER_INIT( bondwell )
59231{
60   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
232   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
61233   ppi8255_init(&pc_ppi8255_interface);
62234   pc_turbo_setup(0, 3, 0x02, 4.77/12, 1);
63235}
64236
65237DRIVER_INIT( pcmda )
66238{
67   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
239   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
68240   ppi8255_init(&pc_ppi8255_interface);
69241   pc_turbo_setup(0, 3, 0x02, 4.77/12, 1);
70242}
r2186r2187
90262      rom[0xfffff]=256-a;
91263   }
92264
93   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
265   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
94266
95267   europc_rtc_init();
96268//   europc_rtc_set_time(machine);
r2186r2187
103275    /* just a plain bit pattern for graphics data generation */
104276    for (i = 0; i < 256; i++)
105277      gfx[i] = i;
106   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
278   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
107279   pc_turbo_setup(0, 3, 0x02, 4.77/12, 1);
108280}
109281
r2186r2187
122294   videoram=memory_region(REGION_CPU1)+0xb0000;
123295   memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x278, 0x27b, 0, 0, pc200_16le_port378_r );
124296
125   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
297   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
126298}
127299
128300DRIVER_INIT( pc1512 )
r2186r2187
143315   memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x278, 0x27b, 0, 0, pc16le_parallelport2_r );
144316
145317
146   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
318   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
147319   mc146818_init(MC146818_IGNORE_CENTURY);
148320}
149321
r2186r2187
206378   memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x278, 0x27b, 0, 0, pc1640_16le_port278_r );
207379   memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x4278, 0x427b, 0, 0, pc1640_16le_port4278_r );
208380
209   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
381   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
210382
211383   mc146818_init(MC146818_IGNORE_CENTURY);
212384}
213385
214386DRIVER_INIT( pc_vga )
215387{
216   init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
388   mess_init_pc_common(PCCOMMON_KEYBOARD_PC | PCCOMMON_DMA8237_PC | PCCOMMON_TIMER_8253 | PCCOMMON_NEC765_RDY_NC);
217389   ppi8255_init(&pc_ppi8255_interface);
218390
219391   pc_vga_init(&vga_interface, NULL);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team