107 Commits

Author SHA1 Message Date
Sergey
7e4b86d135 Branch "sdram" imported from GoogleCode. 2015-03-21 14:08:32 -07:00
Sergey
9bbe938e48 At startup, set peripheral clock PBCLK as defined by busdiv option
in kernel configuration file.
2015-02-14 20:20:19 -08:00
Sergey
d5c97a9b19 Added bit definitions for OSCCON register.
File machdep.c reindented.
2015-02-14 17:57:48 -08:00
Sergey
0005e7d7bf Fixed bug in fsck: using bcopy() instead of structure assignment.
File exception.c converted to indent4 format.
2015-02-13 21:05:03 -08:00
Sergey
42665ba3b3 SPI bus driver simplified. 2015-02-13 19:48:32 -08:00
Sergey
942bdda5ed Diskspeed: added extra sync and timeout before each test. 2015-02-13 19:41:32 -08:00
Serge Vakulenko
5ce8a8cd33 Added diskspeed utility. 2015-02-12 19:27:59 -08:00
Serge Vakulenko
b3442f28f3 Finalize skel.h. 2015-02-05 19:12:50 -08:00
Serge Vakulenko
29c75b3f71 Skeleton driver completed. 2015-02-05 19:08:53 -08:00
Serge Vakulenko
9b9f6392dc Added a skeleton for character driver. 2015-02-05 19:05:59 -08:00
Serge Vakulenko
f5bbefc222 Fixed indenting in devsw.c. 2015-02-05 18:13:17 -08:00
Serge Vakulenko
7f5ad5d3f8 Using Max32 board with Arduino SD card shield as a default configuration. 2015-02-04 14:28:03 -08:00
Serge Vakulenko
df8f8eaf71 Directory sys/pic32/max32 removed: nobody is using this configuration,
as it required a nonstandard SD card connection.
2015-02-04 14:18:42 -08:00
Serge Vakulenko
f62f70c718 Max32-eth configuration: SD card speed reduced to 10MHz.
Now it works stable with MakerStudio SD card shield.
2015-02-02 22:26:19 -08:00
Serge Vakulenko
1916f8c9da New kernel configuration: chipKIT WF32 board with microSD card on 2.4" LCD TFT display shield.
WF32 board by itself already has a microSD socket.
It's useless for RetroBSD though, as it is not connected to any
of available SPI ports (must use GPIO instead).

Fortunately, a cheap shield is widely available, which adds a microSD slot
connected to SPI2 pins.
2015-01-28 19:14:41 -08:00
Serge Vakulenko
d8269d1996 No more pause on tty output in case of clist overflow. 2015-01-20 18:09:13 -08:00
Serge Vakulenko
8e228dde62 Fixed bug in fsutil: incorrect positioning of partition superblock. 2015-01-06 19:47:31 -08:00
Serge Vakulenko
bae12383a0 Fixed build issues on Linux x86-64. 2015-01-06 19:36:49 -08:00
Serge Vakulenko
8e2c046406 Merge pull request #41 from alexfru/master
SmallerC: generate smaller & faster code; bugfixes
2014-12-29 20:06:10 -08:00
alex
dad5247184 Merge branch 'master' of https://github.com/alexfru/retrobsd 2014-12-29 16:36:58 -08:00
alex
b1f67fbca0 SmallerC: generate smaller & faster code; bugfixes
Improvements:
- use registers more efficiently
- eliminate some register copies and stack manipulations
- promote left operands to right immediate operands
- improve simple assignments to auto/static vars
- use bltz, blez, bgtz, bgez
- change mul/divu (by powers of 2) to sll/srl/and
- use seb, seh for sign extension instead of sll/sra
- overall generate a bit tighter, faster and more readable asm code

Fixes:
- >>= should be unsigned when the left operand is unsigned int.
The right operand isn't important here.
- very subtle bug in e.g. void f(){int a; &a+1;/*wrong value of &a+1*/}

Other:
- include stdarg.c and skeleton.c in /share/example/Makefile
2014-12-29 16:28:56 -08:00
Serge Vakulenko
f76ab8417c Merge pull request #39 from alexfru/master
Smaller C: Fix >>=
2014-12-13 01:19:36 -08:00
Alexey Frunze
3bb914c8b4 Fix >>=
>>= should be unsigned when the left operand is unsigned int. The right
operand isn't important here.
2014-12-13 01:06:53 -08:00
Serge Vakulenko
8b099bcf76 Merge pull request #38 from alexfru/master
Correct sd card image name.
2014-12-07 21:58:35 -08:00
Alexey Frunze
2fc41d34cf Correct sd card image name. 2014-12-07 21:51:06 -08:00
Serge Vakulenko
2301571ecb Merge pull request #37 from alexfru/master
Smaller C fixes and improvements.
2014-12-06 16:38:56 -08:00
alex
00269e9387 Smaller C fixes and improvements:
- move va_list type detection under #ifdef as it's rarely needed anyway
- allow up to 254 characters in a string literal
- generate a warning when an integer is passed instead of a pointer (and
vice versa) as a function parameter (pass -Wall for this)
- when printing an unexpected token, print identifier tokens instead of
'<tokIdent>'
- fix: allow most control characters inside '' and ""
- fix handling of -I<path> and -SI<path>
- switch() now supports Duff's device
- for() now supports declarations in its first clause as in C99/C++
2014-12-06 16:18:17 -08:00
Serge Vakulenko
687695d0db Fixed missing .profile at top level. 2014-10-23 19:08:11 -07:00
Serge Vakulenko
0aa5e1c462 README updated. 2014-10-21 11:28:22 -07:00
Serge Vakulenko
3a7cde7974 Merge pull request #36 from alexfru/master
Smaller C: Fix MIPS code generation for -= and postfix --. Also convert most of Small C sample programs to Smaller C.
2014-10-21 00:16:19 -07:00
alex
f57cc446b0 Remove no longer applicable comment. 2014-10-19 00:53:29 -07:00
alex
1a55933faf Merge branch 'master' of https://github.com/alexfru/retrobsd 2014-10-19 00:25:23 -07:00
alex
b18ce0aa87 Fix MIPS code generation for -= and postfix --.
Also convert most of Small C sample programs to Smaller C.
2014-10-19 00:22:44 -07:00
alex
5bbf8d4e73 Fix MIPS code generation for -= and postfix --.
Convert most of Small C sample programs to Smaller C.
2014-10-19 00:13:00 -07:00
Sergey
7aa774702b Fubarino configuration modified to use Arduino-compatible bootloader. 2014-10-04 14:30:21 -07:00
Sergey
64430a0f91 Added comfiguration for Majenko SDXL board.
DIP and Pinguino-micro boards removed - nobody uses these.
Deleted unused linker scripts.
2014-10-04 13:57:03 -07:00
Serge Vakulenko
d5e30d7b79 Fixed help message for fsutil. 2014-09-26 21:05:27 -07:00
Serge Vakulenko
a8d9b3d01f Makefiles updated for man sources. 2014-09-25 19:31:55 -07:00
Serge Vakulenko
ebd35d772f Fixed bug in 'make installfs'. 2014-09-25 18:09:06 -07:00
Serge Vakulenko
c4da2137e1 Added man sources from 2.11bsd tape. 2014-09-25 17:14:51 -07:00
Serge Vakulenko
c42133cdff Fixed newlines in crib game. 2014-09-25 13:44:51 -07:00
Sergey
dc66e6fdda Fsutil enhanced to create and handle partitions. 2014-09-20 18:54:13 -07:00
Serge Vakulenko
f58c7a7426 Added missing files for atc, boggle, btlgammon, cribbage. 2014-09-17 13:54:28 -07:00
Serge Vakulenko
5c4309942a Merge branch 'games'. 2014-09-17 13:21:59 -07:00
Serge Vakulenko
e557c88b1e Added manual for atc game.
Cribbage manuals installed.
2014-09-17 13:00:06 -07:00
Serge Vakulenko
850797db2e Fixed snake game.
Fixed newline bug in libcurses.

File /etc/termcap replaced by small version. Five TERM types supported:
ansi - simple generic display;
xterm - common for most modern terminal emulators;
linux - for Linux console;
cons25 - for BSD console;
vt100 - for DEC VT100 terminal emulators.

Terminal type xterm set by default.
2014-09-15 20:40:04 -07:00
Serge Vakulenko
cae7db41ca Snake fixed. 2014-09-15 14:24:17 -07:00
Serge Vakulenko
808dfaf6ef Ported snake game. 2014-09-15 12:28:43 -07:00
Sergey
d3d48970e3 Some progress with snake game. 2014-09-14 23:19:06 -07:00
Sergey
93d95abc69 Fixed warning in fsutil. 2014-09-13 15:17:30 -07:00
Serge Vakulenko
c5ac22d17f Ported robots game. 2014-09-12 13:32:16 -07:00
Serge Vakulenko
e7b77dadc3 Ported quiz game. 2014-09-12 12:03:11 -07:00
Serge Vakulenko
2ea9e02ba5 Monop game done. 2014-09-10 20:48:05 -07:00
Serge Vakulenko
d9d91365c0 Fixed warning in mille. 2014-09-10 20:09:59 -07:00
Serge Vakulenko
2da083e9bd Some progress on 'monop' game. 2014-09-08 21:36:15 -07:00
Serge Vakulenko
e4e9ff1ef4 Ported mille game. 2014-09-08 19:19:18 -07:00
Serge Vakulenko
aecac2f5d7 Ported hangman. 2014-09-08 18:07:59 -07:00
Serge Vakulenko
8886a00340 Ported fortune. 2014-09-08 12:30:17 -07:00
Serge Vakulenko
25bcc79a69 Merge branch 'master' into games.
Conflicts:
	Makefile
