Previous 15994 Revisions Next

r3905 Saturday 20th December, 2008 at 10:00:27 UTC by Miodrag Milanović
More deprecat.h removal
[src/mess/includes]serial.h
[src/mess/machine]6551.c msm8251.c pmd85.c serial.c thomson.c

src/mess/includes/serial.h
r3904r3905
123123
124124   /* this callback is executed when this side has refreshed it's state,
125125    to let the other end know */
126   void   (*out_callback)(int id, unsigned long state);
126   void   (*out_callback)(running_machine *machine, int id, unsigned long state);
127127   /* this callback is executed when the other side has refreshed it's state,
128128    to let the other end know */
129   void   (*in_callback)(int id, unsigned long state);
129   void   (*in_callback)(running_machine *machine, int id, unsigned long state);
130130};
131131
132132/*----------- defined in machine/serial.c -----------*/
133133
134134/* setup out and in callbacks */
135void serial_connection_init(struct serial_connection *connection);
135void serial_connection_init(running_machine *machine, struct serial_connection *connection);
136136
137137/* set callback which will be executed when out status has changed */
138void serial_connection_set_out_callback(struct serial_connection *connection, void (*out_cb)(int id, unsigned long state));
138void serial_connection_set_out_callback(running_machine *machine, struct serial_connection *connection, void (*out_cb)(running_machine *machine, int id, unsigned long state));
139139
140140/* set callback which will be executed when in status has changed */
141void serial_connection_set_in_callback(struct serial_connection *connection, void (*in_cb)(int id, unsigned long state));
141void serial_connection_set_in_callback(running_machine *machine, struct serial_connection *connection, void (*in_cb)(running_machine *machine, int id, unsigned long state));
142142
143143/* output status, if callback is setup it will be executed with the new status */
144void serial_connection_out(struct serial_connection *connection);
144void serial_connection_out(running_machine *machine, struct serial_connection *connection);
145145
146146/* join two serial connections */
147void serial_connection_link(struct serial_connection *connection_a, struct serial_connection *connection_b);
147void serial_connection_link(running_machine *machine, struct serial_connection *connection_a, struct serial_connection *connection_b);
148148
149149
150150/*******************************************************************************/
r3904r3905
225225int transmit_register_get_data_bit(struct serial_transmit_register *transmit_reg);
226226/* setup transmit reg ready for transmit */
227227void transmit_register_setup(struct serial_transmit_register *transmit_reg, struct data_form *data_form,unsigned char data_byte);
228void   transmit_register_send_bit(struct serial_transmit_register *transmit_reg, struct serial_connection *connection);
228void   transmit_register_send_bit(running_machine *machine, struct serial_transmit_register *transmit_reg, struct serial_connection *connection);
229229void   transmit_register_reset(struct serial_transmit_register *transmit_reg);
230230
231231/*******************************************************************************/
src/mess/machine/serial.c
r3904r3905
8181   return serial_parity_table[data & 0x0ff];
8282}
8383
84static void serial_device_in_callback(int id, unsigned long status)
84static void serial_device_in_callback(running_machine *machine, int id, unsigned long status)
8585{
8686   serial_devices[id].connection.input_state = status;
8787}
r3904r3905
124124   serial_devices[id].data_form.parity = parity_code;
125125   serial_devices[id].timer = timer_alloc(image->machine, serial_device_baud_rate_callback, NULL);
126126
127   serial_connection_init(&serial_devices[id].connection);
128   serial_connection_set_in_callback(&serial_devices[id].connection, serial_device_in_callback);
127   serial_connection_init(image->machine, &serial_devices[id].connection);
128   serial_connection_set_in_callback(image->machine, &serial_devices[id].connection, serial_device_in_callback);
129129
130130   /* signal to other end it is clear to send! */
131131   /* data is initially high state */
r3904r3905
135135   /* set /dtr */
136136   serial_devices[id].connection.State |= SERIAL_STATE_DTR;
137137   set_out_data_bit(serial_devices[id].connection.State, 1);
138   serial_connection_out(&serial_devices[id].connection);
138   serial_connection_out(image->machine,&serial_devices[id].connection);
139139   transmit_register_reset(&serial_devices[id].transmit_reg);
140140   receive_register_reset(&serial_devices[id].receive_reg);
141141   receive_register_setup(&serial_devices[id].receive_reg, &serial_devices[id].data_form);
r3904r3905
495495   return bit;
496496}
497497
498void   transmit_register_send_bit(struct serial_transmit_register *transmit_reg, struct serial_connection *connection)
498void   transmit_register_send_bit(running_machine *machine, struct serial_transmit_register *transmit_reg, struct serial_connection *connection)
499499{
500500   int data;
501501
r3904r3905
505505   set_out_data_bit(connection->State, data);
506506
507507   /* state out through connection */
508   serial_connection_out(connection);
508   serial_connection_out(machine, connection);
509509}
510510
511511void serial_protocol_none_sent_char(int id)
r3904r3905
559559   if (serial_devices[id].connection.input_state & SERIAL_STATE_CTS)
560560   {
561561      /* send bit */
562      transmit_register_send_bit(&serial_devices[id].transmit_reg, &serial_devices[id].connection);
562      transmit_register_send_bit(machine, &serial_devices[id].transmit_reg, &serial_devices[id].connection);
563563   }
564564}
565565
r3904r3905
572572   if ((id<0) || (id>=MAX_SERIAL_DEVICES))
573573      return;
574574
575   serial_connection_link(connection, &serial_devices[id].connection);
575   serial_connection_link(image->machine, connection, &serial_devices[id].connection);
576576}
577577
578578
r3904r3905
906906
907907
908908/* setup callbacks for connection */
909void   serial_connection_init(struct serial_connection *connection)
909void   serial_connection_init(running_machine *machine, struct serial_connection *connection)
910910{
911911   connection->out_callback = NULL;
912912   connection->in_callback = NULL;
913913}
914914
915915/* set callback which will be executed when out status has changed */
916void   serial_connection_set_out_callback(struct serial_connection *connection, void (*out_cb)(int id, unsigned long state))
916void   serial_connection_set_out_callback(running_machine *machine, struct serial_connection *connection, void (*out_cb)(running_machine *machine, int id, unsigned long state))
917917{
918918   connection->out_callback = out_cb;
919919}
920920
921921/* set callback which will be executed when in status has changed */
922void   serial_connection_set_in_callback(struct serial_connection *connection, void (*in_cb)(int id, unsigned long state))
922void   serial_connection_set_in_callback(running_machine *machine, struct serial_connection *connection, void (*in_cb)(running_machine *machine, int id, unsigned long state))
923923{
924924   connection->in_callback = in_cb;
925925}
926926
927927/* output new state through connection */
928void   serial_connection_out(struct serial_connection *connection)
928void   serial_connection_out(running_machine *machine, struct serial_connection *connection)
929929{
930930   if (connection->out_callback!=NULL)
931931   {
r3904r3905
933933
934934      state_at_other_end = serial_connection_spin_bits(connection->State);
935935
936      connection->out_callback(connection->id, state_at_other_end);
936      connection->out_callback(machine, connection->id, state_at_other_end);
937937   }
938938}
939939
940940/* join two serial connections together */
941void   serial_connection_link(struct serial_connection *connection_a, struct serial_connection *connection_b)
941void   serial_connection_link(running_machine *machine, struct serial_connection *connection_a, struct serial_connection *connection_b)
942942{
943943   /* both connections should have their in connection setup! */
944944   /* the in connection is the callback they use to update their state based
r3904r3905
947947   connection_b->out_callback = connection_a->in_callback;
948948
949949   /* let b know the state of a */
950   serial_connection_out(connection_a);
950   serial_connection_out(machine,connection_a);
951951   /* let a know the state of b */
952   serial_connection_out(connection_b);
952   serial_connection_out(machine,connection_b);
953953}
src/mess/machine/thomson.c
r3904r3905
770770      to7_io_line.State &= ~SERIAL_STATE_DTR;
771771
772772   set_out_data_bit( to7_io_line.State, tx );
773   serial_connection_out( &to7_io_line );
773   serial_connection_out( space->machine, &to7_io_line );
774774}
775775
776776
r3904r3905
815815
816816
817817
818static void to7_io_in_cb ( int id, unsigned long state )
818static void to7_io_in_cb ( running_machine *machine, int id, unsigned long state )
819819{
820820   /* our peer's state has changed */
821821   to7_io_line.input_state = state;
822822
823   //LOG_IO(( "%f to7_io_in_callback:  cts=%i dsr=%i rd=%i\n", attotime_to_double(timer_get_time(machine)), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) ));
823   LOG_IO(( "%f to7_io_in_callback:  cts=%i dsr=%i rd=%i\n", attotime_to_double(timer_get_time(machine)), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) ));
824824}
825825
826826
r3904r3905
861861   to7_io_line.State &= ~SERIAL_STATE_DTR;
862862   to7_io_line.State |=  SERIAL_STATE_RTS;  /* always ready to send */
863863   set_out_data_bit( to7_io_line.State, 1 );
864   serial_connection_out( &to7_io_line );
864   serial_connection_out( machine, &to7_io_line );
865865}
866866
867867
r3904r3905
871871   LOG (( "to7_io_init: CC 90-323 serial / parallel extension\n" ));
872872   pia_config( machine, THOM_PIA_IO, &to7_io );
873873   centronics_config( machine, 0, &to7_centronics );
874   serial_connection_init( &to7_io_line );
875   serial_connection_set_in_callback( &to7_io_line, to7_io_in_cb );
874   serial_connection_init( machine, &to7_io_line );
875   serial_connection_set_in_callback( machine, &to7_io_line, to7_io_in_cb );
876876}
877877
878878
src/mess/machine/pmd85.c
r3904r3905
762762
763763static struct serial_connection pmd85_cassette_serial_connection;
764764
765static void pmd85_cassette_write(int id, unsigned long state)
765static void pmd85_cassette_write(running_machine *machine, int id, unsigned long state)
766766{
767767   pmd85_cassette_serial_connection.input_state = state;
768768}
r3904r3905
797797                     data = (!previous_level && current_level) ? 1 : 0;
798798
799799                     set_out_data_bit(pmd85_cassette_serial_connection.State, data);
800                     serial_connection_out(&pmd85_cassette_serial_connection);
800                     serial_connection_out(machine, &pmd85_cassette_serial_connection);
801801                     msm8251_receive_clock(device_list_find_by_tag( machine->config->devicelist, MSM8251, "uart" ));
802802
803803                     clk_level_tape = 1;
r3904r3905
854854   pmd85_cassette_timer = timer_alloc(machine, pmd85_cassette_timer_callback, NULL);
855855   timer_adjust_periodic(pmd85_cassette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(2400));
856856
857   serial_connection_init(&pmd85_cassette_serial_connection);
858   serial_connection_set_in_callback(&pmd85_cassette_serial_connection, pmd85_cassette_write);
857   serial_connection_init(machine, &pmd85_cassette_serial_connection);
858   serial_connection_set_in_callback(machine, &pmd85_cassette_serial_connection, pmd85_cassette_write);
859859}
860860
861861DRIVER_INIT ( pmd851 )
src/mess/machine/6551.c
r3904r3905
1313*********************************************************************/
1414
1515#include "driver.h"
16#include "deprecat.h"
1716#include "6551.h"
1817#include "includes/serial.h"
1918
r3904r3905
7978   has updated state
8079-------------------------------------------------*/
8180
82static void acia_6551_in_callback(int id, unsigned long state)
81static void acia_6551_in_callback(running_machine *machine, int id, unsigned long state)
8382{
8483   const device_config *device;
8584   acia6551_t *acia;
8685
8786   /* NPW 29-Nov-2008 - These two lines are a hack and indicate why our "serial" infrastructure needs to be updated */
88   device = device_list_find_by_tag(Machine->config->devicelist, ACIA6551, "acia");
87   device = device_list_find_by_tag(machine->config->devicelist, ACIA6551, "acia");
8988   acia = get_token(device);
9089
9190   acia->connection.input_state = state;
r3904r3905
130129   if ((acia->transmit_reg.flags & TRANSMIT_REGISTER_EMPTY)==0)
131130   {
132131   //   logerror("UART6551\n");
133      transmit_register_send_bit(&acia->transmit_reg, &acia->connection);
132      transmit_register_send_bit(machine, &acia->transmit_reg, &acia->connection);
134133   }
135134}
136135
r3904r3905
151150   acia->status_register |= (1<<4);
152151   acia->timer = timer_alloc(device->machine, acia_6551_timer_callback, (void *) device);
153152
154   serial_connection_init(&acia->connection);
155   serial_connection_set_in_callback(&acia->connection, acia_6551_in_callback);
153   serial_connection_init(device->machine, &acia->connection);
154   serial_connection_set_in_callback(device->machine, &acia->connection, acia_6551_in_callback);
156155   transmit_register_reset(&acia->transmit_reg);
157156   receive_register_reset(&acia->receive_reg);
158157   return DEVICE_START_OK;
r3904r3905
398397            break;
399398         }
400399
401         serial_connection_out(&acia->connection);
400         serial_connection_out(device->machine, &acia->connection);
402401
403402         acia_6551_update_data_form(device);
404403      }
src/mess/machine/msm8251.c
r3904r3905
77*********************************************************************/
88
99#include "driver.h"
10#include "deprecat.h"
1110#include "msm8251.h"
1211#include "includes/serial.h"
1312
r3904r3905
6463***************************************************************************/
6564
6665static void msm8251_receive_character(const device_config *device, UINT8 ch);
67static void msm8251_in_callback(int id, unsigned long state);
66static void msm8251_in_callback(running_machine *machine, int id, unsigned long state);
6867static void msm8251_update_tx_empty(const device_config *device);
6968static void msm8251_update_tx_ready(const device_config *device);
7069
r3904r3905
10099    msm8251_in_callback
101100-------------------------------------------------*/
102101
103static void msm8251_in_callback(int id, unsigned long state)
102static void msm8251_in_callback(running_machine *machine, int id, unsigned long state)
104103{
105104   const device_config *device;
106105   msm8251_t *uart;
107106   int changed;
108107
109108   /* NPW 29-Nov-2008 - These two lines are a hack and indicate why our "serial" infrastructure needs to be updated */
110   device = device_list_find_by_tag(Machine->config->devicelist, MSM8251, "uart");
109   device = device_list_find_by_tag(machine->config->devicelist, MSM8251, "uart");
111110   uart = get_token(device);
112111
113112   changed = uart->connection.input_state^state;
r3904r3905
136135   serial_helper_setup();
137136
138137   /* setup this side of the serial connection */
139   serial_connection_init(&uart->connection);
140   serial_connection_set_in_callback(&uart->connection, msm8251_in_callback);
138   serial_connection_init(device->machine,&uart->connection);
139   serial_connection_set_in_callback(device->machine,&uart->connection, msm8251_in_callback);
141140   uart->connection.input_state = 0;
142141   return DEVICE_START_OK;
143142}
r3904r3905
228227      if ((uart->transmit_reg.flags & TRANSMIT_REGISTER_EMPTY)==0)
229228      {
230229   //      logerror("MSM8251\n");
231         transmit_register_send_bit(&uart->transmit_reg, &uart->connection);
230         transmit_register_send_bit(device->machine,&uart->transmit_reg, &uart->connection);
232231      }
233232   }
234233
r3904r3905
315314   {
316315      /* tx is in marking state (high) when tx empty! */
317316      set_out_data_bit(uart->connection.State, 1);
318      serial_connection_out(&uart->connection);
317      serial_connection_out(device->machine,&uart->connection);
319318   }
320319
321320   if (uart_interface->tx_empty_callback != NULL)
r3904r3905
342341
343342   /* assumption, rts is set to 1 */
344343   uart->connection.State &= ~SERIAL_STATE_RTS;
345   serial_connection_out(&uart->connection);
344   serial_connection_out(device->machine, &uart->connection);
346345
347346   transmit_register_reset(&uart->transmit_reg);
348347   receive_register_reset(&uart->receive_reg);
r3904r3905
659658
660659
661660      /* refresh outputs */
662      serial_connection_out(&uart->connection);
661      serial_connection_out(device->machine, &uart->connection);
663662
664663      if (data & (1<<4))
665664      {
r3904r3905
780779void msm8251_connect(const device_config *device, struct serial_connection *other_connection)
781780{
782781   msm8251_t *uart = get_token(device);
783   serial_connection_link(&uart->connection, other_connection);
782   serial_connection_link(device->machine, &uart->connection, other_connection);
784783}
785784
786785

Previous 15994 Revisions Next


© 1998-2018 The MESS Team