Changeset 86018c1 in mainline for uspace/srv
- Timestamp:
- 2010-01-24T19:48:56Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8e33e1d
- Parents:
- eeb643d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/kbd/port/niagara.c
reeb643d r86018c1 47 47 #define POLL_INTERVAL 10000 48 48 49 /** 50 * Virtual address mapped to the buffer shared with the kernel counterpart. 51 */ 52 static uintptr_t input_buffer_addr; 53 54 /* 55 * Kernel counterpart of the driver pushes characters (it has read) here. 56 * Keep in sync with the definition from 57 * kernel/arch/sparc64/src/drivers/niagara.c. 58 */ 59 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 60 typedef volatile struct { 61 uint64_t write_ptr; 62 uint64_t read_ptr; 63 char data[INPUT_BUFFER_SIZE]; 64 } 65 __attribute__ ((packed)) 66 __attribute__ ((aligned(PAGE_SIZE))) 67 *input_buffer_t; 68 69 input_buffer_t input_buffer; 70 49 71 static volatile bool polling_disabled = false; 50 //static void *niagara_thread_impl(void *arg);72 static void *niagara_thread_impl(void *arg); 51 73 52 74 /** … … 56 78 int kbd_port_init(void) 57 79 { 58 printf("****************** Niagara keyboard driver **********************\n"); 59 /* 80 input_buffer_addr = (uintptr_t) as_get_mappable_page(PAGE_SIZE); 81 int result = physmem_map( 82 (void *) sysinfo_value("niagara.inbuf.address"), 83 (void *) input_buffer_addr, 84 1, AS_AREA_READ | AS_AREA_WRITE); 85 86 if (result != 0) { 87 printf("Niagara: uspace driver couldn't map physical memory: %d\n", 88 result); 89 } 90 91 input_buffer = (input_buffer_t) input_buffer_addr; 92 60 93 thread_id_t tid; 61 94 int rc; … … 65 98 return rc; 66 99 } 67 */68 100 return 0; 69 101 } … … 90 122 static void niagara_key_pressed(void) 91 123 { 92 printf("%s\n", "polling");93 /*94 124 char c; 95 125 96 uint32_t begin = SGCN_BUFFER_HEADER->in_begin; 97 uint32_t end = SGCN_BUFFER_HEADER->in_end; 98 uint32_t size = end - begin; 99 100 volatile char *buf_ptr = (volatile char *) 101 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 102 volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr); 103 volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr); 104 105 while (*in_rdptr_ptr != *in_wrptr_ptr) { 106 c = *buf_ptr; 107 *in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; 108 buf_ptr = (volatile char *) 109 SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); 126 while (input_buffer->read_ptr != input_buffer->write_ptr) { 127 c = input_buffer->data[input_buffer->read_ptr]; 128 input_buffer->read_ptr = 129 ((input_buffer->read_ptr) + 1) % INPUT_BUFFER_SIZE; 110 130 kbd_push_scancode(c); 111 131 } 112 */113 132 } 114 133 … … 116 135 * Thread to poll SGCN for keypresses. 117 136 */ 118 /*119 137 static void *niagara_thread_impl(void *arg) 120 138 { … … 128 146 return 0; 129 147 } 130 */131 148 /** @} 132 149 */
Note:
See TracChangeset
for help on using the changeset viewer.