Ignore:
Timestamp:
2009-11-08T20:05:48Z (14 years ago)
Author:
Pavel Rimsky <pavel@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
70a1c59
Parents:
74cbac7d
Message:

Kernel input driver implemented, now the kconsole is usable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc64/src/drivers/niagara.c

    r74cbac7d r69b68d1f  
    4141#include <ddi/device.h>
    4242#include <arch/asm.h>
     43#include <arch.h>
    4344#include <mm/slab.h>
    4445#include <arch/drivers/kbd.h>
     
    4647#include <sysinfo/sysinfo.h>
    4748#include <ipc/irq.h>
     49#include <print.h>
     50#include <proc/thread.h>
     51#include <console/console.h>
     52#include <genarch/srln/srln.h>
     53
     54#define POLL_INTERVAL  10000
    4855
    4956/**
     
    5562 */
    5663#define FICTIONAL_INR           1
     64
     65
     66static niagara_instance_t *instance = NULL;
    5767
    5868/* functions referenced from definitions of I/O operations structures */
     
    7888 * the mapped buffer. The shared buffer definition follows.
    7989 */
     90/*
    8091#define OUTPUT_BUFFER_SIZE      ((PAGE_SIZE) - 2 * 8)
    8192static volatile struct {
     
    8798        __attribute__ ((aligned(PAGE_SIZE)))
    8899        output_buffer;
     100*/
    89101
    90102#if 0
     
    197209}
    198210
     211#endif
     212
    199213/**
    200214 * Function regularly called by the keyboard polling thread. Asks the
     
    202216 * and sends it to the upper layers of HelenOS.
    203217 */
    204 void niagara_poll(void)
    205 {
     218static void niagara_poll(niagara_instance_t *instance)
     219{
     220        /*
    206221        while (output_buffer.read_ptr != output_buffer.write_ptr) {
    207222                do_putchar(output_buffer.data[output_buffer.read_ptr]);
     
    209224                        ((output_buffer.read_ptr) + 1) % OUTPUT_BUFFER_SIZE;
    210225        }
     226        */
    211227
    212228        uint64_t c;
    213229
    214230        if (__hypercall_fast_ret1(0, 0, 0, 0, 0, CONS_GETCHAR, &c) == EOK) {
     231                indev_push_character(instance->srlnin, c);
     232                #if 0
    215233                ipl_t ipl = interrupts_disable();
    216234                spinlock_lock(&niagara_irq.lock);
     
    235253                                chardev_push_character(&niagara_io, '\n');
    236254                }
    237         }
    238 
    239 }
    240 
    241 #endif
     255                #endif
     256        }
     257
     258}
     259
     260/**
     261 * Polling thread function.
     262 */
     263static void kniagarapoll(void *instance) {
     264        while (true) {
     265                //MH
     266                //if (!silent)
     267                        niagara_poll(instance);
     268               
     269                thread_usleep(POLL_INTERVAL);
     270        }
     271}
    242272
    243273/**
     
    245275 * input/output is used.
    246276 */
    247 void niagara_init(void)
    248 {
     277static void niagara_init(void)
     278{
     279        if (instance)
     280                return;
     281       
     282        instance = malloc(sizeof(niagara_instance_t), FRAME_ATOMIC);
     283       
     284        if (instance) {
     285                instance->thread = thread_create(kniagarapoll, instance, TASK, 0,
     286                        "kniagarapoll", true);
     287               
     288                if (!instance->thread) {
     289                        free(instance);
     290                        instance = NULL;
     291                        return;
     292                }
     293        }
     294
     295        instance->srlnin = NULL;
     296
    249297        #if 0
    250298        kbd_type = KBD_SUN4V;
     
    269317         * niagara fb driver can communicate with kernel using a shared buffer.
    270318         */
    271         output_buffer.read_ptr = 0;
    272         output_buffer.write_ptr = 0;
     319        //output_buffer.read_ptr = 0;
     320        //output_buffer.write_ptr = 0;
    273321
    274322        #if 0
     
    296344}
    297345
     346/**
     347 * A public function which initializes input from the Niagara console.
     348 */
     349niagara_instance_t *niagarain_init(void)
     350{
     351        niagara_init();
     352
     353        // TODO - move to console init
     354        if (instance) {
     355                srln_instance_t *srln_instance = srln_init();
     356                if (srln_instance) {
     357                        indev_t *sink = stdin_wire();
     358                        indev_t *srln = srln_wire(srln_instance, sink);
     359
     360                        // wire std. input to niagara
     361                        instance->srlnin = srln;
     362                        thread_ready(instance->thread);
     363                }
     364        }
     365        return instance;
     366}
     367
    298368/** @}
    299369 */
Note: See TracChangeset for help on using the changeset viewer.