From ce8185b383eb2d071a486a0bfd50364f6037d3e7 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Thu, 8 Mar 2007 17:40:40 +0000 Subject: [PATCH] cleanup & disabled most debug output git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20357 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/bus_managers/ps2/ps2_common.c | 56 ++++++------ .../kernel/bus_managers/ps2/ps2_common.h | 18 ++-- src/add-ons/kernel/bus_managers/ps2/ps2_dev.c | 54 ++++++------ src/add-ons/kernel/bus_managers/ps2/ps2_dev.h | 4 +- .../kernel/bus_managers/ps2/ps2_keyboard.c | 54 ++++++------ .../kernel/bus_managers/ps2/ps2_mouse.c | 87 +++++++++---------- .../kernel/bus_managers/ps2/ps2_service.c | 30 +++---- .../kernel/bus_managers/ps2/ps2_service.h | 4 +- 8 files changed, 155 insertions(+), 152 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_common.c b/src/add-ons/kernel/bus_managers/ps2/ps2_common.c index 3b0104f1bb..ddd8dee782 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_common.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_common.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Haiku, Inc. + * Copyright 2004-2007 Haiku, Inc. * Distributed under the terms of the Haiku License. * * Authors (in chronological order): @@ -8,7 +8,7 @@ * Marcus Overhagen */ -/*! PS/2 hid device driver */ +/*! PS/2 bus manager */ #include @@ -41,7 +41,7 @@ ps2_read_data(void) void ps2_write_ctrl(uint8 ctrl) { - TRACE(("ps2_write_ctrl 0x%02x\n", ctrl)); + TRACE("ps2_write_ctrl 0x%02x\n", ctrl); gIsa->write_io_8(PS2_PORT_CTRL, ctrl); } @@ -50,7 +50,7 @@ ps2_write_ctrl(uint8 ctrl) void ps2_write_data(uint8 data) { - TRACE(("ps2_write_data 0x%02x\n", data)); + TRACE("ps2_write_data 0x%02x\n", data); gIsa->write_io_8(PS2_PORT_DATA, data); } @@ -99,7 +99,7 @@ ps2_flush(void) if (!(ctrl & PS2_STATUS_OUTPUT_BUFFER_FULL)) break; data = ps2_read_data(); - dprintf("ps2: ps2_flush: ctrl 0x%02x, data 0x%02x (%s)\n", ctrl, data, (ctrl & PS2_STATUS_AUX_DATA) ? "aux" : "keyb"); + TRACE("ps2: ps2_flush: ctrl 0x%02x, data 0x%02x (%s)\n", ctrl, data, (ctrl & PS2_STATUS_AUX_DATA) ? "aux" : "keyb"); snooze(100); } @@ -115,7 +115,7 @@ ps2_setup_command_byte() uint8 cmdbyte; res = ps2_command(PS2_CTRL_READ_CMD, NULL, 0, &cmdbyte, 1); - dprintf("ps2: get command byte: res 0x%08lx, cmdbyte 0x%02x\n", res, cmdbyte); + TRACE("ps2: get command byte: res 0x%08lx, cmdbyte 0x%02x\n", res, cmdbyte); if (res != B_OK) cmdbyte = 0x47; @@ -123,7 +123,7 @@ ps2_setup_command_byte() cmdbyte &= ~(PS2_BITS_KEYBOARD_DISABLED | PS2_BITS_MOUSE_DISABLED); res = ps2_command(PS2_CTRL_WRITE_CMD, &cmdbyte, 1, NULL, 0); - dprintf("ps2: set command byte: res 0x%08lx, cmdbyte 0x%02x\n", res, cmdbyte); + TRACE("ps2: set command byte: res 0x%08lx, cmdbyte 0x%02x\n", res, cmdbyte); return res; } @@ -165,27 +165,27 @@ ps2_setup_active_multiplexing(bool *enabled) // MS Virtual PC, it's 0xa6. Since current active multiplexing // specification version is 1.1 (0x11), we validate the data. if (in > 0x9f) { - dprintf("ps2: active multiplexing v%d.%d detected, but ignored!\n", (in >> 4), in & 0xf); + TRACE("ps2: active multiplexing v%d.%d detected, but ignored!\n", (in >> 4), in & 0xf); goto no_support; } - dprintf("ps2: active multiplexing v%d.%d enabled\n", (in >> 4), in & 0xf); + INFO("ps2: active multiplexing v%d.%d enabled\n", (in >> 4), in & 0xf); *enabled = true; return B_OK; no_support: - dprintf("ps2: active multiplexing not supported\n"); + TRACE("ps2: active multiplexing not supported\n"); *enabled = false; return B_OK; fail: - dprintf("ps2: testing for active multiplexing failed\n"); + TRACE("ps2: testing for active multiplexing failed\n"); *enabled = false; // this should revert the controller into legacy mode, // just in case it has switched to multiplexed mode res = ps2_command(PS2_CTRL_SELF_TEST, NULL, 0, &out, 1); if (res != B_OK || out != 0x55) { - dprintf("ps2: controller self test failed, status 0x%08lx, data 0x%02x\n", res, out); + INFO("ps2: controller self test failed, status 0x%08lx, data 0x%02x\n", res, out); return B_ERROR; } return B_OK; @@ -201,9 +201,9 @@ ps2_command(uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count) acquire_sem(gControllerSem); atomic_add(&sIgnoreInterrupts, 1); - dprintf("ps2: ps2_command cmd 0x%02x, out %d, in %d\n", cmd, out_count, in_count); + TRACE("ps2: ps2_command cmd 0x%02x, out %d, in %d\n", cmd, out_count, in_count); for (i = 0; i < out_count; i++) - dprintf("ps2: ps2_command out 0x%02x\n", out[i]); + TRACE("ps2: ps2_command out 0x%02x\n", out[i]); res = ps2_wait_write(); if (res == B_OK) @@ -214,7 +214,7 @@ ps2_command(uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count) if (res == B_OK) ps2_write_data(out[i]); else - dprintf("ps2: ps2_command out byte %d failed\n", i); + TRACE("ps2: ps2_command out byte %d failed\n", i); } for (i = 0; res == B_OK && i < in_count; i++) { @@ -222,12 +222,12 @@ ps2_command(uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count) if (res == B_OK) in[i] = ps2_read_data(); else - dprintf("ps2: ps2_command in byte %d failed\n", i); + TRACE("ps2: ps2_command in byte %d failed\n", i); } for (i = 0; i < in_count; i++) - dprintf("ps2: ps2_command in 0x%02x\n", in[i]); - dprintf("ps2: ps2_command result 0x%08lx\n", res); + TRACE("ps2: ps2_command in 0x%02x\n", in[i]); + TRACE("ps2: ps2_command result 0x%08lx\n", res); atomic_add(&sIgnoreInterrupts, -1); release_sem(gControllerSem); @@ -252,7 +252,7 @@ ps2_interrupt(void* cookie) return B_UNHANDLED_INTERRUPT; if (atomic_get(&sIgnoreInterrupts)) { - TRACE(("ps2_interrupt: ignoring, ctrl 0x%02x (%s)\n", ctrl, (ctrl & PS2_STATUS_AUX_DATA) ? "aux" : "keyb")); + TRACE("ps2_interrupt: ignoring, ctrl 0x%02x (%s)\n", ctrl, (ctrl & PS2_STATUS_AUX_DATA) ? "aux" : "keyb"); return B_HANDLED_INTERRUPT; } @@ -263,15 +263,15 @@ ps2_interrupt(void* cookie) if (gActiveMultiplexingEnabled) { idx = ctrl >> 6; error = (ctrl & 0x04) != 0; - TRACE(("ps2_interrupt: ctrl 0x%02x, data 0x%02x (mouse %d)\n", ctrl, data, idx)); + TRACE("ps2_interrupt: ctrl 0x%02x, data 0x%02x (mouse %d)\n", ctrl, data, idx); } else { idx = 0; error = (ctrl & 0xC0) != 0; - TRACE(("ps2_interrupt: ctrl 0x%02x, data 0x%02x (aux)\n", ctrl, data)); + TRACE("ps2_interrupt: ctrl 0x%02x, data 0x%02x (aux)\n", ctrl, data); } dev = &ps2_device[PS2_DEVICE_MOUSE + idx]; } else { - TRACE(("ps2_interrupt: ctrl 0x%02x, data 0x%02x (keyb)\n", ctrl, data)); + TRACE("ps2_interrupt: ctrl 0x%02x, data 0x%02x (keyb)\n", ctrl, data); dev = &ps2_device[PS2_DEVICE_KEYB]; error = (ctrl & 0xC0) != 0; @@ -297,7 +297,7 @@ ps2_init(void) { status_t status; - TRACE(("ps2: init\n")); + TRACE("ps2: init\n"); status = get_module(B_ISA_MODULE_NAME, (module_info **)&gIsa); if (status < B_OK) @@ -325,13 +325,13 @@ ps2_init(void) status = ps2_setup_command_byte(); if (status) { - dprintf("ps2: setting up command byte failed\n"); + INFO("ps2: setting up command byte failed\n"); goto err5; } status = ps2_setup_active_multiplexing(&gActiveMultiplexingEnabled); if (status) { - dprintf("ps2: setting up active multiplexing failed\n"); + INFO("ps2: setting up active multiplexing failed\n"); goto err5; } @@ -343,7 +343,7 @@ ps2_init(void) ps2_service_notify_device_added(&ps2_device[PS2_DEVICE_MOUSE + 3]); } - TRACE(("ps2_hid: init_driver done!\n")); + TRACE("ps2: init done!\n"); return B_OK; @@ -358,7 +358,7 @@ err2: err1: delete_sem(gControllerSem); put_module(B_ISA_MODULE_NAME); - TRACE(("ps2_hid: init_driver failed!\n")); + TRACE("ps2: init failed!\n"); return B_ERROR; } @@ -366,7 +366,7 @@ err1: void ps2_uninit(void) { - TRACE(("ps2: uninit\n")); + TRACE("ps2: uninit\n"); remove_io_interrupt_handler(INT_PS2_MOUSE, &ps2_interrupt, NULL); remove_io_interrupt_handler(INT_PS2_KEYBOARD, &ps2_interrupt, NULL); ps2_service_exit(); diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_common.h b/src/add-ons/kernel/bus_managers/ps2/ps2_common.h index 59f34b0617..1de23499bb 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_common.h +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_common.h @@ -1,8 +1,8 @@ /* - * Copyright 2004-2006 Haiku, Inc. + * Copyright 2004-2007 Haiku, Inc. * Distributed under the terms of the MIT License. * - * PS/2 hid device driver + * PS/2 bus manager * * Authors (in chronological order): * Elad Lahav (elad@eldarshany.com) @@ -23,13 +23,19 @@ #include "ps2_dev.h" -// debug defines -#ifdef DEBUG -# define TRACE(x) dprintf x +#if 1 +# define INFO(x...) dprintf(x) #else -# define TRACE(x) ; +# define INFO(x...) #endif +#if 0 +# define TRACE(x...) dprintf(x) +#else +# define TRACE(x...) +#endif + + // global variables extern isa_module_info *gIsa; diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.c b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.c index c20ebb8efb..3388d25c01 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.c @@ -1,8 +1,8 @@ /* - * Copyright 2005-2006 Haiku, Inc. + * Copyright 2005-2007 Haiku, Inc. * Distributed under the terms of the MIT License. * - * PS/2 hid device driver + * PS/2 bus manager * * Authors (in chronological order): * Marcus Overhagen (marcus@overhagen.de) @@ -61,7 +61,7 @@ void ps2_dev_publish(ps2_dev *dev) { status_t status; - TRACE(("ps2_dev_publish %s\n", dev->name)); + TRACE("ps2_dev_publish %s\n", dev->name); if (dev->active) return; @@ -71,7 +71,7 @@ ps2_dev_publish(ps2_dev *dev) status = devfs_publish_device(dev->name, NULL, (atomic_get(&dev->flags) & PS2_FLAG_KEYB) ? &gKeyboardDeviceHooks : &gMouseDeviceHooks); - dprintf("ps2: devfs_publish_device %s, status = 0x%08lx\n", dev->name, status); + INFO("ps2: devfs_publish_device %s, status = 0x%08lx\n", dev->name, status); } @@ -79,7 +79,7 @@ void ps2_dev_unpublish(ps2_dev *dev) { status_t status; - TRACE(("ps2_dev_unpublish %s\n", dev->name)); + TRACE("ps2_dev_unpublish %s\n", dev->name); if (!dev->active) return; @@ -91,7 +91,7 @@ ps2_dev_unpublish(ps2_dev *dev) if ((dev->flags & PS2_FLAG_ENABLED) && dev->disconnect) dev->disconnect(dev); - dprintf("ps2: devfs_unpublish_device %s, status = 0x%08lx\n", dev->name, status); + INFO("ps2: devfs_unpublish_device %s, status = 0x%08lx\n", dev->name, status); } @@ -112,7 +112,7 @@ ps2_dev_handle_int(ps2_dev *dev) atomic_or(&dev->flags, PS2_FLAG_NACK); } else if ((flags & PS2_FLAG_GETID) && (data == 0 || data == 3 || data == 4)) { // workaround for broken mice that don't ack the "get id" command - dprintf("ps2: ps2_dev_handle_int: mouse didn't ack the 'get id' command\n"); + TRACE("ps2: ps2_dev_handle_int: mouse didn't ack the 'get id' command\n"); atomic_or(&dev->flags, PS2_FLAG_ACK); if (dev->result_buf_cnt) { dev->result_buf[dev->result_buf_idx] = data; @@ -124,8 +124,8 @@ ps2_dev_handle_int(ps2_dev *dev) } } } else { -// dprintf("ps2: ps2_dev_handle_int unexpected data 0x%02x while waiting for ack\n", data); - dprintf("ps2: int1 %02x\n", data); +// TRACE("ps2: ps2_dev_handle_int unexpected data 0x%02x while waiting for ack\n", data); + TRACE("ps2: int1 %02x\n", data); goto pass_to_handler; } release_sem_etc(dev->result_sem, cnt, B_DO_NOT_RESCHEDULE); @@ -140,8 +140,8 @@ ps2_dev_handle_int(ps2_dev *dev) return B_INVOKE_SCHEDULER; } } else { -// dprintf("ps2: ps2_dev_handle_int unexpected data 0x%02x during command processing\n", data); - dprintf("ps2: int2 %02x\n", data); +// TRACE("ps2: ps2_dev_handle_int unexpected data 0x%02x during command processing\n", data); + TRACE("ps2: int2 %02x\n", data); goto pass_to_handler; } return B_HANDLED_INTERRUPT; @@ -151,14 +151,14 @@ pass_to_handler: if ((flags & PS2_FLAG_KEYB) == 0) { if (dev->history[0].error && data == 0xfd) { - dprintf("ps2: hot removal of %s\n", dev->name); + INFO("ps2: hot removal of %s\n", dev->name); ps2_service_notify_device_removed(dev); return B_INVOKE_SCHEDULER; } if (data == 0x00 && dev->history[1].data == 0xaa && (dev->history[0].time - dev->history[1].time) < 50000) { - dprintf("ps2: hot plugin of %s\n", dev->name); + INFO("ps2: hot plugin of %s\n", dev->name); if (dev->active) { - dprintf("ps2: device %s still active, removing...\n", dev->name); + TRACE("ps2: device %s still active, removing...\n", dev->name); ps2_service_notify_device_removed(dev); } ps2_service_notify_device_added(dev); @@ -167,9 +167,9 @@ pass_to_handler: } if (!dev->active) { - dprintf("ps2: %s not active, data 0x%02x dropped\n", dev->name, data); + TRACE("ps2: %s not active, data 0x%02x dropped\n", dev->name, data); if (data != 0x00 && data != 0xaa) { - dprintf("ps2: possibly a hot plugin of %s\n", dev->name); + INFO("ps2: possibly a hot plugin of %s\n", dev->name); ps2_service_notify_device_added(dev); return B_INVOKE_SCHEDULER; } @@ -177,7 +177,7 @@ pass_to_handler: } if ((flags & PS2_FLAG_ENABLED) == 0) { - dprintf("ps2: %s not enabled, data 0x%02x dropped\n", dev->name, data); + TRACE("ps2: %s not enabled, data 0x%02x dropped\n", dev->name, data); return B_HANDLED_INTERRUPT; } @@ -193,13 +193,13 @@ ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 int32 sem_count; int i; - dprintf("ps2: ps2_dev_command cmd 0x%02x, out %d, in %d, dev %s\n", cmd, out_count, in_count, dev->name); + TRACE("ps2: ps2_dev_command cmd 0x%02x, out %d, in %d, dev %s\n", cmd, out_count, in_count, dev->name); for (i = 0; i < out_count; i++) - dprintf("ps2: ps2_dev_command out 0x%02x\n", out[i]); + TRACE("ps2: ps2_dev_command out 0x%02x\n", out[i]); res = get_sem_count(dev->result_sem, &sem_count); if (res == B_OK && sem_count != 0) { - dprintf("ps2: ps2_dev_command: sem_count %ld, fixing!\n", sem_count); + TRACE("ps2: ps2_dev_command: sem_count %ld, fixing!\n", sem_count); if (sem_count > 0) acquire_sem_etc(dev->result_sem, sem_count, 0, 0); else @@ -245,17 +245,17 @@ ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 start = system_time(); res = acquire_sem_etc(dev->result_sem, 1, B_RELATIVE_TIMEOUT, 4000000); - dprintf("ps2: ps2_dev_command wait for ack res 0x%08lx, wait-time %Ld\n", res, system_time() - start); + TRACE("ps2: ps2_dev_command wait for ack res 0x%08lx, wait-time %Ld\n", res, system_time() - start); if (res != B_OK) break; if (atomic_get(&dev->flags) & PS2_FLAG_ACK) { - dprintf("ps2: ps2_dev_command got ACK\n"); + TRACE("ps2: ps2_dev_command got ACK\n"); } if (atomic_get(&dev->flags) & PS2_FLAG_NACK) { - dprintf("ps2: ps2_dev_command got NACK\n"); + TRACE("ps2: ps2_dev_command got NACK\n"); res = B_ERROR; break; } @@ -265,18 +265,18 @@ ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 if (res == B_OK && in_count != 0) { start = system_time(); res = acquire_sem_etc(dev->result_sem, 1, B_RELATIVE_TIMEOUT, 4000000); - dprintf("ps2: ps2_dev_command wait for input res 0x%08lx, wait-time %Ld\n", res, system_time() - start); + TRACE("ps2: ps2_dev_command wait for input res 0x%08lx, wait-time %Ld\n", res, system_time() - start); if (dev->result_buf_cnt != 0) { - dprintf("ps2: ps2_dev_command error: %d input bytes not received\n", dev->result_buf_cnt); + TRACE("ps2: ps2_dev_command error: %d input bytes not received\n", dev->result_buf_cnt); dev->result_buf_cnt = 0; } for (i = 0; i < in_count; i++) - dprintf("ps2: ps2_dev_command in 0x%02x\n", in[i]); + TRACE("ps2: ps2_dev_command in 0x%02x\n", in[i]); } - dprintf("ps2: ps2_dev_command result 0x%08lx\n", res); + TRACE("ps2: ps2_dev_command result 0x%08lx\n", res); atomic_and(&dev->flags, ~PS2_FLAG_CMD); diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h index e25652fe39..77555da2b8 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.h @@ -1,8 +1,8 @@ /* - * Copyright 2005 Haiku, Inc. + * Copyright 2005-2007 Haiku, Inc. * Distributed under the terms of the MIT License. * - * PS/2 hid device driver + * PS/2 bus manager * * Authors (in chronological order): * Marcus Overhagen (marcus@overhagen.de) diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.c b/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.c index 99acb28877..d2f807147a 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.c @@ -1,5 +1,5 @@ /* - * Copyright 2004-2006 Haiku, Inc. + * Copyright 2004-2007 Haiku, Inc. * Distributed under the terms of the MIT License. * * Authors (in chronological order): @@ -43,7 +43,7 @@ set_leds(led_info *ledInfo) { uint8 leds = 0; - TRACE(("ps2_hid: set keyboard LEDs\n")); + TRACE("ps2: set keyboard LEDs\n"); if (ledInfo->scroll_lock) leds |= LED_SCROLL; @@ -61,7 +61,7 @@ set_typematic(int32 rate, bigtime_t delay) { uint8 value; - dprintf("ps2: set_typematic rate %ld, delay %Ld\n", rate, delay); + TRACE("ps2: set_typematic rate %ld, delay %Ld\n", rate, delay); // input server and keyboard preferences *seem* to use a range of 20-300 if (rate < 20) @@ -101,11 +101,11 @@ keyboard_handle_int(ps2_dev *dev) if (scancode == EXTENDED_KEY) { sIsExtended = true; - TRACE(("Extended key\n")); + TRACE("Extended key\n"); return B_HANDLED_INTERRUPT; } - TRACE(("scancode: %x\n", scancode)); + TRACE("scancode: %x\n", scancode); if (scancode & 0x80) { keyInfo.is_keydown = false; @@ -138,23 +138,23 @@ read_keyboard_packet(at_kbd_io *packet) { status_t status; - TRACE(("read_keyboard_packet()\n")); + TRACE("ps2: read_keyboard_packet\n"); status = acquire_sem_etc(sKeyboardSem, 1, B_CAN_INTERRUPT, 0); if (status < B_OK) return status; if (!ps2_device[PS2_DEVICE_KEYB].active) { - dprintf("ps2: read_keyboard_packet, Error device no longer active\n"); + TRACE("ps2: read_keyboard_packet, Error device no longer active\n"); return B_ERROR; } if (packet_buffer_read(sKeyBuffer, (uint8 *)packet, sizeof(*packet)) == 0) { - TRACE(("read_keyboard_packet(): error reading packet: %s\n", strerror(status))); + TRACE("ps2: read_keyboard_packet, Error reading packet: %s\n", strerror(status)); return B_ERROR; } - TRACE(("scancode: %x, keydown: %s\n", packet->scancode, packet->is_keydown ? "true" : "false")); + TRACE("scancode: %x, keydown: %s\n", packet->scancode, packet->is_keydown ? "true" : "false"); return B_OK; } @@ -163,7 +163,7 @@ static void ps2_keyboard_disconnect(ps2_dev *dev) { // the keyboard might not be opened at this point - dprintf("ps2: ps2_keyboard_disconnect %s\n", dev->name); + INFO("ps2: ps2_keyboard_disconnect %s\n", dev->name); if (sKeyboardOpenMask) release_sem(sKeyboardSem); } @@ -180,13 +180,13 @@ probe_keyboard(void) // This test doesn't work relyable on some notebooks (it reports 0x03) // status = ps2_command(PS2_CTRL_KEYBOARD_TEST, NULL, 0, &data, 1); // if (status != B_OK || data != 0x00) { -// dprintf("ps2: keyboard test failed, status 0x%08lx, data 0x%02x\n", status, data); +// INFO("ps2: keyboard test failed, status 0x%08lx, data 0x%02x\n", status, data); // return B_ERROR; // } status = ps2_dev_command(&ps2_device[PS2_DEVICE_KEYB], PS2_CMD_RESET, NULL, 0, &data, 1); if (status != B_OK || data != 0xaa) { - dprintf("ps2: keyboard reset failed, status 0x%08lx, data 0x%02x\n", status, data); + INFO("ps2: keyboard reset failed, status 0x%08lx, data 0x%02x\n", status, data); return B_ERROR; } @@ -199,7 +199,7 @@ probe_keyboard(void) // On my notebook, the keyboard controller does NACK the echo command. // status = ps2_dev_command(&ps2_device[PS2_DEVICE_KEYB], PS2_CMD_ECHO, NULL, 0, &data, 1); // if (status != B_OK || data != 0xee) { -// dprintf("ps2: keyboard echo test failed, status 0x%08lx, data 0x%02x\n", status, data); +// INFO("ps2: keyboard echo test failed, status 0x%08lx, data 0x%02x\n", status, data); // return B_ERROR; // } @@ -215,14 +215,14 @@ keyboard_open(const char *name, uint32 flags, void **_cookie) { status_t status; - dprintf("ps2: keyboard_open %s\n", name); + TRACE("ps2: keyboard_open %s\n", name); if (atomic_or(&sKeyboardOpenMask, 1) != 0) return B_BUSY; status = probe_keyboard(); if (status != B_OK) { - dprintf("ps2: keyboard probing failed\n"); + INFO("ps2: keyboard probing failed\n"); ps2_service_notify_device_removed(&ps2_device[PS2_DEVICE_KEYB]); goto err1; } @@ -245,7 +245,7 @@ keyboard_open(const char *name, uint32 flags, void **_cookie) atomic_or(&ps2_device[PS2_DEVICE_KEYB].flags, PS2_FLAG_ENABLED); - dprintf("ps2: keyboard_open %s success\n", name); + TRACE("ps2: keyboard_open %s success\n", name); return B_OK; err2: @@ -253,7 +253,7 @@ err2: err1: atomic_and(&sKeyboardOpenMask, 0); - dprintf("ps2: keyboard_open %s failed\n", name); + TRACE("ps2: keyboard_open %s failed\n", name); return status; } @@ -261,7 +261,7 @@ err1: static status_t keyboard_close(void *cookie) { - TRACE(("keyboard_close()\n")); + TRACE("ps2: keyboard_close\n"); delete_packet_buffer(sKeyBuffer); delete_sem(sKeyboardSem); @@ -284,7 +284,7 @@ keyboard_freecookie(void *cookie) static status_t keyboard_read(void *cookie, off_t pos, void *buffer, size_t *_length) { - TRACE(("keyboard read()\n")); + TRACE("ps2: keyboard read\n"); *_length = 0; return B_NOT_ALLOWED; } @@ -293,7 +293,7 @@ keyboard_read(void *cookie, off_t pos, void *buffer, size_t *_length) static status_t keyboard_write(void *cookie, off_t pos, const void *buffer, size_t *_length) { - TRACE(("keyboard write()\n")); + TRACE("ps2: keyboard write\n"); *_length = 0; return B_NOT_ALLOWED; } @@ -302,13 +302,13 @@ keyboard_write(void *cookie, off_t pos, const void *buffer, size_t *_length) static status_t keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length) { - TRACE(("keyboard ioctl()\n")); + TRACE("ps2: keyboard ioctl\n"); switch (op) { case KB_READ: { at_kbd_io packet; status_t status; - TRACE(("KB_READ\n")); + TRACE("ps2: KB_READ\n"); if ((status = read_keyboard_packet(&packet)) < B_OK) return status; return user_memcpy(buffer, &packet, sizeof(packet)); @@ -317,7 +317,7 @@ keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length) case KB_SET_LEDS: { led_info info; - TRACE(("KB_SET_LEDS\n")); + TRACE("ps2: KB_SET_LEDS\n"); if (user_memcpy(&info, buffer, sizeof(led_info)) < B_OK) return B_BAD_ADDRESS; return set_leds(&info); @@ -340,7 +340,7 @@ keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length) int32 key_repeat_rate; if (user_memcpy(&key_repeat_rate, buffer, sizeof(key_repeat_rate)) < B_OK) return B_BAD_ADDRESS; - dprintf("ps2: KB_SET_KEY_REPEAT_RATE %ld\n", key_repeat_rate); + TRACE("ps2: KB_SET_KEY_REPEAT_RATE %ld\n", key_repeat_rate); if (set_typematic(key_repeat_rate, sKeyboardRepeatDelay) < B_OK) return B_ERROR; sKeyboardRepeatRate = key_repeat_rate; @@ -357,7 +357,7 @@ keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length) bigtime_t key_repeat_delay; if (user_memcpy(&key_repeat_delay, buffer, sizeof(key_repeat_delay)) < B_OK) return B_BAD_ADDRESS; - dprintf("ps2: KB_SET_KEY_REPEAT_DELAY %Ld\n", key_repeat_delay); + TRACE("ps2: KB_SET_KEY_REPEAT_DELAY %Ld\n", key_repeat_delay); if (set_typematic(sKeyboardRepeatRate, key_repeat_delay) < B_OK) return B_ERROR; sKeyboardRepeatDelay = key_repeat_delay; @@ -374,11 +374,11 @@ keyboard_ioctl(void *cookie, uint32 op, void *buffer, size_t length) case KB_SET_CONTROL_ALT_DEL_TIMEOUT: case KB_CANCEL_CONTROL_ALT_DEL: case KB_DELAY_CONTROL_ALT_DEL: - TRACE(("ps2_hid: ioctl 0x%lx not implemented yet, returning B_OK\n", op)); + INFO("ps2: ioctl 0x%lx not implemented yet, returning B_OK\n", op); return B_OK; default: - TRACE(("ps2_hid: invalid ioctl 0x%lx\n", op)); + INFO("ps2: invalid ioctl 0x%lx\n", op); return EINVAL; } } diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c b/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c index cf2c004738..978dcb106b 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_mouse.c @@ -1,5 +1,5 @@ /* - * Copyright 2001-2006 Haiku, Inc. + * Copyright 2001-2007 Haiku, Inc. * Distributed under the terms of the MIT License. * * PS/2 mouse device driver @@ -46,13 +46,7 @@ * * Interrupts: * ~~~~~~~~~~ - * The PS/2 mouse device is connected to interrupt 12, which means that - * it uses the second interrupt controller (handles INT8 to INT15). In - * order for this interrupt to be enabled, both the 5th interrupt of - * the second controller AND the 3rd interrupt of the first controller - * (cascade mode) should be unmasked. - * This is all done inside install_io_interrupt_handler(), no need to - * worry about it anymore + * The PS/2 mouse device is connected to interrupt 12. * The controller uses 3 consecutive interrupts to inform the computer * that it has new data. On the first the data register holds the status * byte, on the second the X offset, and on the 3rd the Y offset. @@ -94,17 +88,17 @@ ps2_reset_mouse(mouse_cookie *cookie) uint8 data[2]; status_t status; - TRACE(("ps2_reset_mouse()\n")); + TRACE("ps2_reset_mouse\n"); status = ps2_dev_command(cookie->dev, PS2_CMD_RESET, NULL, 0, data, 2); if (status == B_OK && data[0] != 0xAA && data[1] != 0x00) { - TRACE(("reset mouse failed, response was: 0x%02x 0x%02x\n", data[0], data[1])); + TRACE("reset mouse failed, response was: 0x%02x 0x%02x\n", data[0], data[1]); status = B_ERROR; } else if (status != B_OK) { - TRACE(("reset mouse failed\n")); + TRACE("reset mouse failed\n"); } else { - TRACE(("reset mouse success\n")); + TRACE("reset mouse success\n"); } return status; @@ -151,7 +145,7 @@ ps2_packet_to_movement(mouse_cookie *cookie, uint8 packet[], mouse_movement *pos } } -// dprintf("packet: %02x %02x %02x %02x: xd %d, yd %d, 0x%x (%d), w-xd %d, w-yd %d\n", +// TRACE("packet: %02x %02x %02x %02x: xd %d, yd %d, 0x%x (%d), w-xd %d, w-yd %d\n", // packet[0], packet[1], packet[2], packet[3], // xDelta, yDelta, buttons, cookie->click_count, wheel_xdelta, wheel_ydelta); @@ -165,8 +159,8 @@ ps2_packet_to_movement(mouse_cookie *cookie, uint8 packet[], mouse_movement *pos pos->wheel_ydelta = (int)wheel_ydelta; pos->wheel_xdelta = (int)wheel_xdelta; - TRACE(("xdelta: %d, ydelta: %d, buttons %x, clicks: %d, timestamp %Ld\n", - xDelta, yDelta, buttons, cookie->click_count, currentTime)); + TRACE("xdelta: %d, ydelta: %d, buttons %x, clicks: %d, timestamp %Ld\n", + xDelta, yDelta, buttons, cookie->click_count, currentTime); } } @@ -179,23 +173,23 @@ mouse_read_event(mouse_cookie *cookie, mouse_movement *movement) uint8 packet[PS2_MAX_PACKET_SIZE]; status_t status; - TRACE(("mouse_read_event()\n")); + TRACE("ps2: mouse_read_event\n"); status = acquire_sem_etc(cookie->mouse_sem, 1, B_CAN_INTERRUPT, 0); if (status < B_OK) return status; if (!cookie->dev->active) { - dprintf("ps2: mouse_read_event: Error device no longer active\n"); + TRACE("ps2: mouse_read_event: Error device no longer active\n"); return B_ERROR; } if (packet_buffer_read(cookie->mouse_buffer, packet, cookie->packet_size) != cookie->packet_size) { - TRACE(("error copying buffer\n")); + TRACE("ps2: error copying buffer\n"); return B_ERROR; } if (!(packet[0] & 8)) - panic("ps2_hid: got broken data from packet_buffer_read\n"); + panic("ps2: got broken data from packet_buffer_read\n"); ps2_packet_to_movement(cookie, packet, movement); return B_OK; @@ -206,7 +200,7 @@ static void ps2_mouse_disconnect(ps2_dev *dev) { // the mouse device might not be opened at this point - dprintf("ps2: ps2_mouse_disconnect %s\n", dev->name); + INFO("ps2: ps2_mouse_disconnect %s\n", dev->name); if (dev->flags & PS2_FLAG_OPEN) release_sem(((mouse_cookie *)dev->cookie)->mouse_sem); } @@ -225,7 +219,7 @@ mouse_handle_int(ps2_dev *dev) const uint8 data = dev->history[0].data; if (cookie->packet_index == 0 && !(data & 8)) { - TRACE(("bad mouse data, trying resync\n")); + TRACE("bad mouse data, trying resync\n"); return B_HANDLED_INTERRUPT; } @@ -259,17 +253,20 @@ probe_mouse(mouse_cookie *cookie, size_t *probed_packet_size) status_t status; uint8 deviceId = 0; - status = ps2_reset_mouse(cookie); + if (status != B_OK) { + INFO("ps2: probe_mouse reset failed\n"); + return B_ERROR; + } // get device id status = ps2_dev_command(cookie->dev, PS2_CMD_GET_DEVICE_ID, NULL, 0, &deviceId, 1); if (status != B_OK) { - TRACE(("probe_mouse(): get device id failed\n")); + INFO("ps2: probe_mouse get device id failed\n"); return B_ERROR; } - TRACE(("probe_mouse(): device id: %2x\n", deviceId)); + TRACE("ps2: probe_mouse device id: %2x\n", deviceId); // check for MS Intellimouse if (deviceId == 0) { @@ -279,17 +276,17 @@ probe_mouse(mouse_cookie *cookie, size_t *probed_packet_size) status |= ps2_set_sample_rate(cookie, 80); status |= ps2_dev_command(cookie->dev, PS2_CMD_GET_DEVICE_ID, NULL, 0, &alternate_device_id, 1); if (status == 0) { - TRACE(("probe_mouse(): alternate device id: %2x\n", alternate_device_id)); + TRACE("ps2: probe_mouse alternate device id: %2x\n", alternate_device_id); deviceId = alternate_device_id; } } if (deviceId == PS2_DEV_ID_STANDARD) { - TRACE(("Standard PS/2 mouse found\n")); + INFO("ps2: probe_mouse Standard PS/2 mouse found\n"); if (probed_packet_size) *probed_packet_size = PS2_PACKET_STANDARD; } else if (deviceId == PS2_DEV_ID_INTELLIMOUSE) { - TRACE(("Extended PS/2 mouse found\n")); + INFO("ps2: probe_mouse Extended PS/2 mouse found\n"); if (probed_packet_size) *probed_packet_size = PS2_PACKET_INTELLIMOUSE; } else { @@ -313,7 +310,7 @@ mouse_open(const char *name, uint32 flags, void **_cookie) status_t status; int i; - dprintf("ps2: mouse_open %s\n", name); + TRACE("ps2: mouse_open %s\n", name); for (dev = NULL, i = 0; i < PS2_DEVICE_COUNT; i++) { if (0 == strcmp(ps2_device[i].name, name)) { @@ -323,7 +320,7 @@ mouse_open(const char *name, uint32 flags, void **_cookie) } if (dev == NULL) { - TRACE(("dev = NULL\n")); + TRACE("dev = NULL\n"); return B_ERROR; } @@ -344,14 +341,14 @@ mouse_open(const char *name, uint32 flags, void **_cookie) status = probe_mouse(cookie, &cookie->packet_size); if (status != B_OK) { - TRACE(("probing mouse failed\n")); + INFO("ps2: probing mouse %s failed\n", name); ps2_service_notify_device_removed(dev); goto err1; } cookie->mouse_buffer = create_packet_buffer(MOUSE_HISTORY_SIZE * cookie->packet_size); if (cookie->mouse_buffer == NULL) { - TRACE(("can't allocate mouse actions buffer\n")); + TRACE("can't allocate mouse actions buffer\n"); goto err2; } @@ -359,19 +356,19 @@ mouse_open(const char *name, uint32 flags, void **_cookie) // the interrupt handler and the read operation cookie->mouse_sem = create_sem(0, "ps2_mouse_sem"); if (cookie->mouse_sem < 0) { - TRACE(("failed creating PS/2 mouse semaphore!\n")); + TRACE("failed creating PS/2 mouse semaphore!\n"); goto err3; } status = ps2_dev_command(dev, PS2_CMD_ENABLE, NULL, 0, NULL, 0); if (status < B_OK) { - TRACE(("mouse_open(): cannot enable PS/2 mouse\n")); + INFO("ps2: cannot enable mouse %s\n", name); goto err4; } atomic_or(&dev->flags, PS2_FLAG_ENABLED); - dprintf("ps2: mouse_open %s success\n", name); + TRACE("ps2: mouse_open %s success\n", name); return B_OK; err4: @@ -383,7 +380,7 @@ err2: err1: atomic_and(&dev->flags, ~PS2_FLAG_OPEN); - dprintf("ps2: mouse_open %s failed\n", name); + TRACE("ps2: mouse_open %s failed\n", name); return B_ERROR; } @@ -393,7 +390,7 @@ mouse_close(void *_cookie) { mouse_cookie *cookie = _cookie; - dprintf("ps2: mouse_close %s\n", cookie->dev->name); + TRACE("ps2: mouse_close %s\n", cookie->dev->name); ps2_dev_command(cookie->dev, PS2_CMD_DISABLE, NULL, 0, NULL, 0); @@ -441,7 +438,7 @@ mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length) case MS_NUM_EVENTS: { int32 count; - TRACE(("MS_NUM_EVENTS\n")); + TRACE("MS_NUM_EVENTS\n"); get_sem_count(cookie->mouse_sem, &count); return count; } @@ -450,36 +447,36 @@ mouse_ioctl(void *_cookie, uint32 op, void *buffer, size_t length) { mouse_movement movement; status_t status; - TRACE(("MS_READ\n")); + TRACE("MS_READ\n"); if ((status = mouse_read_event(cookie, &movement)) < B_OK) return status; -// dprintf("%s %d %d %d %d\n", cookie->dev->name, +// TRACE("%s %d %d %d %d\n", cookie->dev->name, // movement.xdelta, movement.ydelta, movement.buttons, movement.clicks); return user_memcpy(buffer, &movement, sizeof(movement)); } case MS_SET_TYPE: - TRACE(("MS_SET_TYPE not implemented\n")); + TRACE("MS_SET_TYPE not implemented\n"); return B_BAD_VALUE; case MS_SET_MAP: - TRACE(("MS_SET_MAP (set mouse mapping) not implemented\n")); + TRACE("MS_SET_MAP (set mouse mapping) not implemented\n"); return B_BAD_VALUE; case MS_GET_ACCEL: - TRACE(("MS_GET_ACCEL (get mouse acceleration) not implemented\n")); + TRACE("MS_GET_ACCEL (get mouse acceleration) not implemented\n"); return B_BAD_VALUE; case MS_SET_ACCEL: - TRACE(("MS_SET_ACCEL (set mouse acceleration) not implemented\n")); + TRACE("MS_SET_ACCEL (set mouse acceleration) not implemented\n"); return B_BAD_VALUE; case MS_SET_CLICKSPEED: - TRACE(("MS_SETCLICK (set click speed)\n")); + TRACE("MS_SETCLICK (set click speed)\n"); return user_memcpy(&cookie->click_speed, buffer, sizeof(bigtime_t)); default: - TRACE(("unknown opcode: %ld\n", op)); + TRACE("unknown opcode: %ld\n", op); return B_BAD_VALUE; } } diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_service.c b/src/add-ons/kernel/bus_managers/ps2/ps2_service.c index 7c39482503..9bc3843af9 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_service.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_service.c @@ -1,8 +1,8 @@ /* - * Copyright 2005 Haiku, Inc. + * Copyright 2005-2007 Haiku, Inc. * Distributed under the terms of the MIT License. * - * PS/2 hid device driver + * PS/2 bus manager * * Authors (in chronological order): * Marcus Overhagen (marcus@overhagen.de) @@ -33,7 +33,7 @@ ps2_service_notify_device_added(ps2_dev *dev) { ps2_service_cmd cmd; - TRACE(("ps2_service_notify_device_added %s\n", dev->name)); + TRACE("ps2_service_notify_device_added %s\n", dev->name); cmd.id = PS2_SERVICE_NOTIFY_DEVICE_ADDED; cmd.dev = dev; @@ -41,7 +41,7 @@ ps2_service_notify_device_added(ps2_dev *dev) packet_buffer_write(sServiceCmdBuffer, (const uint8 *)&cmd, sizeof(cmd)); release_sem_etc(sServiceSem, 1, B_DO_NOT_RESCHEDULE); - TRACE(("ps2_service_notify_device_added done\n")); + TRACE("ps2_service_notify_device_added done\n"); } @@ -50,7 +50,7 @@ ps2_service_notify_device_removed(ps2_dev *dev) { ps2_service_cmd cmd; - TRACE(("ps2_service_notify_device_removed %s\n", dev->name)); + TRACE("ps2_service_notify_device_removed %s\n", dev->name); cmd.id = PS2_SERVICE_NOTIFY_DEVICE_REMOVED; cmd.dev = dev; @@ -58,14 +58,14 @@ ps2_service_notify_device_removed(ps2_dev *dev) packet_buffer_write(sServiceCmdBuffer, (const uint8 *)&cmd, sizeof(cmd)); release_sem_etc(sServiceSem, 1, B_DO_NOT_RESCHEDULE); - TRACE(("ps2_service_notify_device_removed done\n")); + TRACE("ps2_service_notify_device_removed done\n"); } static int32 ps2_service_thread(void *arg) { - TRACE(("ps2_service_thread started\n")); + TRACE("ps2_service_thread started\n"); for (;;) { status_t status; @@ -79,21 +79,21 @@ ps2_service_thread(void *arg) packet_buffer_read(sServiceCmdBuffer, (uint8 *)&cmd, sizeof(cmd)); switch (cmd.id) { case PS2_SERVICE_NOTIFY_DEVICE_ADDED: - TRACE(("PS2_SERVICE_NOTIFY_DEVICE_ADDED %s\n", cmd.dev->name)); + TRACE("PS2_SERVICE_NOTIFY_DEVICE_ADDED %s\n", cmd.dev->name); ps2_dev_publish(cmd.dev); break; case PS2_SERVICE_NOTIFY_DEVICE_REMOVED: - TRACE(("PS2_SERVICE_NOTIFY_DEVICE_REMOVED %s\n", cmd.dev->name)); + TRACE("PS2_SERVICE_NOTIFY_DEVICE_REMOVED %s\n", cmd.dev->name); ps2_dev_unpublish(cmd.dev); break; default: - TRACE(("PS2_SERVICE: unknown id %lu\n", cmd.id)); + TRACE("PS2_SERVICE: unknown id %lu\n", cmd.id); break; } } else { - dprintf("ps2_service_thread: Error, status 0x%08lx, terminating\n", status); + INFO("ps2_service_thread: Error, status 0x%08lx, terminating\n", status); break; } } @@ -104,7 +104,7 @@ ps2_service_thread(void *arg) status_t ps2_service_init(void) { - TRACE(("ps2_service_init\n")); + TRACE("ps2_service_init\n"); sServiceCmdBuffer = create_packet_buffer(sizeof(ps2_service_cmd) * 50); if (sServiceCmdBuffer == NULL) goto err1; @@ -116,7 +116,7 @@ ps2_service_init(void) goto err3; sServiceTerminate = false; resume_thread(sServiceThread); - TRACE(("ps2_service_init done\n")); + TRACE("ps2_service_init done\n"); return B_OK; err3: @@ -124,7 +124,7 @@ err3: err2: delete_packet_buffer(sServiceCmdBuffer); err1: - TRACE(("ps2_service_init failed\n")); + TRACE("ps2_service_init failed\n"); return B_ERROR; } @@ -132,7 +132,7 @@ err1: void ps2_service_exit(void) { - TRACE(("ps2_service_exit\n")); + TRACE("ps2_service_exit\n"); sServiceTerminate = true; release_sem(sServiceSem); wait_for_thread(sServiceThread, NULL); diff --git a/src/add-ons/kernel/bus_managers/ps2/ps2_service.h b/src/add-ons/kernel/bus_managers/ps2/ps2_service.h index 5a4a5a10f1..3680d2354a 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_service.h +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_service.h @@ -1,8 +1,8 @@ /* - * Copyright 2005 Haiku, Inc. + * Copyright 2005-2007 Haiku, Inc. * Distributed under the terms of the MIT License. * - * PS/2 hid device driver + * PS/2 bus manager * * Authors (in chronological order): * Marcus Overhagen (marcus@overhagen.de)