Changeset 607c5f9 in mainline


Ignore:
Timestamp:
2005-11-23T00:16:03Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a83a802
Parents:
2677758
Message:

Enable dummy kconsole for ia32 and amd64 (UP mode works).

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/src/amd64.c

    r2677758 r607c5f9  
    103103void arch_post_smp_init(void)
    104104{
     105        trap_virtual_enable_irqs(1<<IRQ_KBD);
    105106}
    106107
  • arch/ia32/src/drivers/i8042.c

    r2677758 r607c5f9  
    3636#include <synch/spinlock.h>
    3737#include <typedefs.h>
     38#include <console/chardev.h>
     39#include <console/console.h>
    3840
    3941/**
     
    5557static volatile int keyflags;           /**< Tracking of multiple keypresses. */
    5658static volatile int lockflags;          /**< Tracking of multiple keys lockings. */
     59
     60static void i8042_suspend(void);
     61static void i8042_resume(void);
     62
     63static chardev_t kbrd;
     64static chardev_operations_t ops = {
     65        .suspend = i8042_suspend,
     66        .resume = i8042_resume
     67};
    5768
    5869/** Primary meaning of scancodes. */
     
    221232        trap_register(VECTOR_KBD, i8042_interrupt);
    222233        spinlock_initialize(&keylock);
     234        chardev_initialize(&kbrd, &ops);
     235        stdin = &kbrd;
    223236}
    224237
     
    293306                if (shift)
    294307                        map = sc_secondary_map;
    295                 putchar(map[sc]);
     308                chardev_push_character(&kbrd, map[sc]);
    296309                break;
    297310        }
    298311        spinlock_unlock(&keylock);
    299312}
     313
     314/* Called from getc(). */
     315void i8042_resume(void)
     316{
     317}
     318
     319/* Called from getc(). */
     320void i8042_suspend(void)
     321{
     322}
  • arch/mips32/src/drivers/keyboard.c

    r2677758 r607c5f9  
    3737#include <typedefs.h>
    3838
     39static void keyboard_enable(void);
     40static void keyboard_disable(void);
     41
    3942static chardev_t kbrd;
    40 
    41 static void keyboard_enable(void);
     43static chardev_operations_t ops = {
     44        .resume = keyboard_enable,
     45        .suspend = keyboard_disable
     46};
    4247
    4348/** Initialize keyboard subsystem. */
     
    4550{
    4651        cp0_unmask_int(KEYBOARD_IRQ);
    47         chardev_initialize(&kbrd, keyboard_enable);
     52        chardev_initialize(&kbrd, &ops);
    4853        stdin = &kbrd;
    4954}
    5055
    51 /** Process keyboard interrupt.
    52  *
    53  * This function is called directly from the interrupt handler.
    54  * It feeds the keyboard buffer with characters read. When the buffer
    55  * is full, it simply masks the keyboard interrupt signal.
    56  */
     56/** Process keyboard interrupt. */
    5757void keyboard(void)
    5858{
    5959        char ch;
    6060
    61         spinlock_lock(&kbrd.lock);
    62         kbrd.counter++;
    63         if (kbrd.counter == CHARDEV_BUFLEN - 1) {
    64                 /* buffer full => disable keyboard interrupt */
    65                 cp0_mask_int(KEYBOARD_IRQ);
    66         }
    67 
    6861        ch = *((char *) KEYBOARD_ADDRESS);
    69         putchar(ch);
    70         kbrd.buffer[kbrd.index++] = ch;
    71         kbrd.index = kbrd.index % CHARDEV_BUFLEN; /* index modulo size of buffer */
    72         waitq_wakeup(&kbrd.wq, WAKEUP_FIRST);
    73         spinlock_unlock(&kbrd.lock);
     62        chardev_push_character(&kbrd, ch);
    7463}
    7564
     
    7968        cp0_unmask_int(KEYBOARD_IRQ);
    8069}
     70
     71/* Called from getc(). */
     72void keyboard_disable(void)
     73{
     74        cp0_mask_int(KEYBOARD_IRQ);
     75}
  • generic/include/console/chardev.h

    r2677758 r607c5f9  
    3535#include <synch/spinlock.h>
    3636
    37 #define CHARDEV_BUFLEN 10
     37#define CHARDEV_BUFLEN 512
    3838
    39 typedef void (* ready_func_t)(void);
     39/* Character device operations interface. */
     40struct chardev_operations {
     41        void (* suspend)(void);         /**< Suspend pushing characters. */
     42        void (* resume)(void);          /**< Resume pushing characters. */
     43};
     44
     45typedef struct chardev_operations chardev_operations_t;
    4046
    4147/** Character input device. */
     
    4652        count_t counter;
    4753        index_t index;
    48         ready_func_t ready_func;        /**< Function to re-enable input from the device. */
     54        chardev_operations_t *op;       /**< Implementation of chardev operations. */
    4955};
    5056
    51 extern void chardev_initialize(chardev_t *chardev, ready_func_t r);
     57extern void chardev_initialize(chardev_t *chardev, chardev_operations_t *op);
     58void chardev_push_character(chardev_t *chardev, __u8 ch);
    5259
    5360#endif /* __CHARDEV_H__ */
  • generic/src/console/chardev.c

    r2677758 r607c5f9  
    2828
    2929#include <console/chardev.h>
     30#include <putchar.h>
    3031#include <synch/waitq.h>
    3132#include <synch/spinlock.h>
    3233
    33 /** Initialize character device. */
    34 void chardev_initialize(chardev_t *chardev, ready_func_t r)
     34/** Initialize character device.
     35 *
     36 * @param chardev Character device.
     37 * @param op Implementation of character device operations.
     38 */
     39void chardev_initialize(chardev_t *chardev, chardev_operations_t *op)
    3540{
    3641        waitq_initialize(&chardev->wq);
     
    3843        chardev->counter = 0;
    3944        chardev->index = 0;
    40         chardev->ready_func = r;
     45        chardev->op = op;
    4146}
     47
     48/** Push character read from input character device.
     49 *
     50 * @param chardev Character device.
     51 * @param ch Character being pushed.
     52 */
     53void chardev_push_character(chardev_t *chardev, __u8 ch)
     54{
     55        spinlock_lock(&chardev->lock);
     56        chardev->counter++;
     57        if (chardev->counter == CHARDEV_BUFLEN - 1) {
     58                /* buffer full => disable device interrupt */
     59                chardev->op->suspend();
     60        }
     61
     62        putchar(ch);
     63        chardev->buffer[chardev->index++] = ch;
     64        chardev->index = chardev->index % CHARDEV_BUFLEN; /* index modulo size of buffer */
     65        waitq_wakeup(&chardev->wq, WAKEUP_FIRST);
     66        spinlock_unlock(&chardev->lock);
     67}
  • generic/src/console/console.c

    r2677758 r607c5f9  
    8383        interrupts_restore(ipl);
    8484
    85         chardev->ready_func();
     85        chardev->op->resume();
    8686
    8787        return ch;
Note: See TracChangeset for help on using the changeset viewer.