Changeset 973be64e in mainline for arch/mips32/src/drivers/msim.c


Ignore:
Timestamp:
2005-12-10T00:19:57Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fcfac420
Parents:
705b4149
Message:

Added generic exc_register/exc_dispatch functions,
copied from ia32 architecture. Currently only mips32 uses them.

The chardev_t can now be both input & output device (was
needed for serial driver).

Broken other architectures - ia64, sparc, powerpc will not compile.

Mips32 supports input on all msim, gxemul, indy(tested emulation
in gxemul, loses characters), simics. Simics serial line
is done using polling, I was unable to make it produce
an interrupt when the key was pressed.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • arch/mips32/src/drivers/msim.c

    r705b4149 r973be64e  
    11/*
    2  * Copyright (C) 2003 Josef Cejka
    3  * Copyright (C) 2005 Jakub Jermar
     2 * Copyright (C) 2005 Ondrej Palkovsky
    43 * All rights reserved.
    54 *
     
    2827 */
    2928
    30 #include <arch/drivers/keyboard.h>
     29#include <interrupt.h>
    3130#include <console/chardev.h>
    32 #include <console/console.h>
     31#include <arch/drivers/msim.h>
    3332#include <arch/cp0.h>
    34 #include <putchar.h>
    35 #include <synch/spinlock.h>
    36 #include <synch/waitq.h>
    37 #include <typedefs.h>
    38 #include <arch/drivers/arc.h>
    3933
    40 static void keyboard_enable(void);
    41 static void keyboard_disable(void);
    42 static void arc_kb_disable(void);
    43 static void arc_kb_enable(void);
     34static chardev_t console;
    4435
    45 static chardev_t kbrd;
     36static void msim_write(chardev_t *dev, const char ch);
     37static void msim_enable(chardev_t *dev);
     38static void msim_disable(chardev_t *dev);
    4639
    47 static chardev_operations_t arc_ops = {
    48         .resume = arc_kb_enable,
    49         .suspend = arc_kb_disable
     40static chardev_operations_t msim_ops = {
     41        .resume = msim_enable,
     42        .suspend = msim_disable,
     43        .write = msim_write
    5044};
    5145
    52 static chardev_operations_t msim_ops = {
    53         .resume = keyboard_enable,
    54         .suspend = keyboard_disable
    55 };
     46/** Putchar that works with MSIM & gxemul */
     47void msim_write(chardev_t *dev, const char ch)
     48{
     49        *((char *) MSIM_VIDEORAM) = ch;
     50}
    5651
    57 static int arc_kb_enabled;
     52/* Called from getc(). */
     53void msim_enable(chardev_t *dev)
     54{
     55        cp0_unmask_int(MSIM_KBD_IRQ);
     56}
    5857
    59 /** Initialize keyboard subsystem. */
    60 void keyboard_init(void)
     58/* Called from getc(). */
     59void msim_disable(chardev_t *dev)
    6160{
    62         if (arc_enabled()) {
    63                 chardev_initialize(&kbrd, &arc_ops);
    64                 arc_kb_enabled = 1;
    65         } else {
    66                 cp0_unmask_int(KEYBOARD_IRQ);
    67                 chardev_initialize(&kbrd, &msim_ops);
    68         }
    69         stdin = &kbrd;
     61        cp0_mask_int(MSIM_KBD_IRQ);
    7062}
    7163
    7264/** Process keyboard interrupt. */
    73 void keyboard(void)
     65static void msim_interrupt(int n, void *stack)
    7466{
    7567        char ch;
    7668
    77         ch = *((char *) KEYBOARD_ADDRESS);
     69        ch = *((char *) MSIM_KBD_ADDRESS);
    7870        if (ch =='\r')
    7971                ch = '\n';
    80         chardev_push_character(&kbrd, ch);
     72        chardev_push_character(&console, ch);
    8173}
    8274
    83 /* Called from getc(). */
    84 void keyboard_enable(void)
     75
     76/* Return console object representing msim console */
     77chardev_t * msim_console(void)
    8578{
    86         cp0_unmask_int(KEYBOARD_IRQ);
     79        chardev_initialize("msim_console", &console, &msim_ops);
     80
     81        exc_register(MSIM_KBD_IRQ, "msim_kbd", msim_interrupt);
     82
     83        cp0_unmask_int(MSIM_KBD_IRQ);
     84
     85        return &console;
    8786}
    88 
    89 /* Called from getc(). */
    90 void keyboard_disable(void)
    91 {
    92         cp0_mask_int(KEYBOARD_IRQ);
    93 }
    94 
    95 /*****************************/
    96 /* Arc keyboard */
    97 
    98 void keyboard_poll(void)
    99 {
    100         int ch;
    101 
    102         if (!arc_enabled() || !arc_kb_enabled)
    103                 return;
    104         while ((ch = arc_getchar()) != -1)
    105                 chardev_push_character(&kbrd, ch);             
    106 }
    107 
    108 static void arc_kb_enable(void)
    109 {
    110         arc_kb_enabled = 1;
    111 }
    112 
    113 /* Called from getc(). */
    114 static void arc_kb_disable(void)
    115 {
    116         arc_kb_enabled = 0;
    117 }
Note: See TracChangeset for help on using the changeset viewer.