Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/mcayland/tags/qemu-macppc-20200…
Browse files Browse the repository at this point in the history
…626' into staging

qemu-macppc patches

# gpg: Signature made Fri 26 Jun 2020 10:15:36 BST
# gpg:                using RSA key CC621AB98E82200D915CC9C45BC2C56FAE0F321F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Mark Cave-Ayland <[email protected]>" [full]
# Primary key fingerprint: CC62 1AB9 8E82 200D 915C  C9C4 5BC2 C56F AE0F 321F

* remotes/mcayland/tags/qemu-macppc-20200626: (22 commits)
  adb: add ADB bus trace events
  adb: use adb_device prefix for ADB device trace events
  adb: only call autopoll callbacks when autopoll is not blocked
  mac_via: rework ADB state machine to be compatible with both MacOS and Linux
  mac_via: move VIA1 portB write logic into mos6522_q800_via1_write()
  pmu: add adb_autopoll_block() and adb_autopoll_unblock() functions
  cuda: add adb_autopoll_block() and adb_autopoll_unblock() functions
  adb: add autopoll_blocked variable to block autopoll
  adb: use adb_request() only for explicit requests
  adb: add status field for holding information about the last ADB request
  adb: keep track of devices with pending data
  adb: introduce new ADBDeviceHasData method to ADBDeviceClass
  mac_via: convert to use ADBBusState internal autopoll variables
  pmu: convert to use ADBBusState internal autopoll variables
  cuda: convert to use ADBBusState internal autopoll variables
  adb: create autopoll variables directly within ADBBusState
  adb: introduce realize/unrealize and VMStateDescription for ADB bus
  pmu: honour autopoll_rate_ms when rearming the ADB autopoll timer
  pmu: fix duplicate autopoll mask variable
  cuda: convert ADB autopoll timer from ns to ms
  ...

Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
pm215 committed Jun 26, 2020
2 parents 611ac63 + e590e7f commit 10f7ffa
Show file tree
Hide file tree
Showing 13 changed files with 620 additions and 283 deletions.
42 changes: 24 additions & 18 deletions hw/input/adb-kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
olen = 0;
switch (cmd) {
case ADB_WRITEREG:
trace_adb_kbd_writereg(reg, buf[1]);
trace_adb_device_kbd_writereg(reg, buf[1]);
switch (reg) {
case 2:
/* LED status */
Expand All @@ -256,24 +256,22 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
case ADB_CMD_CHANGE_ID_AND_ACT:
case ADB_CMD_CHANGE_ID_AND_ENABLE:
d->devaddr = buf[1] & 0xf;
trace_adb_kbd_request_change_addr(d->devaddr);
trace_adb_device_kbd_request_change_addr(d->devaddr);
break;
default:
if (!d->disable_direct_reg3_writes) {
d->devaddr = buf[1] & 0xf;

/* we support handlers:
* 1: Apple Standard Keyboard
* 2: Apple Extended Keyboard (LShift = RShift)
* 3: Apple Extended Keyboard (LShift != RShift)
*/
if (buf[2] == 1 || buf[2] == 2 || buf[2] == 3) {
d->handler = buf[2];
}

trace_adb_kbd_request_change_addr_and_handler(d->devaddr,
d->handler);
d->devaddr = buf[1] & 0xf;
/*
* we support handlers:
* 1: Apple Standard Keyboard
* 2: Apple Extended Keyboard (LShift = RShift)
* 3: Apple Extended Keyboard (LShift != RShift)
*/
if (buf[2] == 1 || buf[2] == 2 || buf[2] == 3) {
d->handler = buf[2];
}

trace_adb_device_kbd_request_change_addr_and_handler(
d->devaddr, d->handler);
break;
}
}
Expand All @@ -296,12 +294,19 @@ static int adb_kbd_request(ADBDevice *d, uint8_t *obuf,
olen = 2;
break;
}
trace_adb_kbd_readreg(reg, obuf[0], obuf[1]);
trace_adb_device_kbd_readreg(reg, obuf[0], obuf[1]);
break;
}
return olen;
}

static bool adb_kbd_has_data(ADBDevice *d)
{
KBDState *s = ADB_KEYBOARD(d);

return s->count > 0;
}

