Changeset 323a5aaf in mainline


Ignore:
Timestamp:
2008-11-30T12:17:56Z (16 years ago)
Author:
Jakub Vana <jakub.vana@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ad9e47
Parents:
57e76cb
Message:

Legacy IRQ support, uspace NS16550 support, some minor changes

Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r57e76cb r323a5aaf  
    127127endif
    128128
     129ifeq ($(CONFIG_I8042_INTERRUPT_DRIVEN),y)
     130        DEFS += -DCONFIG_I8042_INTERRUPT_DRIVEN
     131endif
     132
    129133ifeq ($(CONFIG_NS16550_INTERRUPT_DRIVEN),y)
    130134        DEFS += -DCONFIG_NS16550_INTERRUPT_DRIVEN
     135endif
     136
     137ifeq ($(CONFIG_IOSAPIC),y)
     138        DEFS += -DCONFIG_IOSAPIC
    131139endif
    132140
  • kernel/arch/ia64/include/interrupt.h

    r57e76cb r323a5aaf  
    5757#define IRQ_MOUSE               252
    5858#define INTERRUPT_SPURIOUS      15
     59#define LAGACY_INTERRUPT_BASE   0x20
    5960
    6061/** General Exception codes. */
     
    153154extern void disabled_fp_register(uint64_t vector, istate_t *istate);
    154155
     156
    155157#endif
    156158
  • kernel/arch/ia64/src/drivers/ega.c

    r57e76cb r323a5aaf  
    9595        sysinfo_set_item_val("fb.width", NULL, ROW);
    9696        sysinfo_set_item_val("fb.height", NULL, ROWS);
     97        sysinfo_set_item_val("fb.blinking", NULL, true);
    9798        sysinfo_set_item_val("fb.address.physical", NULL, VIDEORAM & 0xffffffff);
    9899       
  • kernel/arch/ia64/src/ia64.c

    r57e76cb r323a5aaf  
    6464
    6565/*NS16550 as a COM 1*/
    66 #define NS16550_IRQ 4
     66#define NS16550_IRQ (4+LAGACY_INTERRUPT_BASE)
    6767#define NS16550_PORT 0x3f8
    6868
    6969bootinfo_t *bootinfo;
     70
     71static uint64_t iosapic_base=0xfec00000;
    7072
    7173void arch_pre_main(void)
     
    112114}
    113115
     116static void iosapic_init(void)
     117{
     118
     119        uint64_t IOSAPIC = PA2KA((unative_t)(iosapic_base))|FW_OFFSET;
     120        int i;
     121       
     122       
     123        for(i=0;i<16;i++)
     124        {
     125       
     126                if(i==2) continue;       //Disable Cascade interrupt
     127                ((uint32_t*)(IOSAPIC+0x00))[0]=0x10+2*i;
     128                srlz_d();
     129                ((uint32_t*)(IOSAPIC+0x10))[0]=LAGACY_INTERRUPT_BASE+i;
     130                srlz_d();
     131                ((uint32_t*)(IOSAPIC+0x00))[0]=0x10+2*i+1;
     132                srlz_d();
     133                ((uint32_t*)(IOSAPIC+0x10))[0]=1<<(56-32);
     134                srlz_d();
     135        }
     136
     137}
     138
     139
    114140void arch_post_mm_init(void)
    115141{
    116142        if(config.cpu_active==1)
    117143        {
     144                iosapic_init();
     145       
    118146                irq_init(INR_COUNT, INR_COUNT);
    119147#ifdef SKI
     
    123151#endif 
    124152        }
    125         it_init();     
     153        it_init();
     154               
    126155}
    127156
     
    143172                i8042_poll();
    144173#ifdef CONFIG_NS16550
     174        #ifndef CONFIG_NS16550_INTERRUPT_DRIVEN
    145175                ns16550_poll();
     176        #endif 
    146177#endif
    147178                thread_usleep(POLL_INTERVAL);
     
    149180}
    150181#endif
     182
     183
     184static void end_of_irq_void(void *cir_arg __attribute__((unused)),inr_t inr __attribute__((unused)))
     185{
     186        return;
     187}
     188
    151189
    152190void arch_post_smp_init(void)
     
    172210
    173211#ifdef CONFIG_NS16550
    174                 ns16550_init(kbd, NS16550_IRQ, NS16550_PORT); // as a COM 1
     212                ns16550_init(kbd, NS16550_IRQ, NS16550_PORT,end_of_irq_void,NULL); // as a COM 1
    175213#else
    176214#endif
     
    188226        sysinfo_set_item_val("ia64_iospace.address", NULL, true);
    189227        sysinfo_set_item_val("ia64_iospace.address.virtual", NULL, IO_OFFSET);
     228
     229
     230
     231
    190232
    191233}
     
    238280#ifdef SKI
    239281        ski_kbd_grab();
     282#else
     283        i8042_grab();
     284        #ifdef CONFIG_NS16550
     285                ns16550_grab();
     286        #endif 
     287               
    240288#endif 
    241289}
     
    247295#ifdef SKI
    248296        ski_kbd_release();
     297        i8042_release();
     298#else   
     299        #ifdef CONFIG_NS16550
     300                ns16550_release();
     301        #endif 
     302
    249303#endif
    250304}
  • kernel/arch/ia64/src/interrupt.c

    r57e76cb r323a5aaf  
    236236}
    237237
    238 static void end_of_local_irq()
     238static void end_of_local_irq(void)
    239239{
    240240        asm volatile ("mov cr.eoi=r0;;");
     
    244244void external_interrupt(uint64_t vector, istate_t *istate)
    245245{
    246         irq_t *irq;
    247246        cr_ivr_t ivr;
    248247       
     
    250249        srlz_d();
    251250
    252         irq = irq_dispatch_and_lock(ivr.vector);
    253         if (irq) {
    254                 irq->handler(irq, irq->arg);
    255                 spinlock_unlock(&irq->lock);
    256         } else {
    257251                switch (ivr.vector) {
    258252                case INTERRUPT_SPURIOUS:
     
    271265
    272266                default:
    273                         panic("\nUnhandled External Interrupt Vector %d\n",
    274                             ivr.vector);
     267                        {
     268
     269                                int ack=false;
     270                                irq_t *irq = irq_dispatch_and_lock(ivr.vector);
     271                                if (irq) {
     272                                        /*
     273                                         * The IRQ handler was found.
     274                                         */
     275                 
     276                                        if (irq->preack) {
     277                                                /* Send EOI before processing the interrupt */
     278                                                end_of_local_irq();
     279                                                ack=true;
     280                                        }
     281                                        irq->handler(irq, irq->arg);
     282                                        spinlock_unlock(&irq->lock);
     283                                } else {
     284                                        /*
     285                                         * Unhandled interrupt.
     286                                         */
     287                                        end_of_local_irq();
     288                                        ack=true;
     289#ifdef CONFIG_DEBUG
     290                                        printf("\nUnhandled External Interrupt Vector %d\n",ivr.vector);
     291#endif
     292                                }
     293                                if(!ack) end_of_local_irq();
     294
     295                        }       
     296
     297
    275298                        break;
    276299                }
    277         }
    278300}
    279301
  • kernel/arch/ia64/src/ski/ski.c

    r57e76cb r323a5aaf  
    4545#include <synch/spinlock.h>
    4646#include <arch/asm.h>
     47#include <drivers/kbd.h>
    4748
    4849#define SKI_KBD_INR     0
     
    228229        sysinfo_set_item_val("kbd.inr", NULL, SKI_KBD_INR);
    229230        sysinfo_set_item_val("kbd.devno", NULL, ski_kbd_devno);
     231        sysinfo_set_item_val("kbd.type", NULL, KBD_SKI);
    230232}
    231233
  • kernel/genarch/src/kbd/ns16550.c

    r57e76cb r323a5aaf  
    3939#include <genarch/kbd/scanc.h>
    4040#include <genarch/kbd/scanc_sun.h>
     41#include <arch/drivers/kbd.h>
    4142#ifndef ia64
    42 #include <arch/drivers/kbd.h>
    4343#include <arch/drivers/ns16550.h>
    4444#endif
     
    131131        ns16550_irq.cir_arg = cir_arg;
    132132        irq_register(&ns16550_irq);
     133
     134
     135        while ((ns16550_lsr_read(&ns16550) & LSR_DATA_READY))
     136                ns16550_rbr_read(&ns16550);
     137
    133138       
    134139        sysinfo_set_item_val("kbd", NULL, true);
    135 #ifndef ia64
    136140        sysinfo_set_item_val("kbd.type", NULL, KBD_NS16550);
    137 #endif
    138141        sysinfo_set_item_val("kbd.devno", NULL, devno);
    139142        sysinfo_set_item_val("kbd.inr", NULL, inr);
    140143        sysinfo_set_item_val("kbd.address.virtual", NULL, port);
     144        sysinfo_set_item_val("kbd.port", NULL, port);
    141145
    142146#ifdef CONFIG_NS16550_INTERRUPT_DRIVEN
     
    148152#ifdef ia64
    149153        uint8_t c;
     154        // This switches rbr & ier to mode when accept baudrate constant
    150155        c = ns16550_lcr_read(&ns16550);
    151156        ns16550_lcr_write(&ns16550, 0x80 | c);
  • kernel/generic/src/ipc/irq.c

    r57e76cb r323a5aaf  
    101101                            code->cmds[i].value;
    102102                        break;
    103 #if defined(ia32) || defined(amd64)
     103#if defined(ia32) || defined(amd64) || defined(ia64)
    104104                case CMD_PORT_READ_1:
    105105                        dstval = inb((long) code->cmds[i].addr);
  • kernel/kernel.config

    r57e76cb r323a5aaf  
    142142! [ARCH=sparc64|ARCH=ia64] CONFIG_NS16550 (y/n)
    143143
     144# IOSapic on default address support (including legacy IRQ)
     145! [ARCH=ia64] CONFIG_IOSAPIC (y/n)
     146
     147# Interrupt-driven driver for Legacy Keyboard?
     148! [CONFIG_IOSAPIC=y] CONFIG_I8042_INTERRUPT_DRIVEN (y/n)
     149
    144150# Interrupt-driven driver for NS16550?
    145 ! [CONFIG_NS16550=y] CONFIG_NS16550_INTERRUPT_DRIVEN (n/y)
     151! [CONFIG_NS16550=y&((ARCH!=ia64)|CONFIG_IOSAPIC=y)] CONFIG_NS16550_INTERRUPT_DRIVEN (y/n)
    146152
    147153# Virtually indexed D-cache support
  • uspace/srv/fb/ega.c

    r57e76cb r323a5aaf  
    6565#define EGA_IO_SIZE 2
    6666
    67 #define NORMAL_COLOR       0x0f
    68 #define INVERTED_COLOR     0xf0
     67int ega_normal_color=0x0f;
     68int ega_inverted_color=0xf0;
     69
     70#define NORMAL_COLOR            ega_normal_color       
     71#define INVERTED_COLOR          ega_inverted_color
    6972
    7073#define EGA_STYLE(fg,bg) ((fg) > (bg) ? NORMAL_COLOR : INVERTED_COLOR)
     
    7780static char *scr_addr;
    7881
    79 static unsigned int style = NORMAL_COLOR;
     82static unsigned int style;
    8083
    8184static void clrscr(void)
     
    313316        scr_width = sysinfo_value("fb.width");
    314317        scr_height = sysinfo_value("fb.height");
     318        if(sysinfo_value("fb.blinking"))
     319        {
     320                        ega_normal_color&=0x77;
     321                        ega_inverted_color&=0x77;
     322        }
     323        style = NORMAL_COLOR;
     324
    315325        iospace_enable(task_get_id(), (void *) EGA_IO_ADDRESS, 2);
    316326
  • uspace/srv/kbd/arch/ia64/src/kbd.c

    r57e76cb r323a5aaf  
    4040#include <kbd.h>
    4141#include <keys.h>
     42#include <stdio.h>
     43#include <stdlib.h>
     44
     45#include <unistd.h>
     46#include <align.h>
     47#include <async.h>
     48#include <ipc/ipc.h>
     49#include <errno.h>
     50#include <stdio.h>
     51#include <ddi.h>
     52#include <sysinfo.h>
     53#include <as.h>
     54#include <ipc/fb.h>
     55#include <ipc/ipc.h>
     56#include <ipc/ns.h>
     57#include <ipc/services.h>
     58#include <libarch/ddi.h>
     59
    4260
    4361#define KEY_F1 0x504f1b
     
    5472#define KEY_F12 0x7e34325b1b
    5573
     74
     75
     76
     77#define NSKEY_F1 0x415b5b1b
     78#define NSKEY_F2 0x425b5b1b
     79#define NSKEY_F3 0x435b5b1b
     80#define NSKEY_F4 0x445b5b1b
     81#define NSKEY_F5 0x455b5b1b
     82#define NSKEY_F6 0x37315b1b
     83#define NSKEY_F7 0x38315b1b
     84#define NSKEY_F8 0x39315b1b
     85#define NSKEY_F9 0x30325b1b
     86#define NSKEY_F10 0x31325b1b
     87#define NSKEY_F11 0x33325b1b
     88#define NSKEY_F12 0x34325b1b
     89
     90
    5691#define FUNCTION_KEYS 0x100
     92
     93
     94#define KBD_SKI 1
     95#define KBD_LEGACY 2
     96#define KBD_NS16550 3
     97
     98
     99
     100
     101/* NS16550 registers */
     102#define RBR_REG         0       /** Receiver Buffer Register. */
     103#define IER_REG         1       /** Interrupt Enable Register. */
     104#define IIR_REG         2       /** Interrupt Ident Register (read). */
     105#define FCR_REG         2       /** FIFO control register (write). */
     106#define LCR_REG         3       /** Line Control register. */
     107#define MCR_REG         4       /** Modem Control Register. */
     108#define LSR_REG         5       /** Line Status Register. */
     109
     110
     111
    57112
    58113irq_cmd_t ski_cmds[1] = {
     
    65120};
    66121
     122
     123
     124irq_cmd_t ns16550_cmds[1] = {
     125        { CMD_PORT_READ_1, 0, 0, 2 },
     126};
     127
     128irq_code_t ns16550_kbd = {
     129        1,
     130        ns16550_cmds
     131};
     132
     133
     134uint16_t ns16550_port;
     135
     136int kbd_type;
     137
    67138int kbd_arch_init(void)
    68139{
    69140        if (sysinfo_value("kbd")) {
    70                 ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ski_kbd);
     141                kbd_type=sysinfo_value("kbd.type");
     142                if(kbd_type==KBD_SKI) ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ski_kbd);
     143                if(kbd_type==KBD_NS16550) {
     144                        ns16550_kbd.cmds[0].addr= (void *)  (sysinfo_value("kbd.port")+RBR_REG);
     145                        ipc_register_irq(sysinfo_value("kbd.inr"), sysinfo_value("kbd.devno"), 0, &ns16550_kbd);
     146                        iospace_enable(task_get_id(),ns16550_port=sysinfo_value("kbd.port"),8);
     147                }       
    71148                return 0;
    72149        }       
     
    82159}
    83160*/
    84 
    85 int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
     161#define LSR_DATA_READY  0x01
     162
     163int kbd_ns16550_process(keybuffer_t *keybuffer, ipc_call_t *call)
     164{
     165        static unsigned long buf = 0;
     166        static int count = 0, esc_count=0;     
     167
     168        int scan_code = IPC_GET_ARG2(*call);
     169
     170        if (scan_code == 0x1b) {
     171                esc_count++;
     172                if (esc_count == 3) {
     173                        __SYSCALL0(SYS_DEBUG_ENABLE_CONSOLE);
     174                }       
     175        } else {
     176                esc_count = 0;
     177        }
     178
     179        if(scan_code==0x0d) return 1;   //Delete CR
     180
     181        if(scan_code == 0x7e) {
     182                switch (buf) {
     183                case NSKEY_F6:
     184                        keybuffer_push(keybuffer,FUNCTION_KEYS | 6);
     185                        buf = count = 0;
     186                        return 1;
     187                case NSKEY_F7:
     188                        keybuffer_push(keybuffer,FUNCTION_KEYS | 7);
     189                        buf = count = 0;
     190                        return 1;
     191                case NSKEY_F8:
     192                        keybuffer_push(keybuffer,FUNCTION_KEYS | 8);
     193                        buf = count = 0;
     194                        return 1;
     195                case NSKEY_F9:
     196                        keybuffer_push(keybuffer,FUNCTION_KEYS | 9);
     197                        buf = count = 0;
     198                        return 1;
     199                case NSKEY_F10:
     200                        keybuffer_push(keybuffer,FUNCTION_KEYS | 10);
     201                        buf = count = 0;
     202                        return 1;
     203                case NSKEY_F11:
     204                        keybuffer_push(keybuffer,FUNCTION_KEYS | 11);
     205                        buf = count = 0;
     206                        return 1;
     207                case NSKEY_F12:
     208                        keybuffer_push(keybuffer,FUNCTION_KEYS | 12);
     209                        buf = count = 0;
     210                        return 1;
     211                default:
     212                        keybuffer_push(keybuffer, buf & 0xff);
     213                        keybuffer_push(keybuffer, (buf >> 8) &0xff);
     214                        keybuffer_push(keybuffer, (buf >> 16) &0xff);
     215                        keybuffer_push(keybuffer, (buf >> 24) &0xff);
     216                        keybuffer_push(keybuffer, scan_code);
     217                        buf = count = 0;
     218                        return 1;
     219                }
     220        }
     221
     222        buf |= ((unsigned long) scan_code)<<(8*(count++));
     223       
     224        if((buf & 0xff) != (NSKEY_F1 & 0xff)) {
     225                keybuffer_push(keybuffer, buf);
     226                buf = count = 0;
     227                return 1;
     228        }
     229
     230        if (count <= 1)
     231                return 1;
     232
     233        if ((buf & 0xffff) != (NSKEY_F1 & 0xffff))  {
     234
     235                keybuffer_push(keybuffer, buf & 0xff);
     236                keybuffer_push(keybuffer, (buf >> 8) &0xff);
     237                buf = count = 0;
     238                return 1;
     239        }
     240
     241        if (count <= 2)
     242                return 1;
     243
     244
     245        if ((buf & 0xffffff) != (NSKEY_F1 & 0xffffff)
     246                && (buf & 0xffffff) != (NSKEY_F6 & 0xffffff)
     247                && (buf & 0xffffff) != (NSKEY_F9 & 0xffffff) ) {
     248
     249                keybuffer_push(keybuffer, buf & 0xff);
     250                keybuffer_push(keybuffer, (buf >> 8) &0xff);
     251                keybuffer_push(keybuffer, (buf >> 16) &0xff);
     252                buf = count = 0;
     253                return 1;
     254        }
     255
     256        if (count <= 3)
     257                return 1;
     258
     259        switch (buf) {
     260        case NSKEY_F1:
     261                keybuffer_push(keybuffer,FUNCTION_KEYS | 1);
     262                buf = count = 0;
     263                return 1;
     264        case NSKEY_F2:
     265                keybuffer_push(keybuffer,FUNCTION_KEYS | 2);
     266                buf = count = 0;
     267                return 1;
     268        case NSKEY_F3:
     269                keybuffer_push(keybuffer,FUNCTION_KEYS | 3);
     270                buf = count = 0;
     271                return 1;
     272        case NSKEY_F4:
     273                keybuffer_push(keybuffer,FUNCTION_KEYS | 4);
     274                buf = count = 0;
     275                return 1;
     276        case NSKEY_F5:
     277                keybuffer_push(keybuffer,FUNCTION_KEYS | 5);
     278                buf = count = 0;
     279                return 1;
     280        }
     281
     282
     283       
     284        switch (buf) {
     285        case NSKEY_F6:
     286        case NSKEY_F7:
     287        case NSKEY_F8:
     288        case NSKEY_F9:
     289        case NSKEY_F10:
     290        case NSKEY_F11:
     291        case NSKEY_F12:
     292                return 1;
     293        default:
     294                keybuffer_push(keybuffer, buf & 0xff);
     295                keybuffer_push(keybuffer, (buf >> 8) &0xff);
     296                keybuffer_push(keybuffer, (buf >> 16) &0xff);
     297                keybuffer_push(keybuffer, (buf >> 24) &0xff);
     298                buf = count = 0;
     299                return 1;
     300        }
     301        return 1;
     302}
     303
     304
     305
     306
     307
     308
     309
     310int kbd_ski_process(keybuffer_t *keybuffer, ipc_call_t *call)
    86311{
    87312        static unsigned long long buf = 0;
     
    89314        static int esc_count = 0;
    90315        int scan_code = IPC_GET_ARG2(*call);
    91 
     316       
    92317        /*
    93318         * Please preserve this code (it can be used to determine scancodes)
     
    98323        //keybuffer_push(keybuffer, ' ');
    99324        //*/
     325
    100326       
    101327        if (scan_code) {
     
    156382                buf = count = 0;
    157383        }
    158 
    159384        return  1;
    160385}
     386
     387int kbd_arch_process(keybuffer_t *keybuffer, ipc_call_t *call)
     388{
     389        printf("KBD Key pressed: %x(%c)\n",IPC_GET_ARG2(*call),IPC_GET_ARG2(*call));
     390        if(kbd_type==KBD_SKI) return kbd_ski_process(keybuffer,call);
     391        if(kbd_type==KBD_NS16550) return kbd_ns16550_process(keybuffer,call);
     392
     393       
     394}
     395
     396
    161397
    162398/**
Note: See TracChangeset for help on using the changeset viewer.