2014-09-08 11:31:12 -07:00
Serge Vakulenko
8d55f87ab8 Fsutil: dynamically allocate data structure for file i/o. 2014-09-04 19:29:18 -07:00
Matt Jenkins
9adca14b87 Added hx8357 TFT driver for PICadillo 2014-08-30 21:17:16 +01:00
Matt Jenkins
83a999be0a Added definitions for picadillo, and spi sram device 2014-08-27 23:13:26 +01:00
Sergey
1462eeb400 Using manifest files to create root and user filesystems. 2014-08-03 15:53:53 -07:00
Serge Vakulenko
d42bfdc7b9 Fsutil: can read manifest files.
Added a manifest for root filesystem.
2014-08-01 21:23:38 -07:00
Serge Vakulenko
1cdf42ef94 Fsutil: inode API simplified. 2014-08-01 18:17:38 -07:00
Serge Vakulenko
8f4aad27f9 Fsutil: able to create filesystem contents from manifest. 2014-08-01 17:49:59 -07:00
Serge Vakulenko
cb4ca7f73a Fsutuil: move manifest routines to a separate file. 2014-08-01 14:29:22 -07:00
Serge Vakulenko
b44cab756f Fsutil: new option --scan to create manifest from directory contents. 2014-07-31 20:55:42 -07:00
Serge Vakulenko
c2b3647d5e Fsutil: sources reformatted to 4-space indents. 2014-07-31 18:37:15 -07:00
Serge Vakulenko
4d8233582a Fsutil: added --manifest option. 2014-07-31 18:16:39 -07:00
Serge Vakulenko
eb1fb36b6b Fsutil library: use names for inode ops. 2014-07-31 17:46:24 -07:00
Sergey
2293493bfd Fixed bugs in fsutil. 2014-07-20 17:23:57 -07:00
Sergey
61ce169328 Fsutil mount complete. 2014-07-20 16:57:36 -07:00
Sergey
173efb822d Fsutil mount: symlink() and readlink() calls completed. 2014-07-19 15:06:55 -07:00
Serge Vakulenko
21babaf947 Fsutil mount: added rename and mknod calls. 2014-07-18 19:07:51 -07:00
Serge Vakulenko
3a789348da Fsutol mount: fixed rmdir call. 2014-07-18 17:41:08 -07:00
Serge Vakulenko
d6e558bea0 Fsutil mount: added truncate, mkdir, rmdir, link and unlink calls. 2014-07-18 00:13:27 -07:00
Serge Vakulenko
847e2bff77 Fsutil: allow truncate to arbitrary length. 2014-07-17 21:31:49 -07:00
Serge Vakulenko
08c79d7fec Fsutil --mount can read and write files. 2014-07-17 20:16:25 -07:00
Serge Vakulenko
0cef044377 Fsutil: added option -m to mount the filesystem via FUSE. 2014-07-16 20:31:03 -07:00
Serge Vakulenko
61c7c690b9 Merge pull request #33 from ibara/master
Emg updated to version 1.7.
2014-07-11 12:17:26 -07:00
Brian Callahan
294ccae3be emg 1.7 2014-07-10 18:11:43 -04:00
Serge Vakulenko
1c4e562363 Added kernel configuration for PICadillo-35T board. 2014-06-23 22:15:51 -07:00
Serge Vakulenko
09b50bf614 Merge pull request #31 from ibara/master
Update emg man page.
2014-06-18 10:59:57 -07:00
Serge Vakulenko
8439672624 Merge pull request #32 from jturner/fix-build
Fix build after aout reorganization.
2014-06-18 10:58:32 -07:00
James Turner
b6e105c87b Fix build after aout reorganization 2014-06-18 13:45:24 -04:00
Brian Callahan
70b8d93b21 Update emg man page. 2014-06-17 08:43:13 -04:00
Serge Vakulenko
5fa78e772b Moved aout sources to separate directory.
Fsutil and modff license changed to BSD style.
2014-06-04 11:46:33 -07:00
Serge Vakulenko
7b1bf93d3a Merge pull request #30 from ibara/master
Changes for emg 1.6 merged.
2014-05-30 21:01:53 -07:00
Brian Callahan
04208ea903 Remove unusued variable... put this down and walk away until tomorrow. 2014-05-29 18:20:55 -04:00
Brian Callahan
e003436e91 Dumbest off-by-one ever... 2014-05-29 18:16:24 -04:00
Brian Callahan
29904aacd7 I should trust my instincts. I had this right the first time. 2014-05-29 18:03:39 -04:00
Brian Callahan
dbe51ae294 This is cleaner, prevent the percent from being greater than 100. 2014-05-29 15:06:16 -04:00
Brian Callahan
87489937bf Add PgUp and PgDn scrolling to emg, release this as emg 1.6
Make sure emg.keys is installed.
2014-05-29 14:31:58 -04:00
Brian Callahan
bbba8d6f95 Remove all hardcoded make commands, changing them to ${MAKE}.
This is a first step towards being able to build RetroBSD on *BSD.
2014-05-25 16:25:15 -04:00
Sergey
b3abe580bd Added emg editor from github.com/ibara/emg. 2014-05-24 19:37:02 -07:00
Serge Vakulenko
66ffc30ccd Kernel makefiles updated. 2014-05-23 11:33:58 -07:00
Serge Vakulenko
0b31486402 Added loadmax target to kernel Makefile.
Use "make loadmax" in sys/pic32/max32 directory to upload the kernel image
to chipKIT Max32 board.
2014-05-21 12:26:24 -07:00
Serge Vakulenko
5bd8f3a470 Fixed sd timeout in the simulator.
SD driver reformatted with 4 spaces per tab.
2014-05-16 20:44:53 -07:00
Serge Vakulenko
fa46b819f0 Merge branch 'master' of https://github.com/RetroBSD/retrobsd 2014-05-16 18:01:00 -07:00
Serge Vakulenko
91468f005f Fixed build and simulator configuration for Explorer1 board. 2014-05-16 17:59:53 -07:00
Serge Vakulenko
e2cb851fbf Merge pull request #28 from alexfru/master
Update cpp to pcc 1.0.0's cpp
2014-05-14 22:39:59 -07:00
Alexey Frunze
e725ab2b44 Update cpp to pcc 1.0.0's cpp
Update the preprocessor to fix some of its bugs.
2014-05-14 02:49:38 -07:00
Sergey
8423492f33 More games ported: boggle, btlgammon, cribbage.
Simulator modified to allow CR in UART output.
2014-05-09 23:39:23 -07:00
Sergey
8e8fc70ed5 Merge branch 'games' of https://github.com/RetroBSD/retrobsd into games 2014-05-09 21:01:09 -07:00
Sergey
d8305bc374 Added words file - needed for games. 2014-05-09 21:00:43 -07:00
Serge Vakulenko
3942e87cd1 Compiled atc game. Fixed include file for curses library. 2014-04-23 20:02:02 -07:00
1359 changed files with 50066 additions and 128248 deletions

27
LICENSE
View File

@@ -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.

224
Makefile
View File

