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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.