Changeset 973be64e in mainline for arch/mips32/src/drivers/arc.c
- Timestamp:
- 2005-12-10T00:19:57Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fcfac420
- Parents:
- 705b4149
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/mips32/src/drivers/arc.c
r705b4149 r973be64e 34 34 #include <arch/mm/frame.h> 35 35 #include <mm/frame.h> 36 #include <interrupt.h> 36 37 37 38 /* This is a good joke, SGI HAS different types than NT bioses... */ … … 98 99 static arc_func_vector_t *arc_entry; 99 100 100 static void _arc_putchar(char ch); 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'); 118 } 101 102 static void arc_putchar(char ch); 119 103 120 104 /** Return true if ARC is available */ … … 130 114 printf("%s: ",ctypes[c->type]); 131 115 for (i=0;i < c->identifier_len;i++) 132 putchar(c->identifier[i]);133 putchar('\n');116 arc_putchar(c->identifier[i]); 117 arc_putchar('\n'); 134 118 } 135 119 … … 175 159 176 160 /** Print charactor to console */ 177 void arc_putchar(char ch)161 static void arc_putchar(char ch) 178 162 { 179 163 __u32 cnt; … … 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 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 197 char ch; 193 198 __u32 count; 194 199 long result; 200 201 if (! kbd_polling_enabled) 202 return; 195 203 196 204 if (arc_entry->getreadstatus(0)) 197 return -1;205 return; 198 206 result = arc_entry->read(0, &ch, 1, &count); 199 207 if (result || count!=1) { 200 cpu_halt(); 201 return -1; 208 return; 202 209 } 203 210 if (ch == '\r') 204 return '\n'; 205 return ch; 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); 253 return &console; 206 254 } 207 255
Note:
See TracChangeset
for help on using the changeset viewer.