@@ -11,33 +11,24 @@
#
# Supported boards
#
MAX32 = sys/pic32/max32/MAX32
MAX32-ETH = sys/pic32/max32-eth/MAX32-ETH
UBW32 = sys/pic32/ubw32/UBW32
UBW32UART = sys/pic32/ubw32-uart/UBW32-UART
UBW32UARTSDRAM = sys/pic32/ubw32-uart-sdram/UBW32-UART-SDRAM
MAXIMITE = sys/pic32/maximite/MAXIMITE
MAXCOLOR = sys/pic32/maximite-color/MAXCOLOR
EXPLORER16 = sys/pic32/explorer16/EXPLORER16
STARTERKIT = sys/pic32/starter-kit/STARTER-KIT
DUINOMITE = sys/pic32/duinomite/DUINOMITE
DUINOMITEUART = sys/pic32/duinomite-uart/DUINOMITE-UART
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
MAX32 = pic32/max32
UBW32 = pic32/ubw32
UBW32UART = pic32/ubw32-uart
UBW32UARTSDRSW = pic32/ubw32-uart-sdramswap
MAXIMITE = pic32/maximite
EXPLORER16 = pic32/explorer16
STARTERKIT = pic32/starter-kit
DUINOMITE = pic32/duinomite
PINGUINO = pic32/pinguino-micro
DIP = pic32/dip
BAREMETAL = pic32/baremetal
RETROONE = pic32/retroone
# Select target board
TARGET ?= $(MAX32)
TARGET ?= $(UBW32UARTSDRSW)
# Filesystem and swap sizes.
FS_KBYTES = 102400
U_KBYTES = 102400
FS_KBYTES = 16384
SWAP_KBYTES = 2048
# Set this to the device name for your SD card. With this
@@ -54,153 +45,136 @@ DEFS =
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.
#
BIN_FILES := $(wildcard bin/*)
SBIN_FILES := $(wildcard sbin/*)
GAMES_FILES := $(shell find games -type f ! -path '*/.*')
LIB_FILES := $(wildcard lib/*)
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/passwd etc/shadow etc/fstab etc/motd etc/shells \
etc/termcap etc/MAKEDEV etc/phones etc/remote
INC_FILES = $(wildcard include/*.h) \
$(wildcard include/sys/*.h) \
$(wildcard include/machine/*.h) \
$(wildcard include/smallc/*.h) \
$(wildcard include/smallc/sys/*.h) \
$(wildcard include/arpa/*.h)
etc/termcap
INC_FILES = include/stdio.h include/syscall.h include/sys/types.h \
include/sys/select.h
SHARE_FILES = share/re.help share/example/Makefile \
share/example/ashello.S share/example/chello.c \
share/example/blkjack.bas share/example/hilow.bas \
share/example/stars.bas share/example/prime.scm \
share/example/fact.fth share/example/echo.S \
share/example/stdarg.c share/example/skeleton.c \
$(wildcard share/smallc/*)
MANFILES = share/man/ share/man/cat1/ share/man/cat2/ share/man/cat3/ \
share/man/cat4/ share/man/cat5/ share/man/cat6/ share/man/cat7/ \
share/man/cat8/ $(wildcard share/man/cat?/*)
share/example/fact.fth share/example/echo.S
ALLFILES = $(SBIN_FILES) $(ETC_FILES) $(BIN_FILES) $(LIB_FILES) $(LIBEXEC_FILES) \
$(INC_FILES) $(SHARE_FILES) $(GAMES_FILES) \
var/log/messages var/log/wtmp .profile
ALLDIRS = games/ sbin/ bin/ dev/ etc/ tmp/ lib/ libexec/ share/ include/ \
var/ u/ share/example/ share/misc/ share/smallc/ \
var/run/ var/log/ var/lock/ games/ games/lib/ include/sys/ \
include/machine/ include/arpa/ include/smallc/ \
include/smallc/sys/ share/misc/ share/smallc/ include/sys/ \
games/lib/
BDEVS = dev/rd0!b0:0 dev/rd0a!b0:1 dev/rd0b!b0:2 dev/rd0c!b0:3 dev/rd0d!b0:4
BDEVS += dev/rd1!b1:0 dev/rd1a!b1:1 dev/rd1b!b1:2 dev/rd1c!b1:3 dev/rd1d!b1:4
BDEVS += dev/rd2!b2:0 dev/rd2a!b2:1 dev/rd2b!b2:2 dev/rd2c!b2:3 dev/rd2d!b2:4
BDEVS += dev/rd3!b3:0 dev/rd3a!b3:1 dev/rd3b!b3:2 dev/rd3c!b3:3 dev/rd3d!b3:4
BDEVS += dev/swap!b4:64 dev/swap0!b4:0 dev/swap1!b4:1 dev/swap2!b4:2
ALLDIRS = sbin/ bin/ dev/ etc/ tmp/ lib/ libexec/ share/ share/example/ \
share/misc/ var/ var/run/ var/log/ u/ include/ include/sys/ \
games/ games/lib/
BDEVS = dev/sd0!b0:0 dev/sd1!b0:1 dev/sw0!b1:0
CDEVS = dev/console!c0:0 \
dev/mem!c1:0 dev/kmem!c1:1 dev/null!c1:2 dev/zero!c1:3 \
dev/tty!c2:0 \
dev/rsd0!c3:0 dev/rsd1!c3:1 dev/swap!c3:0 \
dev/klog!c4:0 \
dev/stdin!c5:0 dev/stdout!c5:1 dev/stderr!c5: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
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
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
all: build kernel
$(MAKE) fs
fs: sdcard.rd
fs: filesys.img user.img
.PHONY: tools
tools:
kernel:
$(MAKE) -C sys/$(TARGET)
build:
$(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
filesys.img: $(FSUTIL) $(ALLFILES)
rm -f $@
$(FSUTIL) -n$(FS_KBYTES) $@
$(FSUTIL) -a $@ $(ALLDIRS)
$(FSUTIL) -n$(FS_KBYTES) -s$(SWAP_KBYTES) $@
$(FSUTIL) -a $@ $(ALLDIRS) $(ALLFILES)
$(FSUTIL) -a $@ $(CDEVS)
$(FSUTIL) -a $@ $(BDEVS)
$(FSUTIL) -a $@ $(ALLFILES)
$(FSUTIL) -a $@ $(MANFILES)
swap.img:
dd if=/dev/zero of=$@ bs=1k count=$(SWAP_KBYTES)
$(FSUTIL) -a $@ $(ADCDEVS)
$(FSUTIL) -a $@ $(OCDEVS)
# $(FSUTIL) -a $@ $(FDDEVS)
user.img: $(FSUTIL)
ifneq ($(U_KBYTES), 0)
rm -f $@
$(FSUTIL) -n$(U_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) -n$(FS_KBYTES) $@
$(FSUTIL):
cd tools/fsutil; $(MAKE)
$(CONFIG):
make -C tools/configsys
clean:
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
$(MAKE) -C lib clean
rm -f sys/pic32/*/unix.hex bin/* sbin/* games/[a-k]* games/[m-z]* libexec/* share/man/cat*/*
rm -f sys/pic32/*/unix.hex bin/* sbin/* lib/* games/[a-k]* games/[m-z]* libexec/* share/man/cat*/*
rm -f games/lib/adventure.dat
rm -f games/lib/cfscores
rm -f share/re.help
rm -f share/misc/more.help
rm -f etc/termcap etc/remote etc/phones
rm -rf share/unixbench
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
rm -rf var/lock
rm -f etc/termcap
# TODO
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
ifdef SDCARD
sudo dd bs=32k if=sdcard.rd of=$(SDCARD)
sudo dd bs=16k if=filesys.img of=$(SDCARD)
else
@echo "Error: No SDCARD defined."
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
View 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
View File

@@ -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
View File

@@ -1 +0,0 @@
*

View File

@@ -18,14 +18,6 @@ TAGSFILE = tags
MANROFF = nroff -man -h
ELF2AOUT = cp
CFLAGS = -O -DCROSS
CFLAGS = -O -DCROSS -I/usr/include -I$(TOPSRC)/include
LDFLAGS =
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
View File

@@ -1,3 +0,0 @@
phones
remote
termcap

View File

@@ -52,13 +52,16 @@ do
case $i in
std)
mknod console c 0 0
mknod mem c 1 0 ; chmod 640 mem ; chgrp kmem mem
mknod console c 0 0
# mknod kUmem c 1 3 ; chmod 600 kUmem ;: untested
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 zero c 1 3 ; chmod 444 zero
mknod tty c 2 0 ; chmod 666 tty
mknod klog c 3 0 ; chmod 600 klog
mknod tty c 9 0 ; chmod 666 tty
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)
@@ -67,105 +70,304 @@ fd)
rm -f stdin stdout stderr
mkdir fd
chmod 755 fd
mknod stdin c 4 0
mknod stdout c 4 1
mknod stderr c 4 2
mknod stdin c 26 0
mknod stdout c 26 1
mknod stderr c 26 2
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
rm -f rd[0123] rd[0123][abcd]
mknod rd0 b 0 0
mknod rd0a b 0 1
mknod rd0b b 0 2
mknod rd0c b 0 2
mknod rd0d b 0 2
mknod rd1 b 1 0
mknod rd1a b 1 1
mknod rd1b b 1 2
mknod rd1c b 1 2
mknod rd1d b 1 2
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]
name=rx; blk=8; chr=17
mknod ${name}0a b ${blk} 0
mknod ${name}1a b ${blk} 1
mknod ${name}0b b ${blk} 2
mknod ${name}1b b ${blk} 3
mknod r${name}0a c ${chr} 0
mknod r${name}1a c ${chr} 1
mknod r${name}0b c ${chr} 2
mknod r${name}1b c ${chr} 3
chgrp operator ${name}[01][ab] r${name}[01][ab]
chmod 640 ${name}[01][ab] r${name}[01][ab]
;;
gpio)
umask 0
rm -f port[abcdefg] conf[abcdef]
mknod porta c 5 0
mknod portb c 5 1
mknod portc c 5 2
mknod portd c 5 3
mknod porte c 5 4
mknod portf c 5 5
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
ram*)
# Note, this must come *before* the "ra*". The entry "rram" is for
# auto fscks when ram is mentioned in /etc/fstab.
umask 2
mknod ram b 3 0
ln ram rram
chgrp operator ram
chmod 640 ram
umask 77
;;
adc)
umask 0
rm -f adc[0123456789] adc1[012345]
mknod adc0 c 6 0
mknod adc1 c 6 1
mknod adc2 c 6 2
mknod adc3 c 6 3
mknod adc4 c 6 4
mknod adc5 c 6 5
mknod adc6 c 6 6
mknod adc7 c 6 7
mknod adc8 c 6 8
mknod adc9 c 6 9
mknod adc10 c 6 10
mknod adc11 c 6 11
mknod adc12 c 6 12
mknod adc13 c 6 13
mknod adc14 c 6 14
mknod adc15 c 6 15
br*|hk*|ra*|si*|xp*|rl*)
umask 2 ; unit=`expr $i : '..\(.*\)'`
case $i in
br*) name=rp; blk=11; chr=20;;
hk*) name=hk; blk=4; chr=13;;
ra*) name=ra; blk=5; chr=14;;
si*) name=si; blk=9; chr=18;;
xp*) name=xp; blk=10; chr=19;;
rl*) name=rl; blk=7; chr=16;;
esac
case $unit in
0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\
17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)
mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1`
mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2`
mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4`
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)
umask 0
rm -f spi[1234]
mknod spi1 c 7 0
mknod spi2 c 7 1
mknod spi3 c 7 2
mknod spi4 c 7 3
dz*)
unit=`expr $i : 'dz\(.*\)'`
case $unit in
0|1|2|3|4|5|6|7)
eval `echo $unit | awk ' { u = $1 } END {
for (i = 0; i < 8; i++)
printf("mknod tty%02d c 2 %d; ",u*8+i,u*8+i); }'`
;;
*)
echo bad unit for dz in: $i
;;
esac
;;
glcd)
umask 0
rm -f glcd0
mknod glcd0 c 8 0
#
# we may want dmz and dmf someday...
# dhu*|dh*|dmf*|dmz*)
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)
umask 0
rm -f oc[12345]
mknod oc1 c 9 0
mknod oc2 c 9 1
mknod oc3 c 9 2
mknod oc4 c 9 3
mknod oc5 c 9 4
# extra DL-11 units not including the console. unit numbers start at 1 because
# the console is always unit 0. Seven units (1 - 7) are defined for the 11/93
# and 11/94. Device name is "ttyl?". The DH range was restricted from 'h'-'o'
# to 'h' - 'k' (very unlikely that more than 64 channels of DH-11 will or could
# be put on an 11.
dl*)
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)

View File

