Rev 4311 | Rev 4329 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4311 | Rev 4313 | ||
---|---|---|---|
Line 132... | Line 132... | ||
132 | /** SGCN output device operations */ |
132 | /** SGCN output device operations */ |
133 | static outdev_operations_t sgcnout_ops = { |
133 | static outdev_operations_t sgcnout_ops = { |
134 | .write = sgcn_putchar |
134 | .write = sgcn_putchar |
135 | }; |
135 | }; |
136 | 136 | ||
137 | /** SGCN input device operations */ |
- | |
138 | static indev_operations_t sgcnin_ops = { |
- | |
139 | .poll = NULL |
- | |
140 | }; |
- | |
141 | - | ||
142 | static indev_t sgcnin; /**< SGCN input device. */ |
- | |
143 | static outdev_t sgcnout; /**< SGCN output device. */ |
137 | static outdev_t sgcnout; /**< SGCN output device. */ |
144 | 138 | ||
145 | /** |
139 | /** |
146 | * Set some sysinfo values (SRAM address and SRAM size). |
140 | * Set some sysinfo values (SRAM address and SRAM size). |
147 | */ |
141 | */ |
Line 299... | Line 293... | ||
299 | /** |
293 | /** |
300 | * Function regularly called by the keyboard polling thread. Finds out whether |
294 | * Function regularly called by the keyboard polling thread. Finds out whether |
301 | * there are some unread characters in the input queue. If so, it picks them up |
295 | * there are some unread characters in the input queue. If so, it picks them up |
302 | * and sends them to the upper layers of HelenOS. |
296 | * and sends them to the upper layers of HelenOS. |
303 | */ |
297 | */ |
304 | static void sgcn_poll() |
298 | static void sgcn_poll(sgcn_instance_t *instance) |
305 | { |
299 | { |
306 | uint32_t begin = SGCN_BUFFER_HEADER->in_begin; |
300 | uint32_t begin = SGCN_BUFFER_HEADER->in_begin; |
307 | uint32_t end = SGCN_BUFFER_HEADER->in_end; |
301 | uint32_t end = SGCN_BUFFER_HEADER->in_end; |
308 | uint32_t size = end - begin; |
302 | uint32_t size = end - begin; |
309 | 303 | ||
Line 317... | Line 311... | ||
317 | SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); |
311 | SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); |
318 | volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr); |
312 | volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr); |
319 | volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr); |
313 | volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr); |
320 | 314 | ||
321 | while (*in_rdptr_ptr != *in_wrptr_ptr) { |
315 | while (*in_rdptr_ptr != *in_wrptr_ptr) { |
322 | - | ||
323 | buf_ptr = (volatile char *) |
316 | buf_ptr = (volatile char *) |
324 | SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); |
317 | SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr); |
325 | char c = *buf_ptr; |
318 | char c = *buf_ptr; |
326 | *in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; |
319 | *in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin; |
327 | 320 | ||
328 | indev_push_character(&sgcnin, c); |
321 | indev_push_character(instance->srlnin, c); |
329 | } |
322 | } |
330 | 323 | ||
331 | spinlock_unlock(&sgcn_input_lock); |
324 | spinlock_unlock(&sgcn_input_lock); |
332 | } |
325 | } |
333 | 326 | ||
334 | /** |
327 | /** |
335 | * Polling thread function. |
328 | * Polling thread function. |
336 | */ |
329 | */ |
337 | static void kkbdpoll(void *arg) { |
330 | static void ksgcnpoll(void *instance) { |
338 | while (1) { |
331 | while (1) { |
339 | if (!silent) { |
332 | if (!silent) |
340 | sgcn_poll(); |
333 | sgcn_poll(instance); |
341 | } |
- | |
342 | thread_usleep(POLL_INTERVAL); |
334 | thread_usleep(POLL_INTERVAL); |
343 | } |
335 | } |
344 | } |
336 | } |
345 | 337 | ||
346 | /** |
338 | /** |
347 | * A public function which initializes input from the Serengeti console. |
339 | * A public function which initializes input from the Serengeti console. |
348 | */ |
340 | */ |
349 | indev_t *sgcnin_init(void) |
341 | sgcn_instance_t *sgcnin_init(void) |
350 | { |
342 | { |
351 | sgcn_buffer_begin_init(); |
343 | sgcn_buffer_begin_init(); |
352 | 344 | ||
- | 345 | sgcn_instance_t *instance = |
|
353 | sysinfo_set_item_val("kbd", NULL, true); |
346 | malloc(sizeof(sgcn_instance_t), FRAME_ATOMIC); |
- | 347 | if (!instance) |
|
- | 348 | return NULL; |
|
354 | 349 | ||
- | 350 | instance->srlnin = NULL; |
|
355 | thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true); |
351 | instance->thread = thread_create(ksgcnpoll, instance, TASK, 0, |
- | 352 | "ksgcnpoll", true); |
|
356 | if (!t) |
353 | if (!instance->thread) { |
357 | panic("Cannot create kkbdpoll."); |
354 | free(instance); |
358 | thread_ready(t); |
355 | return NULL; |
- | 356 | } |
|
359 | 357 | ||
- | 358 | return instance; |
|
- | 359 | } |
|
- | 360 | ||
360 | indev_initialize("sgcnin", &sgcnin, &sgcnin_ops); |
361 | void sgcnin_wire(sgcn_instance_t *instance, indev_t *srlnin) |
- | 362 | { |
|
- | 363 | ASSERT(instance); |
|
- | 364 | ASSERT(srlnin); |
|
361 | 365 | ||
362 | return &sgcnin; |
366 | instance->srlnin = srlnin; |
- | 367 | thread_ready(instance->thread); |
|
- | 368 | ||
- | 369 | sysinfo_set_item_val("kbd", NULL, true); |
|
363 | } |
370 | } |
364 | 371 | ||
365 | /** |
372 | /** |
366 | * A public function which initializes output to the Serengeti console. |
373 | * A public function which initializes output to the Serengeti console. |
367 | */ |
374 | */ |