Changeset 63b1537 in mainline


Ignore:
Timestamp:
2009-03-11T17:26:48Z (15 years ago)
Author:
Pavel Rimsky <rimskyp@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
de88998
Parents:
04d672c3
Message:

SGCN driver modified to reflect the new keyboard driver architecture. Making the Serengeti bootable image smaller by not including some servers/applications.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • boot/arch/sparc64/loader/Makefile

    r04d672c3 r63b1537  
    102102        $(USPACEDIR)/srv/kbd/kbd \
    103103        $(USPACEDIR)/srv/console/console \
    104         $(USPACEDIR)/srv/fs/tmpfs/tmpfs \
     104        $(USPACEDIR)/srv/fs/tmpfs/tmpfs
     105
     106ifeq ($(MACHINE),generic)
     107RD_SRVS += \
    105108        $(USPACEDIR)/srv/fs/fat/fat \
    106109        $(USPACEDIR)/srv/fhc/fhc \
    107         $(USPACEDIR)/srv/obio/obio
     110        $(USPACEDIR)/srv/obio/obio
     111endif
    108112
    109113RD_APPS = \
    110114        $(USPACEDIR)/app/tetris/tetris \
    111         $(USPACEDIR)/app/tester/tester \
    112115        $(USPACEDIR)/app/trace/trace \
    113116        $(USPACEDIR)/app/bdsh/bdsh \
    114117        $(USPACEDIR)/app/klog/klog
     118
     119ifeq ($(MACHINE),generic)
     120RD_APPS += \
     121        $(USPACEDIR)/app/tester/tester
     122endif
    115123
    116124OBJECTS := $(addsuffix .o,$(basename $(SOURCES)))
  • kernel/arch/sparc64/include/drivers/sgcn.h

    r04d672c3 r63b1537  
    118118void sgcn_grab(void);
    119119void sgcn_release(void);
    120 void sgcn_poll(void);
    121120void sgcn_init(void);
    122121
  • kernel/arch/sparc64/src/console.c

    r04d672c3 r63b1537  
    125125
    126126
    127 /** Kernel thread for polling keyboard.
    128  *
    129  * @param arg Ignored.
    130  */
    131 void kkbdpoll(void *arg)
    132 {
    133         thread_detach(THREAD);
    134 
    135         if (kbd_type != KBD_SGCN)
    136                 return;
    137 
    138         while (1) {
    139 #ifdef CONFIG_SGCN
    140                 if (kbd_type == KBD_SGCN)
    141                         sgcn_poll();
    142 #endif
    143                 thread_usleep(KEYBOARD_POLL_PAUSE);
    144         }
    145 }
    146 
    147127/** Acquire console back for kernel
    148128 *
  • kernel/arch/sparc64/src/drivers/kbd.c

    r04d672c3 r63b1537  
    5757
    5858kbd_type_t kbd_type = KBD_UNKNOWN;
     59
     60#if defined (CONFIG_Z8530) || defined (CONFIG_NS16550)
    5961
    6062/** Initialize keyboard.
     
    209211}
    210212
     213        #endif
    211214/** @}
    212215 */
  • kernel/arch/sparc64/src/drivers/sgcn.c

    r04d672c3 r63b1537  
    3535 */
    3636
     37#include <arch.h>
    3738#include <arch/drivers/sgcn.h>
    3839#include <arch/drivers/kbd.h>
     
    4243#include <print.h>
    4344#include <mm/page.h>
    44 #include <ipc/irq.h>
    45 #include <ddi/ddi.h>
    46 #include <ddi/device.h>
     45#include <proc/thread.h>
    4746#include <console/chardev.h>
    4847#include <console/console.h>
    49 #include <ddi/device.h>
    5048#include <sysinfo/sysinfo.h>
    5149#include <synch/spinlock.h>
     50
     51#define POLL_INTERVAL           10000
    5252
    5353/*
     
    8383#define SGCN_BUFFER_MAGIC       "CON"
    8484
    85 /**
    86  * The driver is polling based, but in order to notify the userspace
    87  * of a key being pressed, we need to supply the interface with some
    88  * interrupt number. The interrupt number can be arbitrary as it it
    89  * will never be used for identifying HW interrupts, but only in
    90  * notifying the userspace.
    91  */
    92 #define FICTIONAL_INR           1
    93 
    94 
    9585/*
    9686 * Returns a pointer to the object of a given type which is placed at the given
     
    124114static uintptr_t sgcn_buffer_begin;
    125115
    126 /**
    127  * SGCN IRQ structure. So far used only for notifying the userspace of the
    128  * key being pressed, not for kernel being informed about keyboard interrupts.
    129  */
    130 static irq_t sgcn_irq;
    131 
    132 // TODO think of a way how to synchronize accesses to SGCN buffer between the kernel and the userspace
     116/* true iff the kernel driver should ignore pressed keys */
     117static bool kbd_disabled;
    133118
    134119/*
     
    309294
    310295/**
    311  * The driver works in polled mode, so no interrupt should be handled by it.
    312  */
    313 static irq_ownership_t sgcn_claim(irq_t *irq)
    314 {
    315         return IRQ_DECLINE;
    316 }
    317 
    318 /**
    319  * The driver works in polled mode, so no interrupt should be handled by it.
    320  */
    321 static void sgcn_irq_handler(irq_t *irq)
    322 {
    323         panic("Not yet implemented, SGCN works in polled mode.");
    324 }
    325 
    326 /**
    327296 * Grabs the input for kernel.
    328297 */
    329298void sgcn_grab(void)
    330299{
    331         ipl_t ipl = interrupts_disable();
    332        
    333         volatile uint32_t *in_wrptr_ptr = &(SGCN_BUFFER_HEADER->in_wrptr);
    334         volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr);
    335        
    336         /* skip all the user typed before the grab and hasn't been processed */
    337         spinlock_lock(&sgcn_input_lock);
    338         *in_rdptr_ptr = *in_wrptr_ptr;
    339         spinlock_unlock(&sgcn_input_lock);
    340 
    341         spinlock_lock(&sgcn_irq.lock);
    342         sgcn_irq.notif_cfg.notify = false;
    343         spinlock_unlock(&sgcn_irq.lock);
    344        
    345         interrupts_restore(ipl);
     300        kbd_disabled = true;
    346301}
    347302
     
    351306void sgcn_release(void)
    352307{
    353         ipl_t ipl = interrupts_disable();
    354         spinlock_lock(&sgcn_irq.lock);
    355         if (sgcn_irq.notif_cfg.answerbox)
    356                 sgcn_irq.notif_cfg.notify = true;
    357         spinlock_unlock(&sgcn_irq.lock);
    358         interrupts_restore(ipl);
     308        kbd_disabled = true;
    359309}
    360310
     
    364314 * and sends them to the upper layers of HelenOS.
    365315 */
    366 void sgcn_poll(void)
     316static void sgcn_poll()
    367317{
    368318        uint32_t begin = SGCN_BUFFER_HEADER->in_begin;
    369319        uint32_t end = SGCN_BUFFER_HEADER->in_end;
    370320        uint32_t size = end - begin;
    371        
     321
    372322        spinlock_lock(&sgcn_input_lock);
    373323       
    374324        ipl_t ipl = interrupts_disable();
    375         spinlock_lock(&sgcn_irq.lock);
     325
     326        if (kbd_disabled) {
     327                interrupts_restore(ipl);
     328                return;
     329        }
    376330       
    377331        /* we need pointers to volatile variables */
     
    381335        volatile uint32_t *in_rdptr_ptr = &(SGCN_BUFFER_HEADER->in_rdptr);
    382336       
    383         if (*in_rdptr_ptr != *in_wrptr_ptr) {
    384                 /* XXX: send notification to userspace */
    385         }
    386        
    387         spinlock_unlock(&sgcn_irq.lock);
    388         interrupts_restore(ipl);       
    389 
    390337        while (*in_rdptr_ptr != *in_wrptr_ptr) {
    391338               
     
    400347                chardev_push_character(&sgcn_io, c);   
    401348        }       
    402        
     349
     350        interrupts_restore(ipl);       
    403351        spinlock_unlock(&sgcn_input_lock);
     352}
     353
     354/**
     355 * Polling thread function.
     356 */
     357static void kkbdpoll(void *arg) {
     358        while (1) {
     359                if (!silent) {
     360                        sgcn_poll();
     361                }
     362                thread_usleep(POLL_INTERVAL);
     363        }
    404364}
    405365
     
    414374        kbd_type = KBD_SGCN;
    415375
    416         devno_t devno = device_assign_devno();
    417         irq_initialize(&sgcn_irq);
    418         sgcn_irq.devno = devno;
    419         sgcn_irq.inr = FICTIONAL_INR;
    420         sgcn_irq.claim = sgcn_claim;
    421         sgcn_irq.handler = sgcn_irq_handler;
    422         irq_register(&sgcn_irq);
    423        
    424376        sysinfo_set_item_val("kbd", NULL, true);
    425377        sysinfo_set_item_val("kbd.type", NULL, KBD_SGCN);
    426         sysinfo_set_item_val("kbd.devno", NULL, devno);
    427         sysinfo_set_item_val("kbd.inr", NULL, FICTIONAL_INR);
    428378        sysinfo_set_item_val("fb.kind", NULL, 4);
     379
     380        thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true);
     381        if (!t)
     382                panic("Cannot create kkbdpoll.");
     383        thread_ready(t);
    429384       
    430385        chardev_initialize("sgcn_io", &sgcn_io, &sgcn_ops);
  • kernel/arch/sparc64/src/sparc64.c

    r04d672c3 r63b1537  
    3838#include <arch/trap/trap.h>
    3939#include <arch/console.h>
    40 #include <proc/thread.h>
    4140#include <console/console.h>
    4241#include <arch/boot/boot.h>
     
    105104        if (config.cpu_active == 1) {
    106105                standalone_sparc64_console_init();
    107 
    108                 /* Create thread that polls keyboard.
    109                  * XXX: this is only used by sgcn now
    110                  */
    111                 thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll",
    112                     true);
    113                 if (!t)
    114                         panic("Cannot create kkbdpoll.");
    115                 thread_ready(t);
    116106        }
    117107}
  • uspace/srv/kbd/Makefile

    r04d672c3 r63b1537  
    117117endif
    118118ifeq ($(UARCH), sparc64)
     119    ifeq ($(MACHINE),serengeti)
     120        GENARCH_SOURCES += \
     121                port/sgcn.c \
     122                ctl/stty.c
     123    else
    119124        GENARCH_SOURCES += \
    120125                port/z8530.c \
    121126                ctl/sun.c
     127    endif
    122128endif
    123129
  • uspace/srv/kbd/port/sgcn.c

    r04d672c3 r63b1537  
    3737#include <as.h>
    3838#include <ddi.h>
    39 #include <ipc/ipc.h>
    4039#include <async.h>
    4140#include <kbd.h>
     
    4342#include <sysinfo.h>
    4443#include <stdio.h>
     44#include <thread.h>
     45
     46#define POLL_INTERVAL           10000
    4547
    4648/**
     
    8890static uintptr_t sram_buffer_offset;
    8991
    90 static void sgcn_irq_handler(ipc_callid_t iid, ipc_call_t *call);
     92/* polling thread */
     93static void *sgcn_thread_impl(void *arg);
    9194
    9295
    9396/**
    9497 * Initializes the SGCN driver.
    95  * Maps the physical memory (SRAM) and registers the interrupt.
     98 * Maps the physical memory (SRAM) and creates the polling thread.
    9699 */
    97100int kbd_port_init(void)
    98101{
    99         async_set_interrupt_received(sgcn_irq_handler);
    100102        sram_virt_addr = (uintptr_t) as_get_mappable_page(sysinfo_value("sram.area.size"));
    101103        if (physmem_map((void *) sysinfo_value("sram.address.physical"),
     
    107109       
    108110        sram_buffer_offset = sysinfo_value("sram.buffer.offset");
    109         ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"),
    110                 0, (void *) 0);
     111
     112        thread_id_t tid;
     113        int rc;
     114
     115        rc = thread_create(sgcn_thread_impl, NULL, "kbd_poll", &tid);
     116        if (rc != 0) {
     117                return rc;
     118        }
     119
    111120        return 0;
    112121}
     
    116125 * the buffer.
    117126 */
    118 static void sgcn_irq_handler(ipc_callid_t iid, ipc_call_t *call)
     127static void sgcn_key_pressed(void)
    119128{
    120129        char c;
     
    138147}
    139148
     149/**
     150 * Thread to poll SGCN for keypresses.
     151 */
     152static void *sgcn_thread_impl(void *arg)
     153{
     154        (void) arg;
     155
     156        while (1) {
     157                sgcn_key_pressed();
     158                usleep(POLL_INTERVAL);
     159        }
     160}
     161
     162
    140163/** @}
    141164 */
Note: See TracChangeset for help on using the changeset viewer.