@@ -1,2 +1,2 @@
/dev/rd0a / ufs rw,async 1 1
#/dev/rd0c /u ufs rw,async 1 2
/dev/sd0 / ufs rw,async 1 1
#/dev/sd1 /u ufs rw,async 1 2

View File

@@ -80,8 +80,6 @@ v|std.3500000|3500000-baud:\
:sp#3500000:
w|std.4000000|4000000-baud:\
:sp#4000000:
x|std.default|default-baud:\
:sp#0:
#

3
etc/rc
View File

@@ -3,8 +3,6 @@ HOME=/; export HOME
PATH=/bin:/sbin; export PATH
exec >/dev/console 2>&1
/sbin/devupdate
if test "$1" != "autoboot"; then
#
# Switch from single-user to multi-user mode.
@@ -66,7 +64,6 @@ rm -f /etc/nologin
echo -n "Starting daemons:"
update && echo -n "update"
cron && echo -n "cron"
echo
#/etc/rc.local

View File

@@ -1,16 +1,4 @@
#
# name getty type status comments
#
console "/libexec/getty std.default" 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
console "/libexec/getty std.115200" vt100 on secure #special

1
games/.gitignore vendored
View File

@@ -1 +0,0 @@
*

View File

Binary file not shown.

View File

@@ -33,36 +33,48 @@
#ifndef _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_
#include <nlist.h>
/* Relocations */
struct reloc {
unsigned flags;
#define RSMASK 0x70 /* bitmask for segments */
#define RABS 0
#define RTEXT 0x20
#define RDATA 0x30
#define RBSS 0x40
#define RSTRNG 0x60 /* for assembler */
#define REXT 0x70 /* externals and bitmask */
#define RGPREL 0x08 /* gp relative */
#define RABS 0
#define RTEXT 0x20
#define RDATA 0x30
#define RBSS 0x40
#define RSTRNG 0x60 /* for assembler */
#define REXT 0x70 /* externals and bitmask */
#define RFMASK 0x07 /* bitmask for format */
#define RBYTE16 0x00 /* low part of byte address: bits 15:0 */
#define RBYTE32 0x01 /* 32-bit byte address */
#define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */
#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 */
#define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */
#define RWORD16 0x03 /* word address: bits 17:2 */
#define RWORD26 0x04 /* word address: bits 27:2 */
unsigned index; /* 24-bit index in symbol table,
* for REXT */
unsigned offset; /* 16-bit offset,
* for RIGH16 and RIGH16S */
};
#define RINDEX(h) ((h) >> 8)
#define RSETINDEX(h) ((h) << 8)
#endif /* !_AOUT_H_ */

View File

@@ -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

View File

@@ -9,7 +9,7 @@
#include <sgtty.h>
#include <term.h>
#define bool int
#define bool char
#define reg register
#define TRUE (1)
@@ -149,7 +149,7 @@ int __void__;
#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 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 erasechar() (_tty.sg_erase)
@@ -167,20 +167,11 @@ int wgetch (WINDOW *);
char *wstandout (WINDOW *);
char *wstandend (WINDOW *);
int touchwin (WINDOW *);
int touchline (WINDOW *, int, int, int);
void box (WINDOW *, char, char);
int touchline (WINDOW *, int, int);
int box (WINDOW *, char, char);
void endwin (void);
int printw (char *, ...);
int wprintw (WINDOW *, char *, ...);
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);
int printw (char *fmt, ...);
int wprintw (WINDOW *win, char *fmt, ...);
/*
* Used to be in unctrl.h.

View File

@@ -7,9 +7,4 @@ struct group { /* see getgrent(3) */
char **gr_mem;
};
struct group *getgrent(void);
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);
struct group *getgrent(), *getgrgid(), *getgrnam();

View File

@@ -1,6 +0,0 @@
#ifndef _KMEM_H
#define _KMEM_H
extern dev_t kmemdev();
#endif

View File

@@ -35,7 +35,8 @@
#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 {
char *n_name; /* In memory address of symbol name,
@@ -55,12 +56,13 @@ struct nlist {
#define N_BSS 0x04 /* bss segment */
#define N_STRNG 0x05 /* string 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_TYPE 0x1f /* mask for all the type bits */
#define N_EXT 0x20 /* external (global) bit, OR'ed in */
#define N_WEAK 0x40 /* weak reference bit, OR'ed in */
#define N_LOC 0x80 /* local, for assembler */
#define N_TYPE 0x1f /* mask for all the type bits */
#define N_FORMAT "%06o" /* namelist value format; XXX */
/*
* Get symbols from a file.

View File

@@ -39,7 +39,7 @@
struct ranlib {
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 */
};

View File

@@ -14,29 +14,9 @@
* 9 - $ra - return address
* 10 - $gp - global data pointer
* 11 - $sp - stack pointer
* 12 - signal mask saved
* 13 - signal mask
*/
typedef int jmp_buf [14];
typedef jmp_buf sigjmp_buf;
typedef int jmp_buf [12];
/*
* 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);
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

View File

@@ -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

View File

@@ -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 */

View 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&LTOSTOP) */
#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 */

View File

@@ -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

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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;

View File

@@ -4,49 +4,27 @@
#ifndef _STDARG_H
#define _STDARG_H
/*
* 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))
/* Define __gnuc_va_list. */
#elif defined(__PCC__) /* PCC */
# define va_start(ap, last) __builtin_stdarg_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))
#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))
#ifndef __GNUC_VA_LIST
#define __GNUC_VA_LIST
typedef __builtin_va_list __gnuc_va_list;
#endif
/*
* Define va_list.
*/
#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
#ifdef __GNUC__
# define va_start(ap, last) __builtin_va_start((ap), last)
#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.
*/
#if defined(__GNUC__) && !defined(__GNUC_VA_LIST)
# define __GNUC_VA_LIST
typedef __builtin_va_list __gnuc_va_list;
#ifndef _VA_LIST
#define _VA_LIST
typedef __gnuc_va_list va_list;
#endif
#endif /* not _STDARG_H */

View File

@@ -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

View File

@@ -14,7 +14,7 @@ extern struct _iobuf {
char *_base; /* ditto */
int _bufsiz;
short _flag;
short _file;
char _file; /* should be short */
} _iob[];
#define _IOREAD 01
@@ -73,7 +73,6 @@ FILE *fopen (const char *, const char *);
FILE *fdopen (int, const char *);
FILE *freopen (const char *, const char *, FILE *);
FILE *popen (const char *, const char *);
FILE *tmpfile (void);
int fclose (FILE *);
long ftell (FILE *);
int fflush (FILE *);
@@ -94,8 +93,6 @@ int setvbuf (FILE *, char *, int, size_t);
int fseek (FILE *, long, int);
void rewind (FILE *);
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 fwrite (const void *, size_t, size_t, FILE *);
@@ -110,12 +107,7 @@ int scanf (const char *, ...);
int sscanf (const char *, const char *, ...);
#ifndef _VA_LIST_
# ifdef __GNUC__
# define va_list __builtin_va_list /* For Gnu C */
# endif
# ifdef __SMALLER_C__
# define va_list char * /* For Smaller C */
# endif
#define va_list __builtin_va_list /* For GCC */
#endif
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);
#ifndef _VA_LIST_
# undef va_list
#undef va_list
#endif
void perror (const char *);

View File

@@ -54,51 +54,48 @@
#define RAND_MAX 0x7fff
void abort (void);
void abort();
int abs (int);
int atexit (void (*)(void));
int atoi (const char *);
long atol (const char *);
double atof();
int atoi();
long atol();
void *calloc (size_t, size_t);
void exit (int);
void free (void *);
char *getenv (const char *);
long labs (long);
char *getenv();
void *malloc (size_t);
char *mktemp (char *);
int mkstemp (char *);
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
int rand (void);
void qsort();
int rand();
void *realloc (void*, size_t);
void srand (unsigned);
long strtol (const char *, char **, int);
unsigned long strtoul (const char *, char **, int);
int system (const char *);
void srand();
double strtod();
long strtol();
unsigned long strtoul();
int system();
int putenv (char *string);
int setenv (const char *name, const char *value, int overwrite);
int unsetenv (const char *name);
char *_findenv (const char *name, int *offset);
void *alloca (size_t size);
void *alloca();
int daemon (int, int);
char *devname (dev_t dev, mode_t type);
int getloadavg (unsigned loadavg[], int nelem);
int daemon();
char *devname();
int getloadavg(unsigned loadavg[], int nelem);
extern char *suboptarg; /* getsubopt(3) external variable */
int getsubopt (char **, char **, char **);
int getsubopt();
long random (void);
char *setstate (char *);
void srandom (unsigned);
#ifndef __SMALLER_C__
double atof (const char *);
double strtod (const char *, char **);
char *ecvt (double, int, int *, int *);
char *fcvt (double, int, int *, int *);
char *gcvt (double, int, char *);
#endif
char *ecvt (double, int, int *, int *);
char *fcvt (double, int, int *, int *);
char *gcvt (double, int, char *);
#endif /* _STDLIB_H_ */

View File

@@ -39,5 +39,5 @@ char *strtok_r (char *, const char *, char **);
size_t strcspn (const char *, const char *);
size_t strspn (const char *, const char *);
char *strerror (int);
const char *strerror (int);
const char *syserrlst (int);

View File

@@ -34,7 +34,7 @@
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t);
void bzero(void *, unsigned long);
void bzero(void *, size_t);
int ffs(int);
char *index(const char *, int);
char *rindex(const char *, int);

View File

@@ -59,7 +59,7 @@
#define SYS_getegid 48
#define SYS_setgid 49
#define SYS_setegid 50
#define SYS_kmemdev 51
/* 51 is old; acct */
#define SYS_phys 52
#define SYS_lock 53
#define SYS_ioctl 54
@@ -81,7 +81,7 @@
#define SYS_rdglob 70
#define SYS_wrglob 71
/* 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 */
/* 74 is unused 4.3: mprotect */
/* 75 is unused 4.3: madvise */

