char dev ioctls

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1610 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2005-11-10 23:58:33 +00:00
parent f8d179e33d
commit 2122c51a9c
2 changed files with 29 additions and 10 deletions

View File

@ -107,6 +107,7 @@ static void serial_update_irq(SerialState *s)
static void serial_update_parameters(SerialState *s) static void serial_update_parameters(SerialState *s)
{ {
int speed, parity, data_bits, stop_bits; int speed, parity, data_bits, stop_bits;
QEMUSerialSetParams ssp;
if (s->lcr & 0x08) { if (s->lcr & 0x08) {
if (s->lcr & 0x10) if (s->lcr & 0x10)
@ -124,7 +125,12 @@ static void serial_update_parameters(SerialState *s)
if (s->divider == 0) if (s->divider == 0)
return; return;
speed = 115200 / s->divider; speed = 115200 / s->divider;
#if 0 ssp.speed = speed;
ssp.parity = parity;
ssp.data_bits = data_bits;
ssp.stop_bits = stop_bits;
qemu_chr_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_PARAMS, &ssp);
#if 0
printf("speed=%d parity=%c data=%d stop=%d\n", printf("speed=%d parity=%c data=%d stop=%d\n",
speed, parity, data_bits, stop_bits); speed, parity, data_bits, stop_bits);
#endif #endif
@ -179,7 +185,8 @@ static void serial_ioport_write(void *opaque, uint32_t addr, uint32_t val)
break_enable = (val >> 6) & 1; break_enable = (val >> 6) & 1;
if (break_enable != s->last_break_enable) { if (break_enable != s->last_break_enable) {
s->last_break_enable = break_enable; s->last_break_enable = break_enable;
qemu_chr_set_serial_break(s, break_enable); qemu_chr_ioctl(s->chr, CHR_IOCTL_SERIAL_SET_BREAK,
&break_enable);
} }
} }
break; break;

28
vl.h
View File

@ -200,6 +200,24 @@ void qemu_del_fd_read_handler(int fd);
#define CHR_EVENT_BREAK 0 /* serial break char */ #define CHR_EVENT_BREAK 0 /* serial break char */
#define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */ #define CHR_EVENT_FOCUS 1 /* focus to this terminal (modal input needed) */
#define CHR_IOCTL_SERIAL_SET_PARAMS 1
typedef struct {
int speed;
int parity;
int data_bits;
int stop_bits;
} QEMUSerialSetParams;
#define CHR_IOCTL_SERIAL_SET_BREAK 2
#define CHR_IOCTL_PP_READ_DATA 3
#define CHR_IOCTL_PP_WRITE_DATA 4
#define CHR_IOCTL_PP_READ_CONTROL 5
#define CHR_IOCTL_PP_WRITE_CONTROL 6
#define CHR_IOCTL_PP_READ_STATUS 7
typedef void IOEventHandler(void *opaque, int event); typedef void IOEventHandler(void *opaque, int event);
typedef struct CharDriverState { typedef struct CharDriverState {
@ -207,10 +225,7 @@ typedef struct CharDriverState {
void (*chr_add_read_handler)(struct CharDriverState *s, void (*chr_add_read_handler)(struct CharDriverState *s,
IOCanRWHandler *fd_can_read, IOCanRWHandler *fd_can_read,
IOReadHandler *fd_read, void *opaque); IOReadHandler *fd_read, void *opaque);
void (*chr_set_serial_parameters)(struct CharDriverState *s, int (*chr_ioctl)(struct CharDriverState *s, int cmd, void *arg);
int speed, int parity,
int data_bits, int stop_bits);
void (*chr_set_serial_break)(struct CharDriverState *s, int enable);
IOEventHandler *chr_event; IOEventHandler *chr_event;
void (*chr_send_event)(struct CharDriverState *chr, int event); void (*chr_send_event)(struct CharDriverState *chr, int event);
void *opaque; void *opaque;
@ -223,10 +238,7 @@ void qemu_chr_add_read_handler(CharDriverState *s,
IOCanRWHandler *fd_can_read, IOCanRWHandler *fd_can_read,
IOReadHandler *fd_read, void *opaque); IOReadHandler *fd_read, void *opaque);
void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event); void qemu_chr_add_event_handler(CharDriverState *s, IOEventHandler *chr_event);
void qemu_chr_set_serial_parameters(CharDriverState *s, int qemu_chr_ioctl(CharDriverState *s, int cmd, void *arg);
int speed, int parity,
int data_bits, int stop_bits);
void qemu_chr_set_serial_break(CharDriverState *s, int enable);
/* consoles */ /* consoles */