remote.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * IBM ASM Service Processor Device Driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright (C) IBM Corporation, 2004
  19. *
  20. * Author: Max Asböck <amax@us.ibm.com>
  21. *
  22. * Orignally written by Pete Reynolds
  23. */
  24. #ifndef _IBMASM_REMOTE_H_
  25. #define _IBMASM_REMOTE_H_
  26. #include <asm/io.h>
  27. /* pci offsets */
  28. #define CONDOR_MOUSE_DATA 0x000AC000
  29. #define CONDOR_MOUSE_ISR_CONTROL 0x00
  30. #define CONDOR_MOUSE_ISR_STATUS 0x04
  31. #define CONDOR_MOUSE_Q_READER 0x08
  32. #define CONDOR_MOUSE_Q_WRITER 0x0C
  33. #define CONDOR_MOUSE_Q_BEGIN 0x10
  34. #define CONDOR_MOUSE_MAX_X 0x14
  35. #define CONDOR_MOUSE_MAX_Y 0x18
  36. #define CONDOR_INPUT_DESKTOP_INFO 0x1F0
  37. #define CONDOR_INPUT_DISPLAY_RESX 0x1F4
  38. #define CONDOR_INPUT_DISPLAY_RESY 0x1F8
  39. #define CONDOR_INPUT_DISPLAY_BITS 0x1FC
  40. #define CONDOR_OUTPUT_VNC_STATUS 0x200
  41. #define CONDOR_MOUSE_INTR_STATUS_MASK 0x00000001
  42. #define INPUT_TYPE_MOUSE 0x1
  43. #define INPUT_TYPE_KEYBOARD 0x2
  44. /* mouse button states received from SP */
  45. #define REMOTE_MOUSE_DOUBLE_CLICK 0xF0
  46. #define REMOTE_MOUSE_BUTTON_LEFT 0x01
  47. #define REMOTE_MOUSE_BUTTON_MIDDLE 0x02
  48. #define REMOTE_MOUSE_BUTTON_RIGHT 0x04
  49. struct mouse_input {
  50. unsigned short y;
  51. unsigned short x;
  52. };
  53. struct keyboard_input {
  54. unsigned short key_code;
  55. unsigned char key_flag;
  56. unsigned char key_down;
  57. };
  58. struct remote_input {
  59. union {
  60. struct mouse_input mouse;
  61. struct keyboard_input keyboard;
  62. } data;
  63. unsigned char type;
  64. unsigned char pad1;
  65. unsigned char mouse_buttons;
  66. unsigned char pad3;
  67. };
  68. #define mouse_addr(sp) sp->base_address + CONDOR_MOUSE_DATA
  69. #define display_width(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESX
  70. #define display_height(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_RESY
  71. #define display_depth(sp) mouse_addr(sp) + CONDOR_INPUT_DISPLAY_BITS
  72. #define vnc_status(sp) mouse_addr(sp) + CONDOR_OUTPUT_VNC_STATUS
  73. #define mouse_interrupt_pending(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
  74. #define clear_mouse_interrupt(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_STATUS)
  75. #define enable_mouse_interrupts(sp) writel(1, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
  76. #define disable_mouse_interrupts(sp) writel(0, mouse_addr(sp) + CONDOR_MOUSE_ISR_CONTROL)
  77. /* remote input queue operations */
  78. #define REMOTE_QUEUE_SIZE 60
  79. #define get_queue_writer(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_WRITER)
  80. #define get_queue_reader(sp) readl(mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
  81. #define set_queue_reader(sp, reader) writel(reader, mouse_addr(sp) + CONDOR_MOUSE_Q_READER)
  82. #define queue_begin mouse_addr(sp) + CONDOR_MOUSE_Q_BEGIN
  83. #define get_queue_entry(sp, read_index) \
  84. queue_begin + read_index * sizeof(struct remote_input)
  85. static inline int advance_queue_reader(struct service_processor *sp, unsigned long reader)
  86. {
  87. reader++;
  88. if (reader == REMOTE_QUEUE_SIZE)
  89. reader = 0;
  90. set_queue_reader(sp, reader);
  91. return reader;
  92. }
  93. #endif /* _IBMASM_REMOTE_H_ */