1
0
mirror of https://github.com/wfjm/w11.git synced 2026-04-15 01:13:44 +00:00

asm-11 BUGFIX; add ip_delete_tap; update 211bsd_eth.tcl

- tools
  - bin/asm-11: BUGFIX: fix directly nested .if behavior
  - bin/ip_delete_tap: added
  - asm-11/tests: add zbug_0007.mac, test_0460_if_nest.mac
  - oskit/test/os/211bsd/211bsd_eth.tcl: use 'ip' command
This commit is contained in:
wfjm
2023-02-16 12:29:45 +01:00
parent 95bc9be957
commit 6b7c25a961
18 changed files with 320 additions and 62 deletions

View File

@@ -36,7 +36,10 @@ The full set of tests is only run for tagged releases.
- tools/bin
- ip_inspect, ip_create_br: removed
- ip_create_tap: rewritten with 'ip' commands
- ip_delete_tap: added
### Bug Fixes
- tools/bin/asm-11:
- BUGFIX: fix directly nested .if behavior
<!-- --------------------------------------------------------------------- -->
---

View File

@@ -1,4 +1,4 @@
; $Id: test_0350_macro_concat.mac 1359 2023-01-27 20:58:50Z mueller $
; $Id: test_0350_macro_concat.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
@@ -8,8 +8,7 @@
. = 1000
; list macro expansion
.list me
.list cnd
.list me,cnd
;
; define and use macro with a concatinated label
; check label creation with .if df

View File

@@ -1,4 +1,4 @@
; $Id: test_0360_macro_mexit.mac 1359 2023-01-27 20:58:50Z mueller $
; $Id: test_0360_macro_mexit.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
@@ -8,8 +8,7 @@
. = 1000
; list macro expansion
.list me
.list cnd
.list me,cnd
;
; nested macro calls, ensure that .mexit individually
.macro mtop,src

View File

@@ -1,4 +1,4 @@
; $Id: test_0430_if_idn.mac 1359 2023-01-27 20:58:50Z mueller $
; $Id: test_0430_if_idn.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
@@ -7,8 +7,7 @@
.asect
. = 1000
;
.list me
.list cnd
.list me,cnd
;
; Note: if idn/dif seems to be broken in RT-11 MACRO-11
;

View File

@@ -1,4 +1,4 @@
; $Id: test_0450_if_macro.mac 1359 2023-01-27 20:58:50Z mueller $
; $Id: test_0450_if_macro.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
@@ -7,9 +7,8 @@
.asect
. = 1000
; list macro expansion
.list me
.list cnd
; list macro and conditional expansion
.list me,cnd
;
.macro movclr,dst,src
.if b,dst

View File

@@ -0,0 +1,77 @@
; $Id: test_0460_if_nest.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
; test nested .if
;
.asect
. = 1000
; list macro expansion
.list me,cnd
;
.macro testif,p0,p1,p2
maskt = 0
maskf = 0
.if ne,p0 ; p0=1
maskt = maskt + 000100
.if ne,p1 ; p0=1,p1=1
maskt = maskt + 000010
.if ne,p2 ; p0=1,p1=1,p2=1
maskt = maskt + 000001
.iff ; p0=1,p1=1,p2=0
maskf = maskf + 000001
.endc
.iff ; p0=1,p1=0
maskf = maskf + 000010
.if ne,p2 ; p0=1,p1=0,p2=1
maskt = maskt + 000001
.iff ; p0=1,p1=0,p2=0
maskf = maskf + 000001
.endc
.endc
.iff ; p0=0
maskf = maskf + 000100
.if ne,p1 ; p0=0,p1=1
maskt = maskt + 000010
.if ne,p2 ; p0=0,p1=1,p2=1
maskt = maskt + 000001
.iff ; p0=0,p1=1,p2=0
maskf = maskf + 000001
.endc ; p0=0,p1=0
.iff
maskf = maskf + 000010
.if ne,p2 ; p0=0,p1=0,p2=1
maskt = maskt + 000001
.iff ; p0=0,p1=0,p2=0
maskf = maskf + 000001
.endc
.endc
.endc
.endm
;
testif 0,0,0
.word maskt,maskf ;;!! 000000 000111
;
testif 0,0,1
.word maskt,maskf ;;!! 000001 000110
;
testif 0,1,0
.word maskt,maskf ;;!! 000010 000101
;
testif 0,1,1
.word maskt,maskf ;;!! 000011 000100
;
testif 1,0,0
.word maskt,maskf ;;!! 000100 000011
;
testif 1,0,1
.word maskt,maskf ;;!! 000101 000010
;
testif 1,1,0
.word maskt,maskf ;;!! 000110 000001
;
testif 1,1,1
.word maskt,maskf ;;!! 000111 000000
;
.end

