Subversion Repositories HelenOS

Rev

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

Rev 2131 Rev 2456
Line 47... Line 47...
47
#include <console/chardev.h>
47
#include <console/chardev.h>
48
#include <console/console.h>
48
#include <console/console.h>
49
#include <interrupt.h>
49
#include <interrupt.h>
50
#include <sysinfo/sysinfo.h>
50
#include <sysinfo/sysinfo.h>
51
#include <ipc/irq.h>
51
#include <ipc/irq.h>
-
 
52
#include <generic/synch/rcu.h>
52
 
53
 
53
/* Keyboard commands. */
54
/* Keyboard commands. */
54
#define KBD_ENABLE  0xf4
55
#define KBD_ENABLE  0xf4
55
#define KBD_DISABLE 0xf5
56
#define KBD_DISABLE 0xf5
56
#define KBD_ACK     0xfa
57
#define KBD_ACK     0xfa
Line 105... Line 106...
105
    i8042_command_write(i8042_SET_COMMAND);
106
    i8042_command_write(i8042_SET_COMMAND);
106
    i8042_wait();
107
    i8042_wait();
107
    i8042_data_write(i8042_COMMAND);
108
    i8042_data_write(i8042_COMMAND);
108
    i8042_wait();
109
    i8042_wait();
109
 
110
 
110
    spinlock_lock(&i8042_kbd_irq.lock);
111
    //rcu_read_lock() is not needed, ints are disabled
111
    i8042_kbd_irq.notif_cfg.notify = false;
112
    //rcu: atomic update doesn't need reallocation
112
    spinlock_unlock(&i8042_kbd_irq.lock);
113
    rcu_dereference_pointer(i8042_kbd_irq.notif_cfg).notify = false;
113
   
114
   
114
    spinlock_lock(&i8042_mouse_irq.lock);
-
 
115
    i8042_mouse_irq.notif_cfg.notify = false;
115
    rcu_dereference_pointer(i8042_mouse_irq.notif_cfg).notify = false;
116
    spinlock_unlock(&i8042_mouse_irq.lock);
-
 
117
   
116
   
118
    interrupts_restore(ipl);
117
    interrupts_restore(ipl);
119
}
118
}
120
 
119
 
121
void i8042_release(void)
120
void i8042_release(void)
122
{
121
{
123
    ipl_t ipl = interrupts_disable();
122
    ipl_t ipl = interrupts_disable();
124
   
-
 
-
 
123
    //rcu: atomic update doesn't need reallocation
125
    spinlock_lock(&i8042_kbd_irq.lock);
124
    spinlock_lock(&i8042_kbd_irq.lock);
126
    if (i8042_kbd_irq.notif_cfg.answerbox)
125
    if (rcu_dereference_pointer(i8042_kbd_irq.notif_cfg).answerbox)
127
        i8042_kbd_irq.notif_cfg.notify = true;
126
        rcu_dereference_pointer(i8042_kbd_irq.notif_cfg).notify = true;
128
    spinlock_unlock(&i8042_kbd_irq.lock);
127
    spinlock_unlock(&i8042_kbd_irq.lock);
129
   
128
   
130
    spinlock_lock(&i8042_mouse_irq.lock);
129
    spinlock_lock(&i8042_mouse_irq.lock);
131
    if (i8042_mouse_irq.notif_cfg.answerbox)
130
    if (rcu_dereference_pointer(i8042_mouse_irq.notif_cfg).answerbox)
132
        i8042_mouse_irq.notif_cfg.notify = true;
131
        rcu_dereference_pointer(i8042_mouse_irq.notif_cfg).notify = true;
133
    spinlock_unlock(&i8042_mouse_irq.lock);
132
    spinlock_unlock(&i8042_mouse_irq.lock);
134
   
133
   
135
    interrupts_restore(ipl);
134
    interrupts_restore(ipl);
136
}
135
}
137
 
136
 
Line 140... Line 139...
140
    return IRQ_ACCEPT;
139
    return IRQ_ACCEPT;
141
}
140
}
142
 
141
 
143
static void i8042_kbd_irq_handler(irq_t *irq, void *arg, ...)
142
static void i8042_kbd_irq_handler(irq_t *irq, void *arg, ...)
144
{
143
{
145
    if (irq->notif_cfg.notify && irq->notif_cfg.answerbox)
144
    if (rcu_dereference_pointer(irq->notif_cfg).notify && rcu_dereference_pointer(irq->notif_cfg).answerbox)
146
        ipc_irq_send_notif(irq);
145
        ipc_irq_send_notif(irq);
147
    else {
146
    else {
148
        uint8_t x;
147
        uint8_t x;
149
        uint8_t status;
148
        uint8_t status;
150
       
149
       
Line 162... Line 161...
162
    }
161
    }
163
}
162
}
164
 
163
 
165
static void i8042_mouse_irq_handler(irq_t *irq, void *arg, ...)
164
static void i8042_mouse_irq_handler(irq_t *irq, void *arg, ...)
166
{
165
{
167
    if (irq->notif_cfg.notify && irq->notif_cfg.answerbox)
166
    if (rcu_dereference_pointer(irq->notif_cfg).notify && rcu_dereference_pointer(irq->notif_cfg).answerbox)
168
        ipc_irq_send_notif(irq);
167
        ipc_irq_send_notif(irq);
169
}
168
}
170
 
169
 
171
/** Initialize i8042. */
170
/** Initialize i8042. */
172
void i8042_init(devno_t kbd_devno, inr_t kbd_inr, devno_t mouse_devno, inr_t mouse_inr)
171
void i8042_init(devno_t kbd_devno, inr_t kbd_inr, devno_t mouse_devno, inr_t mouse_inr)