Mercurial > hg > Members > kono > os9 > sbc09
comparison io.c @ 53:fe88cea67ef0
clock interrupt
get time
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 22 Jul 2018 17:55:06 +0900 |
parents | 51b437557f42 |
children | fc10b7ae23d0 |
comparison
equal
deleted
inserted
replaced
52:51b437557f42 | 53:fe88cea67ef0 |
---|---|
310 mem[(IOPAGE&0xfe00)+a]=c; | 310 mem[(IOPAGE&0xfe00)+a]=c; |
311 } else if (a==0x30+(IOPAGE&0x1ff) && c==0x04) { | 311 } else if (a==0x30+(IOPAGE&0x1ff) && c==0x04) { |
312 time_t tm = time(0); | 312 time_t tm = time(0); |
313 struct tm *t = localtime(&tm); | 313 struct tm *t = localtime(&tm); |
314 mem[IOPAGE+0x31] = t->tm_year; | 314 mem[IOPAGE+0x31] = t->tm_year; |
315 mem[IOPAGE+0x32] = t->tm_mon; | 315 mem[IOPAGE+0x32] = t->tm_mon+1; |
316 mem[IOPAGE+0x33] = t->tm_mday; | 316 mem[IOPAGE+0x33] = t->tm_mday; |
317 mem[IOPAGE+0x34] = t->tm_hour; | 317 mem[IOPAGE+0x34] = t->tm_hour; |
318 mem[IOPAGE+0x35] = t->tm_min; | 318 mem[IOPAGE+0x35] = t->tm_min; |
319 mem[IOPAGE+0x36] = t->tm_sec; | 319 mem[IOPAGE+0x36] = t->tm_sec; |
320 } else { | 320 } else { |
367 #endif | 367 #endif |
368 } | 368 } |
369 | 369 |
370 void timehandler(int sig) { | 370 void timehandler(int sig) { |
371 attention = 1; | 371 attention = 1; |
372 #ifdef USE_MMU | |
373 irq = 1; | |
374 #else | |
372 irq = 2; | 375 irq = 2; |
373 mem[(IOPAGE&0xfe00)+0x30] |= 0x10 ; | 376 #endif |
377 mem[IOPAGE+0x30] |= 0x10 ; | |
374 // signal(SIGALRM, timehandler); | 378 // signal(SIGALRM, timehandler); |
375 } | 379 } |
376 | 380 |
377 void handler(int sig) { | 381 void handler(int sig) { |
378 escape = 1; | 382 escape = 1; |
399 newterm.c_cc[VINTR] = escchar; | 403 newterm.c_cc[VINTR] = escchar; |
400 tcsetattr(0, TCSAFLUSH, &newterm); | 404 tcsetattr(0, TCSAFLUSH, &newterm); |
401 fcntl(0, F_SETFL, tflags | O_NDELAY); /* Make input from stdin non-blocking */ | 405 fcntl(0, F_SETFL, tflags | O_NDELAY); /* Make input from stdin non-blocking */ |
402 signal(SIGALRM, timehandler); | 406 signal(SIGALRM, timehandler); |
403 timercontrol.it_interval.tv_sec = 0; | 407 timercontrol.it_interval.tv_sec = 0; |
404 timercontrol.it_interval.tv_usec = 20000; | 408 timercontrol.it_interval.tv_usec = 200000; |
405 timercontrol.it_value.tv_sec = 0; | 409 timercontrol.it_value.tv_sec = 0; |
406 timercontrol.it_value.tv_usec = 20000; | 410 timercontrol.it_value.tv_usec = 200000; |
407 if (timer) | 411 if (timer) |
408 setitimer(ITIMER_REAL, &timercontrol, NULL); | 412 setitimer(ITIMER_REAL, &timercontrol, NULL); |
409 } | 413 } |
410 | 414 |
411 void restore_term(void) { | 415 void restore_term(void) { |