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


Ignore:
Timestamp:
2005-12-10T00:19:57Z (20 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 edited

Legend:

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

    r705b4149 r973be64e  
    3434#include <arch/mm/frame.h>
    3535#include <mm/frame.h>
     36#include <interrupt.h>
    3637
    3738/* This is a good joke, SGI HAS different types than NT bioses... */
     
    9899static arc_func_vector_t *arc_entry;
    99100
    100 static void _arc_putchar(char ch);
    101 
    102 /** Initialize ARC structure
    103  *
    104  * @return 0 - ARC OK, -1 - ARC does not exist
    105  */
    106 int arc_init(void)
    107 {
    108         if (sbp->signature != ARC_MAGIC) {
    109                 sbp = NULL;
    110                 return -1;
    111         }
    112         arc_entry = sbp->firmwarevector;
    113 
    114         arc_putchar('A');
    115         arc_putchar('R');
    116         arc_putchar('C');
    117         arc_putchar('\n');
    118 }
     101
     102static void arc_putchar(char ch);
    119103
    120104/** Return true if ARC is available */
     
    130114        printf("%s: ",ctypes[c->type]);
    131115        for (i=0;i < c->identifier_len;i++)
    132                 putchar(c->identifier[i]);
    133         putchar('\n');
     116                arc_putchar(c->identifier[i]);
     117        arc_putchar('\n');
    134118}
    135119
     
    175159
    176160/** Print charactor to console */
    177 void arc_putchar(char ch)
     161static void arc_putchar(char ch)
    178162{
    179163        __u32 cnt;
     
    187171}
    188172
     173/** Initialize ARC structure
     174 *
     175 * @return 0 - ARC OK, -1 - ARC does not exist
     176 */
     177int arc_init(void)
     178{
     179        if (sbp->signature != ARC_MAGIC) {
     180                sbp = NULL;
     181                return -1;
     182        }
     183        arc_entry = sbp->firmwarevector;
     184
     185        arc_putchar('A');
     186        arc_putchar('R');
     187        arc_putchar('C');
     188        arc_putchar('\n');
     189}
     190
     191static int kbd_polling_enabled;
     192static chardev_t console;
     193
    189194/** Try to get character, return character or -1 if not available */
    190 int arc_getchar(void)
     195static void arc_keyboard_poll(void)
    191196{
    192197        char ch;
    193198        __u32 count;
    194199        long result;
     200       
     201        if (! kbd_polling_enabled)
     202                return;
    195203
    196204        if (arc_entry->getreadstatus(0))
    197                 return -1;
     205                return;
    198206        result = arc_entry->read(0, &ch, 1, &count);
    199207        if (result || count!=1) {
    200                 cpu_halt();
    201                 return -1;
     208                return;
    202209        }
    203210        if (ch == '\r')
    204                 return '\n';
    205         return ch;
     211                ch = '\n';
     212
     213        chardev_push_character(&console, ch);
     214}
     215
     216static void arc_write(chardev_t *dev, const char ch)
     217{
     218        arc_putchar(ch);
     219}
     220
     221static void arc_enable(chardev_t *dev)
     222{
     223        kbd_polling_enabled = 1;       
     224}
     225
     226static void arc_disable(chardev_t *dev)
     227{
     228        kbd_polling_enabled = 0;
     229}
     230
     231static chardev_operations_t arc_ops = {
     232        .resume = arc_enable,
     233        .suspend = arc_disable,
     234        .write = arc_write
     235};
     236
     237iroutine old_timer;
     238/** Do polling on timer interrupt */
     239static void timer_replace(int n, void *stack)
     240{
     241        arc_keyboard_poll();
     242        old_timer(n, stack);
     243        arc_keyboard_poll();
     244}
     245
     246
     247chardev_t * arc_console(void)
     248{
     249        kbd_polling_enabled = 1;
     250       
     251        chardev_initialize("arc_console", &console, &arc_ops);
     252        old_timer = exc_register(TIMER_IRQ, "arc_kb_poll", timer_replace);
     253        return &console;
    206254}
    207255
Note: See TracChangeset for help on using the changeset viewer.