View File

@@ -2,9 +2,13 @@
#define _TERM_H
extern int tgetent(char *, char *);
extern int tnchktc();
extern int tnamatch(char *);
extern char *tskip(register char *);
extern int tgetnum(char *);
extern int tgetflag(char *);
extern char *tgetstr(char *, char **);
extern char *tdecode(register char *, char **);
extern char *tgoto(char *, int, int);
extern int tputs(register char *, int, int (*)());

View File

@@ -18,5 +18,5 @@ struct ttyent { /* see getttyent(3) */
struct ttyent *getttyent (void);
struct ttyent *getttynam (const char *name);
void setttyent (void);
void endttyent (void);
int setttyent (void);
int endttyent (void);

View File

@@ -97,4 +97,4 @@ struct tzhead {
** 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)

View File

@@ -94,7 +94,6 @@ void setusershell();
void sync();
unsigned int ualarm();
void usleep();
int pause (void);
pid_t vfork();
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 setuid (uid_t uid);
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 chdir (const char *path);
int fchdir (int fd);
int chflags (const char *path, 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;
int stat (const char *path, struct stat *buf);
@@ -143,12 +135,7 @@ extern char *optarg; /* getopt(3) external variables */
extern int opterr, optind, optopt;
#ifndef _VA_LIST_
# ifdef __GNUC__
# define va_list __builtin_va_list /* For Gnu C */
# endif
# ifdef __SMALLER_C__
# define va_list char * /* For Smaller C */
# endif
#define va_list __builtin_va_list /* For GCC */
#endif
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);
#ifndef _VA_LIST_
# undef va_list
#undef va_list
#endif
#endif /* !_UNISTD_H_ */

View File

@@ -3,7 +3,7 @@
#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)

View File

@@ -62,13 +62,13 @@ void udp_stop (udp_t *u);
/*
* 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);
/*
* 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);
/*

14
lib/.gitignore vendored
View File

@@ -1,14 +0,0 @@
a.out.h
aout
ar
ar.h
as
ld
nlist.h
nm
ranlib
ranlib.h
retroImage
size
strip
gccdump.s

View File

@@ -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 .

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
View File

@@ -1 +0,0 @@
*

1
sbin/.gitignore vendored
View File

@@ -1 +0,0 @@
*

755
sdram-fpga.S Normal file
View File

@@ -0,0 +1,755 @@
/*
* SDRAM Access Routines for PIC32.
*
* Retromaster - 10.05.2010
*
* This file is in the public domain. You can use, modify, and distribute the source code
* and executable programs based on the source code. This file is provided "as is" and
* without any express or implied warranties whatsoever. Use at your own risk!
*
* Changes by jmcgee for inclusion in the retrobsd project.
*/
/* SDRAM Used: HY57V281620
* SDRAM Pin to PIC32 Pin Mapping:
* SDRAM PIC32
* ------ ------
* note: the order of An to RBn DOES matter
* At the moment it is a bit of a mess and
* needs to be cleaned up.
* A0 23 RB11
* A1 24 RB12
* A2 25 RB13
* A3 26 RB14
* A4 29 RB5
* A5 30 RB4
* A6 31 RB3
* A7 32 RB2
* A8 33 RB6
* A9 34 RB7
* A10 22 RB15
* A11 35 RB9
*
* BA0 20 RD4
* BA1 21 RD5
*
* note: the order of DQn to RAn does not matter
* DQ0 2 RA6
* DQ1 4 RA1
* DQ2 5 RA7
* DQ3 7 RA2
* DQ4 8 RA3
* DQ5 10 RA4
* DQ6 11 RA5
* DQ7 13 RA0
* CLK 38 OC1-RD0
* CKE 37 A10
* CS 19 RF12
* WE 16 RF0
* CAS 17 RF1
* RAS 18 RF13
*
* SDRam 42, 44, 45, 47, 48, 50, 51, 53 - (d8-d15) should be pulled up, but
* on the prototype board these were simply left floating
*
* Power connections not listed.
*/
/*
* Retrobsd does not currently contain a good header
* for pulling the pic32 port addresses into an assembly
* file, so define some needed registers here for the moment.
*/
#define TRISA 0xBF886000
#define T2CON 0xBF800800
#define TMR2 0xBF800810
#define PR2 0xBF800820
#define T2CONSET 0xBF800808
#define OC1CON 0xBF803000
#define OC4CON 0xBF803600
#define OCXR_OFFSET 0x10
#define OCXRS_OFFSET 0x20
#define AD1PCFGSET 0xBF809068
/* Offsets (from TRISA) for the io ports */
#define SDR_OFFSET_A 0
#define SDR_OFFSET_B 0x40
#define SDR_OFFSET_C 0x80
#define SDR_OFFSET_D 0xc0
#define SDR_OFFSET_E 0x100
#define SDR_OFFSET_F 0x140
#define SDR_OFFSET_G 0x180
/* Offsets (from TRISA) for the various port control registers */
#define TRIS_OFFSET 0x0
#define PORT_OFFSET 0x10
#define LAT_OFFSET 0x20
#define ODCF_OFFSET 0x30
/* Offsets (from TRISA) for the various io port bit manipulator registers */
#define NOP_OP_OFFSET 0x0
#define CLR_OP_OFFSET 0x4
#define SET_OP_OFFSET 0x8
#define INV_OP_OFFSET 0xc
/*
* Specific assignments of ports ports used
* Note: In general, it is not sufficient to
* change the constants below - corresponding
* changes to the code below will likely be
* required if any of the following values
* are changed.
*/
/* DATA_PORT_TRIS must be assigned to a TRIS of the port
* that has the low 8 bits tied the 8 data bits on the ram.
*/
#define SDR_OCR OC1CON
#define SDR_DATA_IO SDR_OFFSET_A
#define SDR_DATA_TRIS SDR_OFFSET_A
#define SDR_ADDRESS_IO SDR_OFFSET_B
#define SDR_ADDRESS_TRIS SDR_OFFSET_B
#define ADDRESS_MASK 0xfafc
#define SDR_BANK_IO SDR_OFFSET_D
#define SDR_BANK_TRIS SDR_OFFSET_D
#define BANK_0_BIT 4
#define BANK_1_BIT 5
#define SDR_CONTROL_IO SDR_OFFSET_F
#define SDR_CONTROL_TRIS SDR_OFFSET_F
#define CONTROL_WE_BIT 0
#define CONTROL_CAS_BIT 1
#define CONTROL_CS_BIT 12
#define CONTROL_RAS_BIT 13
#define SDR_CKE_IO SDR_OFFSET_A
#define SDR_CKE_TRIS SDR_OFFSET_A
#define CKE_BIT 10
#define DATA_DIR_BIT 15
#define CONTROL_ALL_MASK ( (1<<CONTROL_CS_BIT) | (1<<CONTROL_RAS_BIT) | (1<<CONTROL_CAS_BIT) | (1<<CONTROL_WE_BIT) )
#define BANK_ALL_MASK ( (1 << BANK_1_BIT) | ( 1 << BANK_0_BIT ) )
/* Global Symbols */
.globl sdram_init
.globl sdram_read
.globl sdram_write
.globl sdram_active
.globl sdram_auto_refresh
.globl sdram_precharge
.globl sdram_precharge_all
.globl sdram_sleep
.globl sdram_wake
.globl sdram_bank
.type sdram_init, @function
.type sdram_read, @function
.type sdram_write, @function
.type sdram_active, @function
.type sdram_auto_refresh, @function
.type sdram_precharge, @function
.type sdram_precharge_all, @function
.type sdram_sleep, @function
.type sdram_wake, @function
.type sdram_bank, @function
/*
* This code MUST execute from ram and the ram MUST be configured
* for zero wait states. Interrupts MUST disabled before
* calling any of these functions, and any DMA MUST also be
* disabled.
*
* Also, the peripheral bus divisor must be set to 1.
*/
.section .ramfunc,"ax",@progbits
/* No instruction reordering */
.set noreorder
#define clock4 \
nop;nop;nop;nop
#define clock3 \
nop;nop;nop
#define clock2 \
nop;nop
#define clock1 \
nop
/*
* The SDRAM clock is output from the output compare unit.
* This macro synchronizes with that clock so that we are
* sure to have at least two clock cycles to issue control
* line changes and access the data bus before the rising
* edge.
*/
#define sync_clock \
la $t8, TMR2; \
li $v0, 2; \
lw $v1, ($t8); \
bge $v1, $v0, 1f; \
nop; \
nop; \
nop; \
1: \
nop;
#define output_column \
and $t5, $a0, 0x1f; \
sll $t5, 2; \
and $t6, $a0, 0x20; \
sll $t6, 9; \
or $t5, $t6; \
lw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0); \
and $t6, ~ADDRESS_MASK; \
or $t6, $t5; \
sw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0);
#define output_address \
sll $t5, $a0, 2; \
and $t5, ADDRESS_MASK; \
and $t6, $a0, 0x40; \
sll $t6, 8; \
or $t5, $t6; \
and $t6, $a0, 0x100; \
sll $t6, 7; \
or $t5, $t6; \
lw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0); \
and $t6, ~ADDRESS_MASK; \
or $t6, $t5; \
sw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0);
/*.ent sdram_init*/
/*
* Initializes the SDRAM.
* Should be called once sometime after startup
* C Prototype:
* extern __attribute__((far)) void sdram_init();
*/
sdram_init:
/* Initialize address lines */
la $t0, TRISA /* base of io addresses */
li $t1, ADDRESS_MASK
sw $t1, SDR_ADDRESS_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
li $t1, 0xFFFF
sw $t1, AD1PCFGSET
li $t1, BANK_ALL_MASK
sw $t1, SDR_BANK_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
/* All address lines low */
li $t1, ADDRESS_MASK
sw $t1, SDR_ADDRESS_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
li $t1, BANK_ALL_MASK
sw $t1, SDR_BANK_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
/* Initialize data lines */
li $t1, 0xFF
sw $t1, SDR_DATA_IO + TRIS_OFFSET + SET_OP_OFFSET($t0)
/* Initialize SDRAM control lines */
li $t1, CONTROL_ALL_MASK
sw $t1, SDR_CONTROL_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
/* Command Inhibit */
li $t1, CONTROL_ALL_MASK
sw $t1, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
li $t1, (1<<DATA_DIR_BIT)
sw $t1, SDR_CKE_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
/* Initialize CKE line */
// li $t1, (1<<CKE_BIT)
li $t1, (1<<CKE_BIT)|(1<<DATA_DIR_BIT)
sw $t1, SDR_CKE_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
/* CKE low */
li $t1, (1<<CKE_BIT)
sw $t1, SDR_CKE_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
/* SDRAM clock output */
/* Initialize Timer2 */
sw $zero, T2CON
sw $zero, TMR2
li $t1, 3
sw $t1, PR2
li $t1, 0x8000
sw $t1, T2CONSET
/* Initialize OC device */
sw $zero, SDR_OCR /*OC4CON */
li $t1, 1
sw $t1, SDR_OCR + OCXRS_OFFSET /*OC4RS*/
li $t1, 3
sw $t1, SDR_OCR + OCXR_OFFSET /*OC4R*/
li $t1, 0x8005
sw $t1, SDR_OCR /*OC4CON*/
/* Clock output starts here */
/* SD-RAM initialization delay */
li $t2, 500
move $t1, $zero
sdram_init_delay_1:
addi $t1, $t1, 1
bne $t1, $t2, sdram_init_delay_1
nop
/* CKE high */
li $t1, (1<<CKE_BIT)
sw $t1, SDR_CKE_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
/* Delay some more */
li $t2, 3000
move $t1, $zero
sdram_init_delay_2:
addi $t1, $t1, 1
bne $t1, $t2, sdram_init_delay_2
nop
/* Get ready for the commands we are about to issue. */
li $t4, (1<<CONTROL_CAS_BIT)
li $t5, (1<<CONTROL_WE_BIT)
li $t6, 0x1810 /* Mode Register: CL:2, BL:8 (0x23) */
li $t7, CONTROL_ALL_MASK
li $t8, 0x8000 /* A10 */
sw $t8, SDR_ADDRESS_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* A10 = 1 for Precharge ALL */
sync_clock
.set nomacro
/* Precharge All */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* LLLL */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* LLHL */
clock2
/* Auto Refresh 1 */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* LLLL */
sw $t5, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* LLLH */
clock2
/* Auto Refresh 2 */
clock4
/* Auto Refresh 3 */
clock4
/* Auto Refresh 4 */
clock4
/* Auto Refresh 5 */
clock4
/* Auto Refresh 6 */
clock4
/* Auto Refresh 7 */
clock4
/* Auto Refresh 8 */
li $t4, ADDRESS_MASK
sw $t4, SDR_ADDRESS_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
clock2
/* Load Mode Register */
sw $t6, SDR_ADDRESS_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
clock2
/* Command Inhibit */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
clock3
/* Command Inhibit */
clock4
.set macro
jr $ra
nop
/*.end sdram_init*/
/*
* Sends ACTIVE command
* C Prototype:
* extern __attribute__((far)) void sdram_active(uint16_t rowaddr);
*/
sdram_active:
la $t0, TRISA /* Port Base */
li $t7, (1<<CONTROL_CS_BIT)|(1<<CONTROL_RAS_BIT)
/* Set row */
output_address
sync_clock
.set nomacro
/* Active */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
clock3
/* Command Inhibit */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
clock3
/* Command Inhibit */
clock4
.set macro
jr $ra
nop
/*
* Sends WRITE command
* C Prototype:
* extern __attribute__((far)) void sdram_write(uint16_t pseudocoladdr, uint64_t val);
* Each pseudo column contains 8 bytes of data (consists of 8 ram columns)
*/
sdram_write:
la $t0, TRISA /* Port Base */
li $t4, 0xFF
li $t7, (1<<CONTROL_CS_BIT) | (1<<CONTROL_CAS_BIT) | (1<<CONTROL_WE_BIT)
li $t3, (1<<DATA_DIR_BIT)
/* Set column */
output_column
/* Set data lines */
srl $t5, $a2, 24
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0)
sw $t3, SDR_CKE_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
sync_clock
.set nomacro
/* Write */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LHLL */
sw $t4, SDR_DATA_IO + TRIS_OFFSET + INV_OP_OFFSET($t0) /* 1 - enable data lines */
srl $t5, $a2, 16
clock1
/* Command Inhibit */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* HHHH */
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 2 */
srl $t5, $a2, 8
clock1
/* Command Inhibit */
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 3 */
clock3
/* Command Inhibit */
sb $a2, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 4 */
srl $t5, $a3, 24
clock2
/* Command Inhibit */
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 5 */
srl $t5, $a3, 16
clock2
/* Command Inhibit */
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 6 */
srl $t5, $a3, 8
clock2
/* Command Inhibit */
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 7 */
clock3
/* Command Inhibit */
sb $a3, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 8 */
clock3
sw $t4, SDR_DATA_IO + TRIS_OFFSET + INV_OP_OFFSET($t0) /* Data lines input again */
clock4 /* make certain sdram output has had time to disable - probably not needed */
sw $t3, SDR_CKE_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
.set macro
jr $ra
nop
/*
* Sends READ command
* C Prototype:
* extern __attribute__((far)) uint64_t sdram_read(uint16_t pseudocoladdr);
* Each pseudo column contains 8 bytes of data (consists of 8 ram columns)
*/
sdram_read:
la $t0, TRISA /* Port Base */
li $t7, (1<<CONTROL_CS_BIT) | (1<<CONTROL_CAS_BIT)
/* Set column */
output_column
sync_clock
.set nomacro
/* Read */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LHLH */
clock3
/* Command Inhibit */
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* HHHH */
clock3
/* Command Inhibit */
clock3
lbu $v0, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 1 */
/* Command Inhibit */
clock3
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 2 */
/* Command Inhibit */
sll $v0, $v0, 8
or $v0, $v0, $t5
clock1
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 3 */
/* Command Inhibit */
sll $v0, $v0, 8
or $v0, $v0, $t5
clock1
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 4 */
/* Command Inhibit */
sll $v0, $v0, 8
or $v0, $v0, $t5
clock1
lbu $v1, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 5 */
/* Command Inhibit */
clock3
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 6 */
/* Command Inhibit */
sll $v1, $v1, 8
or $v1, $v1, $t5
clock1
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 7 */
/* Command Inhibit */
sll $v1, $v1, 8
or $v1, $v1, $t5
clock1
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 8 */
/* Command Inhibit */
sll $v1, $v1, 8
or $v1, $v1, $t5
.set macro
jr $ra
nop
/*
* Sends PRECHARGE ALL command
* C Prototype:
* extern __attribute__((far)) void sdram_precharge_all(void);
*/
sdram_precharge_all:
la $t0, TRISA /* Port Base */
li $t3, 0x8000 /* A10 */
li $t4, (1<<CONTROL_CS_BIT) | (1<<CONTROL_RAS_BIT) | (1<<CONTROL_WE_BIT)
sw $t3, SDR_ADDRESS_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* A10 = 1 for Precharge ALL */
sync_clock
.set nomacro
/* Precharge All */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLHL */
clock3
/* Command Inhibit */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
clock3
.set macro
jr $ra
nop
/*
* Sends PRECHARGE command
* C Prototype:
* extern __attribute__((far)) void sdram_precharge(void);
*/
sdram_precharge:
la $t0, TRISA /* Port Base */
li $t3, 0x8000 /* A10 */
li $t4, (1<<CONTROL_CS_BIT) | (1<<CONTROL_RAS_BIT) | (1<<CONTROL_WE_BIT)
sw $t3, SDR_ADDRESS_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* A10 = 0 for Precharge */
sync_clock
.set nomacro
/* Precharge All */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLHL */
clock3
/* Command Inhibit */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
clock3
.set macro
jr $ra
nop
/*
* Sends AUTO REFRESH command
* All banks must be in PRECHARGEd state
* C Prototype:
* extern __attribute__((far)) void sdram_auto_refresh(void);
*/
sdram_auto_refresh:
la $t0, TRISA /* Port Base */
li $t4, (1<<CONTROL_CS_BIT)|(1<<CONTROL_RAS_BIT)|(1<<CONTROL_CAS_BIT)
sync_clock
.set nomacro
/* Auto Refresh */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLH */
clock3
/* Command Inhibit */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
clock3
.set macro
jr $ra
nop
/*
* Puts the SDRAM into the self refresh mode.
* SDRAM retains data in this state.
* C Prototype:
* extern __attribute__((far)) void sdram_sleep(void);
*/
sdram_sleep:
la $t0, TRISA /* Port Base */
li $t1, (1<<CKE_BIT)
li $t4, (1<<CONTROL_CS_BIT)|(1<<CONTROL_RAS_BIT)|(1<<CONTROL_CAS_BIT)
sync_clock
.set nomacro
/* Auto Refresh */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLH */
sw $t1, SDR_CKE_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* CKE low */
clock2
/* Command Inhibit */
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
clock3
.set macro
jr $ra
nop
/*
* Takes the SDRAM out of the self refresh mode.
* Parameters: none
* C Prototype:
* extern __attribute__((far)) void sdram_wake(void);
*/
sdram_wake:
la $t0, TRISA /* Port Base */
li $t1, (1<<CKE_BIT)
sync_clock
.set nomacro
/* Command Inhibit */
sw $t1, SDR_CKE_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* CKE low */
clock3
/* Command Inhibit */
clock4
/* Command Inhibit */
clock4
.set macro
jr $ra
nop
/*
* Selects the bank to which commands are issued
* Parameters:
* C Prototype:
* extern __attribute__((far)) void sdram_bank(uint8_t bank);
* (only lower 2 bits are of bank are currently significant)
*/
sdram_bank:
la $t0, TRISA /* Port Base */
lw $t1, SDR_BANK_IO + LAT_OFFSET + NOP_OP_OFFSET($t0);
and $t1, ~BANK_ALL_MASK
sll $t2, $a0, BANK_0_BIT
or $t1, $t2
sw $t1, SDR_BANK_IO + LAT_OFFSET + NOP_OP_OFFSET($t0);
jr $ra
nop