View File

@@ -1,4 +1,4 @@
; $Id: test_0510_rept_mexit.mac 1359 2023-01-27 20:58:50Z mueller $
; $Id: test_0510_rept_mexit.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
@@ -8,8 +8,7 @@
. = 1000
; list macro expansion
.list me
.list cnd
.list me,cnd
;
; single .rept with an .mexit abort
a = 1020 ; write limit

View File

@@ -1,4 +1,4 @@
; $Id: test_0600_mcall.mac 1359 2023-01-27 20:58:50Z mueller $
; $Id: test_0600_mcall.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
@@ -10,8 +10,7 @@
.if df,...top ; asm-11 only
; list macro expansion
.list me
.list cnd
.list me,cnd
;
.mcall push,pop
;

View File

@@ -0,0 +1,37 @@
; $Id: zbug_0007.mac 1373 2023-02-16 11:21:26Z mueller $
; SPDX-License-Identifier: GPL-3.0-or-later
; Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
;
; for asm-11 prior rev 1372
;
; ISSUE: faulty handling of directly nested .if blocks
;
; REASON: error in drop code, didnt handle .if in a dropped .if section correctly
;
.asect
. = 1000
.list me,cnd
;
.macro call5,func,args,lbl
jsr r5,func
.if nb,args ; aaa
.if nb,lbl ; lll
lbl: .word args
.iff
.word args
.endc
.endc
.endm
;
call5 f1
call5 f2,<p1>
call5 f3,<p1,p2>,a2
;
f1: rts r5
f2: rts r5
f3: rts r5
;
p1: .word 0
p2: .word 0
;
.end

View File

