ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/vt102/vt102
(Generate patch)

Comparing vt102/vt102 (file contents):
Revision 1.20 by root, Wed Dec 3 08:17:16 2014 UTC vs.
Revision 1.21 by root, Wed Dec 3 08:57:58 2014 UTC

690my $slave = $PTY->slave; 690my $slave = $PTY->slave;
691 691
692$PTY->set_winsize (24, 80); 692$PTY->set_winsize (24, 80);
693 693
694unless (fork) { 694unless (fork) {
695 $ENV{LC_ALL} = "C";
695 $ENV{TERM} = $VT102 ? "vt102" : "vt100"; 696 $ENV{TERM} = $VT102 ? "vt102" : "vt100";
696 697
697 close $PTY; 698 close $PTY;
698 699
699 open STDIN , "<&", $slave; 700 open STDIN , "<&", $slave;
713 714
714############################################################################# 715#############################################################################
715# the actual hardware simulator 716# the actual hardware simulator
716 717
717my @ICACHE; # compiled instruction cache 718my @ICACHE; # compiled instruction cache
719
720my $POWERSAVE; # powersave counter
721
722my $RIN; # libev for the less well-off
723
724(vec $RIN, 0, 1) = 1 if $KBD;
725(vec $RIN, fileno $PTY, 1) = 1 if $PTY;
718 726
719while () { 727while () {
720 # execute extended basic blocks 728 # execute extended basic blocks
721 $PC = ($ICACHE[$PC] ||= do { 729 $PC = ($ICACHE[$PC] ||= do {
722 my $pc = $PC; 730 my $pc = $PC;
758 # things we do from time to time only 766 # things we do from time to time only
759 unless ($CLK & 0xf) { 767 unless ($CLK & 0xf) {
760 # do I/O 768 # do I/O
761 769
762 unless ($CLK & 0xfff) { 770 unless ($CLK & 0xfff) {
763 771 if (select $x = $RIN, undef, undef, $POWERSAVE < 100 ? 0 : 0.2) {
764 # pty/serial I/O 772 # pty/serial I/O
765 unless ((@PUSARTRECV >= 128) || @KQUEUE || !$PTY) { 773 if ($PTY && (vec $x, fileno $PTY, 1) && (@PUSARTRECV < 128) && !@KQUEUE) {
766 my $rin = ""; (vec $rin, fileno $PTY, 1) = 1; 774 my $rin = ""; (vec $rin, fileno $PTY, 1) = 1;
767 775
768 if (select $rin, undef, undef, 0) { 776 if (select $rin, undef, undef, 0) {
769 sysread $PTY, my $buf, 256; 777 sysread $PTY, my $buf, 256;
770 778
771 # linux don't do cs7 and/or parity anymore, so we need to filter 779 # linux don't do cs7 and/or parity anymore, so we need to filter
772 # out xoff characters to avoid freezes. 780 # out xoff characters to avoid freezes.
773 push @PUSARTRECV, grep { ($_ & 0x7f) != 0x13 } unpack "C*", $buf; 781 push @PUSARTRECV, grep { ($_ & 0x7f) != 0x13 } unpack "C*", $buf;
782 }
774 } 783 }
775 }
776 784
777 # keyboard input 785 # keyboard input
778 if ($KBD) { 786 if ($KBD && (vec $x, 0, 1)) {
779 while (select my $rin = "\x01", undef, undef, 0) { 787 while (select my $rin = "\x01", undef, undef, 0) {
780 sysread STDIN, $STDIN_BUF, 1, length $STDIN_BUF 788 sysread STDIN, $STDIN_BUF, 1, length $STDIN_BUF
781 or last; 789 or last;
790 }
791
792 stdin_parse if length $STDIN_BUF;
793 $POWERSAVE = 0;
782 } 794 }
783 795
784 stdin_parse if length $STDIN_BUF; 796 $POWERSAVE = 0;
797 } else {
798 ++$POWERSAVE;
785 } 799 }
786 } 800 }
787 801
788 # kick off various interrupts 802 # kick off various interrupts
789 803

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines