1 /* 2 * Copyright 2005-2007 Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * PS/2 bus manager 6 * 7 * Authors (in chronological order): 8 * Marcus Overhagen (marcus@overhagen.de) 9 */ 10 #ifndef __PS2_DEV_H 11 #define __PS2_DEV_H 12 13 struct ps2_dev; 14 typedef struct ps2_dev ps2_dev; 15 16 #include "ps2_common.h" 17 18 typedef struct 19 { 20 bigtime_t time; 21 uint8 data; 22 bool error; 23 } data_history; 24 25 struct ps2_dev 26 { 27 const char * name; 28 bool active; 29 uint32 flags; 30 uint8 idx; 31 sem_id result_sem; 32 uint8 * result_buf; 33 int result_buf_idx; 34 int result_buf_cnt; 35 void * cookie; 36 data_history history[2]; 37 38 // functions 39 void (*disconnect)(ps2_dev *); 40 int32 (*handle_int)(ps2_dev *); 41 }; 42 43 #define PS2_DEVICE_COUNT 5 44 45 extern ps2_dev ps2_device[PS2_DEVICE_COUNT]; 46 47 #define PS2_DEVICE_MOUSE 0 48 #define PS2_DEVICE_KEYB 4 49 50 #define PS2_FLAG_KEYB (1<<0) 51 #define PS2_FLAG_OPEN (1<<1) 52 #define PS2_FLAG_ENABLED (1<<2) 53 #define PS2_FLAG_CMD (1<<3) 54 #define PS2_FLAG_ACK (1<<4) 55 #define PS2_FLAG_NACK (1<<5) 56 #define PS2_FLAG_GETID (1<<6) 57 58 status_t ps2_dev_init(void); 59 void ps2_dev_exit(void); 60 61 status_t ps2_dev_command(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count); 62 status_t ps2_dev_command_timeout(ps2_dev *dev, uint8 cmd, const uint8 *out, int out_count, uint8 *in, int in_count, bigtime_t timeout); 63 64 void ps2_dev_publish(ps2_dev *dev); 65 void ps2_dev_unpublish(ps2_dev *dev); 66 67 int32 ps2_dev_handle_int(ps2_dev *dev); 68 69 #endif 70