@@ -1,10 +1,11 @@
#!/usr/bin/perl -w
# $Id: asm-11 1361 2023-01-30 07:48:17Z mueller $
# $Id: asm-11 1373 2023-02-16 11:21:26Z mueller $
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2013-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# Revision History:
# Date Rev Version Comment
# 2023-02-16 1373 1.2.7 BUGFIX: fix directly nested .if behavior
# 2023-01-30 1361 1.2.6 use 'R' error code; fix 'S' logic
# 2023-01-29 1360 1.2.5 BUFGIX: expressions: allow uop after bop operator;
# proper sign handling for '/','*' and .if ge,gt,le,lt
@@ -312,7 +313,7 @@ my $mautolbl = 30000; # auto-generated label
my @reptstk; # active .rept stack
my $reptlvl = 0; # .rept definition depth
# conditional assembly stack
my @ifstk; # if stack {tst=>0|1, cur=>0|1}
my @ifstk; # if stack {tst=>0|1,cur=>0|1,dif=>n}
my $ifcond; # current if condition
# .end handlinh
my $end = 0;
@@ -675,10 +676,16 @@ sub parse_line {
if (scalar(@ifstk)) { # is .if conditional block active ?
add_flag(\%l,'c'); # flag conditional block
unless ($dnam =~ m/^\.(iff|ift|iftf|endc)$/) { # and not sub-cond or end
unless ($ifstk[-1]{cur}) { # if (sub-)cond false
add_flag(\%l,'d'); # flag condition drop
return \%l; # ignore line
unless ($ifstk[-1]{cur}) { # if (sub-)cond false
$ifstk[-1]{dif} += 1 if $dnam eq '.if'; # nested .if in dropped code
if ($ifstk[-1]{dif} > 0) {
$ifstk[-1]{dif} -= 1 if $dnam eq '.endc'; # nested .endc in dropped code
add_flag(\%l,'d'); # flag condition drop
return \%l; # ignore line
}
unless ($dnam =~ m/^\.(iff|ift|iftf|endc)$/) { # and not sub-cond or end
add_flag(\%l,'d'); # flag condition drop
return \%l; # ignore line
}
}
}
@@ -923,7 +930,7 @@ sub parse_line {
add_err(\%l, 'A');
}
add_flag(\%l,'c'); # flag conditional block
push @ifstk, {tst => $tst, cur => $tst};
push @ifstk, {tst => $tst, cur => $tst, dif => 0};
$state = 'end';
} elsif ($op =~ m/^\.if(t|f|tf)$/) { # .if(f|t|tf) ----------
@@ -932,7 +939,7 @@ sub parse_line {
last STATE;
}
my $tst = $ifstk[-1]{tst}; # test value
my $cur = $tst; # for .itf
my $cur = $tst; # for .ift
$cur = $tst ? 0 : 1 if $op eq '.iff';
$cur = 1 if $op eq '.iftf';
$ifstk[-1]{cur} = $cur;
@@ -1312,6 +1319,7 @@ sub parse_line {
}
$op_cmod = 0;
} else {
$op_creg = 0;
add_err(\%l, 'R');
}
$state = 'op_end';
@@ -1656,7 +1664,7 @@ sub parse_line {
} else {
add_err(\%l, 'A');
}
push @ifstk, {tst => $tst, cur => $tst};
push @ifstk, {tst => $tst, cur => $tst, dif => 0};
} elsif ($d_dire eq '.rept') { # .rept ------------------
my $cnt;
@@ -1822,7 +1830,7 @@ sub add_err {
sub add_flag {
my ($rl,$flag) = @_;
next if index($$rl{flag}, $flag) >= 0; # prevent multiple flags
return if index($$rl{flag}, $flag) >= 0; # prevent multiple flags
$$rl{flag} .= $flag; # set flag
return;
}
@@ -3129,8 +3137,9 @@ sub dump_rl {
prt_err($rl), (join '', sort split '', $$rl{flag}),
savestr($$rl{typ}), savestr($$rl{oper}), $$rl{lineno},
$$rl{psect}, $$rl{dot};
printf " MRmri=%d %d %d %d %d\n",
$mdeflvl, $reptlvl, scalar(@mexecstk), scalar(@reptstk), scalar(@ifstk);
printf " MRmrid=%d %d %d %d %d %d\n",
$mdeflvl, $reptlvl, scalar(@mexecstk), scalar(@reptstk), scalar(@ifstk),
(scalar(@ifstk) ? $ifstk[-1]{dif} : 0);
my $i = 0;
foreach my $rt (@{$$rl{tl}}) {
printf " tl[%2d]: tag=%-4s, typ=%-2s, om=%-2s, em=%-2s, val='%s'",

View File

@@ -1,50 +1,68 @@
#!/bin/bash
# $Id: ip_create_tap 1172 2019-06-29 07:27:24Z mueller $
# $Id: ip_create_tap 1373 2023-02-16 11:21:26Z mueller $
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2017-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
# Copyright 2017-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# Revision History:
# Date Rev Version Comment
# 2023-02-16 1373 1.1 add -dry option, use 'ip' commands
# 2017-04-14 873 1.0 Initial version
# 2017-03-04 858 0.5 First draft
#
tap=${1:-tap0}
# handle options
optdry=""
while (( $# > 0 )) ; do
case $1 in
-dry|--dry) optdry=$1 ; shift 1 ;;
-*) echo "ip_create_br-E: invalid option '$1'"; exit 1 ;;
*) break;;
esac
done
if ifconfig | grep -q "${tap}\s*Link"
then
echo "tap ${tap} already exists"
exit 1
prefdry=""
if [[ -n "$optdry" ]] ; then
prefdry="echo"
fi
ifconfig | grep -q "br0\s*Link"
tap=${1:-tap0}
br=${2:-br0}
ip link show ${tap} >/dev/null 2>&1
if [ $? == 0 ]
then
echo "ip_create_tap-I: tap ${tap} already exists"
exit 0
fi
ip link show ${br} >/dev/null 2>&1
if [ $? != 0 ]
then
echo "ip_create_tap-I: create bridge br0"
ip_create_br
echo "ip_create_tap-E: bridge ${br} does not exist"
exit 1
fi
# sanitize PATH, use what sudo has
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
which_ifconfig=$(which ifconfig)
which_tunctl=$(which tunctl)
which_ip=$(which ip)
which_brctl=$(which brctl)
if [[ -z "$which_ifconfig" || -z "$which_tunctl" || -z "$which_brctl" ]]
if [[ -z "$which_ip" ]]
then
echo "ip_create_br-E: ifconfig, brctl, or route not in PATH"
echo "ip_create_br-E: ip command not in PATH"
exit 1
fi
# print info so that sudo password prompt is expected
if [[ $(id -u) -ne 0 ]] ; then echo "ip_create_br-I: requires sudo" ; fi
# print info that sudo password prompt is expected
if [[ $(id -u) -ne 0 ]] ; then echo "ip_create_br-I: uses sudo" ; fi
sudo $which_tunctl -t ${tap} -u $USER
sudo $which_ifconfig ${tap} up
# bridge in the tap device
sudo $which_brctl addif br0 ${tap}
sudo $which_ifconfig ${tap} 0.0.0.0
$prefdry sudo ip tuntap add ${tap} mode tap user $USER
$prefdry sudo ip link set ${tap} up
$prefdry sudo ip link set ${tap} master ${br}
#
$which_ifconfig ${tap}
if [[ -n "$which_brctl" ]]
then
$prefdry $which_brctl show ${br}
fi

56
tools/bin/ip_delete_tap Executable file
View File

@@ -0,0 +1,56 @@
#!/bin/bash
# $Id: ip_delete_tap 1373 2023-02-16 11:21:26Z mueller $
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# Revision History:
# Date Rev Version Comment
# 2023-02-16 1373 1.0 Initial version
#
# handle options
optdry=""
while (( $# > 0 )) ; do
case $1 in
-dry|--dry) optdry=$1 ; shift 1 ;;
-*) echo "ip_delete_br-E: invalid option '$1'"; exit 1 ;;
*) break;;
esac
done
prefdry=""
if [[ -n "$optdry" ]] ; then
prefdry="echo"
fi
tap=${1:-tap0}
ip link show ${tap} >/dev/null 2>&1
if [ $? != 0 ]
then
echo "ip_delete_tap-I: tap ${tap} doesn't exist"
exit 0
fi
# sanitize PATH, use what sudo has
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
which_ip=$(which ip)
which_brctl=$(which brctl)
if [[ -z "$which_ip" ]]
then
echo "ip_delete_br-E: ip command not in PATH"
exit 1
fi
# print info that sudo password prompt is expected
if [[ $(id -u) -ne 0 ]] ; then echo "ip_delete_br-I: uses sudo" ; fi
$prefdry sudo ip tuntap delete ${tap} mode tap
#
if [[ -n "$which_brctl" ]]
then
$prefdry $which_brctl show ${br}
fi

View File

@@ -1,11 +1,11 @@
.\" -*- nroff -*-
.\" $Id: ip_create_tap.1 1372 2023-02-12 17:18:38Z mueller $
.\" $Id: ip_create_tap.1 1373 2023-02-16 11:21:26Z mueller $
.\" SPDX-License-Identifier: GPL-3.0-or-later
.\" Copyright 2017-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\"
.\" ------------------------------------------------------------------
.
.TH IP_CREATE_TAP 1 2023-02-12 "Retro Project" "Retro Project Manual"
.TH IP_CREATE_TAP 1 2023-02-16 "Retro Project" "Retro Project Manual"
.\" ------------------------------------------------------------------
.SH NAME
ip_create_tap \- add a user-mode tap device to a bridge
@@ -36,6 +36,11 @@ printed and not executed.
The script should be run as a normal user. It uses \fBsudo\fR(8) to
execute privileged commands, and might therefore ask for the user password.
.\" ------------------------------------------------------------------
.SH "SEE ALSO"
.BR ip_delete_tap (1)
.\" ------------------------------------------------------------------
.SH AUTHOR
Walter F.J. Mueller <W.F.J.Mueller@gsi.de>

View File

@@ -0,0 +1,38 @@
.\" -*- nroff -*-
.\" $Id: ip_delete_tap.1 1373 2023-02-16 11:21:26Z mueller $
.\" SPDX-License-Identifier: GPL-3.0-or-later
.\" Copyright 2023- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
.\"
.\" ------------------------------------------------------------------
.
.TH IP_DELETE_TAP 1 2023-02-12 "Retro Project" "Retro Project Manual"
.\" ------------------------------------------------------------------
.SH NAME
ip_delete_tap \- remove a user-mode tap device
.\" ------------------------------------------------------------------
.SH SYNOPSIS
.
.SY ip_delete_tap
.OP \-dry
.RI [ TAPNAME ]
.YS
.
.\" ------------------------------------------------------------------
.SH DESCRIPTION
This script removes a tap device, named \fITAPNAME\fP or 'tap0' by default.
If the \fB\-dry\fP option is specified, the generated commands are only
printed and not executed.
The script should be run as a normal user. It uses \fBsudo\fR(8) to
execute privileged commands, and might therefore ask for the user password.
.\" ------------------------------------------------------------------
.SH "SEE ALSO"
.BR ip_create_tap (1)
.\" ------------------------------------------------------------------
.SH AUTHOR
Walter F.J. Mueller <W.F.J.Mueller@gsi.de>

View File

@@ -2,3 +2,4 @@
*hook.tcl
*license.txt
*license.pdf
*.pcap

View File

@@ -0,0 +1,19 @@
This directory contains **`ti_w11` startup hook files** and contains
| File | Comments |
| ---- | -------- |
| [hook_disk_over.tcl](hook_disk_over.tcl) | set default diskscheme to over |
| [hook_dmscnt.tcl](hook_dmscnt.tcl) | start dmscnt |
| [hook_ibmon_dza.tcl](hook_ibmon_dza.tcl) | start ibmon for dza |
| [hook_ibmon_lpa.tcl](hook_ibmon_lpa.tcl) | start ibmon for lpa |
| [hook_ibmon_pca.tcl](hook_ibmon_pca.tcl) | start ibmon for pca |
| [hook_ibmon_rka.tcl](hook_ibmon_rka.tcl) | start ibmon for rka |
| [hook_ibmon_rpa.tcl](hook_ibmon_rpa.tcl) | start ibmon for rpa |
| [hook_ibmon_tma.tcl](hook_ibmon_tma.tcl) | start ibmon for tma |
| [hook_ibmon_tta.tcl](hook_ibmon_tta.tcl) | start ibmon for tta |
| [hook_ibmon_xua.tcl](hook_ibmon_xua.tcl) | start ibmon for xua |
| [hook_trace_blkdev.tcl](hook_trace_blkdev.tcl) | trace all block devices to rlc.log |
| [hook_trace_dza.tcl](hook_trace_dza.tcl) | trace dza to rlc.log |
| [hook_trace_lpa.tcl](hook_trace_lpa.tcl) | trace lpa to rlc.log |
| [hook_trace_xua.tcl](hook_trace_xua.tcl) | trace xua to rlc.log |

View File

@@ -1,9 +1,10 @@
# $Id: 211bsd_eth.tcl 1196 2019-07-20 18:18:16Z mueller $
# $Id: 211bsd_eth.tcl 1373 2023-02-16 11:21:26Z mueller $
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2019- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
# Copyright 2019-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
#
# Revision History:
# Date Rev Version Comment
# 2023-02-14 1373 1.1.1 use 'ip -j -p a' to probe tap0 existence
# 2019-07-20 1196 1.1 Use os namespace 211bsd
# 2019-06-29 1173 1.0 Initial version
# 2019-06-10 1163 0.1 First draft
@@ -19,10 +20,10 @@ namespace eval 211bsd {
#
lappend ::tenv(procs_preboot) "211bsd::eth_preboot"
proc eth_preboot {} {
et_spawn "if_tst" ifconfig
et_spawn "if_tst" "ip" "-j" "-p" "a"
set rc 1
expect {
-re "tap0 +Link" { set rc 0; exp_continue}
-re {"ifname": "tap0"} { set rc 0; exp_continue}
eof { }
}
et_close "if_tst"

View File

@@ -1,6 +1,6 @@
// $Id: Rw11CntlDEUNA.cpp 1186 2019-07-12 17:49:59Z mueller $
// $Id: Rw11CntlDEUNA.cpp 1373 2023-02-16 11:21:26Z mueller $
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright 2014-2019 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2014-2023 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
//
// Revision History:
// Date Rev Version Comment
@@ -551,7 +551,7 @@ bool Rw11CntlDEUNA::RcvCallback(RethBuf::pbuf_t& pbuf)
}
return true;
}
} else { // machted
} else { // matched
if (matchdst == 0) {
fStats.Inc(kStatNRxFraFDst);
} else if (matchdst == 1) {