3 Commits

Author SHA1 Message Date
Serge Vakulenko
f33305f894 Levee editor compiled for RetroBSD. 2015-01-06 13:42:43 -08:00
Serge Vakulenko
e834303650 Levee editor compiled on Linux. 2015-01-06 12:58:23 -08:00
Serge Vakulenko
476573dae6 Imported levee editor sources from http://www.pell.portland.or.us/~orc/Code/levee/levee-3.5a.tar.gz 2015-01-06 12:54:38 -08:00
1018 changed files with 62321 additions and 159769 deletions

7
.gitignore vendored
View File

@@ -24,10 +24,7 @@
*.dis
*.0
*.img
sdcard.rd
.profile
Makefile.user
#misc
*.log
*.txt

View File

@@ -8,6 +8,32 @@
# The `make' will compile everything, including a kernel, utilities
# and a root filesystem image.
#
# 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
BAREMETAL = sys/pic32/baremetal/BAREMETAL
RETROONE = sys/pic32/retroone/RETROONE
FUBARINO = sys/pic32/fubarino/FUBARINO
FUBARINOBIG = sys/pic32/fubarino/FUBARINO-UART2CONS-UART1-SRAMC
SDXL = sys/pic32/sdxl/SDXL
MMBMX7 = sys/pic32/mmb-mx7/MMB-MX7
# Select target board
TARGET ?= $(MAX32)
# Filesystem and swap sizes.
FS_MBYTES = 100
U_MBYTES = 100
@@ -29,18 +55,23 @@ FSUTIL = tools/fsutil/fsutil
-include Makefile.user
TARGETDIR = $(shell dirname $(TARGET))
TARGETNAME = $(shell basename $(TARGET))
TOPSRC = $(shell pwd)
CONFIG = $(TOPSRC)/tools/configsys/config
all:
all: .profile
$(MAKE) -C tools
$(MAKE) -C lib
$(MAKE) -C src install
$(MAKE) kernel
$(MAKE) fs
kernel: $(CONFIG)
$(MAKE) -C sys/pic32 all
kernel: $(TARGETDIR)/Makefile
$(MAKE) -C $(TARGETDIR)
$(TARGETDIR)/Makefile: $(CONFIG) $(TARGETDIR)/$(TARGETNAME)
cd $(TARGETDIR) && ../../../tools/configsys/config $(TARGETNAME)
fs: sdcard.img
@@ -49,9 +80,7 @@ sdcard.img: $(FSUTIL) rootfs.manifest userfs.manifest
rm -f $@
$(FSUTIL) --repartition=fs=$(FS_MBYTES)M:swap=$(SWAP_MBYTES)M:fs=$(U_MBYTES)M $@
$(FSUTIL) --new --partition=1 --manifest=rootfs.manifest $@ .
# In case you need a separate /u partition,
# uncomment the following line.
# $(FSUTIL) --new --partition=3 --manifest=userfs.manifest $@ u
$(FSUTIL) --new --partition=3 --manifest=userfs.manifest $@ u
$(FSUTIL):
cd tools/fsutil; $(MAKE)
@@ -71,7 +100,7 @@ cleanall: clean
rm -f share/re.help share/emg.keys share/misc/more.help
rm -f etc/termcap etc/remote etc/phones
rm -f tools/configsys/.depend
rm -f var/log/aculog sdcard.img
rm -f var/log/aculog
rm -rf var/lock share/unixbench
installfs:
@@ -89,3 +118,6 @@ installflash:
# 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

View File

