Changeset 253d3d0 in mainline


Ignore:
Timestamp:
2009-04-21T19:52:32Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5646813
Parents:
f2d2c7ba
Message:

Convert sgcn to the new HID wiring mechanism.

Location:
kernel/arch
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/drivers/ski.c

    rf2d2c7ba r253d3d0  
    184184        ski_init();
    185185       
    186         ski_instance_t *instance
    187             = malloc(sizeof(ski_instance_t), FRAME_ATOMIC);
     186        ski_instance_t *instance =
     187            malloc(sizeof(ski_instance_t), FRAME_ATOMIC);
    188188       
    189189        if (instance) {
    190                 instance->thread = thread_create(kskipoll, (void *) instance, TASK, 0, "kskipoll", true);
     190                instance->thread = thread_create(kskipoll, instance, TASK, 0,
     191                    "kskipoll", true);
    191192               
    192193                if (!instance->thread) {
  • kernel/arch/sparc64/include/drivers/sgcn.h

    rf2d2c7ba r253d3d0  
    3838#include <arch/types.h>
    3939#include <console/chardev.h>
     40#include <proc/thread.h>
    4041
    4142/* number of bytes in the TOC magic, including the NULL-terminator */
     
    117118} __attribute__ ((packed)) sgcn_buffer_header_t;
    118119
    119 void sgcn_grab(void);
    120 void sgcn_release(void);
    121 indev_t *sgcnin_init(void);
    122 void sgcnout_init(void);
     120typedef struct {
     121        thread_t *thread;
     122        indev_t *srlnin;
     123} sgcn_instance_t;
     124
     125extern void sgcn_grab(void);
     126extern void sgcn_release(void);
     127extern sgcn_instance_t *sgcnin_init(void);
     128extern void sgcnin_wire(sgcn_instance_t *, indev_t *);
     129extern void sgcnout_init(void);
    123130
    124131#endif
  • kernel/arch/sparc64/src/console.c

    rf2d2c7ba r253d3d0  
    9393{
    9494#ifdef CONFIG_SGCN_KBD
    95         indev_t *kbrdin;
    96         kbrdin = sgcnin_init();
    97         if (kbrdin)
    98                 srln_init(kbrdin);
     95        sgcn_instance_t *sgcn_instance = sgcnin_init();
     96        if (sgcn_instance) {
     97                srln_instance_t *srln_instance = srln_init();
     98                if (srln_instance) {
     99                        indev_t *sink = stdin_wire();
     100                        indev_t *srln = srln_wire(srln_instance, sink);
     101                        sgcnin_wire(sgcn_instance, srln);
     102                }
     103        }
    99104#endif
    100105#ifdef CONFIG_SGCN_PRN
  • kernel/arch/sparc64/src/drivers/sgcn.c

    rf2d2c7ba r253d3d0  
    135135};
    136136
    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. */
    143137static outdev_t sgcnout;        /**< SGCN output device. */
    144138
     
    302296 * and sends them to the upper layers of HelenOS.
    303297 */
    304 static void sgcn_poll()
     298static void sgcn_poll(sgcn_instance_t *instance)
    305299{
    306300        uint32_t begin = SGCN_BUFFER_HEADER->in_begin;
     
    320314       
    321315        while (*in_rdptr_ptr != *in_wrptr_ptr) {
    322                
    323316                buf_ptr = (volatile char *)
    324317                    SGCN_BUFFER(char, SGCN_BUFFER_HEADER->in_rdptr);
     
    326319                *in_rdptr_ptr = (((*in_rdptr_ptr) - begin + 1) % size) + begin;
    327320                       
    328                 indev_push_character(&sgcnin, c);       
     321                indev_push_character(instance->srlnin, c);     
    329322        }       
    330323
     
    335328 * Polling thread function.
    336329 */
    337 static void kkbdpoll(void *arg) {
     330static void ksgcnpoll(void *instance) {
    338331        while (1) {
    339                 if (!silent) {
    340                         sgcn_poll();
    341                 }
     332                if (!silent)
     333                        sgcn_poll(instance);
    342334                thread_usleep(POLL_INTERVAL);
    343335        }
     
    347339 * A public function which initializes input from the Serengeti console.
    348340 */
    349 indev_t *sgcnin_init(void)
     341sgcn_instance_t *sgcnin_init(void)
    350342{
    351343        sgcn_buffer_begin_init();
    352344
     345        sgcn_instance_t *instance =
     346            malloc(sizeof(sgcn_instance_t), FRAME_ATOMIC);
     347        if (!instance)
     348                return NULL;
     349
     350        instance->srlnin = NULL;
     351        instance->thread = thread_create(ksgcnpoll, instance, TASK, 0,
     352            "ksgcnpoll", true);
     353        if (!instance->thread) {
     354                free(instance);
     355                return NULL;
     356        }
     357       
     358        return instance;
     359}
     360
     361void sgcnin_wire(sgcn_instance_t *instance, indev_t *srlnin)
     362{
     363        ASSERT(instance);
     364        ASSERT(srlnin);
     365
     366        instance->srlnin = srlnin;
     367        thread_ready(instance->thread);
     368
    353369        sysinfo_set_item_val("kbd", NULL, true);
    354 
    355         thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true);
    356         if (!t)
    357                 panic("Cannot create kkbdpoll.");
    358         thread_ready(t);
    359        
    360         indev_initialize("sgcnin", &sgcnin, &sgcnin_ops);
    361 
    362         return &sgcnin;
    363370}
    364371
Note: See TracChangeset for help on using the changeset viewer.