Compare commits
108 Commits
mz-startup
...
uflash
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
163dcbd961 | ||
|
|
7e4b86d135 | ||
|
|
9bbe938e48 | ||
|
|
d5c97a9b19 | ||
|
|
0005e7d7bf | ||
|
|
42665ba3b3 | ||
|
|
942bdda5ed | ||
|
|
5ce8a8cd33 | ||
|
|
b3442f28f3 | ||
|
|
29c75b3f71 | ||
|
|
9b9f6392dc | ||
|
|
f5bbefc222 | ||
|
|
7f5ad5d3f8 | ||
|
|
df8f8eaf71 | ||
|
|
f62f70c718 | ||
|
|
1916f8c9da | ||
|
|
d8269d1996 | ||
|
|
8e228dde62 | ||
|
|
bae12383a0 | ||
|
|
8e2c046406 | ||
|
|
dad5247184 | ||
|
|
b1f67fbca0 | ||
|
|
f76ab8417c | ||
|
|
3bb914c8b4 | ||
|
|
8b099bcf76 | ||
|
|
2fc41d34cf | ||
|
|
2301571ecb | ||
|
|
00269e9387 | ||
|
|
687695d0db | ||
|
|
0aa5e1c462 | ||
|
|
3a7cde7974 | ||
|
|
f57cc446b0 | ||
|
|
1a55933faf | ||
|
|
b18ce0aa87 | ||
|
|
5bbf8d4e73 | ||
|
|
7aa774702b | ||
|
|
64430a0f91 | ||
|
|
d5e30d7b79 | ||
|
|
a8d9b3d01f | ||
|
|
ebd35d772f | ||
|
|
c4da2137e1 | ||
|
|
c42133cdff | ||
|
|
dc66e6fdda | ||
|
|
f58c7a7426 | ||
|
|
5c4309942a | ||
|
|
e557c88b1e | ||
|
|
850797db2e | ||
|
|
cae7db41ca | ||
|
|
808dfaf6ef | ||
|
|
d3d48970e3 | ||
|
|
93d95abc69 | ||
|
|
c5ac22d17f | ||
|
|
e7b77dadc3 | ||
|
|
2ea9e02ba5 | ||
|
|
d9d91365c0 | ||
|
|
2da083e9bd | ||
|
|
e4e9ff1ef4 | ||
|
|
aecac2f5d7 | ||
|
|
8886a00340 | ||
|
|
25bcc79a69 | ||
|
|
8d55f87ab8 | ||
|
|
9adca14b87 | ||
|
|
83a999be0a | ||
|
|
1462eeb400 | ||
|
|
d42bfdc7b9 | ||
|
|
1cdf42ef94 | ||
|
|
8f4aad27f9 | ||
|
|
cb4ca7f73a | ||
|
|
b44cab756f | ||
|
|
c2b3647d5e | ||
|
|
4d8233582a | ||
|
|
eb1fb36b6b | ||
|
|
2293493bfd | ||
|
|
61ce169328 | ||
|
|
173efb822d | ||
|
|
21babaf947 | ||
|
|
3a789348da | ||
|
|
d6e558bea0 | ||
|
|
847e2bff77 | ||
|
|
08c79d7fec | ||
|
|
0cef044377 | ||
|
|
61c7c690b9 | ||
|
|
294ccae3be | ||
|
|
1c4e562363 | ||
|
|
09b50bf614 | ||
|
|
8439672624 | ||
|
|
b6e105c87b | ||
|
|
70b8d93b21 | ||
|
|
5fa78e772b | ||
|
|
7b1bf93d3a | ||
|
|
04208ea903 | ||
|
|
e003436e91 | ||
|
|
29904aacd7 | ||
|
|
dbe51ae294 | ||
|
|
87489937bf | ||
|
|
bbba8d6f95 | ||
|
|
b3abe580bd | ||
|
|
66ffc30ccd | ||
|
|
0b31486402 | ||
|
|
5bd8f3a470 | ||
|
|
fa46b819f0 | ||
|
|
91468f005f | ||
|
|
e2cb851fbf | ||
|
|
e725ab2b44 | ||
|
|
8423492f33 | ||
|
|
8e8fc70ed5 | ||
|
|
d8305bc374 | ||
|
|
3942e87cd1 |
27
LICENSE
27
LICENSE
@@ -1,27 +0,0 @@
|
|||||||
Copyright (c) 2014, RetroBSD
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the {organization} nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
226
Makefile
226
Makefile
@@ -11,33 +11,23 @@
|
|||||||
#
|
#
|
||||||
# Supported boards
|
# Supported boards
|
||||||
#
|
#
|
||||||
MAX32 = sys/pic32/max32/MAX32
|
MAX32 = pic32/max32
|
||||||
MAX32-ETH = sys/pic32/max32-eth/MAX32-ETH
|
UBW32 = pic32/ubw32
|
||||||
UBW32 = sys/pic32/ubw32/UBW32
|
UBW32UART = pic32/ubw32-uart
|
||||||
UBW32UART = sys/pic32/ubw32-uart/UBW32-UART
|
MAXIMITE = pic32/maximite
|
||||||
UBW32UARTSDRAM = sys/pic32/ubw32-uart-sdram/UBW32-UART-SDRAM
|
EXPLORER16 = pic32/explorer16
|
||||||
MAXIMITE = sys/pic32/maximite/MAXIMITE
|
STARTERKIT = pic32/starter-kit
|
||||||
MAXCOLOR = sys/pic32/maximite-color/MAXCOLOR
|
DUINOMITE = pic32/duinomite
|
||||||
EXPLORER16 = sys/pic32/explorer16/EXPLORER16
|
PINGUINO = pic32/pinguino-micro
|
||||||
STARTERKIT = sys/pic32/starter-kit/STARTER-KIT
|
DIP = pic32/dip
|
||||||
DUINOMITE = sys/pic32/duinomite/DUINOMITE
|
BAREMETAL = pic32/baremetal
|
||||||
DUINOMITEUART = sys/pic32/duinomite-uart/DUINOMITE-UART
|
RETROONE = pic32/retroone
|
||||||
DUINOMITEE = sys/pic32/duinomite-e/DUINOMITE-E
|
|
||||||
DUINOMITEEUART = sys/pic32/duinomite-e-uart/DUINOMITE-E-UART
|
|
||||||
PINGUINO = sys/pic32/pinguino-micro/PINGUINO-MICRO
|
|
||||||
DIP = sys/pic32/dip/DIP
|
|
||||||
BAREMETAL = sys/pic32/baremetal/BAREMETAL
|
|
||||||
RETROONE = sys/pic32/retroone/RETROONE
|
|
||||||
FUBARINO = sys/pic32/fubarino/FUBARINO
|
|
||||||
FUBARINOBIG = sys/pic32/fubarino/FUBARINO-UART2CONS-UART1-SRAMC
|
|
||||||
MMBMX7 = sys/pic32/mmb-mx7/MMB-MX7
|
|
||||||
|
|
||||||
# Select target board
|
# Select target board
|
||||||
TARGET ?= $(MAX32)
|
TARGET ?= $(MAX32)
|
||||||
|
|
||||||
# Filesystem and swap sizes.
|
# Filesystem and swap sizes.
|
||||||
FS_KBYTES = 102400
|
FS_KBYTES = 16384
|
||||||
U_KBYTES = 102400
|
|
||||||
SWAP_KBYTES = 2048
|
SWAP_KBYTES = 2048
|
||||||
|
|
||||||
# Set this to the device name for your SD card. With this
|
# Set this to the device name for your SD card. With this
|
||||||
@@ -54,153 +44,141 @@ DEFS =
|
|||||||
|
|
||||||
FSUTIL = tools/fsutil/fsutil
|
FSUTIL = tools/fsutil/fsutil
|
||||||
|
|
||||||
-include Makefile.user
|
|
||||||
|
|
||||||
TARGETDIR = $(shell dirname $(TARGET))
|
|
||||||
TARGETNAME = $(shell basename $(TARGET))
|
|
||||||
TOPSRC = $(shell pwd)
|
|
||||||
CONFIG = $(TOPSRC)/tools/configsys/config
|
|
||||||
#
|
#
|
||||||
# Filesystem contents.
|
# Filesystem contents.
|
||||||
#
|
#
|
||||||
BIN_FILES := $(wildcard bin/*)
|
BIN_FILES := $(wildcard bin/*)
|
||||||
SBIN_FILES := $(wildcard sbin/*)
|
SBIN_FILES := $(wildcard sbin/*)
|
||||||
|
UFLASH_FILES := $(wildcard uflash/*)
|
||||||
GAMES_FILES := $(shell find games -type f ! -path '*/.*')
|
GAMES_FILES := $(shell find games -type f ! -path '*/.*')
|
||||||
|
LIB_FILES := $(wildcard lib/*)
|
||||||
LIBEXEC_FILES := $(wildcard libexec/*)
|
LIBEXEC_FILES := $(wildcard libexec/*)
|
||||||
LIB_FILES := lib/crt0.o lib/retroImage $(wildcard lib/*.a)
|
|
||||||
ETC_FILES = etc/rc etc/rc.local etc/ttys etc/gettytab etc/group \
|
ETC_FILES = etc/rc etc/rc.local etc/ttys etc/gettytab etc/group \
|
||||||
etc/passwd etc/shadow etc/fstab etc/motd etc/shells \
|
etc/passwd etc/shadow etc/fstab etc/motd etc/shells \
|
||||||
etc/termcap etc/MAKEDEV etc/phones etc/remote
|
etc/termcap
|
||||||
INC_FILES = $(wildcard include/*.h) \
|
INC_FILES = include/stdio.h include/syscall.h include/sys/types.h \
|
||||||
$(wildcard include/sys/*.h) \
|
include/sys/select.h
|
||||||
$(wildcard include/machine/*.h) \
|
|
||||||
$(wildcard include/smallc/*.h) \
|
|
||||||
$(wildcard include/smallc/sys/*.h) \
|
|
||||||
$(wildcard include/arpa/*.h)
|
|
||||||
SHARE_FILES = share/re.help share/example/Makefile \
|
SHARE_FILES = share/re.help share/example/Makefile \
|
||||||
share/example/ashello.S share/example/chello.c \
|
share/example/ashello.S share/example/chello.c \
|
||||||
share/example/blkjack.bas share/example/hilow.bas \
|
share/example/blkjack.bas share/example/hilow.bas \
|
||||||
share/example/stars.bas share/example/prime.scm \
|
share/example/stars.bas share/example/prime.scm \
|
||||||
share/example/fact.fth share/example/echo.S \
|
share/example/fact.fth share/example/echo.S \
|
||||||
share/example/stdarg.c share/example/skeleton.c \
|
share/smallc/lib.c share/smallc/Makefile share/smallc/primelist.c \
|
||||||
$(wildcard share/smallc/*)
|
share/smallc/primesum.c share/smallc/sys.s share/smallc/test1.c \
|
||||||
MANFILES = share/man/ share/man/cat1/ share/man/cat2/ share/man/cat3/ \
|
share/smallc/test2.c $(wildcard share/lccom/*)
|
||||||
share/man/cat4/ share/man/cat5/ share/man/cat6/ share/man/cat7/ \
|
|
||||||
share/man/cat8/ $(wildcard share/man/cat?/*)
|
|
||||||
ALLFILES = $(SBIN_FILES) $(ETC_FILES) $(BIN_FILES) $(LIB_FILES) $(LIBEXEC_FILES) \
|
ALLFILES = $(SBIN_FILES) $(ETC_FILES) $(BIN_FILES) $(LIB_FILES) $(LIBEXEC_FILES) \
|
||||||
$(INC_FILES) $(SHARE_FILES) $(GAMES_FILES) \
|
$(INC_FILES) $(SHARE_FILES) $(GAMES_FILES) $(UFLASH_FILES) \
|
||||||
var/log/messages var/log/wtmp .profile
|
var/log/messages var/log/wtmp .profile
|
||||||
ALLDIRS = games/ sbin/ bin/ dev/ etc/ tmp/ lib/ libexec/ share/ include/ \
|
ALLDIRS = sbin/ bin/ dev/ etc/ tmp/ lib/ libexec/ share/ share/example/ \
|
||||||
var/ u/ share/example/ share/misc/ share/smallc/ \
|
share/lccom/ share/misc/ share/smallc/ var/ var/run/ var/log/ u/ include/ include/sys/ \
|
||||||
var/run/ var/log/ var/lock/ games/ games/lib/ include/sys/ \
|
games/ games/lib/ uflash/
|
||||||
include/machine/ include/arpa/ include/smallc/ \
|
BDEVS = dev/sd0!b0:0 dev/sd1!b0:1 dev/sw0!b1:0
|
||||||
include/smallc/sys/ share/misc/ share/smallc/ include/sys/ \
|
CDEVS = dev/console!c0:0 \
|
||||||
games/lib/
|
dev/mem!c1:0 dev/kmem!c1:1 dev/null!c1:2 dev/zero!c1:3 \
|
||||||
BDEVS = dev/rd0!b0:0 dev/rd0a!b0:1 dev/rd0b!b0:2 dev/rd0c!b0:3 dev/rd0d!b0:4
|
dev/tty!c2:0 \
|
||||||
BDEVS += dev/rd1!b1:0 dev/rd1a!b1:1 dev/rd1b!b1:2 dev/rd1c!b1:3 dev/rd1d!b1:4
|
dev/rsd0!c3:0 dev/rsd1!c3:1 dev/swap!c3:0 \
|
||||||
BDEVS += dev/rd2!b2:0 dev/rd2a!b2:1 dev/rd2b!b2:2 dev/rd2c!b2:3 dev/rd2d!b2:4
|
dev/klog!c4:0 \
|
||||||
BDEVS += dev/rd3!b3:0 dev/rd3a!b3:1 dev/rd3b!b3:2 dev/rd3c!b3:3 dev/rd3d!b3:4
|
dev/stdin!c5:0 dev/stdout!c5:1 dev/stderr!c5:2 \
|
||||||
BDEVS += dev/swap!b4:64 dev/swap0!b4:0 dev/swap1!b4:1 dev/swap2!b4:2
|
dev/rsw0!c6:0 \
|
||||||
|
dev/porta!c7:0 dev/portb!c7:1 dev/portc!c7:2 \
|
||||||
|
dev/portd!c7:3 dev/porte!c7:4 dev/portf!c7:5 dev/portg!c7:6 \
|
||||||
|
dev/confa!c7:64 dev/confb!c7:65 dev/confc!c7:66 \
|
||||||
|
dev/confd!c7:67 dev/confe!c7:68 dev/conff!c7:69 dev/confg!c7:70 \
|
||||||
|
dev/spi1!c9:0 dev/spi2!c9:1 dev/spi3!c9:2 dev/spi4!c9:3 \
|
||||||
|
dev/glcd0!c10:0 dev/uflash!c12:0
|
||||||
|
FDDEVS = dev/fd/ dev/fd/0!c5:0 dev/fd/1!c5:1 dev/fd/2!c5:2 \
|
||||||
|
dev/fd/3!c5:3 dev/fd/4!c5:4 dev/fd/5!c5:5 dev/fd/6!c5:6 \
|
||||||
|
dev/fd/7!c5:7 dev/fd/8!c5:8 dev/fd/9!c5:9 dev/fd/10!c5:10 \
|
||||||
|
dev/fd/11!c5:11 dev/fd/12!c5:12 dev/fd/13!c5:13 \
|
||||||
|
dev/fd/14!c5:14 dev/fd/15!c5:15 dev/fd/16!c5:16 \
|
||||||
|
dev/fd/17!c5:17 dev/fd/18!c5:18 dev/fd/19!c5:19 \
|
||||||
|
dev/fd/20!c5:20 dev/fd/21!c5:21 dev/fd/22!c5:22 \
|
||||||
|
dev/fd/23!c5:23 dev/fd/24!c5:24 dev/fd/25!c5:25 \
|
||||||
|
dev/fd/26!c5:26 dev/fd/27!c5:27 dev/fd/28!c5:28 \
|
||||||
|
dev/fd/29!c5:29
|
||||||
|
ADCDEVS = dev/adc0!c8:0 dev/adc1!c8:1 dev/adc2!c8:2 dev/adc3!c8:3 \
|
||||||
|
dev/adc4!c8:4 dev/adc5!c8:5 dev/adc6!c8:6 dev/adc7!c8:7 \
|
||||||
|
dev/adc8!c8:8 dev/adc9!c8:9 dev/adc10!c8:10 dev/adc11!c8:11 \
|
||||||
|
dev/adc12!c8:12 dev/adc13!c8:13 dev/adc14!c8:14 dev/adc15!c8:15
|
||||||
|
OCDEVS = dev/oc0!c11:0 dev/oc1!c11:1 dev/oc2!c11:2 dev/oc3!c11:3 dev/oc4!c11:4
|
||||||
|
|
||||||
D_CONSOLE = dev/console!c0:0
|
all: build kernel
|
||||||
D_MEM = dev/mem!c1:0 dev/kmem!c1:1 dev/null!c1:2 dev/zero!c1:3
|
|
||||||
D_TTY = dev/tty!c2:0
|
|
||||||
D_FD = dev/stdin!c3:0 dev/stdout!c3:1 dev/stderr!c3:2
|
|
||||||
D_TEMP = dev/temp0!c4:0 dev/temp1!c4:1 dev/temp2!c4:2
|
|
||||||
|
|
||||||
U_DIRS = $(addsuffix /,$(shell find u -type d ! -path '*/.svn*'))
|
|
||||||
U_FILES = $(shell find u -type f ! -path '*/.svn/*')
|
|
||||||
#U_ALL = $(patsubst u/%,%,$(U_DIRS) $(U_FILES))
|
|
||||||
|
|
||||||
CDEVS = $(D_CONSOLE) $(D_MEM) $(D_TTY) $(D_FD) $(D_TEMP)
|
|
||||||
|
|
||||||
all: tools build kernel
|
|
||||||
$(MAKE) fs
|
$(MAKE) fs
|
||||||
|
|
||||||
fs: sdcard.rd
|
fs: filesys.img user.img
|
||||||
|
|
||||||
.PHONY: tools
|
kernel:
|
||||||
tools:
|
$(MAKE) -C sys/$(TARGET)
|
||||||
|
|
||||||
|
build:
|
||||||
$(MAKE) -C tools
|
$(MAKE) -C tools
|
||||||
|
|
||||||
kernel: $(TARGETDIR)/Makefile
|
|
||||||
$(MAKE) -C $(TARGETDIR)
|
|
||||||
|
|
||||||
$(TARGETDIR)/Makefile: $(CONFIG) $(TARGETDIR)/$(TARGETNAME)
|
|
||||||
cd $(TARGETDIR) && ../../../tools/configsys/config $(TARGETNAME)
|
|
||||||
|
|
||||||
.PHONY: lib
|
|
||||||
lib:
|
|
||||||
$(MAKE) -C lib
|
|
||||||
|
|
||||||
build: tools lib
|
|
||||||
$(MAKE) -C src install
|
$(MAKE) -C src install
|
||||||
|
|
||||||
filesys.img: $(FSUTIL) $(ALLFILES)
|
filesys.img: $(FSUTIL) $(ALLFILES)
|
||||||
rm -f $@
|
rm -f $@
|
||||||
$(FSUTIL) -n$(FS_KBYTES) $@
|
$(FSUTIL) -n$(FS_KBYTES) -s$(SWAP_KBYTES) $@
|
||||||
$(FSUTIL) -a $@ $(ALLDIRS)
|
$(FSUTIL) -a $@ $(ALLDIRS) $(ALLFILES)
|
||||||
$(FSUTIL) -a $@ $(CDEVS)
|
$(FSUTIL) -a $@ $(CDEVS)
|
||||||
$(FSUTIL) -a $@ $(BDEVS)
|
$(FSUTIL) -a $@ $(BDEVS)
|
||||||
$(FSUTIL) -a $@ $(ALLFILES)
|
$(FSUTIL) -a $@ $(ADCDEVS)
|
||||||
$(FSUTIL) -a $@ $(MANFILES)
|
$(FSUTIL) -a $@ $(OCDEVS)
|
||||||
|
# $(FSUTIL) -a $@ $(FDDEVS)
|
||||||
swap.img:
|
|
||||||
dd if=/dev/zero of=$@ bs=1k count=$(SWAP_KBYTES)
|
|
||||||
|
|
||||||
user.img: $(FSUTIL)
|
user.img: $(FSUTIL)
|
||||||
ifneq ($(U_KBYTES), 0)
|
|
||||||
rm -f $@
|
rm -f $@
|
||||||
$(FSUTIL) -n$(U_KBYTES) $@
|
$(FSUTIL) -n$(FS_KBYTES) $@
|
||||||
(cd u; find . -type d -exec ../$(FSUTIL) -a ../$@ '{}/' \;)
|
|
||||||
(cd u; find . -type f -exec ../$(FSUTIL) -a ../$@ '{}' \+)
|
|
||||||
endif
|
|
||||||
|
|
||||||
sdcard.rd: filesys.img swap.img user.img
|
|
||||||
ifneq ($(U_KBYTES), 0)
|
|
||||||
tools/mkrd/mkrd -out $@ -boot filesys.img -swap swap.img -fs user.img
|
|
||||||
else
|
|
||||||
tools/mkrd/mkrd -out $@ -boot filesys.img -swap swap.img
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(FSUTIL):
|
$(FSUTIL):
|
||||||
cd tools/fsutil; $(MAKE)
|
cd tools/fsutil; $(MAKE)
|
||||||
|
|
||||||
$(CONFIG):
|
|
||||||
make -C tools/configsys
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~
|
rm -f *~
|
||||||
for dir in tools lib src sys/pic32; do $(MAKE) -C $$dir -k clean; done
|
for dir in tools src sys/pic32; do $(MAKE) -C $$dir -k clean; done
|
||||||
|
|
||||||
cleanall: clean
|
cleanall: clean
|
||||||
$(MAKE) -C lib clean
|
rm -f sys/pic32/*/unix.hex bin/* sbin/* lib/* games/[a-k]* games/[m-z]* libexec/* share/man/cat*/*
|
||||||
rm -f sys/pic32/*/unix.hex bin/* sbin/* games/[a-k]* games/[m-z]* libexec/* share/man/cat*/*
|
|
||||||
rm -f games/lib/adventure.dat
|
rm -f games/lib/adventure.dat
|
||||||
rm -f games/lib/cfscores
|
rm -f games/lib/cfscores
|
||||||
rm -f share/re.help
|
rm -f share/re.help
|
||||||
rm -f share/misc/more.help
|
rm -f share/misc/more.help
|
||||||
rm -f etc/termcap etc/remote etc/phones
|
rm -f etc/termcap
|
||||||
rm -rf share/unixbench
|
rm -f uflash/*
|
||||||
rm -f games/lib/adventure.dat games/lib/cfscores share/re.help share/misc/more.help etc/termcap
|
|
||||||
rm -f tools/configsys/.depend
|
|
||||||
rm -f var/log/aculog
|
# TODO
|
||||||
rm -rf var/lock
|
buildlib:
|
||||||
|
@echo installing /usr/include
|
||||||
|
# cd include; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
@echo compiling libc.a
|
||||||
|
cd lib/libc; $(MAKE) $(LIBCDEFS)
|
||||||
|
@echo installing /lib/libc.a
|
||||||
|
cd lib/libc; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
@echo compiling C compiler
|
||||||
|
cd lib; $(MAKE) ccom cpp c2
|
||||||
|
@echo installing C compiler
|
||||||
|
cd lib/ccom; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/cpp; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/c2; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib; $(MAKE) clean
|
||||||
|
@echo
|
||||||
|
@echo re-compiling libc.a
|
||||||
|
cd lib/libc; $(MAKE) $(LIBCDEFS)
|
||||||
|
@echo re-installing /lib/libc.a
|
||||||
|
cd lib/libc; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
@echo re-compiling C compiler
|
||||||
|
cd lib; $(MAKE) ccom cpp c2
|
||||||
|
@echo re-installing C compiler
|
||||||
|
cd lib/ccom; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/cpp; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/c2; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
|
||||||
installfs: filesys.img
|
installfs: filesys.img
|
||||||
ifdef SDCARD
|
ifdef SDCARD
|
||||||
sudo dd bs=32k if=sdcard.rd of=$(SDCARD)
|
sudo dd bs=16k if=filesys.img of=$(SDCARD)
|
||||||
else
|
else
|
||||||
@echo "Error: No SDCARD defined."
|
@echo "Error: No SDCARD defined."
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# TODO: make it relative to Target
|
|
||||||
installflash:
|
|
||||||
sudo pic32prog sys/pic32/fubarino/unix.hex
|
|
||||||
|
|
||||||
# TODO: make it relative to Target
|
|
||||||
installboot:
|
|
||||||
sudo pic32prog sys/pic32/fubarino/bootloader.hex
|
|
||||||
|
|
||||||
.profile: etc/root/dot.profile
|
|
||||||
cp etc/root/dot.profile .profile
|
|
||||||
|
|||||||
129
README
Normal file
129
README
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
This is the RetroBSD source directory.
|
||||||
|
|
||||||
|
|
||||||
|
Source Roadmap
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
bin User commands.
|
||||||
|
etc Template files for /etc.
|
||||||
|
include System include files.
|
||||||
|
lib System libraries.
|
||||||
|
libexec System binaries.
|
||||||
|
sbin System administration commands.
|
||||||
|
share Shared resources.
|
||||||
|
sys Kernel sources.
|
||||||
|
tools Build tools and simulators.
|
||||||
|
|
||||||
|
|
||||||
|
Supported hardware
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
* chipKIT Max32 board.
|
||||||
|
* Sparkfun UBW32 board.
|
||||||
|
* Maximite computer.
|
||||||
|
* Microchip Explorer 16 board, with PIC32 CAN-USB plug-in module and SD & MMC pictail.
|
||||||
|
* Microchip PIC32 USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail.
|
||||||
|
* Olimex Duinomite, Duinomite-Mini and Duinomite-Mega boards.
|
||||||
|
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
|
||||||
|
* eflightworks DIP board.
|
||||||
|
|
||||||
|
|
||||||
|
Build
|
||||||
|
~~~~~
|
||||||
|
By default, the system is configured for the Max32 board.
|
||||||
|
To select another target board, edit a top-level Makefile
|
||||||
|
and change a TARGET value under section "Select target board":
|
||||||
|
|
||||||
|
TARGET = $(UBW32) # for the UBW32 board with USB console
|
||||||
|
TARGET = $(UBW32UART) # for the UBW32 board with UART console
|
||||||
|
TARGET = $(MAXIMITE) # for the Maximite board
|
||||||
|
TARGET = $(EXPLORER16) # for the Explorer 16 board
|
||||||
|
TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit
|
||||||
|
TARGET = $(MAX32) # default
|
||||||
|
TARGET = $(DUINOMITE) # for the Duinomite board
|
||||||
|
TARGET = $(PINGUINO) # for the Pinguino-Micro board
|
||||||
|
TARGET = $(DIP) # for the DIP board
|
||||||
|
|
||||||
|
You can also change a desired filesystem size and swap area size,
|
||||||
|
as required. Default is:
|
||||||
|
|
||||||
|
FS_KBYTES = 16384
|
||||||
|
SWAP_KBYTES = 2048
|
||||||
|
|
||||||
|
To compile the kernel and build a filesystem image, run:
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
|
A resulting root filesystem image is in file `filesys.img`.
|
||||||
|
A kernel is in file `unix.hex` in your target board subdirectory.
|
||||||
|
|
||||||
|
|
||||||
|
Filesystem image
|
||||||
|
~~~~~~~~~~~~~~~~
|
||||||
|
You need to put a filesystem image on a SD card. On Windows, use
|
||||||
|
Win32DiskImager utility (https://launchpad.net/win32-image-writer/+download).
|
||||||
|
On Linux, run:
|
||||||
|
|
||||||
|
sudo dd if=filesys.img of=/dev/XYZ
|
||||||
|
|
||||||
|
Here `XYZ` is a device name of SD card, as recognized by Linux (sdb in my case).
|
||||||
|
|
||||||
|
|
||||||
|
Install kernel
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
Kernel image should be written to PIC32 flash memory. The procedure depends
|
||||||
|
on a board used.
|
||||||
|
|
||||||
|
Max32 board:
|
||||||
|
cd sys/pic32/ubw32
|
||||||
|
AVRTOOLS=/Applications/Mpide.app/Contents/Resources/Java/hardware/tools
|
||||||
|
$AVRTOOLS/bin/avrdude -C$AVRTOOLS/etc/avrdude.conf -c stk500v2 -p pic32 \
|
||||||
|
-P /dev/tty.usbserial-* -b 115200 -v -U flash:w:unix.hex:i
|
||||||
|
|
||||||
|
Here you need to change AVRTOOLS path and tty name according to your system.
|
||||||
|
|
||||||
|
UBW32 board:
|
||||||
|
Use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
||||||
|
and a USB cable to install a kernel:
|
||||||
|
|
||||||
|
pic32prog sys/pic32/ubw32/unix.hex
|
||||||
|
|
||||||
|
Maximite:
|
||||||
|
Use the bootload program for Windows, available for download by link:
|
||||||
|
http://geoffg.net/Downloads/Maximite/Maximite_Update_V2.7B.zip
|
||||||
|
|
||||||
|
Explorer 16 board:
|
||||||
|
There is an auxiliary PIC18 chip on the Explorer 16 board, which can be
|
||||||
|
used as a built-in programmer device. You will need a PICkit 2 adapter
|
||||||
|
to install a needed firmware, as described in article:
|
||||||
|
http://www.paintyourdragon.com/?p=51
|
||||||
|
(section "Hack #2: Lose the PICkit 2, Save $35").
|
||||||
|
This should be done only once.
|
||||||
|
|
||||||
|
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
||||||
|
and a USB cable to install a kernel:
|
||||||
|
|
||||||
|
pic32prog sys/pic32/explorer16/unix.hex
|
||||||
|
|
||||||
|
PIC32 Starter Kit:
|
||||||
|
Use PICkit 2 adapter and software to install a boot loader from
|
||||||
|
file `sys/pic32/starter-kit/boot.hex`. This should be done only once.
|
||||||
|
|
||||||
|
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
||||||
|
and a USB cable to install a kernel:
|
||||||
|
|
||||||
|
pic32prog sys/pic32/starter-kit/unix.hex
|
||||||
|
|
||||||
|
|
||||||
|
Simulator
|
||||||
|
~~~~~~~~~
|
||||||
|
You can use a MIPS32 simulator to develop a debug a RetroBSD software,
|
||||||
|
without a need for hardware board. By default, a simulator is configured
|
||||||
|
to imitate a Max32 board. To build it:
|
||||||
|
|
||||||
|
cd tools/virtualmips
|
||||||
|
make
|
||||||
|
|
||||||
|
Run it:
|
||||||
|
|
||||||
|
./pic32
|
||||||
|
|
||||||
|
Configuration of simulated board is stored in file `pic32_max32.conf`.
|
||||||
166
README.md
166
README.md
@@ -1,166 +0,0 @@
|
|||||||
# This is the RetroBSD source directory.
|
|
||||||
|
|
||||||
## Source Roadmap
|
|
||||||
|
|
||||||
bin User commands.
|
|
||||||
etc Template files for /etc.
|
|
||||||
include System include files.
|
|
||||||
lib System libraries.
|
|
||||||
libexec System binaries.
|
|
||||||
sbin System administration commands.
|
|
||||||
share Shared resources.
|
|
||||||
sys Kernel sources.
|
|
||||||
tools Build tools and simulators.
|
|
||||||
|
|
||||||
|
|
||||||
## Supported hardware
|
|
||||||
|
|
||||||
* chipKIT Max32 board.
|
|
||||||
* Sparkfun UBW32 board.
|
|
||||||
* Maximite and Colour Maximite computers.
|
|
||||||
* Microchip Explorer 16 board, with PIC32 CAN-USB plug-in module and SD & MMC pictail.
|
|
||||||
* Microchip PIC32 USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail.
|
|
||||||
* Olimex Duinomite, Duinomite-Mini and Duinomite-Mega boards.
|
|
||||||
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
|
|
||||||
* eflightworks DIP board.
|
|
||||||
|
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
By default, the system is configured for the Max32 board.
|
|
||||||
To select another target board, edit a top-level user-specific Makefile called "Makefile.user"
|
|
||||||
and set a TARGET value:
|
|
||||||
|
|
||||||
```Makefile
|
|
||||||
TARGET = $(UBW32) # for the UBW32 board with USB console
|
|
||||||
TARGET = $(UBW32UART) # for the UBW32 board with UART console
|
|
||||||
TARGET = $(UBW32UARTSDRAM) # for the UBW32 boars with UART console and 8MB SRAM ramdisk
|
|
||||||
TARGET = $(MAXIMITE) # for the Maximite board
|
|
||||||
TARGET = $(MAXCOLOR) # for the Colour Maximite board
|
|
||||||
TARGET = $(EXPLORER16) # for the Explorer 16 board
|
|
||||||
TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit
|
|
||||||
TARGET = $(MAX32) # default
|
|
||||||
TARGET = $(MAX32-ETH) # for the chipKIT MAX32 board with Arduino Ethernet shield
|
|
||||||
TARGET = $(DUINOMITE) # for the Duinomite board with USB console
|
|
||||||
TARGET = $(DUINOMITEUART) # for the Duinomite board with UART console
|
|
||||||
TARGET = $(DUINOMITEE) # for the Duinomite E board with USB console
|
|
||||||
TARGET = $(DUINOMITEEUART) # for the Duinomite E board with UART console
|
|
||||||
TARGET = $(PINGUINO) # for the Pinguino-Micro board
|
|
||||||
TARGET = $(DIP) # for the DIP board
|
|
||||||
TARGET = $(BAREMETAL) # Bare PIC32 chip on a breakout board
|
|
||||||
TARGET = $(FUBARINO) # Fubarino SD board
|
|
||||||
TARGET = $(FUBARINOBIG) # Fubarino SD board with 8MB SRAM RAMDISK
|
|
||||||
TARGET = $(MMBMX7) # MMB MX7 board
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also change a desired filesystem size and swap area size,
|
|
||||||
as required. Default is:
|
|
||||||
```Makefile
|
|
||||||
FS_KBYTES = 16384
|
|
||||||
SWAP_KBYTES = 2048
|
|
||||||
```
|
|
||||||
To compile the kernel and build a filesystem image, run:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
|
|
||||||
A resulting root filesystem image is in file `sdcard.rd`.
|
|
||||||
A kernel is in file `unix.hex` in your target board subdirectory.
|
|
||||||
|
|
||||||
|
|
||||||
### Filesystem image
|
|
||||||
|
|
||||||
You need to put a filesystem image on a SD card. On Windows, use
|
|
||||||
Win32DiskImager utility (https://launchpad.net/win32-image-writer/+download).
|
|
||||||
On Linux, run:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ sudo dd if=sdcard.rd of=/dev/XYZ
|
|
||||||
```
|
|
||||||
|
|
||||||
Here `XYZ` is a device name of SD card, as recognized by Linux (sdb in my case).
|
|
||||||
|
|
||||||
|
|
||||||
### Install kernel
|
|
||||||
|
|
||||||
Kernel image should be written to PIC32 flash memory. The procedure depends
|
|
||||||
on a board used.
|
|
||||||
|
|
||||||
#### Max32 board:
|
|
||||||
```shell
|
|
||||||
$ cd sys/pic32/ubw32
|
|
||||||
$ AVRTOOLS=/Applications/Mpide.app/Contents/Resources/Java/hardware/tools/avr
|
|
||||||
$AVRTOOLS/bin/avrdude -C$AVRTOOLS/etc/avrdude.conf -c stk500v2 -p pic32 \
|
|
||||||
-P /dev/tty.usbserial-* -b 115200 -v -U flash:w:unix.hex:i
|
|
||||||
```
|
|
||||||
|
|
||||||
Here you need to change AVRTOOLS path and tty name according to your system.
|
|
||||||
|
|
||||||
#### UBW32 board:
|
|
||||||
Use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
|
||||||
and a USB cable to install a kernel:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ pic32prog sys/pic32/ubw32/unix.hex
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Maximite:
|
|
||||||
Use the bootload program for Windows, available for download by link:
|
|
||||||
http://geoffg.net/Downloads/Maximite/Maximite_Update_V2.7B.zip
|
|
||||||
|
|
||||||
#### Explorer 16 board:
|
|
||||||
There is an auxiliary PIC18 chip on the Explorer 16 board, which can be
|
|
||||||
used as a built-in programmer device. You will need a PICkit 2 adapter
|
|
||||||
to install a needed firmware, as described in article:
|
|
||||||
http://www.paintyourdragon.com/?p=51
|
|
||||||
(section "Hack #2: Lose the PICkit 2, Save $35").
|
|
||||||
This should be done only once.
|
|
||||||
|
|
||||||
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
|
||||||
and a USB cable to install a kernel:
|
|
||||||
|
|
||||||
``` shell
|
|
||||||
$ pic32prog sys/pic32/explorer16/unix.hex
|
|
||||||
```
|
|
||||||
|
|
||||||
#### PIC32 Starter Kit:
|
|
||||||
Use PICkit 2 adapter and software to install a boot loader from
|
|
||||||
file `sys/pic32/starter-kit/boot.hex`. This should be done only once.
|
|
||||||
|
|
||||||
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
|
||||||
and a USB cable to install a kernel:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ pic32prog sys/pic32/starter-kit/unix.hex
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Simulator
|
|
||||||
|
|
||||||
You can use a MIPS32 simulator to develop a debug a RetroBSD software,
|
|
||||||
without a need for hardware board. By default, a simulator is configured
|
|
||||||
to imitate a Max32 board. To build it:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ cd tools/virtualmips
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
|
|
||||||
Run it:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ ./pic32
|
|
||||||
```
|
|
||||||
|
|
||||||
Configuration of simulated board is stored in file `pic32_max32.conf`.
|
|
||||||
|
|
||||||
## Build packages
|
|
||||||
|
|
||||||
|
|
||||||
For building under Ubuntu you need the following packages installed:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ sudo apt-get install byacc libelf-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
1
bin/.gitignore
vendored
1
bin/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
10
cross.mk
10
cross.mk
@@ -18,14 +18,6 @@ TAGSFILE = tags
|
|||||||
MANROFF = nroff -man -h
|
MANROFF = nroff -man -h
|
||||||
ELF2AOUT = cp
|
ELF2AOUT = cp
|
||||||
|
|
||||||
CFLAGS = -O -DCROSS
|
CFLAGS = -O -DCROSS -I/usr/include -I$(TOPSRC)/include
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
LIBS =
|
LIBS =
|
||||||
|
|
||||||
# Add system include path
|
|
||||||
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
|
|
||||||
CFLAGS += -I/usr/include
|
|
||||||
else
|
|
||||||
CFLAGS += -I/usr/include/i386-linux-gnu
|
|
||||||
endif
|
|
||||||
CFLAGS += -I$(TOPSRC)/include
|
|
||||||
|
|||||||
3
etc/.gitignore
vendored
3
etc/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
phones
|
|
||||||
remote
|
|
||||||
termcap
|
|
||||||
380
etc/MAKEDEV
380
etc/MAKEDEV
@@ -52,13 +52,16 @@ do
|
|||||||
case $i in
|
case $i in
|
||||||
|
|
||||||
std)
|
std)
|
||||||
mknod console c 0 0
|
mknod console c 0 0
|
||||||
mknod mem c 1 0 ; chmod 640 mem ; chgrp kmem mem
|
# mknod kUmem c 1 3 ; chmod 600 kUmem ;: untested
|
||||||
mknod kmem c 1 1 ; chmod 640 kmem ; chgrp kmem kmem
|
mknod kmem c 1 1 ; chmod 640 kmem ; chgrp kmem kmem
|
||||||
|
mknod mem c 1 0 ; chmod 640 mem ; chgrp kmem mem
|
||||||
mknod null c 1 2 ; chmod 666 null
|
mknod null c 1 2 ; chmod 666 null
|
||||||
mknod zero c 1 3 ; chmod 444 zero
|
mknod zero c 1 3 ; chmod 444 zero
|
||||||
mknod tty c 2 0 ; chmod 666 tty
|
mknod tty c 9 0 ; chmod 666 tty
|
||||||
mknod klog c 3 0 ; chmod 600 klog
|
mknod klog c 22 0 ; chmod 600 klog
|
||||||
|
mknod errlog c 22 1 ; chmod 600 errlog
|
||||||
|
mknod acctlog c 22 2 ; chmod 600 acctlog
|
||||||
;;
|
;;
|
||||||
|
|
||||||
fd)
|
fd)
|
||||||
@@ -67,105 +70,304 @@ fd)
|
|||||||
rm -f stdin stdout stderr
|
rm -f stdin stdout stderr
|
||||||
mkdir fd
|
mkdir fd
|
||||||
chmod 755 fd
|
chmod 755 fd
|
||||||
mknod stdin c 4 0
|
mknod stdin c 26 0
|
||||||
mknod stdout c 4 1
|
mknod stdout c 26 1
|
||||||
mknod stderr c 4 2
|
mknod stderr c 26 2
|
||||||
eval `echo "" | awk '{ for (i = 0; i < 32; i++)
|
eval `echo "" | awk '{ for (i = 0; i < 32; i++)
|
||||||
printf("mknod fd/%d c 4 %d; ",i,i); }'`
|
printf("mknod fd/%d c 26 %d; ",i,i); }'`
|
||||||
;;
|
;;
|
||||||
|
|
||||||
rd)
|
ht*|tm*|ts*|tu*)
|
||||||
|
umask 0 ; ctlr=`expr $i : '..\(.*\)'`
|
||||||
|
ctlr=`expr $ctlr '*' 64`
|
||||||
|
case $i in
|
||||||
|
ht*) blk=0; chr=6;;
|
||||||
|
tm*) blk=1; chr=7;;
|
||||||
|
ts*) blk=2; chr=8;;
|
||||||
|
tu*) blk=12; chr=23;;
|
||||||
|
esac
|
||||||
|
# Maximum of 4 controllers in a system
|
||||||
|
case $ctlr in
|
||||||
|
0|64|128|192)
|
||||||
|
# Maximum of 4 units per controller
|
||||||
|
# for unit in 0 1 2 3
|
||||||
|
for unit in 0 1
|
||||||
|
do
|
||||||
|
zero=`expr $ctlr + $unit + 0`
|
||||||
|
four=`expr $zero + 4` ; eight=`expr $zero + 8`
|
||||||
|
twelve=`expr $zero + 12`
|
||||||
|
sixteen=`expr $zero + 16`
|
||||||
|
twenty=`expr $zero + 20`
|
||||||
|
twentyfour=`expr $zero + 24`
|
||||||
|
twentyeight=`expr $zero + 28`
|
||||||
|
mknod mt$zero b $blk $zero
|
||||||
|
mknod mt$four b $blk $four
|
||||||
|
mknod mt$eight b $blk $eight
|
||||||
|
mknod mt$twelve b $blk $twelve
|
||||||
|
mknod nmt$zero b $blk $four ;: v7 compatibility
|
||||||
|
mknod nmt$eight b $blk $twelve ;: ditto
|
||||||
|
mknod nrmt$zero c $chr $four ;: ditto
|
||||||
|
mknod nrmt$eight c $chr $twelve ;: ditto
|
||||||
|
mknod rmt$zero c $chr $zero
|
||||||
|
mknod rmt$four c $chr $four
|
||||||
|
mknod rmt$eight c $chr $eight
|
||||||
|
mknod rmt$twelve c $chr $twelve
|
||||||
|
if [ `expr $i : '\(..\)'` = tu ]
|
||||||
|
then
|
||||||
|
mknod mt$sixteen b $blk $sixteen
|
||||||
|
mknod mt$twenty b $blk $twenty
|
||||||
|
mknod mt$twentyfour b $blk $twentyfour
|
||||||
|
mknod mt$twentyeight b $blk $twentyeight
|
||||||
|
mknod nmt$sixteen b $blk $twenty ;: v7 compatibility
|
||||||
|
mknod nmt$twentyfour b $blk $twentyeight ;: ditto
|
||||||
|
mknod nrmt$sixteen c $chr $twenty ;: ditto
|
||||||
|
mknod nrmt$twentyfour c $chr $twentyeight ;: ditto
|
||||||
|
mknod rmt$sixteen c $chr $sixteen
|
||||||
|
mknod rmt$twenty c $chr $twenty
|
||||||
|
mknod rmt$twentyfour c $chr $twentyfour
|
||||||
|
mknod rmt$twentyeight c $chr $twentyeight
|
||||||
|
fi
|
||||||
|
if [ `expr $i : '\(..\)'` = ut ]
|
||||||
|
then
|
||||||
|
mknod mt$twenty b $blk $twenty
|
||||||
|
mknod rmt$twenty c $chr $twenty
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad controller for tape in: $1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
umask 77
|
||||||
|
;;
|
||||||
|
|
||||||
|
rk*)
|
||||||
|
# The 2.11BSD rk driver doesn't support partitions. We create
|
||||||
|
# a single block and charater inode pair for each unit and
|
||||||
|
# call it rkNh.
|
||||||
|
umask 2 ; unit=`expr $i : '..\(.*\)'`
|
||||||
|
case $i in
|
||||||
|
rk*) name=rk; blk=6; chr=15;;
|
||||||
|
esac
|
||||||
|
mknod ${name}${unit}h b ${blk} ${unit}
|
||||||
|
mknod r${name}${unit}h c ${chr} ${unit}
|
||||||
|
chgrp operator ${name}${unit}h r${name}${unit}h
|
||||||
|
chmod 640 ${name}${unit}h r${name}${unit}h
|
||||||
|
;;
|
||||||
|
|
||||||
|
rx*)
|
||||||
umask 2
|
umask 2
|
||||||
rm -f rd[0123] rd[0123][abcd]
|
name=rx; blk=8; chr=17
|
||||||
mknod rd0 b 0 0
|
mknod ${name}0a b ${blk} 0
|
||||||
mknod rd0a b 0 1
|
mknod ${name}1a b ${blk} 1
|
||||||
mknod rd0b b 0 2
|
mknod ${name}0b b ${blk} 2
|
||||||
mknod rd0c b 0 2
|
mknod ${name}1b b ${blk} 3
|
||||||
mknod rd0d b 0 2
|
mknod r${name}0a c ${chr} 0
|
||||||
mknod rd1 b 1 0
|
mknod r${name}1a c ${chr} 1
|
||||||
mknod rd1a b 1 1
|
mknod r${name}0b c ${chr} 2
|
||||||
mknod rd1b b 1 2
|
mknod r${name}1b c ${chr} 3
|
||||||
mknod rd1c b 1 2
|
chgrp operator ${name}[01][ab] r${name}[01][ab]
|
||||||
mknod rd1d b 1 2
|
chmod 640 ${name}[01][ab] r${name}[01][ab]
|
||||||
mknod rd2 b 2 0
|
|
||||||
mknod rd2a b 2 1
|
|
||||||
mknod rd2b b 2 2
|
|
||||||
mknod rd2c b 2 2
|
|
||||||
mknod rd2d b 2 2
|
|
||||||
mknod rd3 b 3 0
|
|
||||||
mknod rd3a b 3 1
|
|
||||||
mknod rd3b b 3 2
|
|
||||||
mknod rd3c b 3 2
|
|
||||||
mknod rd3d b 3 2
|
|
||||||
chgrp operator rd[0123]
|
|
||||||
chgrp operator rd[0123][abcd]
|
|
||||||
chmod 640 rd[0123][abcd]
|
|
||||||
chmod 640 rd[0123]
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
gpio)
|
ram*)
|
||||||
umask 0
|
# Note, this must come *before* the "ra*". The entry "rram" is for
|
||||||
rm -f port[abcdefg] conf[abcdef]
|
# auto fscks when ram is mentioned in /etc/fstab.
|
||||||
mknod porta c 5 0
|
umask 2
|
||||||
mknod portb c 5 1
|
mknod ram b 3 0
|
||||||
mknod portc c 5 2
|
ln ram rram
|
||||||
mknod portd c 5 3
|
chgrp operator ram
|
||||||
mknod porte c 5 4
|
chmod 640 ram
|
||||||
mknod portf c 5 5
|
umask 77
|
||||||
mknod portg c 5 6
|
|
||||||
mknod confa c 5 64
|
|
||||||
mknod confb c 5 65
|
|
||||||
mknod confc c 5 66
|
|
||||||
mknod confd c 5 67
|
|
||||||
mknod confe c 5 68
|
|
||||||
mknod conff c 5 69
|
|
||||||
mknod confg c 5 70
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
adc)
|
br*|hk*|ra*|si*|xp*|rl*)
|
||||||
umask 0
|
umask 2 ; unit=`expr $i : '..\(.*\)'`
|
||||||
rm -f adc[0123456789] adc1[012345]
|
case $i in
|
||||||
mknod adc0 c 6 0
|
br*) name=rp; blk=11; chr=20;;
|
||||||
mknod adc1 c 6 1
|
hk*) name=hk; blk=4; chr=13;;
|
||||||
mknod adc2 c 6 2
|
ra*) name=ra; blk=5; chr=14;;
|
||||||
mknod adc3 c 6 3
|
si*) name=si; blk=9; chr=18;;
|
||||||
mknod adc4 c 6 4
|
xp*) name=xp; blk=10; chr=19;;
|
||||||
mknod adc5 c 6 5
|
rl*) name=rl; blk=7; chr=16;;
|
||||||
mknod adc6 c 6 6
|
esac
|
||||||
mknod adc7 c 6 7
|
case $unit in
|
||||||
mknod adc8 c 6 8
|
0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\
|
||||||
mknod adc9 c 6 9
|
17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)
|
||||||
mknod adc10 c 6 10
|
mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
|
||||||
mknod adc11 c 6 11
|
mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1`
|
||||||
mknod adc12 c 6 12
|
mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2`
|
||||||
mknod adc13 c 6 13
|
mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
|
||||||
mknod adc14 c 6 14
|
mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4`
|
||||||
mknod adc15 c 6 15
|
mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5`
|
||||||
|
mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6`
|
||||||
|
mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7`
|
||||||
|
mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
|
||||||
|
mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1`
|
||||||
|
mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2`
|
||||||
|
mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3`
|
||||||
|
mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4`
|
||||||
|
mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5`
|
||||||
|
mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7`
|
||||||
|
mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6`
|
||||||
|
chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
|
||||||
|
chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for disk in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
umask 77
|
||||||
;;
|
;;
|
||||||
|
|
||||||
spi)
|
dz*)
|
||||||
umask 0
|
unit=`expr $i : 'dz\(.*\)'`
|
||||||
rm -f spi[1234]
|
case $unit in
|
||||||
mknod spi1 c 7 0
|
0|1|2|3|4|5|6|7)
|
||||||
mknod spi2 c 7 1
|
eval `echo $unit | awk ' { u = $1 } END {
|
||||||
mknod spi3 c 7 2
|
for (i = 0; i < 8; i++)
|
||||||
mknod spi4 c 7 3
|
printf("mknod tty%02d c 2 %d; ",u*8+i,u*8+i); }'`
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for dz in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
glcd)
|
#
|
||||||
umask 0
|
# we may want dmz and dmf someday...
|
||||||
rm -f glcd0
|
# dhu*|dh*|dmf*|dmz*)
|
||||||
mknod glcd0 c 8 0
|
dhv*|dhu*|dh*)
|
||||||
|
case $i in
|
||||||
|
# dmz*) name=dmz; major=37; count=24;
|
||||||
|
# unit=`expr $i : "$name\(.*\)"`
|
||||||
|
# case $unit in
|
||||||
|
# 0) ch=a ;; 1) ch=b ;; 2) ch=c ;; 3) ch=e ;;
|
||||||
|
# 4) ch=f ;; 5) ch=g ;;
|
||||||
|
# *) echo bad unit for $name in: $i ;;
|
||||||
|
# esac;;
|
||||||
|
# dmf*) name=dmf; major=22; count=8;
|
||||||
|
# unit=`expr $i : "$name\(.*\)"`
|
||||||
|
# case $unit in
|
||||||
|
# 0) ch=A ;; 1) ch=B ;; 2) ch=C ;; 3) ch=E ;;
|
||||||
|
# 4) ch=F ;; 5) ch=G ;; 6) ch=H ;; 7) ch=I ;;
|
||||||
|
# *) echo bad unit for $name in: $i ;;
|
||||||
|
# esac;;
|
||||||
|
dhv*) name=dhv; major=24; count=8;
|
||||||
|
unit=`expr $i : "$name\(.*\)"`;
|
||||||
|
case $unit in
|
||||||
|
0) ch=S ;; 1) ch=T ;; 2) ch=U ;; 3) ch=V ;;
|
||||||
|
4) ch=W ;; 5) ch=X ;; 6) ch=Y ;; 7) ch=Z ;;
|
||||||
|
*) echo bad unit for $name in: $i ;;
|
||||||
|
esac;;
|
||||||
|
dhu*) name=dhu; major=4; count=16;
|
||||||
|
unit=`expr $i : "$name\(.*\)"`;
|
||||||
|
case $unit in
|
||||||
|
0) ch=S ;; 1) ch=T ;; 2) ch=U ;; 3) ch=V ;;
|
||||||
|
4) ch=W ;; 5) ch=X ;; 6) ch=Y ;; 7) ch=Z ;;
|
||||||
|
*) echo bad unit for $name in: $i ;;
|
||||||
|
esac;;
|
||||||
|
dh*) name=dh; major=3; count=16;
|
||||||
|
unit=`expr $i : "$name\(.*\)"`
|
||||||
|
case $unit in
|
||||||
|
0) ch=h ;; 1) ch=i ;; 2) ch=j ;; 3) ch=k ;;
|
||||||
|
*) echo bad unit for $name in: $i ;;
|
||||||
|
esac;;
|
||||||
|
esac
|
||||||
|
eval `echo $ch $unit $major $count |
|
||||||
|
awk ' { ch = $1; u = $4 * $2; m = $3; cnt = $4 } END {
|
||||||
|
for (i = 0; i < cnt; i++)
|
||||||
|
if (i < 10)
|
||||||
|
printf("mknod tty%s%x c %d %d; ",ch,i,m,u+i);
|
||||||
|
else
|
||||||
|
printf("mknod tty%s%c c %d %d; ",ch,87+i,m,u+i); }'`
|
||||||
;;
|
;;
|
||||||
|
|
||||||
oc)
|
# extra DL-11 units not including the console. unit numbers start at 1 because
|
||||||
umask 0
|
# the console is always unit 0. Seven units (1 - 7) are defined for the 11/93
|
||||||
rm -f oc[12345]
|
# and 11/94. Device name is "ttyl?". The DH range was restricted from 'h'-'o'
|
||||||
mknod oc1 c 9 0
|
# to 'h' - 'k' (very unlikely that more than 64 channels of DH-11 will or could
|
||||||
mknod oc2 c 9 1
|
# be put on an 11.
|
||||||
mknod oc3 c 9 2
|
|
||||||
mknod oc4 c 9 3
|
dl*)
|
||||||
mknod oc5 c 9 4
|
name=dl; major=0; ch=l
|
||||||
|
unit=`expr $i : "$name\(.*\)"`
|
||||||
|
case $unit in
|
||||||
|
1|2|3|4|5|6|7)
|
||||||
|
mknod tty${ch}${unit} c $major $unit;
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for $name in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
# we may want va and vp someday...
|
||||||
|
# lp*|va*|vp*)
|
||||||
|
lp*|dn*)
|
||||||
|
case $i in
|
||||||
|
lp*) name=lp; major=5;;
|
||||||
|
dn*) name=dn; major=21;;
|
||||||
|
# va*) name=va; major=10;;
|
||||||
|
# vp*) name=vp; major=6;;
|
||||||
|
esac
|
||||||
|
unit=`expr $i : "$name\(.*\)"`
|
||||||
|
case $unit in
|
||||||
|
0|1|2|3|4|5|6|7)
|
||||||
|
mknod $i c $major $unit;
|
||||||
|
chmod 666 $i
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for $name in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
pty*)
|
||||||
|
class=`expr $i : 'pty\(.*\)'`
|
||||||
|
case $class in
|
||||||
|
0) offset=0 name=p;;
|
||||||
|
1) offset=16 name=q;;
|
||||||
|
2) offset=32 name=r;;
|
||||||
|
3) offset=48 name=s;;
|
||||||
|
4) offset=64 name=t;;
|
||||||
|
5) offset=80 name=u;;
|
||||||
|
*) echo bad unit for pty in: $i;;
|
||||||
|
esac
|
||||||
|
case $class in
|
||||||
|
0|1|2|3|4|5)
|
||||||
|
umask 0
|
||||||
|
eval `echo $offset $name | awk ' { b=$1; n=$2 } END {
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
printf("mknod tty%s%x c 11 %d; \
|
||||||
|
mknod pty%s%x c 10 %d; ", \
|
||||||
|
n, i, b+i, n, i, b+i); }'`
|
||||||
|
umask 77
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
dr*)
|
||||||
|
unit=`expr $i : '..\(.*\)'`
|
||||||
|
case $i in
|
||||||
|
dr*) name=dr; chr=12;;
|
||||||
|
esac
|
||||||
|
case $unit in
|
||||||
|
0|1|2|3|4|5|6|7)
|
||||||
|
umask 0
|
||||||
|
mknod ${name}${unit} c ${chr} ${unit}
|
||||||
|
umask 77
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for ${name} in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
ingreslock)
|
||||||
|
mknod ingreslock c 25 0
|
||||||
|
chown ingres ingreslock
|
||||||
|
chmod 200 ingreslock
|
||||||
;;
|
;;
|
||||||
|
|
||||||
local)
|
local)
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
/dev/rd0a / ufs rw,async 1 1
|
/dev/sd0 / ufs rw,async 1 1
|
||||||
#/dev/rd0c /u ufs rw,async 1 2
|
#/dev/sd1 /u ufs rw,async 1 2
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ v|std.3500000|3500000-baud:\
|
|||||||
:sp#3500000:
|
:sp#3500000:
|
||||||
w|std.4000000|4000000-baud:\
|
w|std.4000000|4000000-baud:\
|
||||||
:sp#4000000:
|
:sp#4000000:
|
||||||
x|std.default|default-baud:\
|
|
||||||
:sp#0:
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
3
etc/rc
3
etc/rc
@@ -3,8 +3,6 @@ HOME=/; export HOME
|
|||||||
PATH=/bin:/sbin; export PATH
|
PATH=/bin:/sbin; export PATH
|
||||||
exec >/dev/console 2>&1
|
exec >/dev/console 2>&1
|
||||||
|
|
||||||
/sbin/devupdate
|
|
||||||
|
|
||||||
if test "$1" != "autoboot"; then
|
if test "$1" != "autoboot"; then
|
||||||
#
|
#
|
||||||
# Switch from single-user to multi-user mode.
|
# Switch from single-user to multi-user mode.
|
||||||
@@ -66,7 +64,6 @@ rm -f /etc/nologin
|
|||||||
|
|
||||||
echo -n "Starting daemons:"
|
echo -n "Starting daemons:"
|
||||||
update && echo -n "update"
|
update && echo -n "update"
|
||||||
cron && echo -n "cron"
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
#/etc/rc.local
|
#/etc/rc.local
|
||||||
|
|||||||
14
etc/ttys
14
etc/ttys
@@ -1,16 +1,4 @@
|
|||||||
#
|
#
|
||||||
# name getty type status comments
|
# name getty type status comments
|
||||||
#
|
#
|
||||||
console "/libexec/getty std.default" vt100 on secure #special
|
console "/libexec/getty std.115200" vt100 on secure #special
|
||||||
|
|
||||||
# Enable some of these for additional logins. Do NOT enable the same one as the
|
|
||||||
# console port, or strange things will happen. You can turn off the console port
|
|
||||||
# if you would rather use the getty on the real tty - it's up to you.
|
|
||||||
|
|
||||||
tty0 "/libexec/getty std.default" vt100 off secure
|
|
||||||
tty1 "/libexec/getty std.default" vt100 off secure
|
|
||||||
tty2 "/libexec/getty std.default" vt100 off secure
|
|
||||||
tty3 "/libexec/getty std.default" vt100 off secure
|
|
||||||
tty4 "/libexec/getty std.default" vt100 off secure
|
|
||||||
tty5 "/libexec/getty std.default" vt100 off secure
|
|
||||||
ttyUSB0 "/libexec/getty std.default" vt100 off secure
|
|
||||||
|
|||||||
1
games/.gitignore
vendored
1
games/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
Binary file not shown.
@@ -33,36 +33,48 @@
|
|||||||
#ifndef _AOUT_H_
|
#ifndef _AOUT_H_
|
||||||
#define _AOUT_H_
|
#define _AOUT_H_
|
||||||
|
|
||||||
#include <sys/exec_aout.h>
|
#include <sys/exec.h>
|
||||||
|
|
||||||
|
/* Valid magic number check. */
|
||||||
|
#define N_BADMAG(x) (((x).a_magic) != RMAGIC && \
|
||||||
|
((x).a_magic) != OMAGIC && \
|
||||||
|
((x).a_magic) != NMAGIC)
|
||||||
|
|
||||||
|
/* Text segment offset. */
|
||||||
|
#define N_TXTOFF(x) sizeof(struct exec)
|
||||||
|
|
||||||
|
/* Data segment offset. */
|
||||||
|
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
|
||||||
|
|
||||||
|
/* Text relocation table offset. */
|
||||||
|
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
|
||||||
|
|
||||||
|
/* Data relocation table offset. */
|
||||||
|
#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext)
|
||||||
|
|
||||||
|
/* Symbol table offset. */
|
||||||
|
#define N_SYMOFF(x) ((x).a_magic == RMAGIC ? \
|
||||||
|
N_DRELOFF(x) + (x).a_reldata : \
|
||||||
|
N_DATOFF(x) + (x).a_data)
|
||||||
|
|
||||||
#define _AOUT_INCLUDE_
|
#define _AOUT_INCLUDE_
|
||||||
#include <nlist.h>
|
#include <nlist.h>
|
||||||
|
|
||||||
/* Relocations */
|
/* Relocations */
|
||||||
struct reloc {
|
|
||||||
unsigned flags;
|
|
||||||
#define RSMASK 0x70 /* bitmask for segments */
|
#define RSMASK 0x70 /* bitmask for segments */
|
||||||
#define RABS 0
|
#define RABS 0
|
||||||
#define RTEXT 0x20
|
#define RTEXT 0x20
|
||||||
#define RDATA 0x30
|
#define RDATA 0x30
|
||||||
#define RBSS 0x40
|
#define RBSS 0x40
|
||||||
#define RSTRNG 0x60 /* for assembler */
|
#define RSTRNG 0x60 /* for assembler */
|
||||||
#define REXT 0x70 /* externals and bitmask */
|
#define REXT 0x70 /* externals and bitmask */
|
||||||
|
|
||||||
#define RGPREL 0x08 /* gp relative */
|
|
||||||
|
|
||||||
#define RFMASK 0x07 /* bitmask for format */
|
#define RFMASK 0x07 /* bitmask for format */
|
||||||
#define RBYTE16 0x00 /* low part of byte address: bits 15:0 */
|
#define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */
|
||||||
#define RBYTE32 0x01 /* 32-bit byte address */
|
#define RWORD16 0x03 /* word address: bits 17:2 */
|
||||||
#define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */
|
#define RWORD26 0x04 /* word address: bits 27:2 */
|
||||||
#define RHIGH16S 0x03 /* upper part of address with signed offset */
|
|
||||||
#define RWORD16 0x04 /* word address: bits 17:2 */
|
|
||||||
#define RWORD26 0x05 /* word address: bits 27:2 */
|
|
||||||
|
|
||||||
unsigned index; /* 24-bit index in symbol table,
|
#define RINDEX(h) ((h) >> 8)
|
||||||
* for REXT */
|
#define RSETINDEX(h) ((h) << 8)
|
||||||
unsigned offset; /* 16-bit offset,
|
|
||||||
* for RIGH16 and RIGH16S */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* !_AOUT_H_ */
|
#endif /* !_AOUT_H_ */
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
/* alloca.h - Allocate memory on stack */
|
|
||||||
|
|
||||||
#ifndef ALLOCA_H
|
|
||||||
#define ALLOCA_H
|
|
||||||
|
|
||||||
#undef alloca
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define alloca(size) __builtin_alloca(size)
|
|
||||||
#else
|
|
||||||
#include <sys/types.h>
|
|
||||||
void *alloca(size_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <sgtty.h>
|
#include <sgtty.h>
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
|
|
||||||
#define bool int
|
#define bool char
|
||||||
#define reg register
|
#define reg register
|
||||||
|
|
||||||
#define TRUE (1)
|
#define TRUE (1)
|
||||||
@@ -149,7 +149,7 @@ int __void__;
|
|||||||
#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
||||||
#define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty))
|
#define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty))
|
||||||
#define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty))
|
#define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty))
|
||||||
#define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), _res_flg = _tty.sg_flags)
|
#define savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
|
||||||
#define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty))
|
#define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty))
|
||||||
|
|
||||||
#define erasechar() (_tty.sg_erase)
|
#define erasechar() (_tty.sg_erase)
|
||||||
@@ -167,20 +167,11 @@ int wgetch (WINDOW *);
|
|||||||
char *wstandout (WINDOW *);
|
char *wstandout (WINDOW *);
|
||||||
char *wstandend (WINDOW *);
|
char *wstandend (WINDOW *);
|
||||||
int touchwin (WINDOW *);
|
int touchwin (WINDOW *);
|
||||||
int touchline (WINDOW *, int, int, int);
|
int touchline (WINDOW *, int, int);
|
||||||
void box (WINDOW *, char, char);
|
int box (WINDOW *, char, char);
|
||||||
void endwin (void);
|
void endwin (void);
|
||||||
int printw (char *, ...);
|
int printw (char *fmt, ...);
|
||||||
int wprintw (WINDOW *, char *, ...);
|
int wprintw (WINDOW *win, char *fmt, ...);
|
||||||
int scroll (WINDOW *);
|
|
||||||
void wclrtoeol (WINDOW *);
|
|
||||||
void werase (WINDOW *);
|
|
||||||
int setterm (char *);
|
|
||||||
int delwin (WINDOW *);
|
|
||||||
int waddstr (WINDOW *, char *);
|
|
||||||
int wgetstr (WINDOW *, char *);
|
|
||||||
int wdeleteln (WINDOW *);
|
|
||||||
void mvcur(int ly, int lx, int y, int x);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used to be in unctrl.h.
|
* Used to be in unctrl.h.
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ struct group { /* see getgrent(3) */
|
|||||||
char **gr_mem;
|
char **gr_mem;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct group *getgrent(void);
|
struct group *getgrent(), *getgrgid(), *getgrnam();
|
||||||
struct group *getgrnam(const char *name);
|
|
||||||
struct group *getgrgid(gid_t gid);
|
|
||||||
void setgrent(void);
|
|
||||||
void endgrent(void);
|
|
||||||
int setgroups(size_t size, const gid_t *list);
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#ifndef _KMEM_H
|
|
||||||
#define _KMEM_H
|
|
||||||
|
|
||||||
extern dev_t kmemdev();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -35,7 +35,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Symbol table entry format.
|
* Symbol table entry format. The #ifdef's are so that programs including
|
||||||
|
* nlist.h can initialize nlist structures statically.
|
||||||
*/
|
*/
|
||||||
struct nlist {
|
struct nlist {
|
||||||
char *n_name; /* In memory address of symbol name,
|
char *n_name; /* In memory address of symbol name,
|
||||||
@@ -55,12 +56,13 @@ struct nlist {
|
|||||||
#define N_BSS 0x04 /* bss segment */
|
#define N_BSS 0x04 /* bss segment */
|
||||||
#define N_STRNG 0x05 /* string segment (for assembler) */
|
#define N_STRNG 0x05 /* string segment (for assembler) */
|
||||||
#define N_COMM 0x06 /* .comm segment (for assembler) */
|
#define N_COMM 0x06 /* .comm segment (for assembler) */
|
||||||
|
#define N_REG 0x14 /* register symbol */
|
||||||
#define N_FN 0x1f /* file name */
|
#define N_FN 0x1f /* file name */
|
||||||
|
|
||||||
#define N_TYPE 0x1f /* mask for all the type bits */
|
|
||||||
#define N_EXT 0x20 /* external (global) bit, OR'ed in */
|
#define N_EXT 0x20 /* external (global) bit, OR'ed in */
|
||||||
#define N_WEAK 0x40 /* weak reference bit, OR'ed in */
|
#define N_TYPE 0x1f /* mask for all the type bits */
|
||||||
#define N_LOC 0x80 /* local, for assembler */
|
|
||||||
|
#define N_FORMAT "%06o" /* namelist value format; XXX */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get symbols from a file.
|
* Get symbols from a file.
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
struct ranlib {
|
struct ranlib {
|
||||||
int ran_len; /* 1 byte - name length in bytes */
|
int ran_len; /* 1 byte - name length in bytes */
|
||||||
unsigned ran_off; /* 4 bytes - file offset */
|
off_t ran_off; /* 4 bytes - file offset */
|
||||||
char *ran_name; /* in memory symbol name */
|
char *ran_name; /* in memory symbol name */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,29 +14,9 @@
|
|||||||
* 9 - $ra - return address
|
* 9 - $ra - return address
|
||||||
* 10 - $gp - global data pointer
|
* 10 - $gp - global data pointer
|
||||||
* 11 - $sp - stack pointer
|
* 11 - $sp - stack pointer
|
||||||
* 12 - signal mask saved
|
|
||||||
* 13 - signal mask
|
|
||||||
*/
|
*/
|
||||||
typedef int jmp_buf [14];
|
typedef int jmp_buf [12];
|
||||||
typedef jmp_buf sigjmp_buf;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Save and restore only CPU state.
|
|
||||||
* Signal mask is not saved.
|
|
||||||
*/
|
|
||||||
int _setjmp (jmp_buf env);
|
|
||||||
void _longjmp (jmp_buf env, int val);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Save and restore CPU state and signal mask.
|
|
||||||
*/
|
|
||||||
int setjmp (jmp_buf env);
|
int setjmp (jmp_buf env);
|
||||||
void longjmp (jmp_buf env, int val);
|
void longjmp (jmp_buf env, int val);
|
||||||
|
|
||||||
/*
|
|
||||||
* Save and restore CPU state and optionally a signal mask.
|
|
||||||
* Signal mask is saved only when savesigs is nonzero.
|
|
||||||
*/
|
|
||||||
int sigsetjmp (sigjmp_buf env, int savesigs);
|
|
||||||
void siglongjmp (sigjmp_buf env, int val);
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* SmallC: interface to curses library.
|
|
||||||
*/
|
|
||||||
#define WINDOW int
|
|
||||||
|
|
||||||
extern WINDOW *stdscr, *curscr;
|
|
||||||
|
|
||||||
extern int LINES, COLS;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pseudo functions for standard screen
|
|
||||||
*/
|
|
||||||
#define addch(ch) waddch(stdscr, ch)
|
|
||||||
#define getch() wgetch(stdscr)
|
|
||||||
#define addstr(str) waddstr(stdscr, str)
|
|
||||||
#define getstr(str) wgetstr(stdscr, str)
|
|
||||||
#define move(y, x) wmove(stdscr, y, x)
|
|
||||||
#define clear() wclear(stdscr)
|
|
||||||
#define erase() werase(stdscr)
|
|
||||||
#define clrtobot() wclrtobot(stdscr)
|
|
||||||
#define clrtoeol() wclrtoeol(stdscr)
|
|
||||||
#define insertln() winsertln(stdscr)
|
|
||||||
#define deleteln() wdeleteln(stdscr)
|
|
||||||
#define refresh() wrefresh(stdscr)
|
|
||||||
#define inch() winch(stdscr)
|
|
||||||
#define insch(c) winsch(stdscr,c)
|
|
||||||
#define delch() wdelch(stdscr)
|
|
||||||
#define standout() wstandout(stdscr)
|
|
||||||
#define standend() wstandend(stdscr)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* mv functions
|
|
||||||
*/
|
|
||||||
#define mvwaddch(win,y,x,ch) wmove(win,y,x) == 0 ? 0 : waddch(win,ch)
|
|
||||||
#define mvwgetch(win,y,x) wmove(win,y,x) == 0 ? 0 : wgetch(win)
|
|
||||||
#define mvwaddstr(win,y,x,str) wmove(win,y,x) == 0 ? 0 : waddstr(win,str)
|
|
||||||
#define mvwgetstr(win,y,x,str) wmove(win,y,x) == 0 ? 0 : wgetstr(win,str)
|
|
||||||
#define mvwinch(win,y,x) wmove(win,y,x) == 0 ? 0 : winch(win)
|
|
||||||
#define mvwdelch(win,y,x) wmove(win,y,x) == 0 ? 0 : wdelch(win)
|
|
||||||
#define mvwinsch(win,y,x,c) wmove(win,y,x) == 0 ? 0 : winsch(win,c)
|
|
||||||
#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
|
|
||||||
#define mvgetch(y,x) mvwgetch(stdscr,y,x)
|
|
||||||
#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
|
|
||||||
#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
|
|
||||||
#define mvinch(y,x) mvwinch(stdscr,y,x)
|
|
||||||
#define mvdelch(y,x) mvwdelch(stdscr,y,x)
|
|
||||||
#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
|
|
||||||
|
|
||||||
#ifdef TODO
|
|
||||||
|
|
||||||
#define TRUE (1)
|
|
||||||
#define FALSE (0)
|
|
||||||
#define ERR (0)
|
|
||||||
#define OK (1)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Capabilities from termcap
|
|
||||||
*/
|
|
||||||
extern int AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
|
|
||||||
XB, XN, XT, XS, XX;
|
|
||||||
extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
|
|
||||||
*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
|
|
||||||
*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
|
|
||||||
*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
|
|
||||||
*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
|
|
||||||
*VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
|
|
||||||
*LEFT_PARM, *RIGHT_PARM;
|
|
||||||
extern char PC;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* From the tty modes...
|
|
||||||
*/
|
|
||||||
extern int GT, NONL, UPPERCASE, normtty, _pfast;
|
|
||||||
|
|
||||||
extern int My_term, _echoit, _rawmode, _endwin;
|
|
||||||
|
|
||||||
extern char *Def_term, ttytype[];
|
|
||||||
|
|
||||||
extern int _tty_ch, _res_flg;
|
|
||||||
|
|
||||||
extern SGTTY _tty;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pseudo functions
|
|
||||||
*/
|
|
||||||
#define clearok(win,bf) (win->_clear = bf)
|
|
||||||
#define leaveok(win,bf) (win->_leave = bf)
|
|
||||||
#define scrollok(win,bf) (win->_scroll = bf)
|
|
||||||
#define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
|
|
||||||
#define getyx(win,y,x) y = win->_cury, x = win->_curx
|
|
||||||
#define winch(win) (win->_y[win->_cury][win->_curx] & 0177)
|
|
||||||
|
|
||||||
#define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
#define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
#define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty))
|
|
||||||
#define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), _res_flg = _tty.sg_flags)
|
|
||||||
#define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
|
|
||||||
#define erasechar() (_tty.sg_erase)
|
|
||||||
#define killchar() (_tty.sg_kill)
|
|
||||||
#define baudrate() (_tty.sg_ospeed)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used to be in unctrl.h.
|
|
||||||
*/
|
|
||||||
#define unctrl(c) _unctrl[(c) & 0177]
|
|
||||||
extern char *_unctrl[];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
|
|
||||||
/* open-only flags */
|
|
||||||
#define O_RDONLY 0x0000 /* open for reading only */
|
|
||||||
#define O_WRONLY 0x0001 /* open for writing only */
|
|
||||||
#define O_RDWR 0x0002 /* open for reading and writing */
|
|
||||||
#define O_ACCMODE 0x0003 /* mask for above modes */
|
|
||||||
|
|
||||||
#define O_NONBLOCK 0x0004 /* no delay */
|
|
||||||
#define O_APPEND 0x0008 /* set append mode */
|
|
||||||
#define O_SHLOCK 0x0010 /* open with shared file lock */
|
|
||||||
#define O_EXLOCK 0x0020 /* open with exclusive file lock */
|
|
||||||
#define O_ASYNC 0x0040 /* signal pgrp when data ready */
|
|
||||||
#define O_FSYNC 0x0080 /* synchronous writes */
|
|
||||||
#define O_CREAT 0x0200 /* create if nonexistant */
|
|
||||||
#define O_TRUNC 0x0400 /* truncate to zero length */
|
|
||||||
#define O_EXCL 0x0800 /* error if already exists */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Constants used for fcntl(2)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* command values */
|
|
||||||
#define F_DUPFD 0 /* duplicate file descriptor */
|
|
||||||
#define F_GETFD 1 /* get file descriptor flags */
|
|
||||||
#define F_SETFD 2 /* set file descriptor flags */
|
|
||||||
#define F_GETFL 3 /* get file status flags */
|
|
||||||
#define F_SETFL 4 /* set file status flags */
|
|
||||||
#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
|
|
||||||
#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
|
|
||||||
|
|
||||||
/* file descriptor flags (F_GETFD, F_SETFD) */
|
|
||||||
#define FD_CLOEXEC 1 /* close-on-exec flag */
|
|
||||||
|
|
||||||
/* lock operations for flock() */
|
|
||||||
#define LOCK_SH 1 /* shared file lock */
|
|
||||||
#define LOCK_EX 2 /* exclusive file lock */
|
|
||||||
#define LOCK_NB 4 /* don't block when locking */
|
|
||||||
#define LOCK_UN 8 /* unlock file */
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1986 Regents of the University of California.
|
|
||||||
* All rights reserved. The Berkeley software License Agreement
|
|
||||||
* specifies the terms and conditions for redistribution.
|
|
||||||
*/
|
|
||||||
#ifndef NSIG
|
|
||||||
|
|
||||||
#define NSIG 32
|
|
||||||
|
|
||||||
#define SIGHUP 1 /* hangup */
|
|
||||||
#define SIGINT 2 /* interrupt */
|
|
||||||
#define SIGQUIT 3 /* quit */
|
|
||||||
#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
|
||||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
|
||||||
#define SIGIOT 6 /* IOT instruction */
|
|
||||||
#define SIGABRT SIGIOT /* compatibility */
|
|
||||||
#define SIGEMT 7 /* EMT instruction */
|
|
||||||
#define SIGFPE 8 /* floating point exception */
|
|
||||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
|
||||||
#define SIGBUS 10 /* bus error */
|
|
||||||
#define SIGSEGV 11 /* segmentation violation */
|
|
||||||
#define SIGSYS 12 /* bad argument to system call */
|
|
||||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
|
||||||
#define SIGALRM 14 /* alarm clock */
|
|
||||||
#define SIGTERM 15 /* software termination signal from kill */
|
|
||||||
#define SIGURG 16 /* urgent condition on IO channel */
|
|
||||||
#define SIGSTOP 17 /* sendable stop signal not from tty */
|
|
||||||
#define SIGTSTP 18 /* stop signal from tty */
|
|
||||||
#define SIGCONT 19 /* continue a stopped process */
|
|
||||||
#define SIGCHLD 20 /* to parent on child stop or exit */
|
|
||||||
#define SIGCLD SIGCHLD /* compatibility */
|
|
||||||
#define SIGTTIN 21 /* to readers pgrp upon background tty read */
|
|
||||||
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
|
|
||||||
#define SIGIO 23 /* input/output possible signal */
|
|
||||||
#define SIGXCPU 24 /* exceeded CPU time limit */
|
|
||||||
#define SIGXFSZ 25 /* exceeded file size limit */
|
|
||||||
#define SIGVTALRM 26 /* virtual time alarm */
|
|
||||||
#define SIGPROF 27 /* profiling time alarm */
|
|
||||||
#define SIGWINCH 28 /* window size changes */
|
|
||||||
#define SIGUSR1 30 /* user defined signal 1 */
|
|
||||||
#define SIGUSR2 31 /* user defined signal 2 */
|
|
||||||
|
|
||||||
#define SIG_ERR -1
|
|
||||||
#define SIG_DFL 0
|
|
||||||
#define SIG_IGN 1
|
|
||||||
#define BADSIG SIG_ERR
|
|
||||||
|
|
||||||
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
|
|
||||||
#define SA_RESTART 0x0002 /* restart system on signal return */
|
|
||||||
#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
|
|
||||||
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flags for sigprocmask:
|
|
||||||
*/
|
|
||||||
#define SIG_BLOCK 1 /* block specified signal set */
|
|
||||||
#define SIG_UNBLOCK 2 /* unblock specified signal set */
|
|
||||||
#define SIG_SETMASK 3 /* set specified signal set */
|
|
||||||
|
|
||||||
#define MINSIGSTKSZ 128 /* minimum allowable stack */
|
|
||||||
#define SIGSTKSZ (MINSIGSTKSZ + 384) /* recommended stack size */
|
|
||||||
|
|
||||||
#define SV_ONSTACK SA_ONSTACK /* take signal on signal stack */
|
|
||||||
#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macro for converting signal number to a mask suitable for
|
|
||||||
* sigblock().
|
|
||||||
*/
|
|
||||||
#define sigmask(m) (1L << ((m)-1))
|
|
||||||
#define sigaddset(set, signo) (*(set) |= 1L << ((signo) - 1), 0)
|
|
||||||
#define sigdelset(set, signo) (*(set) &= ~(1L << ((signo) - 1)), 0)
|
|
||||||
#define sigemptyset(set) (*(set) = (sigset_t)0, (int)0)
|
|
||||||
#define sigfillset(set) (*(set) = ~(sigset_t)0, (int)0)
|
|
||||||
#define sigismember(set, signo) ((*(set) & (1L << ((signo) - 1))) != 0)
|
|
||||||
|
|
||||||
#endif /* NSIG */
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* SmallC: interface to stdio library.
|
|
||||||
*/
|
|
||||||
#define BUFSIZ 1024
|
|
||||||
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FILE int
|
|
||||||
#define EOF (-1)
|
|
||||||
|
|
||||||
extern int _iob[];
|
|
||||||
|
|
||||||
#define stdin (&_iob[0])
|
|
||||||
#define stdout (&_iob[5])
|
|
||||||
#define stderr (&_iob[10])
|
|
||||||
|
|
||||||
#define SEEK_SET 0 /* set file offset to offset */
|
|
||||||
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
|
||||||
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
|
||||||
|
|
||||||
#define getc fgetc
|
|
||||||
#define putc fputc
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Ioctl definitions for GPIO driver.
|
|
||||||
*/
|
|
||||||
#define GPIO_PORT(n) (n) /* port number */
|
|
||||||
#define GPIO_PORTA 0
|
|
||||||
#define GPIO_PORTB 1
|
|
||||||
#define GPIO_PORTC 2
|
|
||||||
#define GPIO_PORTD 3
|
|
||||||
#define GPIO_PORTE 4
|
|
||||||
#define GPIO_PORTF 5
|
|
||||||
#define GPIO_PORTG 6
|
|
||||||
|
|
||||||
#define GPIO_CONFIN 0x20016700 /* configure as input */
|
|
||||||
#define GPIO_CONFOUT 0x20026700 /* configure as output */
|
|
||||||
#define GPIO_CONFOD 0x20046700 /* configure as open drain */
|
|
||||||
#define GPIO_DECONF 0x20086700 /* deconfigure */
|
|
||||||
#define GPIO_STORE 0x20106700 /* store all outputs */
|
|
||||||
#define GPIO_SET 0x20206700 /* set to 1 by mask */
|
|
||||||
#define GPIO_CLEAR 0x20406700 /* set to 0 by mask */
|
|
||||||
#define GPIO_INVERT 0x20806700 /* invert by mask */
|
|
||||||
#define GPIO_POLL 0x21006700 /* poll */
|
|
||||||
#define GPIO_LOL 0x82006700 /* display lol picture */
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Ioctl definitions for SPI driver.
|
|
||||||
*/
|
|
||||||
#define SPICTL_SETMODE 0x20007000 /* set SPI mode */
|
|
||||||
#define SPICTL_SETRATE 0x20007001 /* set clock rate, kHz */
|
|
||||||
#define SPICTL_SETSELPIN 0x20007002 /* set select pin */
|
|
||||||
#define SPICTL_IO8(n) (0xc0007003 | (n)<<16) /* transfer n*8 bits */
|
|
||||||
#define SPICTL_IO16(n) (0xc0007004 | (n)<<16) /* transfer n*16 bits */
|
|
||||||
#define SPICTL_IO32(n) (0xc0007005 | (n)<<16) /* transfer n*32 bits */
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* SmallC: interface to wiznet library.
|
|
||||||
*/
|
|
||||||
#define MAX_SOCK_NUM 4 /* Max number of sockets per chip */
|
|
||||||
#define CLIENT_SIZE 3 /* Size of client structure in words */
|
|
||||||
#define UDP_SIZE 2 /* Size of UDP structure in words */
|
|
||||||
|
|
||||||
extern unsigned _socket_port[];
|
|
||||||
|
|
||||||
extern unsigned _client_srcport;
|
|
||||||
|
|
||||||
extern unsigned _server_port;
|
|
||||||
@@ -4,49 +4,27 @@
|
|||||||
#ifndef _STDARG_H
|
#ifndef _STDARG_H
|
||||||
#define _STDARG_H
|
#define _STDARG_H
|
||||||
|
|
||||||
/*
|
/* Define __gnuc_va_list. */
|
||||||
* Define va_start, va_arg, va_end, va_copy.
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__) /* Gnu C */
|
|
||||||
# define va_start(ap, last) __builtin_va_start((ap), last)
|
|
||||||
# define va_arg(ap, type) __builtin_va_arg((ap), type)
|
|
||||||
# define va_end(ap) __builtin_va_end((ap))
|
|
||||||
# define va_copy(dest, src) __builtin_va_copy((dest), (src))
|
|
||||||
|
|
||||||
#elif defined(__PCC__) /* PCC */
|
#ifndef __GNUC_VA_LIST
|
||||||
# define va_start(ap, last) __builtin_stdarg_start((ap), last)
|
#define __GNUC_VA_LIST
|
||||||
# define va_arg(ap, type) __builtin_va_arg((ap), type)
|
typedef __builtin_va_list __gnuc_va_list;
|
||||||
# define va_end(ap) __builtin_va_end((ap))
|
|
||||||
# define va_copy(dest, src) __builtin_va_copy((dest), (src))
|
|
||||||
|
|
||||||
#else /* SmallerC, LCC */
|
|
||||||
# define va_start(ap, last) (ap = ((char*)&(last) + \
|
|
||||||
(((sizeof(last) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))))
|
|
||||||
# define va_arg(ap, type) ((type*)(ap += \
|
|
||||||
sizeof(type) == sizeof(int) ? sizeof(type) : \
|
|
||||||
(-(int)(ap) & (sizeof(type) - 1)) + sizeof(type)))[-1]
|
|
||||||
# define va_end(ap)
|
|
||||||
# define va_copy(dest, src) (dest = (src))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
#ifdef __GNUC__
|
||||||
* Define va_list.
|
# define va_start(ap, last) __builtin_va_start((ap), last)
|
||||||
*/
|
|
||||||
#ifndef _VA_LIST_T
|
|
||||||
# define _VA_LIST_T
|
|
||||||
# if defined(__GNUC__) || defined(__PCC__)
|
|
||||||
typedef __builtin_va_list va_list;
|
|
||||||
# else
|
|
||||||
typedef char *va_list;
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __PCC__
|
||||||
|
# define va_start(ap, last) __builtin_stdarg_start((ap), last)
|
||||||
|
#endif
|
||||||
|
#define va_arg(ap, type) __builtin_va_arg((ap), type)
|
||||||
|
#define va_end(ap) __builtin_va_end((ap))
|
||||||
|
#define va_copy(dest, src) __builtin_va_copy((dest), (src))
|
||||||
|
|
||||||
/*
|
|
||||||
* Define __gnuc_va_list.
|
#ifndef _VA_LIST
|
||||||
*/
|
#define _VA_LIST
|
||||||
#if defined(__GNUC__) && !defined(__GNUC_VA_LIST)
|
typedef __gnuc_va_list va_list;
|
||||||
# define __GNUC_VA_LIST
|
|
||||||
typedef __builtin_va_list __gnuc_va_list;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* not _STDARG_H */
|
#endif /* not _STDARG_H */
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
/* Offset of member MEMBER in a struct of type TYPE. */
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ > 3
|
|
||||||
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
|
|
||||||
#else
|
|
||||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER)
|
|
||||||
#endif
|
|
||||||
@@ -14,7 +14,7 @@ extern struct _iobuf {
|
|||||||
char *_base; /* ditto */
|
char *_base; /* ditto */
|
||||||
int _bufsiz;
|
int _bufsiz;
|
||||||
short _flag;
|
short _flag;
|
||||||
short _file;
|
char _file; /* should be short */
|
||||||
} _iob[];
|
} _iob[];
|
||||||
|
|
||||||
#define _IOREAD 01
|
#define _IOREAD 01
|
||||||
@@ -73,7 +73,6 @@ FILE *fopen (const char *, const char *);
|
|||||||
FILE *fdopen (int, const char *);
|
FILE *fdopen (int, const char *);
|
||||||
FILE *freopen (const char *, const char *, FILE *);
|
FILE *freopen (const char *, const char *, FILE *);
|
||||||
FILE *popen (const char *, const char *);
|
FILE *popen (const char *, const char *);
|
||||||
FILE *tmpfile (void);
|
|
||||||
int fclose (FILE *);
|
int fclose (FILE *);
|
||||||
long ftell (FILE *);
|
long ftell (FILE *);
|
||||||
int fflush (FILE *);
|
int fflush (FILE *);
|
||||||
@@ -94,8 +93,6 @@ int setvbuf (FILE *, char *, int, size_t);
|
|||||||
int fseek (FILE *, long, int);
|
int fseek (FILE *, long, int);
|
||||||
void rewind (FILE *);
|
void rewind (FILE *);
|
||||||
int remove (const char *);
|
int remove (const char *);
|
||||||
int getw(FILE *stream);
|
|
||||||
int putw(int w, FILE *stream);
|
|
||||||
|
|
||||||
size_t fread (void *, size_t, size_t, FILE *);
|
size_t fread (void *, size_t, size_t, FILE *);
|
||||||
size_t fwrite (const void *, size_t, size_t, FILE *);
|
size_t fwrite (const void *, size_t, size_t, FILE *);
|
||||||
@@ -110,12 +107,7 @@ int scanf (const char *, ...);
|
|||||||
int sscanf (const char *, const char *, ...);
|
int sscanf (const char *, const char *, ...);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# ifdef __GNUC__
|
#define va_list __builtin_va_list /* For GCC */
|
||||||
# define va_list __builtin_va_list /* For Gnu C */
|
|
||||||
# endif
|
|
||||||
# ifdef __SMALLER_C__
|
|
||||||
# define va_list char * /* For Smaller C */
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int vfprintf (FILE *, const char *, va_list);
|
int vfprintf (FILE *, const char *, va_list);
|
||||||
@@ -131,7 +123,7 @@ int _doprnt (const char *, va_list, FILE *);
|
|||||||
int _doscan (FILE *, const char *, va_list);
|
int _doscan (FILE *, const char *, va_list);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# undef va_list
|
#undef va_list
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void perror (const char *);
|
void perror (const char *);
|
||||||
|
|||||||
@@ -54,51 +54,48 @@
|
|||||||
|
|
||||||
#define RAND_MAX 0x7fff
|
#define RAND_MAX 0x7fff
|
||||||
|
|
||||||
void abort (void);
|
void abort();
|
||||||
int abs (int);
|
int abs (int);
|
||||||
int atexit (void (*)(void));
|
int atexit (void (*)(void));
|
||||||
int atoi (const char *);
|
double atof();
|
||||||
long atol (const char *);
|
int atoi();
|
||||||
|
long atol();
|
||||||
void *calloc (size_t, size_t);
|
void *calloc (size_t, size_t);
|
||||||
void exit (int);
|
void exit (int);
|
||||||
void free (void *);
|
void free (void *);
|
||||||
char *getenv (const char *);
|
char *getenv();
|
||||||
long labs (long);
|
|
||||||
void *malloc (size_t);
|
void *malloc (size_t);
|
||||||
char *mktemp (char *);
|
char *mktemp (char *);
|
||||||
int mkstemp (char *);
|
int mkstemp (char *);
|
||||||
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
|
void qsort();
|
||||||
int rand (void);
|
int rand();
|
||||||
void *realloc (void*, size_t);
|
void *realloc (void*, size_t);
|
||||||
void srand (unsigned);
|
void srand();
|
||||||
long strtol (const char *, char **, int);
|
double strtod();
|
||||||
unsigned long strtoul (const char *, char **, int);
|
long strtol();
|
||||||
int system (const char *);
|
unsigned long strtoul();
|
||||||
|
int system();
|
||||||
|
|
||||||
int putenv (char *string);
|
int putenv (char *string);
|
||||||
int setenv (const char *name, const char *value, int overwrite);
|
int setenv (const char *name, const char *value, int overwrite);
|
||||||
int unsetenv (const char *name);
|
int unsetenv (const char *name);
|
||||||
char *_findenv (const char *name, int *offset);
|
char *_findenv (const char *name, int *offset);
|
||||||
|
|
||||||
void *alloca (size_t size);
|
void *alloca();
|
||||||
|
|
||||||
int daemon (int, int);
|
int daemon();
|
||||||
char *devname (dev_t dev, mode_t type);
|
char *devname();
|
||||||
int getloadavg (unsigned loadavg[], int nelem);
|
int getloadavg(unsigned loadavg[], int nelem);
|
||||||
|
|
||||||
extern char *suboptarg; /* getsubopt(3) external variable */
|
extern char *suboptarg; /* getsubopt(3) external variable */
|
||||||
int getsubopt (char **, char **, char **);
|
int getsubopt();
|
||||||
|
|
||||||
long random (void);
|
long random (void);
|
||||||
char *setstate (char *);
|
char *setstate (char *);
|
||||||
void srandom (unsigned);
|
void srandom (unsigned);
|
||||||
|
|
||||||
#ifndef __SMALLER_C__
|
char *ecvt (double, int, int *, int *);
|
||||||
double atof (const char *);
|
char *fcvt (double, int, int *, int *);
|
||||||
double strtod (const char *, char **);
|
char *gcvt (double, int, char *);
|
||||||
char *ecvt (double, int, int *, int *);
|
|
||||||
char *fcvt (double, int, int *, int *);
|
|
||||||
char *gcvt (double, int, char *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _STDLIB_H_ */
|
#endif /* _STDLIB_H_ */
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ char *strtok_r (char *, const char *, char **);
|
|||||||
size_t strcspn (const char *, const char *);
|
size_t strcspn (const char *, const char *);
|
||||||
size_t strspn (const char *, const char *);
|
size_t strspn (const char *, const char *);
|
||||||
|
|
||||||
char *strerror (int);
|
const char *strerror (int);
|
||||||
const char *syserrlst (int);
|
const char *syserrlst (int);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
int bcmp(const void *, const void *, size_t);
|
int bcmp(const void *, const void *, size_t);
|
||||||
void bcopy(const void *, void *, size_t);
|
void bcopy(const void *, void *, size_t);
|
||||||
void bzero(void *, unsigned long);
|
void bzero(void *, size_t);
|
||||||
int ffs(int);
|
int ffs(int);
|
||||||
char *index(const char *, int);
|
char *index(const char *, int);
|
||||||
char *rindex(const char *, int);
|
char *rindex(const char *, int);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
#define SYS_getegid 48
|
#define SYS_getegid 48
|
||||||
#define SYS_setgid 49
|
#define SYS_setgid 49
|
||||||
#define SYS_setegid 50
|
#define SYS_setegid 50
|
||||||
#define SYS_kmemdev 51
|
/* 51 is old; acct */
|
||||||
#define SYS_phys 52
|
#define SYS_phys 52
|
||||||
#define SYS_lock 53
|
#define SYS_lock 53
|
||||||
#define SYS_ioctl 54
|
#define SYS_ioctl 54
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
#define SYS_rdglob 70
|
#define SYS_rdglob 70
|
||||||
#define SYS_wrglob 71
|
#define SYS_wrglob 71
|
||||||
/* 71 is unused 4.3: mmap */
|
/* 71 is unused 4.3: mmap */
|
||||||
#define SYS_msec 72 /* 72 is unused 4.3: vadvise */
|
/* 72 is unused 4.3: vadvise */
|
||||||
/* 73 is unused 4.3: munmap */
|
/* 73 is unused 4.3: munmap */
|
||||||
/* 74 is unused 4.3: mprotect */
|
/* 74 is unused 4.3: mprotect */
|
||||||
/* 75 is unused 4.3: madvise */
|
/* 75 is unused 4.3: madvise */
|
||||||
|
|||||||
@@ -2,9 +2,13 @@
|
|||||||
#define _TERM_H
|
#define _TERM_H
|
||||||
|
|
||||||
extern int tgetent(char *, char *);
|
extern int tgetent(char *, char *);
|
||||||
|
extern int tnchktc();
|
||||||
|
extern int tnamatch(char *);
|
||||||
|
extern char *tskip(register char *);
|
||||||
extern int tgetnum(char *);
|
extern int tgetnum(char *);
|
||||||
extern int tgetflag(char *);
|
extern int tgetflag(char *);
|
||||||
extern char *tgetstr(char *, char **);
|
extern char *tgetstr(char *, char **);
|
||||||
|
extern char *tdecode(register char *, char **);
|
||||||
extern char *tgoto(char *, int, int);
|
extern char *tgoto(char *, int, int);
|
||||||
extern int tputs(register char *, int, int (*)());
|
extern int tputs(register char *, int, int (*)());
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ struct ttyent { /* see getttyent(3) */
|
|||||||
|
|
||||||
struct ttyent *getttyent (void);
|
struct ttyent *getttyent (void);
|
||||||
struct ttyent *getttynam (const char *name);
|
struct ttyent *getttynam (const char *name);
|
||||||
void setttyent (void);
|
int setttyent (void);
|
||||||
void endttyent (void);
|
int endttyent (void);
|
||||||
|
|||||||
@@ -97,4 +97,4 @@ struct tzhead {
|
|||||||
** that will probably do.
|
** that will probably do.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ void setusershell();
|
|||||||
void sync();
|
void sync();
|
||||||
unsigned int ualarm();
|
unsigned int ualarm();
|
||||||
void usleep();
|
void usleep();
|
||||||
int pause (void);
|
|
||||||
pid_t vfork();
|
pid_t vfork();
|
||||||
|
|
||||||
int pipe (int pipefd[2]);
|
int pipe (int pipefd[2]);
|
||||||
@@ -108,18 +107,11 @@ int chown (const char *path, uid_t owner, gid_t group);
|
|||||||
int nice (int inc);
|
int nice (int inc);
|
||||||
int setuid (uid_t uid);
|
int setuid (uid_t uid);
|
||||||
int setgid (gid_t gid);
|
int setgid (gid_t gid);
|
||||||
int seteuid (uid_t euid);
|
|
||||||
int setegid (gid_t egid);
|
|
||||||
int setreuid (uid_t ruid, uid_t euid);
|
|
||||||
int setregid (gid_t rgid, gid_t egid);
|
|
||||||
int isatty (int fd);
|
int isatty (int fd);
|
||||||
int chdir (const char *path);
|
int chdir (const char *path);
|
||||||
int fchdir (int fd);
|
int fchdir (int fd);
|
||||||
int chflags (const char *path, u_long flags);
|
int chflags (const char *path, u_long flags);
|
||||||
int fchflags (int fd, u_long flags);
|
int fchflags (int fd, u_long flags);
|
||||||
int getgroups (int size, gid_t list[]);
|
|
||||||
int getdtablesize (void);
|
|
||||||
int rmdir (const char *pathname);
|
|
||||||
|
|
||||||
struct stat;
|
struct stat;
|
||||||
int stat (const char *path, struct stat *buf);
|
int stat (const char *path, struct stat *buf);
|
||||||
@@ -143,12 +135,7 @@ extern char *optarg; /* getopt(3) external variables */
|
|||||||
extern int opterr, optind, optopt;
|
extern int opterr, optind, optopt;
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# ifdef __GNUC__
|
#define va_list __builtin_va_list /* For GCC */
|
||||||
# define va_list __builtin_va_list /* For Gnu C */
|
|
||||||
# endif
|
|
||||||
# ifdef __SMALLER_C__
|
|
||||||
# define va_list char * /* For Smaller C */
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void err (int eval, const char *fmt, ...);
|
void err (int eval, const char *fmt, ...);
|
||||||
@@ -161,6 +148,6 @@ void vwarn (const char *fmt, va_list ap);
|
|||||||
void vwarnx (const char *fmt, va_list ap);
|
void vwarnx (const char *fmt, va_list ap);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# undef va_list
|
#undef va_list
|
||||||
#endif
|
#endif
|
||||||
#endif /* !_UNISTD_H_ */
|
#endif /* !_UNISTD_H_ */
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "w5100.h"
|
#include "w5100.h"
|
||||||
|
|
||||||
extern unsigned _socket_port [MAX_SOCK_NUM];
|
extern uint16_t _socket_port [MAX_SOCK_NUM];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Opens a socket(TCP or UDP or IP_RAW mode)
|
* Opens a socket(TCP or UDP or IP_RAW mode)
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ void udp_stop (udp_t *u);
|
|||||||
/*
|
/*
|
||||||
* Send a packet to specified peer.
|
* Send a packet to specified peer.
|
||||||
*/
|
*/
|
||||||
unsigned udp_send_packet (udp_t *u, const uint8_t *data, unsigned len,
|
uint16_t udp_send_packet (udp_t *u, const uint8_t *data, unsigned len,
|
||||||
uint8_t *ip, unsigned port);
|
uint8_t *ip, unsigned port);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a zero-terminated string to specified peer.
|
* Send a zero-terminated string to specified peer.
|
||||||
*/
|
*/
|
||||||
unsigned udp_send_string (udp_t *u, const char *data,
|
uint16_t udp_send_string (udp_t *u, const char *data,
|
||||||
uint8_t *ip, unsigned port);
|
uint8_t *ip, unsigned port);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
14
lib/.gitignore
vendored
14
lib/.gitignore
vendored
@@ -1,14 +0,0 @@
|
|||||||
a.out.h
|
|
||||||
aout
|
|
||||||
ar
|
|
||||||
ar.h
|
|
||||||
as
|
|
||||||
ld
|
|
||||||
nlist.h
|
|
||||||
nm
|
|
||||||
ranlib
|
|
||||||
ranlib.h
|
|
||||||
retroImage
|
|
||||||
size
|
|
||||||
strip
|
|
||||||
gccdump.s
|
|
||||||
65
lib/Makefile
65
lib/Makefile
@@ -1,65 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ..; pwd)
|
|
||||||
SUBDIR = startup libc libcurses libtermlib libwiznet
|
|
||||||
PROG = ar as aout ld nm ranlib size strip
|
|
||||||
|
|
||||||
# Build a list of the host include directories.
|
|
||||||
CPP = $(shell gcc -print-prog-name=cc1)
|
|
||||||
HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
|
|
||||||
|
|
||||||
# Add system include path
|
|
||||||
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
|
|
||||||
HOSTINC += -I/usr/include
|
|
||||||
else
|
|
||||||
HOSTINC += -I/usr/include/i386-linux-gnu
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS += -nostdinc -fno-builtin -g -Werror -Wall -DCROSS -I. $(HOSTINC) \
|
|
||||||
-I$(TOPSRC)/include -I$(TOPSRC)/src/cmd/ar \
|
|
||||||
-I$(TOPSRC)/src/cmd/as
|
|
||||||
LDFLAGS += -g
|
|
||||||
|
|
||||||
AR_OBJS = ar.o append.o archive.o contents.o delete.o extract.o \
|
|
||||||
misc.o move.o print.o replace.o strmode.o
|
|
||||||
AOUT_OBJS = aout.o mips-dis.o
|
|
||||||
RANLIB_OBJS = ranlib.o archive.o
|
|
||||||
HEADERS = a.out.h ar.h nlist.h ranlib.h
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/cmd/ar $(TOPSRC)/src/cmd/as $(TOPSRC)/src/cmd/ld \
|
|
||||||
$(TOPSRC)/src/cmd/nm $(TOPSRC)/src/cmd/ranlib $(TOPSRC)/src/cmd
|
|
||||||
|
|
||||||
all install depend: $(HEADERS) $(SUBDIR) $(PROG)
|
|
||||||
-for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) DESTDIR=$(DESTDIR) $@; done
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o *.a *.h $(PROG) retroImage gccdump.s
|
|
||||||
for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) clean; done
|
|
||||||
|
|
||||||
ar: $(AR_OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(AR_OBJS) $(LIBS)
|
|
||||||
|
|
||||||
as: as.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
aout: $(AOUT_OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(AOUT_OBJS) $(LIBS)
|
|
||||||
|
|
||||||
ld: ld.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
nm: nm.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
ranlib: $(RANLIB_OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(RANLIB_OBJS) $(LIBS)
|
|
||||||
|
|
||||||
size: size.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
strip: strip.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
$(HEADERS):
|
|
||||||
-ln -s -f ../include/a.out.h .
|
|
||||||
-ln -s -f ../include/ar.h .
|
|
||||||
-ln -s -f ../include/nlist.h .
|
|
||||||
-ln -s -f ../include/ranlib.h .
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
LIBCDIR = $(TOPSRC)/src/libc
|
|
||||||
vpath %.S $(LIBCDIR)/mips/sys $(LIBCDIR)/mips/string $(LIBCDIR)/mips/gen \
|
|
||||||
$(LIBCDIR)/runtime
|
|
||||||
vpath %.c $(LIBCDIR)/mips/sys $(LIBCDIR)/gen $(LIBCDIR)/stdio \
|
|
||||||
$(LIBCDIR)/stdlib $(LIBCDIR)/string $(LIBCDIR)/inet \
|
|
||||||
$(LIBCDIR)/compat $(LIBCDIR)/runtime
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
ASFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -I$(LIBCDIR)/mips/sys
|
|
||||||
|
|
||||||
# modules which can not use SYSCALL and must be assembled from sources. The
|
|
||||||
# rest of the system calls are generated with printf(1) and do not have
|
|
||||||
# source files associated with them.
|
|
||||||
|
|
||||||
# libc/mips/sys
|
|
||||||
SYSOBJS = __sysctl.o accept.o access.o adjtime.o bind.o chdir.o \
|
|
||||||
chflags.o chmod.o chown.o chroot.o close.o connect.o dup.o \
|
|
||||||
dup2.o execve.o fchdir.o fchflags.o fchmod.o fchown.o \
|
|
||||||
fcntl.o flock.o fork.o fstat.o fsync.o ftruncate.o \
|
|
||||||
getdtablesize.o getgroups.o getitimer.o getsockname.o \
|
|
||||||
getpeername.o getpriority.o getrlimit.o getrusage.o \
|
|
||||||
getsockopt.o gettimeofday.o ioctl.o kill.o killpg.o link.o \
|
|
||||||
listen.o lstat.o mkdir.o mknod.o mount.o open.o pselect.o \
|
|
||||||
quota.o read.o readlink.o readv.o reboot.o recv.o \
|
|
||||||
recvfrom.o recvmsg.o rename.o rmdir.o select.o send.o \
|
|
||||||
sendmsg.o sendto.o setgroups.o setitimer.o setpgrp.o \
|
|
||||||
setpriority.o setquota.o setuid.o seteuid.o setgid.o \
|
|
||||||
setegid.o setrlimit.o setsockopt.o settimeofday.o \
|
|
||||||
shutdown.o sigaltstack.o socket.o socketpair.o stat.o \
|
|
||||||
symlink.o sigprocmask.o sigstack.o sigwait.o statfs.o \
|
|
||||||
fstatfs.o getfsstat.o truncate.o umount.o unlink.o \
|
|
||||||
utimes.o wait4.o write.o writev.o lseek.o sigsuspend.o \
|
|
||||||
getgid.o getegid.o getpgrp.o getpid.o getppid.o getuid.o \
|
|
||||||
geteuid.o profil.o sigpending.o sync.o ufetch.o ustore.o \
|
|
||||||
ucall.o umask.o vfork.o vhangup.o rdglob.o wrglob.o
|
|
||||||
|
|
||||||
OBJS = $(SYSOBJS) sbrk.o execl.o execle.o execv.o \
|
|
||||||
_exit.o _brk.o pipe.o ptrace.o sigaction.o
|
|
||||||
|
|
||||||
# libc/mips/string
|
|
||||||
ASFLAGS += -DLWHI=lwr -DLWLO=lwl -DSWHI=swr -DSWLO=swl
|
|
||||||
OBJS += bcopy.o bzero.o ffs.o memcpy.o memmove.o memset.o \
|
|
||||||
strlen.o bcmp.o index.o rindex.o strcmp.o
|
|
||||||
|
|
||||||
# libc/mips/gen
|
|
||||||
OBJS += _setjmp.o htonl.o htons.o
|
|
||||||
|
|
||||||
# libc/gen
|
|
||||||
OBJS += abort.o alarm.o atof.o atoi.o atol.o calloc.o closedir.o crypt.o \
|
|
||||||
ctime.o ctype_.o daemon.o devname.o ecvt.o err.o \
|
|
||||||
execvp.o fakcu.o frexp.o fstab.o gcvt.o getenv.o getgrent.o \
|
|
||||||
getgrgid.o getgrnam.o getlogin.o \
|
|
||||||
getgrouplist.o gethostname.o getpagesize.o \
|
|
||||||
getpass.o getpwent.o getloadavg.o getmntinfo.o \
|
|
||||||
getttyent.o getttynam.o getusershell.o getwd.o \
|
|
||||||
initgroups.o isatty.o isinff.o isnanf.o ldexp.o malloc.o mktemp.o \
|
|
||||||
modff.o ndbm.o nlist.o knlist.o opendir.o perror.o popen.o \
|
|
||||||
psignal.o qsort.o random.o readdir.o regex.o scandir.o \
|
|
||||||
seekdir.o setmode.o sethostname.o setenv.o siglist.o \
|
|
||||||
signal.o siginterrupt.o sigsetops.o \
|
|
||||||
sleep.o strcasecmp.o strftime.o swab.o sysctl.o syslog.o system.o \
|
|
||||||
strcat.o strncat.o strcpy.o strncpy.o strncmp.o \
|
|
||||||
telldir.o time.o timezone.o ttyname.o ttyslot.o ualarm.o usleep.o \
|
|
||||||
strdup.o uname.o wait.o wait3.o waitpid.o
|
|
||||||
|
|
||||||
# libc/stdio
|
|
||||||
OBJS += fgetc.o fgets.o fputc.o fputs.o gets.o puts.o \
|
|
||||||
clrerr.o doscan.o exit.o fdopen.o filbuf.o findiop.o \
|
|
||||||
flsbuf.o fopen.o fprintf.o fread.o freopen.o fseek.o \
|
|
||||||
ftell.o fwrite.o getchar.o getw.o printf.o putchar.o putw.o \
|
|
||||||
rew.o scanf.o setbuf.o setbuffer.o setvbuf.o snprintf.o sprintf.o \
|
|
||||||
strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o doprnt.o \
|
|
||||||
remove.o feof.o ferror.o fileno.o
|
|
||||||
|
|
||||||
# libc/stdlib
|
|
||||||
OBJS += getopt.o getsubopt.o strtol.o strtoul.o strtod.o
|
|
||||||
|
|
||||||
# libc/string
|
|
||||||
OBJS += strcspn.o strpbrk.o strerror.o strsep.o strspn.o \
|
|
||||||
strstr.o strtok.o strtok_r.o
|
|
||||||
|
|
||||||
# libc/inet
|
|
||||||
OBJS += inet_addr.o inet_network.o inet_netof.o \
|
|
||||||
inet_ntoa.o inet_lnaof.o inet_maddr.o
|
|
||||||
|
|
||||||
# libc/compat
|
|
||||||
OBJS += creat.o ftime.o gethostid.o gtty.o memccpy.o memchr.o \
|
|
||||||
memcmp.o memcpy.o memset.o nice.o pause.o rand.o \
|
|
||||||
sethostid.o setregid.o setreuid.o setrgid.o setruid.o \
|
|
||||||
sigcompat.o strchr.o strrchr.o stty.o times.o tmpnam.o \
|
|
||||||
utime.o
|
|
||||||
|
|
||||||
# libc/runtime
|
|
||||||
OBJS += addsf3.o comparesf2.o divsf3.o fixsfsi.o floatsisf.o \
|
|
||||||
mulsf3.o negsf2.o subsf3.o sc_case.o
|
|
||||||
|
|
||||||
all: ../libc.a
|
|
||||||
|
|
||||||
../libc.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
$(SYSOBJS): $(LIBCDIR)/mips/sys/SYS.h
|
|
||||||
@echo creating $*.o
|
|
||||||
@printf '#include "SYS.h"\nSYS($*)\n' | $(AS) $(ASFLAGS) - -c -o $*.o
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/libcurses
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
|
|
||||||
OBJS = addch.o addstr.o box.o clear.o clrtobot.o clrtoeol.o cr_put.o \
|
|
||||||
cr_tty.o curses.o delch.o deleteln.o delwin.o endwin.o erase.o \
|
|
||||||
fullname.o getch.o getstr.o idlok.o id_subwins.o initscr.o insch.o \
|
|
||||||
insertln.o longname.o move.o mvprintw.o mvscanw.o mvwin.o newwin.o \
|
|
||||||
overlay.o overwrite.o printw.o putchar.o refresh.o scanw.o scroll.o \
|
|
||||||
toucholap.o standout.o touchwin.o tstp.o unctrl.o
|
|
||||||
|
|
||||||
all: ../libcurses.a
|
|
||||||
|
|
||||||
../libcurses.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/libtermlib
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
|
|
||||||
OBJS = termcap.o tgoto.o tputs.o tcattr.o
|
|
||||||
|
|
||||||
all: ../libtermlib.a
|
|
||||||
|
|
||||||
../libtermlib.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/libwiznet
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
|
|
||||||
OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o
|
|
||||||
|
|
||||||
all: ../libwiznet.a
|
|
||||||
|
|
||||||
../libwiznet.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (c) 1987 Regents of the University of California.
|
|
||||||
# All rights reserved. The Berkeley software License Agreement
|
|
||||||
# specifies the terms and conditions for redistribution.
|
|
||||||
#
|
|
||||||
# crt0 Normal C run time startoff
|
|
||||||
#
|
|
||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
vpath %.c $(TOPSRC)/src/startup-mips
|
|
||||||
|
|
||||||
CFLAGS = -B$(TOPSRC)/lib/ -O -Wa,-x $(DEFS)
|
|
||||||
|
|
||||||
OBJS = ../crt0.o
|
|
||||||
|
|
||||||
all: $(OBJS)
|
|
||||||
|
|
||||||
../crt0.o: crt0.c
|
|
||||||
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OBJS) *~
|
|
||||||
1
libexec/.gitignore
vendored
1
libexec/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
1
sbin/.gitignore
vendored
1
sbin/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
3
share/.gitignore
vendored
3
share/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
re.help
|
|
||||||
misc
|
|
||||||
unixbench
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
all: ashello echo chello
|
all: ashello echo
|
||||||
|
|
||||||
ashello: ashello.o
|
ashello: ashello.o
|
||||||
$(LD) ashello.o -o $@
|
$(LD) ashello.o -o $@
|
||||||
@@ -11,4 +11,4 @@ echo: echo.o
|
|||||||
$(LD) $@.o -o $@
|
$(LD) $@.o -o $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o ashello echo chello *.dis *~
|
rm -f *.o ashello echo *.dis *~
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ CFLAGS += -Werror
|
|||||||
ASFLAGS += -DCROSS
|
ASFLAGS += -DCROSS
|
||||||
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
|
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
|
||||||
|
|
||||||
all: chello cplus echo stdarg
|
all: hello cplus
|
||||||
|
|
||||||
chello: chello.o
|
hello: hello.o
|
||||||
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
|
${CC} ${LDFLAGS} -o hello.elf hello.o ${LIBS}
|
||||||
${OBJDUMP} -S chello.elf > chello.dis
|
${OBJDUMP} -S hello.elf > hello.dis
|
||||||
${SIZE} chello.elf
|
${SIZE} hello.elf
|
||||||
${ELF2AOUT} chello.elf $@
|
${ELF2AOUT} hello.elf $@
|
||||||
|
|
||||||
cplus: cplus.o
|
cplus: cplus.o
|
||||||
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
|
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
|
||||||
@@ -24,6 +24,7 @@ echo: echo.o
|
|||||||
${OBJDUMP} -S $@.elf > $@.dis
|
${OBJDUMP} -S $@.elf > $@.dis
|
||||||
${SIZE} $@.elf
|
${SIZE} $@.elf
|
||||||
${ELF2AOUT} $@.elf $@
|
${ELF2AOUT} $@.elf $@
|
||||||
|
./aout $@ > $@.dis
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.elf ${MAN} chello cplus echo stdarg *.elf *.dis tags *~
|
rm -f *.o *.elf ${MAN} hello cplus *.elf *.dis tags *~
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
printf ("Hello, C World!\n");
|
printf ("Hello, C World!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Generic skeleton for a C program.
|
|
||||||
* When you create your own program based on this skeleton,
|
|
||||||
* you can replace the author's name and copyright with
|
|
||||||
* whatever your want. When you redistribute this skeleton or
|
|
||||||
* enhance it, please leave my name and copyright on it.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1993-2014 Serge Vakulenko, <vak@cronyx.ru>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software
|
|
||||||
* and its documentation for any purpose and without fee is hereby
|
|
||||||
* granted, provided that the above copyright notice appear in all
|
|
||||||
* copies and that both that the copyright notice and this
|
|
||||||
* permission notice and warranty disclaimer appear in supporting
|
|
||||||
* documentation, and that the name of the author not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
*
|
|
||||||
* The author disclaim all warranties with regard to this
|
|
||||||
* software, including all implied warranties of merchantability
|
|
||||||
* and fitness. In no event shall the author be liable for any
|
|
||||||
* special, indirect or consequential damages or any damages
|
|
||||||
* whatsoever resulting from loss of use, data or profits, whether
|
|
||||||
* in an action of contract, negligence or other tortious action,
|
|
||||||
* arising out of or in connection with the use or performance of
|
|
||||||
* this software.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
const char version[] = "1.0";
|
|
||||||
const char copyright[] = "Copyright (C) 1993-2014 Serge Vakulenko";
|
|
||||||
|
|
||||||
char *progname; /* Name of the current program (argv[0]) */
|
|
||||||
int verbose; /* Option -v */
|
|
||||||
int trace; /* Option -t */
|
|
||||||
int debug; /* Option -d */
|
|
||||||
|
|
||||||
void usage ()
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Generic C skeleton, Version %s, %s\n", version, copyright);
|
|
||||||
fprintf (stderr, "Usage:\n\t%s [-vtd] [-r count] file...\n", progname);
|
|
||||||
fprintf (stderr, "Options:\n");
|
|
||||||
fprintf (stderr, "\t-v\tverbose mode\n");
|
|
||||||
fprintf (stderr, "\t-t\ttrace mode\n");
|
|
||||||
fprintf (stderr, "\t-d\tdebug\n");
|
|
||||||
fprintf (stderr, "\t-r #\trepeat count\n");
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int count = 1; /* Option -r # */
|
|
||||||
|
|
||||||
progname = *argv;
|
|
||||||
for (;;) {
|
|
||||||
switch (getopt (argc, argv, "vtdr:")) {
|
|
||||||
case EOF:
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
++verbose;
|
|
||||||
continue;
|
|
||||||
case 't':
|
|
||||||
++trace;
|
|
||||||
continue;
|
|
||||||
case 'd':
|
|
||||||
++debug;
|
|
||||||
continue;
|
|
||||||
case 'r':
|
|
||||||
count = strtol (optarg, 0, 0);
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
usage ();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (argc < 1)
|
|
||||||
usage ();
|
|
||||||
|
|
||||||
while (count-- > 0) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0; i<argc; ++i)
|
|
||||||
printf ("%s ", argv[i]);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
void print(char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int d;
|
|
||||||
char c, *s;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
while (*fmt) {
|
|
||||||
switch (*fmt++) {
|
|
||||||
case 's': /* string */
|
|
||||||
s = va_arg(ap, char*);
|
|
||||||
printf("string %s\n", s);
|
|
||||||
break;
|
|
||||||
case 'd': /* int */
|
|
||||||
d = va_arg(ap, int);
|
|
||||||
printf("int %d\n", d);
|
|
||||||
break;
|
|
||||||
case 'c': /* char */
|
|
||||||
c = va_arg(ap, int);
|
|
||||||
printf("char %c\n", c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
print("sdcsdc", "abracadabra", 12345, 'Z', "foo", 365, '%');
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
21
share/lccom/Makefile
Normal file
21
share/lccom/Makefile
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
|
||||||
|
.SUFFIXES: .c .s .S .o
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
lccom -target=mips-el $< > $*.s
|
||||||
|
as -o $@ $*.s
|
||||||
|
|
||||||
|
.s.o:
|
||||||
|
as -o $@ $<
|
||||||
|
|
||||||
|
.S.o:
|
||||||
|
as -o $@ $<
|
||||||
|
|
||||||
|
all: hello
|
||||||
|
|
||||||
|
hello: hello.o sys.o
|
||||||
|
ld -o hello -e main hello.o sys.o
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.s hello
|
||||||
|
|
||||||
6
share/lccom/hello.c
Normal file
6
share/lccom/hello.c
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
write(1,"hello\n",6);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
100
share/lccom/sys.s
Normal file
100
share/lccom/sys.s
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
.text
|
||||||
|
|
||||||
|
#
|
||||||
|
# int open( char* file, int flags, int mode )
|
||||||
|
#
|
||||||
|
open:
|
||||||
|
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 5
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
#
|
||||||
|
# int read( int fd, void* dest, int count)
|
||||||
|
# returns: count of chars read or -1 if error (see errno)
|
||||||
|
#
|
||||||
|
read:
|
||||||
|
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 3
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# int write( int fd, void* string, int count );
|
||||||
|
# returns: count of chars written or -1 if error (see errno)
|
||||||
|
#
|
||||||
|
write:
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 4
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
#
|
||||||
|
# int close( int fd );
|
||||||
|
#
|
||||||
|
close:
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 6
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
#
|
||||||
|
# exit( int n );
|
||||||
|
#
|
||||||
|
exit:
|
||||||
|
syscall 1
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
serrn:
|
||||||
|
la $t1, _errno
|
||||||
|
sw $t0, 0($t1)
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
.data
|
||||||
|
_errno: .byte 0,0,0,0
|
||||||
|
|
||||||
|
.globl open
|
||||||
|
.globl read
|
||||||
|
.globl write
|
||||||
|
.globl close
|
||||||
|
.globl exit
|
||||||
|
.globl _errno
|
||||||
|
|
||||||
0
share/man/cat5/.gitignore
vendored
0
share/man/cat5/.gitignore
vendored
0
share/man/cat6/.gitignore
vendored
0
share/man/cat6/.gitignore
vendored
0
share/man/cat7/.gitignore
vendored
0
share/man/cat7/.gitignore
vendored
0
share/man/cat8/.gitignore
vendored
0
share/man/cat8/.gitignore
vendored
@@ -1,41 +1,27 @@
|
|||||||
CC = scc
|
|
||||||
PROG = hello primelist primesum test1 test2 test3 gpio adc rain \
|
|
||||||
webserver q8
|
|
||||||
|
|
||||||
all: $(PROG)
|
.SUFFIXES: .c .s .o
|
||||||
|
|
||||||
hello: hello.c
|
.c.o:
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) hello.c
|
smallc $<
|
||||||
|
as -o $@ $*.s
|
||||||
|
|
||||||
primelist: primelist.c
|
.s.o:
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primelist.c
|
as -o $@ $<
|
||||||
|
|
||||||
primesum: primesum.c
|
all: primelist primesum test1 test2
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primesum.c
|
|
||||||
|
|
||||||
webserver: webserver.c
|
primelist: primelist.o lib.o sys.o
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) webserver.c -lwiznet
|
ld -o primelist -e _main primelist.o lib.o sys.o
|
||||||
|
|
||||||
gpio: gpio.c
|
primesum: primesum.o lib.o sys.o
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) gpio.c
|
ld -o primesum -e _main primesum.o lib.o sys.o
|
||||||
|
|
||||||
adc: adc.c
|
test1: test1.o lib.o sys.o
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) adc.c
|
ld -o $@ -e _main test1.o lib.o sys.o
|
||||||
|
|
||||||
rain: rain.c
|
test2: test2.o lib.o sys.o
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) rain.c
|
ld -o $@ -e _main test2.o lib.o sys.o
|
||||||
|
|
||||||
q8: q8.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) q8.c
|
|
||||||
|
|
||||||
test1: test1.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test1.c
|
|
||||||
|
|
||||||
test2: test2.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test2.c
|
|
||||||
|
|
||||||
test3: test3.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test3.c
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o $(PROG)
|
rm *.o primelist primesum test1 test2 primelist.s primesum.s test1.s test2.s
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of reading ADC data.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
char buf[100];
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int i, fd, value;
|
|
||||||
|
|
||||||
for (i=0; i<16; i++) {
|
|
||||||
sprintf(buf, "/dev/adc%d", i);
|
|
||||||
fd = open(buf, O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
printf("Error: unable to open %s\n", buf);
|
|
||||||
} else {
|
|
||||||
if (read(fd, buf, 20) > 0) {
|
|
||||||
value = strtol (buf, 0, 0);
|
|
||||||
printf("adc%-2d = %d\n", i, value);
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of polling general purpose i/o pins.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/gpio.h>
|
|
||||||
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
int fd, pnum, value;
|
|
||||||
|
|
||||||
fd = open ("/dev/porta", O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
perror ("/dev/porta");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (pnum=0; pnum<7; pnum++) {
|
|
||||||
value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0);
|
|
||||||
if (value < 0)
|
|
||||||
perror ("GPIO_POLL");
|
|
||||||
printf ("port%c = 0x%04x\n", pnum + 'A', value);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
extern int printf();
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
printf ("Hello, SmallC World!\n");
|
|
||||||
}
|
|
||||||
37
share/smallc/lib.c
Normal file
37
share/smallc/lib.c
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
w_s(s)
|
||||||
|
char*s;
|
||||||
|
{
|
||||||
|
write( 1, s, strlen(s) );
|
||||||
|
}
|
||||||
|
|
||||||
|
strlen(s)
|
||||||
|
char*s;
|
||||||
|
{
|
||||||
|
char *e;
|
||||||
|
e = s;
|
||||||
|
while(*e != 0) ++e;
|
||||||
|
return e-s;
|
||||||
|
}
|
||||||
|
|
||||||
|
w_c(c)
|
||||||
|
char c;
|
||||||
|
{
|
||||||
|
write( 1, &c, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
w_n(number, radix)
|
||||||
|
int number, radix;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *drp;
|
||||||
|
drp = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
if (number < 0 & radix == 10)
|
||||||
|
{
|
||||||
|
w_c('-');
|
||||||
|
number = -number;
|
||||||
|
}
|
||||||
|
if ((i = number / radix) != 0)
|
||||||
|
w_n(i, radix);
|
||||||
|
w_c(drp[number % radix]);
|
||||||
|
}
|
||||||
@@ -1,31 +1,24 @@
|
|||||||
/*
|
|
||||||
* Print the list of prime numbers up to 100.
|
|
||||||
*/
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
for(n=2;n<100;++n){
|
||||||
for (n=2; n<100; ++n) {
|
if( isprime(n) ){
|
||||||
if (isprime(n)) {
|
w_n(n,10);
|
||||||
printf("%d ", n);
|
w_c(' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
w_c('\n');
|
||||||
|
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
isprime(n)
|
isprime(n)
|
||||||
int n;
|
int n;
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
if( n == 2 ) return 1;
|
||||||
if (n == 2)
|
if( n % 2 == 0 ) return 0;
|
||||||
return 1;
|
for(j=3;j*j<=n;j+=2)
|
||||||
|
if( n % j == 0 ) return 0;
|
||||||
if (n % 2 == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (j=3; j*j<=n; j+=2)
|
|
||||||
if (n % j == 0)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,27 @@
|
|||||||
/*
|
|
||||||
* Compute the sum of prime numbers up to 10000.
|
|
||||||
*/
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
int sum, n;
|
int sum;
|
||||||
|
int n;
|
||||||
sum = 0;
|
sum = 0;
|
||||||
for (n=2; n<10000; ++n) {
|
for(n=2;n<10000;++n){
|
||||||
if (isprime(n)) {
|
if( isprime(n) ){
|
||||||
sum += n;
|
sum += n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Sum of primes less than 10000: %d\n", sum);
|
w_s("sum of primes less than 10000: ");
|
||||||
|
w_n(sum,10);
|
||||||
|
w_c('\n');
|
||||||
|
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
isprime(n)
|
isprime(n)
|
||||||
int n;
|
int n;
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
if( n == 2 ) return 1;
|
||||||
if (n == 2)
|
if( n % 2 == 0 ) return 0;
|
||||||
return 1;
|
for(j=3;j*j<=n;j+=2)
|
||||||
|
if( n % j == 0 ) return 0;
|
||||||
if (n % 2 == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (j=3; j*j<=n; j+=2)
|
|
||||||
if (n % j == 0)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,208 +0,0 @@
|
|||||||
/*
|
|
||||||
* Eight Queens puzzle
|
|
||||||
*
|
|
||||||
* (C) 2010 by Mark Sproul
|
|
||||||
* Open source as per standard Arduino code
|
|
||||||
* Modified by Pito 12/2012 for SmallC
|
|
||||||
*/
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
|
|
||||||
unsigned int gChessBoard[8];
|
|
||||||
unsigned int gLoopCounter;
|
|
||||||
int gValidCount;
|
|
||||||
|
|
||||||
CheckCurrentBoard()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int jj;
|
|
||||||
int theRow;
|
|
||||||
int theLongRow;
|
|
||||||
int theLongColumns;
|
|
||||||
int bitCount;
|
|
||||||
|
|
||||||
//* we know we have 1 in each row,
|
|
||||||
//* Check for 1 in each column
|
|
||||||
theRow = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow |= gChessBoard[ii];
|
|
||||||
}
|
|
||||||
if (theRow != 0x0ff) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* we have 1 in each column, now check the diagonals
|
|
||||||
theLongColumns = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theLongRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theLongRow = theLongRow << ii;
|
|
||||||
|
|
||||||
theLongColumns |= theLongRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* now count the bits
|
|
||||||
bitCount = 0;
|
|
||||||
for (ii=0; ii<16; ii++) {
|
|
||||||
if ((theLongColumns & 0x01) == 0x01) {
|
|
||||||
bitCount++;
|
|
||||||
}
|
|
||||||
theLongColumns = theLongColumns >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitCount != 8) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* we now have to check the other diagonal
|
|
||||||
theLongColumns = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theLongRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theLongRow = theLongRow << 8;
|
|
||||||
theLongRow = theLongRow >> ii;
|
|
||||||
|
|
||||||
theLongColumns |= theLongRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* now count the bits
|
|
||||||
bitCount = 0;
|
|
||||||
for (ii=0; ii<16; ii++) {
|
|
||||||
if ((theLongColumns & 0x01) == 0x01) {
|
|
||||||
bitCount++;
|
|
||||||
}
|
|
||||||
theLongColumns = theLongColumns >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitCount != 8) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckForDone()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int weAreDone;
|
|
||||||
int theRow;
|
|
||||||
|
|
||||||
weAreDone = FALSE;
|
|
||||||
|
|
||||||
//* we know we have 1 in each row,
|
|
||||||
//* Check for 1 in each column
|
|
||||||
theRow = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow |= gChessBoard[ii];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theRow == 0x01) {
|
|
||||||
weAreDone = TRUE;
|
|
||||||
}
|
|
||||||
return weAreDone;
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateQueens()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int keepGoing;
|
|
||||||
int theRow;
|
|
||||||
|
|
||||||
ii = 0;
|
|
||||||
keepGoing = TRUE;
|
|
||||||
while (keepGoing && (ii < 8)) {
|
|
||||||
theRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theRow = (theRow >> 1) & 0x0ff;
|
|
||||||
if (theRow != 0) {
|
|
||||||
gChessBoard[ii] = theRow;
|
|
||||||
keepGoing = FALSE;
|
|
||||||
} else {
|
|
||||||
gChessBoard[ii] = 0x080;
|
|
||||||
}
|
|
||||||
ii++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintChessBoard()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int jj;
|
|
||||||
int theRow;
|
|
||||||
char textString[32];
|
|
||||||
|
|
||||||
printf("\nLoop= %d\n", gLoopCounter);
|
|
||||||
printf("Solution count= %d\n", gValidCount);
|
|
||||||
|
|
||||||
printf("+----------------+\n");
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow = gChessBoard[ii];
|
|
||||||
|
|
||||||
printf("|");
|
|
||||||
for (jj=0; jj<8; jj++) {
|
|
||||||
if (theRow & 0x080) {
|
|
||||||
printf("Q ");
|
|
||||||
} else {
|
|
||||||
printf(". ");
|
|
||||||
}
|
|
||||||
theRow = theRow << 1;
|
|
||||||
}
|
|
||||||
printf("|\n");
|
|
||||||
}
|
|
||||||
printf("+----------------+\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
|
|
||||||
printf("\nEight Queens brute force");
|
|
||||||
printf("\n************************\n");
|
|
||||||
//* put the 8 queens on the board, 1 in each row
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
gChessBoard[ii] = 0x080;
|
|
||||||
}
|
|
||||||
PrintChessBoard();
|
|
||||||
|
|
||||||
gLoopCounter = 0;
|
|
||||||
gValidCount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
gLoopCounter++;
|
|
||||||
|
|
||||||
if (CheckCurrentBoard()) {
|
|
||||||
gValidCount++;
|
|
||||||
PrintChessBoard();
|
|
||||||
} else if ((gLoopCounter % 1000) == 0) {
|
|
||||||
//PrintChessBoard();
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateQueens();
|
|
||||||
if (CheckForDone()) {
|
|
||||||
//int elapsedSeconds;
|
|
||||||
//int elapsedMinutes;
|
|
||||||
//int elapsedHours;
|
|
||||||
|
|
||||||
//elapsedSeconds = millis() / 1000;
|
|
||||||
//elapsedMinutes = elapsedSeconds / 60;
|
|
||||||
//elapsedHours = elapsedMinutes / 60;
|
|
||||||
|
|
||||||
printf("----------------------------------\n");
|
|
||||||
printf("All done\n");
|
|
||||||
|
|
||||||
PrintChessBoard();
|
|
||||||
printf("----------------------------------\n");
|
|
||||||
|
|
||||||
//Serial.print("total seconds=");
|
|
||||||
//Serial.println(elapsedSeconds);
|
|
||||||
|
|
||||||
//Serial.print("hours=");
|
|
||||||
//Serial.println(elapsedHours);
|
|
||||||
|
|
||||||
//Serial.print("minutes=");
|
|
||||||
//Serial.println(elapsedMinutes % 60);
|
|
||||||
|
|
||||||
//Serial.print("seconds=");
|
|
||||||
//Serial.println(elapsedSeconds % 60);
|
|
||||||
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of using termcap library for SmallC.
|
|
||||||
* 11/3/1980 EPS/CITHEP
|
|
||||||
*
|
|
||||||
* Copyright (c) 1980 Regents of the University of California.
|
|
||||||
* All rights reserved. The Berkeley software License Agreement
|
|
||||||
* specifies the terms and conditions for redistribution.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#define CO 80 /* number of columns */
|
|
||||||
#define LI 24 /* number of lines */
|
|
||||||
|
|
||||||
#define CL "\33[H\33[J" /* clear the screen */
|
|
||||||
#define CM "\33[%u;%uH" /* move the cursor to row, column */
|
|
||||||
#define BC "\b" /* move cursor left */
|
|
||||||
#define DN "\33[B" /* move cursor down */
|
|
||||||
#define ND " " /* move cursor right */
|
|
||||||
|
|
||||||
int xpos[5], ypos[5];
|
|
||||||
char outbuf[BUFSIZ];
|
|
||||||
|
|
||||||
moveto(col, row)
|
|
||||||
int col, row;
|
|
||||||
{
|
|
||||||
printf(CM, row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
onsig(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
moveto(0, LI - 1);
|
|
||||||
fflush(stdout);
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int x, y, j;
|
|
||||||
|
|
||||||
setbuf(stdout, outbuf);
|
|
||||||
for (j = SIGHUP; j <= SIGTERM; j++)
|
|
||||||
if (signal(j, SIG_IGN) != SIG_IGN)
|
|
||||||
signal(j, onsig);
|
|
||||||
|
|
||||||
fputs(CL, stdout);
|
|
||||||
fflush(stdout);
|
|
||||||
for (j = 5; --j >= 0; ) {
|
|
||||||
xpos[j] = 2 + rand() % (CO - 4);
|
|
||||||
ypos[j] = 2 + rand() % (LI - 4);
|
|
||||||
}
|
|
||||||
for (j = 0; ; ) {
|
|
||||||
x = 2 + rand() % (CO - 4);
|
|
||||||
y = 2 + rand() % (LI - 4);
|
|
||||||
moveto(x, y);
|
|
||||||
putchar('.');
|
|
||||||
moveto(xpos[j], ypos[j]);
|
|
||||||
putchar('o');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]);
|
|
||||||
putchar('O');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-1);
|
|
||||||
putchar('-');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs("|.|", stdout);
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar('-');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-2);
|
|
||||||
putchar('-');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs("/ \\", stdout);
|
|
||||||
moveto(xpos[j]-2, ypos[j]);
|
|
||||||
fputs("| O |", stdout);
|
|
||||||
moveto(xpos[j]-1, ypos[j]+1);
|
|
||||||
fputs("\\ /", stdout);
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar('-');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-2);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
moveto(xpos[j]-2, ypos[j]);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
moveto(xpos[j]-1, ypos[j]+1);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
xpos[j] = x;
|
|
||||||
ypos[j] = y;
|
|
||||||
fflush(stdout);
|
|
||||||
usleep(100000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
159
share/smallc/sys.s
Normal file
159
share/smallc/sys.s
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
.text
|
||||||
|
|
||||||
|
#
|
||||||
|
# int open( char* file, int flags, int mode )
|
||||||
|
#
|
||||||
|
_open:
|
||||||
|
lw $a0, 8($sp)
|
||||||
|
lw $a1, 4($sp)
|
||||||
|
lw $a2, 0($sp)
|
||||||
|
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 5
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
#
|
||||||
|
# int read( int fd, void* dest, int count)
|
||||||
|
# returns: count of chars read or -1 if error (see errno)
|
||||||
|
#
|
||||||
|
_read:
|
||||||
|
lw $a0, 8($sp)
|
||||||
|
lw $a1, 4($sp)
|
||||||
|
lw $a2, 0($sp)
|
||||||
|
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 3
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# int write( int fd, void* string, int count );
|
||||||
|
# returns: count of chars written or -1 if error (see errno)
|
||||||
|
#
|
||||||
|
_write:
|
||||||
|
lw $a0, 8($sp)
|
||||||
|
lw $a1, 4($sp)
|
||||||
|
lw $a2, 0($sp)
|
||||||
|
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 4
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
#
|
||||||
|
# int close( int fd );
|
||||||
|
#
|
||||||
|
_close:
|
||||||
|
lw $a0, 0($sp)
|
||||||
|
|
||||||
|
# errno handling code after syscall is not ideal,
|
||||||
|
# but I don't think the assembler handles specifying
|
||||||
|
# relocations for %hi and %lo yet, so the handling
|
||||||
|
# shown in the retrobsd code is not really doable
|
||||||
|
|
||||||
|
syscall 6
|
||||||
|
nop
|
||||||
|
j serrn
|
||||||
|
nop
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
#
|
||||||
|
# exit( int n );
|
||||||
|
#
|
||||||
|
_exit:
|
||||||
|
lw $a0, 0($sp)
|
||||||
|
addiu $sp, $sp, -4
|
||||||
|
syscall 1
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
serrn:
|
||||||
|
la $t1, _errno
|
||||||
|
sw $t0, 0($t1)
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
#
|
||||||
|
# $v0 = value to switch on
|
||||||
|
# 0($sp) = pointer to list of value,ptr cases
|
||||||
|
# ended where ptr=0, value is used as pointer to jump to in default case
|
||||||
|
# looks like stack is popped as part of this
|
||||||
|
# FIXME - The assembler/linker only stores the bottom 16 bits
|
||||||
|
# of the labels in pair, so we construct the address by merging the 16 bits
|
||||||
|
# in the cell with the upper 16 bits in the return address of the code that
|
||||||
|
# called this. Is there a way to get the assembler linker to store the full
|
||||||
|
# address? If so, that should be used instead.
|
||||||
|
#
|
||||||
|
Tcase:
|
||||||
|
lw $t1, 0($sp) # t1=pointer to list of value/ptr pairs
|
||||||
|
addiu $sp, $sp, 4 # pop stack that held pointer
|
||||||
|
.Tcl:
|
||||||
|
lw $t2, 0($t1) # get value from pair
|
||||||
|
lw $t3, 4($t1) # get ptr from pair
|
||||||
|
beq $t3, $zero, .Tcd
|
||||||
|
nop
|
||||||
|
|
||||||
|
beq $t2, $v0, .Tcm
|
||||||
|
nop
|
||||||
|
|
||||||
|
addiu $t1, $t1, 8 # t1 += size of pair
|
||||||
|
j .Tcl
|
||||||
|
nop
|
||||||
|
|
||||||
|
.Tcd:
|
||||||
|
move $t3, $t2
|
||||||
|
.Tcm:
|
||||||
|
lui $t2, 0xffff
|
||||||
|
and $t2, $t2, $ra
|
||||||
|
or $t3, $t3, $t2
|
||||||
|
jr $t3
|
||||||
|
nop
|
||||||
|
|
||||||
|
Tcallstk:
|
||||||
|
jr $t1
|
||||||
|
nop
|
||||||
|
|
||||||
|
.data
|
||||||
|
_errno: .byte 0,0,0,0
|
||||||
|
|
||||||
|
.globl _open
|
||||||
|
.globl _read
|
||||||
|
.globl _write
|
||||||
|
.globl _close
|
||||||
|
.globl _exit
|
||||||
|
.globl _errno
|
||||||
|
.globl Tcase
|
||||||
|
.globl Tcallstk
|
||||||
|
|
||||||
@@ -1,219 +1,231 @@
|
|||||||
int ga[5];
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
int a, b, c, d;
|
int a,b,c,d;
|
||||||
int arr[5];
|
int arr[5];
|
||||||
int *pi;
|
int *pi;
|
||||||
char arrc[5];
|
char arrc[5];
|
||||||
char *pic;
|
char *pic;
|
||||||
int s1, s2;
|
int s1,s2;
|
||||||
int z;
|
int z;
|
||||||
int t;
|
int t;
|
||||||
int *pip;
|
int *pip;
|
||||||
int *picp;
|
int *picp;
|
||||||
int e1, e2;
|
int e1,e2;
|
||||||
|
|
||||||
ga[0] = 10;
|
a = 21;
|
||||||
ga[1] = 20;
|
b = 31;
|
||||||
ga[2] = 30;
|
c = 71;
|
||||||
ga[3] = 40;
|
d = 82;
|
||||||
ga[4] = 50;
|
|
||||||
|
arr[0] = 10;
|
||||||
|
arr[1] = 20;
|
||||||
|
arr[2] = 30;
|
||||||
|
arr[3] = 40;
|
||||||
|
arr[4] = 50;
|
||||||
|
pi = &arr[0];
|
||||||
|
|
||||||
|
arrc[0] = 13;
|
||||||
|
arrc[1] = 23;
|
||||||
|
arrc[2] = 33;
|
||||||
|
arrc[3] = 43;
|
||||||
|
arrc[4] = 53;
|
||||||
|
pic = &arrc[0];
|
||||||
|
|
||||||
|
w_s("21+31="); w_n(a+b,10); w_s(" (52)\n");
|
||||||
|
w_s("21-31="); w_n(a-b,10); w_s(" (-10)\n");
|
||||||
|
w_s("21&71="); w_n(a&c,10); w_s(" (5)\n");
|
||||||
|
w_s("21|82="); w_n(a|d,10); w_s(" (87)\n");
|
||||||
|
w_s("21^82="); w_n(a^d,10); w_s(" (71)\n");
|
||||||
|
w_s("21*82="); w_n(a*d,10); w_s(" (1722)\n");
|
||||||
|
w_s("82%21="); w_n(d%a,10); w_s(" (19)\n");
|
||||||
|
w_s("82/21="); w_n(d/a,10); w_s(" (3)\n");
|
||||||
|
w_s("*pi="); w_n(*pi,10); w_s(" (10)\n");
|
||||||
|
w_s("*pi+1="); w_n(*pi+1,10); w_s(" (11)\n");
|
||||||
|
w_s("*(pi+1)="); w_n(*(pi+1),10); w_s(" (20)\n");
|
||||||
|
w_s("&arr[3]-&arr[0]="); w_n(&arr[3]-&arr[0],10); w_s(" (3)\n");
|
||||||
|
|
||||||
|
w_s("*pic="); w_n(*pic,10); w_s(" (13)\n");
|
||||||
|
w_s("*pic+1="); w_n(*pic+1,10); w_s(" (14)\n");
|
||||||
|
w_s("*(pic+1)="); w_n(*(pic+1),10); w_s(" (23)\n");
|
||||||
|
w_s("&arrc[3]-&arrc[0]="); w_n(&arrc[3]-&arrc[0],10); w_s(" (3)\n");
|
||||||
|
|
||||||
|
s1 = 3;
|
||||||
|
s2 = -200;
|
||||||
|
w_s("82<<3="); w_n(d<<s1,10); w_s(" (656)\n");
|
||||||
|
w_s("82>>3="); w_n(d>>s1,10); w_s(" (10)\n");
|
||||||
|
w_s("-200>>3="); w_n(s2>>s1,10); w_s(" (-25)\n");
|
||||||
|
w_s("-200<<3="); w_n(s2<<s1,10); w_s(" (-1600)\n");
|
||||||
|
|
||||||
|
w_s("-s1="); w_n(-s1,10); w_s(" (-3)\n");
|
||||||
|
w_s("-s2="); w_n(-s2,10); w_s(" (200)\n");
|
||||||
|
|
||||||
|
w_s("~82="); w_n(~d,10); w_s(" (-83)\n");
|
||||||
|
|
||||||
|
z = 0;
|
||||||
|
|
||||||
|
w_s("!82="); w_n(!d,10); w_s(" (0)\n");
|
||||||
|
w_s("!0="); w_n(!z,10); w_s(" (1)\n");
|
||||||
|
|
||||||
|
t = 0;
|
||||||
|
if(t) printt(t,"failure\n"); else printt(t,"success\n");
|
||||||
|
t = 1;
|
||||||
|
if(t) printt(t,"success\n"); else printt(t,"failure\n");
|
||||||
|
t = 8;
|
||||||
|
if(t) printt(t,"success\n"); else printt(t,"failure\n");
|
||||||
|
t = -2;
|
||||||
|
if(t) printt(t,"success\n"); else printt(t,"failure\n");
|
||||||
|
|
||||||
|
w_s("0&&0="); w_n(z&&z,10); w_s(" (0)\n");
|
||||||
|
w_s("0&&21="); w_n(z&&a,10); w_s(" (0)\n");
|
||||||
|
w_s("3&&21="); w_n(s1&&a,10); w_s(" (1)\n");
|
||||||
|
w_s("21&&3="); w_n(a&&s1,10); w_s(" (1)\n");
|
||||||
|
|
||||||
|
w_s("0||0="); w_n(z||z,10); w_s(" (0)\n");
|
||||||
|
w_s("0||21="); w_n(z||a,10); w_s(" (1)\n");
|
||||||
|
w_s("3||21="); w_n(s1||a,10); w_s(" (1)\n");
|
||||||
|
w_s("21||3="); w_n(a||s1,10); w_s(" (1)\n");
|
||||||
|
|
||||||
|
pi = 4;
|
||||||
|
w_s("pi++="); w_n(pi++,10); w_s(" (4)\n");
|
||||||
|
w_s("pi="); w_n(pi,10); w_s(" (8)\n");
|
||||||
|
w_s("++pi="); w_n(++pi,10); w_s(" (12)\n");
|
||||||
|
w_s("pi--="); w_n(pi--,10); w_s(" (12)\n");
|
||||||
|
w_s("pi="); w_n(pi,10); w_s(" (8)\n");
|
||||||
|
w_s("--pi="); w_n(--pi,10); w_s(" (4)\n");
|
||||||
|
|
||||||
|
pic = 4;
|
||||||
|
w_s("pic++="); w_n(pic++,10); w_s(" (4)\n");
|
||||||
|
w_s("pic="); w_n(pic,10); w_s(" (5)\n");
|
||||||
|
w_s("++pic="); w_n(++pic,10); w_s(" (6)\n");
|
||||||
|
w_s("pic--="); w_n(pic--,10); w_s(" (6)\n");
|
||||||
|
w_s("pic="); w_n(pic,10); w_s(" (5)\n");
|
||||||
|
w_s("--pic="); w_n(--pic,10); w_s(" (4)\n");
|
||||||
|
|
||||||
|
t = 4;
|
||||||
|
w_s("t++="); w_n(t++,10); w_s(" (4)\n");
|
||||||
|
w_s("t="); w_n(t,10); w_s(" (5)\n");
|
||||||
|
w_s("++t="); w_n(++t,10); w_s(" (6)\n");
|
||||||
|
w_s("t--="); w_n(t--,10); w_s(" (6)\n");
|
||||||
|
w_s("t="); w_n(t,10); w_s(" (5)\n");
|
||||||
|
w_s("--t="); w_n(--t,10); w_s(" (4)\n");
|
||||||
|
|
||||||
a = 21;
|
t = 4;
|
||||||
b = 31;
|
w_s("t==4="); w_n(t==4,10); w_s(" (1)\n");
|
||||||
c = 71;
|
w_s("t==3="); w_n(t==3,10); w_s(" (0)\n");
|
||||||
d = 82;
|
w_s("t==5="); w_n(t==5,10); w_s(" (0)\n");
|
||||||
|
t = -4;
|
||||||
|
w_s("t==-4="); w_n(t==-4,10); w_s(" (1)\n");
|
||||||
|
w_s("t==-3="); w_n(t==-3,10); w_s(" (0)\n");
|
||||||
|
w_s("t==-5="); w_n(t==-5,10); w_s(" (0)\n");
|
||||||
|
w_s("t==4="); w_n(t==4,10); w_s(" (0)\n");
|
||||||
|
w_s("t==3="); w_n(t==3,10); w_s(" (0)\n");
|
||||||
|
w_s("t==5="); w_n(t==5,10); w_s(" (0)\n");
|
||||||
|
|
||||||
|
t = 4;
|
||||||
|
w_s("t!=4="); w_n(t!=4,10); w_s(" (0)\n");
|
||||||
|
w_s("t!=3="); w_n(t!=3,10); w_s(" (1)\n");
|
||||||
|
w_s("t!=5="); w_n(t!=5,10); w_s(" (1)\n");
|
||||||
|
t = -4;
|
||||||
|
w_s("t!=-4="); w_n(t!=-4,10); w_s(" (0)\n");
|
||||||
|
w_s("t!=-3="); w_n(t!=-3,10); w_s(" (1)\n");
|
||||||
|
w_s("t!=-5="); w_n(t!=-5,10); w_s(" (1)\n");
|
||||||
|
w_s("t!=4="); w_n(t!=4,10); w_s(" (1)\n");
|
||||||
|
w_s("t!=3="); w_n(t!=3,10); w_s(" (1)\n");
|
||||||
|
w_s("t!=5="); w_n(t!=5,10); w_s(" (1)\n");
|
||||||
|
|
||||||
arr[0] = 10;
|
t = 4;
|
||||||
arr[1] = 20;
|
w_s("t<4="); w_n(t<4,10); w_s(" (0)\n");
|
||||||
arr[2] = 30;
|
w_s("t<3="); w_n(t<3,10); w_s(" (0)\n");
|
||||||
arr[3] = 40;
|
w_s("t<5="); w_n(t<5,10); w_s(" (1)\n");
|
||||||
arr[4] = 50;
|
w_s("t<-1="); w_n(t<-1,10); w_s(" (0)\n");
|
||||||
pi = &arr[0];
|
|
||||||
|
|
||||||
arrc[0] = 13;
|
w_s("t<=4="); w_n(t<=4,10); w_s(" (1)\n");
|
||||||
arrc[1] = 23;
|
w_s("t<=3="); w_n(t<=3,10); w_s(" (0)\n");
|
||||||
arrc[2] = 33;
|
w_s("t<=5="); w_n(t<=5,10); w_s(" (1)\n");
|
||||||
arrc[3] = 43;
|
w_s("t<=-1="); w_n(t<=-1,10); w_s(" (0)\n");
|
||||||
arrc[4] = 53;
|
|
||||||
pic = &arrc[0];
|
|
||||||
|
|
||||||
printf(" 21 + 31 = %d (52)\n", a + b);
|
t = 4;
|
||||||
printf(" 21 - 31 = %d (-10)\n", a - b);
|
w_s("t>4="); w_n(t>4,10); w_s(" (0)\n");
|
||||||
printf(" 21 & 71 = %d (5)\n", a & c);
|
w_s("t>3="); w_n(t>3,10); w_s(" (1)\n");
|
||||||
printf(" 21 | 82 = %d (87)\n", a | d);
|
w_s("t>5="); w_n(t>5,10); w_s(" (0)\n");
|
||||||
printf(" 21 ^ 82 = %d (71)\n", a ^ d);
|
w_s("t>-1="); w_n(t>-1,10); w_s(" (1)\n");
|
||||||
printf(" 21 * 82 = %d (1722)\n", a * d);
|
|
||||||
printf(" 82 % 21 = %d (19)\n", d % a);
|
|
||||||
printf(" 82 / 21 = %d (3)\n", d / a);
|
|
||||||
printf(" *pi = %d (10)\n", *pi);
|
|
||||||
printf(" *pi + 1 = %d (11)\n", *pi + 1);
|
|
||||||
printf(" *(pi + 1) = %d (20)\n", *(pi + 1));
|
|
||||||
printf("&arr[3] - &arr[0] = %d (3)\n", &arr[3] - &arr[0]);
|
|
||||||
printf(" arr[3]-arr[0] = %d (30)\n", arr[3] - arr[0]);
|
|
||||||
printf(" arr[3]+arr[0] = %d (50)\n", arr[3] + arr[0]);
|
|
||||||
printf(" &ga[3] - &ga[0] = %d (3)\n", &ga[3] - &ga[0]);
|
|
||||||
printf(" ga[3]-ga[0] = %d (30)\n", ga[3] - ga[0]);
|
|
||||||
printf(" ga[3]+ga[0] = %d (50)\n", ga[3] + ga[0]);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" *pic = %d (13)\n", *pic);
|
w_s("t>=4="); w_n(t>=4,10); w_s(" (1)\n");
|
||||||
printf(" *pic + 1 = %d (14)\n", *pic+1);
|
w_s("t>=3="); w_n(t>=3,10); w_s(" (1)\n");
|
||||||
printf(" *(pic + 1) = %d (23)\n", *(pic+1));
|
w_s("t>=5="); w_n(t>=5,10); w_s(" (0)\n");
|
||||||
printf("&arrc[3] - &arrc[0] = %d (3)\n", &arrc[3]-&arrc[0]);
|
w_s("t>=-1="); w_n(t>=-1,10); w_s(" (1)\n");
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
s1 = 3;
|
pi = -100;
|
||||||
s2 = -200;
|
w_s("pi<4="); w_n(pi<4,10); w_s(" (0)\n");
|
||||||
printf(" 82 << 3 = %d (656)\n", d << s1);
|
w_s("pi<3="); w_n(pi<3,10); w_s(" (0)\n");
|
||||||
printf(" 82 >> 3 = %d (10)\n", d >> s1);
|
w_s("pi<-100="); w_n(pi<-100,10); w_s(" (0)\n");
|
||||||
printf("-200 >> 3 = %d (-25)\n", s2 >> s1);
|
w_s("pi<-1="); w_n(pi<-1,10); w_s(" (1)\n");
|
||||||
printf("-200 << 3 = %d (-1600)\n", s2 << s1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("-s1 = %d (-3)\n", -s1);
|
w_s("pi<=4="); w_n(pi<=4,10); w_s(" (0)\n");
|
||||||
printf("-s2 = %d (200)\n", -s2);
|
w_s("pi<=3="); w_n(pi<=3,10); w_s(" (0)\n");
|
||||||
printf("\n");
|
w_s("pi<=-100="); w_n(pi<=-100,10); w_s(" (1)\n");
|
||||||
|
w_s("pi<=-1="); w_n(pi<=-1,10); w_s(" (1)\n");
|
||||||
|
|
||||||
printf("~82 = %d (-83)\n", ~d);
|
pi = -100;
|
||||||
printf("\n");
|
w_s("pi>4="); w_n(pi>4,10); w_s(" (1)\n");
|
||||||
|
w_s("pi>3="); w_n(pi>3,10); w_s(" (1)\n");
|
||||||
|
w_s("pi>-100="); w_n(pi>-100,10); w_s(" (0)\n");
|
||||||
|
w_s("pi>-1="); w_n(pi>-1,10); w_s(" (0)\n");
|
||||||
|
|
||||||
z = 0;
|
w_s("pi>=4="); w_n(pi>=4,10); w_s(" (1)\n");
|
||||||
printf("!82 = %d (0)\n", !d);
|
w_s("pi>=3="); w_n(pi>=3,10); w_s(" (1)\n");
|
||||||
printf(" !0 = %d (1)\n", !z);
|
w_s("pi>=-100="); w_n(pi>=-100,10); w_s(" (1)\n");
|
||||||
printf("\n");
|
w_s("pi>=-1="); w_n(pi>=-1,10); w_s(" (0)\n");
|
||||||
|
|
||||||
printf(" 0 && 0 = %d (0)\n", z && z);
|
w_s("switch test: ");
|
||||||
printf(" 0 && 21 = %d (0)\n", z && a);
|
switch(t)
|
||||||
printf(" 3 && 21 = %d (1)\n", s1 && a);
|
{
|
||||||
printf("21 && 3 = %d (1)\n", a && s1);
|
case 3:
|
||||||
printf("\n");
|
w_s("failure");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
w_s("success");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
w_s("failure");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
w_s("\n");
|
||||||
|
|
||||||
printf(" 0 || 0 = %d (0)\n", z || z);
|
w_s("switch fallthrough test: ");
|
||||||
printf(" 0 || 21 = %d (1)\n", z || a);
|
switch(t)
|
||||||
printf(" 3 || 21 = %d (1)\n", s1 || a);
|
{
|
||||||
printf("21 || 3 = %d (1)\n", a || s1);
|
case 3:
|
||||||
printf("\n");
|
w_s("failure");
|
||||||
|
break;
|
||||||
pi = 4;
|
case 4:
|
||||||
printf("pi++ = %d (4)\n", pi++);
|
w_s("OKSOFAR: ");
|
||||||
printf(" pi = %d (8)\n", pi);
|
case 5:
|
||||||
printf("++pi = %d (12)\n", ++pi);
|
w_s("success if oksofar printed before this in caps");
|
||||||
printf("pi-- = %d (12)\n", pi--);
|
break;
|
||||||
printf(" pi = %d (8)\n", pi);
|
}
|
||||||
printf("--pi = %d (4)\n", --pi);
|
w_s("\n");
|
||||||
printf("\n");
|
|
||||||
|
pi = &arr[0];
|
||||||
pic = 4;
|
pip = &arr[3];
|
||||||
printf("pic++ = %d (4)\n", pic++);
|
w_s("*pip-*pi: "); w_n(*pip-*pi,10); w_s(" 30\n");
|
||||||
printf(" pic = %d (5)\n", pic);
|
w_s("pip-pi: "); w_n(pip-pi,10); w_s(" 3\n");
|
||||||
printf("++pic = %d (6)\n", ++pic);
|
w_s("*pip: "); w_n( *pip, 10 ); w_s(" 40\n");
|
||||||
printf("pic-- = %d (6)\n", pic--);
|
w_s("*(pip-3): "); w_n(*(pip-3),10); w_s(" 10\n");
|
||||||
printf(" pic = %d (5)\n", pic);
|
w_s("*&arr[3]: "); w_n( *&arr[3], 10 ); w_s(" 40\n");
|
||||||
printf("--pic = %d (4)\n", --pic);
|
// The following causes an address error, so it has been removed
|
||||||
printf("\n");
|
// and needs to be fixed
|
||||||
|
w_s("*(&arr[3]-3): "); w_n(0/**(&arr[3]-3)*/,10); w_s(" 10 broken - causes address error\n");
|
||||||
t = 4;
|
exit(0);
|
||||||
printf("t++ = %d (4)\n", t++);
|
|
||||||
printf(" t = %d (5)\n", t);
|
|
||||||
printf("++t = %d (6)\n", ++t);
|
|
||||||
printf("t-- = %d (6)\n", t--);
|
|
||||||
printf(" t = %d (5)\n", t);
|
|
||||||
printf("--t = %d (4)\n", --t);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t==4 = %d (1)\n", t == 4);
|
|
||||||
printf(" t==3 = %d (0)\n", t == 3);
|
|
||||||
printf(" t==5 = %d (0)\n", t == 5);
|
|
||||||
t = -4;
|
|
||||||
printf("t==-4 = %d (1)\n", t == -4);
|
|
||||||
printf("t==-3 = %d (0)\n", t == -3);
|
|
||||||
printf("t==-5 = %d (0)\n", t == -5);
|
|
||||||
printf(" t==4 = %d (0)\n", t == 4);
|
|
||||||
printf(" t==3 = %d (0)\n", t == 3);
|
|
||||||
printf(" t==5 = %d (0)\n", t == 5);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t!=4 = %d (0)\n", t != 4);
|
|
||||||
printf(" t!=3 = %d (1)\n", t != 3);
|
|
||||||
printf(" t!=5 = %d (1)\n", t != 5);
|
|
||||||
t = -4;
|
|
||||||
printf("t!=-4 = %d (0)\n", t != -4);
|
|
||||||
printf("t!=-3 = %d (1)\n", t != -3);
|
|
||||||
printf("t!=-5 = %d (1)\n", t != -5);
|
|
||||||
printf(" t!=4 = %d (1)\n", t != 4);
|
|
||||||
printf(" t!=3 = %d (1)\n", t != 3);
|
|
||||||
printf(" t!=5 = %d (1)\n", t != 5);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t<4 = %d (0)\n", t < 4);
|
|
||||||
printf(" t<3 = %d (0)\n", t < 3);
|
|
||||||
printf(" t<5 = %d (1)\n", t < 5);
|
|
||||||
printf("t<-1 = %d (0)\n", t < -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" t<=4 = %d (1)\n", t <= 4);
|
|
||||||
printf(" t<=3 = %d (0)\n", t <= 3);
|
|
||||||
printf(" t<=5 = %d (1)\n", t <= 5);
|
|
||||||
printf("t<=-1 = %d (0)\n", t <= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t>4 = %d (0)\n", t > 4);
|
|
||||||
printf(" t>3 = %d (1)\n", t > 3);
|
|
||||||
printf(" t>5 = %d (0)\n", t > 5);
|
|
||||||
printf("t>-1 = %d (1)\n", t > -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" t>=4 = %d (1)\n", t >= 4);
|
|
||||||
printf(" t>=3 = %d (1)\n", t >= 3);
|
|
||||||
printf(" t>=5 = %d (0)\n", t >= 5);
|
|
||||||
printf("t>=-1 = %d (1)\n", t >= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = -100;
|
|
||||||
printf(" pi<4 = %d (0)\n", pi < 4);
|
|
||||||
printf(" pi<3 = %d (0)\n", pi < 3);
|
|
||||||
printf("pi<-100 = %d (0)\n", pi < -100);
|
|
||||||
printf(" pi<-1 = %d (1)\n", pi < -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" pi<=4 = %d (0)\n", pi <= 4);
|
|
||||||
printf(" pi<=3 = %d (0)\n", pi <= 3);
|
|
||||||
printf("pi<=-100 = %d (1)\n", pi <= -100);
|
|
||||||
printf(" pi<=-1 = %d (1)\n", pi <= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = -100;
|
|
||||||
printf(" pi>4 = %d (1)\n", pi > 4);
|
|
||||||
printf(" pi>3 = %d (1)\n", pi > 3);
|
|
||||||
printf("pi>-100 = %d (0)\n", pi > -100);
|
|
||||||
printf(" pi>-1 = %d (0)\n", pi > -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" pi>=4 = %d (1)\n", pi >= 4);
|
|
||||||
printf(" pi>=3 = %d (1)\n", pi >= 3);
|
|
||||||
printf("pi>=-100 = %d (1)\n", pi >= -100);
|
|
||||||
printf(" pi>=-1 = %d (0)\n", pi >= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = &arr[0];
|
|
||||||
pip = &arr[3];
|
|
||||||
printf(" *pip - *pi: %d 30\n", *pip - *pi);
|
|
||||||
printf(" pip - pi: %d 3\n", pip - pi);
|
|
||||||
printf(" *pip: %d 40\n", *pip);
|
|
||||||
printf(" *(pip - 3): %d 10\n", *(pip - 3));
|
|
||||||
printf(" *&arr[3]: %d 40\n", *&arr[3]);
|
|
||||||
printf("*(&arr[3] - 3): %d 10\n", *(&arr[3]-3));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printt (t, str)
|
printt(t,str)
|
||||||
int t;
|
int t;
|
||||||
char *str;
|
char *str;
|
||||||
{
|
{
|
||||||
printf("bool test on value %d %s\n", t, str);
|
w_s("bool t test on value ");
|
||||||
|
w_n(t,10);
|
||||||
|
w_s(" ");
|
||||||
|
w_s(str);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
#include <fcntl.h>
|
|
||||||
|
#define O_RDONLY 0x0000 /* open for reading only */
|
||||||
|
#define O_WRONLY 0x0001 /* open for writing only */
|
||||||
|
#define O_RDWR 0x0002 /* open for reading and writing */
|
||||||
|
#define O_ACCMODE 0x0003 /* mask for above modes */
|
||||||
|
|
||||||
|
#define O_NONBLOCK 0x0004 /* no delay */
|
||||||
|
#define O_APPEND 0x0008 /* set append mode */
|
||||||
|
#define O_SHLOCK 0x0010 /* open with shared file lock */
|
||||||
|
#define O_EXLOCK 0x0020 /* open with exclusive file lock */
|
||||||
|
#define O_ASYNC 0x0040 /* signal pgrp when data ready */
|
||||||
|
#define O_FSYNC 0x0080 /* synchronous writes */
|
||||||
|
#define O_CREAT 0x0200 /* create if nonexistant */
|
||||||
|
#define O_TRUNC 0x0400 /* truncate to zero length */
|
||||||
|
#define O_EXCL 0x0800 /* error if already exists */
|
||||||
|
|
||||||
int aaa;
|
int aaa;
|
||||||
int bbb;
|
int bbb;
|
||||||
@@ -11,117 +25,126 @@ extern errno;
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
char b;
|
char b;
|
||||||
int la;
|
int la;
|
||||||
unsigned int u1, u2;
|
unsigned int u1, u2;
|
||||||
int s1, s2;
|
int s1, s2;
|
||||||
unsigned char uc1, uc2;
|
unsigned char uc1, uc2;
|
||||||
char sc1, sc2;
|
char sc1, sc2;
|
||||||
int fd;
|
int fd;
|
||||||
char buffer[6];
|
char buffer[6];
|
||||||
int ibuffer[7];
|
int ibuffer[7];
|
||||||
|
|
||||||
|
w_s( "sizeof(uc1): "); w_n( sizeof(uc1), 10 ); w_s( " 1\n" );
|
||||||
|
w_s( "sizeof(sc1): "); w_n( sizeof(sc1), 10 ); w_s( " 1\n" );
|
||||||
|
w_s( "sizeof(u1): "); w_n( sizeof(u1), 10 ); w_s( " 4\n" );
|
||||||
|
w_s( "sizeof(s1): "); w_n( sizeof(s1), 10 ); w_s( " 4\n" );
|
||||||
|
w_s( "sizeof(aaa): "); w_n( sizeof(aaa), 10 ); w_s( " 4\n" );
|
||||||
|
w_s( "sizeof(bbb): "); w_n( sizeof(bbb), 10 ); w_s( " 4\n" );
|
||||||
|
w_s( "sizeof(gc): "); w_n( sizeof(gc), 10 ); w_s( " 1\n" );
|
||||||
|
w_s( "sizeof(buffer): "); w_n( sizeof(buffer), 10 ); w_s( " 6\n" );
|
||||||
|
w_s( "sizeof(ibuffer): "); w_n( sizeof(ibuffer), 10 ); w_s( " 28\n" );
|
||||||
|
w_s( "sizeof(char): "); w_n( sizeof(char), 10 ); w_s( " 1\n" );
|
||||||
|
w_s( "sizeof(int): "); w_n( sizeof(int), 10 ); w_s( " 4\n" );
|
||||||
|
w_s( "sizeof(gbuffer): "); w_n( sizeof(gbuffer), 10 ); w_s( " 3\n" );
|
||||||
|
w_s( "sizeof(gibuffer): "); w_n( sizeof(gibuffer), 10 ); w_s( " 16\n" );
|
||||||
|
// sizeof(ibuffer[0]) is not supported, so the following can be used...
|
||||||
|
w_s( "sizeof(ibuffer)/sizeof(int): "); w_n( sizeof(ibuffer)/sizeof(int), 10 ); w_s( " 7\n" );
|
||||||
|
|
||||||
printf(" sizeof(uc1): %d 1\n", sizeof(uc1));
|
aaa = 1;
|
||||||
printf(" sizeof(sc1): %d 1\n", sizeof(sc1));
|
bbb = 2;
|
||||||
printf(" sizeof(u1): %d 4\n", sizeof(u1));
|
la = 4;
|
||||||
printf(" sizeof(s1): %d 4\n", sizeof(s1));
|
|
||||||
printf(" sizeof(aaa): %d 4\n", sizeof(aaa));
|
|
||||||
printf(" sizeof(bbb): %d 4\n", sizeof(bbb));
|
|
||||||
printf(" sizeof(gc): %d 1\n", sizeof(gc));
|
|
||||||
printf(" sizeof(buffer): %d 6\n", sizeof(buffer));
|
|
||||||
printf(" sizeof(ibuffer): %d 28\n", sizeof(ibuffer));
|
|
||||||
printf(" sizeof(char): %d 1\n", sizeof(char));
|
|
||||||
printf(" sizeof(int): %d 4\n", sizeof(int));
|
|
||||||
printf(" sizeof(gbuffer): %d 3\n", sizeof(gbuffer));
|
|
||||||
printf(" sizeof(gibuffer): %d 16\n", sizeof(gibuffer));
|
|
||||||
// sizeof(ibuffer[0]) is not supported, so the following can be used...
|
|
||||||
printf("sizeof(ibuffer)/sizeof(int): %d 7\n", sizeof(ibuffer)/sizeof(int));
|
|
||||||
|
|
||||||
aaa = 1;
|
|
||||||
bbb = 2;
|
w_n(aaa,10);
|
||||||
la = 4;
|
w_s(" 1\n");
|
||||||
printf("%d 1\n", aaa);
|
w_n(bbb,10);
|
||||||
printf("%d 2\n", bbb);
|
w_s(" 2\n");
|
||||||
printf("%d 4\n", la);
|
w_n(la,10);
|
||||||
|
w_s(" 4\n");
|
||||||
|
|
||||||
uc1 = 0x80;
|
uc1 = 0x80;
|
||||||
sc1 = 0x80;
|
sc1 = 0x80;
|
||||||
s1 = uc1;
|
s1 = uc1;
|
||||||
s2 = sc1;
|
s2 = sc1;
|
||||||
printf("unsigned char (0x80) -> int: %d 128\n", s1);
|
w_s( "unsigned char (0x80) -> int: "); w_n( s1, 10 ); w_s( " 128\n" );
|
||||||
printf(" signed char (0x80) -> int: %d -128\n", s2);
|
w_s( "signed char (0x80) -> int: "); w_n( s2, 10 ); w_s( " -128\n" );
|
||||||
|
|
||||||
u1 = uc1;
|
u1 = uc1;
|
||||||
u2 = sc1;
|
u2 = sc1;
|
||||||
printf("unsigned char (0x80) -> unsigned: %d 128\n", u1);
|
w_s( "unsigned char (0x80) -> unsigned: "); w_n( u1, 10 ); w_s( " 128\n" );
|
||||||
printf(" signed char (0x80) -> unsigned: %d -128\n", u2);
|
w_s( "signed char (0x80) -> unsigned: "); w_n( u2, 10 ); w_s( " -128\n" );
|
||||||
|
|
||||||
la = errno;
|
la = errno;
|
||||||
printf("errno: %d 0\n", la);
|
w_s("errno: "); w_n(la,10); w_s( " 0\n");
|
||||||
|
|
||||||
|
write( 1, "abcd ", 5 );
|
||||||
|
la = errno;
|
||||||
|
w_s("errno after good write call: "); w_n(la,10); w_s( " 0\n");
|
||||||
|
|
||||||
|
write( 10, "abcde", 5 );
|
||||||
|
la = errno;
|
||||||
|
w_s("errno after bad write call: "); w_n(la,10); w_s( " 9\n");
|
||||||
|
|
||||||
|
write( 1, "abcd ", 5 );
|
||||||
|
la = errno;
|
||||||
|
w_s("good write after failed should not overwrite errno: "); w_n(la,10); w_s( " 9\n");
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
write( 1, "abcd ", 5 );
|
||||||
|
la = errno;
|
||||||
|
w_s("good write after errno set to zero: "); w_n(la,10); w_s( " 0\n");
|
||||||
|
|
||||||
|
la = write( 1, "abcd ", 5 );
|
||||||
|
w_s( "write() return: " ); w_n(la,10); w_s( " 5\n" );
|
||||||
|
|
||||||
|
la = write( 10, "abcd ", 5 );
|
||||||
|
w_s( "write(bad fd) return: " ); w_n(la,10); w_s( " -1\n" );
|
||||||
|
|
||||||
write(1, "abcd ", 5);
|
fd = open( "/a.txt", O_WRONLY|O_CREAT, 0666 );
|
||||||
la = errno;
|
if( fd != -1 )
|
||||||
printf("errno after good write call: %d 0\n", la);
|
{
|
||||||
|
w_s("open success\n");
|
||||||
|
la = write( fd, "abcd\n", 5 );
|
||||||
|
if( la == 5 ) w_s( "write success\n" ); else w_s( "write failed\n" );
|
||||||
|
la = close( fd );
|
||||||
|
if( la != -1 ) w_s( "close success\n" ); else w_s( "close failed\n" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
w_s("open failed\n");
|
||||||
|
}
|
||||||
|
|
||||||
write(10, "abcde", 5);
|
buffer[0] = 0;
|
||||||
la = errno;
|
buffer[1] = 0;
|
||||||
printf("errno after bad write call: %d 9\n", la);
|
buffer[2] = 0;
|
||||||
|
buffer[3] = 0;
|
||||||
write(1, "abcd ", 5);
|
buffer[4] = 0;
|
||||||
la = errno;
|
buffer[5] = 0;
|
||||||
printf("good write after failed should not overwrite errno: %d 9\n", la);
|
|
||||||
|
fd = open( "/a.txt", O_RDONLY, 0666 );
|
||||||
errno = 0;
|
if( fd != -1 )
|
||||||
write(1, "abcd ", 5);
|
{
|
||||||
la = errno;
|
w_s("open success\n");
|
||||||
printf("good write after errno set to zero: %d 0\n", la);
|
la = read( fd, buffer, 5 );
|
||||||
|
w_s( buffer );
|
||||||
la = write(1, "abcd ", 5);
|
if( la == 5 ) w_s( "read success\n" ); else w_s( "read failed\n" );
|
||||||
printf("write() return: %d 5\n", la);
|
la = close( fd );
|
||||||
|
if( la != -1 ) w_s( "close success\n" ); else w_s( "close failed\n" );
|
||||||
la = write(10, "abcd ", 5);
|
}
|
||||||
printf("write(bad fd) return: %d -1\n", la);
|
else
|
||||||
|
{
|
||||||
fd = open("/a.txt", O_WRONLY | O_CREAT, 0666);
|
w_s("open failed\n");
|
||||||
if (fd != -1) {
|
}
|
||||||
printf("open success\n");
|
|
||||||
la = write(fd, "abcd\n", 5);
|
if( buffer[0] != 'a') w_s("data0 readback from file MISMATCH\n");
|
||||||
if (la == 5) printf("write success\n"); else printf("write failed\n");
|
if( buffer[1] != 'b') w_s("data1 readback from file MISMATCH\n");
|
||||||
la = close(fd);
|
if( buffer[2] != 'c') w_s("data2 readback from file MISMATCH\n");
|
||||||
if (la != -1) printf("close success\n"); else printf("close failed\n");
|
if( buffer[3] != 'd') w_s("data3 readback from file MISMATCH\n");
|
||||||
} else {
|
if( buffer[4] != '\n') w_s("data4 readback from file MISMATCH\n");
|
||||||
printf("open failed\n");
|
|
||||||
}
|
if( buffer[0] != 'a' || buffer[1] != 'b' || buffer[2] != 'c' || buffer[3] != 'd' || buffer[4] != '\n') w_s("data readback from file MISMATCH\n");
|
||||||
|
else w_s("data readback from file OK\n");
|
||||||
buffer[0] = 0;
|
|
||||||
buffer[1] = 0;
|
exit(0);
|
||||||
buffer[2] = 0;
|
|
||||||
buffer[3] = 0;
|
|
||||||
buffer[4] = 0;
|
|
||||||
buffer[5] = 0;
|
|
||||||
|
|
||||||
fd = open("/a.txt", O_RDONLY, 0666);
|
|
||||||
if (fd != -1) {
|
|
||||||
printf("open success\n");
|
|
||||||
la = read(fd, buffer, 5);
|
|
||||||
printf(buffer);
|
|
||||||
if (la == 5) printf("read success\n"); else printf("read failed\n");
|
|
||||||
la = close(fd);
|
|
||||||
if (la != -1) printf("close success\n"); else printf("close failed\n");
|
|
||||||
} else {
|
|
||||||
printf("open failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer[0] != 'a') printf("data0 readback from file MISMATCH\n");
|
|
||||||
if (buffer[1] != 'b') printf("data1 readback from file MISMATCH\n");
|
|
||||||
if (buffer[2] != 'c') printf("data2 readback from file MISMATCH\n");
|
|
||||||
if (buffer[3] != 'd') printf("data3 readback from file MISMATCH\n");
|
|
||||||
if (buffer[4] != '\n') printf("data4 readback from file MISMATCH\n");
|
|
||||||
|
|
||||||
if (buffer[0] != 'a' || buffer[1] != 'b' || buffer[2] != 'c' ||
|
|
||||||
buffer[3] != 'd' || buffer[4] != '\n') {
|
|
||||||
printf("data readback from file MISMATCH\n");
|
|
||||||
} else {
|
|
||||||
printf("data readback from file OK\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
main()
|
|
||||||
{
|
|
||||||
int t;
|
|
||||||
|
|
||||||
t = 0;
|
|
||||||
if (t) printt(t, "failure"); else printt(t, "success");
|
|
||||||
t = 1;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
t = 8;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
t = -2;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf("switch test: ");
|
|
||||||
switch (t) {
|
|
||||||
case 3:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
printf("success");
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("switch fallthrough test: ");
|
|
||||||
switch (t) {
|
|
||||||
case 3:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
printf("OKSOFAR: ");
|
|
||||||
case 5:
|
|
||||||
printf("success if oksofar printed before this in caps");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printt (t, str)
|
|
||||||
int t;
|
|
||||||
char *str;
|
|
||||||
{
|
|
||||||
printf("bool test on value %d %s\n", t, str);
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Web server, written in SmallC.
|
|
||||||
*
|
|
||||||
* A simple web server that shows the value of the analog input pins.
|
|
||||||
* using an Arduino Wiznet Ethernet shield.
|
|
||||||
*
|
|
||||||
* 18 Dec 2009 created by David A. Mellis
|
|
||||||
* 4 Sep 2010 modified by Tom Igoe
|
|
||||||
* 16 Apr 2012 ported to RetroBSD by Serge Vakulenko
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/gpio.h>
|
|
||||||
#include <wiznet.h>
|
|
||||||
|
|
||||||
int client [CLIENT_SIZE];
|
|
||||||
|
|
||||||
char buf [80];
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
/* Initialize the Ethernet server library
|
|
||||||
* with the IP address and port you want to use
|
|
||||||
* (port 80 is default for HTTP). */
|
|
||||||
ethernet_init ();
|
|
||||||
server_init (80);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
/* Listen for incoming clients. */
|
|
||||||
if (server_available (client)) {
|
|
||||||
process_request();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process_request()
|
|
||||||
{
|
|
||||||
int current_line_is_blank;
|
|
||||||
int c, fd, pnum, value;
|
|
||||||
|
|
||||||
/* An http request ends with a blank line. */
|
|
||||||
current_line_is_blank = 1;
|
|
||||||
|
|
||||||
/* Parse the http request. */
|
|
||||||
while (client_connected (client)) {
|
|
||||||
if (client_available (client)) {
|
|
||||||
c = client_getc (client);
|
|
||||||
|
|
||||||
/* If you've gotten to the end of the line (received
|
|
||||||
* a newline character) and the line is blank, the http
|
|
||||||
* request has ended, so you can send a reply. */
|
|
||||||
if (c == '\n' && current_line_is_blank)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (c == '\n') {
|
|
||||||
/* You're starting a new line. */
|
|
||||||
current_line_is_blank = 1;
|
|
||||||
}
|
|
||||||
else if (c != '\r') {
|
|
||||||
/* You've gotten a character on the current line. */
|
|
||||||
current_line_is_blank = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send a standard http response header. */
|
|
||||||
client_puts (client, "HTTP/1.1 200 OK\n");
|
|
||||||
client_puts (client, "Content-Type: text/html\n\n");
|
|
||||||
|
|
||||||
/* Output the value of each digital pin. */
|
|
||||||
fd = open ("/dev/porta", O_RDONLY);
|
|
||||||
if (fd < 0) {
|
|
||||||
client_puts (client, "Failed to open /dev/porta\n");
|
|
||||||
} else {
|
|
||||||
for (pnum = 0; pnum < 6; pnum++) {
|
|
||||||
value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0);
|
|
||||||
sprintf (buf, "PORT%c = 0x%04x <br />\n", pnum+'A', value);
|
|
||||||
client_puts (client, buf);
|
|
||||||
}
|
|
||||||
close (fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Give the web browser time to receive the data. */
|
|
||||||
usleep (1000);
|
|
||||||
|
|
||||||
/* Close the connection. */
|
|
||||||
client_stop (client);
|
|
||||||
}
|
|
||||||
@@ -21,7 +21,7 @@ FRC:
|
|||||||
install: elf32-mips.ld
|
install: elf32-mips.ld
|
||||||
-for i in $(SUBDIR); do \
|
-for i in $(SUBDIR); do \
|
||||||
$(MAKE) -C $$i DESTDIR=$(DESTDIR) all install; done
|
$(MAKE) -C $$i DESTDIR=$(DESTDIR) all install; done
|
||||||
# cp -p elf32-mips.ld $(DESTDIR)/lib/elf32-mips.ld
|
cp -p elf32-mips.ld $(DESTDIR)/lib/elf32-mips.ld
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f a.out core *.s *.o *.a *~
|
rm -f a.out core *.s *.o *.a *~
|
||||||
|
|||||||
71
src/cmd/.gitignore
vendored
71
src/cmd/.gitignore
vendored
@@ -1,71 +0,0 @@
|
|||||||
basename
|
|
||||||
bc
|
|
||||||
cal
|
|
||||||
cat
|
|
||||||
cb
|
|
||||||
chgrp
|
|
||||||
chmod
|
|
||||||
cmp
|
|
||||||
col
|
|
||||||
comm
|
|
||||||
cp
|
|
||||||
dd
|
|
||||||
df
|
|
||||||
du
|
|
||||||
echo
|
|
||||||
ed
|
|
||||||
egrep
|
|
||||||
expr
|
|
||||||
expr.c
|
|
||||||
false
|
|
||||||
fgrep
|
|
||||||
file
|
|
||||||
grep
|
|
||||||
head
|
|
||||||
hostid
|
|
||||||
iostat
|
|
||||||
join
|
|
||||||
kill
|
|
||||||
last
|
|
||||||
ln
|
|
||||||
mail
|
|
||||||
mesg
|
|
||||||
mkdir
|
|
||||||
mv
|
|
||||||
nice
|
|
||||||
nohup
|
|
||||||
od
|
|
||||||
pagesize
|
|
||||||
pr
|
|
||||||
printenv
|
|
||||||
ps
|
|
||||||
pwd
|
|
||||||
rev
|
|
||||||
rm
|
|
||||||
rmail
|
|
||||||
rmdir
|
|
||||||
size
|
|
||||||
sleep
|
|
||||||
sort
|
|
||||||
split
|
|
||||||
strip
|
|
||||||
su
|
|
||||||
sum
|
|
||||||
sync
|
|
||||||
tail
|
|
||||||
tar
|
|
||||||
tee
|
|
||||||
time
|
|
||||||
touch
|
|
||||||
tr
|
|
||||||
true
|
|
||||||
tsort
|
|
||||||
tty
|
|
||||||
uniq
|
|
||||||
vmstat
|
|
||||||
w
|
|
||||||
wall
|
|
||||||
wc
|
|
||||||
whereis
|
|
||||||
who
|
|
||||||
write
|
|
||||||
@@ -11,13 +11,12 @@ CFLAGS += -Werror
|
|||||||
# Programs that live in subdirectories, and have makefiles of their own.
|
# Programs that live in subdirectories, and have makefiles of their own.
|
||||||
# /bin
|
# /bin
|
||||||
SUBDIR = adb adc-demo ar as awk basic cc chflags chpass \
|
SUBDIR = adb adc-demo ar as awk basic cc chflags chpass \
|
||||||
cpp dc diff env fdisk find forth fstat glcdtest hostname \
|
cpp dc diff env find forth fstat glcdtest hostname \
|
||||||
id la lcc lcpp ld ls login make man med \
|
id la lcc lcpp ld ls login make man med \
|
||||||
more nm passwd picoc portio printf pwm \
|
more nm passwd portio printf pwm \
|
||||||
rdprof ranlib re renice retroforth scm setty sl \
|
ranlib re renice retroforth scm setty sl \
|
||||||
sed sh smallc smlrc stty sysctl test uname wiznet xargs \
|
sed sh smallc stty sysctl test uname wiznet xargs \
|
||||||
zmodem gtest msec unixbench cron compress date2 tip \
|
zmodem gtest cron uflash_r picoc-1 lccom-1
|
||||||
talloc devupdate uucp smux
|
|
||||||
|
|
||||||
# /sbin
|
# /sbin
|
||||||
SUBDIR += chown chroot disktool fsck getty init \
|
SUBDIR += chown chroot disktool fsck getty init \
|
||||||
@@ -33,11 +32,11 @@ SCRIPT = false nohup true #lorder mkdep
|
|||||||
# C programs that live in the current directory and do not need
|
# C programs that live in the current directory and do not need
|
||||||
# explicit make lines.
|
# explicit make lines.
|
||||||
#
|
#
|
||||||
STD = basename cal cat cb chgrp chmod cmp col comm cp dd du \
|
STD = basename cal cat cb chgrp chmod cmp col comm cp date dd du \
|
||||||
echo ed fgrep file grep head hostid join kill last ln \
|
echo ed fgrep file grep head hostid join kill last ln \
|
||||||
mesg mkdir mv nice od pagesize pr printenv pwd rev rm rmail rmdir \
|
mesg mkdir mv nice od pagesize pr printenv pwd rev rm rmail rmdir \
|
||||||
size sleep sort split sum sync tail tar tee time touch tr \
|
size sleep sort split sum sync tail tar tee time touch tr \
|
||||||
tsort tty uniq w wc whereis who
|
tsort tty uniq w wc whereis who uflash
|
||||||
|
|
||||||
# C programs that live in the current directory and need explicit make lines.
|
# C programs that live in the current directory and need explicit make lines.
|
||||||
#
|
#
|
||||||
|
|||||||
1
src/cmd/adb/.gitignore
vendored
1
src/cmd/adb/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
adb
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
TOPSRC = $(shell cd ../../..; pwd)
|
TOPSRC = $(shell cd ../../..; pwd)
|
||||||
include $(TOPSRC)/target.mk
|
include $(TOPSRC)/target.mk
|
||||||
#include $(TOPSRC)/cross.mk
|
#include $(TOPSRC)/cross.mk
|
||||||
#CFLAGS = -DCROSS -I$(TOPSRC)/include -I/usr/include -D__mips__ -ggdb3
|
|
||||||
|
|
||||||
OBJS = message.o access.o command.o expr.o findfn.o format.o input.o \
|
OBJS = message.o access.o command.o expr.o findfn.o format.o input.o \
|
||||||
main.o opset.o output.o pcs.o print.o \
|
main.o opset.o output.o pcs.o print.o \
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* File handling and access routines
|
* File handling and access routines
|
||||||
*/
|
*/
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
within(adr, lbd, ubd)
|
within(adr, lbd, ubd)
|
||||||
@@ -60,7 +59,7 @@ acces(mode, adr, space, value)
|
|||||||
long adr;
|
long adr;
|
||||||
{
|
{
|
||||||
int w, w1, pmode, rd, file;
|
int w, w1, pmode, rd, file;
|
||||||
BKPTR bkptr;
|
BKPTR bkptr, scanbkpt();
|
||||||
|
|
||||||
if (space == NSP)
|
if (space == NSP)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -90,7 +89,7 @@ acces(mode, adr, space, value)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
w = 0;
|
w = 0;
|
||||||
if (mode==WT && wtflag==O_RDONLY) {
|
if (mode==WT && wtflag==0) {
|
||||||
error("not in write mode");
|
error("not in write mode");
|
||||||
}
|
}
|
||||||
if (! chkmap(&adr, space))
|
if (! chkmap(&adr, space))
|
||||||
|
|||||||
@@ -190,8 +190,7 @@ trypr:
|
|||||||
regptr = getreg(savc);
|
regptr = getreg(savc);
|
||||||
if (regptr != NOREG) {
|
if (regptr != NOREG) {
|
||||||
uframe[regptr] = shorten(dot);
|
uframe[regptr] = shorten(dot);
|
||||||
ptrace(PT_WRITE_U, pid, (char*) (KERNEL_DATA_END - USIZE) +
|
ptrace(PT_WRITE_U, pid, &uframe[regptr] - (int)&corhdr,
|
||||||
((char*)&uframe[regptr] - (char*)&corhdr),
|
|
||||||
uframe[regptr]);
|
uframe[regptr]);
|
||||||
} else if ((modifier = varchk(savc)) != -1) {
|
} else if ((modifier = varchk(savc)) != -1) {
|
||||||
var[modifier] = dot;
|
var[modifier] = dot;
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../../../..; pwd)
|
|
||||||
include $(TOPSRC)/cross.mk
|
|
||||||
|
|
||||||
vpath %.c ..
|
|
||||||
|
|
||||||
# Build a list of the host include directories.
|
|
||||||
CPP = $(shell gcc -print-prog-name=cc1)
|
|
||||||
HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
|
|
||||||
HOSTINC += -I/usr/include/i386-linux-gnu
|
|
||||||
|
|
||||||
CFLAGS = -m32 -g -DCROSS -nostdinc -I. $(HOSTINC) -I.. -D__mips__
|
|
||||||
CFLAGS += -Wall -Werror -DNUM_SYMS_CACHE=50 -fno-builtin
|
|
||||||
LDFLAGS += -m32 -g
|
|
||||||
|
|
||||||
OBJS = message.o access.o command.o expr.o findfn.o format.o input.o \
|
|
||||||
main.o opset.o output.o pcs.o print.o \
|
|
||||||
runpcs.o setup.o sym.o
|
|
||||||
HEADERS = a.out.h nlist.h time.h signal.h stdlib.h \
|
|
||||||
sys/exec.h sys/types.h sys/param.h sys/user.h \
|
|
||||||
sys/time.h sys/dir.h sys/resource.h sys/select.h \
|
|
||||||
sys/signal.h sys/wait.h \
|
|
||||||
machine/io.h machine/machparam.h
|
|
||||||
|
|
||||||
all: $(HEADERS) adb
|
|
||||||
|
|
||||||
adb: $(OBJS)
|
|
||||||
$(CC) $(LDFLAGS) $(OBJS) -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o adb *.h */*.h gccdump.s
|
|
||||||
|
|
||||||
$(HEADERS):
|
|
||||||
ln -s -f ../../../../include/a.out.h .
|
|
||||||
ln -s -f ../../../../include/nlist.h .
|
|
||||||
ln -s -f ../../../../include/time.h .
|
|
||||||
ln -s -f ../../../../include/stdlib.h .
|
|
||||||
ln -s -f sys/signal.h .
|
|
||||||
ln -s -f ../../../../../include/sys/exec.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/param.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/user.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/types.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/time.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/dir.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/resource.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/select.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/wait.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/signal.h sys/
|
|
||||||
ln -s -f ../../../../../include/machine/io.h machine/
|
|
||||||
ln -s -f ../../../../../include/machine/machparam.h machine/
|
|
||||||
|
|
||||||
test:
|
|
||||||
echo '$$q' | ./adb fsck fsck.core
|
|
||||||
@printf '\n----------------------------\n'
|
|
||||||
echo '$$m' | ./adb fsck fsck.core
|
|
||||||
@printf '\n----------------------------\n'
|
|
||||||
@@ -8,22 +8,16 @@
|
|||||||
* This has changed over time - see a.out.h, sys/exec.h and nlist.h
|
* This has changed over time - see a.out.h, sys/exec.h and nlist.h
|
||||||
* for the current a.out definition and format.
|
* for the current a.out definition and format.
|
||||||
*/
|
*/
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
#include <machine/io.h>
|
#include <machine/io.h>
|
||||||
|
#include <sgtty.h>
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <a.out.h>
|
#include <a.out.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
#ifdef CROSS
|
|
||||||
# include <termios.h>
|
|
||||||
# define sgttyb termios
|
|
||||||
#else
|
|
||||||
# include <sgtty.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MAXSYMLEN 32
|
#define MAXSYMLEN 32
|
||||||
#define MAXCOM 64
|
#define MAXCOM 64
|
||||||
@@ -55,6 +49,7 @@ typedef struct map MAP;
|
|||||||
typedef MAP *MAPPTR;
|
typedef MAP *MAPPTR;
|
||||||
typedef struct bkpt BKPT;
|
typedef struct bkpt BKPT;
|
||||||
typedef BKPT *BKPTR;
|
typedef BKPT *BKPTR;
|
||||||
|
typedef struct user U;
|
||||||
|
|
||||||
/* file address maps */
|
/* file address maps */
|
||||||
struct map {
|
struct map {
|
||||||
@@ -134,9 +129,7 @@ typedef struct reglist REGLIST;
|
|||||||
#define MAXPOS 80
|
#define MAXPOS 80
|
||||||
#define MAXLIN 128
|
#define MAXLIN 128
|
||||||
|
|
||||||
#ifndef TRUE
|
#define TRUE (-1)
|
||||||
#define TRUE (-1)
|
|
||||||
#endif
|
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define LOBYTE 0377
|
#define LOBYTE 0377
|
||||||
#define HIBYTE 0177400
|
#define HIBYTE 0177400
|
||||||
@@ -150,7 +143,7 @@ typedef struct reglist REGLIST;
|
|||||||
|
|
||||||
/* long to ints and back (puns) */
|
/* long to ints and back (puns) */
|
||||||
#define leng(a) ((long)((unsigned)(a)))
|
#define leng(a) ((long)((unsigned)(a)))
|
||||||
#define shorten(a) ((long)a)
|
#define shorten(a) ((int)a)
|
||||||
|
|
||||||
struct sgttyb adbtty, usrtty;
|
struct sgttyb adbtty, usrtty;
|
||||||
jmp_buf erradb;
|
jmp_buf erradb;
|
||||||
|
|||||||
@@ -1,961 +0,0 @@
|
|||||||
.sp 100
|
|
||||||
.nr PS 9
|
|
||||||
.nr VS 11
|
|
||||||
. \" START OF Figures
|
|
||||||
.de P1
|
|
||||||
.nf
|
|
||||||
.in +.5i
|
|
||||||
.ta .5i 1i 1.5i 2i 2.5i 3i 3.5i 4i 4.5i 5i
|
|
||||||
.sp
|
|
||||||
.ps 9
|
|
||||||
.vs 11p
|
|
||||||
..
|
|
||||||
.de P2
|
|
||||||
.sp
|
|
||||||
.fi
|
|
||||||
.ps \\n(PS
|
|
||||||
.vs \\n(VS
|
|
||||||
.in -.5i
|
|
||||||
..
|
|
||||||
.SH
|
|
||||||
Figure 1: C program with pointer bug
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
struct buf {
|
|
||||||
int fildes;
|
|
||||||
int nleft;
|
|
||||||
char *nextp;
|
|
||||||
char buff[512];
|
|
||||||
}bb;
|
|
||||||
struct buf *obuf;
|
|
||||||
|
|
||||||
char *charp "this is a sentence.";
|
|
||||||
|
|
||||||
main(argc,argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
char cc;
|
|
||||||
|
|
||||||
if(argc < 2) {
|
|
||||||
printf("Input file missing\\n");
|
|
||||||
exit(8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((fcreat(argv[1],obuf)) < 0){
|
|
||||||
printf("%s : not found\\n", argv[1]);
|
|
||||||
exit(8);
|
|
||||||
}
|
|
||||||
charp = \'T\';
|
|
||||||
printf("debug 1 %s\\n",charp);
|
|
||||||
while(cc= *charp++)
|
|
||||||
putc(cc,obuf);
|
|
||||||
fflush(obuf);
|
|
||||||
}
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 2: ADB output for C program of Figure 1
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
.ft B
|
|
||||||
adb a.out core
|
|
||||||
$c
|
|
||||||
.ft R
|
|
||||||
~main(02,0177762)
|
|
||||||
.ft B
|
|
||||||
$C
|
|
||||||
.ft R
|
|
||||||
~main(02,0177762)
|
|
||||||
argc: 02
|
|
||||||
argv: 0177762
|
|
||||||
cc: 02124
|
|
||||||
.ft B
|
|
||||||
$r
|
|
||||||
.ft R
|
|
||||||
ps 0170010
|
|
||||||
pc 0204 ~main+0152
|
|
||||||
sp 0177740
|
|
||||||
r5 0177752
|
|
||||||
r4 01
|
|
||||||
r3 0
|
|
||||||
r2 0
|
|
||||||
r1 0
|
|
||||||
r0 0124
|
|
||||||
~main+0152: mov _obuf,(sp)
|
|
||||||
.ft B
|
|
||||||
$e
|
|
||||||
.ft R
|
|
||||||
savr5: 0
|
|
||||||
_obuf: 0
|
|
||||||
_charp: 0124
|
|
||||||
_errno: 0
|
|
||||||
_fout: 0
|
|
||||||
.ft B
|
|
||||||
$m
|
|
||||||
.ft R
|
|
||||||
text map \`ex1\'
|
|
||||||
b1 = 0 e1 = 02360 f1 = 020
|
|
||||||
b2 = 0 e2 = 02360 f2 = 020
|
|
||||||
data map \`core1\'
|
|
||||||
b1 = 0 e1 = 03500 f1 = 02000
|
|
||||||
b2 = 0175400 e2 = 0200000 f2 = 05500
|
|
||||||
.ft B
|
|
||||||
*charp/s
|
|
||||||
.ft R
|
|
||||||
0124: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTLx Nh@x&_
|
|
||||||
~
|
|
||||||
.ft B
|
|
||||||
charp/s
|
|
||||||
.ft R
|
|
||||||
_charp: T
|
|
||||||
|
|
||||||
_charp+02: this is a sentence.
|
|
||||||
|
|
||||||
_charp+026: Input file missing
|
|
||||||
.ft B
|
|
||||||
main.argc/d
|
|
||||||
.ft R
|
|
||||||
0177756: 2
|
|
||||||
.ft B
|
|
||||||
*main.argv/3o
|
|
||||||
.ft R
|
|
||||||
0177762: 0177770 0177776 0177777
|
|
||||||
.ft B
|
|
||||||
0177770/s
|
|
||||||
.ft R
|
|
||||||
0177770: a.out
|
|
||||||
.ft B
|
|
||||||
*main.argv/3o
|
|
||||||
.ft R
|
|
||||||
0177762: 0177770 0177776 0177777
|
|
||||||
.ft B
|
|
||||||
*"/s
|
|
||||||
.ft R
|
|
||||||
0177770: a.out
|
|
||||||
.ft B
|
|
||||||
.=o
|
|
||||||
.ft R
|
|
||||||
0177770
|
|
||||||
.ft B
|
|
||||||
.\(mi10/d
|
|
||||||
.ft R
|
|
||||||
0177756: 2
|
|
||||||
.ft B
|
|
||||||
$q
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 3: Multiple function C program for stack trace illustration
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
int fcnt,gcnt,hcnt;
|
|
||||||
h(x,y)
|
|
||||||
{
|
|
||||||
int hi; register int hr;
|
|
||||||
hi = x+1;
|
|
||||||
hr = x\(miy+1;
|
|
||||||
hcnt++ ;
|
|
||||||
hj:
|
|
||||||
f(hr,hi);
|
|
||||||
}
|
|
||||||
|
|
||||||
g(p,q)
|
|
||||||
{
|
|
||||||
int gi; register int gr;
|
|
||||||
gi = q\(mip;
|
|
||||||
gr = q\(mip+1;
|
|
||||||
gcnt++ ;
|
|
||||||
gj:
|
|
||||||
h(gr,gi);
|
|
||||||
}
|
|
||||||
|
|
||||||
f(a,b)
|
|
||||||
{
|
|
||||||
int fi; register int fr;
|
|
||||||
fi = a+2*b;
|
|
||||||
fr = a+b;
|
|
||||||
fcnt++ ;
|
|
||||||
fj:
|
|
||||||
g(fr,fi);
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
f(1,1);
|
|
||||||
}
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 4: ADB output for C program of Figure 3
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
.ft B
|
|
||||||
adb
|
|
||||||
$c
|
|
||||||
.ft R
|
|
||||||
~h(04452,04451)
|
|
||||||
~g(04453,011124)
|
|
||||||
~f(02,04451)
|
|
||||||
~h(04450,04447)
|
|
||||||
~g(04451,011120)
|
|
||||||
~f(02,04447)
|
|
||||||
~h(04446,04445)
|
|
||||||
~g(04447,011114)
|
|
||||||
~f(02,04445)
|
|
||||||
~h(04444,04443)
|
|
||||||
.ft B
|
|
||||||
HIT DEL KEY
|
|
||||||
.ft R
|
|
||||||
adb
|
|
||||||
.ft B
|
|
||||||
,5$C
|
|
||||||
.ft R
|
|
||||||
~h(04452,04451)
|
|
||||||
x: 04452
|
|
||||||
y: 04451
|
|
||||||
hi: ?
|
|
||||||
~g(04453,011124)
|
|
||||||
p: 04453
|
|
||||||
q: 011124
|
|
||||||
gi: 04451
|
|
||||||
gr: ?
|
|
||||||
~f(02,04451)
|
|
||||||
a: 02
|
|
||||||
b: 04451
|
|
||||||
fi: 011124
|
|
||||||
fr: 04453
|
|
||||||
~h(04450,04447)
|
|
||||||
x: 04450
|
|
||||||
y: 04447
|
|
||||||
hi: 04451
|
|
||||||
hr: 02
|
|
||||||
~g(04451,011120)
|
|
||||||
p: 04451
|
|
||||||
q: 011120
|
|
||||||
gi: 04447
|
|
||||||
gr: 04450
|
|
||||||
.ft B
|
|
||||||
fcnt/d
|
|
||||||
.ft R
|
|
||||||
_fcnt: 1173
|
|
||||||
.ft B
|
|
||||||
gcnt/d
|
|
||||||
.ft R
|
|
||||||
_gcnt: 1173
|
|
||||||
.ft B
|
|
||||||
hcnt/d
|
|
||||||
.ft R
|
|
||||||
_hcnt: 1172
|
|
||||||
.ft B
|
|
||||||
h.x/d
|
|
||||||
.ft R
|
|
||||||
022004: 2346
|
|
||||||
.ft B
|
|
||||||
$q
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 5: C program to decode tabs
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
#define MAXLINE 80
|
|
||||||
#define YES 1
|
|
||||||
#define NO 0
|
|
||||||
#define TABSP 8
|
|
||||||
.sp .5
|
|
||||||
char input[] "data";
|
|
||||||
char ibuf[518];
|
|
||||||
int tabs[MAXLINE];
|
|
||||||
.sp .5
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int col, *ptab;
|
|
||||||
char c;
|
|
||||||
.sp .5
|
|
||||||
ptab = tabs;
|
|
||||||
settab(ptab); /*Set initial tab stops */
|
|
||||||
col = 1;
|
|
||||||
if(fopen(input,ibuf) < 0) {
|
|
||||||
printf("%s : not found\\n",input);
|
|
||||||
exit(8);
|
|
||||||
}
|
|
||||||
while((c = getc(ibuf)) != \(mi1) {
|
|
||||||
switch(c) {
|
|
||||||
case \(fm\\t\(fm: /* TAB */
|
|
||||||
while(tabpos(col) != YES) {
|
|
||||||
putchar(\(fm \(fm); /* put BLANK */
|
|
||||||
col++ ;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case \(fm\\n\(fm: /*NEWLINE */
|
|
||||||
putchar(\(fm\\n\(fm);
|
|
||||||
col = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
putchar(c);
|
|
||||||
col++ ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.sp .5
|
|
||||||
/* Tabpos return YES if col is a tab stop */
|
|
||||||
tabpos(col)
|
|
||||||
int col;
|
|
||||||
{
|
|
||||||
if(col > MAXLINE)
|
|
||||||
return(YES);
|
|
||||||
else
|
|
||||||
return(tabs[col]);
|
|
||||||
}
|
|
||||||
.sp .5
|
|
||||||
/* Settab - Set initial tab stops */
|
|
||||||
settab(tabp)
|
|
||||||
int *tabp;
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
.sp .5
|
|
||||||
for(i = 0; i<= MAXLINE; i++)
|
|
||||||
(i%TABSP) ? (tabs[i] = NO) : (tabs[i] = YES);
|
|
||||||
}
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 6a: ADB output for C program of Figure 5
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
.ft B
|
|
||||||
adb a.out \(mi
|
|
||||||
settab+4:b
|
|
||||||
fopen+4:b
|
|
||||||
getc+4:b
|
|
||||||
tabpos+4:b
|
|
||||||
$b
|
|
||||||
.ft R
|
|
||||||
breakpoints
|
|
||||||
count bkpt command
|
|
||||||
1 ~tabpos+04
|
|
||||||
1 _getc+04
|
|
||||||
1 _fopen+04
|
|
||||||
1 ~settab+04
|
|
||||||
.ft B
|
|
||||||
settab,5?ia
|
|
||||||
.ft R
|
|
||||||
~settab: jsr r5,csv
|
|
||||||
~settab+04: tst \(mi(sp)
|
|
||||||
~settab+06: clr 0177770(r5)
|
|
||||||
~settab+012: cmp $0120,0177770(r5)
|
|
||||||
~settab+020: blt ~settab+076
|
|
||||||
~settab+022:
|
|
||||||
.ft B
|
|
||||||
settab,5?i
|
|
||||||
.ft R
|
|
||||||
~settab: jsr r5,csv
|
|
||||||
tst \(mi(sp)
|
|
||||||
clr 0177770(r5)
|
|
||||||
cmp $0120,0177770(r5)
|
|
||||||
blt ~settab+076
|
|
||||||
.ft B
|
|
||||||
:r
|
|
||||||
.ft R
|
|
||||||
a.out: running
|
|
||||||
breakpoint ~settab+04: tst \(mi(sp)
|
|
||||||
.ft B
|
|
||||||
settab+4:d
|
|
||||||
:c
|
|
||||||
.ft R
|
|
||||||
a.out: running
|
|
||||||
breakpoint _fopen+04: mov 04(r5),nulstr+012
|
|
||||||
.ft B
|
|
||||||
$C
|
|
||||||
.ft R
|
|
||||||
_fopen(02302,02472)
|
|
||||||
~main(01,0177770)
|
|
||||||
col: 01
|
|
||||||
c: 0
|
|
||||||
ptab: 03500
|
|
||||||
.ft B
|
|
||||||
tabs,3/8o
|
|
||||||
.ft R
|
|
||||||
03500: 01 0 0 0 0 0 0 0
|
|
||||||
01 0 0 0 0 0 0 0
|
|
||||||
01 0 0 0 0 0 0 0
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 6b: ADB output for C program of Figure 5
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
.ft B
|
|
||||||
:c
|
|
||||||
.ft R
|
|
||||||
a.out: running
|
|
||||||
breakpoint _getc+04: mov 04(r5),r1
|
|
||||||
.ft B
|
|
||||||
ibuf+6/20c
|
|
||||||
.ft R
|
|
||||||
__cleanu+0202: This is a test of
|
|
||||||
.ft B
|
|
||||||
:c
|
|
||||||
.ft R
|
|
||||||
a.out: running
|
|
||||||
breakpoint ~tabpos+04: cmp $0120,04(r5)
|
|
||||||
.ft B
|
|
||||||
tabpos+4:d
|
|
||||||
settab+4:b settab,5?ia
|
|
||||||
settab+4:b settab,5?ia; 0
|
|
||||||
getc+4,3:b main.c?C; 0
|
|
||||||
settab+4:b settab,5?ia; ptab/o; 0
|
|
||||||
$b
|
|
||||||
.ft R
|
|
||||||
breakpoints
|
|
||||||
count bkpt command
|
|
||||||
1 ~tabpos+04
|
|
||||||
3 _getc+04 main.c?C;0
|
|
||||||
1 _fopen+04
|
|
||||||
1 ~settab+04 settab,5?ia;ptab?o;0
|
|
||||||
~settab: jsr r5,csv
|
|
||||||
~settab+04: bpt
|
|
||||||
~settab+06: clr 0177770(r5)
|
|
||||||
~settab+012: cmp $0120,0177770(r5)
|
|
||||||
~settab+020: blt ~settab+076
|
|
||||||
~settab+022:
|
|
||||||
0177766: 0177770
|
|
||||||
0177744: @\`
|
|
||||||
T0177744: T
|
|
||||||
h0177744: h
|
|
||||||
i0177744: i
|
|
||||||
s0177744: s
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 7: ADB output for C program with breakpoints
|
|
||||||
.LP
|
|
||||||
.in +.5i
|
|
||||||
.nf
|
|
||||||
.ps 8
|
|
||||||
.vs 9
|
|
||||||
.ft B
|
|
||||||
adb ex3 \(mi
|
|
||||||
h+4:b hcnt/d; h.hi/; h.hr/
|
|
||||||
g+4:b gcnt/d; g.gi/; g.gr/
|
|
||||||
f+4:b fcnt/d; f.fi/; f.fr/
|
|
||||||
:r
|
|
||||||
.ft R
|
|
||||||
ex3: running
|
|
||||||
_fcnt: 0
|
|
||||||
0177732: 214
|
|
||||||
symbol not found
|
|
||||||
.ft B
|
|
||||||
f+4:b fcnt/d; f.a/; f.b/; f.fi/
|
|
||||||
g+4:b gcnt/d; g.p/; g.q/; g.gi/
|
|
||||||
h+4:b hcnt/d; h.x/; h.y/; h.hi/
|
|
||||||
:c
|
|
||||||
.ft R
|
|
||||||
ex3: running
|
|
||||||
_fcnt: 0
|
|
||||||
0177746: 1
|
|
||||||
0177750: 1
|
|
||||||
0177732: 214
|
|
||||||
_gcnt: 0
|
|
||||||
0177726: 2
|
|
||||||
0177730: 3
|
|
||||||
0177712: 214
|
|
||||||
_hcnt: 0
|
|
||||||
0177706: 2
|
|
||||||
0177710: 1
|
|
||||||
0177672: 214
|
|
||||||
_fcnt: 1
|
|
||||||
0177666: 2
|
|
||||||
0177670: 3
|
|
||||||
0177652: 214
|
|
||||||
_gcnt: 1
|
|
||||||
0177646: 5
|
|
||||||
0177650: 8
|
|
||||||
0177632: 214
|
|
||||||
.ft B
|
|
||||||
HIT DEL
|
|
||||||
f+4:b fcnt/d; f.a/"a = "d; f.b/"b = "d; f.fi/"fi = "d
|
|
||||||
g+4:b gcnt/d; g.p/"p = "d; g.q/"q = "d; g.gi/"gi = "d
|
|
||||||
h+4:b hcnt/d; h.x/"x = "d; h.y/"h = "d; h.hi/"hi = "d
|
|
||||||
:r
|
|
||||||
.ft R
|
|
||||||
ex3: running
|
|
||||||
_fcnt: 0
|
|
||||||
0177746: a = 1
|
|
||||||
0177750: b = 1
|
|
||||||
0177732: fi = 214
|
|
||||||
_gcnt: 0
|
|
||||||
0177726: p = 2
|
|
||||||
0177730: q = 3
|
|
||||||
0177712: gi = 214
|
|
||||||
_hcnt: 0
|
|
||||||
0177706: x = 2
|
|
||||||
0177710: y = 1
|
|
||||||
0177672: hi = 214
|
|
||||||
_fcnt: 1
|
|
||||||
0177666: a = 2
|
|
||||||
0177670: b = 3
|
|
||||||
0177652: fi = 214
|
|
||||||
.ft B
|
|
||||||
HIT DEL
|
|
||||||
$q
|
|
||||||
.in -.5i
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 8: ADB address maps
|
|
||||||
.LP
|
|
||||||
.de l1
|
|
||||||
.tc
|
|
||||||
.ta 1.20i +1.6i +2.5i
|
|
||||||
..
|
|
||||||
.de l3
|
|
||||||
.tc
|
|
||||||
.ta 1.6i +2.80i +.2i +1.55i
|
|
||||||
..
|
|
||||||
.de l2
|
|
||||||
.tc
|
|
||||||
.ti 1.0i
|
|
||||||
.ta +0.5i +3.0i +1.75i
|
|
||||||
.tc _
|
|
||||||
..
|
|
||||||
.de l5
|
|
||||||
.tc
|
|
||||||
.ti 1.0i
|
|
||||||
.ta +0.75i +3.0i +1.5i
|
|
||||||
.tc _
|
|
||||||
..
|
|
||||||
.de l6
|
|
||||||
.tc
|
|
||||||
.ti 1.0i
|
|
||||||
.ta +.8i +2.85i +0.4i +1.1i
|
|
||||||
..
|
|
||||||
.de l8
|
|
||||||
.tc
|
|
||||||
.ti 1.0i
|
|
||||||
.ta +0.5i +3.0i +1.75i
|
|
||||||
.tc _
|
|
||||||
..
|
|
||||||
.de la
|
|
||||||
.tc
|
|
||||||
.ta 1.20i +1.25i +1.7i
|
|
||||||
..
|
|
||||||
.de lc
|
|
||||||
.tc
|
|
||||||
.ti 1.0i
|
|
||||||
.ta +.85i +1.6i +.35i +1.1i
|
|
||||||
..
|
|
||||||
.de lb
|
|
||||||
.tc
|
|
||||||
.ti 1.0i
|
|
||||||
.ta +0.75i +1.75i +1.5i
|
|
||||||
.tc _
|
|
||||||
..
|
|
||||||
.ul
|
|
||||||
407 files
|
|
||||||
.sp
|
|
||||||
.l1
|
|
||||||
a.out hdr text+data
|
|
||||||
.l2
|
|
||||||
| | |
|
|
||||||
.l3
|
|
||||||
0 D
|
|
||||||
.sp
|
|
||||||
.l1
|
|
||||||
core hdr text+data stack
|
|
||||||
.l5
|
|
||||||
| | ......| |
|
|
||||||
.l6
|
|
||||||
0 D S E
|
|
||||||
.sp 2
|
|
||||||
.ul
|
|
||||||
410 files (shared text)
|
|
||||||
.sp
|
|
||||||
.l1
|
|
||||||
a.out hdr text data
|
|
||||||
.l2
|
|
||||||
| | | |
|
|
||||||
.l3
|
|
||||||
0 T B D
|
|
||||||
.sp
|
|
||||||
.la
|
|
||||||
core hdr data stack
|
|
||||||
.lb
|
|
||||||
| | ......| |
|
|
||||||
.lc
|
|
||||||
B D S E
|
|
||||||
.sp 2
|
|
||||||
.ul
|
|
||||||
411 files (separated I and D space)
|
|
||||||
.sp
|
|
||||||
.l1
|
|
||||||
a.out hdr text data
|
|
||||||
.l2
|
|
||||||
| | | |
|
|
||||||
.l3
|
|
||||||
0 T 0 D
|
|
||||||
.sp
|
|
||||||
.la
|
|
||||||
core hdr data stack
|
|
||||||
.lb
|
|
||||||
| | ......| |
|
|
||||||
.lc
|
|
||||||
0 D S E
|
|
||||||
.sp 2
|
|
||||||
The following
|
|
||||||
.ul
|
|
||||||
adb
|
|
||||||
variables are set.
|
|
||||||
.nf
|
|
||||||
.ta .75i 1.5i 3.5i 4.5i 5.5i
|
|
||||||
.sp
|
|
||||||
407 410 411
|
|
||||||
.sp
|
|
||||||
b base of data 0 B 0
|
|
||||||
d length of data D D\(miB D
|
|
||||||
s length of stack S S S
|
|
||||||
t length of text 0 T T
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 9: ADB output for maps
|
|
||||||
.LP
|
|
||||||
.nf
|
|
||||||
.in +.5i
|
|
||||||
.ft B
|
|
||||||
adb map407 core407
|
|
||||||
$m
|
|
||||||
.ft R
|
|
||||||
text map \`map407\'
|
|
||||||
b1 = 0 e1 = 0256 f1 = 020
|
|
||||||
b2 = 0 e2 = 0256 f2 = 020
|
|
||||||
data map \`core407\'
|
|
||||||
b1 = 0 e1 = 0300 f1 = 02000
|
|
||||||
b2 = 0175400 e2 = 0200000 f2 = 02300
|
|
||||||
.ft B
|
|
||||||
$v
|
|
||||||
.ft R
|
|
||||||
variables
|
|
||||||
d = 0300
|
|
||||||
m = 0407
|
|
||||||
s = 02400
|
|
||||||
.ft B
|
|
||||||
$q
|
|
||||||
.sp 2
|
|
||||||
adb map410 core410
|
|
||||||
$m
|
|
||||||
.ft R
|
|
||||||
text map \`map410\'
|
|
||||||
b1 = 0 e1 = 0200 f1 = 020
|
|
||||||
b2 = 020000 e2 = 020116 f2 = 0220
|
|
||||||
data map \`core410\'
|
|
||||||
b1 = 020000 e1 = 020200 f1 = 02000
|
|
||||||
b2 = 0175400 e2 = 0200000 f2 = 02200
|
|
||||||
.ft B
|
|
||||||
$v
|
|
||||||
.ft R
|
|
||||||
variables
|
|
||||||
b = 020000
|
|
||||||
d = 0200
|
|
||||||
m = 0410
|
|
||||||
s = 02400
|
|
||||||
t = 0200
|
|
||||||
.ft B
|
|
||||||
$q
|
|
||||||
.sp 2
|
|
||||||
adb map411 core411
|
|
||||||
$m
|
|
||||||
.ft R
|
|
||||||
text map \`map411\'
|
|
||||||
b1 = 0 e1 = 0200 f1 = 020
|
|
||||||
b2 = 0 e2 = 0116 f2 = 0220
|
|
||||||
data map \`core411\'
|
|
||||||
b1 = 0 e1 = 0200 f1 = 02000
|
|
||||||
b2 = 0175400 e2 = 0200000 f2 = 02200
|
|
||||||
.ft B
|
|
||||||
$v
|
|
||||||
.ft R
|
|
||||||
variables
|
|
||||||
d = 0200
|
|
||||||
m = 0411
|
|
||||||
s = 02400
|
|
||||||
t = 0200
|
|
||||||
.ft B
|
|
||||||
$q
|
|
||||||
.in -.5i
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 10: Simple C program for illustrating formatting and patching
|
|
||||||
.LP
|
|
||||||
.P1
|
|
||||||
char str1[] "This is a character string";
|
|
||||||
int one 1;
|
|
||||||
int number 456;
|
|
||||||
long lnum 1234;
|
|
||||||
float fpt 1.25;
|
|
||||||
char str2[] "This is the second character string";
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
one = 2;
|
|
||||||
}
|
|
||||||
.P2
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 11: ADB output illustrating fancy formats
|
|
||||||
.LP
|
|
||||||
.nf
|
|
||||||
.ps 9
|
|
||||||
.vs 11p
|
|
||||||
.ft B
|
|
||||||
adb map410 core410
|
|
||||||
<b,\(mi1/8ona
|
|
||||||
.ft R
|
|
||||||
020000: 0 064124 071551 064440 020163 020141 064143 071141
|
|
||||||
.sp .5
|
|
||||||
_str1+016: 061541 062564 020162 072163 064562 063556 0 02
|
|
||||||
.sp .5
|
|
||||||
_number:
|
|
||||||
_number: 0710 0 02322 040240 0 064124 071551 064440
|
|
||||||
.sp .5
|
|
||||||
_str2+06: 020163 064164 020145 062563 067543 062156 061440 060550
|
|
||||||
.sp .5
|
|
||||||
_str2+026: 060562 072143 071145 071440 071164 067151 0147 0
|
|
||||||
.sp .5
|
|
||||||
savr5+02: 0 0 0 0 0 0 0 0
|
|
||||||
.sp .5
|
|
||||||
.ft B
|
|
||||||
<b,20/4o4^8Cn
|
|
||||||
.ft R
|
|
||||||
020000: 0 064124 071551 064440 @\`@\`This i
|
|
||||||
020163 020141 064143 071141 s a char
|
|
||||||
061541 062564 020162 072163 acter st
|
|
||||||
064562 063556 0 02 ring@\`@\`@b@\`
|
|
||||||
.sp .5
|
|
||||||
_number: 0710 0 02322 040240 H@a@\`@\`R@d @@
|
|
||||||
0 064124 071551 064440 @\`@\`This i
|
|
||||||
020163 064164 020145 062563 s the se
|
|
||||||
067543 062156 061440 060550 cond cha
|
|
||||||
060562 072143 071145 071440 racter s
|
|
||||||
071164 067151 0147 0 tring@\`@\`@\`
|
|
||||||
0 0 0 0 @\`@\`@\`@\`@\`@\`@\`@\`
|
|
||||||
0 0 0 0 @\`@\`@\`@\`@\`@\`@\`@\`
|
|
||||||
data address not found
|
|
||||||
.ft B
|
|
||||||
<b,20/4o4^8t8cna
|
|
||||||
.ft R
|
|
||||||
020000: 0 064124 071551 064440 This i
|
|
||||||
_str1+06: 020163 020141 064143 071141 s a char
|
|
||||||
_str1+016: 061541 062564 020162 072163 acter st
|
|
||||||
_str1+026: 064562 063556 0 02 ring
|
|
||||||
_number:
|
|
||||||
_number: 0710 0 02322 040240 HR
|
|
||||||
_fpt+02: 0 064124 071551 064440 This i
|
|
||||||
_str2+06: 020163 064164 020145 062563 s the se
|
|
||||||
_str2+016: 067543 062156 061440 060550 cond cha
|
|
||||||
_str2+026: 060562 072143 071145 071440 racter s
|
|
||||||
_str2+036: 071164 067151 0147 0 tring
|
|
||||||
savr5+02: 0 0 0 0
|
|
||||||
savr5+012: 0 0 0 0
|
|
||||||
data address not found
|
|
||||||
.ft B
|
|
||||||
<b,10/2b8t^2cn
|
|
||||||
.ft R
|
|
||||||
020000: 0 0
|
|
||||||
.sp .5
|
|
||||||
_str1: 0124 0150 Th
|
|
||||||
0151 0163 is
|
|
||||||
040 0151 i
|
|
||||||
0163 040 s
|
|
||||||
0141 040 a
|
|
||||||
0143 0150 ch
|
|
||||||
0141 0162 ar
|
|
||||||
0141 0143 ac
|
|
||||||
0164 0145 te
|
|
||||||
.ft B
|
|
||||||
$Q
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Figure 12: Directory and inode dumps
|
|
||||||
.LP
|
|
||||||
.nf
|
|
||||||
.ft B
|
|
||||||
adb dir \(mi
|
|
||||||
=nt"Inode"t"Name"
|
|
||||||
0,\(mi1?ut14cn
|
|
||||||
.ft R
|
|
||||||
|
|
||||||
Inode Name
|
|
||||||
0: 652 .
|
|
||||||
82 ..
|
|
||||||
5971 cap.c
|
|
||||||
5323 cap
|
|
||||||
0 pp
|
|
||||||
.sp 4
|
|
||||||
.ft B
|
|
||||||
adb /dev/src \(mi
|
|
||||||
.ft B
|
|
||||||
02000>b
|
|
||||||
?m<b
|
|
||||||
.ft R
|
|
||||||
new map \`/dev/src\'
|
|
||||||
b1 = 02000 e1 = 0100000000 f1 = 0
|
|
||||||
b2 = 0 e2 = 0 f2 = 0
|
|
||||||
.ft B
|
|
||||||
$v
|
|
||||||
.ft R
|
|
||||||
variables
|
|
||||||
b = 02000
|
|
||||||
.ft B
|
|
||||||
<b,\(mi1?"flags"8ton"links,uid,gid"8t3bn"size"8tbrdn"addr"8t8un"times"8t2Y2na
|
|
||||||
.ft R
|
|
||||||
02000: flags 073145
|
|
||||||
links,uid,gid 0163 0164 0141
|
|
||||||
size 0162 10356
|
|
||||||
addr 28770 8236 25956 27766 25455 8236 25956 25206
|
|
||||||
times 1976 Feb 5 08:34:56 1975 Dec 28 10:55:15
|
|
||||||
|
|
||||||
02040: flags 024555
|
|
||||||
links,uid,gid 012 0163 0164
|
|
||||||
size 0162 25461
|
|
||||||
addr 8308 30050 8294 25130 15216 26890 29806 10784
|
|
||||||
times 1976 Aug 17 12:16:51 1976 Aug 17 12:16:51
|
|
||||||
|
|
||||||
02100: flags 05173
|
|
||||||
links,uid,gid 011 0162 0145
|
|
||||||
size 0147 29545
|
|
||||||
addr 25972 8306 28265 8308 25642 15216 2314 25970
|
|
||||||
times 1977 Apr 2 08:58:01 1977 Feb 5 10:21:44
|
|
||||||
.\"
|
|
||||||
.\" Start of Summary
|
|
||||||
.sp 100
|
|
||||||
.TL
|
|
||||||
ADB Summary
|
|
||||||
.LP
|
|
||||||
.LP
|
|
||||||
.if t .2C
|
|
||||||
.nr VS 9
|
|
||||||
.nr VS 11
|
|
||||||
.SH
|
|
||||||
Command Summary
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
a) formatted printing
|
|
||||||
.sp .5
|
|
||||||
.IP "\fB? \fIformat\fR" .7i
|
|
||||||
print from \fIa.out\fR file according to \fIformat\fR
|
|
||||||
.IP "\fB/ \fIformat\fR" .7i
|
|
||||||
print from \fIcore\fR file according to \fIformat\fR
|
|
||||||
.IP "\fB= \fIformat\fR" .7i
|
|
||||||
print the value of \fIdot\fR
|
|
||||||
.sp .5
|
|
||||||
.IP "\fB?w\fR expr" .7i
|
|
||||||
write expression into \fIa.out\fR file
|
|
||||||
.IP "\fB/w\fR expr" .7i
|
|
||||||
write expression into \fIcore\fR file
|
|
||||||
.sp .5
|
|
||||||
.IP "\fB?l\fR expr" .7i
|
|
||||||
locate expression in \fIa.out\fR file
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
b) breakpoint and program control
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.nf
|
|
||||||
.ta .7i
|
|
||||||
\fB:b\fR set breakpoint at \fIdot\fR
|
|
||||||
\fB:c\fR continue running program
|
|
||||||
\fB:d\fR delete breakpoint
|
|
||||||
\fB:k\fR kill the program being debugged
|
|
||||||
\fB:r\fR run \fIa.out\fR file under ADB control
|
|
||||||
\fB:s\fR single step
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
c) miscellaneous printing
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.nf
|
|
||||||
\fB$b\fR print current breakpoints
|
|
||||||
\fB$c\fR C stack trace
|
|
||||||
\fB$e\fR external variables
|
|
||||||
\fB$f\fR floating registers
|
|
||||||
\fB$m\fR print ADB segment maps
|
|
||||||
\fB$q\fR exit from ADB
|
|
||||||
\fB$r\fR general registers
|
|
||||||
\fB$s\fR set offset for symbol match
|
|
||||||
\fB$v\fR print ADB variables
|
|
||||||
\fB$w\fR set output line width
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
d) calling the shell
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.nf
|
|
||||||
\fB!\fR call \fIshell\fP to read rest of line
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
e) assignment to variables
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.nf
|
|
||||||
\fB>\fIname\fR assign dot to variable or register \fIname\fR
|
|
||||||
.sp 100
|
|
||||||
.SH
|
|
||||||
Format Summary
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.nf
|
|
||||||
\fBa \fRthe value of dot
|
|
||||||
\fBb \fRone byte in octal
|
|
||||||
\fBc \fRone byte as a character
|
|
||||||
\fBd \fRone word in decimal
|
|
||||||
\fBf \fRtwo words in floating point
|
|
||||||
\fBi \fRPDP 11 instruction
|
|
||||||
\fBo \fRone word in octal
|
|
||||||
\fBn \fRprint a newline
|
|
||||||
\fBr \fRprint a blank space
|
|
||||||
\fBs \fRa null terminated character string
|
|
||||||
\fIn\fBt \fRmove to next \fIn\fR space tab
|
|
||||||
\fBu \fRone word as unsigned integer
|
|
||||||
\fBx \fRhexadecimal
|
|
||||||
\fBY \fRdate
|
|
||||||
\fB^ \fRbackup dot
|
|
||||||
\fB"..."\fR print string
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.SH
|
|
||||||
Expression Summary
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
a) expression components
|
|
||||||
.LP
|
|
||||||
.ta .1.1i
|
|
||||||
.nf
|
|
||||||
\fBdecimal integer \fRe.g. 256
|
|
||||||
\fBoctal integer \fRe.g. 0277
|
|
||||||
\fBhexadecimal \fRe.g. #ff
|
|
||||||
\fBsymbols \fRe.g. flag _main main.argc
|
|
||||||
\fBvariables \fRe.g. <b
|
|
||||||
\fBregisters \fRe.g. <pc <r0
|
|
||||||
\fB(expression) \fRexpression grouping
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
b) dyadic operators
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.nf
|
|
||||||
\fB+\fP add
|
|
||||||
\fB\(mi\fP subtract
|
|
||||||
\fB*\fP multiply
|
|
||||||
\fB%\fP integer division
|
|
||||||
\fB&\fP bitwise and
|
|
||||||
\fB|\fP bitwise or
|
|
||||||
\fB#\fP round up to the next multiple
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
c) monadic operators
|
|
||||||
.LP
|
|
||||||
.ta .7i
|
|
||||||
.nf
|
|
||||||
\v'.25m'\s+2\fB~\fP\s0\v'-.25m' not
|
|
||||||
\fB*\fR contents of location
|
|
||||||
\fB\(mi\fR integer negate
|
|
||||||
.fi
|
|
||||||
@@ -1,527 +0,0 @@
|
|||||||
=== Figure 1: C program with pointer bug ===
|
|
||||||
<code c>
|
|
||||||
struct buf {
|
|
||||||
int fildes;
|
|
||||||
int nleft;
|
|
||||||
char *nextp;
|
|
||||||
char buff[512];
|
|
||||||
}bb;
|
|
||||||
struct buf *obuf;
|
|
||||||
|
|
||||||
char *charp "this is a sentence.";
|
|
||||||
|
|
||||||
main(argc,argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
char cc;
|
|
||||||
|
|
||||||
if(argc < 2) {
|
|
||||||
printf("Input file missing\n");
|
|
||||||
exit(8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if((fcreat(argv[1],obuf)) < 0){
|
|
||||||
printf("%s : not found\n", argv[1]);
|
|
||||||
exit(8);
|
|
||||||
}
|
|
||||||
charp = 'T';
|
|
||||||
printf("debug 1 %s\n",charp);
|
|
||||||
while(cc= *charp++)
|
|
||||||
putc(cc,obuf);
|
|
||||||
fflush(obuf);
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
|
|
||||||
=== Figure 2: ADB output for C program of Figure 1 ===
|
|
||||||
**adb a.out core**
|
|
||||||
**$c**
|
|
||||||
~main(02,0177762)
|
|
||||||
**$C**
|
|
||||||
~main(02,0177762)
|
|
||||||
argc: 02
|
|
||||||
argv: 0177762
|
|
||||||
cc: 02124
|
|
||||||
**$r**
|
|
||||||
ps 0170010
|
|
||||||
pc 0204 ~main+0152
|
|
||||||
sp 0177740
|
|
||||||
r5 0177752
|
|
||||||
r4 01
|
|
||||||
r3 0
|
|
||||||
r2 0
|
|
||||||
r1 0
|
|
||||||
r0 0124
|
|
||||||
~main+0152: mov _obuf,(sp)
|
|
||||||
**$e**
|
|
||||||
savr5: 0
|
|
||||||
_obuf: 0
|
|
||||||
_charp: 0124
|
|
||||||
_errno: 0
|
|
||||||
_fout: 0
|
|
||||||
**$m**
|
|
||||||
text map `ex1'
|
|
||||||
b1 = 0 e1 = 02360 f1 = 020
|
|
||||||
b2 = 0 e2 = 02360 f2 = 020
|
|
||||||
data map `core1'
|
|
||||||
b1 = 0 e1 = 03500 f1 = 02000
|
|
||||||
b2 = 0175400 e2 = 0200000 f2 = 05500
|
|
||||||
***charp/s**
|
|
||||||
0124: TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTLxNh@x&_
|
|
||||||
~
|
|
||||||
**charp/s**
|
|
||||||
_charp: T
|
|
||||||
|
|
||||||
_charp+02: this is a sentence.
|
|
||||||
|
|
||||||
_charp+026: Input file missing
|
|
||||||
**main.argc/d**
|
|
||||||
0177756: 2
|
|
||||||
***main.argv/3o**
|
|
||||||
0177762: 0177770 0177776 0177777
|
|
||||||
**0177770/s**
|
|
||||||
0177770: a.out
|
|
||||||
***main.argv/3o**
|
|
||||||
0177762: 0177770 0177776 0177777
|
|
||||||
***"/s**
|
|
||||||
0177770: a.out
|
|
||||||
**.=o**
|
|
||||||
0177770
|
|
||||||
**.-10/d**
|
|
||||||
0177756: 2
|
|
||||||
**$q**
|
|
||||||
|
|
||||||
=== Figure 3: Multiple function C program for stack trace ===
|
|
||||||
<code c>
|
|
||||||
int fcnt,gcnt,hcnt;
|
|
||||||
h(x,y)
|
|
||||||
{
|
|
||||||
int hi; register int hr;
|
|
||||||
hi = x+1;
|
|
||||||
hr = x-y+1;
|
|
||||||
hcnt++ ;
|
|
||||||
hj:
|
|
||||||
f(hr,hi);
|
|
||||||
}
|
|
||||||
|
|
||||||
g(p,q)
|
|
||||||
{
|
|
||||||
int gi; register int gr;
|
|
||||||
gi = q-p;
|
|
||||||
gr = q-p+1;
|
|
||||||
gcnt++ ;
|
|
||||||
gj:
|
|
||||||
h(gr,gi);
|
|
||||||
}
|
|
||||||
|
|
||||||
f(a,b)
|
|
||||||
{
|
|
||||||
int fi; register int fr;
|
|
||||||
fi = a+2*b;
|
|
||||||
fr = a+b;
|
|
||||||
fcnt++ ;
|
|
||||||
fj:
|
|
||||||
g(fr,fi);
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
f(1,1);
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
|
|
||||||
=== Figure 4: ADB output for C program of Figure 3 ===
|
|
||||||
**adb**
|
|
||||||
**$c**
|
|
||||||
~h(04452,04451)
|
|
||||||
~g(04453,011124)
|
|
||||||
~f(02,04451)
|
|
||||||
~h(04450,04447)
|
|
||||||
~g(04451,011120)
|
|
||||||
~f(02,04447)
|
|
||||||
~h(04446,04445)
|
|
||||||
~g(04447,011114)
|
|
||||||
~f(02,04445)
|
|
||||||
~h(04444,04443)
|
|
||||||
**HIT DEL KEY**
|
|
||||||
adb
|
|
||||||
**,5$C**
|
|
||||||
~h(04452,04451)
|
|
||||||
x: 04452
|
|
||||||
y: 04451
|
|
||||||
hi: ?
|
|
||||||
~g(04453,011124)
|
|
||||||
p: 04453
|
|
||||||
q: 011124
|
|
||||||
gi: 04451
|
|
||||||
gr: ?
|
|
||||||
~f(02,04451)
|
|
||||||
a: 02
|
|
||||||
b: 04451
|
|
||||||
fi: 011124
|
|
||||||
fr: 04453
|
|
||||||
~h(04450,04447)
|
|
||||||
x: 04450
|
|
||||||
y: 04447
|
|
||||||
hi: 04451
|
|
||||||
hr: 02
|
|
||||||
~g(04451,011120)
|
|
||||||
p: 04451
|
|
||||||
q: 011120
|
|
||||||
gi: 04447
|
|
||||||
gr: 04450
|
|
||||||
**fcnt/d**
|
|
||||||
_fcnt: 1173
|
|
||||||
**gcnt/d**
|
|
||||||
_gcnt: 1173
|
|
||||||
**hcnt/d**
|
|
||||||
_hcnt: 1172
|
|
||||||
**h.x/d**
|
|
||||||
022004: 2346
|
|
||||||
**$q**
|
|
||||||
|
|
||||||
=== Figure 5: C program to decode tabs ===
|
|
||||||
<code c>
|
|
||||||
#define MAXLINE 80
|
|
||||||
#define YES 1
|
|
||||||
#define NO 0
|
|
||||||
#define TABSP 8
|
|
||||||
char input[] "data";
|
|
||||||
char ibuf[518];
|
|
||||||
int tabs[MAXLINE];
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int col, *ptab;
|
|
||||||
char c;
|
|
||||||
ptab = tabs;
|
|
||||||
settab(ptab); /*Set initial tab stops */
|
|
||||||
col = 1;
|
|
||||||
if(fopen(input,ibuf) < 0) {
|
|
||||||
printf("%s : not found\n",input);
|
|
||||||
exit(8);
|
|
||||||
}
|
|
||||||
while((c = getc(ibuf)) != -1) {
|
|
||||||
switch(c) {
|
|
||||||
case '\t': /* TAB */
|
|
||||||
while(tabpos(col) != YES) {
|
|
||||||
putchar(' '); /* put BLANK */
|
|
||||||
col++ ;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case '\n': /*NEWLINE */
|
|
||||||
putchar('\n');
|
|
||||||
col = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
putchar(c);
|
|
||||||
col++ ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Tabpos return YES if col is a tab stop */
|
|
||||||
tabpos(col)
|
|
||||||
int col;
|
|
||||||
{
|
|
||||||
if(col > MAXLINE)
|
|
||||||
return(YES);
|
|
||||||
else
|
|
||||||
return(tabs[col]);
|
|
||||||
}
|
|
||||||
/* Settab - Set initial tab stops */
|
|
||||||
settab(tabp)
|
|
||||||
int *tabp;
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for(i = 0; i<= MAXLINE; i++)
|
|
||||||
(i%TABSP) ? (tabs[i] = NO) : (tabs[i] = YES);
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
|
|
||||||
=== Figure 6a: ADB output for C program of Figure 5 ===
|
|
||||||
**adb a.out -**
|
|
||||||
**settab+4:b**
|
|
||||||
**fopen+4:b**
|
|
||||||
**getc+4:b**
|
|
||||||
**tabpos+4:b**
|
|
||||||
**$b**
|
|
||||||
breakpoints
|
|
||||||
count bkpt command
|
|
||||||
1 ~tabpos+04
|
|
||||||
1 _getc+04
|
|
||||||
1 _fopen+04
|
|
||||||
1 ~settab+04
|
|
||||||
**settab,5?ia**
|
|
||||||
~settab: jsr r5,csv
|
|
||||||
~settab+04: tst -(sp)
|
|
||||||
~settab+06: clr 0177770(r5)
|
|
||||||
~settab+012: cmp $0120,0177770(r5)
|
|
||||||
~settab+020: blt ~settab+076
|
|
||||||
~settab+022:
|
|
||||||
**settab,5?i**
|
|
||||||
~settab: jsr r5,csv
|
|
||||||
tst -(sp)
|
|
||||||
clr 0177770(r5)
|
|
||||||
cmp $0120,0177770(r5)
|
|
||||||
blt ~settab+076
|
|
||||||
**:r**
|
|
||||||
a.out: running
|
|
||||||
breakpoint ~settab+04: tst -(sp)
|
|
||||||
**settab+4:d**
|
|
||||||
**:c**
|
|
||||||
a.out: running
|
|
||||||
breakpoint _fopen+04: mov 04(r5),nulstr+012
|
|
||||||
**$C**
|
|
||||||
_fopen(02302,02472)
|
|
||||||
~main(01,0177770)
|
|
||||||
col: 01
|
|
||||||
c: 0
|
|
||||||
ptab: 03500
|
|
||||||
**tabs,3/8o**
|
|
||||||
03500: 01 0 0 0 0 0 0 0
|
|
||||||
01 0 0 0 0 0 0 0
|
|
||||||
01 0 0 0 0 0 0 0
|
|
||||||
|
|
||||||
|
|
||||||
=== Figure 6b: ADB output for C program of Figure 5 ===
|
|
||||||
**:c**
|
|
||||||
a.out: running
|
|
||||||
breakpoint _getc+04: mov 04(r5),r1
|
|
||||||
**ibuf+6/20c**
|
|
||||||
__cleanu+0202: This is a test of
|
|
||||||
**:c**
|
|
||||||
a.out: running
|
|
||||||
breakpoint ~tabpos+04: cmp $0120,04(r5)
|
|
||||||
**tabpos+4:d**
|
|
||||||
**settab+4:b settab,5?ia**
|
|
||||||
**settab+4:b settab,5?ia; 0**
|
|
||||||
**getc+4,3:b main.c?C; 0**
|
|
||||||
**settab+4:b settab,5?ia; ptab/o; 0**
|
|
||||||
**$b**
|
|
||||||
breakpoints
|
|
||||||
count bkpt command
|
|
||||||
1 ~tabpos+04
|
|
||||||
3 _getc+04 main.c?C;0
|
|
||||||
1 _fopen+04
|
|
||||||
1 ~settab+04 settab,5?ia;ptab?o;0
|
|
||||||
~settab: jsr r5,csv
|
|
||||||
~settab+04: bpt
|
|
||||||
~settab+06: clr 0177770(r5)
|
|
||||||
~settab+012: cmp $0120,0177770(r5)
|
|
||||||
~settab+020: blt ~settab+076
|
|
||||||
~settab+022:
|
|
||||||
0177766: 0177770
|
|
||||||
0177744: @`
|
|
||||||
T0177744: T
|
|
||||||
h0177744: h
|
|
||||||
i0177744: i
|
|
||||||
s0177744: s
|
|
||||||
|
|
||||||
=== Figure 7: ADB output for C program with breakpoints ===
|
|
||||||
**adb ex3 -**
|
|
||||||
**h+4:b hcnt/d; h.hi/; h.hr/**
|
|
||||||
**g+4:b gcnt/d; g.gi/; g.gr/**
|
|
||||||
**f+4:b fcnt/d; f.fi/; f.fr/**
|
|
||||||
**:r**
|
|
||||||
ex3: running
|
|
||||||
_fcnt: 0
|
|
||||||
0177732: 214
|
|
||||||
symbol not found
|
|
||||||
**f+4:b fcnt/d; f.a/; f.b/; f.fi/**
|
|
||||||
**g+4:b gcnt/d; g.p/; g.q/; g.gi/**
|
|
||||||
**h+4:b hcnt/d; h.x/; h.y/; h.hi/**
|
|
||||||
**:c**
|
|
||||||
ex3: running
|
|
||||||
_fcnt: 0
|
|
||||||
0177746: 1
|
|
||||||
0177750: 1
|
|
||||||
0177732: 214
|
|
||||||
_gcnt: 0
|
|
||||||
0177726: 2
|
|
||||||
0177730: 3
|
|
||||||
0177712: 214
|
|
||||||
_hcnt: 0
|
|
||||||
0177706: 2
|
|
||||||
0177710: 1
|
|
||||||
0177672: 214
|
|
||||||
_fcnt: 1
|
|
||||||
0177666: 2
|
|
||||||
0177670: 3
|
|
||||||
0177652: 214
|
|
||||||
_gcnt: 1
|
|
||||||
0177646: 5
|
|
||||||
0177650: 8
|
|
||||||
0177632: 214
|
|
||||||
**HIT DEL**
|
|
||||||
**f+4:b fcnt/d; f.a/"a = "d; f.b/"b = "d; f.fi/"fi = "d**
|
|
||||||
**g+4:b gcnt/d; g.p/"p = "d; g.q/"q = "d; g.gi/"gi = "d**
|
|
||||||
**h+4:b hcnt/d; h.x/"x = "d; h.y/"h = "d; h.hi/"hi = "d**
|
|
||||||
**:r**
|
|
||||||
ex3: running
|
|
||||||
_fcnt: 0
|
|
||||||
0177746: a = 1
|
|
||||||
0177750: b = 1
|
|
||||||
0177732: fi = 214
|
|
||||||
_gcnt: 0
|
|
||||||
0177726: p = 2
|
|
||||||
0177730: q = 3
|
|
||||||
0177712: gi = 214
|
|
||||||
_hcnt: 0
|
|
||||||
0177706: x = 2
|
|
||||||
0177710: y = 1
|
|
||||||
0177672: hi = 214
|
|
||||||
_fcnt: 1
|
|
||||||
0177666: a = 2
|
|
||||||
0177670: b = 3
|
|
||||||
0177652: fi = 214
|
|
||||||
**HIT DEL**
|
|
||||||
**$q**
|
|
||||||
|
|
||||||
|
|
||||||
=== Figure 8: ADB address maps ===
|
|
||||||
<code>
|
|
||||||
a.out hdr text+data
|
|
||||||
|____|_____________________________|
|
|
||||||
0 D
|
|
||||||
|
|
||||||
core hdr text+data stack
|
|
||||||
|______|_____________________________......|________|
|
|
||||||
0 D S E
|
|
||||||
</code>
|
|
||||||
|
|
||||||
The following ''adb'' variables are set.
|
|
||||||
|
|
||||||
|| b || base of data || 0 ||
|
|
||||||
|| d || length of data || D ||
|
|
||||||
|| s || length of stack || S ||
|
|
||||||
|| t || length of text || 0 ||
|
|
||||||
|
|
||||||
|
|
||||||
=== Figure 9: ADB output for maps ===
|
|
||||||
**adb map core**
|
|
||||||
**$m**
|
|
||||||
text map `map'
|
|
||||||
b1 = 0 e1 = 0256 f1 = 020
|
|
||||||
b2 = 0 e2 = 0256 f2 = 020
|
|
||||||
data map `core'
|
|
||||||
b1 = 0 e1 = 0300 f1 = 02000
|
|
||||||
b2 = 0175400 e2 = 0200000 f2 = 02300
|
|
||||||
**$v**
|
|
||||||
variables
|
|
||||||
d = 0300
|
|
||||||
m = 0407
|
|
||||||
s = 02400
|
|
||||||
**$q**
|
|
||||||
|
|
||||||
=== Figure 10: Simple C program for illustrating formatting and patching ===
|
|
||||||
<code c>
|
|
||||||
char str1[] "This is a character string";
|
|
||||||
int one 1;
|
|
||||||
int number 456;
|
|
||||||
long lnum 1234;
|
|
||||||
float fpt 1.25;
|
|
||||||
char str2[] "This is the second character string";
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
one = 2;
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
|
|
||||||
=== Figure 11: ADB output illustrating fancy formats ===
|
|
||||||
<code>
|
|
||||||
**adb map410 core410**
|
|
||||||
**<b,-1/8ona**
|
|
||||||
020000: 0 064124 071551 064440 020163 020141 064143 071141
|
|
||||||
_str1+016: 061541 062564 020162 072163 064562 063556 0 02
|
|
||||||
_number:
|
|
||||||
_number: 0710 0 02322 040240 0 064124 071551 064440
|
|
||||||
_str2+06: 020163 064164 020145 062563 067543 062156 061440 060550
|
|
||||||
_str2+026: 060562 072143 071145 071440 071164 067151 0147 0
|
|
||||||
savr5+02: 0 0 0 0 0 0 0 0
|
|
||||||
**<b,20/4o4^8Cn**
|
|
||||||
020000: 0 064124 071551 064440 @`@`This i
|
|
||||||
020163 020141 064143 071141 s a char
|
|
||||||
061541 062564 020162 072163 acter st
|
|
||||||
064562 063556 0 02 ring@`@`@b@`
|
|
||||||
_number: 0710 0 02322 040240 H@a@`@`R@d @@
|
|
||||||
0 064124 071551 064440 @`@`This i
|
|
||||||
020163 064164 020145 062563 s the se
|
|
||||||
067543 062156 061440 060550 cond cha
|
|
||||||
060562 072143 071145 071440 racter s
|
|
||||||
071164 067151 0147 0 tring@`@`@`
|
|
||||||
0 0 0 0 @`@`@`@`@`@`@`@`
|
|
||||||
0 0 0 0 @`@`@`@`@`@`@`@`
|
|
||||||
data address not found
|
|
||||||
**<b,20/4o4^8t8cna**
|
|
||||||
020000: 0 064124 071551 064440 This i
|
|
||||||
_str1+06: 020163 020141 064143 071141 s a char
|
|
||||||
_str1+016: 061541 062564 020162 072163 acter st
|
|
||||||
_str1+026: 064562 063556 0 02 ring
|
|
||||||
_number:
|
|
||||||
_number: 0710 0 02322 040240 HR
|
|
||||||
_fpt+02: 0 064124 071551 064440 This i
|
|
||||||
_str2+06: 020163 064164 020145 062563 s the se
|
|
||||||
_str2+016: 067543 062156 061440 060550 cond cha
|
|
||||||
_str2+026: 060562 072143 071145 071440 racter s
|
|
||||||
_str2+036: 071164 067151 0147 0 tring
|
|
||||||
savr5+02: 0 0 0 0
|
|
||||||
savr5+012: 0 0 0 0
|
|
||||||
data address not found
|
|
||||||
**<b,10/2b8t^2cn**
|
|
||||||
020000: 0 0
|
|
||||||
_str1: 0124 0150 Th
|
|
||||||
0151 0163 is
|
|
||||||
040 0151 i
|
|
||||||
0163 040 s
|
|
||||||
0141 040 a
|
|
||||||
0143 0150 ch
|
|
||||||
0141 0162 ar
|
|
||||||
0141 0143 ac
|
|
||||||
0164 0145 te
|
|
||||||
**$Q**
|
|
||||||
</code>
|
|
||||||
|
|
||||||
|
|
||||||
=== Figure 12: Directory and inode dumps ===
|
|
||||||
<code>
|
|
||||||
**adb dir -**
|
|
||||||
**=nt"Inode"t"Name"**
|
|
||||||
**0,-1?ut14cn**
|
|
||||||
|
|
||||||
Inode Name
|
|
||||||
0: 652 .
|
|
||||||
82 ..
|
|
||||||
5971 cap.c
|
|
||||||
5323 cap
|
|
||||||
0 pp
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**adb /dev/src -**
|
|
||||||
**02000>b**
|
|
||||||
**?m<b**
|
|
||||||
new map `/dev/src'
|
|
||||||
b1 = 02000 e1 = 0100000000 f1 = 0
|
|
||||||
b2 = 0 e2 = 0 f2 = 0
|
|
||||||
**$v**
|
|
||||||
variables
|
|
||||||
b = 02000
|
|
||||||
**<b,-1?"flags"8ton"links,uid,gid"8t3bn"size"8tbrdn"addr"8t8un"times"8t2Y2na**
|
|
||||||
02000: flags 073145
|
|
||||||
links,uid,gid 0163 0164 0141
|
|
||||||
size 0162 10356
|
|
||||||
addr 28770 8236 25956 27766 25455 8236 25956 25206
|
|
||||||
times 1976 Feb 5 08:34:56 1975 Dec 28 10:55:15
|
|
||||||
|
|
||||||
02040: flags 024555
|
|
||||||
links,uid,gid 012 0163 0164
|
|
||||||
size 0162 25461
|
|
||||||
addr 8308 30050 8294 25130 15216 26890 29806 10784
|
|
||||||
times 1976 Aug 17 12:16:51 1976 Aug 17 12:16:51
|
|
||||||
|
|
||||||
02100: flags 05173
|
|
||||||
links,uid,gid 011 0162 0145
|
|
||||||
size 0147 29545
|
|
||||||
addr 25972 8306 28265 8308 25642 15216 2314 25970
|
|
||||||
times 1977 Apr 2 08:58:01 1977 Feb 5 10:21:44
|
|
||||||
</code>
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
=== ADB Summary ===
|
|
||||||
|
|
||||||
== Command Summary ==
|
|
||||||
|
|
||||||
a) formatted printing
|
|
||||||
|
|
||||||
|| ? format || print from ''a.out'' file according to format ||
|
|
||||||
|| / format || print from ''core'' file according to format ||
|
|
||||||
|| = format || print the value of dot ||
|
|
||||||
|| ?w expr || write expression into ''a.out'' file ||
|
|
||||||
|| /w expr || write expression into ''core'' file ||
|
|
||||||
|| ?l expr || locate expression in ''a.out'' file ||
|
|
||||||
|
|
||||||
b) breakpoint and program control
|
|
||||||
|
|
||||||
|| :b || set breakpoint at dot ||
|
|
||||||
|| :c || continue running program ||
|
|
||||||
|| :d || delete breakpoint ||
|
|
||||||
|| :k || kill the program being debugged ||
|
|
||||||
|| :r || run ''a.out'' file under ADB control ||
|
|
||||||
|| :s || single step ||
|
|
||||||
|
|
||||||
c) miscellaneous printing
|
|
||||||
|
|
||||||
|| $b || print current breakpoints ||
|
|
||||||
|| $c || C stack trace ||
|
|
||||||
|| $e || external variables ||
|
|
||||||
|| $f || floating registers ||
|
|
||||||
|| $m || print ADB segment maps ||
|
|
||||||
|| $q || exit from ADB ||
|
|
||||||
|| $r || general registers ||
|
|
||||||
|| $s || set offset for symbol match ||
|
|
||||||
|| $v || print ADB variables ||
|
|
||||||
|| $w || set output line width ||
|
|
||||||
|
|
||||||
d) calling the shell
|
|
||||||
|
|
||||||
|| ! || call shell to read rest of line ||
|
|
||||||
|
|
||||||
e) assignment to variables
|
|
||||||
|
|
||||||
|| >name || assign dot to variable or register name ||
|
|
||||||
|
|
||||||
|
|
||||||
== Format Summary ==
|
|
||||||
|
|
||||||
|| a || the value of dot ||
|
|
||||||
|| b || one byte in octal ||
|
|
||||||
|| c || one byte as a character ||
|
|
||||||
|| d || one word in decimal ||
|
|
||||||
|| f || two words in floating point ||
|
|
||||||
|| i || PDP 11 instruction ||
|
|
||||||
|| o || one word in octal ||
|
|
||||||
|| n || print a newline ||
|
|
||||||
|| r || print a blank space ||
|
|
||||||
|| s || a null terminated character string ||
|
|
||||||
|| nt || move to next n space tab ||
|
|
||||||
|| u || one word as unsigned integer ||
|
|
||||||
|| x || hexadecimal ||
|
|
||||||
|| Y || date ||
|
|
||||||
|| ^ || backup dot ||
|
|
||||||
|| "..." || print string ||
|
|
||||||
|
|
||||||
|
|
||||||
== Expression Summary ==
|
|
||||||
|
|
||||||
a) expression components
|
|
||||||
|
|
||||||
|| decimal integer || e.g. 256 ||
|
|
||||||
|| octal integer || e.g. 0277 ||
|
|
||||||
|| hexadecimal || e.g. #ff ||
|
|
||||||
|| symbols || e.g. flag _main main.argc ||
|
|
||||||
|| variables || e.g. <b ||
|
|
||||||
|| registers || e.g. <pc <r0 ||
|
|
||||||
|| (expression) || expression grouping ||
|
|
||||||
|
|
||||||
b) dyadic operators
|
|
||||||
|
|
||||||
|| + || add ||
|
|
||||||
|| - || subtract ||
|
|
||||||
|| * || multiply ||
|
|
||||||
|| % || integer division ||
|
|
||||||
|| & || bitwise and ||
|
|
||||||
|| | || bitwise or ||
|
|
||||||
|| # || round up to the next multiple ||
|
|
||||||
|
|
||||||
c) monadic operators
|
|
||||||
|
|
||||||
|| ~ || not ||
|
|
||||||
|| * || contents of location ||
|
|
||||||
|| - || integer negate ||
|
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,760 +0,0 @@
|
|||||||
====== A Tutorial Introduction to ADB ======
|
|
||||||
|
|
||||||
//J. F. Maranzano, S. R. Bourne//
|
|
||||||
//May 5, 1977//
|
|
||||||
|
|
||||||
===== 1. Introduction =====
|
|
||||||
|
|
||||||
ADB is a new debugging program that is available on
|
|
||||||
UNIX. It provides capabilities to look at "core" files
|
|
||||||
resulting from aborted programs, print output in a variety
|
|
||||||
of formats, patch files, and run programs with embedded
|
|
||||||
breakpoints. This document provides examples of the more
|
|
||||||
useful features of ADB. The reader is expected to be familiar
|
|
||||||
with the basic commands on UNIX with the C language, and
|
|
||||||
with References 1, 2 and 3.
|
|
||||||
|
|
||||||
|
|
||||||
===== 2. A Quick Survey =====
|
|
||||||
|
|
||||||
==== 2.1. Invocation ====
|
|
||||||
|
|
||||||
ADB is invoked as:
|
|
||||||
**adb objfile corefile**
|
|
||||||
where ''objfile'' is an executable UNIX file and ''corefile'' is a
|
|
||||||
core image file. Many times this will look like:
|
|
||||||
**adb a.out core**
|
|
||||||
or more simply:
|
|
||||||
**adb**
|
|
||||||
where the defaults are ''a.out'' and ''core'' respectively. The
|
|
||||||
filename minus (-) means ignore this argument as in:
|
|
||||||
**adb - core**
|
|
||||||
|
|
||||||
ADB has requests for examining locations in either file.
|
|
||||||
The **?** request examines the contents of ''objfile'',
|
|
||||||
the **/** request examines the ''corefile''. The general form of these
|
|
||||||
requests is:
|
|
||||||
**address ? format**
|
|
||||||
or
|
|
||||||
**address / format**
|
|
||||||
|
|
||||||
==== 2.2. Current Address ====
|
|
||||||
|
|
||||||
ADB maintains a current address, called dot, similar in
|
|
||||||
function to the current pointer in the UNIX editor. When an
|
|
||||||
address is entered, the current address is set to that location,
|
|
||||||
so that:
|
|
||||||
**0126?i**
|
|
||||||
sets dot to octal 126 and prints the instruction at that
|
|
||||||
address. The request:
|
|
||||||
**.,10/d**
|
|
||||||
prints 10 decimal numbers starting at dot. Dot ends up
|
|
||||||
referring to the address of the last item printed. When
|
|
||||||
used with the **?** or **/** requests, the current address can be
|
|
||||||
advanced by typing newline; it can be decremented by typing **^**.
|
|
||||||
|
|
||||||
Addresses are represented by expressions. Expressions
|
|
||||||
are made up from decimal, octal, and hexadecimal integers,
|
|
||||||
and symbols from the program under test. These may be combined
|
|
||||||
with the operators +, -, *, % (integer division), &
|
|
||||||
(bitwise and), | (bitwise inclusive or), # (round up to the
|
|
||||||
next multiple), and ~ (not). (All arithmetic within ADB is
|
|
||||||
32 bits.) When typing a symbolic address for a C program,
|
|
||||||
the user can type ''name'' or ''_name''; ADB will recognize both
|
|
||||||
forms.
|
|
||||||
|
|
||||||
==== 2.3. Formats ====
|
|
||||||
|
|
||||||
To print data, a user specifies a collection of letters
|
|
||||||
and characters that describe the format of the printout.
|
|
||||||
Formats are "remembered" in the sense that typing a request
|
|
||||||
without one will cause the new printout to appear in the
|
|
||||||
previous format. The following are the most commonly used
|
|
||||||
format letters.
|
|
||||||
|
|
||||||
|| b || one byte in octal ||
|
|
||||||
|| c || one byte as a character ||
|
|
||||||
|| o || one word in octal ||
|
|
||||||
|| d || one word in decimal ||
|
|
||||||
|| f || two words in floating point ||
|
|
||||||
|| i || PDP 11 instruction ||
|
|
||||||
|| s || a null terminated character string ||
|
|
||||||
|| a || the value of dot ||
|
|
||||||
|| u || one word as unsigned integer ||
|
|
||||||
|| n || print a newline ||
|
|
||||||
|| r || print a blank space ||
|
|
||||||
|| ^ || backup dot ||
|
|
||||||
|
|
||||||
(Format letters are also available for "long" values, for
|
|
||||||
example, `**D**' for long decimal, and `**F**' for double floating
|
|
||||||
point.) For other formats see the ADB manual.
|
|
||||||
|
|
||||||
==== 2.4. General Request Meanings ====
|
|
||||||
|
|
||||||
The general form of a request is:
|
|
||||||
**address,count command modifier**
|
|
||||||
which sets `dot' to ''address'' and executes the command ''count''
|
|
||||||
times.
|
|
||||||
|
|
||||||
The following table illustrates some general ADB command meanings:
|
|
||||||
|
|
||||||
^^ Command ^^ Meaning ^^
|
|
||||||
|| ? || Print contents from ''a.out'' file ||
|
|
||||||
|| / || Print contents from ''core'' file ||
|
|
||||||
|| = || Print value of "dot" ||
|
|
||||||
|| : || Breakpoint control ||
|
|
||||||
|| $ || Miscellaneous requests ||
|
|
||||||
|| ; || Request separator ||
|
|
||||||
|| ! || Escape to shell ||
|
|
||||||
|
|
||||||
ADB catches signals, so a user cannot use a quit signal
|
|
||||||
to exit from ADB. The request $q or $Q (or cntl-D) must be
|
|
||||||
used to exit from ADB.
|
|
||||||
|
|
||||||
===== 3. Debugging C Programs =====
|
|
||||||
|
|
||||||
==== 3.1. Debugging A Core Image ====
|
|
||||||
|
|
||||||
Consider the C program in Figure 1. The program is
|
|
||||||
used to illustrate a common error made by C programmers.
|
|
||||||
The object of the program is to change the lower case "t" to
|
|
||||||
upper case in the string pointed to by ''charp'' and then write
|
|
||||||
the character string to the file indicated by argument 1.
|
|
||||||
The bug shown is that the character "T" is stored in the
|
|
||||||
pointer ''charp'' instead of the string pointed to by ''charp''.
|
|
||||||
Executing the program produces a core file because of an out
|
|
||||||
of bounds memory reference.
|
|
||||||
|
|
||||||
ADB is invoked by:
|
|
||||||
**adb a.out core**
|
|
||||||
The first debugging request:
|
|
||||||
**$c**
|
|
||||||
is used to give a C backtrace through the subroutines
|
|
||||||
called. As shown in Figure 2 only one function (''main'') was
|
|
||||||
called and the arguments ''argc'' and ''argv'' have octal values 02
|
|
||||||
and 0177762 respectively. Both of these values look reasonable;
|
|
||||||
02 = two arguments, 0177762 = address on stack of
|
|
||||||
parameter vector.
|
|
||||||
The next request:
|
|
||||||
**$C**
|
|
||||||
is used to give a C backtrace plus an interpretation of all
|
|
||||||
the local variables in each function and their values in
|
|
||||||
octal. The value of the variable ''cc'' looks incorrect since
|
|
||||||
''cc'' was declared as a character.
|
|
||||||
|
|
||||||
The next request:
|
|
||||||
**$r**
|
|
||||||
prints out the registers including the program counter and
|
|
||||||
an interpretation of the instruction at that location.
|
|
||||||
|
|
||||||
The request:
|
|
||||||
**$e**
|
|
||||||
prints out the values of all external variables.
|
|
||||||
|
|
||||||
A map exists for each file handled by ADB. The map for
|
|
||||||
the ''a.out'' file is referenced by **?** whereas the map for ''core**
|
|
||||||
file is referenced by **/**. Furthermore, a good rule of thumb
|
|
||||||
is to use **?** for instructions and **/** for data when looking at
|
|
||||||
programs. To print out information about the maps type:
|
|
||||||
**$m**
|
|
||||||
This produces a report of the contents of the maps. More
|
|
||||||
about these maps later.
|
|
||||||
|
|
||||||
In our example, it is useful to see the contents of the
|
|
||||||
string pointed to by ''charp.'' This is done by:
|
|
||||||
***charp/s**
|
|
||||||
which says use ''charp'' as a pointer in the ''core'' file and print
|
|
||||||
the information as a character string. This printout
|
|
||||||
clearly shows that the character buffer was incorrectly
|
|
||||||
overwritten and helps identify the error. Printing the
|
|
||||||
locations around ''charp'' shows that the buffer is unchanged
|
|
||||||
but that the pointer is destroyed. Using ADB similarly, we
|
|
||||||
could print information about the arguments to a function.
|
|
||||||
The request:
|
|
||||||
**main.argc/d**
|
|
||||||
prints the decimal ''core'' image value of the argument ''argc'' in
|
|
||||||
the function //main.//
|
|
||||||
The request:
|
|
||||||
***main.argv,3/o**
|
|
||||||
prints the octal values of the three consecutive cells
|
|
||||||
pointed to by ''argv'' in the function ''main.'' Note that these
|
|
||||||
values are the addresses of the arguments to main. Therefore:
|
|
||||||
**0177770/s**
|
|
||||||
prints the ASCII value of the first argument. Another way
|
|
||||||
to print this value would have been
|
|
||||||
***"/s**
|
|
||||||
The " means ditto which remembers the last address typed, in
|
|
||||||
this case ''main.argc'' ; the ** * ** instructs ADB to use the address
|
|
||||||
field of the ''core'' file as a pointer.
|
|
||||||
|
|
||||||
The request:
|
|
||||||
**.=o**
|
|
||||||
prints the current address (not its contents) in octal which
|
|
||||||
has been set to the address of the first argument. The current
|
|
||||||
address, dot, is used by ADB to "remember" its current
|
|
||||||
location. It allows the user to reference locations relative
|
|
||||||
to the current address, for example:
|
|
||||||
**.-10/d**
|
|
||||||
|
|
||||||
==== 3.2. Multiple Functions ====
|
|
||||||
|
|
||||||
Consider the C program illustrated in Figure 3. This
|
|
||||||
program calls functions ''f,'' ''g,'' and ''h'' until the stack is
|
|
||||||
exhausted and a core image is produced.
|
|
||||||
|
|
||||||
Again you can enter the debugger via:
|
|
||||||
**adb**
|
|
||||||
which assumes the names ''a.out'' and ''core'' for the executable
|
|
||||||
file and core image file respectively. The request:
|
|
||||||
**$c**
|
|
||||||
will fill a page of backtrace references to //f,'' ''g,'' and ''h.//
|
|
||||||
Figure 4 shows an abbreviated list (typing ''DEL'' will terminate
|
|
||||||
the output and bring you back to ADB request level).
|
|
||||||
|
|
||||||
The request:
|
|
||||||
**,5$C**
|
|
||||||
prints the five most recent activations.
|
|
||||||
|
|
||||||
Notice that each function (''f,g,h'') has a counter of the
|
|
||||||
number of times it was called.
|
|
||||||
|
|
||||||
The request:
|
|
||||||
**fcnt/d**
|
|
||||||
prints the decimal value of the counter for the function //f.//
|
|
||||||
Similarly ''gcnt'' and ''hcnt'' could be printed. To print the
|
|
||||||
value of an automatic variable, for example the decimal
|
|
||||||
value of ''x'' in the last call of the function ''h,'' type:
|
|
||||||
**h.x/d**
|
|
||||||
It is currently not possible in the exported version to
|
|
||||||
print stack frames other than the most recent activation of
|
|
||||||
a function. Therefore, a user can print everything with **$C**
|
|
||||||
or the occurrence of a variable in the most recent call of a
|
|
||||||
function. It is possible with the **$C** request, however, to
|
|
||||||
print the stack frame starting at some address as **address$C.**
|
|
||||||
|
|
||||||
==== 3.3. Setting Breakpoints ====
|
|
||||||
|
|
||||||
Consider the C program in Figure 5. This program,
|
|
||||||
which changes tabs into blanks, is adapted from //Software//
|
|
||||||
''Tools'' by Kernighan and Plauger, pp. 18-27.
|
|
||||||
|
|
||||||
We will run this program under the control of ADB (see
|
|
||||||
Figure 6a) by:
|
|
||||||
**adb a.out -**
|
|
||||||
Breakpoints are set in the program as:
|
|
||||||
**address:b [request]**
|
|
||||||
The requests:
|
|
||||||
**settab+4:b**
|
|
||||||
**fopen+4:b**
|
|
||||||
**getc+4:b**
|
|
||||||
**tabpos+4:b**
|
|
||||||
set breakpoints at the start of these functions. C does not
|
|
||||||
generate statement labels. Therefore it is currently not
|
|
||||||
possible to plant breakpoints at locations other than function
|
|
||||||
entry points without a knowledge of the code generated
|
|
||||||
by the C compiler. The above addresses are entered as **symbol+4**
|
|
||||||
so that they will appear in any C backtrace since the
|
|
||||||
first instruction of each function is a call to the C save
|
|
||||||
routine (''csv''). Note that some of the functions are from the
|
|
||||||
C library.
|
|
||||||
|
|
||||||
To print the location of breakpoints one types:
|
|
||||||
**$b**
|
|
||||||
The display indicates a ''count'' field. A breakpoint is
|
|
||||||
bypassed //count'' ''-1'' times before causing a stop. The ''command//
|
|
||||||
field indicates the ADB requests to be executed each time
|
|
||||||
the breakpoint is encountered. In our example no //command//
|
|
||||||
fields are present.
|
|
||||||
|
|
||||||
By displaying the original instructions at the function
|
|
||||||
''settab'' we see that the breakpoint is set after the jsr to
|
|
||||||
the C save routine. We can display the instructions using
|
|
||||||
the ADB request:
|
|
||||||
**settab,5?ia**
|
|
||||||
This request displays five instructions starting at //settab//
|
|
||||||
with the addresses of each location displayed. Another
|
|
||||||
variation is:
|
|
||||||
**settab,5?i**
|
|
||||||
which displays the instructions with only the starting
|
|
||||||
address.
|
|
||||||
|
|
||||||
Notice that we accessed the addresses from the //a.out//
|
|
||||||
file with the **?** command. In general when asking for a
|
|
||||||
printout of multiple items, ADB will advance the current
|
|
||||||
address the number of bytes necessary to satisfy the
|
|
||||||
request; in the above example five instructions were displayed
|
|
||||||
and the current address was advanced 18 (decimal)
|
|
||||||
bytes.
|
|
||||||
|
|
||||||
To run the program one simply types:
|
|
||||||
**:r**
|
|
||||||
To delete a breakpoint, for instance the entry to the function
|
|
||||||
''settab,'' one types:
|
|
||||||
**settab+4:d**
|
|
||||||
To continue execution of the program from the breakpoint
|
|
||||||
type:
|
|
||||||
**:c**
|
|
||||||
|
|
||||||
Once the program has stopped (in this case at the
|
|
||||||
breakpoint for ''fopen),'' ADB requests can be used to display
|
|
||||||
the contents of memory. For example:
|
|
||||||
**$C**
|
|
||||||
to display a stack trace, or:
|
|
||||||
**tabs,3/8o**
|
|
||||||
to print three lines of 8 locations each from the array
|
|
||||||
called ''tabs.'' By this time (at location ''fopen)'' in the C program,
|
|
||||||
''settab'' has been called and should have set a one in
|
|
||||||
every eighth location of //tabs.//
|
|
||||||
|
|
||||||
==== 3.4. Advanced Breakpoint Usage ====
|
|
||||||
|
|
||||||
We continue execution of the program with:
|
|
||||||
**:c**
|
|
||||||
See Figure 6b. ''Getc'' is called three times and the contents
|
|
||||||
of the variable ''c'' in the function ''main'' are displayed each
|
|
||||||
time. The single character on the left hand edge is the
|
|
||||||
output from the C program. On the third occurrence of //getc//
|
|
||||||
the program stops. We can look at the full buffer of
|
|
||||||
characters by typing:
|
|
||||||
**ibuf+6/20c**
|
|
||||||
When we continue the program with:
|
|
||||||
**:c**
|
|
||||||
we hit our first breakpoint at ''tabpos'' since there is a tab
|
|
||||||
following the "This" word of the data.
|
|
||||||
|
|
||||||
Several breakpoints of ''tabpos'' will occur until the program
|
|
||||||
has changed the tab into equivalent blanks. Since we
|
|
||||||
feel that ''tabpos'' is working, we can remove the breakpoint at
|
|
||||||
that location by:
|
|
||||||
**tabpos+4:d**
|
|
||||||
If the program is continued with:
|
|
||||||
**:c**
|
|
||||||
it resumes normal execution after ADB prints the message
|
|
||||||
**a.out:running**
|
|
||||||
|
|
||||||
The UNIX quit and interrupt signals act on ADB itself
|
|
||||||
rather than on the program being debugged. If such a signal
|
|
||||||
occurs then the program being debugged is stopped and control
|
|
||||||
is returned to ADB. The signal is saved by ADB and is
|
|
||||||
passed on to the test program if:
|
|
||||||
**:c**
|
|
||||||
is typed. This can be useful when testing interrupt handling
|
|
||||||
routines. The signal is not passed on to the test
|
|
||||||
program if:
|
|
||||||
**:c 0**
|
|
||||||
is typed.
|
|
||||||
|
|
||||||
Now let us reset the breakpoint at ''settab'' and display
|
|
||||||
the instructions located there when we reach the breakpoint.
|
|
||||||
This is accomplished by:
|
|
||||||
**settab+4:b settab,5?ia** (*
|
|
||||||
It is also possible to execute the ADB requests for each
|
|
||||||
occurrence of the breakpoint but only stop after the third
|
|
||||||
occurrence by typing:
|
|
||||||
**getc+4,3:b main.c?C** (*
|
|
||||||
This request will print the local variable ''c'' in the function
|
|
||||||
''main'' at each occurrence of the breakpoint. The semicolon is
|
|
||||||
used to separate multiple ADB requests on a single line.
|
|
||||||
|
|
||||||
Warning: setting a breakpoint causes the value of dot
|
|
||||||
to be changed; executing the program under ADB does not
|
|
||||||
change dot. Therefore:
|
|
||||||
**settab+4:b .,5?ia**
|
|
||||||
-----------
|
|
||||||
(* Owing to a bug in early versions of ADB (including
|
|
||||||
the version distributed in Generic 3 UNIX)
|
|
||||||
these statements must be written as:
|
|
||||||
**settab+4:b settab,5?ia;0**
|
|
||||||
**getc+4,3:b main.c?C;0**
|
|
||||||
**settab+4:b settab,5?ia; ptab/o;0**
|
|
||||||
Note that **;0** will set dot to zero and stop at the
|
|
||||||
breakpoint.
|
|
||||||
|
|
||||||
**fopen+4:b**
|
|
||||||
will print the last thing dot was set to (in the example
|
|
||||||
''fopen+4'') ''not'' the current location (''settab+4'') at which the
|
|
||||||
program is executing.
|
|
||||||
|
|
||||||
A breakpoint can be overwritten without first deleting
|
|
||||||
the old breakpoint. For example:
|
|
||||||
**settab+4:b settab,5?ia; ptab/o** (*
|
|
||||||
could be entered after typing the above requests.
|
|
||||||
|
|
||||||
Now the display of breakpoints:
|
|
||||||
**$b**
|
|
||||||
shows the above request for the ''settab'' breakpoint. When the
|
|
||||||
breakpoint at ''settab'' is encountered the ADB requests are
|
|
||||||
executed. Note that the location at ''settab+4'' has been
|
|
||||||
changed to plant the breakpoint; all the other locations
|
|
||||||
match their original value.
|
|
||||||
|
|
||||||
Using the functions, ''f,'' ''g'' and ''h'' shown in Figure 3, we
|
|
||||||
can follow the execution of each function by planting non-stopping
|
|
||||||
breakpoints. We call ADB with the executable program
|
|
||||||
of Figure 3 as follows:
|
|
||||||
**adb ex3 -**
|
|
||||||
Suppose we enter the following breakpoints:
|
|
||||||
**h+4:b hcnt/d; h.hi/; h.hr/**
|
|
||||||
**g+4:b gcnt/d; g.gi/; g.gr/**
|
|
||||||
**f+4:b fcnt/d; f.fi/; f.fr/**
|
|
||||||
**:r**
|
|
||||||
Each request line indicates that the variables are printed
|
|
||||||
in decimal (by the specification **d**). Since the format is
|
|
||||||
not changed, the **d** can be left off all but the first
|
|
||||||
request.
|
|
||||||
|
|
||||||
The output in Figure 7 illustrates two points. First,
|
|
||||||
the ADB requests in the breakpoint line are not examined
|
|
||||||
until the program under test is run. That means any errors
|
|
||||||
in those ADB requests is not detected until run time. At
|
|
||||||
the location of the error ADB stops running the program.
|
|
||||||
|
|
||||||
The second point is the way ADB handles register variables.
|
|
||||||
ADB uses the symbol table to address variables.
|
|
||||||
Register variables, like ''f.fr'' above, have pointers to uninitialized
|
|
||||||
places on the stack. Therefore the message "symbol
|
|
||||||
not found".
|
|
||||||
|
|
||||||
Another way of getting at the data in this example is
|
|
||||||
to print the variables used in the call as:
|
|
||||||
**f+4:b fcnt/d; f.a/; f.b/; f.fi/**
|
|
||||||
**g+4:b gcnt/d; g.p/; g.q/; g.gi/**
|
|
||||||
**:c**
|
|
||||||
The operator / was used instead of ? to read values from
|
|
||||||
the ''core'' file. The output for each function, as shown in
|
|
||||||
Figure 7, has the same format. For the function ''f'', for
|
|
||||||
example, it shows the name and value of the //external//
|
|
||||||
variable ''fcnt.'' It also shows the address on the stack and
|
|
||||||
value of the variables //a,'' ''b'' and ''fi.//
|
|
||||||
|
|
||||||
Notice that the addresses on the stack will continue to
|
|
||||||
decrease until no address space is left for program execution
|
|
||||||
at which time (after many pages of output) the program
|
|
||||||
under test aborts. A display with names would be produced
|
|
||||||
by requests like the following:
|
|
||||||
**f+4:b fcnt/d; f.a/"a="d; f.b/"b="d; f.fi/"fi="d**
|
|
||||||
In this format the quoted string is printed literally and
|
|
||||||
the **d** produces a decimal display of the variables. The
|
|
||||||
results are shown in Figure 7.
|
|
||||||
|
|
||||||
==== 3.5. Other Breakpoint Facilities ====
|
|
||||||
|
|
||||||
(*) Arguments and change of standard input and output are
|
|
||||||
passed to a program as:
|
|
||||||
**:r arg1 arg2 ... <infile >outfile**
|
|
||||||
This request kills any existing program under test and
|
|
||||||
starts the ''a.out'' afresh.
|
|
||||||
|
|
||||||
(*) The program being debugged can be single stepped by:
|
|
||||||
**:s**
|
|
||||||
If necessary, this request will start up the program
|
|
||||||
being debugged and stop after executing the first
|
|
||||||
instruction.
|
|
||||||
|
|
||||||
(*) ADB allows a program to be entered at a specific address
|
|
||||||
by typing:
|
|
||||||
**address:r**
|
|
||||||
|
|
||||||
(*) The count field can be used to skip the first ''n'' breakpoints as:
|
|
||||||
**,n:r**
|
|
||||||
The request:
|
|
||||||
**,n:c**
|
|
||||||
may also be used for skipping the first ''n'' breakpoints
|
|
||||||
when continuing a program.
|
|
||||||
|
|
||||||
|
|
||||||
(*) A program can be continued at an address different from
|
|
||||||
the breakpoint by:
|
|
||||||
**address:c**
|
|
||||||
|
|
||||||
(*) The program being debugged runs as a separate process
|
|
||||||
and can be killed by:
|
|
||||||
**:k**
|
|
||||||
|
|
||||||
|
|
||||||
===== 4. Maps =====
|
|
||||||
|
|
||||||
UNIX supports several executable file formats. These
|
|
||||||
are used to tell the loader how to load the program file.
|
|
||||||
|
|
||||||
File type 407 is the most common and is generated by a C
|
|
||||||
compiler invocation such as **cc pgm.c**. A 410 file is produced
|
|
||||||
by a C compiler command of the form **cc -n pgm.c**,
|
|
||||||
whereas a 411 file is produced by **cc -i pgm.c**. ADB interprets
|
|
||||||
these different file formats and provides access to
|
|
||||||
the different segments through a set of maps (see Figure 8).
|
|
||||||
To print the maps type:
|
|
||||||
**$m**
|
|
||||||
|
|
||||||
In 407 files, both text (instructions) and data are
|
|
||||||
intermixed. This makes it impossible for ADB to differentiate
|
|
||||||
data from instructions and some of the printed symbolic
|
|
||||||
addresses look incorrect; for example, printing data
|
|
||||||
addresses as offsets from routines.
|
|
||||||
|
|
||||||
In 410 files (shared text), the instructions are separated
|
|
||||||
from data and **?* ** accesses the data part of the ''a.out**
|
|
||||||
file. The **?* ** request tells ADB to use the second part of
|
|
||||||
the map in the ''a.out'' file. Accessing data in the ''core'' file
|
|
||||||
shows the data after it was modified by the execution of the
|
|
||||||
program. Notice also that the data segment may have grown
|
|
||||||
during program execution.
|
|
||||||
|
|
||||||
In 411 files (separated I & D space), the instructions
|
|
||||||
and data are also separated. However, in this case, since
|
|
||||||
data is mapped through a separate set of segmentation registers,
|
|
||||||
the base of the data segment is also relative to
|
|
||||||
address zero. In this case since the addresses overlap it
|
|
||||||
is necessary to use the **?* ** operator to access the data space
|
|
||||||
of the ''a.out'' file. In both 410 and 411 files the corresponding
|
|
||||||
core file does not contain the program text.
|
|
||||||
|
|
||||||
Figure 9 shows the display of three maps for the same
|
|
||||||
program linked as a 407, 410, 411 respectively. The b, e,
|
|
||||||
and f fields are used by ADB to map addresses into file
|
|
||||||
addresses. The "f1" field is the length of the header at
|
|
||||||
the beginning of the file (020 bytes for an ''a.out'' file and
|
|
||||||
02000 bytes for a ''core'' file). The "f2" field is the displacement
|
|
||||||
from the beginning of the file to the data. For a
|
|
||||||
407 file with mixed text and data this is the same as the
|
|
||||||
length of the header; for 410 and 411 files this is the
|
|
||||||
length of the header plus the size of the text portion.
|
|
||||||
|
|
||||||
The "b" and "e" fields are the starting and ending
|
|
||||||
locations for a segment. Given an address, A, the location
|
|
||||||
in the file (either ''a.out'' or ''core'') is calculated as:
|
|
||||||
**b1<=A<=e1 => file address = (A-b1)+f1**
|
|
||||||
**b2<=A<=e2 => file address = (A-b2)+f2**
|
|
||||||
A user can access locations by using the ADB defined variables.
|
|
||||||
The **$v** request prints the variables initialized by
|
|
||||||
ADB:
|
|
||||||
|
|
||||||
|| b || base address of data segment ||
|
|
||||||
|| d || length of the data segment ||
|
|
||||||
|| s || length of the stack ||
|
|
||||||
|| t || length of the text ||
|
|
||||||
|| m || execution type (407,410,411) ||
|
|
||||||
|
|
||||||
In Figure 9 those variables not present are zero. Use
|
|
||||||
can be made of these variables by expressions such as:
|
|
||||||
**<b**
|
|
||||||
in the address field. Similarly the value of the variable
|
|
||||||
can be changed by an assignment request such as:
|
|
||||||
**02000>b**
|
|
||||||
that sets **b** to octal 2000. These variables are useful to
|
|
||||||
know if the file under examination is an executable or //core//
|
|
||||||
image file.
|
|
||||||
|
|
||||||
ADB reads the header of the ''core'' image file to find the
|
|
||||||
values for these variables. If the second file specified
|
|
||||||
does not seem to be a ''core'' file, or if it is missing then
|
|
||||||
the header of the executable file is used instead.
|
|
||||||
|
|
||||||
|
|
||||||
===== 5. Advanced Usage =====
|
|
||||||
|
|
||||||
It is possible with ADB to combine formatting requests
|
|
||||||
to provide elaborate displays. Below are several examples.
|
|
||||||
|
|
||||||
==== 5.1. Formatted dump ====
|
|
||||||
|
|
||||||
The line:
|
|
||||||
**<b,-1/4o4^8Cn**
|
|
||||||
prints 4 octal words followed by their ASCII interpretation
|
|
||||||
from the data space of the core image file. Broken down,
|
|
||||||
the various request pieces mean:
|
|
||||||
|
|
||||||
|| <b || The base address of the data segment. ||
|
|
||||||
|| <b,-1 || Print from the base address to the end of file. A negative count is used here and elsewhere to loop indefinitely or until some error condition (like end of file) is detected. ||
|
|
||||||
|
|
||||||
The format **4o4^8Cn** is broken down as follows:
|
|
||||||
|
|
||||||
|| 4o || Print 4 octal locations. ||
|
|
||||||
|| 4^ || Backup the current address 4 locations (to the original start of the field). ||
|
|
||||||
|| 8C || Print 8 consecutive characters using an escape convention; each character in the range 0 to 037 is printed as @ followed by the corresponding character in the range 0140 to 0177. An @ is printed as @@. ||
|
|
||||||
|| n || Print a newline. ||
|
|
||||||
|
|
||||||
The request:
|
|
||||||
**<b,<d/4o4^8Cn**
|
|
||||||
could have been used instead to allow the printing to stop
|
|
||||||
at the end of the data segment (<d provides the data segment
|
|
||||||
size in bytes).
|
|
||||||
|
|
||||||
The formatting requests can be combined with ADB's
|
|
||||||
ability to read in a script to produce a core image dump
|
|
||||||
script. ADB is invoked as:
|
|
||||||
**adb a.out core < dump**
|
|
||||||
to read in a script file, ''dump,'' of requests. An example of
|
|
||||||
such a script is:
|
|
||||||
**120$w**
|
|
||||||
**4095$s**
|
|
||||||
**$v**
|
|
||||||
**=3n**
|
|
||||||
**$m**
|
|
||||||
**=3n"C Stack Backtrace"**
|
|
||||||
**$C**
|
|
||||||
**=3n"C External Variables"**
|
|
||||||
**$e**
|
|
||||||
**=3n"Registers"**
|
|
||||||
**$r**
|
|
||||||
**0$s**
|
|
||||||
**=3n"Data Segment"**
|
|
||||||
**<b,-1/8ona**
|
|
||||||
|
|
||||||
The request **120$w** sets the width of the output to 120
|
|
||||||
characters (normally, the width is 80 characters). ADB
|
|
||||||
attempts to print addresses as:
|
|
||||||
**symbol + offset**
|
|
||||||
The request **4095$s** increases the maximum permissible offset
|
|
||||||
to the nearest symbolic address from 255 (default) to 4095.
|
|
||||||
The request **=** can be used to print literal strings. Thus,
|
|
||||||
headings are provided in this ''dump'' program with requests of
|
|
||||||
the form:
|
|
||||||
**=3n"C Stack Backtrace"**
|
|
||||||
that spaces three lines and prints the literal string. The
|
|
||||||
request **$v** prints all non-zero ADB variables (see Figure 8).
|
|
||||||
The request **0$s** sets the maximum offset for symbol matches
|
|
||||||
to zero thus suppressing the printing of symbolic labels in
|
|
||||||
favor of octal values. Note that this is only done for the
|
|
||||||
printing of the data segment. The request:
|
|
||||||
**<b,-1/8ona**
|
|
||||||
prints a dump from the base of the data segment to the end
|
|
||||||
of file with an octal address field and eight octal numbers
|
|
||||||
per line.
|
|
||||||
|
|
||||||
Figure 11 shows the results of some formatting requests
|
|
||||||
on the C program of Figure 10.
|
|
||||||
|
|
||||||
==== 5.2. Directory Dump ====
|
|
||||||
|
|
||||||
As another illustration (Figure 12) consider a set of
|
|
||||||
requests to dump the contents of a directory (which is made
|
|
||||||
up of an integer ''inumber'' followed by a 14 character name):
|
|
||||||
**adb dir -**
|
|
||||||
**=n8t"Inum"8t"Name"**
|
|
||||||
**0,-1? u8t14cn**
|
|
||||||
In this example, the **u** prints the ''inumber'' as an unsigned
|
|
||||||
decimal integer, the **8t** means that ADB will space to the
|
|
||||||
next multiple of 8 on the output line, and the **14c** prints
|
|
||||||
the 14 character file name.
|
|
||||||
|
|
||||||
==== 5.3. Ilist Dump ====
|
|
||||||
|
|
||||||
Similarly the contents of the ''ilist'' of a file system,
|
|
||||||
(e.g. /dev/src, on UNIX systems distributed by the UNIX Support
|
|
||||||
Group; see UNIX Programmer's Manual Section V) could be
|
|
||||||
dumped with the following set of requests:
|
|
||||||
**adb /dev/src -**
|
|
||||||
**02000>b**
|
|
||||||
**?m <b**
|
|
||||||
**<b,-1?"flags"8ton"links,uid,gid"8t3bn",size"8tbrdn"addr"8t8un"times"8t2Y2na**
|
|
||||||
In this example the value of the base for the map was
|
|
||||||
changed to 02000 (by saying **?m<b**) since that is the start of
|
|
||||||
an ''ilist'' within a file system. An artifice (**brd** above) was
|
|
||||||
used to print the 24 bit size field as a byte, a space, and
|
|
||||||
a decimal integer. The last access time and last modify
|
|
||||||
time are printed with the **2Y** operator. Figure 12 shows portions
|
|
||||||
of these requests as applied to a directory and file
|
|
||||||
system.
|
|
||||||
|
|
||||||
==== 5.4. Converting values ====
|
|
||||||
|
|
||||||
ADB may be used to convert values from one representation
|
|
||||||
to another. For example:
|
|
||||||
**072 = odx**
|
|
||||||
will print
|
|
||||||
**072 58 #3a**
|
|
||||||
which is the octal, decimal and hexadecimal representations
|
|
||||||
of 072 (octal). The format is remembered so that typing
|
|
||||||
subsequent numbers will print them in the given formats.
|
|
||||||
Character values may be converted similarly, for example:
|
|
||||||
**'a' = co**
|
|
||||||
prints
|
|
||||||
**a 0141**
|
|
||||||
It may also be used to evaluate expressions but be warned
|
|
||||||
that all binary operators have the same precedence which is
|
|
||||||
lower than that for unary operators.
|
|
||||||
|
|
||||||
|
|
||||||
===== 6. Patching =====
|
|
||||||
|
|
||||||
Patching files with ADB is accomplished with the //write,// **w** or **W**,
|
|
||||||
request (which is not like the ''ed'' editor write
|
|
||||||
command). This is often used in conjunction with the
|
|
||||||
''locate,'' **l** or **L** request. In general, the request syntax
|
|
||||||
for **l** and **w** are similar as follows:
|
|
||||||
**?l value**
|
|
||||||
The request **l** is used to match on two bytes, **L** is used for
|
|
||||||
four bytes. The request **w** is used to write two bytes,
|
|
||||||
whereas **W** writes four bytes. The **value** field in either
|
|
||||||
''locate'' or ''write'' requests is an expression. Therefore, decimal
|
|
||||||
and octal numbers, or character strings are supported.
|
|
||||||
|
|
||||||
In order to modify a file, ADB must be called as:
|
|
||||||
**adb -w file1 file2**
|
|
||||||
When called with this option, ''file1'' and ''file2'' are created if
|
|
||||||
necessary and opened for both reading and writing.
|
|
||||||
|
|
||||||
For example, consider the C program shown in Figure 10.
|
|
||||||
We can change the word "This" to "The " in the executable
|
|
||||||
file for this program, ''ex7'', by using the following requests:
|
|
||||||
**adb -w ex7 -**
|
|
||||||
**?l 'Th'**
|
|
||||||
**?W 'The '**
|
|
||||||
The request **?l** starts at dot and stops at the first match of
|
|
||||||
"Th" having set dot to the address of the location found.
|
|
||||||
Note the use of **?** to write to the ''a.out'' file. The form **?* **
|
|
||||||
would have been used for a 411 file.
|
|
||||||
|
|
||||||
More frequently the request will be typed as:
|
|
||||||
**?l 'Th'; ?s**
|
|
||||||
and locates the first occurrence of "Th" and print the
|
|
||||||
entire string. Execution of this ADB request will set dot
|
|
||||||
to the address of the "Th" characters.
|
|
||||||
|
|
||||||
As another example of the utility of the patching
|
|
||||||
facility, consider a C program that has an internal logic
|
|
||||||
flag. The flag could be set by the user through ADB and the
|
|
||||||
program run. For example:
|
|
||||||
**adb a.out -**
|
|
||||||
**:s arg1 arg2**
|
|
||||||
**flag/w 1**
|
|
||||||
**:c**
|
|
||||||
The **:s** request is normally used to single step through a
|
|
||||||
process or start a process in single step mode. In this
|
|
||||||
case it starts ''a.out'' as a subprocess with arguments **arg1** and **arg2**.
|
|
||||||
If there is a subprocess running ADB writes to it
|
|
||||||
rather than to the file so the **w** request causes ''flag'' to be
|
|
||||||
changed in the memory of the subprocess.
|
|
||||||
|
|
||||||
|
|
||||||
===== 7. Anomalies =====
|
|
||||||
|
|
||||||
Below is a list of some strange things that users
|
|
||||||
should be aware of.
|
|
||||||
|
|
||||||
- Function calls and arguments are put on the stack by the C save routine. Putting breakpoints at the entry point to routines means that the function appears not to have been called when the breakpoint occurs.
|
|
||||||
|
|
||||||
- When printing addresses, ADB uses either text or data symbols from the ''a.out'' file. This sometimes causes unexpected symbol names to be printed with data (e.g. ''savr5+022''). This does not happen if **?** is used for text (instructions) and **/** for data.
|
|
||||||
|
|
||||||
- ADB cannot handle C register variables in the most recently activated function.
|
|
||||||
|
|
||||||
===== 8. Acknowledgements =====
|
|
||||||
|
|
||||||
The authors are grateful for the thoughtful comments on
|
|
||||||
how to organize this document from R. B. Brandt, E. N. Pinson
|
|
||||||
and B. A. Tague. D. M. Ritchie made the system changes
|
|
||||||
necessary to accommodate tracing within ADB. He also participated
|
|
||||||
in discussions during the writing of ADB. His earlier
|
|
||||||
work with DB and CDB led to many of the features found in ADB.
|
|
||||||
|
|
||||||
|
|
||||||
===== 9. References =====
|
|
||||||
|
|
||||||
- D. M. Ritchie and K. Thompson, "The UNIX Time-Sharing System", CACM, July, 1974.
|
|
||||||
|
|
||||||
- B. W. Kernighan and D. M. Ritchie, "The C Programming Language", Prentice-Hall, 1978.
|
|
||||||
|
|
||||||
- K. Thompson and D. M. Ritchie, UNIX Programmer's Manual - 7th Edition, 1978.
|
|
||||||
|
|
||||||
- B. W. Kernighan and P. J. Plauger, "Software Tools", Addison-Wesley, 1976.
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#ifdef CROSS
|
#include <ctype.h>
|
||||||
# include </usr/include/ctype.h>
|
|
||||||
#else
|
|
||||||
# include <ctype.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int savlastf;
|
static int savlastf;
|
||||||
static long savframe;
|
static long savframe;
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
#include <ctype.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#ifdef CROSS
|
|
||||||
# include </usr/include/ctype.h>
|
|
||||||
#else
|
|
||||||
# include <ctype.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
scanform(icount, ifp, itype, ptype)
|
scanform(icount, ifp, itype, ptype)
|
||||||
@@ -87,7 +83,7 @@ exform(fcount, ifp, itype, ptype)
|
|||||||
u_int w;
|
u_int w;
|
||||||
long savdot, wx;
|
long savdot, wx;
|
||||||
char *fp = 0;
|
char *fp = 0;
|
||||||
int c, modifier;
|
int c, modifier, longpr;
|
||||||
struct {
|
struct {
|
||||||
long sa;
|
long sa;
|
||||||
int sb, sc;
|
int sb, sc;
|
||||||
@@ -96,7 +92,7 @@ exform(fcount, ifp, itype, ptype)
|
|||||||
while (fcount > 0) {
|
while (fcount > 0) {
|
||||||
fp = ifp;
|
fp = ifp;
|
||||||
c = *fp;
|
c = *fp;
|
||||||
//int longpr = (c >= 'A' && c <= 'Z') || (c == 'f');
|
longpr = (c >= 'A' && c <= 'Z') || (c == 'f');
|
||||||
if (itype == NSP || *fp == 'a') {
|
if (itype == NSP || *fp == 'a') {
|
||||||
wx = dot;
|
wx = dot;
|
||||||
w = dot;
|
w = dot;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
char *Ipath = "/share/adb";
|
char *Ipath = "/share/adb";
|
||||||
|
|
||||||
@@ -60,27 +59,22 @@ main(argc, argv)
|
|||||||
myname = "adb";
|
myname = "adb";
|
||||||
mynamelen = strlen(myname);
|
mynamelen = strlen(myname);
|
||||||
|
|
||||||
#ifdef TIOCGETP
|
|
||||||
ioctl(0, TIOCGETP, &adbtty);
|
ioctl(0, TIOCGETP, &adbtty);
|
||||||
ioctl(0, TIOCGETP, &usrtty);
|
ioctl(0, TIOCGETP, &usrtty);
|
||||||
#else
|
|
||||||
tcgetattr(0, &adbtty);
|
|
||||||
tcgetattr(0, &usrtty);
|
|
||||||
#endif
|
|
||||||
while (argc > 1) {
|
while (argc > 1) {
|
||||||
if (strcmp("-w", argv[1]) == 0) {
|
if (! strcmp("-w", argv[1])) {
|
||||||
wtflag = O_RDWR;
|
wtflag = 2;
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp("-k", argv[1]) == 0) {
|
if (! strcmp("-k", argv[1])) {
|
||||||
kernel++;
|
kernel++;
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (strcmp("-I", argv[1]) == 0) {
|
if (! strcmp("-I", argv[1])) {
|
||||||
Ipath = argv[2];
|
Ipath = argv[2];
|
||||||
argc -= 2;
|
argc -= 2;
|
||||||
argv += 2;
|
argv += 2;
|
||||||
@@ -127,7 +121,7 @@ main(argc, argv)
|
|||||||
flushbuf();
|
flushbuf();
|
||||||
if (errflg) {
|
if (errflg) {
|
||||||
print("%s\n", errflg);
|
print("%s\n", errflg);
|
||||||
exitflg = (errflg != 0);
|
exitflg = (int) errflg;
|
||||||
errflg = 0;
|
errflg = 0;
|
||||||
}
|
}
|
||||||
if (mkfault) {
|
if (mkfault) {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
int outfile = 1;
|
int outfile = 1;
|
||||||
char *printptr = printbuf;
|
char *printptr = printbuf;
|
||||||
@@ -188,143 +187,153 @@ printdate(tvec)
|
|||||||
void
|
void
|
||||||
print(char *fmat, ...)
|
print(char *fmat, ...)
|
||||||
{
|
{
|
||||||
va_list args, prev_args;
|
|
||||||
char *fptr, *s;
|
char *fptr, *s;
|
||||||
|
int *vptr;
|
||||||
|
long *dptr;
|
||||||
|
double *rptr;
|
||||||
int width, prec;
|
int width, prec;
|
||||||
char c, adj;
|
char c, adj;
|
||||||
int decpt, n;
|
int x, decpt, n;
|
||||||
|
long lx;
|
||||||
char digits[64];
|
char digits[64];
|
||||||
union {
|
|
||||||
int int32;
|
|
||||||
float float32;
|
|
||||||
} word;
|
|
||||||
|
|
||||||
va_start(args, fmat);
|
|
||||||
fptr = fmat;
|
fptr = fmat;
|
||||||
|
vptr = 1 + (int*) &fmat;
|
||||||
|
|
||||||
while ((c = *fptr++)) {
|
while ((c = *fptr++)) {
|
||||||
if (c != '%') {
|
if (c != '%') {
|
||||||
printc(c);
|
printc(c);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*fptr == '-') {
|
|
||||||
adj = 'l';
|
|
||||||
fptr++;
|
|
||||||
} else {
|
} else {
|
||||||
adj = 'r';
|
if (*fptr == '-') {
|
||||||
}
|
adj = 'l';
|
||||||
width = convert(&fptr);
|
fptr++;
|
||||||
if (*fptr == '*') {
|
} else {
|
||||||
width = va_arg(args, int);
|
adj = 'r';
|
||||||
fptr++;
|
}
|
||||||
}
|
width = convert(&fptr);
|
||||||
if (*fptr == '.') {
|
|
||||||
fptr++;
|
|
||||||
prec = convert(&fptr);
|
|
||||||
if (*fptr == '*') {
|
if (*fptr == '*') {
|
||||||
prec = va_arg(args, int);
|
width = *vptr++;
|
||||||
fptr++;
|
fptr++;
|
||||||
}
|
}
|
||||||
} else
|
if (*fptr == '.') {
|
||||||
prec = -1;
|
fptr++;
|
||||||
|
prec = convert(&fptr);
|
||||||
|
if (*fptr == '*') {
|
||||||
|
prec = *vptr++;
|
||||||
|
fptr++;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
prec = -1;
|
||||||
|
|
||||||
digitptr = digits;
|
digitptr = digits;
|
||||||
prev_args = args;
|
rptr = (double*) vptr;
|
||||||
word.int32 = va_arg(args, int);
|
dptr = (long*) vptr;
|
||||||
s = 0;
|
lx = *dptr;
|
||||||
switch (c = *fptr++) {
|
x = *vptr++;
|
||||||
case 'd':
|
|
||||||
case 'u':
|
|
||||||
printnum(word.int32, c, 10);
|
|
||||||
break;
|
|
||||||
case 'o':
|
|
||||||
printoct(word.int32, 0);
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
case 'x':
|
|
||||||
printlong(word.int32, 'x', 16);
|
|
||||||
break;
|
|
||||||
case 'Y':
|
|
||||||
printdate(word.int32);
|
|
||||||
break;
|
|
||||||
case 'D':
|
|
||||||
case 'U':
|
|
||||||
printlong(word.int32, c, 10);
|
|
||||||
break;
|
|
||||||
case 'O':
|
|
||||||
printoct(word.int32, 0);
|
|
||||||
break;
|
|
||||||
case 'Q':
|
|
||||||
case 'X':
|
|
||||||
printlong(word.int32, 'x', 16);
|
|
||||||
break;
|
|
||||||
case 'c':
|
|
||||||
printc(word.int32);
|
|
||||||
break;
|
|
||||||
case 's':
|
|
||||||
s = (char*) word.int32;
|
|
||||||
break;
|
|
||||||
case 'f':
|
|
||||||
case 'F':
|
|
||||||
s = ecvt(word.float32, prec, &decpt, &n);
|
|
||||||
*digitptr++ = n ? '-' : '+';
|
|
||||||
*digitptr++ = (decpt <= 0) ? '0' : *s++;
|
|
||||||
if (decpt > 0) {
|
|
||||||
decpt--;
|
|
||||||
}
|
|
||||||
*digitptr++ = '.';
|
|
||||||
while (*s && prec-- ) {
|
|
||||||
*digitptr++ = *s++;
|
|
||||||
}
|
|
||||||
while (*--digitptr=='0');
|
|
||||||
digitptr += (digitptr - digits >= 3) ? 1 : 2;
|
|
||||||
if (decpt) {
|
|
||||||
*digitptr++ = 'e';
|
|
||||||
printnum(decpt, 'd', 10);
|
|
||||||
}
|
|
||||||
s = 0;
|
s = 0;
|
||||||
prec = -1;
|
switch (c = *fptr++) {
|
||||||
break;
|
case 'd':
|
||||||
case 'm':
|
case 'u':
|
||||||
args = prev_args;
|
printnum(x, c, 10);
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'o':
|
||||||
width = word.int32;
|
printoct((long) (unsigned) x, 0);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'q':
|
||||||
case 't':
|
printlong((long) (unsigned) x, 'x', 16);
|
||||||
if (c == 'T') {
|
break;
|
||||||
width = word.int32;
|
case 'x':
|
||||||
} else {
|
printlong((long) (unsigned) x, c, 16);
|
||||||
args = prev_args;
|
break;
|
||||||
|
case 'Y':
|
||||||
|
printdate(lx);
|
||||||
|
//vptr++;
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
case 'U':
|
||||||
|
printlong(lx, c, 10);
|
||||||
|
//vptr++;
|
||||||
|
break;
|
||||||
|
case 'O':
|
||||||
|
printoct(lx, 0);
|
||||||
|
//vptr++;
|
||||||
|
break;
|
||||||
|
case 'Q':
|
||||||
|
printlong(lx, 'x', 16);
|
||||||
|
//vptr++;
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
printlong(lx, 'x', 16);
|
||||||
|
//vptr++;
|
||||||
|
break;
|
||||||
|
case 'c':
|
||||||
|
printc(x);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
s = (char*) x;
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
case 'F':
|
||||||
|
//vptr += 7;
|
||||||
|
s = ecvt(*rptr, prec, &decpt, &n);
|
||||||
|
*digitptr++ = (n?'-':'+');
|
||||||
|
*digitptr++ = (decpt <= 0) ? '0' : *s++;
|
||||||
|
if (decpt > 0) {
|
||||||
|
decpt--;
|
||||||
|
}
|
||||||
|
*digitptr++ = '.';
|
||||||
|
while (*s && prec-- ) {
|
||||||
|
*digitptr++ = *s++;
|
||||||
|
}
|
||||||
|
while (*--digitptr=='0');
|
||||||
|
digitptr += (digitptr - digits >= 3) ? 1 : 2;
|
||||||
|
if (decpt) {
|
||||||
|
*digitptr++ = 'e';
|
||||||
|
printnum(decpt, 'd', 10);
|
||||||
|
}
|
||||||
|
s = 0;
|
||||||
|
prec = -1;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
vptr--;
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
width = x;
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
case 't':
|
||||||
|
if (c == 'T') {
|
||||||
|
width = x;
|
||||||
|
} else {
|
||||||
|
vptr--;
|
||||||
|
}
|
||||||
|
if (width) {
|
||||||
|
width -= (printptr - printbuf) % width;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printc(c);
|
||||||
|
vptr--;
|
||||||
}
|
}
|
||||||
if (width) {
|
|
||||||
width -= (printptr - printbuf) % width;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
printc(c);
|
|
||||||
args = prev_args;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s == 0) {
|
if (s == 0) {
|
||||||
*digitptr = 0;
|
*digitptr = 0;
|
||||||
s = digits;
|
s = digits;
|
||||||
}
|
}
|
||||||
n = strlen(s);
|
n = strlen(s);
|
||||||
n = (prec < n && prec >= 0) ? prec : n;
|
n = (prec < n && prec >= 0) ? prec : n;
|
||||||
width -= n;
|
width -= n;
|
||||||
if (adj == 'r') {
|
if (adj == 'r') {
|
||||||
|
while (width-- > 0)
|
||||||
|
printc(SP);
|
||||||
|
}
|
||||||
|
while (n--)
|
||||||
|
printc(*s++);
|
||||||
while (width-- > 0)
|
while (width-- > 0)
|
||||||
printc(SP);
|
printc(SP);
|
||||||
|
digitptr = digits;
|
||||||
}
|
}
|
||||||
while (n--)
|
|
||||||
printc(*s++);
|
|
||||||
while (width-- > 0)
|
|
||||||
printc(SP);
|
|
||||||
digitptr = digits;
|
|
||||||
}
|
}
|
||||||
va_end(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAXIFD 5
|
#define MAXIFD 5
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ printregs()
|
|||||||
int v;
|
int v;
|
||||||
|
|
||||||
if (kernel) {
|
if (kernel) {
|
||||||
// TODO
|
|
||||||
for (p=kregs; p<&kregs[7]; p++) {
|
for (p=kregs; p<&kregs[7]; p++) {
|
||||||
v = corhdr[p->roffs];
|
v = corhdr[p->roffs];
|
||||||
print("%s%8t%x%8t", p->rname, v);
|
print("%s%8t%x%8t", p->rname, v);
|
||||||
@@ -82,30 +81,12 @@ printregs()
|
|||||||
printc(EOR);
|
printc(EOR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print (" t0 = %9x s0 = %9x t8 = %9x lo = %9x\n",
|
for (p=reglist; p < ®list[NREG]; p++) {
|
||||||
uframe [FRAME_R8], uframe [FRAME_R16],
|
v = uframe[p->roffs];
|
||||||
uframe [FRAME_R24], uframe [FRAME_LO]);
|
print("%s%8t%x%8t", p->rname, v);
|
||||||
print ("at = %9x t1 = %9x s1 = %9x t9 = %9x hi = %9x\n",
|
valpr(v, (p->roffs == FRAME_PC) ? ISYM : DSYM);
|
||||||
uframe [FRAME_R1], uframe [FRAME_R9], uframe [FRAME_R17],
|
printc(EOR);
|
||||||
uframe [FRAME_R25], uframe [FRAME_HI]);
|
}
|
||||||
print ("v0 = %9x t2 = %9x s2 = %9x status = %9x\n",
|
|
||||||
uframe [FRAME_R2], uframe [FRAME_R10],
|
|
||||||
uframe [FRAME_R18], uframe [FRAME_STATUS]);
|
|
||||||
print ("v1 = %9x t3 = %9x s3 = %9x pc = %9x\n",
|
|
||||||
uframe [FRAME_R3], uframe [FRAME_R11],
|
|
||||||
uframe [FRAME_R19], uframe [FRAME_PC]);
|
|
||||||
print ("a0 = %9x t4 = %9x s4 = %9x gp = %9x\n",
|
|
||||||
uframe [FRAME_R4], uframe [FRAME_R12],
|
|
||||||
uframe [FRAME_R20], uframe [FRAME_GP]);
|
|
||||||
print ("a1 = %9x t5 = %9x s5 = %9x sp = %9x\n",
|
|
||||||
uframe [FRAME_R5], uframe [FRAME_R13],
|
|
||||||
uframe [FRAME_R21], uframe [FRAME_SP]);
|
|
||||||
print ("a2 = %9x t6 = %9x s6 = %9x fp = %9x\n",
|
|
||||||
uframe [FRAME_R6], uframe [FRAME_R14],
|
|
||||||
uframe [FRAME_R22], uframe [FRAME_FP]);
|
|
||||||
print ("a3 = %9x t7 = %9x s7 = %9x ra = %9x\n",
|
|
||||||
uframe [FRAME_R7], uframe [FRAME_R15],
|
|
||||||
uframe [FRAME_R23], uframe [FRAME_RA]);
|
|
||||||
printpc();
|
printpc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,7 +285,7 @@ printtrace(modif)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e': case 'E': /* print externals */
|
case 'e': case 'E': /* print externals*/
|
||||||
symset();
|
symset();
|
||||||
while ((symp = symget())) {
|
while ((symp = symget())) {
|
||||||
chkerr();
|
chkerr();
|
||||||
@@ -417,10 +398,8 @@ printpc()
|
|||||||
void
|
void
|
||||||
sigprint()
|
sigprint()
|
||||||
{
|
{
|
||||||
#ifndef CROSS
|
|
||||||
if (signo >= 0 && signo < NSIG)
|
if (signo >= 0 && signo < NSIG)
|
||||||
print("%s", sys_siglist[signo]);
|
print("%s", sys_siglist[signo]);
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
print("unknown signal %d", signo);
|
print("unknown signal %d", signo);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,14 +23,8 @@ bpwait()
|
|||||||
while ((w = wait(&stat)) != pid && w != -1)
|
while ((w = wait(&stat)) != pid && w != -1)
|
||||||
;
|
;
|
||||||
signal(SIGINT, sigint);
|
signal(SIGINT, sigint);
|
||||||
|
|
||||||
#ifdef TIOCGETP
|
|
||||||
ioctl(0, TIOCGETP, &usrtty);
|
ioctl(0, TIOCGETP, &usrtty);
|
||||||
ioctl(0, TIOCSETP, &adbtty);
|
ioctl(0, TIOCSETP, &adbtty);
|
||||||
#else
|
|
||||||
tcgetattr(0, &usrtty);
|
|
||||||
tcsetattr(0, TCSANOW, &adbtty);
|
|
||||||
#endif
|
|
||||||
if (w == -1) {
|
if (w == -1) {
|
||||||
pid = 0;
|
pid = 0;
|
||||||
errflg = BADWAIT;
|
errflg = BADWAIT;
|
||||||
@@ -69,7 +63,7 @@ readregs()
|
|||||||
|
|
||||||
for (i=0; i<NREG; i++) {
|
for (i=0; i<NREG; i++) {
|
||||||
uframe[reglist[i].roffs] = ptrace(PT_READ_U, pid,
|
uframe[reglist[i].roffs] = ptrace(PT_READ_U, pid,
|
||||||
(char*)((long)&uframe[reglist[i].roffs] - (long)&corhdr),
|
(int *)((int)&uframe[reglist[i].roffs] - (int)&corhdr),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,18 +73,12 @@ execbkpt(bkptr)
|
|||||||
BKPTR bkptr;
|
BKPTR bkptr;
|
||||||
{
|
{
|
||||||
int bkptloc;
|
int bkptloc;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
print("exbkpt: %d\n", bkptr->count);
|
print("exbkpt: %d\n", bkptr->count);
|
||||||
#endif
|
#endif
|
||||||
bkptloc = bkptr->loc;
|
bkptloc = bkptr->loc;
|
||||||
ptrace(PT_WRITE_I, pid, (void*) bkptloc, bkptr->ins);
|
ptrace(PT_WRITE_I, pid, (void*) bkptloc, bkptr->ins);
|
||||||
|
|
||||||
#ifdef TIOCGETP
|
|
||||||
ioctl(0, TIOCSETP, &usrtty);
|
ioctl(0, TIOCSETP, &usrtty);
|
||||||
#else
|
|
||||||
tcsetattr(0, TCSANOW, &usrtty);
|
|
||||||
#endif
|
|
||||||
ptrace(PT_STEP, pid, (void*) bkptloc, 0);
|
ptrace(PT_STEP, pid, (void*) bkptloc, 0);
|
||||||
bpwait();
|
bpwait();
|
||||||
chkerr();
|
chkerr();
|
||||||
@@ -112,11 +100,7 @@ runpcs(runmode, execsig)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
print("\ncontinue %d %d\n", userpc, execsig);
|
print("\ncontinue %d %d\n", userpc, execsig);
|
||||||
#endif
|
#endif
|
||||||
#ifdef TIOCGETP
|
|
||||||
ioctl(0, TIOCSETP, &usrtty);
|
ioctl(0, TIOCSETP, &usrtty);
|
||||||
#else
|
|
||||||
tcsetattr(0, TCSANOW, &usrtty);
|
|
||||||
#endif
|
|
||||||
ptrace (runmode, pid, (void*) userpc, execsig);
|
ptrace (runmode, pid, (void*) userpc, execsig);
|
||||||
bpwait();
|
bpwait();
|
||||||
chkerr();
|
chkerr();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <strings.h>
|
|
||||||
|
|
||||||
u_int *uframe = UFRAME;
|
u_int *uframe = UFRAME;
|
||||||
char *symfil = "a.out";
|
char *symfil = "a.out";
|
||||||
@@ -15,15 +14,16 @@ getfile(filnam, cnt)
|
|||||||
{
|
{
|
||||||
register int f;
|
register int f;
|
||||||
|
|
||||||
if (strcmp("-", filnam) == 0)
|
if (strcmp("-", filnam)) {
|
||||||
return -1;
|
f = open(filnam, wtflag);
|
||||||
|
if (f < 0 && argcount > cnt) {
|
||||||
f = open(filnam, wtflag);
|
if (wtflag)
|
||||||
if (f < 0 && argcount > cnt) {
|
f = open(filnam, O_CREAT | O_TRUNC | wtflag, 644);
|
||||||
if (wtflag)
|
if (f < 0)
|
||||||
f = open(filnam, O_CREAT | O_TRUNC | wtflag, 644);
|
print("cannot open `%s'\n", filnam);
|
||||||
if (f < 0)
|
}
|
||||||
print("cannot open `%s'\n", filnam);
|
} else {
|
||||||
|
f = -1;
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
@@ -77,9 +77,9 @@ setcor()
|
|||||||
datmap.ufd = fcor;
|
datmap.ufd = fcor;
|
||||||
if (read(fcor, corhdr, sizeof corhdr) == sizeof corhdr) {
|
if (read(fcor, corhdr, sizeof corhdr) == sizeof corhdr) {
|
||||||
if (! kernel) {
|
if (! kernel) {
|
||||||
txtsiz = ((struct user*)corhdr)->u_tsize;
|
txtsiz = ((U*)corhdr)->u_tsize;
|
||||||
datsiz = ((struct user*)corhdr)->u_dsize;
|
datsiz = ((U*)corhdr)->u_dsize;
|
||||||
stksiz = ((struct user*)corhdr)->u_ssize;
|
stksiz = ((U*)corhdr)->u_ssize;
|
||||||
datmap.f1 = USIZE;
|
datmap.f1 = USIZE;
|
||||||
datmap.b2 = USER_DATA_END - stksiz;
|
datmap.b2 = USER_DATA_END - stksiz;
|
||||||
datmap.e2 = USER_DATA_END;
|
datmap.e2 = USER_DATA_END;
|
||||||
@@ -112,14 +112,13 @@ setcor()
|
|||||||
}
|
}
|
||||||
datbas = datmap.b1;
|
datbas = datmap.b1;
|
||||||
if (! kernel && magic) {
|
if (! kernel && magic) {
|
||||||
/* User's frame pointer in user's address space. */
|
register u_int *frame;
|
||||||
register u_int frame;
|
frame = (u_int*) ((U*)corhdr)->u_frame;
|
||||||
frame = (long) ((struct user*)corhdr)->u_frame;
|
if (frame > (u_int*) (KERNEL_DATA_END - USIZE) &&
|
||||||
frame -= KERNEL_DATA_END - USIZE;
|
frame < (u_int*) KERNEL_DATA_END &&
|
||||||
if (frame > 0 && frame < USIZE && ! (frame & 3)) {
|
! ((unsigned)frame & 3))
|
||||||
/* User's frame pointer in adb address space. */
|
uframe = (u_int*) &corhdr[frame -
|
||||||
uframe = (u_int*) &corhdr[frame >> 2];
|
(u_int*) (KERNEL_DATA_END - USIZE)];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
datmap.e1 = maxfile;
|
datmap.e1 = maxfile;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user