Subversion Repositories HelenOS

Rev

Rev 2927 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2927 Rev 3674
Line 41... Line 41...
41
#include <arch/drivers/z8530.h>
41
#include <arch/drivers/z8530.h>
42
#include <ddi/irq.h>
42
#include <ddi/irq.h>
43
#include <ipc/irq.h>
43
#include <ipc/irq.h>
44
#include <arch/interrupt.h>
44
#include <arch/interrupt.h>
45
#include <arch/drivers/kbd.h>
45
#include <arch/drivers/kbd.h>
46
#include <arch/drivers/fhc.h>
-
 
47
#include <cpu.h>
46
#include <cpu.h>
48
#include <arch/asm.h>
47
#include <arch/asm.h>
49
#include <arch.h>
48
#include <arch.h>
50
#include <console/chardev.h>
49
#include <console/chardev.h>
51
#include <console/console.h>
50
#include <console/console.h>
Line 81... Line 80...
81
     * Clear any pending TX interrupts or we never manage
80
     * Clear any pending TX interrupts or we never manage
82
     * to set FHC UART interrupt state to idle.
81
     * to set FHC UART interrupt state to idle.
83
     */
82
     */
84
    z8530_write_a(&z8530, WR0, WR0_TX_IP_RST);
83
    z8530_write_a(&z8530, WR0, WR0_TX_IP_RST);
85
 
84
 
-
 
85
    /* interrupt on all characters */
86
    z8530_write_a(&z8530, WR1, WR1_IARCSC);     /* interrupt on all characters */
86
    z8530_write_a(&z8530, WR1, WR1_IARCSC);
87
 
87
 
88
    /* 8 bits per character and enable receiver */
88
    /* 8 bits per character and enable receiver */
89
    z8530_write_a(&z8530, WR3, WR3_RX8BITSCH | WR3_RX_ENABLE);
89
    z8530_write_a(&z8530, WR3, WR3_RX8BITSCH | WR3_RX_ENABLE);
90
   
90
   
-
 
91
    /* Master Interrupt Enable. */
91
    z8530_write_a(&z8530, WR9, WR9_MIE);        /* Master Interrupt Enable. */
92
    z8530_write_a(&z8530, WR9, WR9_MIE);
92
   
93
   
93
    spinlock_lock(&z8530_irq.lock);
94
    spinlock_lock(&z8530_irq.lock);
94
    z8530_irq.notif_cfg.notify = false;
95
    z8530_irq.notif_cfg.notify = false;
95
    spinlock_unlock(&z8530_irq.lock);
96
    spinlock_unlock(&z8530_irq.lock);
96
    interrupts_restore(ipl);
97
    interrupts_restore(ipl);
Line 106... Line 107...
106
    spinlock_unlock(&z8530_irq.lock);
107
    spinlock_unlock(&z8530_irq.lock);
107
    interrupts_restore(ipl);
108
    interrupts_restore(ipl);
108
}
109
}
109
 
110
 
110
/** Initialize z8530. */
111
/** Initialize z8530. */
-
 
112
void
111
void z8530_init(devno_t devno, inr_t inr, uintptr_t vaddr)
113
z8530_init(devno_t devno, uintptr_t vaddr, inr_t inr, cir_t cir, void *cir_arg)
112
{
114
{
113
    chardev_initialize("z8530_kbd", &kbrd, &ops);
115
    chardev_initialize("z8530_kbd", &kbrd, &ops);
114
    stdin = &kbrd;
116
    stdin = &kbrd;
115
 
117
 
116
    z8530.devno = devno;
118
    z8530.devno = devno;
Line 119... Line 121...
119
    irq_initialize(&z8530_irq);
121
    irq_initialize(&z8530_irq);
120
    z8530_irq.devno = devno;
122
    z8530_irq.devno = devno;
121
    z8530_irq.inr = inr;
123
    z8530_irq.inr = inr;
122
    z8530_irq.claim = z8530_claim;
124
    z8530_irq.claim = z8530_claim;
123
    z8530_irq.handler = z8530_irq_handler;
125
    z8530_irq.handler = z8530_irq_handler;
-
 
126
    z8530_irq.cir = cir;
-
 
127
    z8530_irq.cir_arg = cir_arg;
124
    irq_register(&z8530_irq);
128
    irq_register(&z8530_irq);
125
 
129
 
126
    sysinfo_set_item_val("kbd", NULL, true);
130
    sysinfo_set_item_val("kbd", NULL, true);
127
    sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530);
131
    sysinfo_set_item_val("kbd.type", NULL, KBD_Z8530);
128
    sysinfo_set_item_val("kbd.devno", NULL, devno);
132
    sysinfo_set_item_val("kbd.devno", NULL, devno);
Line 195... Line 199...
195
    return (z8530_read_a(&z8530, RR0) & RR0_RCA);
199
    return (z8530_read_a(&z8530, RR0) & RR0_RCA);
196
}
200
}
197
 
201
 
198
void z8530_irq_handler(irq_t *irq, void *arg, ...)
202
void z8530_irq_handler(irq_t *irq, void *arg, ...)
199
{
203
{
200
    /*
-
 
201
     * So far, we know we got this interrupt through the FHC.
-
 
202
     * Since we don't have enough documentation about the FHC
-
 
203
     * and because the interrupt looks like level sensitive,
-
 
204
     * we cannot handle it by scheduling one of the level
-
 
205
     * interrupt traps. Process the interrupt directly.
-
 
206
     */
-
 
207
    if (irq->notif_cfg.notify && irq->notif_cfg.answerbox)
204
    if (irq->notif_cfg.notify && irq->notif_cfg.answerbox)
208
        ipc_irq_send_notif(irq);
205
        ipc_irq_send_notif(irq);
209
    else
206
    else
210
        z8530_interrupt();
207
        z8530_interrupt();
211
    fhc_clear_interrupt(central_fhc, irq->inr);
-
 
212
}
208
}
213
 
209
 
214
/** @}
210
/** @}
215
 */
211
 */