Rev 1912 | Rev 1920 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1912 | Rev 1919 | ||
---|---|---|---|
Line 38... | Line 38... | ||
38 | #include <genarch/kbd/z8530.h> |
38 | #include <genarch/kbd/z8530.h> |
39 | #endif |
39 | #endif |
40 | #ifdef CONFIG_NS16550 |
40 | #ifdef CONFIG_NS16550 |
41 | #include <genarch/kbd/ns16550.h> |
41 | #include <genarch/kbd/ns16550.h> |
42 | #endif |
42 | #endif |
43 | - | ||
- | 43 | #include <irq.h> |
|
44 | #include <arch/mm/page.h> |
44 | #include <arch/mm/page.h> |
45 | #include <arch/types.h> |
45 | #include <arch/types.h> |
46 | #include <typedefs.h> |
46 | #include <typedefs.h> |
47 | #include <align.h> |
47 | #include <align.h> |
48 | #include <func.h> |
48 | #include <func.h> |
Line 50... | Line 50... | ||
50 | 50 | ||
51 | volatile uint8_t *kbd_virt_address = NULL; |
51 | volatile uint8_t *kbd_virt_address = NULL; |
52 | 52 | ||
53 | kbd_type_t kbd_type = KBD_UNKNOWN; |
53 | kbd_type_t kbd_type = KBD_UNKNOWN; |
54 | 54 | ||
- | 55 | static irq_t kbd_irq; |
|
- | 56 | ||
55 | /** Initialize keyboard. |
57 | /** Initialize keyboard. |
56 | * |
58 | * |
57 | * Traverse OpenFirmware device tree in order to find necessary |
59 | * Traverse OpenFirmware device tree in order to find necessary |
58 | * info about the keyboard device. |
60 | * info about the keyboard device. |
59 | * |
61 | * |
Line 99... | Line 101... | ||
99 | 101 | ||
100 | uintptr_t pa; |
102 | uintptr_t pa; |
101 | size_t size; |
103 | size_t size; |
102 | int inr; |
104 | int inr; |
103 | 105 | ||
- | 106 | irq_initialize(&kbd_irq); |
|
- | 107 | ||
104 | switch (kbd_type) { |
108 | switch (kbd_type) { |
105 | case KBD_Z8530: |
109 | case KBD_Z8530: |
106 | size = ((ofw_fhc_reg_t *) prop->value)->size; |
110 | size = ((ofw_fhc_reg_t *) prop->value)->size; |
107 | if (!ofw_fhc_apply_ranges(node->parent, ((ofw_fhc_reg_t *) prop->value) , &pa)) { |
111 | if (!ofw_fhc_apply_ranges(node->parent, ((ofw_fhc_reg_t *) prop->value) , &pa)) { |
108 | printf("Failed to determine keyboard address.\n"); |
112 | printf("Failed to determine keyboard address.\n"); |
109 | return; |
113 | return; |
110 | } |
114 | } |
111 | if (!ofw_fhc_map_interrupt(node->parent, ((ofw_fhc_reg_t *) prop->value), interrupts, &inr)) { |
115 | if (!ofw_fhc_map_interrupt(node->parent, ((ofw_fhc_reg_t *) prop->value), interrupts, &inr)) { |
112 | printf("Failed to determine keyboard interrupt.\n"); |
116 | printf("Failed to determine keyboard interrupt.\n"); |
113 | return; |
117 | return; |
- | 118 | } else { |
|
- | 119 | kbd_irq.inr = inr; |
|
- | 120 | kbd_irq.devno = 0; /* FIXME: assign unique devno */ |
|
- | 121 | kbd_irq.trigger = IRQ_TRIGGER_LEVEL; |
|
- | 122 | kbd_irq.claim = z8530_claim; |
|
- | 123 | kbd_irq.handler = z8530_irq_handler; |
|
- | 124 | irq_register(&kbd_irq); |
|
114 | } |
125 | } |
115 | break; |
126 | break; |
- | 127 | ||
116 | case KBD_NS16550: |
128 | case KBD_NS16550: |
117 | size = ((ofw_ebus_reg_t *) prop->value)->size; |
129 | size = ((ofw_ebus_reg_t *) prop->value)->size; |
118 | if (!ofw_ebus_apply_ranges(node->parent, ((ofw_ebus_reg_t *) prop->value) , &pa)) { |
130 | if (!ofw_ebus_apply_ranges(node->parent, ((ofw_ebus_reg_t *) prop->value) , &pa)) { |
119 | printf("Failed to determine keyboard address.\n"); |
131 | printf("Failed to determine keyboard address.\n"); |
120 | return; |
132 | return; |
121 | } |
133 | } |
122 | if (!ofw_ebus_map_interrupt(node->parent, ((ofw_ebus_reg_t *) prop->value), interrupts, &inr)) { |
134 | if (!ofw_ebus_map_interrupt(node->parent, ((ofw_ebus_reg_t *) prop->value), interrupts, &inr)) { |
123 | printf("Failed to determine keyboard interrupt.\n"); |
135 | printf("Failed to determine keyboard interrupt.\n"); |
124 | return; |
136 | return; |
- | 137 | } else { |
|
- | 138 | kbd_irq.inr = inr; |
|
- | 139 | kbd_irq.devno = 0; /* FIXME: assign unique devno */ |
|
- | 140 | kbd_irq.trigger = IRQ_TRIGGER_LEVEL; |
|
- | 141 | kbd_irq.claim = ns16550_claim; |
|
- | 142 | kbd_irq.handler = ns16550_irq_handler; |
|
- | 143 | irq_register(&kbd_irq); |
|
125 | } |
144 | } |
126 | break; |
145 | break; |
- | 146 | ||
127 | default: |
147 | default: |
128 | panic("Unexpected type.\n"); |
148 | panic("Unexpected type.\n"); |
129 | } |
149 | } |
130 | 150 | ||
131 | /* |
151 | /* |