From 4730cb76638da1ff76a675027da8013e7aa0552a Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Mon, 13 Feb 2006 18:47:01 +0000 Subject: [PATCH] improved debug output remove some warnings git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16383 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/bus_managers/ps2/ps2_common.c | 34 ++++++++++++------ .../kernel/bus_managers/ps2/ps2_common.h | 10 ++++-- src/add-ons/kernel/bus_managers/ps2/ps2_dev.c | 35 ++++++++++--------- .../kernel/bus_managers/ps2/ps2_keyboard.c | 5 +-- .../kernel/bus_managers/ps2/ps2_service.c | 2 +- 5 files changed, 53 insertions(+), 33 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 13a73892e6..4329bb1b8e 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_common.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_common.c @@ -25,21 +25,21 @@ bool gMultiplexingActive = false; sem_id gControllerSem; -inline uint8 -ps2_read_ctrl() +uint8 +ps2_read_ctrl(void) { return gIsa->read_io_8(PS2_PORT_CTRL); } -inline uint8 -ps2_read_data() +uint8 +ps2_read_data(void) { return gIsa->read_io_8(PS2_PORT_DATA); } -inline void +void ps2_write_ctrl(uint8 ctrl) { TRACE(("ps2_write_ctrl 0x%02x\n", ctrl)); @@ -48,7 +48,7 @@ ps2_write_ctrl(uint8 ctrl) } -inline void +void ps2_write_data(uint8 data) { TRACE(("ps2_write_data 0x%02x\n", data)); @@ -58,7 +58,7 @@ ps2_write_data(uint8 data) status_t -ps2_wait_read() +ps2_wait_read(void) { int i; for (i = 0; i < PS2_CTRL_WAIT_TIMEOUT / 50; i++) { @@ -71,7 +71,7 @@ ps2_wait_read() status_t -ps2_wait_write() +ps2_wait_write(void) { int i; for (i = 0; i < PS2_CTRL_WAIT_TIMEOUT / 50; i++) { @@ -86,7 +86,7 @@ ps2_wait_write() // #pragma mark - void -ps2_flush() +ps2_flush(void) { int i; @@ -100,7 +100,7 @@ ps2_flush() if (!(ctrl & PS2_STATUS_OUTPUT_BUFFER_FULL)) return; data = ps2_read_data(); - TRACE(("ps2_flush: ctrl 0x%02x, data 0x%02x (%s)\n", ctrl, data, (ctrl & PS2_STATUS_AUX_DATA) ? "aux" : "keyb")); + dprintf("ps2: ps2_flush: ctrl 0x%02x, data 0x%02x (%s)\n", ctrl, data, (ctrl & PS2_STATUS_AUX_DATA) ? "aux" : "keyb"); snooze(100); } @@ -114,10 +114,14 @@ ps2_command(uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count) { status_t res; int i; - + acquire_sem(gControllerSem); atomic_add(&sIgnoreInterrupts, 1); + dprintf("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", out[i]); + res = ps2_wait_write(); if (res == B_OK) ps2_write_ctrl(cmd); @@ -126,14 +130,22 @@ ps2_command(uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count) res = ps2_wait_write(); if (res == B_OK) ps2_write_data(out[i]); + else + dprintf("ps2: ps2_command out byte %d failed\n", i); } for (i = 0; res == B_OK && i < in_count; i++) { res = ps2_wait_read(); if (res == B_OK) in[i] = ps2_read_data(); + else + dprintf("ps2: ps2_command in byte %d failed\n", i); } + for (i = 0; i < in_count; i++) + dprintf("ps2: ps2_command in 0x%02x", in[i]); + dprintf("ps2: ps2_command result 0x%08lx\n", res); + atomic_add(&sIgnoreInterrupts, -1); release_sem(gControllerSem); 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 29e3bbe665..7c5160b3e0 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_common.h +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_common.h @@ -44,10 +44,14 @@ extern sem_id gControllerSem; status_t ps2_init(void); void ps2_uninit(void); -extern status_t ps2_wait_read(); -extern status_t ps2_wait_write(); +uint8 ps2_read_ctrl(void); +uint8 ps2_read_data(void); +void ps2_write_ctrl(uint8 ctrl); +void ps2_write_data(uint8 data); +status_t ps2_wait_read(void); +status_t ps2_wait_write(void); -extern void ps2_flush(); +void ps2_flush(void); extern status_t ps2_command(uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count); 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 9c86dc78c6..26aa578784 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_dev.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_dev.c @@ -68,7 +68,7 @@ ps2_dev_publish(ps2_dev *dev) status = devfs_publish_device(dev->name, NULL, (atomic_get(&dev->flags) & PS2_FLAG_KEYB) ? &gKeyboardDeviceHooks : &gMouseDeviceHooks); - TRACE(("devfs_publish_device %s, status = 0x%08x\n", dev->name, status)); + dprintf("ps2: devfs_publish_device %s, status = 0x%08lx\n", dev->name, status); } @@ -151,14 +151,16 @@ ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 { status_t res; bigtime_t start; - int i, count; int32 sem_count; + int i; - dprintf("ps2_dev_command %02x, %d out, in %d, dev %s\n", cmd, out_count, in_count, dev->name); + dprintf("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", out[i]); res = get_sem_count(dev->result_sem, &sem_count); if (res == B_OK && sem_count != 0) { - dprintf("ps2_dev_command: sem_count %ld, fixing!\n", sem_count); + dprintf("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 @@ -200,17 +202,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_dev_command wait for ack res %08x, wait-time %Ld\n", res, system_time() - start); + dprintf("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_dev_command got ACK\n"); + dprintf("ps2: ps2_dev_command got ACK\n"); } if (atomic_get(&dev->flags) & PS2_FLAG_NACK) { - dprintf("ps2_dev_command got NACK\n"); + dprintf("ps2: ps2_dev_command got NACK\n"); res = B_ERROR; break; } @@ -218,20 +220,21 @@ ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 } if (res == B_OK && in_count != 0) { - dprintf("ps2_dev_command waiting input data\n"); - 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); - count = in_count - dev->result_buf_cnt; - dev->result_buf_cnt = 0; - - dprintf("ps2_dev_command wait for input res %08x, in %d, wait-time %Ld\n", res, count, system_time() - start); - - for (i = 0; i < count; i++) - dprintf("ps2_dev_command data %02x\n", in[i]); + if (dev->result_buf_cnt != 0) { + dprintf("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]); } + dprintf("ps2: ps2_dev_command result 0x%08lx\n", res); + atomic_and(&dev->flags, ~PS2_FLAG_CMD); return res; 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 89600f4d7c..10a4056fdf 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_keyboard.c @@ -215,7 +215,7 @@ keyboard_open(const char *name, uint32 flags, void **_cookie) { status_t status; - TRACE(("keyboard open()\n")); + dprintf("ps2: keyboard_open\n"); if (atomic_or(&sKeyboardOpenMask, 1) != 0) return B_BUSY; @@ -242,7 +242,7 @@ keyboard_open(const char *name, uint32 flags, void **_cookie) *_cookie = NULL; - TRACE(("keyboard_open(): done.\n")); + dprintf("ps2: keyboard_open success\n"); return B_OK; err4: @@ -253,6 +253,7 @@ err2: err1: atomic_and(&sKeyboardOpenMask, 0); + dprintf("ps2: keyboard_open failed\n"); return status; } 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 ce6f165855..be30638e39 100644 --- a/src/add-ons/kernel/bus_managers/ps2/ps2_service.c +++ b/src/add-ons/kernel/bus_managers/ps2/ps2_service.c @@ -130,7 +130,7 @@ ps2_service_thread(void *arg) // do periodic processing } else { - dprintf("ps2_service_thread: Error, status 0x%08x, terminating\n", status); + dprintf("ps2_service_thread: Error, status 0x%08lx, terminating\n", status); break; } }