Mercurial > hg > Members > kono > os9 > sbc09
comparison io.c @ 55:8d151f303bee
FIRQ does not worked
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 23 Jul 2018 08:35:25 +0900 |
parents | fc10b7ae23d0 |
children |
comparison
equal
deleted
inserted
replaced
54:fc10b7ae23d0 | 55:8d151f303bee |
---|---|
89 | 89 |
90 #define SECSIZE 256 | 90 #define SECSIZE 256 |
91 | 91 |
92 | 92 |
93 int timer = 1; | 93 int timer = 1; |
94 int timer_usec = 20000; // 50Hz | |
94 struct termios termsetting; | 95 struct termios termsetting; |
95 struct termios newterm; | 96 struct termios newterm; |
96 struct itimerval timercontrol; | 97 struct itimerval timercontrol; |
97 | 98 |
98 int tflags; | 99 int tflags; |
295 | 296 |
296 void do_timer(int a, int c) { | 297 void do_timer(int a, int c) { |
297 struct itimerval timercontrol; | 298 struct itimerval timercontrol; |
298 if (a==0x30+(IOPAGE&0x1ff) && c==0x8f) { | 299 if (a==0x30+(IOPAGE&0x1ff) && c==0x8f) { |
299 timercontrol.it_interval.tv_sec = 0; | 300 timercontrol.it_interval.tv_sec = 0; |
300 timercontrol.it_interval.tv_usec = 20000; | 301 timercontrol.it_interval.tv_usec = timer_usec; |
301 timercontrol.it_value.tv_sec = 0; | 302 timercontrol.it_value.tv_sec = 0; |
302 timercontrol.it_value.tv_usec = 20000; | 303 timercontrol.it_value.tv_usec = timer_usec; |
303 timer_irq = 1; | 304 timer_irq = 1; |
304 setitimer(ITIMER_REAL, &timercontrol, NULL); | 305 setitimer(ITIMER_REAL, &timercontrol, NULL); |
305 mem[(IOPAGE&0xfe00)+a]=c; | 306 mem[(IOPAGE&0xfe00)+a]=c; |
306 } else if (a==0x30+(IOPAGE&0x1ff) && c==0x80) { | 307 } else if (a==0x30+(IOPAGE&0x1ff) && c==0x80) { |
307 timercontrol.it_interval.tv_sec = 0; | 308 timercontrol.it_interval.tv_sec = 0; |
367 #endif | 368 #endif |
368 } | 369 } |
369 | 370 |
370 void timehandler(int sig) { | 371 void timehandler(int sig) { |
371 attention = 1; | 372 attention = 1; |
372 #ifdef USE_MMU | 373 irq = timerirq; |
373 irq = 1; | |
374 #else | |
375 irq = 2; | |
376 #endif | |
377 mem[IOPAGE+0x30] |= 0x10 ; | 374 mem[IOPAGE+0x30] |= 0x10 ; |
378 // signal(SIGALRM, timehandler); | 375 // signal(SIGALRM, timehandler); |
379 } | 376 } |
380 | 377 |
381 void handler(int sig) { | 378 void handler(int sig) { |
403 newterm.c_cc[VINTR] = escchar; | 400 newterm.c_cc[VINTR] = escchar; |
404 tcsetattr(0, TCSAFLUSH, &newterm); | 401 tcsetattr(0, TCSAFLUSH, &newterm); |
405 fcntl(0, F_SETFL, tflags | O_NDELAY); /* Make input from stdin non-blocking */ | 402 fcntl(0, F_SETFL, tflags | O_NDELAY); /* Make input from stdin non-blocking */ |
406 signal(SIGALRM, timehandler); | 403 signal(SIGALRM, timehandler); |
407 timercontrol.it_interval.tv_sec = 0; | 404 timercontrol.it_interval.tv_sec = 0; |
408 timercontrol.it_interval.tv_usec = 2000000; | 405 timercontrol.it_interval.tv_usec = timer_usec; |
409 timercontrol.it_value.tv_sec = 0; | 406 timercontrol.it_value.tv_sec = 0; |
410 timercontrol.it_value.tv_usec = 2000000; | 407 timercontrol.it_value.tv_usec = timer_usec; |
411 if (timer) | 408 if (timer) |
412 setitimer(ITIMER_REAL, &timercontrol, NULL); | 409 setitimer(ITIMER_REAL, &timercontrol, NULL); |
413 } | 410 } |
414 | 411 |
415 void restore_term(void) { | 412 void restore_term(void) { |