/* This is where keyboard events enter this file */
static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,
InputEvent *evt)
Expand All @@ -316,7 +321,7 @@ static void adb_keyboard_event(DeviceState *dev, QemuConsole *src,
/* FIXME: take handler into account when translating qcode */
keycode = qcode_to_adb_keycode[qcode];
if (keycode == NO_KEY) { /* We don't want to send this to the guest */
trace_adb_kbd_no_key();
trace_adb_device_kbd_no_key();
return;
}
if (evt->u.key.data->down == false) { /* if key release event */
Expand Down Expand Up @@ -384,6 +389,7 @@ static void adb_kbd_class_init(ObjectClass *oc, void *data)
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);

adc->devreq = adb_kbd_request;
adc->devhasdata = adb_kbd_has_data;
dc->reset = adb_kbd_reset;
dc->vmsd = &vmstate_adb_kbd;
}
Expand Down
65 changes: 41 additions & 24 deletions hw/input/adb-mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
s->dx = 0;
s->dy = 0;
s->dz = 0;
trace_adb_mouse_flush();
trace_adb_device_mouse_flush();
return 0;
}

Expand All @@ -130,42 +130,50 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
olen = 0;
switch (cmd) {
case ADB_WRITEREG:
trace_adb_mouse_writereg(reg, buf[1]);
trace_adb_device_mouse_writereg(reg, buf[1]);
switch (reg) {
case 2:
break;
case 3:
/*
* MacOS 9 has a bug in its ADB driver whereby after configuring
* the ADB bus devices it sends another write of invalid length
* to reg 3. Make sure we ignore it to prevent an address clash
* with the previous device.
*/
if (len != 3) {
return 0;
}

switch (buf[2]) {
case ADB_CMD_SELF_TEST:
break;
case ADB_CMD_CHANGE_ID:
case ADB_CMD_CHANGE_ID_AND_ACT:
case ADB_CMD_CHANGE_ID_AND_ENABLE:
d->devaddr = buf[1] & 0xf;
trace_adb_mouse_request_change_addr(d->devaddr);
trace_adb_device_mouse_request_change_addr(d->devaddr);
break;
default:
if (!d->disable_direct_reg3_writes) {
d->devaddr = buf[1] & 0xf;

/* we support handlers:
* 0x01: Classic Apple Mouse Protocol / 100 cpi operations
* 0x02: Classic Apple Mouse Protocol / 200 cpi operations
* we don't support handlers (at least):
* 0x03: Mouse systems A3 trackball
* 0x04: Extended Apple Mouse Protocol
* 0x2f: Microspeed mouse
* 0x42: Macally
* 0x5f: Microspeed mouse
* 0x66: Microspeed mouse
*/
if (buf[2] == 1 || buf[2] == 2) {
d->handler = buf[2];
}

trace_adb_mouse_request_change_addr_and_handler(
d->devaddr, d->handler);
d->devaddr = buf[1] & 0xf;
/*
* we support handlers:
* 0x01: Classic Apple Mouse Protocol / 100 cpi operations
* 0x02: Classic Apple Mouse Protocol / 200 cpi operations
* we don't support handlers (at least):
* 0x03: Mouse systems A3 trackball
* 0x04: Extended Apple Mouse Protocol
* 0x2f: Microspeed mouse
* 0x42: Macally
* 0x5f: Microspeed mouse
* 0x66: Microspeed mouse
*/
if (buf[2] == 1 || buf[2] == 2) {
d->handler = buf[2];
}

trace_adb_device_mouse_request_change_addr_and_handler(
d->devaddr, d->handler);
break;
}
}
Expand All @@ -183,12 +191,20 @@ static int adb_mouse_request(ADBDevice *d, uint8_t *obuf,
olen = 2;
break;
}
trace_adb_mouse_readreg(reg, obuf[0], obuf[1]);
trace_adb_device_mouse_readreg(reg, obuf[0], obuf[1]);
break;
}
return olen;
}

static bool adb_mouse_has_data(ADBDevice *d)
{
MouseState *s = ADB_MOUSE(d);

return !(s->last_buttons_state == s->buttons_state &&
s->dx == 0 && s->dy == 0);
}

static void adb_mouse_reset(DeviceState *dev)
{
ADBDevice *d = ADB_DEVICE(dev);
Expand Down Expand Up @@ -244,6 +260,7 @@ static void adb_mouse_class_init(ObjectClass *oc, void *data)
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);

adc->devreq = adb_mouse_request;
adc->devhasdata = adb_mouse_has_data;
dc->reset = adb_mouse_reset;
dc->vmsd = &vmstate_adb_mouse;
}
Expand Down
Loading

0 comments on commit 10f7ffa

Please sign in to comment.