Commit 2122c51a9c9d5935773d3a542248bd8f369b172c

Authored by bellard
1 parent f8d179e3

char dev ioctls


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1610 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 2 changed files with 29 additions and 10 deletions
hw/serial.c
... ... @@ -107,6 +107,7 @@ static void serial_update_irq(SerialState *s)
107 107 static void serial_update_parameters(SerialState *s)
108 108 {
109 109 int speed, parity, data_bits, stop_bits;
  110 + QEMUSerialSetParams ssp;
110 111  
111 112 if (s->lcr & 0x08) {
112 113 if (s->lcr & 0x10)
... ... @@ -124,7 +125,12 @@ static void serial_update_parameters(SerialState *s)
124 125 if (s->divider == 0)
125 126 return;
126 127 speed = 115200 / s->divider;
127   -#if 0
  128 + ssp.speed = speed;
  129 + ssp.parity = parity;
  130 + ssp.data_bits = data_bits;
  131 + ssp.stop_bits = stop_bits;
  132 + qemu_chr_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
  133 +#if 0
128 134 printf("speed=%d parity=%c data=%d stop=%d\n",
129 135 speed, parity, data_bits, stop_bits);
130 136 #endif
... ... @@ -179,7 +185,8 @@ static void serial_ioport_write(void *opaque, uint32_t addr, uint32_t val)
179 185 break_enable = (val >> 6) & 1;
180 186 if (break_enable != s->last_break_enable) {
181 187 s->last_break_enable = break_enable;
182   - qemu_chr_set_serial_break(s, break_enable);
  188 + qemu_chr_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_BREAK,
  189 + &break_enable);
183 190 }
184 191 }
185 192 break;
... ...
... ... @@ -200,6 +200,24 @@ void qemu_del_fd_read_handler(int fd);
200 200 #define CHR_EVENT_BREAK 0 /* serial break char */
201 201 #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
202 202  
  203 +
  204 +
  205 +#define CHR_IOCTL_SERIAL_SET_PARAMS 1
  206 +typedef struct {
  207 + int speed;
  208 + int parity;
  209 + int data_bits;
  210 + int stop_bits;
  211 +} QEMUSerialSetParams;
  212 +
  213 +#define CHR_IOCTL_SERIAL_SET_BREAK 2
  214 +
  215 +#define CHR_IOCTL_PP_READ_DATA 3
  216 +#define CHR_IOCTL_PP_WRITE_DATA 4
  217 +#define CHR_IOCTL_PP_READ_CONTROL 5
  218 +#define CHR_IOCTL_PP_WRITE_CONTROL 6
  219 +#define CHR_IOCTL_PP_READ_STATUS 7
  220 +
203 221 typedef void IOEventHandler(void *opaque, int event);
204 222  
205 223 typedef struct CharDriverState {
... ... @@ -207,10 +225,7 @@ typedef struct CharDriverState {
207 225 void (*chr_add_read_handler)(struct CharDriverState *s,
208 226 IOCanRWHandler *fd_can_read,
209 227 IOReadHandler *fd_read, void *opaque);
210   - void (*chr_set_serial_parameters)(struct CharDriverState *s,
211   - int speed, int parity,
212   - int data_bits, int stop_bits);
213   - void (*chr_set_serial_break)(struct CharDriverState *s, int enable);
  228 + int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
214 229 IOEventHandler *chr_event;
215 230 void (*chr_send_event)(struct CharDriverState *chr, int event);
216 231 void *opaque;
... ... @@ -223,10 +238,7 @@ void qemu_chr_add_read_handler(CharDriverState *s,
223 238 IOCanRWHandler *fd_can_read,
224 239 IOReadHandler *fd_read, void *opaque);
225 240 void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
226   -void qemu_chr_set_serial_parameters(CharDriverState *s,
227   - int speed, int parity,
228   - int data_bits, int stop_bits);
229   -void qemu_chr_set_serial_break(CharDriverState *s, int enable);
  241 +int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
230 242  
231 243 /* consoles */
232 244  
... ...