Subversion Repositories HelenOS

Rev

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

Rev 4156 Rev 4296
Line 32... Line 32...
32
/**
32
/**
33
 * @file
33
 * @file
34
 * @brief i8042 processor driver
34
 * @brief i8042 processor driver
35
 *
35
 *
36
 * It takes care of the i8042 serial communication.
36
 * It takes care of the i8042 serial communication.
-
 
37
 *
37
 */
38
 */
38
 
39
 
39
#include <genarch/drivers/i8042/i8042.h>
40
#include <genarch/drivers/i8042/i8042.h>
40
#include <genarch/drivers/legacy/ia32/io.h>
41
#include <genarch/drivers/legacy/ia32/io.h>
41
#include <arch/asm.h>
42
#include <arch/asm.h>
Line 47... Line 48...
47
    .poll = NULL
48
    .poll = NULL
48
};
49
};
49
 
50
 
50
#define i8042_SET_COMMAND  0x60
51
#define i8042_SET_COMMAND  0x60
51
#define i8042_COMMAND      0x69
52
#define i8042_COMMAND      0x69
-
 
53
#define i8042_CPU_RESET    0xfe
52
 
54
 
53
#define i8042_BUFFER_FULL_MASK  0x01
55
#define i8042_BUFFER_FULL_MASK  0x01
54
#define i8042_WAIT_MASK         0x02
56
#define i8042_WAIT_MASK         0x02
55
 
57
 
56
static irq_ownership_t i8042_claim(irq_t *irq)
58
static irq_ownership_t i8042_claim(irq_t *irq)
Line 94... Line 96...
94
    instance->irq.claim = i8042_claim;
96
    instance->irq.claim = i8042_claim;
95
    instance->irq.handler = i8042_irq_handler;
97
    instance->irq.handler = i8042_irq_handler;
96
    instance->irq.instance = instance;
98
    instance->irq.instance = instance;
97
    irq_register(&instance->irq);
99
    irq_register(&instance->irq);
98
   
100
   
99
    /*
-
 
100
     * Clear input buffer.
101
    /* Clear input buffer */
101
     */
-
 
102
    while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
102
    while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
103
        (void) pio_read_8(&dev->data);
103
        (void) pio_read_8(&dev->data);
104
   
104
   
105
    return &instance->kbrdin;
105
    return &instance->kbrdin;
106
}
106
}
107
 
107
 
-
 
108
/* Reset CPU by pulsing pin 0 */
-
 
109
void i8042_cpu_reset(i8042_t *dev)
-
 
110
{
-
 
111
    interrupts_disable();
-
 
112
   
-
 
113
    /* Clear input buffer */
-
 
114
    while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK)
-
 
115
        (void) pio_read_8(&dev->data);
-
 
116
   
-
 
117
    /* Reset CPU */
-
 
118
    pio_write_8(&dev->status, i8042_CPU_RESET);
-
 
119
}
-
 
120
 
108
/** @}
121
/** @}
109
 */
122
 */