Changeset 86018c1 in mainline
- 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
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
defaults/sparc64/sun4v/Makefile.config
reeb643d r86018c1 7 7 CONFIG_RD_EXTERNAL = n 8 8 9 CONFIG_LOG = y9 # CONFIG_LOG = y 10 10 11 11 CONFIG_SMP = n -
kernel/arch/sparc64/src/drivers/niagara.c
reeb643d r86018c1 54 54 #define POLL_INTERVAL 10000 55 55 56 /**57 * The driver is polling based, but in order to notify the userspace58 * of a key being pressed, we need to supply the interface with some59 * interrupt number. The interrupt number can be arbitrary as it it60 * will never be used for identifying HW interrupts, but only in61 * notifying the userspace.62 */63 #define FICTIONAL_INR 164 65 66 56 static niagara_instance_t *instance = NULL; 67 57 … … 95 85 output_buffer; 96 86 97 #if 0 98 /** Niagara character device */ 99 chardev_t niagara_io; 100 101 /** defined in drivers/kbd.c */ 102 extern kbd_type_t kbd_type; 103 104 /** 105 * The character read will be stored here until the (notified) uspace 106 * driver picks it up. 107 */ 108 static char read_char; 109 110 111 #endif 87 /** 88 * Analogous to the output_buffer, see the previous definition. 89 */ 90 #define INPUT_BUFFER_SIZE ((PAGE_SIZE) - 2 * 8) 91 static volatile struct { 92 uint64_t write_ptr; 93 uint64_t read_ptr; 94 char data[INPUT_BUFFER_SIZE]; 95 } 96 __attribute__ ((packed)) 97 __attribute__ ((aligned(PAGE_SIZE))) 98 input_buffer; 99 112 100 113 101 /** Writes a single character to the standard output. */ … … 126 114 } 127 115 128 #if 0129 /**130 * Grabs the input for kernel.131 */132 void niagara_grab(void)133 {134 ipl_t ipl = interrupts_disable();135 spinlock_lock(&niagara_irq.lock);136 niagara_irq.notif_cfg.notify = false;137 spinlock_unlock(&niagara_irq.lock);138 interrupts_restore(ipl);139 }140 141 /**142 * Releases the input so that userspace can use it.143 */144 void niagara_release(void)145 {146 ipl_t ipl = interrupts_disable();147 spinlock_lock(&niagara_irq.lock);148 if (niagara_irq.notif_cfg.answerbox)149 niagara_irq.notif_cfg.notify = true;150 spinlock_unlock(&niagara_irq.lock);151 interrupts_restore(ipl);152 }153 154 /**155 * Default suspend/resume operation for the input device.156 */157 static void niagara_noop(chardev_t *d)158 {159 }160 161 /**162 * Called when actively reading the character.163 */164 static char niagara_read(chardev_t *d)165 {166 uint64_t c;167 168 if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) {169 return (char) c;170 }171 172 return '\0';173 }174 175 /**176 * Returns the character last read. This function is called from the177 * pseudocode - the character returned by this function is passed to178 * the userspace keyboard driver.179 */180 char niagara_getc(void) {181 return read_char;182 }183 184 #endif185 186 116 /** 187 117 * Function regularly called by the keyboard polling thread. Asks the 188 118 * hypervisor whether there is any unread character. If so, it picks it up 189 119 * and sends it to the upper layers of HelenOS. 120 * 121 * Apart from that, it also checks whether the userspace output driver has 122 * pushed any characters to the output buffer. If so, it prints them. 190 123 */ 191 124 static void niagara_poll(niagara_instance_t *instance) … … 200 133 201 134 if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) { 202 indev_push_character(instance->srlnin, c); 135 if (!silent) { 136 indev_push_character(instance->srlnin, c); 137 } else { 138 input_buffer.data[input_buffer.write_ptr] = (char) c; 139 input_buffer.write_ptr = 140 ((input_buffer.write_ptr) + 1) % INPUT_BUFFER_SIZE; 141 } 203 142 } 204 143 … … 210 149 static void kniagarapoll(void *instance) { 211 150 while (true) { 212 //MH 213 //if (!silent) 214 niagara_poll(instance); 215 151 niagara_poll(instance); 216 152 thread_usleep(POLL_INTERVAL); 217 153 } … … 245 181 /* 246 182 * Set sysinfos and pareas so that the userspace counterpart of the 247 * niagara fb driver can communicate with kernel using a shared buffer. 183 * niagara fb and kbd driver can communicate with kernel using shared 184 * buffers. 248 185 */ 249 186 output_buffer.read_ptr = 0; 250 187 output_buffer.write_ptr = 0; 188 input_buffer.write_ptr = 0; 189 input_buffer.read_ptr = 0; 251 190 252 191 sysinfo_set_item_val("niagara.outbuf.address", NULL, … … 257 196 OUTPUT_BUFFER_SIZE); 258 197 198 sysinfo_set_item_val("niagara.inbuf.address", NULL, 199 KA2PA(&input_buffer)); 200 sysinfo_set_item_val("niagara.inbuf.size", NULL, 201 PAGE_SIZE); 202 sysinfo_set_item_val("niagara.inbuf.datasize", NULL, 203 INPUT_BUFFER_SIZE); 204 259 205 static parea_t outbuf_parea; 260 206 outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer)); … … 262 208 ddi_parea_register(&outbuf_parea); 263 209 264 #if 0 265 kbd_type = KBD_SUN4V; 266 267 devno_t devno = device_assign_devno(); 268 irq_initialize(&niagara_irq); 269 niagara_irq.devno = devno; 270 niagara_irq.inr = FICTIONAL_INR; 271 niagara_irq.claim = niagara_claim; 272 niagara_irq.handler = niagara_irq_handler; 273 irq_register(&niagara_irq); 274 275 sysinfo_set_item_val("kbd", NULL, true); 276 sysinfo_set_item_val("kbd.type", NULL, KBD_SUN4V); 277 sysinfo_set_item_val("kbd.devno", NULL, devno); 278 sysinfo_set_item_val("kbd.inr", NULL, FICTIONAL_INR); 279 #endif 280 281 /* 282 * Set sysinfos and pareas so that the userspace counterpart of the 283 * niagara fb driver can communicate with kernel using a shared buffer. 284 */ 285 //output_buffer.read_ptr = 0; 286 //output_buffer.write_ptr = 0; 287 288 #if 0 289 sysinfo_set_item_val("niagara.outbuf.address", NULL, 290 KA2PA(&output_buffer)); 291 sysinfo_set_item_val("niagara.outbuf.size", NULL, 292 PAGE_SIZE); 293 sysinfo_set_item_val("niagara.outbuf.datasize", NULL, 294 OUTPUT_BUFFER_SIZE); 295 static parea_t outbuf_parea; 296 outbuf_parea.pbase = (uintptr_t) (KA2PA(&output_buffer)); 297 outbuf_parea.vbase = (uintptr_t) (&output_buffer); 298 outbuf_parea.frames = 1; 299 outbuf_parea.cacheable = false; 300 ddi_parea_register(&outbuf_parea); 301 302 #endif 210 static parea_t inbuf_parea; 211 inbuf_parea.pbase = (uintptr_t) (KA2PA(&input_buffer)); 212 inbuf_parea.frames = 1; 213 ddi_parea_register(&inbuf_parea); 303 214 304 215 outdev_t *niagara_dev = malloc(sizeof(outdev_t), FRAME_ATOMIC); -
uspace/lib/libc/arch/sparc64/src/thread_entry.s
reeb643d r86018c1 38 38 # Create the first stack frame. 39 39 # 40 save %sp, -176, %sp 41 flushw 42 add %g0, -0x7ff, %fp 40 41 # MH 42 #save %sp, -176, %sp 43 #flushw 44 #add %g0, -0x7ff, %fp 43 45 44 46 sethi %hi(_gp), %l7 -
uspace/lib/libc/generic/thread.c
reeb643d r86018c1 41 41 #include <string.h> 42 42 #include <async.h> 43 #include <stdio.h> 43 44 44 45 #ifndef THREAD_INITIAL_STACK_PAGES_NO … … 62 63 __tcb_set(f->tcb); 63 64 65 // MH 66 printf("uarg: %lx\n", uarg); 64 67 uarg->uspace_thread_function(uarg->uspace_thread_arg); 65 68 /* XXX: we cannot free the userspace stack while running on it */ -
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.