3
share/.gitignore vendored
View File

@@ -1,3 +0,0 @@
re.help
misc
unixbench

View File

@@ -1,5 +1,5 @@
all: ashello echo chello
all: ashello echo
ashello: ashello.o
$(LD) ashello.o -o $@
@@ -11,4 +11,4 @@ echo: echo.o
$(LD) $@.o -o $@
clean:
rm -f *.o ashello echo chello *.dis *~
rm -f *.o ashello echo *.dis *~

View File

@@ -5,13 +5,13 @@ CFLAGS += -Werror
ASFLAGS += -DCROSS
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
all: chello cplus echo stdarg
all: hello cplus
chello: chello.o
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
${OBJDUMP} -S chello.elf > chello.dis
${SIZE} chello.elf
${ELF2AOUT} chello.elf $@
hello: hello.o
${CC} ${LDFLAGS} -o hello.elf hello.o ${LIBS}
${OBJDUMP} -S hello.elf > hello.dis
${SIZE} hello.elf
${ELF2AOUT} hello.elf $@
cplus: cplus.o
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
@@ -24,6 +24,7 @@ echo: echo.o
${OBJDUMP} -S $@.elf > $@.dis
${SIZE} $@.elf
${ELF2AOUT} $@.elf $@
./aout $@ > $@.dis
clean:
rm -f *.o *.elf ${MAN} chello cplus echo stdarg *.elf *.dis tags *~
rm -f *.o *.elf ${MAN} hello cplus *.elf *.dis tags *~

