Changeset 86018c1 in mainline for uspace/srv/hid/kbd/port/niagara.c


Ignore:
Timestamp:
2010-01-24T19:48:56Z (14 years ago)
Author:
Pavel Rimsky <pavel@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e33e1d
Parents:
eeb643d
Message:

Implemented uspace keyboard driver. Cleanup needed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/kbd/port/niagara.c

    reeb643d r86018c1  
    4747#define POLL_INTERVAL           10000
    4848
     49/**
     50 * Virtual address mapped to the buffer shared with the kernel counterpart.
     51 */
     52static 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)
     60typedef 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
     69input_buffer_t input_buffer;
     70
    4971static volatile bool polling_disabled = false;
    50 //static void *niagara_thread_impl(void *arg);
     72static void *niagara_thread_impl(void *arg);
    5173
    5274/**
     
    5678int kbd_port_init(void)
    5779{
    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
    6093        thread_id_t tid;
    6194        int rc;
     
    6598                return rc;
    6699        }
    67         */
    68100        return 0;
    69101}
     
    90122static void niagara_key_pressed(void)
    91123{
    92         printf("%s\n", "polling");
    93 /*
    94124        char c;
    95125       
    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;
    110130                kbd_push_scancode(c);
    111131        }
    112 */
    113132}
    114133
     
    116135 * Thread to poll SGCN for keypresses.
    117136 */
    118 /*
    119137static void *niagara_thread_impl(void *arg)
    120138{
     
    128146        return 0;
    129147}
    130 */
    131148/** @}
    132149 */
Note: See TracChangeset for help on using the changeset viewer.