Rev 4055 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4055 | Rev 4156 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup ppc32 |
29 | /** @addtogroup ppc32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
Line 38... | Line 38... | ||
38 | #include <console/chardev.h> |
38 | #include <console/chardev.h> |
39 | #include <arch/drivers/pic.h> |
39 | #include <arch/drivers/pic.h> |
40 | #include <sysinfo/sysinfo.h> |
40 | #include <sysinfo/sysinfo.h> |
41 | #include <interrupt.h> |
41 | #include <interrupt.h> |
42 | #include <stdarg.h> |
42 | #include <stdarg.h> |
- | 43 | #include <ddi/device.h> |
|
43 | 44 | ||
44 | #define CUDA_IRQ 10 |
45 | #define CUDA_IRQ 10 |
45 | #define SPECIAL '?' |
46 | #define SPECIAL '?' |
46 | 47 | ||
47 | #define PACKET_ADB 0x00 |
48 | #define PACKET_ADB 0x00 |
Line 202... | Line 203... | ||
202 | 203 | ||
203 | cuda[B] = cuda[B] | TIP; |
204 | cuda[B] = cuda[B] | TIP; |
204 | } |
205 | } |
205 | 206 | ||
206 | 207 | ||
207 | /* Called from getc(). */ |
- | |
208 | static void cuda_resume(chardev_t *d) |
- | |
209 | { |
- | |
210 | } |
- | |
211 | - | ||
212 | - | ||
213 | /* Called from getc(). */ |
- | |
214 | static void cuda_suspend(chardev_t *d) |
- | |
215 | { |
- | |
216 | } |
- | |
217 | - | ||
218 | - | ||
219 | static char key_read(chardev_t *d) |
- | |
220 | { |
- | |
221 | char ch; |
- | |
222 | - | ||
223 | ch = 0; |
- | |
224 | return ch; |
- | |
225 | } |
- | |
226 | - | ||
227 | - | ||
228 | static chardev_t kbrd; |
208 | static indev_t kbrd; |
229 | static chardev_operations_t ops = { |
209 | static indev_operations_t ops = { |
230 | .suspend = cuda_suspend, |
- | |
231 | .resume = cuda_resume, |
- | |
232 | .read = key_read |
210 | .poll = NULL |
233 | }; |
211 | }; |
234 | 212 | ||
235 | 213 | ||
236 | int cuda_get_scancode(void) |
214 | int cuda_get_scancode(void) |
237 | { |
215 | { |
Line 249... | Line 227... | ||
249 | } |
227 | } |
250 | 228 | ||
251 | static void cuda_irq_handler(irq_t *irq) |
229 | static void cuda_irq_handler(irq_t *irq) |
252 | { |
230 | { |
253 | int scan_code = cuda_get_scancode(); |
231 | int scan_code = cuda_get_scancode(); |
254 | 232 | ||
255 | if (scan_code != -1) { |
233 | if (scan_code != -1) { |
256 | uint8_t scancode = (uint8_t) scan_code; |
234 | uint8_t scancode = (uint8_t) scan_code; |
257 | if ((scancode & 0x80) != 0x80) |
235 | if ((scancode & 0x80) != 0x80) |
258 | chardev_push_character(&kbrd, lchars[scancode & 0x7f]); |
236 | indev_push_character(&kbrd, lchars[scancode & 0x7f]); |
259 | } |
237 | } |
260 | } |
238 | } |
261 | 239 | ||
262 | static irq_ownership_t cuda_claim(irq_t *irq) |
240 | static irq_ownership_t cuda_claim(irq_t *irq) |
263 | { |
241 | { |
264 | return IRQ_ACCEPT; |
242 | return IRQ_ACCEPT; |
265 | } |
243 | } |
266 | 244 | ||
267 | void cuda_init(devno_t devno, uintptr_t base, size_t size) |
245 | void cuda_init(uintptr_t base, size_t size) |
268 | { |
246 | { |
269 | cuda = (uint8_t *) hw_map(base, size); |
247 | cuda = (uint8_t *) hw_map(base, size); |
270 | 248 | ||
271 | chardev_initialize("cuda_kbd", &kbrd, &ops); |
249 | indev_initialize("cuda_kbd", &kbrd, &ops); |
272 | stdin = &kbrd; |
250 | stdin = &kbrd; |
273 | 251 | ||
274 | irq_initialize(&cuda_irq); |
252 | irq_initialize(&cuda_irq); |
275 | cuda_irq.devno = devno; |
253 | cuda_irq.devno = device_assign_devno(); |
276 | cuda_irq.inr = CUDA_IRQ; |
254 | cuda_irq.inr = CUDA_IRQ; |
277 | cuda_irq.claim = cuda_claim; |
255 | cuda_irq.claim = cuda_claim; |
278 | cuda_irq.handler = cuda_irq_handler; |
256 | cuda_irq.handler = cuda_irq_handler; |
279 | irq_register(&cuda_irq); |
257 | irq_register(&cuda_irq); |
280 | 258 | ||
281 | pic_enable_interrupt(CUDA_IRQ); |
259 | pic_enable_interrupt(CUDA_IRQ); |
282 | 260 | ||
283 | sysinfo_set_item_val("kbd", NULL, true); |
261 | sysinfo_set_item_val("kbd", NULL, true); |
284 | sysinfo_set_item_val("kbd.devno", NULL, devno); |
- | |
285 | sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ); |
262 | sysinfo_set_item_val("kbd.inr", NULL, CUDA_IRQ); |
286 | sysinfo_set_item_val("kbd.address.virtual", NULL, base); |
263 | sysinfo_set_item_val("kbd.address.virtual", NULL, base); |
287 | } |
264 | } |
288 | 265 | ||
289 | 266 |