Rev 573 | Rev 577 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 573 | Rev 575 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | #include <print.h> |
31 | #include <print.h> |
32 | #include <arch.h> |
32 | #include <arch.h> |
33 | #include <arch/byteorder.h> |
33 | #include <arch/byteorder.h> |
34 | #include <arch/mm/frame.h> |
34 | #include <arch/mm/frame.h> |
35 | #include <mm/frame.h> |
35 | #include <mm/frame.h> |
- | 36 | #include <interrupt.h> |
|
36 | 37 | ||
37 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
38 | /* This is a good joke, SGI HAS different types than NT bioses... */ |
38 | /* Here is the SGI type */ |
39 | /* Here is the SGI type */ |
39 | static char *basetypes[] = { |
40 | static char *basetypes[] = { |
40 | "ExceptionBlock", |
41 | "ExceptionBlock", |
Line 95... | Line 96... | ||
95 | }; |
96 | }; |
96 | 97 | ||
97 | static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
98 | static arc_sbp *sbp = (arc_sbp *)PA2KA(0x1000); |
98 | static arc_func_vector_t *arc_entry; |
99 | static arc_func_vector_t *arc_entry; |
99 | 100 | ||
100 | static void _arc_putchar(char ch); |
- | |
101 | 101 | ||
102 | /** Initialize ARC structure |
- | |
103 | * |
- | |
104 | * @return 0 - ARC OK, -1 - ARC does not exist |
- | |
105 | */ |
- | |
106 | int arc_init(void) |
- | |
107 | { |
- | |
108 | if (sbp->signature != ARC_MAGIC) { |
- | |
109 | sbp = NULL; |
- | |
110 | return -1; |
- | |
111 | } |
- | |
112 | arc_entry = sbp->firmwarevector; |
- | |
113 | - | ||
114 | arc_putchar('A'); |
- | |
115 | arc_putchar('R'); |
- | |
116 | arc_putchar('C'); |
- | |
117 | arc_putchar('\n'); |
102 | static void arc_putchar(char ch); |
118 | } |
- | |
119 | 103 | ||
120 | /** Return true if ARC is available */ |
104 | /** Return true if ARC is available */ |
121 | int arc_enabled(void) |
105 | int arc_enabled(void) |
122 | { |
106 | { |
123 | return sbp != NULL; |
107 | return sbp != NULL; |
Line 127... | Line 111... | ||
127 | { |
111 | { |
128 | int i; |
112 | int i; |
129 | 113 | ||
130 | printf("%s: ",ctypes[c->type]); |
114 | printf("%s: ",ctypes[c->type]); |
131 | for (i=0;i < c->identifier_len;i++) |
115 | for (i=0;i < c->identifier_len;i++) |
132 | putchar(c->identifier[i]); |
116 | arc_putchar(c->identifier[i]); |
133 | putchar('\n'); |
117 | arc_putchar('\n'); |
134 | } |
118 | } |
135 | 119 | ||
136 | void arc_print_devices(void) |
120 | void arc_print_devices(void) |
137 | { |
121 | { |
138 | arc_component *c,*next; |
122 | arc_component *c,*next; |
Line 172... | Line 156... | ||
172 | desc = arc_entry->getmemorydescriptor(desc); |
156 | desc = arc_entry->getmemorydescriptor(desc); |
173 | } |
157 | } |
174 | } |
158 | } |
175 | 159 | ||
176 | /** Print charactor to console */ |
160 | /** Print charactor to console */ |
177 | void arc_putchar(char ch) |
161 | static void arc_putchar(char ch) |
178 | { |
162 | { |
179 | __u32 cnt; |
163 | __u32 cnt; |
180 | ipl_t ipl; |
164 | ipl_t ipl; |
181 | 165 | ||
182 | /* TODO: Should be spinlock? */ |
166 | /* TODO: Should be spinlock? */ |
Line 184... | Line 168... | ||
184 | arc_entry->write(1, &ch, 1, &cnt); |
168 | arc_entry->write(1, &ch, 1, &cnt); |
185 | interrupts_restore(ipl); |
169 | interrupts_restore(ipl); |
186 | 170 | ||
187 | } |
171 | } |
188 | 172 | ||
- | 173 | /** Initialize ARC structure |
|
- | 174 | * |
|
- | 175 | * @return 0 - ARC OK, -1 - ARC does not exist |
|
- | 176 | */ |
|
- | 177 | int arc_init(void) |
|
- | 178 | { |
|
- | 179 | if (sbp->signature != ARC_MAGIC) { |
|
- | 180 | sbp = NULL; |
|
- | 181 | return -1; |
|
- | 182 | } |
|
- | 183 | arc_entry = sbp->firmwarevector; |
|
- | 184 | ||
- | 185 | arc_putchar('A'); |
|
- | 186 | arc_putchar('R'); |
|
- | 187 | arc_putchar('C'); |
|
- | 188 | arc_putchar('\n'); |
|
- | 189 | } |
|
- | 190 | ||
- | 191 | static int kbd_polling_enabled; |
|
- | 192 | static chardev_t console; |
|
- | 193 | ||
189 | /** Try to get character, return character or -1 if not available */ |
194 | /** Try to get character, return character or -1 if not available */ |
190 | int arc_getchar(void) |
195 | static void arc_keyboard_poll(void) |
191 | { |
196 | { |
192 | char ch; |
197 | char ch; |
193 | __u32 count; |
198 | __u32 count; |
194 | long result; |
199 | long result; |
- | 200 | ||
- | 201 | if (! kbd_polling_enabled) |
|
- | 202 | return; |
|
195 | 203 | ||
196 | if (arc_entry->getreadstatus(0)) |
204 | if (arc_entry->getreadstatus(0)) |
197 | return -1; |
205 | return; |
198 | result = arc_entry->read(0, &ch, 1, &count); |
206 | result = arc_entry->read(0, &ch, 1, &count); |
199 | if (result || count!=1) { |
207 | if (result || count!=1) { |
200 | cpu_halt(); |
- | |
201 | return -1; |
208 | return; |
202 | } |
209 | } |
203 | if (ch == '\r') |
210 | if (ch == '\r') |
204 | return '\n'; |
211 | ch = '\n'; |
- | 212 | ||
- | 213 | chardev_push_character(&console, ch); |
|
- | 214 | } |
|
- | 215 | ||
- | 216 | static void arc_write(chardev_t *dev, const char ch) |
|
- | 217 | { |
|
- | 218 | arc_putchar(ch); |
|
- | 219 | } |
|
- | 220 | ||
- | 221 | static void arc_enable(chardev_t *dev) |
|
- | 222 | { |
|
- | 223 | kbd_polling_enabled = 1; |
|
- | 224 | } |
|
- | 225 | ||
- | 226 | static void arc_disable(chardev_t *dev) |
|
- | 227 | { |
|
- | 228 | kbd_polling_enabled = 0; |
|
- | 229 | } |
|
- | 230 | ||
- | 231 | static chardev_operations_t arc_ops = { |
|
- | 232 | .resume = arc_enable, |
|
- | 233 | .suspend = arc_disable, |
|
- | 234 | .write = arc_write |
|
- | 235 | }; |
|
- | 236 | ||
- | 237 | iroutine old_timer; |
|
- | 238 | /** Do polling on timer interrupt */ |
|
- | 239 | static void timer_replace(int n, void *stack) |
|
- | 240 | { |
|
- | 241 | arc_keyboard_poll(); |
|
- | 242 | old_timer(n, stack); |
|
- | 243 | arc_keyboard_poll(); |
|
- | 244 | } |
|
- | 245 | ||
- | 246 | ||
- | 247 | chardev_t * arc_console(void) |
|
- | 248 | { |
|
- | 249 | kbd_polling_enabled = 1; |
|
- | 250 | ||
- | 251 | chardev_initialize("arc_console", &console, &arc_ops); |
|
- | 252 | old_timer = exc_register(TIMER_IRQ, "arc_kb_poll", timer_replace); |
|
205 | return ch; |
253 | return &console; |
206 | } |
254 | } |
207 | 255 | ||
208 | /* Initialize frame zones from ARC firmware. |
256 | /* Initialize frame zones from ARC firmware. |
209 | * In the future we may use even the FirmwareTemporary regions, |
257 | * In the future we may use even the FirmwareTemporary regions, |
210 | * currently we use the FreeMemory (what about the LoadedProgram?) |
258 | * currently we use the FreeMemory (what about the LoadedProgram?) |