View File

@@ -2,6 +2,6 @@
int main()
{
printf ("Hello, C World!\n");
return 0;
printf ("Hello, C World!\n");
return 0;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -1,41 +0,0 @@
CC = scc
PROG = hello primelist primesum test1 test2 test3 gpio adc rain \
webserver q8
all: $(PROG)
hello: hello.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) hello.c
primelist: primelist.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primelist.c
primesum: primesum.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primesum.c
webserver: webserver.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) webserver.c -lwiznet
gpio: gpio.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) gpio.c
adc: adc.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) adc.c
rain: rain.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) rain.c
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:
rm -f *.o $(PROG)

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -1,6 +0,0 @@
extern int printf();
int main()
{
printf ("Hello, SmallC World!\n");
}

View File

@@ -1,31 +0,0 @@
/*
* Print the list of prime numbers up to 100.
*/
main()
{
int n;
for (n=2; n<100; ++n) {
if (isprime(n)) {
printf("%d ", n);
}
}
printf("\n");
}
isprime(n)
int n;
{
int j;
if (n == 2)
return 1;
if (n % 2 == 0)
return 0;
for (j=3; j*j<=n; j+=2)
if (n % j == 0)
return 0;
return 1;
}

View File

@@ -1,32 +0,0 @@
/*
* Compute the sum of prime numbers up to 10000.
*/
main()
{
int sum, n;
sum = 0;
for (n=2; n<10000; ++n) {
if (isprime(n)) {
sum += n;
}
}
printf("Sum of primes less than 10000: %d\n", sum);
}
isprime(n)
int n;
{
int j;
if (n == 2)
return 1;
if (n % 2 == 0)
return 0;
for (j=3; j*j<=n; j+=2)
if (n % j == 0)
return 0;
return 1;
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}

View File

@@ -1,219 +0,0 @@
int ga[5];
main()
{
int a, b, c, d;
int arr[5];
int *pi;
char arrc[5];
char *pic;
int s1, s2;
int z;
int t;
int *pip;
int *picp;
int e1, e2;
ga[0] = 10;
ga[1] = 20;
ga[2] = 30;
ga[3] = 40;
ga[4] = 50;
a = 21;
b = 31;
c = 71;
d = 82;
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];
printf(" 21 + 31 = %d (52)\n", a + b);
printf(" 21 - 31 = %d (-10)\n", a - b);
printf(" 21 & 71 = %d (5)\n", a & c);
printf(" 21 | 82 = %d (87)\n", a | d);
printf(" 21 ^ 82 = %d (71)\n", a ^ d);
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);
printf(" *pic + 1 = %d (14)\n", *pic+1);
printf(" *(pic + 1) = %d (23)\n", *(pic+1));
printf("&arrc[3] - &arrc[0] = %d (3)\n", &arrc[3]-&arrc[0]);
printf("\n");
s1 = 3;
s2 = -200;
printf(" 82 << 3 = %d (656)\n", d << s1);
printf(" 82 >> 3 = %d (10)\n", d >> s1);
printf("-200 >> 3 = %d (-25)\n", s2 >> s1);
printf("-200 << 3 = %d (-1600)\n", s2 << s1);
printf("\n");
printf("-s1 = %d (-3)\n", -s1);
printf("-s2 = %d (200)\n", -s2);
printf("\n");
printf("~82 = %d (-83)\n", ~d);
printf("\n");
z = 0;
printf("!82 = %d (0)\n", !d);
printf(" !0 = %d (1)\n", !z);
printf("\n");
printf(" 0 && 0 = %d (0)\n", z && z);
printf(" 0 && 21 = %d (0)\n", z && a);
printf(" 3 && 21 = %d (1)\n", s1 && a);
printf("21 && 3 = %d (1)\n", a && s1);
printf("\n");
printf(" 0 || 0 = %d (0)\n", z || z);
printf(" 0 || 21 = %d (1)\n", z || a);
printf(" 3 || 21 = %d (1)\n", s1 || a);
printf("21 || 3 = %d (1)\n", a || s1);
printf("\n");
pi = 4;
printf("pi++ = %d (4)\n", pi++);
printf(" pi = %d (8)\n", pi);
printf("++pi = %d (12)\n", ++pi);
printf("pi-- = %d (12)\n", pi--);
printf(" pi = %d (8)\n", pi);
printf("--pi = %d (4)\n", --pi);
printf("\n");
pic = 4;
printf("pic++ = %d (4)\n", pic++);
printf(" pic = %d (5)\n", pic);
printf("++pic = %d (6)\n", ++pic);
printf("pic-- = %d (6)\n", pic--);
printf(" pic = %d (5)\n", pic);
printf("--pic = %d (4)\n", --pic);
printf("\n");
t = 4;
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)
int t;
char *str;
{
printf("bool test on value %d %s\n", t, str);
}

View File

