2 * QEMU ESCC (Z8030/Z8530/Z85C30/SCC/ESCC) serial port emulation
4 * Copyright (c) 2003-2005 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 #include "qemu/osdep.h"
27 #include "hw/sysbus.h"
28 #include "hw/char/escc.h"
29 #include "ui/console.h"
34 * "Z80C30/Z85C30/Z80230/Z85230/Z85233 SCC/ESCC User Manual",
35 * http://www.zilog.com/docs/serial/scc_escc_um.pdf
37 * On Sparc32 this is the serial port, mouse and keyboard part of chip STP2001
38 * (Slave I/O), also produced as NCR89C105. See
39 * http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
41 * The serial ports implement full AMD AM8530 or Zilog Z8530 chips,
42 * mouse and keyboard ports don't implement all functions and they are
43 * only asynchronous. There is no DMA.
45 * Z85C30 is also used on PowerMacs. There are some small differences
46 * between Sparc version (sunzilog) and PowerMac (pmac):
47 * Offset between control and data registers
48 * There is some kind of lockup bug, but we can ignore it
50 * DMA on pmac using DBDMA chip
51 * pmac can do IRDA and faster rates, sunzilog can only do 38400
52 * pmac baud rate generator clock is 3.6864 MHz, sunzilog 4.9152 MHz
57 * 2006-Aug-10 Igor Kovalenko : Renamed KBDQueue to SERIOQueue, implemented
59 * Implemented serial mouse protocol.
61 * 2010-May-23 Artyom Tarasenko: Reworked IUS logic
64 #define CHN_C(s) ((s)->chn == escc_chn_b ? 'b' : 'a')
70 #define CMD_PTR_MASK 0x07
71 #define CMD_CMD_MASK 0x38
73 #define CMD_CLR_TXINT 0x28
74 #define CMD_CLR_IUS 0x38
76 #define INTR_INTALL 0x01
77 #define INTR_TXINT 0x02
78 #define INTR_RXMODEMSK 0x18
79 #define INTR_RXINT1ST 0x08
80 #define INTR_RXINTALL 0x10
83 #define RXCTRL_RXEN 0x01
85 #define TXCTRL1_PAREN 0x01
86 #define TXCTRL1_PAREV 0x02
87 #define TXCTRL1_1STOP 0x04
88 #define TXCTRL1_1HSTOP 0x08
89 #define TXCTRL1_2STOP 0x0c
90 #define TXCTRL1_STPMSK 0x0c
91 #define TXCTRL1_CLK1X 0x00
92 #define TXCTRL1_CLK16X 0x40
93 #define TXCTRL1_CLK32X 0x80
94 #define TXCTRL1_CLK64X 0xc0
95 #define TXCTRL1_CLKMSK 0xc0
97 #define TXCTRL2_TXEN 0x08
98 #define TXCTRL2_BITMSK 0x60
99 #define TXCTRL2_5BITS 0x00
100 #define TXCTRL2_7BITS 0x20
101 #define TXCTRL2_6BITS 0x40
102 #define TXCTRL2_8BITS 0x60
107 #define MINTR_STATUSHI 0x10
108 #define MINTR_RST_MASK 0xc0
109 #define MINTR_RST_B 0x40
110 #define MINTR_RST_A 0x80
111 #define MINTR_RST_ALL 0xc0
114 #define CLOCK_TRXC 0x08
118 #define MISC2_PLLDIS 0x30
120 #define EXTINT_DCD 0x08
121 #define EXTINT_SYNCINT 0x10
122 #define EXTINT_CTSINT 0x20
123 #define EXTINT_TXUNDRN 0x40
124 #define EXTINT_BRKINT 0x80
127 #define STATUS_RXAV 0x01
128 #define STATUS_ZERO 0x02
129 #define STATUS_TXEMPTY 0x04
130 #define STATUS_DCD 0x08
131 #define STATUS_SYNC 0x10
132 #define STATUS_CTS 0x20
133 #define STATUS_TXUNDRN 0x40
134 #define STATUS_BRK 0x80
136 #define SPEC_ALLSENT 0x01
137 #define SPEC_BITS8 0x06
139 #define IVEC_TXINTB 0x00
140 #define IVEC_LONOINT 0x06
141 #define IVEC_LORXINTA 0x0c
142 #define IVEC_LORXINTB 0x04
143 #define IVEC_LOTXINTA 0x08
144 #define IVEC_HINOINT 0x60
145 #define IVEC_HIRXINTA 0x30
146 #define IVEC_HIRXINTB 0x20
147 #define IVEC_HITXINTA 0x10
149 #define INTR_EXTINTB 0x01
150 #define INTR_TXINTB 0x02
151 #define INTR_RXINTB 0x04
152 #define INTR_EXTINTA 0x08
153 #define INTR_TXINTA 0x10
154 #define INTR_RXINTA 0x20
168 static void handle_kbd_command(ESCCChannelState
*s
, int val
);
169 static int serial_can_receive(void *opaque
);
170 static void serial_receive_byte(ESCCChannelState
*s
, int ch
);
172 static void clear_queue(void *opaque
)
174 ESCCChannelState
*s
= opaque
;
175 ESCCSERIOQueue
*q
= &s
->queue
;
176 q
->rptr
= q
->wptr
= q
->count
= 0;
179 static void put_queue(void *opaque
, int b
)
181 ESCCChannelState
*s
= opaque
;
182 ESCCSERIOQueue
*q
= &s
->queue
;
184 trace_escc_put_queue(CHN_C(s
), b
);
185 if (q
->count
>= ESCC_SERIO_QUEUE_SIZE
) {
188 q
->data
[q
->wptr
] = b
;
189 if (++q
->wptr
== ESCC_SERIO_QUEUE_SIZE
) {
193 serial_receive_byte(s
, 0);
196 static uint32_t get_queue(void *opaque
)
198 ESCCChannelState
*s
= opaque
;
199 ESCCSERIOQueue
*q
= &s
->queue
;
205 val
= q
->data
[q
->rptr
];
206 if (++q
->rptr
== ESCC_SERIO_QUEUE_SIZE
) {
211 trace_escc_get_queue(CHN_C(s
), val
);
213 serial_receive_byte(s
, 0);
217 static int escc_update_irq_chn(ESCCChannelState
*s
)
219 if ((((s
->wregs
[W_INTR
] & INTR_TXINT
) && (s
->txint
== 1)) ||
220 // tx ints enabled, pending
221 ((((s
->wregs
[W_INTR
] & INTR_RXMODEMSK
) == INTR_RXINT1ST
) ||
222 ((s
->wregs
[W_INTR
] & INTR_RXMODEMSK
) == INTR_RXINTALL
)) &&
223 s
->rxint
== 1) || // rx ints enabled, pending
224 ((s
->wregs
[W_EXTINT
] & EXTINT_BRKINT
) &&
225 (s
->rregs
[R_STATUS
] & STATUS_BRK
)))) { // break int e&p
231 static void escc_update_irq(ESCCChannelState
*s
)
235 irq
= escc_update_irq_chn(s
);
236 irq
|= escc_update_irq_chn(s
->otherchn
);
238 trace_escc_update_irq(irq
);
239 qemu_set_irq(s
->irq
, irq
);
242 static void escc_reset_chn(ESCCChannelState
*s
)
247 for (i
= 0; i
< ESCC_SERIAL_REGS
; i
++) {
251 s
->wregs
[W_TXCTRL1
] = TXCTRL1_1STOP
; // 1X divisor, 1 stop bit, no parity
252 s
->wregs
[W_MINTR
] = MINTR_RST_ALL
;
253 s
->wregs
[W_CLOCK
] = CLOCK_TRXC
; // Synch mode tx clock = TRxC
254 s
->wregs
[W_MISC2
] = MISC2_PLLDIS
; // PLL disabled
255 s
->wregs
[W_EXTINT
] = EXTINT_DCD
| EXTINT_SYNCINT
| EXTINT_CTSINT
|
256 EXTINT_TXUNDRN
| EXTINT_BRKINT
; // Enable most interrupts
258 s
->rregs
[R_STATUS
] = STATUS_TXEMPTY
| STATUS_DCD
| STATUS_SYNC
|
259 STATUS_CTS
| STATUS_TXUNDRN
;
261 s
->rregs
[R_STATUS
] = STATUS_TXEMPTY
| STATUS_TXUNDRN
;
262 s
->rregs
[R_SPEC
] = SPEC_BITS8
| SPEC_ALLSENT
;
265 s
->rxint
= s
->txint
= 0;
266 s
->rxint_under_svc
= s
->txint_under_svc
= 0;
267 s
->e0_mode
= s
->led_mode
= s
->caps_lock_mode
= s
->num_lock_mode
= 0;
271 static void escc_reset(DeviceState
*d
)
273 ESCCState
*s
= ESCC(d
);
275 escc_reset_chn(&s
->chn
[0]);
276 escc_reset_chn(&s
->chn
[1]);
279 static inline void set_rxint(ESCCChannelState
*s
)
282 /* XXX: missing daisy chainnig: escc_chn_b rx should have a lower priority
283 than chn_a rx/tx/special_condition service*/
284 s
->rxint_under_svc
= 1;
285 if (s
->chn
== escc_chn_a
) {
286 s
->rregs
[R_INTR
] |= INTR_RXINTA
;
287 if (s
->wregs
[W_MINTR
] & MINTR_STATUSHI
)
288 s
->otherchn
->rregs
[R_IVEC
] = IVEC_HIRXINTA
;
290 s
->otherchn
->rregs
[R_IVEC
] = IVEC_LORXINTA
;
292 s
->otherchn
->rregs
[R_INTR
] |= INTR_RXINTB
;
293 if (s
->wregs
[W_MINTR
] & MINTR_STATUSHI
)
294 s
->rregs
[R_IVEC
] = IVEC_HIRXINTB
;
296 s
->rregs
[R_IVEC
] = IVEC_LORXINTB
;
301 static inline void set_txint(ESCCChannelState
*s
)
304 if (!s
->rxint_under_svc
) {
305 s
->txint_under_svc
= 1;
306 if (s
->chn
== escc_chn_a
) {
307 if (s
->wregs
[W_INTR
] & INTR_TXINT
) {
308 s
->rregs
[R_INTR
] |= INTR_TXINTA
;
310 if (s
->wregs
[W_MINTR
] & MINTR_STATUSHI
)
311 s
->otherchn
->rregs
[R_IVEC
] = IVEC_HITXINTA
;
313 s
->otherchn
->rregs
[R_IVEC
] = IVEC_LOTXINTA
;
315 s
->rregs
[R_IVEC
] = IVEC_TXINTB
;
316 if (s
->wregs
[W_INTR
] & INTR_TXINT
) {
317 s
->otherchn
->rregs
[R_INTR
] |= INTR_TXINTB
;
324 static inline void clr_rxint(ESCCChannelState
*s
)
327 s
->rxint_under_svc
= 0;
328 if (s
->chn
== escc_chn_a
) {
329 if (s
->wregs
[W_MINTR
] & MINTR_STATUSHI
)
330 s
->otherchn
->rregs
[R_IVEC
] = IVEC_HINOINT
;
332 s
->otherchn
->rregs
[R_IVEC
] = IVEC_LONOINT
;
333 s
->rregs
[R_INTR
] &= ~INTR_RXINTA
;
335 if (s
->wregs
[W_MINTR
] & MINTR_STATUSHI
)
336 s
->rregs
[R_IVEC
] = IVEC_HINOINT
;
338 s
->rregs
[R_IVEC
] = IVEC_LONOINT
;
339 s
->otherchn
->rregs
[R_INTR
] &= ~INTR_RXINTB
;
346 static inline void clr_txint(ESCCChannelState
*s
)
349 s
->txint_under_svc
= 0;
350 if (s
->chn
== escc_chn_a
) {
351 if (s
->wregs
[W_MINTR
] & MINTR_STATUSHI
)
352 s
->otherchn
->rregs
[R_IVEC
] = IVEC_HINOINT
;
354 s
->otherchn
->rregs
[R_IVEC
] = IVEC_LONOINT
;
355 s
->rregs
[R_INTR
] &= ~INTR_TXINTA
;
357 s
->otherchn
->rregs
[R_INTR
] &= ~INTR_TXINTB
;
358 if (s
->wregs
[W_MINTR
] & MINTR_STATUSHI
)
359 s
->rregs
[R_IVEC
] = IVEC_HINOINT
;
361 s
->rregs
[R_IVEC
] = IVEC_LONOINT
;
362 s
->otherchn
->rregs
[R_INTR
] &= ~INTR_TXINTB
;
369 static void escc_update_parameters(ESCCChannelState
*s
)
371 int speed
, parity
, data_bits
, stop_bits
;
372 QEMUSerialSetParams ssp
;
374 if (!qemu_chr_fe_backend_connected(&s
->chr
) || s
->type
!= escc_serial
)
377 if (s
->wregs
[W_TXCTRL1
] & TXCTRL1_PAREN
) {
378 if (s
->wregs
[W_TXCTRL1
] & TXCTRL1_PAREV
)
385 if ((s
->wregs
[W_TXCTRL1
] & TXCTRL1_STPMSK
) == TXCTRL1_2STOP
)
389 switch (s
->wregs
[W_TXCTRL2
] & TXCTRL2_BITMSK
) {
404 speed
= s
->clock
/ ((s
->wregs
[W_BRGLO
] | (s
->wregs
[W_BRGHI
] << 8)) + 2);
405 switch (s
->wregs
[W_TXCTRL1
] & TXCTRL1_CLKMSK
) {
421 ssp
.data_bits
= data_bits
;
422 ssp
.stop_bits
= stop_bits
;
423 trace_escc_update_parameters(CHN_C(s
), speed
, parity
, data_bits
, stop_bits
);
424 qemu_chr_fe_ioctl(&s
->chr
, CHR_IOCTL_SERIAL_SET_PARAMS
, &ssp
);
427 static void escc_mem_write(void *opaque
, hwaddr addr
,
428 uint64_t val
, unsigned size
)
430 ESCCState
*serial
= opaque
;
436 saddr
= (addr
>> serial
->it_shift
) & 1;
437 channel
= (addr
>> (serial
->it_shift
+ 1)) & 1;
438 s
= &serial
->chn
[channel
];
441 trace_escc_mem_writeb_ctrl(CHN_C(s
), s
->reg
, val
& 0xff);
445 newreg
= val
& CMD_PTR_MASK
;
455 if (s
->rxint_under_svc
) {
456 s
->rxint_under_svc
= 0;
460 } else if (s
->txint_under_svc
) {
461 s
->txint_under_svc
= 0;
469 case W_INTR
... W_RXCTRL
:
470 case W_SYNC1
... W_TXBUF
:
471 case W_MISC1
... W_CLOCK
:
472 case W_MISC2
... W_EXTINT
:
473 s
->wregs
[s
->reg
] = val
;
477 s
->wregs
[s
->reg
] = val
;
478 escc_update_parameters(s
);
482 s
->wregs
[s
->reg
] = val
;
483 s
->rregs
[s
->reg
] = val
;
484 escc_update_parameters(s
);
487 switch (val
& MINTR_RST_MASK
) {
492 escc_reset_chn(&serial
->chn
[0]);
495 escc_reset_chn(&serial
->chn
[1]);
498 escc_reset(DEVICE(serial
));
511 trace_escc_mem_writeb_data(CHN_C(s
), val
);
513 if (s
->wregs
[W_TXCTRL2
] & TXCTRL2_TXEN
) { // tx enabled
514 if (qemu_chr_fe_backend_connected(&s
->chr
)) {
515 /* XXX this blocks entire thread. Rewrite to use
516 * qemu_chr_fe_write and background I/O callbacks */
517 qemu_chr_fe_write_all(&s
->chr
, &s
->tx
, 1);
518 } else if (s
->type
== escc_kbd
&& !s
->disabled
) {
519 handle_kbd_command(s
, val
);
522 s
->rregs
[R_STATUS
] |= STATUS_TXEMPTY
; // Tx buffer empty
523 s
->rregs
[R_SPEC
] |= SPEC_ALLSENT
; // All sent
531 static uint64_t escc_mem_read(void *opaque
, hwaddr addr
,
534 ESCCState
*serial
= opaque
;
540 saddr
= (addr
>> serial
->it_shift
) & 1;
541 channel
= (addr
>> (serial
->it_shift
+ 1)) & 1;
542 s
= &serial
->chn
[channel
];
545 trace_escc_mem_readb_ctrl(CHN_C(s
), s
->reg
, s
->rregs
[s
->reg
]);
546 ret
= s
->rregs
[s
->reg
];
550 s
->rregs
[R_STATUS
] &= ~STATUS_RXAV
;
552 if (s
->type
== escc_kbd
|| s
->type
== escc_mouse
) {
557 trace_escc_mem_readb_data(CHN_C(s
), ret
);
558 qemu_chr_fe_accept_input(&s
->chr
);
566 static const MemoryRegionOps escc_mem_ops
= {
567 .read
= escc_mem_read
,
568 .write
= escc_mem_write
,
569 .endianness
= DEVICE_NATIVE_ENDIAN
,
571 .min_access_size
= 1,
572 .max_access_size
= 1,
576 static int serial_can_receive(void *opaque
)
578 ESCCChannelState
*s
= opaque
;
581 if (((s
->wregs
[W_RXCTRL
] & RXCTRL_RXEN
) == 0) // Rx not enabled
582 || ((s
->rregs
[R_STATUS
] & STATUS_RXAV
) == STATUS_RXAV
))
583 // char already available
590 static void serial_receive_byte(ESCCChannelState
*s
, int ch
)
592 trace_escc_serial_receive_byte(CHN_C(s
), ch
);
593 s
->rregs
[R_STATUS
] |= STATUS_RXAV
;
598 static void serial_receive_break(ESCCChannelState
*s
)
600 s
->rregs
[R_STATUS
] |= STATUS_BRK
;
604 static void serial_receive1(void *opaque
, const uint8_t *buf
, int size
)
606 ESCCChannelState
*s
= opaque
;
607 serial_receive_byte(s
, buf
[0]);
610 static void serial_event(void *opaque
, int event
)
612 ESCCChannelState
*s
= opaque
;
613 if (event
== CHR_EVENT_BREAK
)
614 serial_receive_break(s
);
617 static const VMStateDescription vmstate_escc_chn
= {
620 .minimum_version_id
= 1,
621 .fields
= (VMStateField
[]) {
622 VMSTATE_UINT32(vmstate_dummy
, ESCCChannelState
),
623 VMSTATE_UINT32(reg
, ESCCChannelState
),
624 VMSTATE_UINT32(rxint
, ESCCChannelState
),
625 VMSTATE_UINT32(txint
, ESCCChannelState
),
626 VMSTATE_UINT32(rxint_under_svc
, ESCCChannelState
),
627 VMSTATE_UINT32(txint_under_svc
, ESCCChannelState
),
628 VMSTATE_UINT8(rx
, ESCCChannelState
),
629 VMSTATE_UINT8(tx
, ESCCChannelState
),
630 VMSTATE_BUFFER(wregs
, ESCCChannelState
),
631 VMSTATE_BUFFER(rregs
, ESCCChannelState
),
632 VMSTATE_END_OF_LIST()
636 static const VMStateDescription vmstate_escc
= {
639 .minimum_version_id
= 1,
640 .fields
= (VMStateField
[]) {
641 VMSTATE_STRUCT_ARRAY(chn
, ESCCState
, 2, 2, vmstate_escc_chn
,
643 VMSTATE_END_OF_LIST()
647 static void sunkbd_handle_event(DeviceState
*dev
, QemuConsole
*src
,
650 ESCCChannelState
*s
= (ESCCChannelState
*)dev
;
654 assert(evt
->type
== INPUT_EVENT_KIND_KEY
);
655 key
= evt
->u
.key
.data
;
656 qcode
= qemu_input_key_value_to_qcode(key
->key
);
657 trace_escc_sunkbd_event_in(qcode
, QKeyCode_str(qcode
),
660 if (qcode
== Q_KEY_CODE_CAPS_LOCK
) {
662 s
->caps_lock_mode
^= 1;
663 if (s
->caps_lock_mode
== 2) {
664 return; /* Drop second press */
667 s
->caps_lock_mode
^= 2;
668 if (s
->caps_lock_mode
== 3) {
669 return; /* Drop first release */
674 if (qcode
== Q_KEY_CODE_NUM_LOCK
) {
676 s
->num_lock_mode
^= 1;
677 if (s
->num_lock_mode
== 2) {
678 return; /* Drop second press */
681 s
->num_lock_mode
^= 2;
682 if (s
->num_lock_mode
== 3) {
683 return; /* Drop first release */
688 if (qcode
> qemu_input_map_qcode_to_sun_len
) {
692 keycode
= qemu_input_map_qcode_to_sun
[qcode
];
696 trace_escc_sunkbd_event_out(keycode
);
697 put_queue(s
, keycode
);
700 static QemuInputHandler sunkbd_handler
= {
701 .name
= "sun keyboard",
702 .mask
= INPUT_EVENT_MASK_KEY
,
703 .event
= sunkbd_handle_event
,
706 static void handle_kbd_command(ESCCChannelState
*s
, int val
)
708 trace_escc_kbd_command(val
);
709 if (s
->led_mode
) { // Ignore led byte
714 case 1: // Reset, return type code
717 put_queue(s
, 4); // Type 4
720 case 0xe: // Set leds
723 case 7: // Query layout
727 put_queue(s
, 0x21); /* en-us layout */
734 static void sunmouse_event(void *opaque
,
735 int dx
, int dy
, int dz
, int buttons_state
)
737 ESCCChannelState
*s
= opaque
;
740 trace_escc_sunmouse_event(dx
, dy
, buttons_state
);
741 ch
= 0x80 | 0x7; /* protocol start byte, no buttons pressed */
743 if (buttons_state
& MOUSE_EVENT_LBUTTON
)
745 if (buttons_state
& MOUSE_EVENT_MBUTTON
)
747 if (buttons_state
& MOUSE_EVENT_RBUTTON
)
759 put_queue(s
, ch
& 0xff);
768 put_queue(s
, ch
& 0xff);
770 // MSC protocol specify two extra motion bytes
776 static void escc_init1(Object
*obj
)
778 ESCCState
*s
= ESCC(obj
);
779 SysBusDevice
*dev
= SYS_BUS_DEVICE(obj
);
782 for (i
= 0; i
< 2; i
++) {
783 sysbus_init_irq(dev
, &s
->chn
[i
].irq
);
784 s
->chn
[i
].chn
= 1 - i
;
786 s
->chn
[0].otherchn
= &s
->chn
[1];
787 s
->chn
[1].otherchn
= &s
->chn
[0];
789 sysbus_init_mmio(dev
, &s
->mmio
);
792 static void escc_realize(DeviceState
*dev
, Error
**errp
)
794 ESCCState
*s
= ESCC(dev
);
797 s
->chn
[0].disabled
= s
->disabled
;
798 s
->chn
[1].disabled
= s
->disabled
;
800 memory_region_init_io(&s
->mmio
, OBJECT(dev
), &escc_mem_ops
, s
, "escc",
801 ESCC_SIZE
<< s
->it_shift
);
803 for (i
= 0; i
< 2; i
++) {
804 if (qemu_chr_fe_backend_connected(&s
->chn
[i
].chr
)) {
805 s
->chn
[i
].clock
= s
->frequency
/ 2;
806 qemu_chr_fe_set_handlers(&s
->chn
[i
].chr
, serial_can_receive
,
807 serial_receive1
, serial_event
, NULL
,
808 &s
->chn
[i
], NULL
, true);
812 if (s
->chn
[0].type
== escc_mouse
) {
813 qemu_add_mouse_event_handler(sunmouse_event
, &s
->chn
[0], 0,
816 if (s
->chn
[1].type
== escc_kbd
) {
817 s
->chn
[1].hs
= qemu_input_handler_register((DeviceState
*)(&s
->chn
[1]),
822 static Property escc_properties
[] = {
823 DEFINE_PROP_UINT32("frequency", ESCCState
, frequency
, 0),
824 DEFINE_PROP_UINT32("it_shift", ESCCState
, it_shift
, 0),
825 DEFINE_PROP_UINT32("disabled", ESCCState
, disabled
, 0),
826 DEFINE_PROP_UINT32("chnBtype", ESCCState
, chn
[0].type
, 0),
827 DEFINE_PROP_UINT32("chnAtype", ESCCState
, chn
[1].type
, 0),
828 DEFINE_PROP_CHR("chrB", ESCCState
, chn
[0].chr
),
829 DEFINE_PROP_CHR("chrA", ESCCState
, chn
[1].chr
),
830 DEFINE_PROP_END_OF_LIST(),
833 static void escc_class_init(ObjectClass
*klass
, void *data
)
835 DeviceClass
*dc
= DEVICE_CLASS(klass
);
837 dc
->reset
= escc_reset
;
838 dc
->realize
= escc_realize
;
839 dc
->vmsd
= &vmstate_escc
;
840 dc
->props
= escc_properties
;
841 set_bit(DEVICE_CATEGORY_INPUT
, dc
->categories
);
844 static const TypeInfo escc_info
= {
846 .parent
= TYPE_SYS_BUS_DEVICE
,
847 .instance_size
= sizeof(ESCCState
),
848 .instance_init
= escc_init1
,
849 .class_init
= escc_class_init
,
852 static void escc_register_types(void)
854 type_register_static(&escc_info
);
857 type_init(escc_register_types
)