@@ -15,35 +15,55 @@
## Supported hardware
* Fubarino SD board.
* Olimex Duinomite, Duinomite-Mini, Duinomite-Mega and Duinomite-eMega boards.
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
* chipKIT Max32 board.
* Sparkfun UBW32 board.
* Maximite and Colour Maximite computers.
* Majenko SDXL board.
* 4D Systems Picadillo-35T board.
* MikroElektronika MultiMedia Board for PIC32MX7.
* chipKIT Max32 board with SD card shield.
* chipKIT WF32 board with 2.4" LCD TFT display shield.
* Sparkfun UBW32 board with SD card slot.
* 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
To compile everything from sources, you'll need some packages installed, namely:
Berkeley YACC, GNU bison, flex, groff, ELF library and FUSE library.
Berkeley YACC, GNU bison and flex, ELF library and FUSE library.
Under Ubuntu, for example, you can do it by command:
```shell
$ sudo apt-get install bison byacc flex groff-base libelf-dev
$ sudo apt-get install bison byacc flex libelf-dev libfuse-dev
```
You can change a desired filesystem size and swap area size, as required.
Default is:
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
FS_MBYTES = 100
SWAP_MBYTES = 2
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 = $(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:
@@ -74,11 +94,11 @@ Kernel image should be written to PIC32 flash memory. The procedure depends
on a board used.
#### Max32 board:
Use a pic32prog utility (http://code.google.com/p/pic32prog/)
and a USB cable to install a kernel:
```shell
$ pic32prog -d /dev/ttyUSB0 sys/pic32/max32/unix.hex
$ 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.

1
etc/.gitignore vendored
View File

@@ -1,4 +1,3 @@
localtime
phones
remote
termcap

View File

@@ -4,14 +4,46 @@
# All rights reserved. The Berkeley software License Agreement
# specifies the terms and conditions for redistribution.
#
# @(#)MAKEDEV 4.27.6 (2.11BSD) 1999/2/19
#
# Device "make" file. Valid arguments:
# std standard devices
# local configuration specific devices
# fd file descriptor driver
# Tapes:
# ht* unibus tu77 & te16
# tm* unibus tm11 & te10 emulations (e.g. Emulex tc-11)
# ts* unibus ts11
# tu* tmscp (tk50/tu81)
# Disks:
# sd* flash cards SecureDigital
# br* unibus Eaton br1538 or br1711
# hk* unibus rk06 and rk07
# ra* unibus uda50 w/ ra??
# rk* unibus rk05
# rl* unibus rl01/rl02
# rx* unibus rx02
# si* unibus cdc 9766 w/ si 9500
# xp* unibus rm02/03/05, rp04/05/06, diva, eagle, cdc9766, fuji 160.
# Terminal multiplexors:
# dl* dl-11 units other than the console
# dz* unibus dz11 and dz32
# dh* unibus dh11 and emulations (e.g. Able dmax, Emulex cs-11)
# dmf* unibus dmf32
# dhu* unibus dhu11
# dmz* unibus dmz32
# dhv* qbus dhv11
# Pseudo terminals:
# pty* set of 16 master and slave pseudo terminals
# Printers:
# lp* unibus lp11 parallel interface
# va* unibus varian parallel interface
# vp* unibus versatec parallel interface
# Call units:
# Special purpose devices:
# dr* unibus dr11
# ram* memory disk
# dn* dn11 dialer
# ingreslock Ingres lock driver.
PATH=/etc:/sbin:/usr/sbin:/bin:/usr/bin
umask 77

View File

@@ -11,6 +11,7 @@ DESTDIR = /foobar
OWN = root
GRP = wheel
SUBDIR = root
FILES = crontab fstab gettytab group motd passwd \
rc rc.local shells syslog.conf ttys
@@ -18,6 +19,8 @@ all install depend lint tags:
clean:
rm -f *~
-for i in ${SUBDIR}; do \
(cd $$i; make DESTDIR=${DESTDIR} $@); done
distribution:
-@mkdir -p ${DESTDIR}/dev
@@ -72,3 +75,5 @@ distribution:
${DESTDIR}/usr/adm/savacct
install -c -o uucp -g daemon -m 600 /dev/null \
${DESTDIR}/usr/adm/aculog
-for i in ${SUBDIR}; do \
(cd $$i; make DESTDIR=${DESTDIR} distribution); done

View File

@@ -1,2 +1,2 @@
/dev/sd0a / ufs rw,async 1 1
#/dev/sd0c /u ufs rw,async 1 2
/dev/rd0a / ufs rw,async 1 1
#/dev/rd0c /u ufs rw,async 1 2

View File

@@ -16,7 +16,7 @@
# entries, and in cases where getty is called with no table name
#
default:\
:ap:im=\r\n\r\nRetroBSD (%h) (%t)\r\n\r\r\n\r:sp#1200:
:ap:im=\r\n\r\n2.11 BSD UNIX (%h) (%t)\r\n\r\r\n\r:sp#1200:
#
# Fixed speed entries

View File

@@ -1,7 +1,8 @@
root:5:0:1:The Man:/root:/bin/sh
daemon:*:1:1:The devil himself:/root:/bin/sh
root:5:0:1:The Man:/:/bin/sh
daemon:*:1:1:The devil himself:/:/bin/sh
sys:*:4:2:Operating System:/tmp:nologin
operator:*:2:5:System &:/u/operator:/bin/sh
bin:*:3:20:Binaries Commands and Source:/root:/bin/sh
operator:*:2:5:System &:/usr/guest/operator:/bin/csh
bin:*:3:20:Binaries Commands and Source:/:/bin/csh
nobody:*:32767:31:Nobody:/nonexistent:/bin/sh
uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/sbin/uucico
uucp:*:66:1:UNIX-to-UNIX Copy:/usr/spool/uucppublic:/usr/sbin/uucico
ingres:*:39:74:INGRES Owner:/usr/ingres:/bin/csh

2
etc/rc
View File

@@ -3,6 +3,8 @@ 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.

18
etc/root/Makefile Normal file
View File

@@ -0,0 +1,18 @@
#
# DESTDIR is defined here to be something which does *NOT* exist - it must be
# specified on the command line when doing a "make DESTDIR=/mnt distribution".
# This is aimed at avoiding overwriting the system disk's /etc files.
DESTDIR = /foobar
OWN = root
GRP = wheel
all install depend lint tags:
distribution:
install -c -o ${OWN} -g ${GRP} -m 644 dot.cshrc ${DESTDIR}/.cshrc
install -c -o ${OWN} -g ${GRP} -m 644 dot.login ${DESTDIR}/.login
install -c -o ${OWN} -g ${GRP} -m 644 dot.profile ${DESTDIR}/.profile
clean:
rm -f *~

14
etc/root/dot.cshrc Normal file
View File

@@ -0,0 +1,14 @@
set history=30
set path=(/bin /sbin /etc /usr/sbin /usr/ucb /usr/bin /usr/new /usr/local)
if ($?prompt) then
set prompt="\!% "
endif
set filec
set mail=( 0 /usr/spool/mail/$USER )
set cdpath=( ~ /usr/spool/mqueue)
set prompt="\!% root--> "
alias mail /usr/ucb/Mail
alias pwd 'echo $cwd'
alias h history
alias q5 'tail -5 /usr/spool/mqueue/syslog'

14
etc/root/dot.login Normal file
View File

@@ -0,0 +1,14 @@
unset noglob
set path=(/bin /etc /sbin /usr/sbin /usr/ucb /usr/bin /usr/local /usr/new)
umask 26
stty dec erase ^H kill ^U eof ^D
set prompt="[\!] root--> "
if ( "$TERM" == dialup || "$TERM" == network) then
setenv TERM vt100
echo -n "Terminal ($TERM)? "
set argv = "$<"
if ( "$argv" != '' ) setenv TERM "$argv"
endif
biff y

8
etc/root/dot.profile Normal file
View File

@@ -0,0 +1,8 @@
echo 'erase, kill ^U, intr ^C'
stty dec
stty erase
PATH=/bin:/sbin:/usr/sbin:/etc:/usr/ucb:/usr/bin:/usr/new
export PATH
HOME=/
export HOME
export TERM

View File

@@ -1,7 +1,8 @@
root:ro46DZg1ViGBs:0:1:The Man:/root:/bin/sh
daemon:*:1:1:The devil himself:/root:/bin/sh
root:ro46DZg1ViGBs:0:1:The Man:/:/bin/sh
daemon:*:1:1:The devil himself:/:/bin/sh
sys:*:4:2:Operating System:/tmp:nologin
operator:*:2:5:System &:/u/operator:/bin/sh
bin:*:3:20:Binaries Commands and Source:/root:/bin/sh
operator:*:2:5:System &:/usr/guest/operator:/bin/csh
bin:*:3:20:Binaries Commands and Source:/:/bin/csh
nobody:*:32767:31:Nobody:/nonexistent:/bin/sh
uucp:*:66:1:UNIX-to-UNIX Copy:/spool/uucppublic:/sbin/uucico
uucp:*:66:1:UNIX-to-UNIX Copy:/usr/spool/uucppublic:/usr/sbin/uucico
ingres:*:39:74:INGRES Owner:/usr/ingres:/bin/csh

1
include/.gitignore vendored
View File

@@ -1 +0,0 @@
readline

View File

@@ -1,3 +1,5 @@
/* assert.h 4.2 85/01/21 */
# ifndef NDEBUG
# define _assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__);exit(1);}}
# define assert(ex) _assert(ex)

View File

@@ -1,3 +1,5 @@
/* ctype.h 4.2 85/09/04 */
#define _U 01
#define _L 02
#define _N 04

View File

@@ -10,6 +10,7 @@
#include <term.h>
#define bool int
#define reg register
#define TRUE (1)
#define FALSE (0)
@@ -32,6 +33,7 @@ typedef struct sgttyb SGTTY;
/*
* Capabilities from termcap
*/
extern bool 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,
@@ -129,6 +131,7 @@ int __void__;
/*
* psuedo functions
*/
#define clearok(win,bf) (win->_clear = bf)
#define leaveok(win,bf) (win->_leave = bf)
#define scrollok(win,bf) (win->_scroll = bf)

28
include/dbm.h Normal file
View File

@@ -0,0 +1,28 @@
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)dbm.h 5.1 (Berkeley) 3/27/86
*/
#ifndef NULL
/*
* this is lunacy, we no longer use it (and never should have
* unconditionally defined it), but, this whole file is for
* backwards compatability - someone may rely on this.
*/
#define NULL ((char *) 0)
#endif
#include <ndbm.h>
datum fetch();
datum firstkey();
datum nextkey();
#if 0
datum makdatum();
datum firsthash();
long calchash();
long hashinc();
#endif

View File

@@ -47,6 +47,9 @@
* if type is "rq", then use concatenation of fs_file and "quotas" to locate
* quota file.
*/
#define _PATH_FSTAB "/etc/fstab"
#define FSTAB "/etc/fstab" /* deprecated */
#define FSTAB_RW "rw" /* read/write device */
#define FSTAB_RQ "rq" /* read/write with quotas */
#define FSTAB_RO "ro" /* read-only device */

View File

@@ -36,6 +36,36 @@
#ifndef _LIMITS_H_
#define _LIMITS_H_
/*
* We don't need this crud at the moment so save on abuse of the C
* preprocessor by not doing the defines.
#define _POSIX_ARG_MAX 4096
#define _POSIX_CHILD_MAX 6
#define _POSIX_LINK_MAX 8
#define _POSIX_MAX_CANON 255
#define _POSIX_MAX_INPUT 255
#define _POSIX_NAME_MAX 14
#define _POSIX_NGROUPS_MAX 0
#define _POSIX_OPEN_MAX 16
#define _POSIX_PATH_MAX 255
#define _POSIX_PIPE_BUF 512
#define _POSIX_SSIZE_MAX 32767
#define _POSIX_STREAM_MAX 8
#define _POSIX_TZNAME_MAX 3
#define _POSIX2_BC_BASE_MAX 99
#define _POSIX2_BC_DIM_MAX 2048
#define _POSIX2_BC_SCALE_MAX 99
#define _POSIX2_BC_STRING_MAX 1000
#define _POSIX2_EQUIV_CLASS_MAX 2
#define _POSIX2_EXPR_NEST_MAX 32
#define _POSIX2_LINE_MAX 2048
#define _POSIX2_RE_DUP_MAX 255
*/
#include <machine/limits.h>
/* #include <sys/syslimits.h> */
#endif /* !_LIMITS_H_ */

View File

@@ -4,16 +4,16 @@
* specifies the terms and conditions for redistribution.
*/
double fabs(double), floor(double), ceil(double);
double sqrt(double), hypot(double, double);
double sin(double), cos(double), tan(double);
double asin(double), acos(double), atan(double), atan2(double, double);
double exp(double), log(double), log10(double), pow(double, double);
double sinh(double), cosh(double), tanh(double);
double j0(double), j1(double), jn(int, double);
double y0(double), y1(double), yn(int, double);
extern double fabs(), floor(), ceil(), fmod(), ldexp();
extern double sqrt(), hypot(), atof();
extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
extern double exp(), log(), log10(), pow();
extern double sinh(), cosh(), tanh();
extern double gamma();
extern double j0(), j1(), jn(), y0(), y1(), yn();
#define HUGE_VAL 3.40282347e+38 /* TBD??? use infinity? */
#define HUGE 1.701411733192644270e38
#define LOGHUGE 39
int isnanf(float x);
int isnan(double x);
@@ -31,21 +31,3 @@ float ldexpf(float x, int exp);
double ldexp(double x, int exp);
double fmod(double x, double y);
#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log 2e */
#define M_LOG10E 0.43429448190325182765 /* log 10e */
#define M_LN2 0.69314718055994530942 /* log e2 */
#define M_LN10 2.30258509299404568402 /* log e10 */
#define M_PI 3.14159265358979323846 /* pi */
#define M_PI_2 1.57079632679489661923 /* pi/2 */
#define M_PI_4 0.78539816339744830962 /* pi/4 */
#define M_1_PI 0.31830988618379067154 /* 1/pi */
#define M_2_PI 0.63661977236758134308 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */

View File

@@ -10,7 +10,11 @@
* Hashed key data base library.
*/
#define PBLKSIZ 1024
#define DBLKSIZ 1024
#ifdef pdp11
#define DBLKSIZ 512
#else
#define DBLKSIZ 4096
#endif
typedef struct {
int dbm_dirf; /* open directory file */

View File

@@ -39,7 +39,7 @@
*/
struct nlist {
char *n_name; /* In memory address of symbol name,
* or string table offset (file) */
or string table offset (file) */
u_short n_len; /* Length of name in bytes */
u_short n_type; /* Type of symbol - see below */
u_int n_value; /* Symbol value */

View File

@@ -24,25 +24,18 @@
#define _PATH_CORE "/core"
#define _PATH_DEV "/dev/"
#define _PATH_CONSOLE "/dev/console"
#define _PATH_LOG "/dev/log"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_TTY "/dev/tty"
#define _PATH_MEM "/dev/mem"
#define _PATH_SWAP "/dev/swap"
#define _PATH_FSTAB "/etc/fstab"
#define _PATH_LOCALTIME "/etc/localtime"
#define _PATH_MOTD "/etc/motd"
#define _PATH_NOLOGIN "/etc/nologin"
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_PTMP "/etc/ptmp"
#define _PATH_SHADOW "/etc/shadow"
#define _PATH_TERMCAP "/etc/termcap"
#define _PATH_USRLIB "/lib/"
#define _PATH_CTIMED "/libexec/ctimed"
#define _PATH_LOCALLIB "/local/lib/"
#define _PATH_SBIN "/sbin/"
#define _PATH_USRSBIN "/sbin/"
#define _PATH_MKPASSWD "/sbin/mkpasswd"
#define _PATH_SENDMAIL "/sbin/sendmail"
#define _PATH_SHARE "/share/"
#define _PATH_ZONEINFO "/share/zoneinfo" /* Time zone object file directory */

229
include/pcc.h Normal file
View File

@@ -0,0 +1,229 @@
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)pcc.h 5.1 (Berkeley) 5/30/85
*/
/*
* This file contains definitions for all the constants and structures
* needed to use the intermediate code files generated and read by
* the Portable C Compiler and related compilers.
*
* Rules for changing this code:
* 1) All op values must be integer constants -- this permits us to run
* a 'sed' script on this file to create %term declarations for yacc.
* 2) Because the PCC uses fancy ASG and UNARY macros, assignment
* operators must have values 1 greater than corresponding normal
* operators, and unary operators must have values 2 greater ditto.
* 3) Ops used only by f1 must have values >= 150 (PCCF_FORTOPS).
* 4) Other language-dependent ops must have values >= 200.
*/
# ifndef PCC_TOKENS
# define PCC_TOKENS 0
# define PCC_ERROR 1 /* an error node */
# define PCC_FREE 2 /* an unused node */
/*
* Constants.
*/
# define PCC_STRING 3 /* a string constant */
# define PCC_ICON 4 /* an integer constant */
# define PCC_FCON 5 /* a floating point constant */
# define PCC_DCON 6 /* a double precision f.p. constant */
/*
* Leaf types.
*/
# define PCC_NAME 7 /* an identifier */
# define PCC_REG 8 /* a register */
# define PCC_OREG 9 /* register and offset */
# define PCC_CCODES 10 /* condition codes */
# define PCC_FLD 11 /* a bit field */
/*
* Arithmetic operators.
*/
# define PCC_PLUS 12 /* + */
# define PCC_PLUSEQ 13 /* += */
# define PCC_UPLUS 14 /* unary + (for completeness) */
# define PCC_MINUS 15 /* - */
# define PCC_MINUSEQ 16 /* -= */
# define PCC_UMINUS 17 /* unary - */
# define PCC_MUL 18 /* * */
# define PCC_MULEQ 19 /* *= */
/* Reserve a slot for 'unary *', which is PCC jargon for PCC_DEREF (yech) */
# define PCC_DIV 21 /* / */
# define PCC_DIVEQ 22 /* /= */
# define PCC_MOD 23 /* % */
# define PCC_MODEQ 24 /* %= */
# define PCC_INCR 25 /* ++ */
# define PCC_DECR 26 /* -- */
# define PCC_ASSIGN 27 /* = (these last 3 are stretching it) */
/*
* Bit operators.
*/
# define PCC_AND 28 /* & */
# define PCC_ANDEQ 29 /* &= */
/* Reserve a slot for 'unary &', jargon for PCC_ADDROF */
# define PCC_OR 31 /* | */
# define PCC_OREQ 32 /* |= */
# define PCC_ER 33 /* ^ */
# define PCC_EREQ 34 /* ^= */
# define PCC_LS 35 /* << */
# define PCC_LSEQ 36 /* <<= */
# define PCC_RS 37 /* >> */
# define PCC_RSEQ 38 /* >>= */
# define PCC_COMPL 39 /* ~ */
/*
* Booleans.
*/
# define PCC_EQ 40 /* == */
# define PCC_NE 41 /* != */
# define PCC_LE 42 /* <= */
# define PCC_LT 43 /* < */
# define PCC_GE 44 /* >= */
# define PCC_GT 45 /* > */
# define PCC_ULE 46 /* unsigned <= */
# define PCC_ULT 47 /* unsigned < */
# define PCC_UGE 48 /* unsigned >= */
# define PCC_UGT 49 /* unsigned > */
# define PCC_QUEST 50 /* ? (for conditional expressions) */
# define PCC_COLON 51 /* : (for conditional expressions) */
# define PCC_ANDAND 52 /* && */
# define PCC_OROR 53 /* || */
# define PCC_NOT 54 /* ! */
/*
* Function calls.
*/
# define PCC_CALL 55 /* call by value */
/* no ASG */
# define PCC_UCALL 57 /* call with no arguments */
# define PCC_FORTCALL 58 /* call by reference? */
/* no ASG */
# define PCC_UFORTCALL 60 /* ??? */
# ifdef INLINE
# define PCC_INLINE 61 /* inline function */
/* no ASG */
# define PCC_UINLINE 63 /* inline with no arguments */
# endif INLINE
/*
* Referencing and dereferencing.
*/
# define PCC_DEREF 20 /* * */
# define PCC_ADDROF 30 /* & */
/*
* Special structure operators.
*/
# define PCC_DOT 64 /* . */
# define PCC_STREF 65 /* -> */
# define PCC_STASG 66 /* structure assignment */
# define PCC_STARG 67 /* an argument of type structure */
# define PCC_STCALL 68 /* a function of type structure */
/* no ASG */
# define PCC_USTCALL 70 /* unary structure function */
/*
* Conversions.
*/
# define PCC_SCONV 71 /* scalar conversion */
# define PCC_PCONV 72 /* pointer conversion */
# define PCC_PMCONV 73 /* pointer multiply conversion */
# define PCC_PVCONV 74 /* pointer divide conversion */
# define PCC_CAST 75 /* redundant? */
/*
* Bracket types.
*/
# define PCC_LB 76 /* [ */
# define PCC_RB 77 /* ] */
/*
* Comma nodes.
*/
# define PCC_COMOP 78 /* , (in expressions) */
# define PCC_CM 79 /* , (in argument lists) */
/*
* Miscellaneous.
*/
# define PCC_FORCE 80 /* result of last expression goes in r0 */
# define PCC_GOTO 81 /* unconditional goto */
# define PCC_CBRANCH 82 /* goto label if !test */
# define PCC_RETURN 83 /* return from function */
# define PCC_INIT 84 /* initialized data */
# define PCC_TYPE 85 /* a type */
# define PCC_CLASS 86 /* a storage class */
# define PCC_MAXOP 86 /* highest numbered PCC op */
/*
* Special codes for interfacing to /lib/f1.
*/
# define PCCF_FORTOPS 150
# define PCCF_FTEXT 150 /* pass literal assembler text */
# define PCCF_FEXPR 151 /* a statement */
# define PCCF_FSWITCH 152 /* not implemented */
# define PCCF_FLBRAC 153 /* beginning of subroutine */
# define PCCF_FRBRAC 154 /* end of subroutine */
# define PCCF_FEOF 155 /* end of file */
# define PCCF_FARIF 156 /* not implemented */
# define PCCF_FLABEL 157 /* an f77 label */
# endif PCC_TOKENS
/*
* Types, as encoded in intermediate file cookies.
*/
# define PCCT_UNDEF 0
# define PCCT_FARG 1 /* function argument */
# define PCCT_CHAR 2
# define PCCT_SHORT 3
# define PCCT_INT 4
# define PCCT_LONG 5
# define PCCT_FLOAT 6
# define PCCT_DOUBLE 7
# define PCCT_STRTY 8
# define PCCT_UNIONTY 9
# define PCCT_ENUMTY 10
# define PCCT_MOETY 11 /* member of enum */
# define PCCT_UCHAR 12
# define PCCT_USHORT 13
# define PCCT_UNSIGNED 14
# define PCCT_ULONG 15
/*
* Type modifiers.
*/
# define PCCTM_PTR 020
# define PCCTM_FTN 040
# define PCCTM_ARY 060
# define PCCTM_BASETYPE 017
# define PCCTM_TYPESHIFT 2
/*
* Useful macros. 'PCCOM' macros apply to ops.
*/
# define PCCOM_ASG 1+
# define PCCOM_UNARY 2+
# define PCCOM_NOASG (-1)+
# define PCCOM_NOUNARY (-2)+
# define PCCM_TRIPLE(op, var, type) \
((op) | ((var) << 8) | (long) (type) << 16)
# define PCCM_TEXT(s) \
PCCM_TRIPLE(PCCF_FTEXT, (strlen(s) + 3) / 4, 0)
# define PCCM_ADDTYPE(t, m) \
((((t) &~ PCCTM_BASETYPE) << PCCTM_TYPESHIFT) | \
(m) | ((t) & PCCTM_BASETYPE))

View File

@@ -34,7 +34,7 @@ struct psout {
time_t o_cstime; /* u_cstime */
short o_pgrp; /* p_pgrp */
int o_sigs; /* sum of SIGINT & SIGQUIT,
* if == 2 proc is ignoring both.*/
if == 2 proc is ignoring both.*/
char o_comm[MAXCOMLEN+1]; /* u_comm */
char o_args[64]; /* best guess at args to process */
};

View File

@@ -15,6 +15,11 @@
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#define _PATH_PASSWD "/etc/passwd"
#define _PATH_SHADOW "/etc/shadow"
#define _PATH_MKPASSWD "/sbin/mkpasswd"
#define _PATH_PTMP "/etc/ptmp"
#define _PW_KEYBYNAME '0'
#define _PW_KEYBYUID '1'

View File

@@ -5,7 +5,6 @@
* not the System V one.
*/
#define NSUBEXP 10
typedef struct regexp {
char *startp[NSUBEXP];
char *endp[NSUBEXP];

42
include/stab.h Normal file
View File

@@ -0,0 +1,42 @@
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* @(#)stab.h 5.1 (Berkeley) 5/30/85
*/
/* IF YOU ADD DEFINITIONS, ADD THEM TO nm.c as well */
/*
* This file gives definitions supplementing <a.out.h>
* for permanent symbol table entries.
* These must have one of the N_STAB bits on,
* and are subject to relocation according to the masks in <a.out.h>.
*/
/*
* for symbolic debugger, sdb(1):
*/
#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */
#define N_STSYM 0x26 /* static symbol: name,,0,type,address */
#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */
#define N_RSYM 0x40 /* register sym: name,,0,type,register */
#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */
#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
#define N_SO 0x64 /* source file name: name,,0,0,address */
#define N_LSYM 0x80 /* local sym: name,,0,type,offset */
#define N_SOL 0x84 /* #included file name: name,,0,0,address */
#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */
#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */
#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */
#define N_BCOMM 0xe2 /* begin common: name,, */
#define N_ECOMM 0xe4 /* end common: name,, */
#define N_ECOML 0xe8 /* end common (local name): ,,address */
#define N_LENG 0xfe /* second stab entry with length information */
/*
* for the berkeley pascal compiler, pc(1):
*/
#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */

View File

@@ -1,22 +1,8 @@
#ifndef _STDDEF_H_
#define _STDDEF_H_
typedef int ptrdiff_t;
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
#ifndef NULL
#define NULL 0
#endif
/* 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
#endif /* _STDDEF_H_ */

View File

@@ -10,4 +10,6 @@ typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
#endif

View File

@@ -5,6 +5,8 @@
*/
#ifndef FILE
#include <sys/types.h>
#define BUFSIZ 1024
extern struct _iobuf {
int _cnt;
@@ -38,11 +40,6 @@ extern struct _iobuf {
#define NULL 0
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
#define FILE struct _iobuf
#define EOF (-1)

View File

@@ -43,6 +43,8 @@
#ifndef _STDLIB_H_
#define _STDLIB_H_
#include <sys/types.h>
#ifndef NULL
#define NULL 0
#endif
@@ -52,11 +54,6 @@
#define RAND_MAX 0x7fff
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
void abort (void);
int abs (int);
int atexit (void (*)(void));
@@ -86,7 +83,7 @@ char *_findenv (const char *name, int *offset);
void *alloca (size_t size);
int daemon (int, int);
char *devname (int dev, int type);
char *devname (dev_t dev, mode_t type);
int getloadavg (unsigned loadavg[], int nelem);
extern char *suboptarg; /* getsubopt(3) external variable */
@@ -96,10 +93,12 @@ 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
#endif /* _STDLIB_H_ */

View File

@@ -3,15 +3,12 @@
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#include <sys/types.h>
#ifndef NULL
#define NULL 0
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
char *strcat (char *, const char *);
char *strncat (char *, const char *, size_t);
char *strcpy (char *, const char *);

View File

@@ -30,10 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
#include <sys/types.h>
int bcmp(const void *, const void *, size_t);
void bcopy(const void *, void *, size_t);

View File

@@ -4,6 +4,8 @@
#include <sys/ioctl.h>
#include <stdint.h>
#define E_TERMCAP "/etc/termcap"
typedef unsigned char cc_t;
typedef unsigned int speed_t;
typedef unsigned int tcflag_t;
@@ -143,4 +145,5 @@ extern int tcsetattr(int, int, struct termios *);
#define TIOCSETAW _IOW(i, 92, struct termios)
#define TIOCSETAF _IOW(i, 92, struct termios)
#endif

View File

@@ -6,19 +6,7 @@
#ifndef _TIME_H
#define _TIME_H
#ifndef NULL
#define NULL 0
#endif
#ifndef _TIME_T
#define _TIME_T
typedef long time_t;
#endif
#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned size_t;
#endif
#include <sys/types.h> /* for time_t */
/*
* Structure returned by gmtime and localtime calls (see ctime(3)).
@@ -37,11 +25,9 @@ struct tm {
char *tm_zone;
};
struct tm *gmtime(const time_t *);
struct tm *localtime(const time_t *);
char *asctime(const struct tm *);
char *ctime(const time_t *);
time_t time(time_t *);
extern struct tm *gmtime(), *localtime();
extern char *asctime(), *ctime();
extern time_t time();
size_t strftime (char *s, size_t maxsize, const char *format,
const struct tm *timeptr);

View File

@@ -5,13 +5,14 @@
/*
** Information about time zone files.
*/
/* Time zone object file directory */
#define TZDIR "/usr/share/zoneinfo"
#define TZDEFAULT "/etc/localtime"
/*
** Each file begins with. . .
*/
struct tzhead {
char tzh_reserved[32]; /* reserved for future use */
char tzh_timecnt[4]; /* coded number of transition times */
@@ -95,4 +96,5 @@ struct tzhead {
** Accurate only for the past couple of centuries;
** that will probably do.
*/
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)

View File

@@ -12,6 +12,7 @@
* Place into the public domain.
* --------------------------------------------------
*/
#include <sys/types.h>
#define MAXSEGNO 16384 /* max number of segments in a space */
@@ -36,7 +37,8 @@ struct vseg { /* structure of a segment in memory */
struct vspace *s_vspace; /* which virtual space */
int s_lock_count;
int s_flags;
union {
union
{
int _winfo[WORDSPERSEG]; /* the actual segment */
char _cinfo[BYTESPERSEG];
} v_un;
@@ -57,7 +59,6 @@ void vmlock(), vmunlock(), vmclrseg(), vmmodify();
void vmflush(), vmclose();
typedef long VADDR;
#define VMMODIFY(seg) (seg->s_flags |= S_DIRTY)
#define VSEG(va) ((short)(va >> LOG2BPS))
#define VOFF(va) ((u_short)va % BYTESPERSEG)

View File

@@ -1,11 +1,21 @@
TOPSRC = $(shell cd ..; pwd)
SUBDIR = startup libc libm libcurses libtermlib libwiznet libreadline libgpanel
SUBDIR = startup libc libcurses libtermlib libwiznet
PROG = ar as aout ld nm ranlib size strip
CFLAGS = -m32 -Os -std=gnu89 -fno-builtin -g -Wall -DCROSS -I. \
-idirafter $(TOPSRC)/include \
-idirafter $(TOPSRC)/src/cmd/ar \
-idirafter $(TOPSRC)/src/cmd/as
# 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 \
@@ -26,28 +36,28 @@ clean:
for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) clean; done
ar: $(AR_OBJS)
$(CC) -m32 $(LDFLAGS) -o $@ $(AR_OBJS) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(AR_OBJS) $(LIBS)
as: as.o
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
aout: $(AOUT_OBJS)
$(CC) -m32 $(LDFLAGS) -o $@ $(AOUT_OBJS) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(AOUT_OBJS) $(LIBS)
ld: ld.o
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
nm: nm.o
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
ranlib: $(RANLIB_OBJS)
$(CC) -m32 $(LDFLAGS) -o $@ $(RANLIB_OBJS) $(LIBS)
$(CC) $(LDFLAGS) -o $@ $(RANLIB_OBJS) $(LIBS)
size: size.o
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
strip: strip.o
$(CC) -m32 $(LDFLAGS) -o $@ $< $(LIBS)
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
$(HEADERS):
-ln -s -f ../include/a.out.h .

View File

@@ -8,7 +8,7 @@ vpath %.c $(LIBCDIR)/mips/sys $(LIBCDIR)/gen $(LIBCDIR)/stdio \
$(LIBCDIR)/stdlib $(LIBCDIR)/string $(LIBCDIR)/inet \
$(LIBCDIR)/compat $(LIBCDIR)/runtime
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
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
@@ -87,16 +87,15 @@ 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 memccpy.o memchr.o \
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 times.o tmpnam.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 fixunssfsi.o \
floatunsisf.o
mulsf3.o negsf2.o subsf3.o sc_case.o
all: ../libc.a

View File

@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libcurses
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
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 \

View File

@@ -1,18 +0,0 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libgpanel
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = open.o clear.o pixel.o line.o rect.o fill.o fill_triangle.o \
circle.o image.o char.o text.o text_width.o
all: ../libgpanel.a
../libgpanel.a: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a

View File

@@ -1,18 +0,0 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libm
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = asin.o atan.o exp.o erf.o floor.o fmod.o hypot.o j0.o j1.o \
jn.o log.o pow.o sin.o sinh.o sqrt.o tan.o tanh.o
all: ../libm.a
../libm.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/libreadline
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = readline.o
all: ../libreadline.a
../libreadline.a: ../ar ../ranlib $(OBJS)
../ar rc $@ $(OBJS)
../ranlib $@
clean:
rm -f *~ *.o a.out *.a

View File

@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libtermlib
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = termcap.o tgoto.o tputs.o tcattr.o

View File

@@ -3,7 +3,7 @@ include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/libwiznet
CFLAGS = -Os -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o

View File

@@ -9,7 +9,7 @@ TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
vpath %.c $(TOPSRC)/src/startup-mips
CFLAGS = -Os -B$(TOPSRC)/lib/ -Wa,-x $(DEFS)
CFLAGS = -B$(TOPSRC)/lib/ -O -Wa,-x $(DEFS)
OBJS = ../crt0.o

View File

@@ -1,7 +0,0 @@
echo 'erase ^?, kill ^U, intr ^C'
stty dec
PATH=/bin:/sbin:/etc
export PATH
HOME=/
export HOME
export TERM

File diff suppressed because it is too large Load Diff

6
share/.gitignore vendored
View File

@@ -1,6 +1,4 @@
calendar
emg.keys
misc
re.help
misc
unixbench
zoneinfo
emg.keys

20
share/example/Makefile Normal file
View File

@@ -0,0 +1,20 @@
all: ashello echo chello stdarg skeleton
ashello: ashello.o
$(LD) ashello.o -o $@
chello: chello.o
$(CC) chello.o -o $@
echo: echo.o
$(LD) $@.o -o $@
stdarg: stdarg.o
$(CC) stdarg.o -o $@
skeleton: skeleton.o
$(CC) skeleton.o -o $@
clean:
rm -f *.o ashello echo chello stdarg skeleton *.dis *~

View File

@@ -0,0 +1,29 @@
TOPSRC = $(shell cd ../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
ASFLAGS += -DCROSS
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
all: chello cplus echo stdarg
chello: chello.o
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
${OBJDUMP} -S chello.elf > chello.dis
${SIZE} chello.elf
${ELF2AOUT} chello.elf $@
cplus: cplus.o
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
${OBJDUMP} -S cplus.elf > cplus.dis
${SIZE} cplus.elf
${ELF2AOUT} cplus.elf $@
echo: echo.o
${LD} ${ASLDFLAGS} -o $@.elf $@.o
${OBJDUMP} -S $@.elf > $@.dis
${SIZE} $@.elf
${ELF2AOUT} $@.elf $@
clean:
rm -f *.o *.elf ${MAN} chello cplus echo stdarg *.elf *.dis tags *~

View File

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

View File

@@ -1,17 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
ASFLAGS += -DCROSS
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
all: echo
echo: echo.o
${LD} ${ASLDFLAGS} -o $@.elf $@.o
${OBJDUMP} -S $@.elf > $@.dis
${SIZE} $@.elf
${ELF2AOUT} $@.elf $@
clean:
rm -f *.o *.elf ${MAN} echo *.elf *.dis tags *~

View File

@@ -1,50 +0,0 @@
CC = cc
PROG = hello stdarg skeleton primelist primesum test1 test2 test3 \
gpio adc rain q8 tetris lcd6
all: $(PROG)
hello: hello.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
stdarg: stdarg.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
skeleton: skeleton.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
primelist: primelist.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
primesum: primesum.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
gpio: gpio.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
adc: adc.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
rain: rain.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
q8: q8.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
tetris: tetris.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
lcd6: lcd6.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test1: test1.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test2: test2.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
test3: test3.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
clean:
rm -f *.o *~ $(PROG)

View File

@@ -1,27 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror -Wall
all: chello stdarg lcd6
chello: chello.o
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
${OBJDUMP} -S chello.elf > chello.dis
${SIZE} chello.elf
${ELF2AOUT} chello.elf $@
tetris: tetris.o
${CC} ${LDFLAGS} -o tetris.elf tetris.o ${LIBS}
${OBJDUMP} -S tetris.elf > tetris.dis
${SIZE} tetris.elf
${ELF2AOUT} tetris.elf $@
lcd6: lcd6.o
${CC} ${LDFLAGS} -o lcd6.elf lcd6.o ${LIBS}
${OBJDUMP} -S lcd6.elf > lcd6.dis
${SIZE} lcd6.elf
${ELF2AOUT} lcd6.elf $@
clean:
rm -f *.o *.elf ${MAN} chello stdarg lcd6 *.elf *.dis tags *~

View File

@@ -1,287 +0,0 @@
/*
* Demo for 6 digit LCD module based on HT1261 controller.
* Based on example sources from http://www.canton-electronics.com
*
* Copyright (C) 2015 Serge Vakulenko
*
* 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 <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/gpio.h>
/*
* Digits, decimal dots and battery levels:
* A B C D E F
* -- -- -- -- -- -- z
* | | | | | | | | | | | | y
* -- -- -- -- -- -- x
* | | | | | | | | | | | |
* -- -- -- c -- d -- e --
*
* Memory map:
* Byte 0, bits 0-6 - segments of digit 'F'
* Byte 0, bit 7 - decimal dot 'e'
* Byte 1, bits 0-6 - segments of digit 'E'
* Byte 1, bit 7 - decimal dot 'd'
* Byte 2, bits 0-6 - segments of digit 'D'
* Byte 2, bit 7 - decimal dot 'c'
* Byte 3, bits 0-6 - segments of digit 'C'
* Byte 3, bit 7 - battery level 'x'
* Byte 4, bits 0-6 - segments of digit 'B'
* Byte 4, bit 7 - battery level 'y'
* Byte 5, bits 0-6 - segments of digit 'A'
* Byte 5, bit 7 - battery level 'z'
*
* Segments are mapped to bits 0-6:
* --4--
* 0---5
* --1--
* 2---6
* --3--
*/
/*
* Signal assignment.
* LED modulee is connected to pins 16,17,18 of Fubarino SD board.
*
* Fubarino PIC32 LED module
* --------------------------
* 16 RE0 CS
* 17 RE1 WR
* 18 RE2 DATA
*/
#define gpio_cs_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 0)
#define gpio_cs_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 0)
#define gpio_wr_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 1)
#define gpio_wr_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 1)
#define gpio_data_clear() ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 2)
#define gpio_data_set() ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 2)
/*
* HT1621 commands
*/
#define HT_SYS_DIS 0x00 /* Turn off system osc and bias generator */
#define HT_SYS_EN 0x01 /* Turn on system oscillator */
#define HT_LCD_OFF 0x02 /* Turn off LCD bias generator */
#define HT_LCD_ON 0x03 /* Turn on LCD bias generator */
#define HT_CLOCK_XTAL 0x14 /* Crystal 32kHz */
#define HT_CLOCK_RC 0x18 /* On-chip RC oscillator 256kHz */
#define HT_CLOCK_EXT 0x1c /* External clock */
#define HT_BIAS_1_3 0x21 /* LCD 1/3 bias option, 2 commons default */
#define HT_COMMONS_3 0x04 /* 3 commons option */
#define HT_COMMONS_4 0x08 /* 4 commons option */
/*
* Mapping of symbols to segments.
* 0, 1, 2, 3, 4, 5, 6, 7,
* 8, 9, A, b, C, c, d, E,
* F, H, h, L, n, N, o, P,
* r, t, U, -, ,
*/
const char char_to_segm[] = {
0x7D, 0x60, 0x3E, 0x7A, 0x63, 0x5B, 0x5F, 0x70,
0x7F, 0x7B, 0x77, 0x4F, 0x1D, 0x0E, 0x6E, 0x1F,
0x17, 0x67, 0x47, 0x0D, 0x46, 0x75, 0x37, 0x06,
0x0F, 0x6D, 0x02, 0x00,
};
/*
* File descriptor for GPIO driver.
*/
int gpio;
/*
* Suspend the process for some amount of milliseconds.
*/
void mdelay(unsigned msec)
{
usleep(msec * 1000);
}
/*
* Send a series of bits to HT1621.
* Up to 8 bits, high bit first.
* Max clock rate is 150kHz.
*/
void ht_send(int nbits, int data)
{
data <<= (8 - nbits);
gpio_wr_clear();
while (nbits-- > 0) {
if (data & 0x80)
gpio_data_set();
else
gpio_data_clear();
gpio_wr_set();
gpio_wr_clear();
data <<= 1;
}
}
/*
* Send command to HT1621.
*/
void ht_cmd(int command)
{
gpio_cs_clear();
ht_send(3, 0x4); /* Mode "100" */
ht_send(8, command);
gpio_cs_set();
}
/*
* Send data and command.
*/
void ht_write(int addr, int data)
{
gpio_cs_clear();
ht_send(3, 0x5); /* Mode "101" */
ht_send(6, addr << 1); /* Half-byte address 6 bits */
ht_send(8, data); /* Data 8 bits */
gpio_cs_set();
}
/*
* Initialize LCD controller.
*/
void lcd_init()
{
/* Open GPIO driver. */
gpio = open("/dev/porta", 1);
if (gpio < 0) {
perror("/dev/porta");
exit(-1);
}
/* Configure pins RE0-RE2 as outputs. */
ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, 0x07);
gpio_cs_set();
gpio_wr_clear();
/* Setup appropriate HT1621 mode. */
ht_cmd(HT_SYS_EN);
ht_cmd(HT_CLOCK_RC);
ht_cmd(HT_BIAS_1_3 | HT_COMMONS_4);
ht_cmd(HT_LCD_ON);
}
/*
* Set display memory to given value.
*/
void lcd_clear(int value)
{
int i;
for (i=0; i<6; i++) {
ht_write(i, value);
}
}
/*
* LCD on/off.
*/
void lcd_enable(int on)
{
if (on)
ht_cmd(HT_LCD_ON);
else
ht_cmd(HT_LCD_OFF);
}
/*
* Display data.
* val - Data to be displayed, 0-999999
* dot - Display decimal dot, 0-3
* bat - Battery level, 0-3
*/
void lcd_display(unsigned val, int dot, int bat)
{
int i, byte[6];
/* Set numeric value. */
byte[5] = char_to_segm[val / 100000];
byte[4] = char_to_segm[(val / 10000) % 10];
byte[3] = char_to_segm[(val / 1000) % 10];
byte[2] = char_to_segm[(val / 100) % 10];
byte[1] = char_to_segm[(val / 10) % 10];
byte[0] = char_to_segm[val % 10];
/* Enable decimal dot/ */
switch (dot) {
case 1:
byte[0] |= 1 << 7;
break;
case 2:
byte[1] |= 1 << 7;
break;
case 3:
byte[2] |= 1 << 7;
break;
default:
break;
}
if (bat > 0)
byte[3] |= 1 << 7;
if (bat > 1)
byte[4] |= 1 << 7;
if (bat > 2)
byte[5] |= 1 << 7;
for (i=0; i<6; i++) {
ht_write(i, byte[i]);
}
}
int main()
{
int i;
/* Initialize hardware. */
lcd_init();
/* Blink all segments twice. */
lcd_clear(0xff);
mdelay(1000);
lcd_clear(0);
mdelay(1000);
lcd_clear(0xff);
mdelay(1000);
lcd_clear(0);
mdelay(1000);
/* Show all characters on all segments. */
for (i=0; i<sizeof(char_to_segm); i++) {
lcd_clear(char_to_segm[i]);
mdelay(200);
}
lcd_clear(0);
/* Display counter 0 to 999999. */
for (;;) {
for (i=0; i<999999; i++) {
lcd_display(i, i/10%4, i/10%4);
mdelay(100);
}
}
return 0;
}

View File

@@ -1,666 +0,0 @@
/*
* Tetris (C) Copyright 1995, Vadim Antonov
* Port to RetroBSD (C) 2015, Serge Vakulenko
*
* This program is designed to run on Olimex Duinomite board
* with SainSmart Graphic LCD4884 shield, modified for 3.3V.
*
* 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/gpio.h>
#define PITWIDTH 12
#define PITDEPTH 21
#define NSHAPES 7
#define NBLOCKS 5
#define FIN 999
typedef struct {
int x, y;
} coord_t;
typedef struct {
int dx, dy;
coord_t p[NBLOCKS];
} shape_t;
const shape_t shape [NSHAPES] = {
/* OOOO */ { 0, 3, { {0,0}, {0,1}, {0,2}, {0,3}, {FIN,FIN} } },
/* O */ { 1, 2, { {0,0}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } },
/* OOO */
/* O */ { 1, 2, { {0,1}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } },
/* OOO */
/* O */ { 1, 2, { {0,2}, {1,0}, {1,1}, {1,2}, {FIN,FIN} } },
/* OOO */
/* OO */ { 1, 2, { {0,0}, {0,1}, {1,1}, {1,2}, {FIN,FIN} } },
/* OO */
/* OO */ { 1, 2, { {0,1}, {0,2}, {1,0}, {1,1}, {FIN,FIN} } },
/* OO */
/* OO */ { 1, 1, { {0,0}, {0,1}, {1,0}, {1,1}, {FIN,FIN} } },
/* OO */
};
int pit [PITDEPTH+1] [PITWIDTH];
int pitcnt [PITDEPTH];
coord_t old [NBLOCKS], new [NBLOCKS], chk [NBLOCKS];
int gpio; /* File descriptor of GPIO driver. */
int adc3; /* File descriptor of ADC3 driver. */
/*-------------------------------------------------------------
* Definitions for a "digital" joystick at A0 analog input.
* Button values are determined by resistors on a board.
*/
enum {
JOYSTICK_LEFT,
JOYSTICK_SELECT,
JOYSTICK_DOWN,
JOYSTICK_RIGHT,
JOYSTICK_UP,
JOYSTICK_IDLE = -1,
};
/*
* Initialize ADC for a joystick.
*/
void joystick_init()
{
/* Open ADC driver. */
adc3 = open("/dev/adc3", 0);
if (adc3 < 0) {
perror("/dev/adc3");
exit(-1);
}
}
/*
* Get a state of joystick.
* Convert ADC value to key number.
* Input buttons are connected to a series network of resistors:
* GND - 3.3k - 1k - 620 - 330 - 2k - +3.3V
* Expected values are:
* 0 - 144 - 329 - 506 - 741 - 1023
*/
int joystick_get()
{
static const unsigned level[5] = { 72, 236, 417, 623, 882 };
unsigned input, k;
char buf[16];
if (read(adc3, buf, sizeof(buf)) <= 0) {
perror("adc");
exit(-1);
}
input = strtol(buf, 0, 10);
for (k=0; k<5; k++) {
if (input < level[k]) {
return k;
}
}
return JOYSTICK_IDLE;
}
/*-------------------------------------------------------------
* Routines for Nokia 5110 display.
* See Philips PCD8544 datasheet.
*/
#define NROW 48
#define NCOL 84
/*
* Pinout for SainSmart Graphic LCD4884 Shield.
*/
#define MASKE_LCD_SCK (1 << 2) /* signal D2, pin RE2 */
#define MASKE_LCD_MOSI (1 << 3) /* signal D3, pin RE3 */
#define MASKE_LCD_DC (1 << 4) /* signal D4, pin RE4 */
#define MASKE_LCD_CS (1 << 5) /* signal D5, pin RE5 */
#define MASKE_LCD_RST (1 << 6) /* signal D6, pin RE6 */
#define MASKE_LCD_BL (1 << 7) /* signal D7, pin RE7 */
static unsigned char gpanel_screen [NROW*NCOL/8];
int gpanel_row, gpanel_col;
static void lcd_cs(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_CS);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_CS);
}
}
static void lcd_rst(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_RST);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_RST);
}
}
static void lcd_dc(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_DC);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_DC);
}
}
static void lcd_bl(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_BL);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_BL);
}
}
static void lcd_mosi(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_MOSI);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_MOSI);
}
}
static void lcd_sck(unsigned on)
{
if (on) {
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_SCK);
} else {
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_SCK);
}
}
static void lcd_write(unsigned byte, unsigned data_flag)
{
unsigned i;
lcd_cs(0);
lcd_dc(data_flag);
for (i=0; i<8; i++, byte<<=1) {
lcd_mosi(byte & 0x80); /* SDIN = bit[i] */
lcd_sck(0); /* SCLK = 0 */
lcd_sck(1); /* SCLK = 1 */
}
lcd_cs(1);
}
/*
* Set up hardware for communication to Nokia 5110 LCD Display.
* Do not clear the display.
* Leave backlight turned off.
*/
void gpanel_init()
{
gpanel_row = 0;
gpanel_col = 0;
/* Open GPIO driver. */
gpio = open("/dev/porta", 0);
if (gpio < 0) {
perror("/dev/porta");
exit(-1);
}
/*
* Set pins as outputs.
*/
ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, MASKE_LCD_SCK |
MASKE_LCD_MOSI | MASKE_LCD_DC | MASKE_LCD_CS |
MASKE_LCD_RST | MASKE_LCD_BL);
ioctl(gpio, GPIO_PORTE | GPIO_SET, MASKE_LCD_RST | MASKE_LCD_CS);
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, MASKE_LCD_SCK |
MASKE_LCD_MOSI | MASKE_LCD_DC | MASKE_LCD_BL);
/* Turn off backlight. */
lcd_bl(0);
/* Reset the display. */
lcd_rst(0);
usleep(10000); // need 1 usec
lcd_rst(1);
usleep(10000); // need 1 usec
lcd_write(0x21, 0); // Enable extended instruction set
lcd_write(0xbf, 0); // Set Vop - contrast level
lcd_write(0x04, 0); // Set temperature coefficient to 0
lcd_write(0x14, 0); // Set bias to 4
lcd_write(0x20, 0); // Back to normal instruction set
lcd_write(0x0c, 0); // Set normal mode
/* Enable backlight. */
lcd_bl(1);
}
/*
* Clear the the LCD screen.
*/
void gpanel_clear()
{
unsigned i;
/* Clear data */
lcd_write(0x40, 0);
lcd_write(0x80, 0);
for (i=0; i<NROW*NCOL/8; i++) {
gpanel_screen[i] = 0;
lcd_write(0, 1);
}
gpanel_row = 0;
gpanel_col = 0;
}
/*
* Lights a single pixel in the specified color
* at the specified x and y addresses
*/
void gpanel_pixel(int x, int y, int color)
{
unsigned char *data;
if (x >= NCOL || y >= NROW)
return;
data = &gpanel_screen [(y >> 3) * NCOL + x];
if (color)
*data |= 1 << (y & 7);
else
*data &= ~(1 << (y & 7));
lcd_write(0x40 | (y >> 3), 0);
lcd_write(0x80 | x, 0);
lcd_write(*data, 1);
}
/*
* Draw a filled rectangle in the specified color from (x1,y1) to (x2,y2).
*
* The best way to fill a rectangle is to take advantage of the "wrap-around" featute
* built into the Philips PCF8833 controller. By defining a drawing box, the memory can
* be simply filled by successive memory writes until all pixels have been illuminated.
*/
void gpanel_rect_filled(int x0, int y0, int x1, int y1, int color)
{
/* Temporary solution */
int xmin, xmax, ymin, ymax, x, y;
/* calculate the min and max for x and y directions */
if (x0 <= x1) {
xmin = x0;
xmax = x1;
} else {
xmin = x1;
xmax = x0;
}
if (y0 <= y1) {
ymin = y0;
ymax = y1;
} else {
ymin = y1;
ymax = y0;
}
for (y=ymin; y<=ymax; y++)
for (x=xmin; x<=xmax; x++)
gpanel_pixel(x, y, color);
}
/*-------------------------------------------------------------
* Output piece coordinates given its center and angle
*/
void translate(const shape_t *t, const coord_t *c, int a, coord_t *res)
{
coord_t org, tmp;
int yw, xw, i;
if (a & 1) { /* 90 deg */
xw = t->dy;
yw = t->dx;
} else {
xw = t->dx;
yw = t->dy;
}
org = *c;
org.x -= (xw + 1) / 2;
org.y -= yw / 2;
if (org.y < 0)
org.y = 0;
if (org.y + yw >= PITWIDTH && c->y <= PITWIDTH)
org.y = PITWIDTH-1 - yw;
for (i=0; t->p[i].x!=FIN; i++) {
switch (a) {
case 0:
res[i].x = t->p[i].x;
res[i].y = t->p[i].y;
break;
case 3:
res[i].x = xw - t->p[i].y;
res[i].y = t->p[i].x;
break;
case 2:
res[i].x = xw - t->p[i].x;
res[i].y = yw - t->p[i].y;
break;
case 1:
res[i].x = t->p[i].y;
res[i].y = yw - t->p[i].x;
}
res[i].x += org.x;
res[i].y += org.y;
}
res[i].x = res[i].y = FIN;
do {
xw = 0;
for (i=0; res[i+1].x!=FIN; i++) {
if (res[i].x < res[i+1].x)
continue;
if (res[i].x == res[i+1].x && res[i].y <= res[i+1].y)
continue;
xw++;
tmp = res[i];
res[i] = res[i+1];
res[i+1] = tmp;
}
} while (xw);
}
/*
* Draw the block
*/
void draw_block(int h, int w, int visible)
{
h *= 4;
w *= 4;
if (visible) {
gpanel_rect_filled(NCOL-1 - h, w, NCOL-1 - (h + 3), w + 3, 1);
} else {
gpanel_rect_filled(NCOL-1 - h, w, NCOL-1 - (h + 3), w + 3, 0);
if (h == (PITDEPTH-1)*5)
gpanel_pixel(NCOL-1 - (h + 3), w + 2, 1);
if (w == 0)
gpanel_pixel(NCOL-1 - (h + 2), w, 1);
else if (w % 16 == 12)
gpanel_pixel(NCOL-1 - (h + 2), w + 3, 1);
}
}
/*
* Move the piece
*/
void move(coord_t *old, coord_t *new)
{
for (;;) {
if (old->x == FIN) {
draw: if (new->x == FIN)
break;
if (new->x >= 0)
draw_block(new->x, new->y, 1);
new++;
continue;
}
if (new->x == FIN) {
clear: if (old->x >= 0)
draw_block(old->x, old->y, 0);
old++;
continue;
}
if (old->x > new->x)
goto draw;
if (old->x < new->x)
goto clear;
if (old->y > new->y)
goto draw;
if (old->y != new->y)
goto clear;
/* old & new at the same place */
old++;
new++;
}
}
/*
* Draw the pit
*/
void clear()
{
int h, w;
for (h=0; h<PITDEPTH; h++) {
for (w=0; w<PITWIDTH; w++) {
draw_block(h, w, 0);
pit[h][w] = 0;
}
pitcnt[h] = 0;
}
for (w=0; w<PITWIDTH; w++)
pit[PITDEPTH][w] = 1;
}
/*
* The piece reached the bottom
*/
void stopped(coord_t *c)
{
int h, nfull, w, k;
/* Count the full lines */
nfull = 0;
for (; c->x!=FIN; c++) {
if (c->x <= 0) {
/* Game over. */
clear();
return;
}
pit[c->x][c->y] = 1;
++pitcnt[c->x];
if (pitcnt[c->x] == PITWIDTH)
nfull++;
}
if (! nfull)
return;
/* Clear upper nfull lines */
for (h=0; h<nfull; h++) {
for (w=0; w<PITWIDTH; w++) {
if (pit[h][w]) {
draw_block(h, w, 0);
}
}
}
/* Move lines down */
k = nfull;
for (h=nfull; h<PITDEPTH && k>0; h++) {
if (pitcnt[h-k] == PITWIDTH) {
k--;
h--;
continue;
}
for (w=0; w<PITWIDTH; w++) {
if (pit[h][w] != pit[h-k][w]) {
draw_block(h, w, pit[h-k][w]);
}
}
}
/* Now fix the pit contents */
for (h=PITDEPTH-1; h>0; h--) {
if (pitcnt[h] != PITWIDTH)
continue;
memmove(pit[0]+PITWIDTH, pit[0], h * sizeof(pit[0]));
memset(pit[0], 0, sizeof(pit[0]));
memmove(pitcnt+1, pitcnt, h * sizeof(pitcnt[0]));
pitcnt[0] = 0;
h++;
}
}
int main()
{
int ptype; /* Piece type */
int angle, anew; /* Angle */
int msec; /* Timeout */
coord_t c, cnew, *cp;
unsigned up_pressed = 0, left_pressed = 0;
unsigned right_pressed = 0, down_pressed = 0;
joystick_init();
gpanel_init();
gpanel_clear();
/* Draw the pit */
clear();
newpiece:
ptype = rand() % NSHAPES;
angle = rand() % 3;
c.y = PITWIDTH/2 - 1;
for (c.x= -2; ; c.x++) {
translate(&shape[ptype], &c, angle, new);
for (cp=new; cp->x!=FIN; cp++) {
if (cp->x >= 0)
goto ok;
}
}
ok:
/* Draw new piece */
for (cp=new; cp->x!=FIN; cp++) {
if (cp->x >= 0) {
draw_block(cp->x, cp->y, 1);
}
}
memcpy(old, new, sizeof old);
msec = 500;
for (;;) {
cnew = c;
anew = angle;
if (msec <= 0) {
/* Timeout: move down */
msec = 500;
cnew.x++;
translate(&shape[ptype], &cnew, anew, chk);
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->x >= 0 && pit[cp->x][cp->y]) {
stopped(new);
goto newpiece;
}
}
goto check;
}
int key = joystick_get();
if (key != JOYSTICK_RIGHT)
right_pressed = 0;
else if (! right_pressed) {
right_pressed = 1;
/* Right: rotate */
if (--anew < 0)
anew = 3;
translate(&shape[ptype], &cnew, anew, chk);
goto check;
}
if (key != JOYSTICK_UP)
up_pressed = 0;
else if (! up_pressed) {
up_pressed = 1;
/* Up: move left. */
if (cnew.y <= 0)
continue;
cnew.y--;
translate(&shape[ptype], &cnew, anew, chk);
goto check;
}
if (key != JOYSTICK_DOWN)
down_pressed = 0;
else if (! down_pressed) {
down_pressed = 1;
/* Down: move right */
if (cnew.y >= PITWIDTH-1)
continue;
cnew.y++;
translate(&shape[ptype], &cnew, anew, chk);
goto check;
}
if (key != JOYSTICK_LEFT)
left_pressed = 0;
else if (! left_pressed) {
left_pressed = 1;
/* Right: drop */
for (;;) {
cnew.x++;
translate(&shape[ptype], &cnew, anew, chk);
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->x >= 0 && pit[cp->x][cp->y]) {
cnew.x--;
translate(&shape[ptype], &cnew, anew, chk);
move(new, chk);
stopped(chk);
goto newpiece;
}
}
}
}
usleep(10000);
msec -= 10;
continue;
check:
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->y < 0 || cp->y >= PITWIDTH)
goto done;
}
for (cp=chk; cp->x!=FIN; cp++) {
if (cp->x >= 0 && pit[cp->x][cp->y])
goto done;
}
c = cnew;
angle = anew;
memcpy(old, new, sizeof old);
memcpy(new, chk, sizeof new);
move(old, new);
done: ;
}
}

View File

@@ -1,15 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
all: cplus
cplus: cplus.o
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
${OBJDUMP} -S cplus.elf > cplus.dis
${SIZE} cplus.elf
${ELF2AOUT} cplus.elf $@
clean:
rm -f *.o *.elf ${MAN} cplus *.elf *.dis tags *~

View File

@@ -1,24 +0,0 @@
PROG = all backlight cube demo
# Duinomite board
#OBJS = duinomite.o
# Fubarino board
OBJS = fubarino.o
all: $(PROG)
all: all.c $(OBJS)
cc $@.c $(OBJS) -o $@
backlight: backlight.c $(OBJS)
cc $@.c $(OBJS) -o $@
cube: cube.c $(OBJS)
cc $@.c $(OBJS) -o $@
demo: demo.c $(OBJS)
cc $@.c $(OBJS) -o $@
clean:
rm -f *.o *~ $(PROG)

View File

@@ -1,16 +0,0 @@
TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
CFLAGS += -Werror
LIBS += -lm
#all: demo
demo: demo.o fubarino.o
${CC} ${LDFLAGS} -o demo.elf demo.o fubarino.o ${LIBS}
${OBJDUMP} -S demo.elf > demo.dis
${SIZE} demo.elf
${ELF2AOUT} demo.elf $@
clean:
rm -f *.o *.elf ${MAN} demo *.elf *.dis tags *~

View File

@@ -1 +0,0 @@
Examples for LED cube 8x8x8.

View File

@@ -1,25 +0,0 @@
/*
* Demo for LED cube 8x8x8.
* Turn on all LEDs.
*/
#include <stdio.h>
#include "cube.h"
int main()
{
static unsigned char data[8] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
int i;
gpio_init();
gpio_le(0);
gpio_plane(data);
gpio_ext(1);
for (;;) {
for (i=0; i<8; i++) {
gpio_layer(i);
}
}
return 0;
}

View File

@@ -1,20 +0,0 @@
/*
* Demo for LED cube 8x8x8.
* Test backlight LEDs.
*/
#include <stdio.h>
#include "cube.h"
int main()
{
gpio_init();
for (;;) {
gpio_backlight_upper(1);
usleep(500000);
gpio_backlight_upper(0);
gpio_backlight_lower(1);
usleep(500000);
gpio_backlight_lower(0);
}
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -1,73 +0,0 @@
/*
* Demo for LED cube 8x8x8.
* Switch between two static images.
*/
#include <stdio.h>
#include <sys/time.h>
#include "cube.h"
void display(int duration, unsigned char *data)
{
struct timeval t0, now;
int z, msec;
gettimeofday(&t0, 0);
z = 0;
for (;;) {
/* Send layer data. Latch is active,
* so previous layer is still displayed. */
gpio_plane(data + z*CUBE_SIZE);
/* Disable output, activate latch,
* switch to next layer. */
gpio_oe(0);
gpio_le(0);
gpio_le(1);
gpio_layer(z);
gpio_oe(1);
/* Next layer. */
z++;
if (z >= CUBE_SIZE) {
z = 0;
/* Check time. */
gettimeofday(&now, 0);
msec = (now.tv_sec - t0.tv_sec) * 1000;
msec += (now.tv_usec - t0.tv_usec) / 1000;
if (msec >= duration)
break;
}
}
}
int main()
{
static unsigned char foo[64] = {
0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff,
0x81, 0, 0, 0, 0, 0, 0, 0x81,
0x81, 0, 0, 0, 0, 0, 0, 0x81,
0x81, 0, 0, 0, 0, 0, 0, 0x81,
0x81, 0, 0, 0, 0, 0, 0, 0x81,
0x81, 0, 0, 0, 0, 0, 0, 0x81,
0x81, 0, 0, 0, 0, 0, 0, 0x81,
0xff, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0xff,
};
static unsigned char bar[64] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e, 0,
0, 0x42, 0, 0, 0, 0, 0x42, 0,
0, 0x42, 0, 0, 0, 0, 0x42, 0,
0, 0x42, 0, 0, 0, 0, 0x42, 0,
0, 0x42, 0, 0, 0, 0, 0x42, 0,
0, 0x7e, 0x42, 0x42, 0x42, 0x42, 0x7e, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
gpio_init();
gpio_ext(1);
for (;;) {
display(500, foo);
display(500, bar);
}
return 0;
}

View File

@@ -1,13 +0,0 @@
/*
* Interface to LED cube 8x8x8.
*/
#define CUBE_SIZE 8
void gpio_init(void);
void gpio_ext(int on);
void gpio_oe(int active);
void gpio_le(int active);
void gpio_backlight_upper(int on);
void gpio_backlight_lower(int on);
void gpio_layer(int z);
void gpio_plane(unsigned char *data);

File diff suppressed because it is too large Load Diff

View File

@@ -1,145 +0,0 @@
/*
* Interface to LED cube 8x8x8.
* The cube is connected to pins D0-D9 of Duinomite board.
*
* Pin PIC32 Function
* ---------------
* D0 RE0 Y0 \
* D1 RE1 Y1 | Layer select
* D2 RE2 Y2 /
* D3 RE3 Y3 - Upper backlignt
* D4 RE4 Y4 - Lower backlight
* D5 RE5 SDI - Serial data \
* D6 RE6 CLK - Clock | to shift registers
* D7 RE7 /LE - Latch enable |
* D8 RB11 /OE - Output enable /
* D10 RD11 EXT - Unknown
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/gpio.h>
#include "cube.h"
static int gpio;
void gpio_init()
{
char *devname = "/dev/porta";
/* Open GPIO driver. */
gpio = open(devname, 1);
if (gpio < 0) {
perror(devname);
exit(-1);
}
/* Configure pins RE0-RE7, RB11 and RD11 as output. */
ioctl(gpio, GPIO_PORTE | GPIO_CONFOUT, 0xff);
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 0xff);
ioctl(gpio, GPIO_PORTB | GPIO_CONFOUT, 1 << 11);
ioctl(gpio, GPIO_PORTB | GPIO_CLEAR, 1 << 11);
ioctl(gpio, GPIO_PORTD | GPIO_CONFOUT, 1 << 11);
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 11);
}
void gpio_ext(int on)
{
/* EXT signal at RD11. */
if (on)
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 11);
else
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 11);
}
void gpio_oe(int active)
{
/* /OE signal at RB11, active low. */
if (active)
ioctl(gpio, GPIO_PORTB | GPIO_CLEAR, 1 << 11);
else
ioctl(gpio, GPIO_PORTB | GPIO_SET, 1 << 11);
}
void gpio_le(int active)
{
/* /LE signal at RE7, active low. */
if (active)
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 7);
else
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 7);
}
void gpio_backlight_upper(int on)
{
/* Y4 signal at RE4. */
if (on)
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 4);
else
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 4);
}
void gpio_backlight_lower(int on)
{
/* Y3 signal at RE3. */
if (on)
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 3);
else
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 3);
}
void gpio_layer(int z)
{
/* Y0-Y2 signals at RE0-RE23. */
if (z & 1)
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 0);
else
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 0);
if (z & 2)
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 1);
else
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 1);
if (z & 4)
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 2);
else
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 2);
}
void gpio_plane(unsigned char *data)
{
int i, n, val;
/* Send 8 bytes of tada to shift registers. */
for (i=0; i<8; i+=2) {
val = *data++;
for (n=0; n<8; n++) {
/* SDI signal at RE5. */
if (val & 0x80)
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 5);
else
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 5);
/* CLK signal at RE6. */
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 6);
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 6);
val <<= 1;
}
val = *data++;
for (n=0; n<8; n++) {
/* SDI signal at RE5. */
if (val & 1)
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 5);
else
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 5);
/* CLK signal at RE6. */
ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 6);
ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 6);
val >>= 1;
}
}
}

View File

@@ -1,143 +0,0 @@
/*
* Interface to LED cube 8x8x8.
* The cube is connected to pins 4-13 of Fubarino board.
*
* Pin PIC32 Function
* ---------------
* 4 RD0 Y0 \
* 5 RC13 Y1 | Layer select
* 6 RC14 Y2 /
* 7 RD1 Y3 - Upper backlignt
* 8 RD2 Y4 - Lower backlight
* 9 RD3 SDI - Serial data \
* 10 RD4 CLK - Clock | to shift registers
* 11 RD5 /LE - Latch enable |
* 12 RD6 /OE - Output enable /
* 13 RD7 EXT - Unknown
*/
#include <stdlib.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/gpio.h>
#include "cube.h"
static int gpio;
void gpio_init()
{
char *devname = "/dev/porta";
/* Open GPIO driver. */
gpio = open(devname, 1);
if (gpio < 0) {
perror(devname);
exit(-1);
}
/* Configure pins RD0-RD7, RC13 and RC14 as output. */
ioctl(gpio, GPIO_PORTD | GPIO_CONFOUT, 0xff);
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 0xff);
ioctl(gpio, GPIO_PORTC | GPIO_CONFOUT, 3 << 13);
ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 3 << 13);
}
void gpio_ext(int on)
{
/* EXT signal at RD7. */
if (on)
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 7);
else
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 7);
}
void gpio_oe(int active)
{
/* /OE signal at RD6, active low. */
if (active)
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 6);
else
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 6);
}
void gpio_le(int active)
{
/* /LE signal at RD5, active low. */
if (active)
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 5);
else
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 5);
}
void gpio_backlight_upper(int on)
{
/* Y4 signal at RD2. */
if (on)
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 2);
else
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 2);
}
void gpio_backlight_lower(int on)
{
/* Y3 signal at RD1. */
if (on)
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 1);
else
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 1);
}
void gpio_layer(int z)
{
/* Y0-Y2 signals at RD0, RC13, RC14. */
if (z & 1)
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 0);
else
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 0);
if (z & 2)
ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 1 << 13);
else
ioctl(gpio, GPIO_PORTC | GPIO_SET, 1 << 13);
if (z & 4)
ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 1 << 14);
else
ioctl(gpio, GPIO_PORTC | GPIO_SET, 1 << 14);
}
void gpio_plane(unsigned char *data)
{
int i, n, val;
/* Send 8 bytes of tada to shift registers. */
for (i=0; i<8; i+=2) {
val = *data++;
for (n=0; n<8; n++) {
/* SDI signal at RD3. */
if (val & 0x80)
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 3);
else
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 3);
/* CLK signal at RD4. */
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 4);
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 4);
val <<= 1;
}
val = *data++;
for (n=0; n<8; n++) {
/* SDI signal at RD3. */
if (val & 1)
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 3);
else
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 3);
/* CLK signal at RD4. */
ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 4);
ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 4);
val >>= 1;
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 264 KiB

View File

@@ -1,20 +0,0 @@
PROG = flip jump timer typetext
#CFLAGS = -DNCURSES_OPAQUE=0
LIBS = -lcurses -ltermlib
all: $(PROG)
clean:
rm -f *.o *~ $(PROG)
flip: flip.c
cc $(CFLAGS) -o $@ $@.c $(LIBS)
jump: jump.c
cc $(CFLAGS) -o $@ $@.c $(LIBS)
timer: timer.c
cc $(CFLAGS) -o $@ $@.c $(LIBS)
typetext: typetext.c
cc $(CFLAGS) -o $@ $@.c $(LIBS)

View File

@@ -1,57 +0,0 @@
#include <curses.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define W_LINES 10
#define W_COLS 30
#define center(WIND,LN,TEXT) \
mvwaddstr((WIND), (LN), (W_COLS - strlen(TEXT))/2, (TEXT))
void die(int sig)
{
signal(sig, SIG_IGN);
clear();
refresh();
endwin();
exit(0);
}
int main()
{
WINDOW *win1, *win2;
if (! initscr()) {
fprintf(stderr, "Sorry, unknown terminal.\n");
exit(1);
}
signal(SIGINT, die);
signal(SIGQUIT, die);
signal(SIGHUP, die);
noecho();
win1 = newwin(W_LINES, W_COLS, ((LINES - W_LINES)/2), ((COLS - W_COLS)/2));
win2 = newwin(W_LINES, W_COLS, ((LINES - W_LINES)/2 + 4), ((COLS - W_COLS)/2 + 10));
scrollok(win1, FALSE);
scrollok(win2, FALSE);
box(win1, '*', '*');
box(win2, '*', '*');
center(win1, 3, "This is window 1");
center(win2, 3, "This is window 2");
for (;;) {
wrefresh(win1);
touchwin(win1);
usleep(200000);
wrefresh(win2);
touchwin(win2);
usleep(200000);
}
}

View File

@@ -1,57 +0,0 @@
#include <curses.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#define W_LINES 7
#define W_COLS 11
void die(int sig)
{
signal(sig, SIG_IGN);
werase(curscr);
wmove(curscr, 0, 0);
wrefresh(curscr);
endwin();
exit(0);
}
int main()
{
WINDOW *win, *blank;
int x, y;
if (! initscr()) {
fprintf(stderr, "Sorry, unknown terminal.\n");
exit(1);
}
signal(SIGINT, die);
signal(SIGQUIT, die);
signal(SIGHUP, die);
noecho();
//delwin(stdscr);
win = newwin(W_LINES, W_COLS, 0, 0);
blank = newwin(W_LINES, W_COLS, 0, 0);
box(win, '*', '*');
mvwaddstr(win, W_LINES/2, (W_COLS - strlen("RetroBSD"))/2, "RetroBSD");
srand(time(0));
for (;;) {
x = rand() % (COLS - W_COLS);
y = rand() % (LINES - W_LINES);
wrefresh(blank);
if (mvwin(win, y, x) == OK) {
wrefresh(win);
usleep(500000);
mvwin(blank, y, x);
}
}
}

View File

@@ -1,82 +0,0 @@
#include <curses.h>
#include <signal.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#define centered(y,str) mvaddstr(y, (COLS - strlen(str))/2, str)
void die()
{
alarm(0);
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGHUP, SIG_IGN);
signal(SIGTERM, SIG_IGN);
clear();
refresh();
endwin();
exit(0);
}
int main(int ac, char **av)
{
int move_col,
msec;
int time_line,
move_line;
long num_start_time,
num_now_time;
char str_start_time[60],
str_now_time[60];
msec = 0;
if (ac > 1) {
msec = atoi(av[1]);
if (msec < 10)
msec = 10;
else if (msec > 1000)
msec = 1000;
}
if (! initscr())
exit(1);
signal(SIGINT, die);
signal(SIGQUIT, die);
signal(SIGHUP, die);
signal(SIGTERM, die);
box(stdscr, '*', '*');
time(&num_start_time);
strcpy(str_start_time, ctime(&num_start_time));
*(index(str_start_time, '\n')) = '\0';
centered(3, "*** Test started at: ***");
centered(4, str_start_time);
move_col = 1;
move_line = (LINES - 2) / 2;
time_line = move_line + (LINES - move_line - 1) / 2;
while (TRUE) {
time(&num_now_time);
strcpy(str_now_time, ctime(&num_now_time));
*(index(str_now_time, '\n')) = '\0';
centered(time_line, str_now_time);
mvaddstr(move_line, move_col, "<-*->");
refresh();
mvaddstr(move_line, move_col, " ");
if (++move_col >= (COLS - 6))
move_col = 1;
if (msec)
usleep(msec * 1000);
}
}

View File

@@ -1,103 +0,0 @@
#include <curses.h>
#include <signal.h>
#include <ctype.h>
#include <stdlib.h>
#define CNTRL(c) ((c) &037)
void die(int sig)
{
signal(sig, SIG_IGN);
move((LINES - 1), 0);
refresh();
endwin();
exit(0);
}
int main()
{
WINDOW *win, *boxing;
int c;
int x, y;
initscr();
signal(SIGINT, die);
noecho();
crmode();
win = subwin(stdscr,
LINES / 2,
COLS / 2,
LINES / 4,
COLS / 4);
scrollok(win, TRUE);
boxing = subwin(stdscr,
LINES / 2 + 2,
COLS / 2 + 2,
LINES / 4 - 1,
COLS / 4 - 1);
box(boxing, '!', '-');
refresh();
wmove(win, 0, 0);
wrefresh(win);
while ((c = wgetch(win)) != '#') {
if (iscntrl(c)) {
switch (c) {
case CNTRL('E'):
werase(win);
wrefresh(win);
continue;
case CNTRL('R'):
wrefresh(curscr);
continue;
case CNTRL('['):
getyx(win, y, x);
c = wgetch(win);
if (c == '[' || c == 'O')
c = wgetch(win);
switch (c) {
case 'H':
x = 0;
y = 0;
goto change;
case 'A':
y--;
goto change;
case 'B':
y++;
goto change;
case 'C':
x++;
goto change;
case 'D':
x--;
change:
if (x >= win->_maxx) {
x = 0;
y++;
}
if (y >= win->_maxy)
y = 0;
wmove(win, y, x);
wrefresh(win);
continue;
default:
break;
}
break;
default:
continue;
}
}
waddch(win, c);
wrefresh(win);
}
die(SIGINT);
}

View File

@@ -1,9 +0,0 @@
OBJS = dhry_1.o dhry_2.o
all: dhrystone
dhrystone: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
clean:
rm -f *.o dhrystone

View File

@@ -1,361 +0,0 @@
Dhrystone Benchmark: Rationale for Version 2 and Measurement Rules
[published in SIGPLAN Notices 23,8 (Aug. 1988), 49-62]
Reinhold P. Weicker
Siemens AG, E STE 35
[now: Siemens AG, AUT E 51]
Postfach 3220
D-8520 Erlangen
Germany (West)
1. Why a Version 2 of Dhrystone?
The Dhrystone benchmark program [1] has become a popular benchmark for
CPU/compiler performance measurement, in particular in the area of
minicomputers, workstations, PC's and microprocesors. It apparently satisfies
a need for an easy-to-use integer benchmark; it gives a first performance
indication which is more meaningful than MIPS numbers which, in their literal
meaning (million instructions per second), cannot be used across different
instruction sets (e.g. RISC vs. CISC). With the increasing use of the
benchmark, it seems necessary to reconsider the benchmark and to check whether
it can still fulfill this function. Version 2 of Dhrystone is the result of
such a re-evaluation, it has been made for two reasons:
o Dhrystone has been published in Ada [1], and Versions in Ada, Pascal and C
have been distributed by Reinhold Weicker via floppy disk. However, the
version that was used most often for benchmarking has been the version made
by Rick Richardson by another translation from the Ada version into the C
programming language, this has been the version distributed via the UNIX
network Usenet [2].
There is an obvious need for a common C version of Dhrystone, since C is at
present the most popular system programming language for the class of
systems (microcomputers, minicomputers, workstations) where Dhrystone is
used most. There should be, as far as possible, only one C version of
Dhrystone such that results can be compared without restrictions. In the
past, the C versions distributed by Rick Richardson (Version 1.1) and by
Reinhold Weicker had small (though not significant) differences.
Together with the new C version, the Ada and Pascal versions have been
updated as well.
o As far as it is possible without changes to the Dhrystone statistics,
optimizing compilers should be prevented from removing significant
statements. It has turned out in the past that optimizing compilers
suppressed code generation for too many statements (by "dead code removal"
or "dead variable elimination"). This has lead to the danger that
benchmarking results obtained by a naive application of Dhrystone - without
inspection of the code that was generated - could become meaningless.
The overall policiy for version 2 has been that the distribution of
statements, operand types and operand locality described in [1] should remain
unchanged as much as possible. (Very few changes were necessary; their impact
should be negligible.) Also, the order of statements should remain unchanged.
Although I am aware of some critical remarks on the benchmark - I agree with
several of them - and know some suggestions for improvement, I didn't want to
change the benchmark into something different from what has become known as
"Dhrystone"; the confusion generated by such a change would probably outweight
the benefits. If I were to write a new benchmark program, I wouldn't give it
the name "Dhrystone" since this denotes the program published in [1].
However, I do recognize the need for a larger number of representative
programs that can be used as benchmarks; users should always be encouraged to
use more than just one benchmark.
The new versions (version 2.1 for C, Pascal and Ada) will be distributed as
widely as possible. (Version 2.1 differs from version 2.0 distributed via the
UNIX Network Usenet in March 1988 only in a few corrections for minor
deficiencies found by users of version 2.0.) Readers who want to use the
benchmark for their own measurements can obtain a copy in machine-readable
form on floppy disk (MS-DOS or XENIX format) from the author.
2. Overall Characteristics of Version 2
In general, version 2 follows - in the parts that are significant for
performance measurement, i.e. within the measurement loop - the published
(Ada) version and the C versions previously distributed. Where the versions
distributed by Rick Richardson [2] and Reinhold Weicker have been different,
it follows the version distributed by Reinhold Weicker. (However, the
differences have been so small that their impact on execution time in all
likelihood has been negligible.) The initialization and UNIX instrumentation
part - which had been omitted in [1] - follows mostly the ideas of Rick
Richardson [2]. However, any changes in the initialization part and in the
printing of the result have no impact on performance measurement since they
are outside the measaurement loop. As a concession to older compilers, names
have been made unique within the first 8 characters for the C version.
The original publication of Dhrystone did not contain any statements for time
measurement since they are necessarily system-dependent. However, it turned
out that it is not enough just to inclose the main procedure of Dhrystone in a
loop and to measure the execution time. If the variables that are computed
are not used somehow, there is the danger that the compiler considers them as
"dead variables" and suppresses code generation for a part of the statements.
Therefore in version 2 all variables of "main" are printed at the end of the
program. This also permits some plausibility control for correct execution of
the benchmark.
At several places in the benchmark, code has been added, but only in branches
that are not executed. The intention is that optimizing compilers should be
prevented from moving code out of the measurement loop, or from removing code
altogether. Statements that are executed have been changed in very few places
only. In these cases, only the role of some operands has been changed, and it
was made sure that the numbers defining the "Dhrystone distribution"
(distribution of statements, operand types and locality) still hold as much as
possible. Except for sophisticated optimizing compilers, execution times for
version 2.1 should be the same as for previous versions.
Because of the self-imposed limitation that the order and distribution of the
executed statements should not be changed, there are still cases where
optimizing compilers may not generate code for some statements. To a certain
degree, this is unavoidable for small synthetic benchmarks. Users of the
benchmark are advised to check code listings whether code is generated for all
statements of Dhrystone.
Contrary to the suggestion in the published paper and its realization in the
versions previously distributed, no attempt has been made to subtract the time
for the measurement loop overhead. (This calculation has proven difficult to
implement in a correct way, and its omission makes the program simpler.)
However, since the loop check is now part of the benchmark, this does have an
impact - though a very minor one - on the distribution statistics which have
been updated for this version.
3. Discussion of Individual Changes
In this section, all changes are described that affect the measurement loop
and that are not just renamings of variables. All remarks refer to the C
version; the other language versions have been updated similarly.
In addition to adding the measurement loop and the printout statements,
changes have been made at the following places:
o In procedure "main", three statements have been added in the non-executed
"then" part of the statement
if (Enum_Loc == Func_1 (Ch_Index, 'C'))
they are
strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
Int_2_Loc = Run_Index;
Int_Glob = Run_Index;
The string assignment prevents movement of the preceding assignment to
Str_2_Loc (5'th statement of "main") out of the measurement loop (This
probably will not happen for the C version, but it did happen with another
language and compiler.) The assignment to Int_2_Loc prevents value
propagation for Int_2_Loc, and the assignment to Int_Glob makes the value of
Int_Glob possibly dependent from the value of Run_Index.
o In the three arithmetic computations at the end of the measurement loop in
"main ", the role of some variables has been exchanged, to prevent the
division from just cancelling out the multiplication as it was in [1]. A
very smart compiler might have recognized this and suppressed code
generation for the division.
o For Proc_2, no code has been changed, but the values of the actual parameter
have changed due to changes in "main".
o In Proc_4, the second assignment has been changed from
Bool_Loc = Bool_Loc | Bool_Glob;
to
Bool_Glob = Bool_Loc | Bool_Glob;
It now assigns a value to a global variable instead of a local variable
(Bool_Loc); Bool_Loc would be a "dead variable" which is not used
afterwards.
o In Func_1, the statement
Ch_1_Glob = Ch_1_Loc;
was added in the non-executed "else" part of the "if" statement, to prevent
the suppression of code generation for the assignment to Ch_1_Loc.
o In Func_2, the second character comparison statement has been changed to
if (Ch_Loc == 'R')
('R' instead of 'X') because a comparison with 'X' is implied in the
preceding "if" statement.
Also in Func_2, the statement
Int_Glob = Int_Loc;
has been added in the non-executed part of the last "if" statement, in order
to prevent Int_Loc from becoming a dead variable.
o In Func_3, a non-executed "else" part has been added to the "if" statement.
While the program would not be incorrect without this "else" part, it is
considered bad programming practice if a function can be left without a
return value.
To compensate for this change, the (non-executed) "else" part in the "if"
statement of Proc_3 was removed.
The distribution statistics have been changed only by the addition of the
measurement loop iteration (1 additional statement, 4 additional local integer
operands) and by the change in Proc_4 (one operand changed from local to
global). The distribution statistics in the comment headers have been updated
accordingly.
4. String Operations
The string operations (string assignment and string comparison) have not been
changed, to keep the program consistent with the original version.
There has been some concern that the string operations are over-represented in
the program, and that execution time is dominated by these operations. This
was true in particular when optimizing compilers removed too much code in the
main part of the program, this should have been mitigated in version 2.
It should be noted that this is a language-dependent issue: Dhrystone was
first published in Ada, and with Ada or Pascal semantics, the time spent in
the string operations is, at least in all implementations known to me,
considerably smaller. In Ada and Pascal, assignment and comparison of strings
are operators defined in the language, and the upper bounds of the strings
occuring in Dhrystone are part of the type information known at compilation
time. The compilers can therefore generate efficient inline code. In C,
string assignemt and comparisons are not part of the language, so the string
operations must be expressed in terms of the C library functions "strcpy" and
"strcmp". (ANSI C allows an implementation to use inline code for these
functions.) In addition to the overhead caused by additional function calls,
these functions are defined for null-terminated strings where the length of
the strings is not known at compilation time; the function has to check every
byte for the termination condition (the null byte).
Obviously, a C library which includes efficiently coded "strcpy" and "strcmp"
functions helps to obtain good Dhrystone results. However, I don't think that
this is unfair since string functions do occur quite frequently in real
programs (editors, command interpreters, etc.). If the strings functions are
implemented efficiently, this helps real programs as well as benchmark
programs.
I admit that the string comparison in Dhrystone terminates later (after
scanning 20 characters) than most string comparisons in real programs. For
consistency with the original benchmark, I didn't change the program despite
this weakness.
5. Intended Use of Dhrystone
When Dhrystone is used, the following "ground rules" apply:
o Separate compilation (Ada and C versions)
As mentioned in [1], Dhrystone was written to reflect actual programming
practice in systems programming. The division into several compilation
units (5 in the Ada version, 2 in the C version) is intended, as is the
distribution of inter-module and intra-module subprogram calls. Although on
many systems there will be no difference in execution time to a Dhrystone
version where all compilation units are merged into one file, the rule is
that separate compilation should be used. The intention is that real
programming practice, where programs consist of several independently
compiled units, should be reflected. This also has implies that the
compiler, while compiling one unit, has no information about the use of
variables, register allocation etc. occuring in other compilation units.
Although in real life compilation units will probably be larger, the
intention is that these effects of separate compilation are modeled in
Dhrystone.
A few language systems have post-linkage optimization available (e.g., final
register allocation is performed after linkage). This is a borderline case:
Post-linkage optimization involves additional program preparation time
(although not as much as compilation in one unit) which may prevent its
general use in practical programming. I think that since it defeats the
intentions given above, it should not be used for Dhrystone.
Unfortunately, ISO/ANSI Pascal does not contain language features for
separate compilation. Although most commercial Pascal compilers provide
separate compilation in some way, we cannot use it for Dhrystone since such
a version would not be portable. Therefore, no attempt has been made to
provide a Pascal version with several compilation units.
o No procedure merging
Although Dhrystone contains some very short procedures where execution would
benefit from procedure merging (inlining, macro expansion of procedures),
procedure merging is not to be used. The reason is that the percentage of
procedure and function calls is part of the "Dhrystone distribution" of
statements contained in [1]. This restriction does not hold for the string
functions of the C version since ANSI C allows an implementation to use
inline code for these functions.
o Other optimizations are allowed, but they should be indicated
It is often hard to draw an exact line between "normal code generation" and
"optimization" in compilers: Some compilers perform operations by default
that are invoked in other compilers only when optimization is explicitly
requested. Also, we cannot avoid that in benchmarking people try to achieve
results that look as good as possible. Therefore, optimizations performed
by compilers - other than those listed above - are not forbidden when
Dhrystone execution times are measured. Dhrystone is not intended to be
non-optimizable but is intended to be similarly optimizable as normal
programs. For example, there are several places in Dhrystone where
performance benefits from optimizations like common subexpression
elimination, value propagation etc., but normal programs usually also
benefit from these optimizations. Therefore, no effort was made to
artificially prevent such optimizations. However, measurement reports
should indicate which compiler optimization levels have been used, and
reporting results with different levels of compiler optimization for the
same hardware is encouraged.
o Default results are those without "register" declarations (C version)
When Dhrystone results are quoted without additional qualification, they
should be understood as results obtained without use of the "register"
attribute. Good compilers should be able to make good use of registers even
without explicit register declarations ([3], p. 193).
Of course, for experimental purposes, post-linkage optimization, procedure
merging and/or compilation in one unit can be done to determine their effects.
However, Dhrystone numbers obtained under these conditions should be
explicitly marked as such; "normal" Dhrystone results should be understood as
results obtained following the ground rules listed above.
In any case, for serious performance evaluation, users are advised to ask for
code listings and to check them carefully. In this way, when results for
different systems are compared, the reader can get a feeling how much
performance difference is due to compiler optimization and how much is due to
hardware speed.
6. Acknowledgements
The C version 2.1 of Dhrystone has been developed in cooperation with Rick
Richardson (Tinton Falls, NJ), it incorporates many ideas from the "Version
1.1" distributed previously by him over the UNIX network Usenet. Through his
activity with Usenet, Rick Richardson has made a very valuable contribution to
the dissemination of the benchmark. I also thank Chaim Benedelac (National
Semiconductor), David Ditzel (SUN), Earl Killian and John Mashey (MIPS), Alan
Smith and Rafael Saavedra-Barrera (UC at Berkeley) for their help with
comments on earlier versions of the benchmark.
7. Bibliography
[1]
Reinhold P. Weicker: Dhrystone: A Synthetic Systems Programming Benchmark.
Communications of the ACM 27, 10 (Oct. 1984), 1013-1030
[2]
Rick Richardson: Dhrystone 1.1 Benchmark Summary (and Program Text)
Informal Distribution via "Usenet", Last Version Known to me: Sept. 21,
1987
[3]
Brian W. Kernighan and Dennis M. Ritchie: The C Programming Language.
Prentice-Hall, Englewood Cliffs (NJ) 1978

View File

@@ -1,4 +0,0 @@
Downloaded from:
http://www.netlib.org/benchmark/dhry-c
Calls time() and times() replaced by gettimeofday().

View File

@@ -1,78 +0,0 @@
This "shar" file contains the documentation for the
electronic mail distribution of the Dhrystone benchmark (C version 2.1);
a companion "shar" file contains the source code.
(Because of mail length restrictions for some mailers, I have
split the distribution in two parts.)
For versions in other languages, see the other "shar" files.
Files containing the C version (*.h: Header File, *.c: C Modules)
dhry.h
dhry_1.c
dhry_2.c
The file RATIONALE contains the article
"Dhrystone Benchmark: Rationale for Version 2 and Measurement Rules"
which has been published, together with the C source code (Version 2.0),
in SIGPLAN Notices vol. 23, no. 8 (Aug. 1988), pp. 49-62.
This article explains all changes that have been made for Version 2,
compared with the version of the original publication
in Communications of the ACM vol. 27, no. 10 (Oct. 1984), pp. 1013-1030.
It also contains "ground rules" for benchmarking with Dhrystone
which should be followed by everyone who uses the program and publishes
Dhrystone results.
Compared with the Version 2.0 published in SIGPLAN Notices, Version 2.1
contains a few corrections that have been made after Version 2.0 was
distriobuted over the UNIX network Usenet. These small differences between
Version 2.0 and 2.1 should not affect execution time measurements.
For those who want to compare the exact contents of both versions,
the file "dhry_c.dif" contains the differences between the two versions,
as generated by a file comparison of the corresponding files with the
UNIX utility "diff".
The file VARIATIONS contains the article
"Understanding Variations in Dhrystone Performance"
which has been published in Microprocessor Report, May 1989
(Editor: M. Slater), pp. 16-17. It describes the points that users
should know if C Dhrystone results are compared.
Recipients of this shar file who perform measurements are asked
to send measurement results to the author and/or to Rick Richardson.
Rick Richardson publishes regularly Dhrystone results on the UNIX network
Usenet. For submissions of results to him (preferably by electronic mail,
see address in the program header), he has provided a form which is contained
in the file "submit.frm".
The following files are contained in other "shar" files:
Files containing the Ada version (*.s: Specifications, *.b: Bodies):
d_global.s
d_main.b
d_pack_1.b
d_pack_1.s
d_pack_2.b
d_pack_2.s
File containing the Pascal version:
dhry.p
February 22, 1990
Reinhold P. Weicker
Siemens AG, AUT E 51
Postfach 3220
D-8520 Erlangen
Germany (West)
Phone: [xxx-49]-9131-7-20330 (8-17 Central European Time)
UUCP: ..!mcsun!unido!estevax!weicker

View File

@@ -1,157 +0,0 @@
Understanding Variations in Dhrystone Performance
By Reinhold P. Weicker, Siemens AG, AUT E 51, Erlangen
April 1989
This article has appeared in:
Microprocessor Report, May 1989 (Editor: M. Slater), pp. 16-17
Microprocessor manufacturers tend to credit all the performance measured by
benchmarks to the speed of their processors, they often don't even mention the
programming language and compiler used. In their detailed documents, usually
called "performance brief" or "performance report," they usually do give more
details. However, these details are often lost in the press releases and other
marketing statements. For serious performance evaluation, it is necessary to
study the code generated by the various compilers.
Dhrystone was originally published in Ada (Communications of the ACM, Oct.
1984). However, since good Ada compilers were rare at this time and, together
with UNIX, C became more and more popular, the C version of Dhrystone is the
one now mainly used in industry. There are "official" versions 2.1 for Ada,
Pascal, and C, which are as close together as the languages' semantic
differences permit.
Dhrystone contains two statements where the programming language and its
translation play a major part in the execution time measured by the benchmark:
o String assignment (in procedure Proc_0 / main)
o String comparison (in function Func_2)
In Ada and Pascal, strings are arrays of characters where the length of the
string is part of the type information known at compile time. In C, strings
are also arrays of characters, but there are no operators defined in the
language for assignment and comparison of strings. Instead, functions
"strcpy" and "strcmp" are used. These functions are defined for strings of
arbitrary length, and make use of the fact that strings in C have to end with
a terminating null byte. For general-purpose calls to these functions, the
implementor can assume nothing about the length and the alignment of the
strings involved.
The C version of Dhrystone spends a relatively large amount of time in these
two functions. Some time ago, I made measurements on a VAX 11/785 with the
Berkeley UNIX (4.2) compilers (often-used compilers, but certainly not the
most advanced). In the C version, 23% of the time was spent in the string
functions; in the Pascal version, only 10%. On good RISC machines (where less
time is spent in the procedure calling sequence than on a VAX) and with better
optimizing compilers, the percentage is higher; MIPS has reported 34% for an
R3000. Because of this effect, Pascal and Ada Dhrystone results are usually
better than C results (except when the optimization quality of the C compiler
is considerably better than that of the other compilers).
Several people have noted that the string operations are over-represented in
Dhrystone, mainly because the strings occurring in Dhrystone are longer than
average strings. I admit that this is true, and have said so in my SIGPLAN
Notices paper (Aug. 1988); however, I didn't want to generate confusion by
changing the string lengths from version 1 to version 2.
Even if they are somewhat over-represented in Dhrystone, string operations are
frequent enough that it makes sense to implement them in the most efficient
way possible, not only for benchmarking purposes. This means that they can
and should be written in assembly language code. ANSI C also explicitly allows
the strings functions to be implemented as macros, i.e. by inline code.
There is also a third way to speed up the "strcpy" statement in Dhrystone: For
this particular "strcpy" statement, the source of the assignment is a string
constant. Therefore, in contrast to calls to "strcpy" in the general case, the
compiler knows the length and alignment of the strings involved at compile
time and can generate code in the same efficient way as a Pascal compiler
(word instructions instead of byte instructions).
This is not allowed in the case of the "strcmp" call: Here, the addresses are
formal procedure parameters, and no assumptions can be made about the length
or alignment of the strings. Any such assumptions would indicate an incorrect
implementation. They might work for Dhrystone, where the strings are in fact
word-aligned with typical compilers, but other programs would deliver
incorrect results.
So, for an apple-to-apple comparison between processors, and not between
several possible (legal or illegal) degrees of compiler optimization, one
should check that the systems are comparable with respect to the following
three points:
(1) String functions in assembly language vs. in C
Frequently used functions such as the string functions can and should be
written in assembly language, and all serious C language systems known
to me do this. (I list this point for completeness only.) Note that
processors with an instruction that checks a word for a null byte (such
as AMD's 29000 and Intel's 80960) have an advantage here. (This
advantage decreases relatively if optimization (3) is applied.) Due to
the length of the strings involved in Dhrystone, this advantage may be
considered too high in perspective, but it is certainly legal to use
such instructions - after all, these situations are what they were
invented for.
(2) String function code inline vs. as library functions.
ANSI C has created a new situation, compared with the older
Kernighan/Ritchie C. In the original C, the definition of the string
function was not part of the language. Now it is, and inlining is
explicitly allowed. I probably should have stated more clearly in my
SIGPLAN Notices paper that the rule "No procedure inlining for
Dhrystone" referred to the user level procedures only and not to the
library routines.
(3) Fixed-length and alignment assumptions for the strings
Compilers should be allowed to optimize in these cases if (and only if)
it is safe to do so. For Dhrystone, this is the "strcpy" statement, but
not the "strcmp" statement (unless, of course, the "strcmp" code
explicitly checks the alignment at execution time and branches
accordingly). A "Dhrystone switch" for the compiler that causes the
generation of code that may not work under certain circumstances is
certainly inappropriate for comparisons. It has been reported in Usenet
that some C compilers provide such a compiler option; since I don't have
access to all C compilers involved, I cannot verify this.
If the fixed-length and word-alignment assumption can be used, a wide
bus that permits fast multi-word load instructions certainly does help;
however, this fact by itself should not make a really big difference.
A check of these points - something that is necessary for a thorough
evaluation and comparison of the Dhrystone performance claims - requires
object code listings as well as listings for the string functions (strcpy,
strcmp) that are possibly called by the program.
I don't pretend that Dhrystone is a perfect tool to measure the integer
performance of microprocessors. The more it is used and discussed, the more I
myself learn about aspects that I hadn't noticed yet when I wrote the program.
And of course, the very success of a benchmark program is a danger in that
people may tune their compilers and/or hardware to it, and with this action
make it less useful.
Whetstone and Linpack have their critical points also: The Whetstone rating
depends heavily on the speed of the mathematical functions (sine, sqrt, ...),
and Linpack is sensitive to data alignment for some cache configurations.
Introduction of a standard set of public domain benchmark software (something
the SPEC effort attempts) is certainly a worthwhile thing. In the meantime,
people will continue to use whatever is available and widely distributed, and
Dhrystone ratings are probably still better than MIPS ratings if these are -
as often in industry - based on no reproducible derivation. However, any
serious performance evaluation requires more than just a comparison of raw
numbers; one has to make sure that the numbers have been obtained in a
comparable way.

View File

@@ -1,364 +0,0 @@
/*
****************************************************************************
*
* "DHRYSTONE" Benchmark Program
* -----------------------------
*
* Version: C, Version 2.1
*
* File: dhry.h (part 1 of 3)
*
* Date: May 25, 1988
*
* Author: Reinhold P. Weicker
* Siemens AG, AUT E 51
* Postfach 3220
* 8520 Erlangen
* Germany (West)
* Phone: [+49]-9131-7-20330
* (8-17 Central European Time)
* Usenet: ..!mcsun!unido!estevax!weicker
*
* Original Version (in Ada) published in
* "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
* pp. 1013 - 1030, together with the statistics
* on which the distribution of statements etc. is based.
*
* In this C version, the following C library functions are used:
* - strcpy, strcmp (inside the measurement loop)
* - printf, scanf (outside the measurement loop)
* In addition, Berkeley UNIX system calls "times ()" or "time ()"
* are used for execution time measurement. For measurements
* on other systems, these calls have to be changed.
*
* Collection of Results:
* Reinhold Weicker (address see above) and
*
* Rick Richardson
* PC Research. Inc.
* 94 Apple Orchard Drive
* Tinton Falls, NJ 07724
* Phone: (201) 389-8963 (9-17 EST)
* Usenet: ...!uunet!pcrat!rick
*
* Please send results to Rick Richardson and/or Reinhold Weicker.
* Complete information should be given on hardware and software used.
* Hardware information includes: Machine type, CPU, type and size
* of caches; for microprocessors: clock frequency, memory speed
* (number of wait states).
* Software information includes: Compiler (and runtime library)
* manufacturer and version, compilation switches, OS version.
* The Operating System version may give an indication about the
* compiler; Dhrystone itself performs no OS calls in the measurement loop.
*
* The complete output generated by the program should be mailed
* such that at least some checks for correctness can be made.
*
***************************************************************************
*
* History: This version C/2.1 has been made for two reasons:
*
* 1) There is an obvious need for a common C version of
* Dhrystone, since C is at present the most popular system
* programming language for the class of processors
* (microcomputers, minicomputers) where Dhrystone is used most.
* There should be, as far as possible, only one C version of
* Dhrystone such that results can be compared without
* restrictions. In the past, the C versions distributed
* by Rick Richardson (Version 1.1) and by Reinhold Weicker
* had small (though not significant) differences.
*
* 2) As far as it is possible without changes to the Dhrystone
* statistics, optimizing compilers should be prevented from
* removing significant statements.
*
* This C version has been developed in cooperation with
* Rick Richardson (Tinton Falls, NJ), it incorporates many
* ideas from the "Version 1.1" distributed previously by
* him over the UNIX network Usenet.
* I also thank Chaim Benedelac (National Semiconductor),
* David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
* Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
* for their help with comments on earlier versions of the
* benchmark.
*
* Changes: In the initialization part, this version follows mostly
* Rick Richardson's version distributed via Usenet, not the
* version distributed earlier via floppy disk by Reinhold Weicker.
* As a concession to older compilers, names have been made
* unique within the first 8 characters.
* Inside the measurement loop, this version follows the
* version previously distributed by Reinhold Weicker.
*
* At several places in the benchmark, code has been added,
* but within the measurement loop only in branches that
* are not executed. The intention is that optimizing compilers
* should be prevented from moving code out of the measurement
* loop, or from removing code altogether. Since the statements
* that are executed within the measurement loop have NOT been
* changed, the numbers defining the "Dhrystone distribution"
* (distribution of statements, operand types and locality)
* still hold. Except for sophisticated optimizing compilers,
* execution times for this version should be the same as
* for previous versions.
*
* Since it has proven difficult to subtract the time for the
* measurement loop overhead in a correct way, the loop check
* has been made a part of the benchmark. This does have
* an impact - though a very minor one - on the distribution
* statistics which have been updated for this version.
*
* All changes within the measurement loop are described
* and discussed in the companion paper "Rationale for
* Dhrystone version 2".
*
* Because of the self-imposed limitation that the order and
* distribution of the executed statements should not be
* changed, there are still cases where optimizing compilers
* may not generate code for some statements. To a certain
* degree, this is unavoidable for small synthetic benchmarks.
* Users of the benchmark are advised to check code listings
* whether code is generated for all statements of Dhrystone.
*
* Version 2.1 is identical to version 2.0 distributed via
* the UNIX network Usenet in March 1988 except that it corrects
* some minor deficiencies that were found by users of version 2.0.
* The only change within the measurement loop is that a
* non-executed "else" part was added to the "if" statement in
* Func_3, and a non-executed "else" part removed from Proc_3.
*
***************************************************************************
*
* Compilation model and measurement (IMPORTANT):
*
* This C version of Dhrystone consists of three files:
* - dhry.h (this file, containing global definitions and comments)
* - dhry_1.c (containing the code corresponding to Ada package Pack_1)
* - dhry_2.c (containing the code corresponding to Ada package Pack_2)
*
* The following "ground rules" apply for measurements:
* - Separate compilation
* - No procedure merging
* - Otherwise, compiler optimizations are allowed but should be indicated
* - Default results are those without register declarations
* See the companion paper "Rationale for Dhrystone Version 2" for a more
* detailed discussion of these ground rules.
*
* For 16-Bit processors (e.g. 80186, 80286), times for all compilation
* models ("small", "medium", "large" etc.) should be given if possible,
* together with a definition of these models for the compiler system used.
*
**************************************************************************
*
* Dhrystone (C version) statistics:
*
* [Comment from the first distribution, updated for version 2.
* Note that because of language differences, the numbers are slightly
* different from the Ada version.]
*
* The following program contains statements of a high level programming
* language (here: C) in a distribution considered representative:
*
* assignments 52 (51.0 %)
* control statements 33 (32.4 %)
* procedure, function calls 17 (16.7 %)
*
* 103 statements are dynamically executed. The program is balanced with
* respect to the three aspects:
*
* - statement type
* - operand type
* - operand locality
* operand global, local, parameter, or constant.
*
* The combination of these three aspects is balanced only approximately.
*
* 1. Statement Type:
* ----------------- number
*
* V1 = V2 9
* (incl. V1 = F(..)
* V = Constant 12
* Assignment, 7
* with array element
* Assignment, 6
* with record component
* --
* 34 34
*
* X = Y +|-|"&&"|"|" Z 5
* X = Y +|-|"==" Constant 6
* X = X +|- 1 3
* X = Y *|/ Z 2
* X = Expression, 1
* two operators
* X = Expression, 1
* three operators
* --
* 18 18
*
* if .... 14
* with "else" 7
* without "else" 7
* executed 3
* not executed 4
* for ... 7 | counted every time
* while ... 4 | the loop condition
* do ... while 1 | is evaluated
* switch ... 1
* break 1
* declaration with 1
* initialization
* --
* 34 34
*
* P (...) procedure call 11
* user procedure 10
* library procedure 1
* X = F (...)
* function call 6
* user function 5
* library function 1
* --
* 17 17
* ---
* 103
*
* The average number of parameters in procedure or function calls
* is 1.82 (not counting the function values as implicit parameters).
*
*
* 2. Operators
* ------------
* number approximate
* percentage
*
* Arithmetic 32 50.8
*
* + 21 33.3
* - 7 11.1
* * 3 4.8
* / (int div) 1 1.6
*
* Comparison 27 42.8
*
* == 9 14.3
* /= 4 6.3
* > 1 1.6
* < 3 4.8
* >= 1 1.6
* <= 9 14.3
*
* Logic 4 6.3
*
* && (AND-THEN) 1 1.6
* | (OR) 1 1.6
* ! (NOT) 2 3.2
*
* -- -----
* 63 100.1
*
*
* 3. Operand Type (counted once per operand reference):
* ---------------
* number approximate
* percentage
*
* Integer 175 72.3 %
* Character 45 18.6 %
* Pointer 12 5.0 %
* String30 6 2.5 %
* Array 2 0.8 %
* Record 2 0.8 %
* --- -------
* 242 100.0 %
*
* When there is an access path leading to the final operand (e.g. a record
* component), only the final data type on the access path is counted.
*
*
* 4. Operand Locality:
* -------------------
* number approximate
* percentage
*
* local variable 114 47.1 %
* global variable 22 9.1 %
* parameter 45 18.6 %
* value 23 9.5 %
* reference 22 9.1 %
* function result 6 2.5 %
* constant 55 22.7 %
* --- -------
* 242 100.0 %
*
*
* The program does not compute anything meaningful, but it is syntactically
* and semantically correct. All variables have a value assigned to them
* before they are used as a source operand.
*
* There has been no explicit effort to account for the effects of a
* cache, or to balance the use of long or short displacements for code or
* data.
*
***************************************************************************
*/
/* Compiler and system dependent definitions: */
typedef enum {
Ident_1,
Ident_2,
Ident_3,
Ident_4,
Ident_5
} Enumeration;
/* General definitions: */
#define true 1
#define false 0
typedef int One_Thirty;
typedef int One_Fifty;
typedef char Capital_Letter;
typedef int Boolean;
typedef char Str_30 [31];
typedef int Arr_1_Dim [50];
typedef int Arr_2_Dim [50] [50];
typedef struct record
{
struct record *Ptr_Comp;
Enumeration Discr;
union {
struct {
Enumeration Enum_Comp;
int Int_Comp;
char Str_Comp [31];
} var_1;
struct {
Enumeration E_Comp_2;
char Str_2_Comp [31];
} var_2;
struct {
char Ch_1_Comp;
char Ch_2_Comp;
} var_3;
} variant;
} Rec_Type, *Rec_Pointer;
/* Forward declaration necessary since Enumeration may not simply be int */
void Proc_1 (Rec_Pointer);
void Proc_2 (One_Fifty *);
void Proc_3 (Rec_Pointer *);
void Proc_4 (void);
void Proc_5 (void);
void Proc_6 (Enumeration, Enumeration *);
void Proc_7 (One_Fifty, One_Fifty, One_Fifty *);
void Proc_8 (Arr_1_Dim, Arr_2_Dim, int, int);
Enumeration Func_1 (Capital_Letter, Capital_Letter);
Boolean Func_2 (Str_30, Str_30);
Boolean Func_3 (Enumeration);

View File

@@ -1,318 +0,0 @@
/*
****************************************************************************
*
* "DHRYSTONE" Benchmark Program
* -----------------------------
*
* Version: C, Version 2.1
*
* File: dhry_1.c (part 2 of 3)
*
* Date: May 25, 1988
*
* Author: Reinhold P. Weicker
*
****************************************************************************
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "dhry.h"
/* Speed of Vak-11/780, 1 DMIPS by definition */
#define DHRYSTONES_PER_DMIPS 1757
/* Global Variables: */
Rec_Pointer Ptr_Glob,
Next_Ptr_Glob;
int Int_Glob;
Boolean Bool_Glob;
char Ch_1_Glob,
Ch_2_Glob;
int Arr_1_Glob [50];
int Arr_2_Glob [50] [50];
/* variables for time measurement: */
struct timeval time_info;
long Begin_Time,
End_Time,
Microseconds,
Dhrystones_per_Millisecond,
Dmips;
/* end of variables for time measurement */
int main ()
/*****/
/* main program, corresponds to procedures */
/* Main and Proc_0 in the Ada version */
{
One_Fifty Int_1_Loc;
One_Fifty Int_2_Loc;
One_Fifty Int_3_Loc;
char Ch_Index;
Enumeration Enum_Loc;
Str_30 Str_1_Loc;
Str_30 Str_2_Loc;
int Run_Index;
int Number_Of_Runs = 1000000;
/* Initializations */
Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
Ptr_Glob->Discr = Ident_1;
Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
Ptr_Glob->variant.var_1.Int_Comp = 40;
strcpy (Ptr_Glob->variant.var_1.Str_Comp,
"DHRYSTONE PROGRAM, SOME STRING");
strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
Arr_2_Glob [8][7] = 10;
/* Was missing in published program. Without this statement, */
/* Arr_2_Glob [8][7] would have an undefined value. */
/* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
/* overflow may occur for this array element. */
printf ("\n");
printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
printf ("\n");
again:
printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
/***************/
/* Start timer */
/***************/
gettimeofday(&time_info, 0);
Begin_Time = time_info.tv_sec * 1000000L + time_info.tv_usec;
for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
{
Proc_5();
Proc_4();
/* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
Int_1_Loc = 2;
Int_2_Loc = 3;
strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
Enum_Loc = Ident_2;
Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
/* Bool_Glob == 1 */
while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
{
Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
/* Int_3_Loc == 7 */
Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
/* Int_3_Loc == 7 */
Int_1_Loc += 1;
} /* while */
/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
/* Int_Glob == 5 */
Proc_1 (Ptr_Glob);
for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
/* loop body executed twice */
{
if (Enum_Loc == Func_1 (Ch_Index, 'C'))
/* then, not executed */
{
Proc_6 (Ident_1, &Enum_Loc);
strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
Int_2_Loc = Run_Index;
Int_Glob = Run_Index;
}
}
/* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
Int_2_Loc = Int_2_Loc * Int_1_Loc;
Int_1_Loc = Int_2_Loc / Int_3_Loc;
Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
/* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
Proc_2 (&Int_1_Loc);
/* Int_1_Loc == 5 */
} /* loop "for Run_Index" */
/**************/
/* Stop timer */
/**************/
gettimeofday(&time_info, 0);
End_Time = time_info.tv_sec * 1000000L + time_info.tv_usec;
/* Measurements should last at least 2 seconds */
Microseconds = End_Time - Begin_Time;
if (Microseconds < 2000000)
{
printf ("Measured time too small to obtain meaningful results\n");
printf ("Increasing the number of runs\n");
printf ("\n");
Number_Of_Runs *= 10;
goto again;
}
printf ("Execution ends\n");
printf ("\n");
printf ("Final values of the variables used in the benchmark:\n");
printf ("\n");
printf ("Int_Glob: %d\n", Int_Glob);
printf (" should be: %d\n", 5);
printf ("Bool_Glob: %d\n", Bool_Glob);
printf (" should be: %d\n", 1);
printf ("Ch_1_Glob: %c\n", Ch_1_Glob);
printf (" should be: %c\n", 'A');
printf ("Ch_2_Glob: %c\n", Ch_2_Glob);
printf (" should be: %c\n", 'B');
printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
printf (" should be: %d\n", 7);
printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
printf (" should be: Number_Of_Runs + 10\n");
printf ("Ptr_Glob->\n");
printf (" Ptr_Comp: %p\n", Ptr_Glob->Ptr_Comp);
printf (" should be: (implementation-dependent)\n");
printf (" Discr: %d\n", Ptr_Glob->Discr);
printf (" should be: %d\n", 0);
printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
printf (" should be: %d\n", 2);
printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
printf (" should be: %d\n", 17);
printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
printf ("Next_Ptr_Glob->\n");
printf (" Ptr_Comp: %p\n", Next_Ptr_Glob->Ptr_Comp);
printf (" should be: (implementation-dependent), same as above\n");
printf (" Discr: %d\n", Next_Ptr_Glob->Discr);
printf (" should be: %d\n", 0);
printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
printf (" should be: %d\n", 1);
printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
printf (" should be: %d\n", 18);
printf (" Str_Comp: %s\n",
Next_Ptr_Glob->variant.var_1.Str_Comp);
printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
printf ("Int_1_Loc: %d\n", Int_1_Loc);
printf (" should be: %d\n", 5);
printf ("Int_2_Loc: %d\n", Int_2_Loc);
printf (" should be: %d\n", 13);
printf ("Int_3_Loc: %d\n", Int_3_Loc);
printf (" should be: %d\n", 7);
printf ("Enum_Loc: %d\n", Enum_Loc);
printf (" should be: %d\n", 1);
printf ("Str_1_Loc: %s\n", Str_1_Loc);
printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
printf ("Str_2_Loc: %s\n", Str_2_Loc);
printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
printf ("\n");
/* Dhrystones per 10^-5 sec. */
Dhrystones_per_Millisecond = Number_Of_Runs / (Microseconds / 1000);
Dmips = Dhrystones_per_Millisecond * 10000 / DHRYSTONES_PER_DMIPS;
printf ("Nanoseconds for one run through Dhrystone: %lu \n",
Microseconds / (Number_Of_Runs / 1000));
printf (" Million Dhrystones per Second: %lu.%03lu \n",
Dhrystones_per_Millisecond / 1000, Dhrystones_per_Millisecond % 1000);
printf (" DMIPS: %lu.%lu \n",
Dmips / 10, Dmips % 10);
printf ("\n");
return 0;
}
void Proc_1 (Rec_Pointer Ptr_Val_Par)
/******************/
/* executed once */
{
Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
/* == Ptr_Glob_Next */
/* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
/* corresponds to "rename" in Ada, "with" in Pascal */
*Ptr_Val_Par->Ptr_Comp = *Ptr_Glob;
Ptr_Val_Par->variant.var_1.Int_Comp = 5;
Next_Record->variant.var_1.Int_Comp
= Ptr_Val_Par->variant.var_1.Int_Comp;
Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
Proc_3 (&Next_Record->Ptr_Comp);
/* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
== Ptr_Glob->Ptr_Comp */
if (Next_Record->Discr == Ident_1)
/* then, executed */
{
Next_Record->variant.var_1.Int_Comp = 6;
Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
&Next_Record->variant.var_1.Enum_Comp);
Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
&Next_Record->variant.var_1.Int_Comp);
}
else /* not executed */
*Ptr_Val_Par = *Ptr_Val_Par->Ptr_Comp;
} /* Proc_1 */
void Proc_2 (One_Fifty *Int_Par_Ref)
/******************/
/* executed once */
/* *Int_Par_Ref == 1, becomes 4 */
{
One_Fifty Int_Loc;
Enumeration Enum_Loc;
Int_Loc = *Int_Par_Ref + 10;
do /* executed once */
if (Ch_1_Glob == 'A')
/* then, executed */
{
Int_Loc -= 1;
*Int_Par_Ref = Int_Loc - Int_Glob;
Enum_Loc = Ident_1;
} /* if */
while (Enum_Loc != Ident_1); /* true */
} /* Proc_2 */
void Proc_3 (Rec_Pointer *Ptr_Ref_Par)
/******************/
/* executed once */
/* Ptr_Ref_Par becomes Ptr_Glob */
{
if (Ptr_Glob != 0)
/* then, executed */
*Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
} /* Proc_3 */
void Proc_4 () /* without parameters */
/*******/
/* executed once */
{
Boolean Bool_Loc;
Bool_Loc = Ch_1_Glob == 'A';
Bool_Glob = Bool_Loc | Bool_Glob;
Ch_2_Glob = 'B';
} /* Proc_4 */
void Proc_5 () /* without parameters */
/*******/
/* executed once */
{
Ch_1_Glob = 'A';
Bool_Glob = false;
} /* Proc_5 */

View File

@@ -1,177 +0,0 @@
/*
****************************************************************************
*
* "DHRYSTONE" Benchmark Program
* -----------------------------
*
* Version: C, Version 2.1
*
* File: dhry_2.c (part 3 of 3)
*
* Date: May 25, 1988
*
* Author: Reinhold P. Weicker
*
****************************************************************************
*/
#include <string.h>
#include "dhry.h"
extern int Int_Glob;
extern char Ch_1_Glob;
void Proc_6 (Enumeration Enum_Val_Par,
Enumeration *Enum_Ref_Par)
/*********************************/
/* executed once */
/* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
{
*Enum_Ref_Par = Enum_Val_Par;
if (! Func_3 (Enum_Val_Par))
/* then, not executed */
*Enum_Ref_Par = Ident_4;
switch (Enum_Val_Par)
{
case Ident_1:
*Enum_Ref_Par = Ident_1;
break;
case Ident_2:
if (Int_Glob > 100)
/* then */
*Enum_Ref_Par = Ident_1;
else *Enum_Ref_Par = Ident_4;
break;
case Ident_3: /* executed */
*Enum_Ref_Par = Ident_2;
break;
case Ident_4: break;
case Ident_5:
*Enum_Ref_Par = Ident_3;
break;
} /* switch */
} /* Proc_6 */
void Proc_7 (One_Fifty Int_1_Par_Val,
One_Fifty Int_2_Par_Val,
One_Fifty *Int_Par_Ref)
/**********************************************/
/* executed three times */
/* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
/* Int_Par_Ref becomes 7 */
/* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
/* Int_Par_Ref becomes 17 */
/* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
/* Int_Par_Ref becomes 18 */
{
One_Fifty Int_Loc;
Int_Loc = Int_1_Par_Val + 2;
*Int_Par_Ref = Int_2_Par_Val + Int_Loc;
} /* Proc_7 */
void Proc_8 (Arr_1_Dim Arr_1_Par_Ref,
Arr_2_Dim Arr_2_Par_Ref,
int Int_1_Par_Val,
int Int_2_Par_Val)
/*********************************************************************/
/* executed once */
/* Int_Par_Val_1 == 3 */
/* Int_Par_Val_2 == 7 */
{
One_Fifty Int_Index;
One_Fifty Int_Loc;
Int_Loc = Int_1_Par_Val + 5;
Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
Int_Glob = 5;
} /* Proc_8 */
Enumeration Func_1 (Capital_Letter Ch_1_Par_Val,
Capital_Letter Ch_2_Par_Val)
/*************************************************/
/* executed three times */
/* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
/* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
/* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
{
Capital_Letter Ch_1_Loc;
Capital_Letter Ch_2_Loc;
Ch_1_Loc = Ch_1_Par_Val;
Ch_2_Loc = Ch_1_Loc;
if (Ch_2_Loc != Ch_2_Par_Val)
/* then, executed */
return (Ident_1);
else /* not executed */
{
Ch_1_Glob = Ch_1_Loc;
return (Ident_2);
}
} /* Func_1 */
Boolean Func_2 (Str_30 Str_1_Par_Ref,
Str_30 Str_2_Par_Ref)
/*************************************************/
/* executed once */
/* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
/* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
{
One_Thirty Int_Loc;
Capital_Letter Ch_Loc;
Int_Loc = 2;
while (Int_Loc <= 2) /* loop body executed once */
if (Func_1 (Str_1_Par_Ref[Int_Loc],
Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
/* then, executed */
{
Ch_Loc = 'A';
Int_Loc += 1;
} /* if, while */
if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
/* then, not executed */
Int_Loc = 7;
if (Ch_Loc == 'R')
/* then, not executed */
return (true);
else /* executed */
{
if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
/* then, not executed */
{
Int_Loc += 7;
Int_Glob = Int_Loc;
return (true);
}
else /* executed */
return (false);
} /* if Ch_Loc */
} /* Func_2 */
Boolean Func_3 (Enumeration Enum_Par_Val)
/***************************/
/* executed once */
/* Enum_Par_Val == Ident_3 */
{
Enumeration Enum_Loc;
Enum_Loc = Enum_Par_Val;
if (Enum_Loc == Ident_3)
/* then, executed */
return (true);
else /* not executed */
return (false);
} /* Func_3 */

View File

@@ -1,74 +0,0 @@
CC = cc
LIBS = -lgpanel
PROG = tft tftetris pixel line rect fill circle font color speed flappy
FONTS = 5x7.o 6x9.o digits20.o digits32.o lucidasans11.o lucidasans15.o \
lucidasans28.o lucidasans7.o lucidasans9.o verdana7.o
all: $(PROG)
clean:
rm -f *.o *~ $(PROG)
tft: tft.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
tftetris: tftetris.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $?
pixel: pixel.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS)
line: line.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS)
rect: rect.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS)
fill: fill.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS)
circle: circle.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS)
color: color.c
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $? $(LIBS)
speed: speed.c lucidasans15.o
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) speed.c lucidasans15.o $(LIBS)
flappy: flappy.c lucidasans15.o lucidasans28.o
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) flappy.c lucidasans15.o lucidasans28.o $(LIBS)
font: font.c $(FONTS)
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) font.c $(FONTS) $(LIBS)
5x7.o: fonts/5x7.c
$(CC) $(CFLAGS) -o $@ -c $?
6x9.o: fonts/6x9.c
$(CC) $(CFLAGS) -o $@ -c $?
digits20.o: fonts/digits20.c
$(CC) $(CFLAGS) -o $@ -c $?
digits32.o: fonts/digits32.c
$(CC) $(CFLAGS) -o $@ -c $?
lucidasans11.o: fonts/lucidasans11.c
$(CC) $(CFLAGS) -o $@ -c $?
lucidasans15.o: fonts/lucidasans15.c
$(CC) $(CFLAGS) -o $@ -c $?
lucidasans28.o: fonts/lucidasans28.c
$(CC) $(CFLAGS) -o $@ -c $?
lucidasans7.o: fonts/lucidasans7.c
$(CC) $(CFLAGS) -o $@ -c $?
lucidasans9.o: fonts/lucidasans9.c
$(CC) $(CFLAGS) -o $@ -c $?
verdana7.o: fonts/verdana7.c
$(CC) $(CFLAGS) -o $@ -c $?

View File

@@ -1,33 +0,0 @@
/*
* Draw random circles.
*/
#include <stdio.h>
#include <sys/gpanel.h>
int xsize, ysize;
int main()
{
char *devname = "/dev/tft0";
int x, y, r, color;
if (gpanel_open(devname) < 0) {
printf("Cannot open %s\n", devname);
exit(-1);
}
gpanel_clear(0, &xsize, &ysize);
printf("Screen size %u x %u.\n", xsize, ysize);
srand(time(0));
printf("Draw random circles.\n");
printf("Press ^C to stop.\n");
for (;;) {
x = rand() % xsize;
y = rand() % ysize;
r = rand() % ysize;
color = rand() << 1;
gpanel_circle(color, x, y, r);
}
return 0;
}

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