@@ -1,127 +0,0 @@
#include <fcntl.h>
int aaa;
int bbb;
int ccc;
char gc;
char gbuffer[3];
int gibuffer[4];
extern errno;
main()
{
char b;
int la;
unsigned int u1, u2;
int s1, s2;
unsigned char uc1, uc2;
char sc1, sc2;
int fd;
char buffer[6];
int ibuffer[7];
printf(" sizeof(uc1): %d 1\n", sizeof(uc1));
printf(" sizeof(sc1): %d 1\n", sizeof(sc1));
printf(" sizeof(u1): %d 4\n", sizeof(u1));
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;
la = 4;
printf("%d 1\n", aaa);
printf("%d 2\n", bbb);
printf("%d 4\n", la);
uc1 = 0x80;
sc1 = 0x80;
s1 = uc1;
s2 = sc1;
printf("unsigned char (0x80) -> int: %d 128\n", s1);
printf(" signed char (0x80) -> int: %d -128\n", s2);
u1 = uc1;
u2 = sc1;
printf("unsigned char (0x80) -> unsigned: %d 128\n", u1);
printf(" signed char (0x80) -> unsigned: %d -128\n", u2);
la = errno;
printf("errno: %d 0\n", la);
write(1, "abcd ", 5);
la = errno;
printf("errno after good write call: %d 0\n", la);
write(10, "abcde", 5);
la = errno;
printf("errno after bad write call: %d 9\n", la);
write(1, "abcd ", 5);
la = errno;
printf("good write after failed should not overwrite errno: %d 9\n", la);
errno = 0;
write(1, "abcd ", 5);
la = errno;
printf("good write after errno set to zero: %d 0\n", la);
la = write(1, "abcd ", 5);
printf("write() return: %d 5\n", la);
la = write(10, "abcd ", 5);
printf("write(bad fd) return: %d -1\n", la);
fd = open("/a.txt", O_WRONLY | O_CREAT, 0666);
if (fd != -1) {
printf("open success\n");
la = write(fd, "abcd\n", 5);
if (la == 5) printf("write success\n"); else printf("write failed\n");
la = close(fd);
if (la != -1) printf("close success\n"); else printf("close failed\n");
} else {
printf("open failed\n");
}
buffer[0] = 0;
buffer[1] = 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");
}
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -21,7 +21,7 @@ FRC:
install: elf32-mips.ld
-for i in $(SUBDIR); do \
$(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:
rm -f a.out core *.s *.o *.a *~

71
src/cmd/.gitignore vendored
View File

@@ -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

View File

@@ -11,13 +11,12 @@ CFLAGS += -Werror
# Programs that live in subdirectories, and have makefiles of their own.
# /bin
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 \
more nm passwd picoc portio printf pwm \
rdprof ranlib re renice retroforth scm setty sl \
sed sh smallc smlrc stty sysctl test uname wiznet xargs \
zmodem gtest msec unixbench cron compress date2 tip \
talloc devupdate uucp smux
ranlib re renice retroforth scm setty sl \
sed sh smallc stty sysctl test uname wiznet xargs \
zmodem gtest
# /sbin
SUBDIR += chown chroot disktool fsck getty init \
@@ -33,7 +32,7 @@ SCRIPT = false nohup true #lorder mkdep
# C programs that live in the current directory and do not need
# 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 \
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 \

View File

@@ -1 +0,0 @@
adb

View File

@@ -1,7 +1,6 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.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 \
main.o opset.o output.o pcs.o print.o \

View File

@@ -2,7 +2,6 @@
* File handling and access routines
*/
#include "defs.h"
#include <fcntl.h>
static int
within(adr, lbd, ubd)
@@ -60,7 +59,7 @@ acces(mode, adr, space, value)
long adr;
{
int w, w1, pmode, rd, file;
BKPTR bkptr;
BKPTR bkptr, scanbkpt();
if (space == NSP)
return 0;
@@ -90,7 +89,7 @@ acces(mode, adr, space, value)
return w;
}
w = 0;
if (mode==WT && wtflag==O_RDONLY) {
if (mode==WT && wtflag==0) {
error("not in write mode");
}
if (! chkmap(&adr, space))

View File

@@ -190,8 +190,7 @@ trypr:
regptr = getreg(savc);
if (regptr != NOREG) {
uframe[regptr] = shorten(dot);
ptrace(PT_WRITE_U, pid, (char*) (KERNEL_DATA_END - USIZE) +
((char*)&uframe[regptr] - (char*)&corhdr),
ptrace(PT_WRITE_U, pid, &uframe[regptr] - (int)&corhdr,
uframe[regptr]);
} else if ((modifier = varchk(savc)) != -1) {
var[modifier] = dot;

View File

@@ -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'

View File

@@ -8,22 +8,16 @@
* This has changed over time - see a.out.h, sys/exec.h and nlist.h
* for the current a.out definition and format.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/user.h>
#include <machine/io.h>
#include <sgtty.h>
#include <setjmp.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <a.out.h>
#include <sys/ptrace.h>
#ifdef CROSS
# include <termios.h>
# define sgttyb termios
#else
# include <sgtty.h>
#endif
#define MAXSYMLEN 32
#define MAXCOM 64
@@ -55,6 +49,7 @@ typedef struct map MAP;
typedef MAP *MAPPTR;
typedef struct bkpt BKPT;
typedef BKPT *BKPTR;
typedef struct user U;
/* file address maps */
struct map {
@@ -134,9 +129,7 @@ typedef struct reglist REGLIST;
#define MAXPOS 80
#define MAXLIN 128
#ifndef TRUE
#define TRUE (-1)
#endif
#define TRUE (-1)
#define FALSE 0
#define LOBYTE 0377
#define HIBYTE 0177400
@@ -150,7 +143,7 @@ typedef struct reglist REGLIST;
/* long to ints and back (puns) */
#define leng(a) ((long)((unsigned)(a)))
#define shorten(a) ((long)a)
#define shorten(a) ((int)a)
struct sgttyb adbtty, usrtty;
jmp_buf erradb;

View File

@@ -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

View File

@@ -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>

View File

@@ -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.

View File

@@ -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.

View File

@@ -1,9 +1,5 @@
#include "defs.h"
#ifdef CROSS
# include </usr/include/ctype.h>
#else
# include <ctype.h>
#endif
#include <ctype.h>
static int savlastf;
static long savframe;

View File

@@ -1,10 +1,6 @@
#include "defs.h"
#include <ctype.h>
#include <sys/wait.h>
#ifdef CROSS
# include </usr/include/ctype.h>
#else
# include <ctype.h>
#endif
void
scanform(icount, ifp, itype, ptype)
@@ -87,7 +83,7 @@ exform(fcount, ifp, itype, ptype)
u_int w;
long savdot, wx;
char *fp = 0;
int c, modifier;
int c, modifier, longpr;
struct {
long sa;
int sb, sc;
@@ -96,7 +92,7 @@ exform(fcount, ifp, itype, ptype)
while (fcount > 0) {
fp = ifp;
c = *fp;
//int longpr = (c >= 'A' && c <= 'Z') || (c == 'f');
longpr = (c >= 'A' && c <= 'Z') || (c == 'f');
if (itype == NSP || *fp == 'a') {
wx = dot;
w = dot;

View File

@@ -1,5 +1,4 @@
#include "defs.h"
#include <fcntl.h>
char *Ipath = "/share/adb";
@@ -60,27 +59,22 @@ main(argc, argv)
myname = "adb";
mynamelen = strlen(myname);
#ifdef TIOCGETP
ioctl(0, TIOCGETP, &adbtty);
ioctl(0, TIOCGETP, &usrtty);
#else
tcgetattr(0, &adbtty);
tcgetattr(0, &usrtty);
#endif
while (argc > 1) {
if (strcmp("-w", argv[1]) == 0) {
wtflag = O_RDWR;
if (! strcmp("-w", argv[1])) {
wtflag = 2;
argc--;
argv++;
continue;
}
if (strcmp("-k", argv[1]) == 0) {
if (! strcmp("-k", argv[1])) {
kernel++;
argc--;
argv++;
continue;
}
if (strcmp("-I", argv[1]) == 0) {
if (! strcmp("-I", argv[1])) {
Ipath = argv[2];
argc -= 2;
argv += 2;
@@ -127,7 +121,7 @@ main(argc, argv)
flushbuf();
if (errflg) {
print("%s\n", errflg);
exitflg = (errflg != 0);
exitflg = (int) errflg;
errflg = 0;
}
if (mkfault) {

View File

@@ -1,5 +1,4 @@
#include "defs.h"
#include <stdarg.h>
int outfile = 1;
char *printptr = printbuf;
@@ -188,143 +187,153 @@ printdate(tvec)
void
print(char *fmat, ...)
{
va_list args, prev_args;
char *fptr, *s;
int *vptr;
long *dptr;
double *rptr;
int width, prec;
char c, adj;
int decpt, n;
int x, decpt, n;
long lx;
char digits[64];
union {
int int32;
float float32;
} word;
va_start(args, fmat);
fptr = fmat;
vptr = 1 + (int*) &fmat;
while ((c = *fptr++)) {
if (c != '%') {
printc(c);
continue;
}
if (*fptr == '-') {
adj = 'l';
fptr++;
} else {
adj = 'r';
}
width = convert(&fptr);
if (*fptr == '*') {
width = va_arg(args, int);
fptr++;
}
if (*fptr == '.') {
fptr++;
prec = convert(&fptr);
if (*fptr == '-') {
adj = 'l';
fptr++;
} else {
adj = 'r';
}
width = convert(&fptr);
if (*fptr == '*') {
prec = va_arg(args, int);
width = *vptr++;
fptr++;
}
} else
prec = -1;
if (*fptr == '.') {
fptr++;
prec = convert(&fptr);
if (*fptr == '*') {
prec = *vptr++;
fptr++;
}
} else
prec = -1;
digitptr = digits;
prev_args = args;
word.int32 = va_arg(args, int);
s = 0;
switch (c = *fptr++) {
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);
}
digitptr = digits;
rptr = (double*) vptr;
dptr = (long*) vptr;
lx = *dptr;
x = *vptr++;
s = 0;
prec = -1;
break;
case 'm':
args = prev_args;
break;
case 'M':
width = word.int32;
break;
case 'T':
case 't':
if (c == 'T') {
width = word.int32;
} else {
args = prev_args;
switch (c = *fptr++) {
case 'd':
case 'u':
printnum(x, c, 10);
break;
case 'o':
printoct((long) (unsigned) x, 0);
break;
case 'q':
printlong((long) (unsigned) x, 'x', 16);
break;
case 'x':
printlong((long) (unsigned) x, c, 16);
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) {
*digitptr = 0;
s = digits;
}
n = strlen(s);
n = (prec < n && prec >= 0) ? prec : n;
width -= n;
if (adj == 'r') {
if (s == 0) {
*digitptr = 0;
s = digits;
}
n = strlen(s);
n = (prec < n && prec >= 0) ? prec : n;
width -= n;
if (adj == 'r') {
while (width-- > 0)
printc(SP);
}
while (n--)
printc(*s++);
while (width-- > 0)
printc(SP);
digitptr = digits;
}
while (n--)
printc(*s++);
while (width-- > 0)
printc(SP);
digitptr = digits;
}
va_end(args);
}
#define MAXIFD 5

View File

@@ -74,7 +74,6 @@ printregs()
int v;
if (kernel) {
// TODO
for (p=kregs; p<&kregs[7]; p++) {
v = corhdr[p->roffs];
print("%s%8t%x%8t", p->rname, v);
@@ -82,30 +81,12 @@ printregs()
printc(EOR);
}
} else {
print (" t0 = %9x s0 = %9x t8 = %9x lo = %9x\n",
uframe [FRAME_R8], uframe [FRAME_R16],
uframe [FRAME_R24], uframe [FRAME_LO]);
print ("at = %9x t1 = %9x s1 = %9x t9 = %9x hi = %9x\n",
uframe [FRAME_R1], uframe [FRAME_R9], uframe [FRAME_R17],
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]);
for (p=reglist; p < &reglist[NREG]; p++) {
v = uframe[p->roffs];
print("%s%8t%x%8t", p->rname, v);
valpr(v, (p->roffs == FRAME_PC) ? ISYM : DSYM);
printc(EOR);
}
printpc();
}
}
@@ -304,7 +285,7 @@ printtrace(modif)
}
break;
case 'e': case 'E': /* print externals */
case 'e': case 'E': /* print externals*/
symset();
while ((symp = symget())) {
chkerr();
@@ -417,10 +398,8 @@ printpc()
void
sigprint()
{
#ifndef CROSS
if (signo >= 0 && signo < NSIG)
print("%s", sys_siglist[signo]);
else
#endif
print("unknown signal %d", signo);
}

Some files were not shown because too many files have changed in this diff Show More