Subversion Repositories HelenOS

Rev

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

Rev 1931 Rev 1932
Line 59... Line 59...
59
static ns16550_t ns16550;
59
static ns16550_t ns16550;
60
 
60
 
61
/** Structure for ns16550's IRQ. */
61
/** Structure for ns16550's IRQ. */
62
static irq_t ns16550_irq;
62
static irq_t ns16550_irq;
63
 
63
 
64
static ipc_notif_cfg_t saved_notif_cfg;
-
 
65
 
-
 
66
/*
64
/*
67
 * These codes read from ns16550 data register are silently ignored.
65
 * These codes read from ns16550 data register are silently ignored.
68
 */
66
 */
69
#define IGNORE_CODE 0x7f        /* all keys up */
67
#define IGNORE_CODE 0x7f        /* all keys up */
70
 
68
 
Line 85... Line 83...
85
    ns16550_ier_write(&ns16550, IER_ERBFI);     /* enable receiver interrupt */
83
    ns16550_ier_write(&ns16550, IER_ERBFI);     /* enable receiver interrupt */
86
   
84
   
87
    while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY)
85
    while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY)
88
        (void) ns16550_rbr_read(&ns16550);
86
        (void) ns16550_rbr_read(&ns16550);
89
 
87
 
90
    if (ns16550_irq.notif_cfg.answerbox) {
-
 
91
        saved_notif_cfg = ns16550_irq.notif_cfg;
-
 
92
        ns16550_irq.notif_cfg.answerbox = NULL;
-
 
93
        ns16550_irq.notif_cfg.code = NULL;
88
    ns16550_irq.notif_cfg.notify = false;
94
        ns16550_irq.notif_cfg.method = 0;
-
 
95
        ns16550_irq.notif_cfg.counter = 0;
-
 
96
    }
-
 
97
}
89
}
98
 
90
 
99
/** Resume the former interrupt vector */
91
/** Resume the former interrupt vector */
100
void ns16550_release(void)
92
void ns16550_release(void)
101
{
93
{
102
    if (saved_notif_cfg.answerbox)
94
    if (ns16550_irq.notif_cfg.answerbox)
103
        ns16550_irq.notif_cfg = saved_notif_cfg;
95
        ns16550_irq.notif_cfg.notify = true;
104
}
96
}
105
 
97
 
106
/** Initialize ns16550.
98
/** Initialize ns16550.
107
 *
99
 *
108
 * @param devno Device number.
100
 * @param devno Device number.
Line 181... Line 173...
181
 
173
 
182
    ipl = interrupts_disable();
174
    ipl = interrupts_disable();
183
    spinlock_lock(&ns16550_irq.lock);
175
    spinlock_lock(&ns16550_irq.lock);
184
 
176
 
185
    if (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) {
177
    if (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) {
186
        if (ns16550_irq.notif_cfg.answerbox) {
178
        if (ns16550_irq.notif_cfg.notify && ns16550_irq.notif_cfg.answerbox) {
187
            /*
179
            /*
188
             * Send IPC notification.
180
             * Send IPC notification.
189
             */
181
             */
190
            ipc_irq_send_notif(&ns16550_irq);
182
            ipc_irq_send_notif(&ns16550_irq);
191
            spinlock_unlock(&ns16550_irq.lock);
183
            spinlock_unlock(&ns16550_irq.lock);