Branch "sdram" imported from GoogleCode.
This commit is contained in:
27
LICENSE
27
LICENSE
@@ -1,27 +0,0 @@
|
|||||||
Copyright (c) 2014, RetroBSD
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
list of conditions and the following disclaimer.
|
|
||||||
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
* Neither the name of the {organization} nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived from
|
|
||||||
this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
203
Makefile
203
Makefile
@@ -11,36 +11,28 @@
|
|||||||
#
|
#
|
||||||
# Supported boards
|
# Supported boards
|
||||||
#
|
#
|
||||||
MAX32 = sys/pic32/max32/MAX32
|
MAX32 = pic32/max32
|
||||||
FUBARINO = sys/pic32/fubarino/FUBARINO
|
UBW32 = pic32/ubw32
|
||||||
FUBARINOBIG = sys/pic32/fubarino/FUBARINO-UART2CONS-UART1-SRAMC
|
UBW32UART = pic32/ubw32-uart
|
||||||
SDXL = sys/pic32/sdxl/SDXL
|
UBW32UARTSDRSW = pic32/ubw32-uart-sdramswap
|
||||||
MAXIMITE = sys/pic32/maximite/MAXIMITE
|
MAXIMITE = pic32/maximite
|
||||||
MAXCOLOR = sys/pic32/maximite-color/MAXCOLOR
|
EXPLORER16 = pic32/explorer16
|
||||||
DUINOMITE = sys/pic32/duinomite/DUINOMITE
|
STARTERKIT = pic32/starter-kit
|
||||||
DUINOMITEUART = sys/pic32/duinomite-uart/DUINOMITE-UART
|
DUINOMITE = pic32/duinomite
|
||||||
DUINOMITEE = sys/pic32/duinomite-e/DUINOMITE-E
|
PINGUINO = pic32/pinguino-micro
|
||||||
DUINOMITEEUART = sys/pic32/duinomite-e-uart/DUINOMITE-E-UART
|
DIP = pic32/dip
|
||||||
MMBMX7 = sys/pic32/mmb-mx7/MMB-MX7
|
BAREMETAL = pic32/baremetal
|
||||||
WF32 = sys/pic32/wf32/WF32
|
RETROONE = pic32/retroone
|
||||||
UBW32 = sys/pic32/ubw32/UBW32
|
|
||||||
UBW32UART = sys/pic32/ubw32-uart/UBW32-UART
|
|
||||||
UBW32UARTSDRAM = sys/pic32/ubw32-uart-sdram/UBW32-UART-SDRAM
|
|
||||||
EXPLORER16 = sys/pic32/explorer16/EXPLORER16
|
|
||||||
STARTERKIT = sys/pic32/starter-kit/STARTER-KIT
|
|
||||||
BAREMETAL = sys/pic32/baremetal/BAREMETAL
|
|
||||||
RETROONE = sys/pic32/retroone/RETROONE
|
|
||||||
|
|
||||||
# Select target board
|
# Select target board
|
||||||
TARGET ?= $(MAX32)
|
TARGET ?= $(UBW32UARTSDRSW)
|
||||||
|
|
||||||
# Filesystem and swap sizes.
|
# Filesystem and swap sizes.
|
||||||
FS_MBYTES = 100
|
FS_KBYTES = 16384
|
||||||
U_MBYTES = 100
|
SWAP_KBYTES = 2048
|
||||||
SWAP_MBYTES = 2
|
|
||||||
|
|
||||||
# Set this to the device name for your SD card. With this
|
# Set this to the device name for your SD card. With this
|
||||||
# enabled you can use "make installfs" to copy the sdcard.img
|
# enabled you can use "make installfs" to copy the filesys.img
|
||||||
# to the SD card.
|
# to the SD card.
|
||||||
|
|
||||||
#SDCARD = /dev/sdb
|
#SDCARD = /dev/sdb
|
||||||
@@ -53,71 +45,136 @@ DEFS =
|
|||||||
|
|
||||||
FSUTIL = tools/fsutil/fsutil
|
FSUTIL = tools/fsutil/fsutil
|
||||||
|
|
||||||
-include Makefile.user
|
#
|
||||||
|
# Filesystem contents.
|
||||||
|
#
|
||||||
|
BIN_FILES := $(wildcard bin/*)
|
||||||
|
SBIN_FILES := $(wildcard sbin/*)
|
||||||
|
GAMES_FILES := $(shell find games -type f ! -path '*/.*')
|
||||||
|
LIB_FILES := $(wildcard lib/*)
|
||||||
|
LIBEXEC_FILES := $(wildcard libexec/*)
|
||||||
|
ETC_FILES = etc/rc etc/rc.local etc/ttys etc/gettytab etc/group \
|
||||||
|
etc/passwd etc/shadow etc/fstab etc/motd etc/shells \
|
||||||
|
etc/termcap
|
||||||
|
INC_FILES = include/stdio.h include/syscall.h include/sys/types.h \
|
||||||
|
include/sys/select.h
|
||||||
|
SHARE_FILES = share/re.help share/example/Makefile \
|
||||||
|
share/example/ashello.S share/example/chello.c \
|
||||||
|
share/example/blkjack.bas share/example/hilow.bas \
|
||||||
|
share/example/stars.bas share/example/prime.scm \
|
||||||
|
share/example/fact.fth share/example/echo.S
|
||||||
|
ALLFILES = $(SBIN_FILES) $(ETC_FILES) $(BIN_FILES) $(LIB_FILES) $(LIBEXEC_FILES) \
|
||||||
|
$(INC_FILES) $(SHARE_FILES) $(GAMES_FILES) \
|
||||||
|
var/log/messages var/log/wtmp .profile
|
||||||
|
ALLDIRS = sbin/ bin/ dev/ etc/ tmp/ lib/ libexec/ share/ share/example/ \
|
||||||
|
share/misc/ var/ var/run/ var/log/ u/ include/ include/sys/ \
|
||||||
|
games/ games/lib/
|
||||||
|
BDEVS = dev/sd0!b0:0 dev/sd1!b0:1 dev/sw0!b1:0
|
||||||
|
CDEVS = dev/console!c0:0 \
|
||||||
|
dev/mem!c1:0 dev/kmem!c1:1 dev/null!c1:2 dev/zero!c1:3 \
|
||||||
|
dev/tty!c2:0 \
|
||||||
|
dev/rsd0!c3:0 dev/rsd1!c3:1 dev/swap!c3:0 \
|
||||||
|
dev/klog!c4:0 \
|
||||||
|
dev/stdin!c5:0 dev/stdout!c5:1 dev/stderr!c5:2 \
|
||||||
|
dev/rsw0!c6:0 \
|
||||||
|
dev/porta!c7:0 dev/portb!c7:1 dev/portc!c7:2 \
|
||||||
|
dev/portd!c7:3 dev/porte!c7:4 dev/portf!c7:5 dev/portg!c7:6 \
|
||||||
|
dev/confa!c7:64 dev/confb!c7:65 dev/confc!c7:66 \
|
||||||
|
dev/confd!c7:67 dev/confe!c7:68 dev/conff!c7:69 dev/confg!c7:70 \
|
||||||
|
dev/spi1!c9:0 dev/spi2!c9:1 dev/spi3!c9:2 dev/spi4!c9:3 \
|
||||||
|
dev/glcd0!c10:0
|
||||||
|
FDDEVS = dev/fd/ dev/fd/0!c5:0 dev/fd/1!c5:1 dev/fd/2!c5:2 \
|
||||||
|
dev/fd/3!c5:3 dev/fd/4!c5:4 dev/fd/5!c5:5 dev/fd/6!c5:6 \
|
||||||
|
dev/fd/7!c5:7 dev/fd/8!c5:8 dev/fd/9!c5:9 dev/fd/10!c5:10 \
|
||||||
|
dev/fd/11!c5:11 dev/fd/12!c5:12 dev/fd/13!c5:13 \
|
||||||
|
dev/fd/14!c5:14 dev/fd/15!c5:15 dev/fd/16!c5:16 \
|
||||||
|
dev/fd/17!c5:17 dev/fd/18!c5:18 dev/fd/19!c5:19 \
|
||||||
|
dev/fd/20!c5:20 dev/fd/21!c5:21 dev/fd/22!c5:22 \
|
||||||
|
dev/fd/23!c5:23 dev/fd/24!c5:24 dev/fd/25!c5:25 \
|
||||||
|
dev/fd/26!c5:26 dev/fd/27!c5:27 dev/fd/28!c5:28 \
|
||||||
|
dev/fd/29!c5:29
|
||||||
|
ADCDEVS = dev/adc0!c8:0 dev/adc1!c8:1 dev/adc2!c8:2 dev/adc3!c8:3 \
|
||||||
|
dev/adc4!c8:4 dev/adc5!c8:5 dev/adc6!c8:6 dev/adc7!c8:7 \
|
||||||
|
dev/adc8!c8:8 dev/adc9!c8:9 dev/adc10!c8:10 dev/adc11!c8:11 \
|
||||||
|
dev/adc12!c8:12 dev/adc13!c8:13 dev/adc14!c8:14 dev/adc15!c8:15
|
||||||
|
OCDEVS = dev/oc0!c11:0 dev/oc1!c11:1 dev/oc2!c11:2 dev/oc3!c11:3 dev/oc4!c11:4
|
||||||
|
|
||||||
TARGETDIR = $(shell dirname $(TARGET))
|
all: build kernel
|
||||||
TARGETNAME = $(shell basename $(TARGET))
|
|
||||||
TOPSRC = $(shell pwd)
|
|
||||||
CONFIG = $(TOPSRC)/tools/configsys/config
|
|
||||||
|
|
||||||
all: .profile
|
|
||||||
$(MAKE) -C tools
|
|
||||||
$(MAKE) -C lib
|
|
||||||
$(MAKE) -C src install
|
|
||||||
$(MAKE) kernel
|
|
||||||
$(MAKE) fs
|
$(MAKE) fs
|
||||||
|
|
||||||
kernel: $(TARGETDIR)/Makefile
|
fs: filesys.img user.img
|
||||||
$(MAKE) -C $(TARGETDIR)
|
|
||||||
|
|
||||||
$(TARGETDIR)/Makefile: $(CONFIG) $(TARGETDIR)/$(TARGETNAME)
|
kernel:
|
||||||
cd $(TARGETDIR) && ../../../tools/configsys/config $(TARGETNAME)
|
$(MAKE) -C sys/$(TARGET)
|
||||||
|
|
||||||
fs: sdcard.img
|
build:
|
||||||
|
$(MAKE) -C tools
|
||||||
|
$(MAKE) -C src install
|
||||||
|
|
||||||
.PHONY: sdcard.img
|
filesys.img: $(FSUTIL) $(ALLFILES)
|
||||||
sdcard.img: $(FSUTIL) rootfs.manifest userfs.manifest
|
|
||||||
rm -f $@
|
rm -f $@
|
||||||
$(FSUTIL) --repartition=fs=$(FS_MBYTES)M:swap=$(SWAP_MBYTES)M:fs=$(U_MBYTES)M $@
|
$(FSUTIL) -n$(FS_KBYTES) -s$(SWAP_KBYTES) $@
|
||||||
$(FSUTIL) --new --partition=1 --manifest=rootfs.manifest $@ .
|
$(FSUTIL) -a $@ $(ALLDIRS) $(ALLFILES)
|
||||||
$(FSUTIL) --new --partition=3 --manifest=userfs.manifest $@ u
|
$(FSUTIL) -a $@ $(CDEVS)
|
||||||
|
$(FSUTIL) -a $@ $(BDEVS)
|
||||||
|
$(FSUTIL) -a $@ $(ADCDEVS)
|
||||||
|
$(FSUTIL) -a $@ $(OCDEVS)
|
||||||
|
# $(FSUTIL) -a $@ $(FDDEVS)
|
||||||
|
|
||||||
|
user.img: $(FSUTIL)
|
||||||
|
rm -f $@
|
||||||
|
$(FSUTIL) -n$(FS_KBYTES) $@
|
||||||
|
|
||||||
$(FSUTIL):
|
$(FSUTIL):
|
||||||
cd tools/fsutil; $(MAKE)
|
cd tools/fsutil; $(MAKE)
|
||||||
|
|
||||||
$(CONFIG):
|
|
||||||
make -C tools/configsys
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~
|
rm -f *~
|
||||||
for dir in tools lib src sys/pic32; do $(MAKE) -C $$dir -k clean; done
|
for dir in tools src sys/pic32; do $(MAKE) -C $$dir -k clean; done
|
||||||
|
|
||||||
cleanall: clean
|
cleanall: clean
|
||||||
$(MAKE) -C lib clean
|
rm -f sys/pic32/*/unix.hex bin/* sbin/* lib/* games/[a-k]* games/[m-z]* libexec/* share/man/cat*/*
|
||||||
rm -f sys/pic32/*/unix.hex bin/* sbin/* libexec/*
|
rm -f games/lib/adventure.dat
|
||||||
rm -f games/[a-k]* games/[m-z]* share/man/cat*/*
|
rm -f games/lib/cfscores
|
||||||
rm -f games/lib/adventure.dat games/lib/cfscores
|
rm -f share/re.help
|
||||||
rm -f share/re.help share/emg.keys share/misc/more.help
|
rm -f share/misc/more.help
|
||||||
rm -f etc/termcap etc/remote etc/phones
|
rm -f etc/termcap
|
||||||
rm -f tools/configsys/.depend
|
|
||||||
rm -f var/log/aculog
|
|
||||||
rm -rf var/lock share/unixbench
|
|
||||||
|
|
||||||
installfs:
|
|
||||||
|
# TODO
|
||||||
|
buildlib:
|
||||||
|
@echo installing /usr/include
|
||||||
|
# cd include; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
@echo compiling libc.a
|
||||||
|
cd lib/libc; $(MAKE) $(LIBCDEFS)
|
||||||
|
@echo installing /lib/libc.a
|
||||||
|
cd lib/libc; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
@echo compiling C compiler
|
||||||
|
cd lib; $(MAKE) ccom cpp c2
|
||||||
|
@echo installing C compiler
|
||||||
|
cd lib/ccom; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/cpp; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/c2; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib; $(MAKE) clean
|
||||||
|
@echo
|
||||||
|
@echo re-compiling libc.a
|
||||||
|
cd lib/libc; $(MAKE) $(LIBCDEFS)
|
||||||
|
@echo re-installing /lib/libc.a
|
||||||
|
cd lib/libc; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
@echo re-compiling C compiler
|
||||||
|
cd lib; $(MAKE) ccom cpp c2
|
||||||
|
@echo re-installing C compiler
|
||||||
|
cd lib/ccom; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/cpp; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
cd lib/c2; $(MAKE) DESTDIR=$(DESTDIR) install
|
||||||
|
@echo
|
||||||
|
|
||||||
|
installfs: filesys.img
|
||||||
ifdef SDCARD
|
ifdef SDCARD
|
||||||
@[ -f sdcard.img ] || $(MAKE) sdcard.img
|
sudo dd bs=16k if=filesys.img of=$(SDCARD)
|
||||||
sudo dd bs=32k if=sdcard.img of=$(SDCARD)
|
|
||||||
else
|
else
|
||||||
@echo "Error: No SDCARD defined."
|
@echo "Error: No SDCARD defined."
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# TODO: make it relative to Target
|
|
||||||
installflash:
|
|
||||||
sudo pic32prog sys/pic32/fubarino/unix.hex
|
|
||||||
|
|
||||||
# TODO: make it relative to Target
|
|
||||||
installboot:
|
|
||||||
sudo pic32prog sys/pic32/fubarino/bootloader.hex
|
|
||||||
|
|
||||||
.profile: etc/root/dot.profile
|
|
||||||
cp etc/root/dot.profile .profile
|
|
||||||
|
|||||||
129
README
Normal file
129
README
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
This is the RetroBSD source directory.
|
||||||
|
|
||||||
|
|
||||||
|
Source Roadmap
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
bin User commands.
|
||||||
|
etc Template files for /etc.
|
||||||
|
include System include files.
|
||||||
|
lib System libraries.
|
||||||
|
libexec System binaries.
|
||||||
|
sbin System administration commands.
|
||||||
|
share Shared resources.
|
||||||
|
sys Kernel sources.
|
||||||
|
tools Build tools and simulators.
|
||||||
|
|
||||||
|
|
||||||
|
Supported hardware
|
||||||
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
* chipKIT Max32 board.
|
||||||
|
* Sparkfun UBW32 board.
|
||||||
|
* Maximite computer.
|
||||||
|
* Microchip Explorer 16 board, with PIC32 CAN-USB plug-in module and SD & MMC pictail.
|
||||||
|
* Microchip PIC32 USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail.
|
||||||
|
* Olimex Duinomite, Duinomite-Mini and Duinomite-Mega boards.
|
||||||
|
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
|
||||||
|
* eflightworks DIP board.
|
||||||
|
|
||||||
|
|
||||||
|
Build
|
||||||
|
~~~~~
|
||||||
|
By default, the system is configured for the Max32 board.
|
||||||
|
To select another target board, edit a top-level Makefile
|
||||||
|
and change a TARGET value under section "Select target board":
|
||||||
|
|
||||||
|
TARGET = $(UBW32) # for the UBW32 board with USB console
|
||||||
|
TARGET = $(UBW32UART) # for the UBW32 board with UART console
|
||||||
|
TARGET = $(MAXIMITE) # for the Maximite board
|
||||||
|
TARGET = $(EXPLORER16) # for the Explorer 16 board
|
||||||
|
TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit
|
||||||
|
TARGET = $(MAX32) # default
|
||||||
|
TARGET = $(DUINOMITE) # for the Duinomite board
|
||||||
|
TARGET = $(PINGUINO) # for the Pinguino-Micro board
|
||||||
|
TARGET = $(DIP) # for the DIP board
|
||||||
|
|
||||||
|
You can also change a desired filesystem size and swap area size,
|
||||||
|
as required. Default is:
|
||||||
|
|
||||||
|
FS_KBYTES = 16384
|
||||||
|
SWAP_KBYTES = 2048
|
||||||
|
|
||||||
|
To compile the kernel and build a filesystem image, run:
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
|
A resulting root filesystem image is in file `filesys.img`.
|
||||||
|
A kernel is in file `unix.hex` in your target board subdirectory.
|
||||||
|
|
||||||
|
|
||||||
|
Filesystem image
|
||||||
|
~~~~~~~~~~~~~~~~
|
||||||
|
You need to put a filesystem image on a SD card. On Windows, use
|
||||||
|
Win32DiskImager utility (https://launchpad.net/win32-image-writer/+download).
|
||||||
|
On Linux, run:
|
||||||
|
|
||||||
|
sudo dd if=filesys.img of=/dev/XYZ
|
||||||
|
|
||||||
|
Here `XYZ` is a device name of SD card, as recognized by Linux (sdb in my case).
|
||||||
|
|
||||||
|
|
||||||
|
Install kernel
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
Kernel image should be written to PIC32 flash memory. The procedure depends
|
||||||
|
on a board used.
|
||||||
|
|
||||||
|
Max32 board:
|
||||||
|
cd sys/pic32/ubw32
|
||||||
|
AVRTOOLS=/Applications/Mpide.app/Contents/Resources/Java/hardware/tools
|
||||||
|
$AVRTOOLS/bin/avrdude -C$AVRTOOLS/etc/avrdude.conf -c stk500v2 -p pic32 \
|
||||||
|
-P /dev/tty.usbserial-* -b 115200 -v -U flash:w:unix.hex:i
|
||||||
|
|
||||||
|
Here you need to change AVRTOOLS path and tty name according to your system.
|
||||||
|
|
||||||
|
UBW32 board:
|
||||||
|
Use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
||||||
|
and a USB cable to install a kernel:
|
||||||
|
|
||||||
|
pic32prog sys/pic32/ubw32/unix.hex
|
||||||
|
|
||||||
|
Maximite:
|
||||||
|
Use the bootload program for Windows, available for download by link:
|
||||||
|
http://geoffg.net/Downloads/Maximite/Maximite_Update_V2.7B.zip
|
||||||
|
|
||||||
|
Explorer 16 board:
|
||||||
|
There is an auxiliary PIC18 chip on the Explorer 16 board, which can be
|
||||||
|
used as a built-in programmer device. You will need a PICkit 2 adapter
|
||||||
|
to install a needed firmware, as described in article:
|
||||||
|
http://www.paintyourdragon.com/?p=51
|
||||||
|
(section "Hack #2: Lose the PICkit 2, Save $35").
|
||||||
|
This should be done only once.
|
||||||
|
|
||||||
|
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
||||||
|
and a USB cable to install a kernel:
|
||||||
|
|
||||||
|
pic32prog sys/pic32/explorer16/unix.hex
|
||||||
|
|
||||||
|
PIC32 Starter Kit:
|
||||||
|
Use PICkit 2 adapter and software to install a boot loader from
|
||||||
|
file `sys/pic32/starter-kit/boot.hex`. This should be done only once.
|
||||||
|
|
||||||
|
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
||||||
|
and a USB cable to install a kernel:
|
||||||
|
|
||||||
|
pic32prog sys/pic32/starter-kit/unix.hex
|
||||||
|
|
||||||
|
|
||||||
|
Simulator
|
||||||
|
~~~~~~~~~
|
||||||
|
You can use a MIPS32 simulator to develop a debug a RetroBSD software,
|
||||||
|
without a need for hardware board. By default, a simulator is configured
|
||||||
|
to imitate a Max32 board. To build it:
|
||||||
|
|
||||||
|
cd tools/virtualmips
|
||||||
|
make
|
||||||
|
|
||||||
|
Run it:
|
||||||
|
|
||||||
|
./pic32
|
||||||
|
|
||||||
|
Configuration of simulated board is stored in file `pic32_max32.conf`.
|
||||||
161
README.md
161
README.md
@@ -1,161 +0,0 @@
|
|||||||
# This is the RetroBSD source directory.
|
|
||||||
|
|
||||||
## Source Roadmap
|
|
||||||
|
|
||||||
bin User commands.
|
|
||||||
etc Template files for /etc.
|
|
||||||
include System include files.
|
|
||||||
lib System libraries.
|
|
||||||
libexec System binaries.
|
|
||||||
sbin System administration commands.
|
|
||||||
share Shared resources.
|
|
||||||
sys Kernel sources.
|
|
||||||
tools Build tools and simulators.
|
|
||||||
|
|
||||||
|
|
||||||
## Supported hardware
|
|
||||||
|
|
||||||
* chipKIT Max32 board.
|
|
||||||
* Sparkfun UBW32 board.
|
|
||||||
* Maximite and Colour Maximite computers.
|
|
||||||
* Microchip Explorer 16 board, with PIC32 CAN-USB plug-in module and SD & MMC pictail.
|
|
||||||
* Microchip PIC32 USB or Ethernet Starter Kit, with I/O Expansion board and SD & MMC pictail.
|
|
||||||
* Olimex Duinomite, Duinomite-Mini and Duinomite-Mega boards.
|
|
||||||
* Olimex Pinguino-Micro board with PIC32MX795F512H microcontroller.
|
|
||||||
* eflightworks DIP board.
|
|
||||||
|
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
To compile everything from sources, you'll need some packages installed, namely:
|
|
||||||
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 libelf-dev libfuse-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
By default, the system is configured for the Max32 board.
|
|
||||||
To select another target board, edit a top-level user-specific Makefile called "Makefile.user"
|
|
||||||
and set a TARGET value:
|
|
||||||
|
|
||||||
```Makefile
|
|
||||||
TARGET = $(MAX32) # for the chipKIT Max32 board with SD card shield (default)
|
|
||||||
TARGET = $(FUBARINO) # Fubarino SD board
|
|
||||||
TARGET = $(FUBARINOBIG) # Fubarino SD board with 8MB SRAM RAMDISK
|
|
||||||
TARGET = $(MAXIMITE) # for the Maximite board
|
|
||||||
TARGET = $(MAXCOLOR) # for the Colour Maximite board
|
|
||||||
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 = $(MMBMX7) # MMB MX7 board
|
|
||||||
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 = $(EXPLORER16) # for the Explorer 16 board
|
|
||||||
TARGET = $(STARTERKIT) # for the PIC32 USB or Ethernet Starter Kit
|
|
||||||
TARGET = $(BAREMETAL) # Bare PIC32 chip on a breakout board
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also change a desired filesystem size and swap area size,
|
|
||||||
as required. Default is:
|
|
||||||
```Makefile
|
|
||||||
FS_KBYTES = 16384
|
|
||||||
SWAP_KBYTES = 2048
|
|
||||||
```
|
|
||||||
To compile the kernel and build a filesystem image, run:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
|
|
||||||
A resulting root filesystem image is in file `sdcard.img`.
|
|
||||||
A kernel is in file `unix.hex` in your target board subdirectory.
|
|
||||||
|
|
||||||
|
|
||||||
### Filesystem image
|
|
||||||
|
|
||||||
You need to put a filesystem image on a SD card. On Windows, use
|
|
||||||
Win32DiskImager utility (https://launchpad.net/win32-image-writer/+download).
|
|
||||||
On Linux, run:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ sudo dd if=sdcard.img of=/dev/XYZ
|
|
||||||
```
|
|
||||||
|
|
||||||
Here `XYZ` is a device name of SD card, as recognized by Linux (sdb in my case).
|
|
||||||
|
|
||||||
|
|
||||||
### Install kernel
|
|
||||||
|
|
||||||
Kernel image should be written to PIC32 flash memory. The procedure depends
|
|
||||||
on a board used.
|
|
||||||
|
|
||||||
#### Max32 board:
|
|
||||||
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
|
|
||||||
```
|
|
||||||
|
|
||||||
Here you need to change AVRTOOLS path and tty name according to your system.
|
|
||||||
|
|
||||||
#### UBW32 board:
|
|
||||||
Use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
|
||||||
and a USB cable to install a kernel:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ pic32prog sys/pic32/ubw32/unix.hex
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Maximite:
|
|
||||||
Use the bootload program for Windows, available for download by link:
|
|
||||||
http://geoffg.net/Downloads/Maximite/Maximite_Update_V2.7B.zip
|
|
||||||
|
|
||||||
#### Explorer 16 board:
|
|
||||||
There is an auxiliary PIC18 chip on the Explorer 16 board, which can be
|
|
||||||
used as a built-in programmer device. You will need a PICkit 2 adapter
|
|
||||||
to install a needed firmware, as described in article:
|
|
||||||
http://www.paintyourdragon.com/?p=51
|
|
||||||
(section "Hack #2: Lose the PICkit 2, Save $35").
|
|
||||||
This should be done only once.
|
|
||||||
|
|
||||||
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
|
||||||
and a USB cable to install a kernel:
|
|
||||||
|
|
||||||
``` shell
|
|
||||||
$ pic32prog sys/pic32/explorer16/unix.hex
|
|
||||||
```
|
|
||||||
|
|
||||||
#### PIC32 Starter Kit:
|
|
||||||
Use PICkit 2 adapter and software to install a boot loader from
|
|
||||||
file `sys/pic32/starter-kit/boot.hex`. This should be done only once.
|
|
||||||
|
|
||||||
Then, you can use a pic32prog utility (http://code.google.com/p/pic32prog/)
|
|
||||||
and a USB cable to install a kernel:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ pic32prog sys/pic32/starter-kit/unix.hex
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Simulator
|
|
||||||
|
|
||||||
You can use a MIPS32 simulator to develop a debug a RetroBSD software,
|
|
||||||
without a need for hardware board. By default, a simulator is configured
|
|
||||||
to imitate a Max32 board. To build it:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ cd tools/virtualmips
|
|
||||||
$ make
|
|
||||||
```
|
|
||||||
|
|
||||||
Run it:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
$ ./pic32
|
|
||||||
```
|
|
||||||
|
|
||||||
Configuration of simulated board is stored in file `pic32_max32.conf`.
|
|
||||||
1
bin/.gitignore
vendored
1
bin/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
12
cross.mk
12
cross.mk
@@ -1,7 +1,7 @@
|
|||||||
DESTDIR = /usr/local/retrobsd
|
DESTDIR = /usr/local/retrobsd
|
||||||
MACHINE = mips
|
MACHINE = mips
|
||||||
|
|
||||||
CC = gcc -m32
|
CC = gcc
|
||||||
|
|
||||||
AS = $(CC) -x assembler-with-cpp
|
AS = $(CC) -x assembler-with-cpp
|
||||||
LD = ld
|
LD = ld
|
||||||
@@ -18,14 +18,6 @@ TAGSFILE = tags
|
|||||||
MANROFF = nroff -man -h
|
MANROFF = nroff -man -h
|
||||||
ELF2AOUT = cp
|
ELF2AOUT = cp
|
||||||
|
|
||||||
CFLAGS = -O -DCROSS
|
CFLAGS = -O -DCROSS -I/usr/include -I$(TOPSRC)/include
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
LIBS =
|
LIBS =
|
||||||
|
|
||||||
# Add system include path
|
|
||||||
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
|
|
||||||
CFLAGS += -I/usr/include
|
|
||||||
else
|
|
||||||
CFLAGS += -I/usr/include/i386-linux-gnu
|
|
||||||
endif
|
|
||||||
CFLAGS += -I$(TOPSRC)/include
|
|
||||||
|
|||||||
4
etc/.gitignore
vendored
4
etc/.gitignore
vendored
@@ -1,4 +0,0 @@
|
|||||||
phones
|
|
||||||
remote
|
|
||||||
termcap
|
|
||||||
termcap.full
|
|
||||||
380
etc/MAKEDEV
380
etc/MAKEDEV
@@ -52,13 +52,16 @@ do
|
|||||||
case $i in
|
case $i in
|
||||||
|
|
||||||
std)
|
std)
|
||||||
mknod console c 0 0
|
mknod console c 0 0
|
||||||
mknod mem c 1 0 ; chmod 640 mem ; chgrp kmem mem
|
# mknod kUmem c 1 3 ; chmod 600 kUmem ;: untested
|
||||||
mknod kmem c 1 1 ; chmod 640 kmem ; chgrp kmem kmem
|
mknod kmem c 1 1 ; chmod 640 kmem ; chgrp kmem kmem
|
||||||
|
mknod mem c 1 0 ; chmod 640 mem ; chgrp kmem mem
|
||||||
mknod null c 1 2 ; chmod 666 null
|
mknod null c 1 2 ; chmod 666 null
|
||||||
mknod zero c 1 3 ; chmod 444 zero
|
mknod zero c 1 3 ; chmod 444 zero
|
||||||
mknod tty c 2 0 ; chmod 666 tty
|
mknod tty c 9 0 ; chmod 666 tty
|
||||||
mknod klog c 3 0 ; chmod 600 klog
|
mknod klog c 22 0 ; chmod 600 klog
|
||||||
|
mknod errlog c 22 1 ; chmod 600 errlog
|
||||||
|
mknod acctlog c 22 2 ; chmod 600 acctlog
|
||||||
;;
|
;;
|
||||||
|
|
||||||
fd)
|
fd)
|
||||||
@@ -67,105 +70,304 @@ fd)
|
|||||||
rm -f stdin stdout stderr
|
rm -f stdin stdout stderr
|
||||||
mkdir fd
|
mkdir fd
|
||||||
chmod 755 fd
|
chmod 755 fd
|
||||||
mknod stdin c 4 0
|
mknod stdin c 26 0
|
||||||
mknod stdout c 4 1
|
mknod stdout c 26 1
|
||||||
mknod stderr c 4 2
|
mknod stderr c 26 2
|
||||||
eval `echo "" | awk '{ for (i = 0; i < 32; i++)
|
eval `echo "" | awk '{ for (i = 0; i < 32; i++)
|
||||||
printf("mknod fd/%d c 4 %d; ",i,i); }'`
|
printf("mknod fd/%d c 26 %d; ",i,i); }'`
|
||||||
;;
|
;;
|
||||||
|
|
||||||
rd)
|
ht*|tm*|ts*|tu*)
|
||||||
|
umask 0 ; ctlr=`expr $i : '..\(.*\)'`
|
||||||
|
ctlr=`expr $ctlr '*' 64`
|
||||||
|
case $i in
|
||||||
|
ht*) blk=0; chr=6;;
|
||||||
|
tm*) blk=1; chr=7;;
|
||||||
|
ts*) blk=2; chr=8;;
|
||||||
|
tu*) blk=12; chr=23;;
|
||||||
|
esac
|
||||||
|
# Maximum of 4 controllers in a system
|
||||||
|
case $ctlr in
|
||||||
|
0|64|128|192)
|
||||||
|
# Maximum of 4 units per controller
|
||||||
|
# for unit in 0 1 2 3
|
||||||
|
for unit in 0 1
|
||||||
|
do
|
||||||
|
zero=`expr $ctlr + $unit + 0`
|
||||||
|
four=`expr $zero + 4` ; eight=`expr $zero + 8`
|
||||||
|
twelve=`expr $zero + 12`
|
||||||
|
sixteen=`expr $zero + 16`
|
||||||
|
twenty=`expr $zero + 20`
|
||||||
|
twentyfour=`expr $zero + 24`
|
||||||
|
twentyeight=`expr $zero + 28`
|
||||||
|
mknod mt$zero b $blk $zero
|
||||||
|
mknod mt$four b $blk $four
|
||||||
|
mknod mt$eight b $blk $eight
|
||||||
|
mknod mt$twelve b $blk $twelve
|
||||||
|
mknod nmt$zero b $blk $four ;: v7 compatibility
|
||||||
|
mknod nmt$eight b $blk $twelve ;: ditto
|
||||||
|
mknod nrmt$zero c $chr $four ;: ditto
|
||||||
|
mknod nrmt$eight c $chr $twelve ;: ditto
|
||||||
|
mknod rmt$zero c $chr $zero
|
||||||
|
mknod rmt$four c $chr $four
|
||||||
|
mknod rmt$eight c $chr $eight
|
||||||
|
mknod rmt$twelve c $chr $twelve
|
||||||
|
if [ `expr $i : '\(..\)'` = tu ]
|
||||||
|
then
|
||||||
|
mknod mt$sixteen b $blk $sixteen
|
||||||
|
mknod mt$twenty b $blk $twenty
|
||||||
|
mknod mt$twentyfour b $blk $twentyfour
|
||||||
|
mknod mt$twentyeight b $blk $twentyeight
|
||||||
|
mknod nmt$sixteen b $blk $twenty ;: v7 compatibility
|
||||||
|
mknod nmt$twentyfour b $blk $twentyeight ;: ditto
|
||||||
|
mknod nrmt$sixteen c $chr $twenty ;: ditto
|
||||||
|
mknod nrmt$twentyfour c $chr $twentyeight ;: ditto
|
||||||
|
mknod rmt$sixteen c $chr $sixteen
|
||||||
|
mknod rmt$twenty c $chr $twenty
|
||||||
|
mknod rmt$twentyfour c $chr $twentyfour
|
||||||
|
mknod rmt$twentyeight c $chr $twentyeight
|
||||||
|
fi
|
||||||
|
if [ `expr $i : '\(..\)'` = ut ]
|
||||||
|
then
|
||||||
|
mknod mt$twenty b $blk $twenty
|
||||||
|
mknod rmt$twenty c $chr $twenty
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad controller for tape in: $1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
umask 77
|
||||||
|
;;
|
||||||
|
|
||||||
|
rk*)
|
||||||
|
# The 2.11BSD rk driver doesn't support partitions. We create
|
||||||
|
# a single block and charater inode pair for each unit and
|
||||||
|
# call it rkNh.
|
||||||
|
umask 2 ; unit=`expr $i : '..\(.*\)'`
|
||||||
|
case $i in
|
||||||
|
rk*) name=rk; blk=6; chr=15;;
|
||||||
|
esac
|
||||||
|
mknod ${name}${unit}h b ${blk} ${unit}
|
||||||
|
mknod r${name}${unit}h c ${chr} ${unit}
|
||||||
|
chgrp operator ${name}${unit}h r${name}${unit}h
|
||||||
|
chmod 640 ${name}${unit}h r${name}${unit}h
|
||||||
|
;;
|
||||||
|
|
||||||
|
rx*)
|
||||||
umask 2
|
umask 2
|
||||||
rm -f rd[0123] rd[0123][abcd]
|
name=rx; blk=8; chr=17
|
||||||
mknod rd0 b 0 0
|
mknod ${name}0a b ${blk} 0
|
||||||
mknod rd0a b 0 1
|
mknod ${name}1a b ${blk} 1
|
||||||
mknod rd0b b 0 2
|
mknod ${name}0b b ${blk} 2
|
||||||
mknod rd0c b 0 2
|
mknod ${name}1b b ${blk} 3
|
||||||
mknod rd0d b 0 2
|
mknod r${name}0a c ${chr} 0
|
||||||
mknod rd1 b 1 0
|
mknod r${name}1a c ${chr} 1
|
||||||
mknod rd1a b 1 1
|
mknod r${name}0b c ${chr} 2
|
||||||
mknod rd1b b 1 2
|
mknod r${name}1b c ${chr} 3
|
||||||
mknod rd1c b 1 2
|
chgrp operator ${name}[01][ab] r${name}[01][ab]
|
||||||
mknod rd1d b 1 2
|
chmod 640 ${name}[01][ab] r${name}[01][ab]
|
||||||
mknod rd2 b 2 0
|
|
||||||
mknod rd2a b 2 1
|
|
||||||
mknod rd2b b 2 2
|
|
||||||
mknod rd2c b 2 2
|
|
||||||
mknod rd2d b 2 2
|
|
||||||
mknod rd3 b 3 0
|
|
||||||
mknod rd3a b 3 1
|
|
||||||
mknod rd3b b 3 2
|
|
||||||
mknod rd3c b 3 2
|
|
||||||
mknod rd3d b 3 2
|
|
||||||
chgrp operator rd[0123]
|
|
||||||
chgrp operator rd[0123][abcd]
|
|
||||||
chmod 640 rd[0123][abcd]
|
|
||||||
chmod 640 rd[0123]
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
gpio)
|
ram*)
|
||||||
umask 0
|
# Note, this must come *before* the "ra*". The entry "rram" is for
|
||||||
rm -f port[abcdefg] conf[abcdef]
|
# auto fscks when ram is mentioned in /etc/fstab.
|
||||||
mknod porta c 5 0
|
umask 2
|
||||||
mknod portb c 5 1
|
mknod ram b 3 0
|
||||||
mknod portc c 5 2
|
ln ram rram
|
||||||
mknod portd c 5 3
|
chgrp operator ram
|
||||||
mknod porte c 5 4
|
chmod 640 ram
|
||||||
mknod portf c 5 5
|
umask 77
|
||||||
mknod portg c 5 6
|
|
||||||
mknod confa c 5 64
|
|
||||||
mknod confb c 5 65
|
|
||||||
mknod confc c 5 66
|
|
||||||
mknod confd c 5 67
|
|
||||||
mknod confe c 5 68
|
|
||||||
mknod conff c 5 69
|
|
||||||
mknod confg c 5 70
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
adc)
|
br*|hk*|ra*|si*|xp*|rl*)
|
||||||
umask 0
|
umask 2 ; unit=`expr $i : '..\(.*\)'`
|
||||||
rm -f adc[0123456789] adc1[012345]
|
case $i in
|
||||||
mknod adc0 c 6 0
|
br*) name=rp; blk=11; chr=20;;
|
||||||
mknod adc1 c 6 1
|
hk*) name=hk; blk=4; chr=13;;
|
||||||
mknod adc2 c 6 2
|
ra*) name=ra; blk=5; chr=14;;
|
||||||
mknod adc3 c 6 3
|
si*) name=si; blk=9; chr=18;;
|
||||||
mknod adc4 c 6 4
|
xp*) name=xp; blk=10; chr=19;;
|
||||||
mknod adc5 c 6 5
|
rl*) name=rl; blk=7; chr=16;;
|
||||||
mknod adc6 c 6 6
|
esac
|
||||||
mknod adc7 c 6 7
|
case $unit in
|
||||||
mknod adc8 c 6 8
|
0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\
|
||||||
mknod adc9 c 6 9
|
17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)
|
||||||
mknod adc10 c 6 10
|
mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0`
|
||||||
mknod adc11 c 6 11
|
mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1`
|
||||||
mknod adc12 c 6 12
|
mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2`
|
||||||
mknod adc13 c 6 13
|
mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3`
|
||||||
mknod adc14 c 6 14
|
mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4`
|
||||||
mknod adc15 c 6 15
|
mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5`
|
||||||
|
mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6`
|
||||||
|
mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7`
|
||||||
|
mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0`
|
||||||
|
mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1`
|
||||||
|
mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2`
|
||||||
|
mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3`
|
||||||
|
mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4`
|
||||||
|
mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5`
|
||||||
|
mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7`
|
||||||
|
mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6`
|
||||||
|
chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h]
|
||||||
|
chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h]
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for disk in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
umask 77
|
||||||
;;
|
;;
|
||||||
|
|
||||||
spi)
|
dz*)
|
||||||
umask 0
|
unit=`expr $i : 'dz\(.*\)'`
|
||||||
rm -f spi[1234]
|
case $unit in
|
||||||
mknod spi1 c 7 0
|
0|1|2|3|4|5|6|7)
|
||||||
mknod spi2 c 7 1
|
eval `echo $unit | awk ' { u = $1 } END {
|
||||||
mknod spi3 c 7 2
|
for (i = 0; i < 8; i++)
|
||||||
mknod spi4 c 7 3
|
printf("mknod tty%02d c 2 %d; ",u*8+i,u*8+i); }'`
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for dz in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
|
|
||||||
glcd)
|
#
|
||||||
umask 0
|
# we may want dmz and dmf someday...
|
||||||
rm -f glcd0
|
# dhu*|dh*|dmf*|dmz*)
|
||||||
mknod glcd0 c 8 0
|
dhv*|dhu*|dh*)
|
||||||
|
case $i in
|
||||||
|
# dmz*) name=dmz; major=37; count=24;
|
||||||
|
# unit=`expr $i : "$name\(.*\)"`
|
||||||
|
# case $unit in
|
||||||
|
# 0) ch=a ;; 1) ch=b ;; 2) ch=c ;; 3) ch=e ;;
|
||||||
|
# 4) ch=f ;; 5) ch=g ;;
|
||||||
|
# *) echo bad unit for $name in: $i ;;
|
||||||
|
# esac;;
|
||||||
|
# dmf*) name=dmf; major=22; count=8;
|
||||||
|
# unit=`expr $i : "$name\(.*\)"`
|
||||||
|
# case $unit in
|
||||||
|
# 0) ch=A ;; 1) ch=B ;; 2) ch=C ;; 3) ch=E ;;
|
||||||
|
# 4) ch=F ;; 5) ch=G ;; 6) ch=H ;; 7) ch=I ;;
|
||||||
|
# *) echo bad unit for $name in: $i ;;
|
||||||
|
# esac;;
|
||||||
|
dhv*) name=dhv; major=24; count=8;
|
||||||
|
unit=`expr $i : "$name\(.*\)"`;
|
||||||
|
case $unit in
|
||||||
|
0) ch=S ;; 1) ch=T ;; 2) ch=U ;; 3) ch=V ;;
|
||||||
|
4) ch=W ;; 5) ch=X ;; 6) ch=Y ;; 7) ch=Z ;;
|
||||||
|
*) echo bad unit for $name in: $i ;;
|
||||||
|
esac;;
|
||||||
|
dhu*) name=dhu; major=4; count=16;
|
||||||
|
unit=`expr $i : "$name\(.*\)"`;
|
||||||
|
case $unit in
|
||||||
|
0) ch=S ;; 1) ch=T ;; 2) ch=U ;; 3) ch=V ;;
|
||||||
|
4) ch=W ;; 5) ch=X ;; 6) ch=Y ;; 7) ch=Z ;;
|
||||||
|
*) echo bad unit for $name in: $i ;;
|
||||||
|
esac;;
|
||||||
|
dh*) name=dh; major=3; count=16;
|
||||||
|
unit=`expr $i : "$name\(.*\)"`
|
||||||
|
case $unit in
|
||||||
|
0) ch=h ;; 1) ch=i ;; 2) ch=j ;; 3) ch=k ;;
|
||||||
|
*) echo bad unit for $name in: $i ;;
|
||||||
|
esac;;
|
||||||
|
esac
|
||||||
|
eval `echo $ch $unit $major $count |
|
||||||
|
awk ' { ch = $1; u = $4 * $2; m = $3; cnt = $4 } END {
|
||||||
|
for (i = 0; i < cnt; i++)
|
||||||
|
if (i < 10)
|
||||||
|
printf("mknod tty%s%x c %d %d; ",ch,i,m,u+i);
|
||||||
|
else
|
||||||
|
printf("mknod tty%s%c c %d %d; ",ch,87+i,m,u+i); }'`
|
||||||
;;
|
;;
|
||||||
|
|
||||||
oc)
|
# extra DL-11 units not including the console. unit numbers start at 1 because
|
||||||
umask 0
|
# the console is always unit 0. Seven units (1 - 7) are defined for the 11/93
|
||||||
rm -f oc[12345]
|
# and 11/94. Device name is "ttyl?". The DH range was restricted from 'h'-'o'
|
||||||
mknod oc1 c 9 0
|
# to 'h' - 'k' (very unlikely that more than 64 channels of DH-11 will or could
|
||||||
mknod oc2 c 9 1
|
# be put on an 11.
|
||||||
mknod oc3 c 9 2
|
|
||||||
mknod oc4 c 9 3
|
dl*)
|
||||||
mknod oc5 c 9 4
|
name=dl; major=0; ch=l
|
||||||
|
unit=`expr $i : "$name\(.*\)"`
|
||||||
|
case $unit in
|
||||||
|
1|2|3|4|5|6|7)
|
||||||
|
mknod tty${ch}${unit} c $major $unit;
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for $name in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
# we may want va and vp someday...
|
||||||
|
# lp*|va*|vp*)
|
||||||
|
lp*|dn*)
|
||||||
|
case $i in
|
||||||
|
lp*) name=lp; major=5;;
|
||||||
|
dn*) name=dn; major=21;;
|
||||||
|
# va*) name=va; major=10;;
|
||||||
|
# vp*) name=vp; major=6;;
|
||||||
|
esac
|
||||||
|
unit=`expr $i : "$name\(.*\)"`
|
||||||
|
case $unit in
|
||||||
|
0|1|2|3|4|5|6|7)
|
||||||
|
mknod $i c $major $unit;
|
||||||
|
chmod 666 $i
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for $name in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
pty*)
|
||||||
|
class=`expr $i : 'pty\(.*\)'`
|
||||||
|
case $class in
|
||||||
|
0) offset=0 name=p;;
|
||||||
|
1) offset=16 name=q;;
|
||||||
|
2) offset=32 name=r;;
|
||||||
|
3) offset=48 name=s;;
|
||||||
|
4) offset=64 name=t;;
|
||||||
|
5) offset=80 name=u;;
|
||||||
|
*) echo bad unit for pty in: $i;;
|
||||||
|
esac
|
||||||
|
case $class in
|
||||||
|
0|1|2|3|4|5)
|
||||||
|
umask 0
|
||||||
|
eval `echo $offset $name | awk ' { b=$1; n=$2 } END {
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
printf("mknod tty%s%x c 11 %d; \
|
||||||
|
mknod pty%s%x c 10 %d; ", \
|
||||||
|
n, i, b+i, n, i, b+i); }'`
|
||||||
|
umask 77
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
dr*)
|
||||||
|
unit=`expr $i : '..\(.*\)'`
|
||||||
|
case $i in
|
||||||
|
dr*) name=dr; chr=12;;
|
||||||
|
esac
|
||||||
|
case $unit in
|
||||||
|
0|1|2|3|4|5|6|7)
|
||||||
|
umask 0
|
||||||
|
mknod ${name}${unit} c ${chr} ${unit}
|
||||||
|
umask 77
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo bad unit for ${name} in: $i
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
|
||||||
|
ingreslock)
|
||||||
|
mknod ingreslock c 25 0
|
||||||
|
chown ingres ingreslock
|
||||||
|
chmod 200 ingreslock
|
||||||
;;
|
;;
|
||||||
|
|
||||||
local)
|
local)
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
/dev/rd0a / ufs rw,async 1 1
|
/dev/sd0 / ufs rw,async 1 1
|
||||||
#/dev/rd0c /u ufs rw,async 1 2
|
#/dev/sd1 /u ufs rw,async 1 2
|
||||||
|
|||||||
@@ -80,8 +80,6 @@ v|std.3500000|3500000-baud:\
|
|||||||
:sp#3500000:
|
:sp#3500000:
|
||||||
w|std.4000000|4000000-baud:\
|
w|std.4000000|4000000-baud:\
|
||||||
:sp#4000000:
|
:sp#4000000:
|
||||||
x|std.default|default-baud:\
|
|
||||||
:sp#0:
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
3
etc/rc
3
etc/rc
@@ -3,8 +3,6 @@ HOME=/; export HOME
|
|||||||
PATH=/bin:/sbin; export PATH
|
PATH=/bin:/sbin; export PATH
|
||||||
exec >/dev/console 2>&1
|
exec >/dev/console 2>&1
|
||||||
|
|
||||||
/sbin/devupdate
|
|
||||||
|
|
||||||
if test "$1" != "autoboot"; then
|
if test "$1" != "autoboot"; then
|
||||||
#
|
#
|
||||||
# Switch from single-user to multi-user mode.
|
# Switch from single-user to multi-user mode.
|
||||||
@@ -66,7 +64,6 @@ rm -f /etc/nologin
|
|||||||
|
|
||||||
echo -n "Starting daemons:"
|
echo -n "Starting daemons:"
|
||||||
update && echo -n "update"
|
update && echo -n "update"
|
||||||
cron && echo -n "cron"
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
#/etc/rc.local
|
#/etc/rc.local
|
||||||
|
|||||||
14
etc/ttys
14
etc/ttys
@@ -1,16 +1,4 @@
|
|||||||
#
|
#
|
||||||
# name getty type status comments
|
# name getty type status comments
|
||||||
#
|
#
|
||||||
console "/libexec/getty std.default" xterm on secure #special
|
console "/libexec/getty std.115200" vt100 on secure #special
|
||||||
|
|
||||||
# Enable some of these for additional logins. Do NOT enable the same one as the
|
|
||||||
# console port, or strange things will happen. You can turn off the console port
|
|
||||||
# if you would rather use the getty on the real tty - it's up to you.
|
|
||||||
|
|
||||||
tty0 "/libexec/getty std.default" xterm off secure
|
|
||||||
tty1 "/libexec/getty std.default" xterm off secure
|
|
||||||
tty2 "/libexec/getty std.default" xterm off secure
|
|
||||||
tty3 "/libexec/getty std.default" xterm off secure
|
|
||||||
tty4 "/libexec/getty std.default" xterm off secure
|
|
||||||
tty5 "/libexec/getty std.default" xterm off secure
|
|
||||||
ttyUSB0 "/libexec/getty std.default" xterm off secure
|
|
||||||
|
|||||||
1
games/.gitignore
vendored
1
games/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
Binary file not shown.
@@ -33,36 +33,48 @@
|
|||||||
#ifndef _AOUT_H_
|
#ifndef _AOUT_H_
|
||||||
#define _AOUT_H_
|
#define _AOUT_H_
|
||||||
|
|
||||||
#include <sys/exec_aout.h>
|
#include <sys/exec.h>
|
||||||
|
|
||||||
|
/* Valid magic number check. */
|
||||||
|
#define N_BADMAG(x) (((x).a_magic) != RMAGIC && \
|
||||||
|
((x).a_magic) != OMAGIC && \
|
||||||
|
((x).a_magic) != NMAGIC)
|
||||||
|
|
||||||
|
/* Text segment offset. */
|
||||||
|
#define N_TXTOFF(x) sizeof(struct exec)
|
||||||
|
|
||||||
|
/* Data segment offset. */
|
||||||
|
#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
|
||||||
|
|
||||||
|
/* Text relocation table offset. */
|
||||||
|
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
|
||||||
|
|
||||||
|
/* Data relocation table offset. */
|
||||||
|
#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_reltext)
|
||||||
|
|
||||||
|
/* Symbol table offset. */
|
||||||
|
#define N_SYMOFF(x) ((x).a_magic == RMAGIC ? \
|
||||||
|
N_DRELOFF(x) + (x).a_reldata : \
|
||||||
|
N_DATOFF(x) + (x).a_data)
|
||||||
|
|
||||||
#define _AOUT_INCLUDE_
|
#define _AOUT_INCLUDE_
|
||||||
#include <nlist.h>
|
#include <nlist.h>
|
||||||
|
|
||||||
/* Relocations */
|
/* Relocations */
|
||||||
struct reloc {
|
|
||||||
unsigned flags;
|
|
||||||
#define RSMASK 0x70 /* bitmask for segments */
|
#define RSMASK 0x70 /* bitmask for segments */
|
||||||
#define RABS 0
|
#define RABS 0
|
||||||
#define RTEXT 0x20
|
#define RTEXT 0x20
|
||||||
#define RDATA 0x30
|
#define RDATA 0x30
|
||||||
#define RBSS 0x40
|
#define RBSS 0x40
|
||||||
#define RSTRNG 0x60 /* for assembler */
|
#define RSTRNG 0x60 /* for assembler */
|
||||||
#define REXT 0x70 /* externals and bitmask */
|
#define REXT 0x70 /* externals and bitmask */
|
||||||
|
|
||||||
#define RGPREL 0x08 /* gp relative */
|
|
||||||
|
|
||||||
#define RFMASK 0x07 /* bitmask for format */
|
#define RFMASK 0x07 /* bitmask for format */
|
||||||
#define RBYTE16 0x00 /* low part of byte address: bits 15:0 */
|
#define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */
|
||||||
#define RBYTE32 0x01 /* 32-bit byte address */
|
#define RWORD16 0x03 /* word address: bits 17:2 */
|
||||||
#define RHIGH16 0x02 /* upper part of byte address: bits 31:16 */
|
#define RWORD26 0x04 /* word address: bits 27:2 */
|
||||||
#define RHIGH16S 0x03 /* upper part of address with signed offset */
|
|
||||||
#define RWORD16 0x04 /* word address: bits 17:2 */
|
|
||||||
#define RWORD26 0x05 /* word address: bits 27:2 */
|
|
||||||
|
|
||||||
unsigned index; /* 24-bit index in symbol table,
|
#define RINDEX(h) ((h) >> 8)
|
||||||
* for REXT */
|
#define RSETINDEX(h) ((h) << 8)
|
||||||
unsigned offset; /* 16-bit offset,
|
|
||||||
* for RIGH16 and RIGH16S */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* !_AOUT_H_ */
|
#endif /* !_AOUT_H_ */
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
/* alloca.h - Allocate memory on stack */
|
|
||||||
|
|
||||||
#ifndef ALLOCA_H
|
|
||||||
#define ALLOCA_H
|
|
||||||
|
|
||||||
#undef alloca
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#define alloca(size) __builtin_alloca(size)
|
|
||||||
#else
|
|
||||||
#include <sys/types.h>
|
|
||||||
void *alloca(size_t);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
#include <sgtty.h>
|
#include <sgtty.h>
|
||||||
#include <term.h>
|
#include <term.h>
|
||||||
|
|
||||||
#define bool int
|
#define bool char
|
||||||
#define reg register
|
#define reg register
|
||||||
|
|
||||||
#define TRUE (1)
|
#define TRUE (1)
|
||||||
@@ -149,7 +149,7 @@ int __void__;
|
|||||||
#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
||||||
#define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty))
|
#define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty))
|
||||||
#define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty))
|
#define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty))
|
||||||
#define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), _res_flg = _tty.sg_flags)
|
#define savetty() ((void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
|
||||||
#define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty))
|
#define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty))
|
||||||
|
|
||||||
#define erasechar() (_tty.sg_erase)
|
#define erasechar() (_tty.sg_erase)
|
||||||
@@ -167,24 +167,11 @@ int wgetch (WINDOW *);
|
|||||||
char *wstandout (WINDOW *);
|
char *wstandout (WINDOW *);
|
||||||
char *wstandend (WINDOW *);
|
char *wstandend (WINDOW *);
|
||||||
int touchwin (WINDOW *);
|
int touchwin (WINDOW *);
|
||||||
int touchline (WINDOW *, int, int, int);
|
int touchline (WINDOW *, int, int);
|
||||||
void box (WINDOW *, char, char);
|
int box (WINDOW *, char, char);
|
||||||
void endwin (void);
|
void endwin (void);
|
||||||
int printw (char *, ...);
|
int printw (char *fmt, ...);
|
||||||
int wprintw (WINDOW *, char *, ...);
|
int wprintw (WINDOW *win, char *fmt, ...);
|
||||||
int scroll (WINDOW *);
|
|
||||||
void wclrtoeol (WINDOW *);
|
|
||||||
void werase (WINDOW *);
|
|
||||||
int setterm (char *);
|
|
||||||
int delwin (WINDOW *);
|
|
||||||
int waddstr (WINDOW *, char *);
|
|
||||||
int wgetstr (WINDOW *, char *);
|
|
||||||
int wdeleteln (WINDOW *);
|
|
||||||
void mvcur(int ly, int lx, int y, int x);
|
|
||||||
void overwrite(WINDOW *win1, WINDOW *win2);
|
|
||||||
void wclrtobot(WINDOW *win);
|
|
||||||
int mvprintw(int y, int x, char *fmt, ...);
|
|
||||||
int mvwprintw(WINDOW *win, int y, int x, char *fmt, ...);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used to be in unctrl.h.
|
* Used to be in unctrl.h.
|
||||||
|
|||||||
@@ -7,9 +7,4 @@ struct group { /* see getgrent(3) */
|
|||||||
char **gr_mem;
|
char **gr_mem;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct group *getgrent(void);
|
struct group *getgrent(), *getgrgid(), *getgrnam();
|
||||||
struct group *getgrnam(const char *name);
|
|
||||||
struct group *getgrgid(gid_t gid);
|
|
||||||
void setgrent(void);
|
|
||||||
void endgrent(void);
|
|
||||||
int setgroups(size_t size, const gid_t *list);
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#ifndef _KMEM_H
|
|
||||||
#define _KMEM_H
|
|
||||||
|
|
||||||
extern dev_t kmemdev();
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -35,7 +35,8 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Symbol table entry format.
|
* Symbol table entry format. The #ifdef's are so that programs including
|
||||||
|
* nlist.h can initialize nlist structures statically.
|
||||||
*/
|
*/
|
||||||
struct nlist {
|
struct nlist {
|
||||||
char *n_name; /* In memory address of symbol name,
|
char *n_name; /* In memory address of symbol name,
|
||||||
@@ -55,12 +56,13 @@ struct nlist {
|
|||||||
#define N_BSS 0x04 /* bss segment */
|
#define N_BSS 0x04 /* bss segment */
|
||||||
#define N_STRNG 0x05 /* string segment (for assembler) */
|
#define N_STRNG 0x05 /* string segment (for assembler) */
|
||||||
#define N_COMM 0x06 /* .comm segment (for assembler) */
|
#define N_COMM 0x06 /* .comm segment (for assembler) */
|
||||||
|
#define N_REG 0x14 /* register symbol */
|
||||||
#define N_FN 0x1f /* file name */
|
#define N_FN 0x1f /* file name */
|
||||||
|
|
||||||
#define N_TYPE 0x1f /* mask for all the type bits */
|
|
||||||
#define N_EXT 0x20 /* external (global) bit, OR'ed in */
|
#define N_EXT 0x20 /* external (global) bit, OR'ed in */
|
||||||
#define N_WEAK 0x40 /* weak reference bit, OR'ed in */
|
#define N_TYPE 0x1f /* mask for all the type bits */
|
||||||
#define N_LOC 0x80 /* local, for assembler */
|
|
||||||
|
#define N_FORMAT "%06o" /* namelist value format; XXX */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get symbols from a file.
|
* Get symbols from a file.
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
struct ranlib {
|
struct ranlib {
|
||||||
int ran_len; /* 1 byte - name length in bytes */
|
int ran_len; /* 1 byte - name length in bytes */
|
||||||
unsigned ran_off; /* 4 bytes - file offset */
|
off_t ran_off; /* 4 bytes - file offset */
|
||||||
char *ran_name; /* in memory symbol name */
|
char *ran_name; /* in memory symbol name */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,29 +14,9 @@
|
|||||||
* 9 - $ra - return address
|
* 9 - $ra - return address
|
||||||
* 10 - $gp - global data pointer
|
* 10 - $gp - global data pointer
|
||||||
* 11 - $sp - stack pointer
|
* 11 - $sp - stack pointer
|
||||||
* 12 - signal mask saved
|
|
||||||
* 13 - signal mask
|
|
||||||
*/
|
*/
|
||||||
typedef int jmp_buf [14];
|
typedef int jmp_buf [12];
|
||||||
typedef jmp_buf sigjmp_buf;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Save and restore only CPU state.
|
|
||||||
* Signal mask is not saved.
|
|
||||||
*/
|
|
||||||
int _setjmp (jmp_buf env);
|
|
||||||
void _longjmp (jmp_buf env, int val);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Save and restore CPU state and signal mask.
|
|
||||||
*/
|
|
||||||
int setjmp (jmp_buf env);
|
int setjmp (jmp_buf env);
|
||||||
void longjmp (jmp_buf env, int val);
|
void longjmp (jmp_buf env, int val);
|
||||||
|
|
||||||
/*
|
|
||||||
* Save and restore CPU state and optionally a signal mask.
|
|
||||||
* Signal mask is saved only when savesigs is nonzero.
|
|
||||||
*/
|
|
||||||
int sigsetjmp (sigjmp_buf env, int savesigs);
|
|
||||||
void siglongjmp (sigjmp_buf env, int val);
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
/*
|
|
||||||
* SmallC: interface to curses library.
|
|
||||||
*/
|
|
||||||
#define WINDOW int
|
|
||||||
|
|
||||||
extern WINDOW *stdscr, *curscr;
|
|
||||||
|
|
||||||
extern int LINES, COLS;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pseudo functions for standard screen
|
|
||||||
*/
|
|
||||||
#define addch(ch) waddch(stdscr, ch)
|
|
||||||
#define getch() wgetch(stdscr)
|
|
||||||
#define addstr(str) waddstr(stdscr, str)
|
|
||||||
#define getstr(str) wgetstr(stdscr, str)
|
|
||||||
#define move(y, x) wmove(stdscr, y, x)
|
|
||||||
#define clear() wclear(stdscr)
|
|
||||||
#define erase() werase(stdscr)
|
|
||||||
#define clrtobot() wclrtobot(stdscr)
|
|
||||||
#define clrtoeol() wclrtoeol(stdscr)
|
|
||||||
#define insertln() winsertln(stdscr)
|
|
||||||
#define deleteln() wdeleteln(stdscr)
|
|
||||||
#define refresh() wrefresh(stdscr)
|
|
||||||
#define inch() winch(stdscr)
|
|
||||||
#define insch(c) winsch(stdscr,c)
|
|
||||||
#define delch() wdelch(stdscr)
|
|
||||||
#define standout() wstandout(stdscr)
|
|
||||||
#define standend() wstandend(stdscr)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* mv functions
|
|
||||||
*/
|
|
||||||
#define mvwaddch(win,y,x,ch) wmove(win,y,x) == 0 ? 0 : waddch(win,ch)
|
|
||||||
#define mvwgetch(win,y,x) wmove(win,y,x) == 0 ? 0 : wgetch(win)
|
|
||||||
#define mvwaddstr(win,y,x,str) wmove(win,y,x) == 0 ? 0 : waddstr(win,str)
|
|
||||||
#define mvwgetstr(win,y,x,str) wmove(win,y,x) == 0 ? 0 : wgetstr(win,str)
|
|
||||||
#define mvwinch(win,y,x) wmove(win,y,x) == 0 ? 0 : winch(win)
|
|
||||||
#define mvwdelch(win,y,x) wmove(win,y,x) == 0 ? 0 : wdelch(win)
|
|
||||||
#define mvwinsch(win,y,x,c) wmove(win,y,x) == 0 ? 0 : winsch(win,c)
|
|
||||||
#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
|
|
||||||
#define mvgetch(y,x) mvwgetch(stdscr,y,x)
|
|
||||||
#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
|
|
||||||
#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
|
|
||||||
#define mvinch(y,x) mvwinch(stdscr,y,x)
|
|
||||||
#define mvdelch(y,x) mvwdelch(stdscr,y,x)
|
|
||||||
#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
|
|
||||||
|
|
||||||
#ifdef TODO
|
|
||||||
|
|
||||||
#define TRUE (1)
|
|
||||||
#define FALSE (0)
|
|
||||||
#define ERR (0)
|
|
||||||
#define OK (1)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Capabilities from termcap
|
|
||||||
*/
|
|
||||||
extern int AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
|
|
||||||
XB, XN, XT, XS, XX;
|
|
||||||
extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
|
|
||||||
*DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
|
|
||||||
*K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
|
|
||||||
*KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
|
|
||||||
*SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
|
|
||||||
*VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
|
|
||||||
*LEFT_PARM, *RIGHT_PARM;
|
|
||||||
extern char PC;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* From the tty modes...
|
|
||||||
*/
|
|
||||||
extern int GT, NONL, UPPERCASE, normtty, _pfast;
|
|
||||||
|
|
||||||
extern int My_term, _echoit, _rawmode, _endwin;
|
|
||||||
|
|
||||||
extern char *Def_term, ttytype[];
|
|
||||||
|
|
||||||
extern int _tty_ch, _res_flg;
|
|
||||||
|
|
||||||
extern SGTTY _tty;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pseudo functions
|
|
||||||
*/
|
|
||||||
#define clearok(win,bf) (win->_clear = bf)
|
|
||||||
#define leaveok(win,bf) (win->_leave = bf)
|
|
||||||
#define scrollok(win,bf) (win->_scroll = bf)
|
|
||||||
#define flushok(win,bf) (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
|
|
||||||
#define getyx(win,y,x) y = win->_cury, x = win->_curx
|
|
||||||
#define winch(win) (win->_y[win->_cury][win->_curx] & 0177)
|
|
||||||
|
|
||||||
#define raw() (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define noraw() (_tty.sg_flags&=~RAW,_rawmode=FALSE,_pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE,ioctl(_tty_ch,TIOCSETP,&_tty))
|
|
||||||
#define echo() (_tty.sg_flags |= ECHO, _echoit = TRUE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
#define nl() (_tty.sg_flags |= CRMOD, _pfast = _rawmode,ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
#define nonl() (_tty.sg_flags &= ~CRMOD,_pfast = TRUE, ioctl(_tty_ch, TIOCSETP,&_tty))
|
|
||||||
#define savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), _res_flg = _tty.sg_flags)
|
|
||||||
#define resetty() (_tty.sg_flags = _res_flg, (void) ioctl(_tty_ch, TIOCSETP, &_tty))
|
|
||||||
|
|
||||||
#define erasechar() (_tty.sg_erase)
|
|
||||||
#define killchar() (_tty.sg_kill)
|
|
||||||
#define baudrate() (_tty.sg_ospeed)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Used to be in unctrl.h.
|
|
||||||
*/
|
|
||||||
#define unctrl(c) _unctrl[(c) & 0177]
|
|
||||||
extern char *_unctrl[];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
|
|
||||||
/* open-only flags */
|
|
||||||
#define O_RDONLY 0x0000 /* open for reading only */
|
|
||||||
#define O_WRONLY 0x0001 /* open for writing only */
|
|
||||||
#define O_RDWR 0x0002 /* open for reading and writing */
|
|
||||||
#define O_ACCMODE 0x0003 /* mask for above modes */
|
|
||||||
|
|
||||||
#define O_NONBLOCK 0x0004 /* no delay */
|
|
||||||
#define O_APPEND 0x0008 /* set append mode */
|
|
||||||
#define O_SHLOCK 0x0010 /* open with shared file lock */
|
|
||||||
#define O_EXLOCK 0x0020 /* open with exclusive file lock */
|
|
||||||
#define O_ASYNC 0x0040 /* signal pgrp when data ready */
|
|
||||||
#define O_FSYNC 0x0080 /* synchronous writes */
|
|
||||||
#define O_CREAT 0x0200 /* create if nonexistant */
|
|
||||||
#define O_TRUNC 0x0400 /* truncate to zero length */
|
|
||||||
#define O_EXCL 0x0800 /* error if already exists */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Constants used for fcntl(2)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* command values */
|
|
||||||
#define F_DUPFD 0 /* duplicate file descriptor */
|
|
||||||
#define F_GETFD 1 /* get file descriptor flags */
|
|
||||||
#define F_SETFD 2 /* set file descriptor flags */
|
|
||||||
#define F_GETFL 3 /* get file status flags */
|
|
||||||
#define F_SETFL 4 /* set file status flags */
|
|
||||||
#define F_GETOWN 5 /* get SIGIO/SIGURG proc/pgrp */
|
|
||||||
#define F_SETOWN 6 /* set SIGIO/SIGURG proc/pgrp */
|
|
||||||
|
|
||||||
/* file descriptor flags (F_GETFD, F_SETFD) */
|
|
||||||
#define FD_CLOEXEC 1 /* close-on-exec flag */
|
|
||||||
|
|
||||||
/* lock operations for flock() */
|
|
||||||
#define LOCK_SH 1 /* shared file lock */
|
|
||||||
#define LOCK_EX 2 /* exclusive file lock */
|
|
||||||
#define LOCK_NB 4 /* don't block when locking */
|
|
||||||
#define LOCK_UN 8 /* unlock file */
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 1986 Regents of the University of California.
|
|
||||||
* All rights reserved. The Berkeley software License Agreement
|
|
||||||
* specifies the terms and conditions for redistribution.
|
|
||||||
*/
|
|
||||||
#ifndef NSIG
|
|
||||||
|
|
||||||
#define NSIG 32
|
|
||||||
|
|
||||||
#define SIGHUP 1 /* hangup */
|
|
||||||
#define SIGINT 2 /* interrupt */
|
|
||||||
#define SIGQUIT 3 /* quit */
|
|
||||||
#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
|
||||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
|
||||||
#define SIGIOT 6 /* IOT instruction */
|
|
||||||
#define SIGABRT SIGIOT /* compatibility */
|
|
||||||
#define SIGEMT 7 /* EMT instruction */
|
|
||||||
#define SIGFPE 8 /* floating point exception */
|
|
||||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
|
||||||
#define SIGBUS 10 /* bus error */
|
|
||||||
#define SIGSEGV 11 /* segmentation violation */
|
|
||||||
#define SIGSYS 12 /* bad argument to system call */
|
|
||||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
|
||||||
#define SIGALRM 14 /* alarm clock */
|
|
||||||
#define SIGTERM 15 /* software termination signal from kill */
|
|
||||||
#define SIGURG 16 /* urgent condition on IO channel */
|
|
||||||
#define SIGSTOP 17 /* sendable stop signal not from tty */
|
|
||||||
#define SIGTSTP 18 /* stop signal from tty */
|
|
||||||
#define SIGCONT 19 /* continue a stopped process */
|
|
||||||
#define SIGCHLD 20 /* to parent on child stop or exit */
|
|
||||||
#define SIGCLD SIGCHLD /* compatibility */
|
|
||||||
#define SIGTTIN 21 /* to readers pgrp upon background tty read */
|
|
||||||
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
|
|
||||||
#define SIGIO 23 /* input/output possible signal */
|
|
||||||
#define SIGXCPU 24 /* exceeded CPU time limit */
|
|
||||||
#define SIGXFSZ 25 /* exceeded file size limit */
|
|
||||||
#define SIGVTALRM 26 /* virtual time alarm */
|
|
||||||
#define SIGPROF 27 /* profiling time alarm */
|
|
||||||
#define SIGWINCH 28 /* window size changes */
|
|
||||||
#define SIGUSR1 30 /* user defined signal 1 */
|
|
||||||
#define SIGUSR2 31 /* user defined signal 2 */
|
|
||||||
|
|
||||||
#define SIG_ERR -1
|
|
||||||
#define SIG_DFL 0
|
|
||||||
#define SIG_IGN 1
|
|
||||||
#define BADSIG SIG_ERR
|
|
||||||
|
|
||||||
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
|
|
||||||
#define SA_RESTART 0x0002 /* restart system on signal return */
|
|
||||||
#define SA_DISABLE 0x0004 /* disable taking signals on alternate stack */
|
|
||||||
#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Flags for sigprocmask:
|
|
||||||
*/
|
|
||||||
#define SIG_BLOCK 1 /* block specified signal set */
|
|
||||||
#define SIG_UNBLOCK 2 /* unblock specified signal set */
|
|
||||||
#define SIG_SETMASK 3 /* set specified signal set */
|
|
||||||
|
|
||||||
#define MINSIGSTKSZ 128 /* minimum allowable stack */
|
|
||||||
#define SIGSTKSZ (MINSIGSTKSZ + 384) /* recommended stack size */
|
|
||||||
|
|
||||||
#define SV_ONSTACK SA_ONSTACK /* take signal on signal stack */
|
|
||||||
#define SV_INTERRUPT SA_RESTART /* same bit, opposite sense */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Macro for converting signal number to a mask suitable for
|
|
||||||
* sigblock().
|
|
||||||
*/
|
|
||||||
#define sigmask(m) (1L << ((m)-1))
|
|
||||||
#define sigaddset(set, signo) (*(set) |= 1L << ((signo) - 1), 0)
|
|
||||||
#define sigdelset(set, signo) (*(set) &= ~(1L << ((signo) - 1)), 0)
|
|
||||||
#define sigemptyset(set) (*(set) = (sigset_t)0, (int)0)
|
|
||||||
#define sigfillset(set) (*(set) = ~(sigset_t)0, (int)0)
|
|
||||||
#define sigismember(set, signo) ((*(set) & (1L << ((signo) - 1))) != 0)
|
|
||||||
|
|
||||||
#endif /* NSIG */
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* SmallC: interface to stdio library.
|
|
||||||
*/
|
|
||||||
#define BUFSIZ 1024
|
|
||||||
|
|
||||||
#ifndef NULL
|
|
||||||
#define NULL 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FILE int
|
|
||||||
#define EOF (-1)
|
|
||||||
|
|
||||||
extern int _iob[];
|
|
||||||
|
|
||||||
#define stdin (&_iob[0])
|
|
||||||
#define stdout (&_iob[5])
|
|
||||||
#define stderr (&_iob[10])
|
|
||||||
|
|
||||||
#define SEEK_SET 0 /* set file offset to offset */
|
|
||||||
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
|
||||||
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
|
||||||
|
|
||||||
#define getc fgetc
|
|
||||||
#define putc fputc
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Ioctl definitions for GPIO driver.
|
|
||||||
*/
|
|
||||||
#define GPIO_PORT(n) (n) /* port number */
|
|
||||||
#define GPIO_PORTA 0
|
|
||||||
#define GPIO_PORTB 1
|
|
||||||
#define GPIO_PORTC 2
|
|
||||||
#define GPIO_PORTD 3
|
|
||||||
#define GPIO_PORTE 4
|
|
||||||
#define GPIO_PORTF 5
|
|
||||||
#define GPIO_PORTG 6
|
|
||||||
|
|
||||||
#define GPIO_CONFIN 0x20016700 /* configure as input */
|
|
||||||
#define GPIO_CONFOUT 0x20026700 /* configure as output */
|
|
||||||
#define GPIO_CONFOD 0x20046700 /* configure as open drain */
|
|
||||||
#define GPIO_DECONF 0x20086700 /* deconfigure */
|
|
||||||
#define GPIO_STORE 0x20106700 /* store all outputs */
|
|
||||||
#define GPIO_SET 0x20206700 /* set to 1 by mask */
|
|
||||||
#define GPIO_CLEAR 0x20406700 /* set to 0 by mask */
|
|
||||||
#define GPIO_INVERT 0x20806700 /* invert by mask */
|
|
||||||
#define GPIO_POLL 0x21006700 /* poll */
|
|
||||||
#define GPIO_LOL 0x82006700 /* display lol picture */
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
* Ioctl definitions for SPI driver.
|
|
||||||
*/
|
|
||||||
#define SPICTL_SETMODE 0x20007000 /* set SPI mode */
|
|
||||||
#define SPICTL_SETRATE 0x20007001 /* set clock rate, kHz */
|
|
||||||
#define SPICTL_SETSELPIN 0x20007002 /* set select pin */
|
|
||||||
#define SPICTL_IO8(n) (0xc0007003 | (n)<<16) /* transfer n*8 bits */
|
|
||||||
#define SPICTL_IO16(n) (0xc0007004 | (n)<<16) /* transfer n*16 bits */
|
|
||||||
#define SPICTL_IO32(n) (0xc0007005 | (n)<<16) /* transfer n*32 bits */
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
/*
|
|
||||||
* SmallC: interface to wiznet library.
|
|
||||||
*/
|
|
||||||
#define MAX_SOCK_NUM 4 /* Max number of sockets per chip */
|
|
||||||
#define CLIENT_SIZE 3 /* Size of client structure in words */
|
|
||||||
#define UDP_SIZE 2 /* Size of UDP structure in words */
|
|
||||||
|
|
||||||
extern unsigned _socket_port[];
|
|
||||||
|
|
||||||
extern unsigned _client_srcport;
|
|
||||||
|
|
||||||
extern unsigned _server_port;
|
|
||||||
@@ -4,49 +4,27 @@
|
|||||||
#ifndef _STDARG_H
|
#ifndef _STDARG_H
|
||||||
#define _STDARG_H
|
#define _STDARG_H
|
||||||
|
|
||||||
/*
|
/* Define __gnuc_va_list. */
|
||||||
* Define va_start, va_arg, va_end, va_copy.
|
|
||||||
*/
|
|
||||||
#if defined(__GNUC__) /* Gnu C */
|
|
||||||
# define va_start(ap, last) __builtin_va_start((ap), last)
|
|
||||||
# define va_arg(ap, type) __builtin_va_arg((ap), type)
|
|
||||||
# define va_end(ap) __builtin_va_end((ap))
|
|
||||||
# define va_copy(dest, src) __builtin_va_copy((dest), (src))
|
|
||||||
|
|
||||||
#elif defined(__PCC__) /* PCC */
|
#ifndef __GNUC_VA_LIST
|
||||||
# define va_start(ap, last) __builtin_stdarg_start((ap), last)
|
#define __GNUC_VA_LIST
|
||||||
# define va_arg(ap, type) __builtin_va_arg((ap), type)
|
typedef __builtin_va_list __gnuc_va_list;
|
||||||
# define va_end(ap) __builtin_va_end((ap))
|
|
||||||
# define va_copy(dest, src) __builtin_va_copy((dest), (src))
|
|
||||||
|
|
||||||
#else /* SmallerC, LCC */
|
|
||||||
# define va_start(ap, last) (ap = ((char*)&(last) + \
|
|
||||||
(((sizeof(last) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))))
|
|
||||||
# define va_arg(ap, type) ((type*)(ap += \
|
|
||||||
sizeof(type) == sizeof(int) ? sizeof(type) : \
|
|
||||||
(-(int)(ap) & (sizeof(type) - 1)) + sizeof(type)))[-1]
|
|
||||||
# define va_end(ap)
|
|
||||||
# define va_copy(dest, src) (dest = (src))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
#ifdef __GNUC__
|
||||||
* Define va_list.
|
# define va_start(ap, last) __builtin_va_start((ap), last)
|
||||||
*/
|
|
||||||
#ifndef _VA_LIST_T
|
|
||||||
# define _VA_LIST_T
|
|
||||||
# if defined(__GNUC__) || defined(__PCC__)
|
|
||||||
typedef __builtin_va_list va_list;
|
|
||||||
# else
|
|
||||||
typedef char *va_list;
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __PCC__
|
||||||
|
# define va_start(ap, last) __builtin_stdarg_start((ap), last)
|
||||||
|
#endif
|
||||||
|
#define va_arg(ap, type) __builtin_va_arg((ap), type)
|
||||||
|
#define va_end(ap) __builtin_va_end((ap))
|
||||||
|
#define va_copy(dest, src) __builtin_va_copy((dest), (src))
|
||||||
|
|
||||||
/*
|
|
||||||
* Define __gnuc_va_list.
|
#ifndef _VA_LIST
|
||||||
*/
|
#define _VA_LIST
|
||||||
#if defined(__GNUC__) && !defined(__GNUC_VA_LIST)
|
typedef __gnuc_va_list va_list;
|
||||||
# define __GNUC_VA_LIST
|
|
||||||
typedef __builtin_va_list __gnuc_va_list;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* not _STDARG_H */
|
#endif /* not _STDARG_H */
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
|
|
||||||
/* Offset of member MEMBER in a struct of type TYPE. */
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && __GNUC__ > 3
|
|
||||||
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
|
|
||||||
#else
|
|
||||||
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE*)0)->MEMBER)
|
|
||||||
#endif
|
|
||||||
@@ -14,7 +14,7 @@ extern struct _iobuf {
|
|||||||
char *_base; /* ditto */
|
char *_base; /* ditto */
|
||||||
int _bufsiz;
|
int _bufsiz;
|
||||||
short _flag;
|
short _flag;
|
||||||
short _file;
|
char _file; /* should be short */
|
||||||
} _iob[];
|
} _iob[];
|
||||||
|
|
||||||
#define _IOREAD 01
|
#define _IOREAD 01
|
||||||
@@ -73,7 +73,6 @@ FILE *fopen (const char *, const char *);
|
|||||||
FILE *fdopen (int, const char *);
|
FILE *fdopen (int, const char *);
|
||||||
FILE *freopen (const char *, const char *, FILE *);
|
FILE *freopen (const char *, const char *, FILE *);
|
||||||
FILE *popen (const char *, const char *);
|
FILE *popen (const char *, const char *);
|
||||||
FILE *tmpfile (void);
|
|
||||||
int fclose (FILE *);
|
int fclose (FILE *);
|
||||||
long ftell (FILE *);
|
long ftell (FILE *);
|
||||||
int fflush (FILE *);
|
int fflush (FILE *);
|
||||||
@@ -94,8 +93,6 @@ int setvbuf (FILE *, char *, int, size_t);
|
|||||||
int fseek (FILE *, long, int);
|
int fseek (FILE *, long, int);
|
||||||
void rewind (FILE *);
|
void rewind (FILE *);
|
||||||
int remove (const char *);
|
int remove (const char *);
|
||||||
int getw(FILE *stream);
|
|
||||||
int putw(int w, FILE *stream);
|
|
||||||
|
|
||||||
size_t fread (void *, size_t, size_t, FILE *);
|
size_t fread (void *, size_t, size_t, FILE *);
|
||||||
size_t fwrite (const void *, size_t, size_t, FILE *);
|
size_t fwrite (const void *, size_t, size_t, FILE *);
|
||||||
@@ -110,12 +107,7 @@ int scanf (const char *, ...);
|
|||||||
int sscanf (const char *, const char *, ...);
|
int sscanf (const char *, const char *, ...);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# ifdef __GNUC__
|
#define va_list __builtin_va_list /* For GCC */
|
||||||
# define va_list __builtin_va_list /* For Gnu C */
|
|
||||||
# endif
|
|
||||||
# ifdef __SMALLER_C__
|
|
||||||
# define va_list char * /* For Smaller C */
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int vfprintf (FILE *, const char *, va_list);
|
int vfprintf (FILE *, const char *, va_list);
|
||||||
@@ -131,7 +123,7 @@ int _doprnt (const char *, va_list, FILE *);
|
|||||||
int _doscan (FILE *, const char *, va_list);
|
int _doscan (FILE *, const char *, va_list);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# undef va_list
|
#undef va_list
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void perror (const char *);
|
void perror (const char *);
|
||||||
|
|||||||
@@ -54,51 +54,48 @@
|
|||||||
|
|
||||||
#define RAND_MAX 0x7fff
|
#define RAND_MAX 0x7fff
|
||||||
|
|
||||||
void abort (void);
|
void abort();
|
||||||
int abs (int);
|
int abs (int);
|
||||||
int atexit (void (*)(void));
|
int atexit (void (*)(void));
|
||||||
int atoi (const char *);
|
double atof();
|
||||||
long atol (const char *);
|
int atoi();
|
||||||
|
long atol();
|
||||||
void *calloc (size_t, size_t);
|
void *calloc (size_t, size_t);
|
||||||
void exit (int);
|
void exit (int);
|
||||||
void free (void *);
|
void free (void *);
|
||||||
char *getenv (const char *);
|
char *getenv();
|
||||||
long labs (long);
|
|
||||||
void *malloc (size_t);
|
void *malloc (size_t);
|
||||||
char *mktemp (char *);
|
char *mktemp (char *);
|
||||||
int mkstemp (char *);
|
int mkstemp (char *);
|
||||||
void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
|
void qsort();
|
||||||
int rand (void);
|
int rand();
|
||||||
void *realloc (void*, size_t);
|
void *realloc (void*, size_t);
|
||||||
void srand (unsigned);
|
void srand();
|
||||||
long strtol (const char *, char **, int);
|
double strtod();
|
||||||
unsigned long strtoul (const char *, char **, int);
|
long strtol();
|
||||||
int system (const char *);
|
unsigned long strtoul();
|
||||||
|
int system();
|
||||||
|
|
||||||
int putenv (char *string);
|
int putenv (char *string);
|
||||||
int setenv (const char *name, const char *value, int overwrite);
|
int setenv (const char *name, const char *value, int overwrite);
|
||||||
int unsetenv (const char *name);
|
int unsetenv (const char *name);
|
||||||
char *_findenv (const char *name, int *offset);
|
char *_findenv (const char *name, int *offset);
|
||||||
|
|
||||||
void *alloca (size_t size);
|
void *alloca();
|
||||||
|
|
||||||
int daemon (int, int);
|
int daemon();
|
||||||
char *devname (dev_t dev, mode_t type);
|
char *devname();
|
||||||
int getloadavg (unsigned loadavg[], int nelem);
|
int getloadavg(unsigned loadavg[], int nelem);
|
||||||
|
|
||||||
extern char *suboptarg; /* getsubopt(3) external variable */
|
extern char *suboptarg; /* getsubopt(3) external variable */
|
||||||
int getsubopt (char **, char **, char **);
|
int getsubopt();
|
||||||
|
|
||||||
long random (void);
|
long random (void);
|
||||||
char *setstate (char *);
|
char *setstate (char *);
|
||||||
void srandom (unsigned);
|
void srandom (unsigned);
|
||||||
|
|
||||||
#ifndef __SMALLER_C__
|
char *ecvt (double, int, int *, int *);
|
||||||
double atof (const char *);
|
char *fcvt (double, int, int *, int *);
|
||||||
double strtod (const char *, char **);
|
char *gcvt (double, int, char *);
|
||||||
char *ecvt (double, int, int *, int *);
|
|
||||||
char *fcvt (double, int, int *, int *);
|
|
||||||
char *gcvt (double, int, char *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _STDLIB_H_ */
|
#endif /* _STDLIB_H_ */
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ char *strtok_r (char *, const char *, char **);
|
|||||||
size_t strcspn (const char *, const char *);
|
size_t strcspn (const char *, const char *);
|
||||||
size_t strspn (const char *, const char *);
|
size_t strspn (const char *, const char *);
|
||||||
|
|
||||||
char *strerror (int);
|
const char *strerror (int);
|
||||||
const char *syserrlst (int);
|
const char *syserrlst (int);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
int bcmp(const void *, const void *, size_t);
|
int bcmp(const void *, const void *, size_t);
|
||||||
void bcopy(const void *, void *, size_t);
|
void bcopy(const void *, void *, size_t);
|
||||||
void bzero(void *, unsigned long);
|
void bzero(void *, size_t);
|
||||||
int ffs(int);
|
int ffs(int);
|
||||||
char *index(const char *, int);
|
char *index(const char *, int);
|
||||||
char *rindex(const char *, int);
|
char *rindex(const char *, int);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
#define SYS_getegid 48
|
#define SYS_getegid 48
|
||||||
#define SYS_setgid 49
|
#define SYS_setgid 49
|
||||||
#define SYS_setegid 50
|
#define SYS_setegid 50
|
||||||
#define SYS_kmemdev 51
|
/* 51 is old; acct */
|
||||||
#define SYS_phys 52
|
#define SYS_phys 52
|
||||||
#define SYS_lock 53
|
#define SYS_lock 53
|
||||||
#define SYS_ioctl 54
|
#define SYS_ioctl 54
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
#define SYS_rdglob 70
|
#define SYS_rdglob 70
|
||||||
#define SYS_wrglob 71
|
#define SYS_wrglob 71
|
||||||
/* 71 is unused 4.3: mmap */
|
/* 71 is unused 4.3: mmap */
|
||||||
#define SYS_msec 72 /* 72 is unused 4.3: vadvise */
|
/* 72 is unused 4.3: vadvise */
|
||||||
/* 73 is unused 4.3: munmap */
|
/* 73 is unused 4.3: munmap */
|
||||||
/* 74 is unused 4.3: mprotect */
|
/* 74 is unused 4.3: mprotect */
|
||||||
/* 75 is unused 4.3: madvise */
|
/* 75 is unused 4.3: madvise */
|
||||||
|
|||||||
@@ -2,9 +2,13 @@
|
|||||||
#define _TERM_H
|
#define _TERM_H
|
||||||
|
|
||||||
extern int tgetent(char *, char *);
|
extern int tgetent(char *, char *);
|
||||||
|
extern int tnchktc();
|
||||||
|
extern int tnamatch(char *);
|
||||||
|
extern char *tskip(register char *);
|
||||||
extern int tgetnum(char *);
|
extern int tgetnum(char *);
|
||||||
extern int tgetflag(char *);
|
extern int tgetflag(char *);
|
||||||
extern char *tgetstr(char *, char **);
|
extern char *tgetstr(char *, char **);
|
||||||
|
extern char *tdecode(register char *, char **);
|
||||||
extern char *tgoto(char *, int, int);
|
extern char *tgoto(char *, int, int);
|
||||||
extern int tputs(register char *, int, int (*)());
|
extern int tputs(register char *, int, int (*)());
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ struct ttyent { /* see getttyent(3) */
|
|||||||
|
|
||||||
struct ttyent *getttyent (void);
|
struct ttyent *getttyent (void);
|
||||||
struct ttyent *getttynam (const char *name);
|
struct ttyent *getttynam (const char *name);
|
||||||
void setttyent (void);
|
int setttyent (void);
|
||||||
void endttyent (void);
|
int endttyent (void);
|
||||||
|
|||||||
@@ -97,4 +97,4 @@ struct tzhead {
|
|||||||
** that will probably do.
|
** that will probably do.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
|
#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ void setusershell();
|
|||||||
void sync();
|
void sync();
|
||||||
unsigned int ualarm();
|
unsigned int ualarm();
|
||||||
void usleep();
|
void usleep();
|
||||||
int pause (void);
|
|
||||||
pid_t vfork();
|
pid_t vfork();
|
||||||
|
|
||||||
int pipe (int pipefd[2]);
|
int pipe (int pipefd[2]);
|
||||||
@@ -108,18 +107,11 @@ int chown (const char *path, uid_t owner, gid_t group);
|
|||||||
int nice (int inc);
|
int nice (int inc);
|
||||||
int setuid (uid_t uid);
|
int setuid (uid_t uid);
|
||||||
int setgid (gid_t gid);
|
int setgid (gid_t gid);
|
||||||
int seteuid (uid_t euid);
|
|
||||||
int setegid (gid_t egid);
|
|
||||||
int setreuid (uid_t ruid, uid_t euid);
|
|
||||||
int setregid (gid_t rgid, gid_t egid);
|
|
||||||
int isatty (int fd);
|
int isatty (int fd);
|
||||||
int chdir (const char *path);
|
int chdir (const char *path);
|
||||||
int fchdir (int fd);
|
int fchdir (int fd);
|
||||||
int chflags (const char *path, u_long flags);
|
int chflags (const char *path, u_long flags);
|
||||||
int fchflags (int fd, u_long flags);
|
int fchflags (int fd, u_long flags);
|
||||||
int getgroups (int size, gid_t list[]);
|
|
||||||
int getdtablesize (void);
|
|
||||||
int rmdir (const char *pathname);
|
|
||||||
|
|
||||||
struct stat;
|
struct stat;
|
||||||
int stat (const char *path, struct stat *buf);
|
int stat (const char *path, struct stat *buf);
|
||||||
@@ -143,12 +135,7 @@ extern char *optarg; /* getopt(3) external variables */
|
|||||||
extern int opterr, optind, optopt;
|
extern int opterr, optind, optopt;
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# ifdef __GNUC__
|
#define va_list __builtin_va_list /* For GCC */
|
||||||
# define va_list __builtin_va_list /* For Gnu C */
|
|
||||||
# endif
|
|
||||||
# ifdef __SMALLER_C__
|
|
||||||
# define va_list char * /* For Smaller C */
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void err (int eval, const char *fmt, ...);
|
void err (int eval, const char *fmt, ...);
|
||||||
@@ -161,6 +148,6 @@ void vwarn (const char *fmt, va_list ap);
|
|||||||
void vwarnx (const char *fmt, va_list ap);
|
void vwarnx (const char *fmt, va_list ap);
|
||||||
|
|
||||||
#ifndef _VA_LIST_
|
#ifndef _VA_LIST_
|
||||||
# undef va_list
|
#undef va_list
|
||||||
#endif
|
#endif
|
||||||
#endif /* !_UNISTD_H_ */
|
#endif /* !_UNISTD_H_ */
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "w5100.h"
|
#include "w5100.h"
|
||||||
|
|
||||||
extern unsigned _socket_port [MAX_SOCK_NUM];
|
extern uint16_t _socket_port [MAX_SOCK_NUM];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Opens a socket(TCP or UDP or IP_RAW mode)
|
* Opens a socket(TCP or UDP or IP_RAW mode)
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ void udp_stop (udp_t *u);
|
|||||||
/*
|
/*
|
||||||
* Send a packet to specified peer.
|
* Send a packet to specified peer.
|
||||||
*/
|
*/
|
||||||
unsigned udp_send_packet (udp_t *u, const uint8_t *data, unsigned len,
|
uint16_t udp_send_packet (udp_t *u, const uint8_t *data, unsigned len,
|
||||||
uint8_t *ip, unsigned port);
|
uint8_t *ip, unsigned port);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Send a zero-terminated string to specified peer.
|
* Send a zero-terminated string to specified peer.
|
||||||
*/
|
*/
|
||||||
unsigned udp_send_string (udp_t *u, const char *data,
|
uint16_t udp_send_string (udp_t *u, const char *data,
|
||||||
uint8_t *ip, unsigned port);
|
uint8_t *ip, unsigned port);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
14
lib/.gitignore
vendored
14
lib/.gitignore
vendored
@@ -1,14 +0,0 @@
|
|||||||
a.out.h
|
|
||||||
aout
|
|
||||||
ar
|
|
||||||
ar.h
|
|
||||||
as
|
|
||||||
ld
|
|
||||||
nlist.h
|
|
||||||
nm
|
|
||||||
ranlib
|
|
||||||
ranlib.h
|
|
||||||
retroImage
|
|
||||||
size
|
|
||||||
strip
|
|
||||||
gccdump.s
|
|
||||||
66
lib/Makefile
66
lib/Makefile
@@ -1,66 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ..; pwd)
|
|
||||||
SUBDIR = startup libc libcurses libtermlib libwiznet
|
|
||||||
PROG = ar as aout ld nm ranlib size strip
|
|
||||||
|
|
||||||
# Build a list of the host include directories.
|
|
||||||
CPP = $(shell gcc -print-prog-name=cc1)
|
|
||||||
HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
|
|
||||||
|
|
||||||
# Add system include path
|
|
||||||
ifeq (,$(wildcard /usr/include/i386-linux-gnu))
|
|
||||||
HOSTINC += -I/usr/include
|
|
||||||
else
|
|
||||||
HOSTINC += -I/usr/include/i386-linux-gnu
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS += -nostdinc -fno-builtin -g -Werror -Wall -DCROSS -I. $(HOSTINC) \
|
|
||||||
-I$(TOPSRC)/include -I$(TOPSRC)/src/cmd/ar \
|
|
||||||
-I$(TOPSRC)/src/cmd/as
|
|
||||||
LDFLAGS += -g
|
|
||||||
|
|
||||||
AR_OBJS = ar.o append.o archive.o contents.o delete.o extract.o \
|
|
||||||
misc.o move.o print.o replace.o strmode.o
|
|
||||||
AOUT_OBJS = aout.o mips-dis.o
|
|
||||||
RANLIB_OBJS = ranlib.o archive.o
|
|
||||||
HEADERS = a.out.h ar.h nlist.h ranlib.h
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/cmd/aout $(TOPSRC)/src/cmd/ar $(TOPSRC)/src/cmd/as \
|
|
||||||
$(TOPSRC)/src/cmd/ld $(TOPSRC)/src/cmd/nm $(TOPSRC)/src/cmd/ranlib \
|
|
||||||
$(TOPSRC)/src/cmd
|
|
||||||
|
|
||||||
all install depend: $(HEADERS) $(SUBDIR) $(PROG)
|
|
||||||
-for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) DESTDIR=$(DESTDIR) $@; done
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o *.a *.h $(PROG) retroImage gccdump.s
|
|
||||||
for i in $(SUBDIR); do $(MAKE) -C $$i $(MFLAGS) clean; done
|
|
||||||
|
|
||||||
ar: $(AR_OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(AR_OBJS) $(LIBS)
|
|
||||||
|
|
||||||
as: as.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
aout: $(AOUT_OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(AOUT_OBJS) $(LIBS)
|
|
||||||
|
|
||||||
ld: ld.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
nm: nm.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
ranlib: $(RANLIB_OBJS)
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $(RANLIB_OBJS) $(LIBS)
|
|
||||||
|
|
||||||
size: size.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
strip: strip.o
|
|
||||||
$(CC) $(LDFLAGS) -o $@ $< $(LIBS)
|
|
||||||
|
|
||||||
$(HEADERS):
|
|
||||||
-ln -s -f ../include/a.out.h .
|
|
||||||
-ln -s -f ../include/ar.h .
|
|
||||||
-ln -s -f ../include/nlist.h .
|
|
||||||
-ln -s -f ../include/ranlib.h .
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
LIBCDIR = $(TOPSRC)/src/libc
|
|
||||||
vpath %.S $(LIBCDIR)/mips/sys $(LIBCDIR)/mips/string $(LIBCDIR)/mips/gen \
|
|
||||||
$(LIBCDIR)/runtime
|
|
||||||
vpath %.c $(LIBCDIR)/mips/sys $(LIBCDIR)/gen $(LIBCDIR)/stdio \
|
|
||||||
$(LIBCDIR)/stdlib $(LIBCDIR)/string $(LIBCDIR)/inet \
|
|
||||||
$(LIBCDIR)/compat $(LIBCDIR)/runtime
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
ASFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -I$(LIBCDIR)/mips/sys
|
|
||||||
|
|
||||||
# modules which can not use SYSCALL and must be assembled from sources. The
|
|
||||||
# rest of the system calls are generated with printf(1) and do not have
|
|
||||||
# source files associated with them.
|
|
||||||
|
|
||||||
# libc/mips/sys
|
|
||||||
SYSOBJS = __sysctl.o accept.o access.o adjtime.o bind.o chdir.o \
|
|
||||||
chflags.o chmod.o chown.o chroot.o close.o connect.o dup.o \
|
|
||||||
dup2.o execve.o fchdir.o fchflags.o fchmod.o fchown.o \
|
|
||||||
fcntl.o flock.o fork.o fstat.o fsync.o ftruncate.o \
|
|
||||||
getdtablesize.o getgroups.o getitimer.o getsockname.o \
|
|
||||||
getpeername.o getpriority.o getrlimit.o getrusage.o \
|
|
||||||
getsockopt.o gettimeofday.o ioctl.o kill.o killpg.o link.o \
|
|
||||||
listen.o lstat.o mkdir.o mknod.o mount.o open.o pselect.o \
|
|
||||||
quota.o read.o readlink.o readv.o reboot.o recv.o \
|
|
||||||
recvfrom.o recvmsg.o rename.o rmdir.o select.o send.o \
|
|
||||||
sendmsg.o sendto.o setgroups.o setitimer.o setpgrp.o \
|
|
||||||
setpriority.o setquota.o setuid.o seteuid.o setgid.o \
|
|
||||||
setegid.o setrlimit.o setsockopt.o settimeofday.o \
|
|
||||||
shutdown.o sigaltstack.o socket.o socketpair.o stat.o \
|
|
||||||
symlink.o sigprocmask.o sigstack.o sigwait.o statfs.o \
|
|
||||||
fstatfs.o getfsstat.o truncate.o umount.o unlink.o \
|
|
||||||
utimes.o wait4.o write.o writev.o lseek.o sigsuspend.o \
|
|
||||||
getgid.o getegid.o getpgrp.o getpid.o getppid.o getuid.o \
|
|
||||||
geteuid.o profil.o sigpending.o sync.o ufetch.o ustore.o \
|
|
||||||
ucall.o umask.o vfork.o vhangup.o rdglob.o wrglob.o
|
|
||||||
|
|
||||||
OBJS = $(SYSOBJS) sbrk.o execl.o execle.o execv.o \
|
|
||||||
_exit.o _brk.o pipe.o ptrace.o sigaction.o
|
|
||||||
|
|
||||||
# libc/mips/string
|
|
||||||
ASFLAGS += -DLWHI=lwr -DLWLO=lwl -DSWHI=swr -DSWLO=swl
|
|
||||||
OBJS += bcopy.o bzero.o ffs.o memcpy.o memmove.o memset.o \
|
|
||||||
strlen.o bcmp.o index.o rindex.o strcmp.o
|
|
||||||
|
|
||||||
# libc/mips/gen
|
|
||||||
OBJS += _setjmp.o htonl.o htons.o
|
|
||||||
|
|
||||||
# libc/gen
|
|
||||||
OBJS += abort.o alarm.o atof.o atoi.o atol.o calloc.o closedir.o crypt.o \
|
|
||||||
ctime.o ctype_.o daemon.o devname.o ecvt.o err.o \
|
|
||||||
execvp.o fakcu.o frexp.o fstab.o gcvt.o getenv.o getgrent.o \
|
|
||||||
getgrgid.o getgrnam.o getlogin.o \
|
|
||||||
getgrouplist.o gethostname.o getpagesize.o \
|
|
||||||
getpass.o getpwent.o getloadavg.o getmntinfo.o \
|
|
||||||
getttyent.o getttynam.o getusershell.o getwd.o \
|
|
||||||
initgroups.o isatty.o isinff.o isnanf.o ldexp.o malloc.o mktemp.o \
|
|
||||||
modff.o ndbm.o nlist.o knlist.o opendir.o perror.o popen.o \
|
|
||||||
psignal.o qsort.o random.o readdir.o regex.o scandir.o \
|
|
||||||
seekdir.o setmode.o sethostname.o setenv.o siglist.o \
|
|
||||||
signal.o siginterrupt.o sigsetops.o \
|
|
||||||
sleep.o strcasecmp.o strftime.o swab.o sysctl.o syslog.o system.o \
|
|
||||||
strcat.o strncat.o strcpy.o strncpy.o strncmp.o \
|
|
||||||
telldir.o time.o timezone.o ttyname.o ttyslot.o ualarm.o usleep.o \
|
|
||||||
strdup.o uname.o wait.o wait3.o waitpid.o
|
|
||||||
|
|
||||||
# libc/stdio
|
|
||||||
OBJS += fgetc.o fgets.o fputc.o fputs.o gets.o puts.o \
|
|
||||||
clrerr.o doscan.o exit.o fdopen.o filbuf.o findiop.o \
|
|
||||||
flsbuf.o fopen.o fprintf.o fread.o freopen.o fseek.o \
|
|
||||||
ftell.o fwrite.o getchar.o getw.o printf.o putchar.o putw.o \
|
|
||||||
rew.o scanf.o setbuf.o setbuffer.o setvbuf.o snprintf.o sprintf.o \
|
|
||||||
strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o doprnt.o \
|
|
||||||
remove.o feof.o ferror.o fileno.o
|
|
||||||
|
|
||||||
# libc/stdlib
|
|
||||||
OBJS += getopt.o getsubopt.o strtol.o strtoul.o strtod.o
|
|
||||||
|
|
||||||
# libc/string
|
|
||||||
OBJS += strcspn.o strpbrk.o strerror.o strsep.o strspn.o \
|
|
||||||
strstr.o strtok.o strtok_r.o
|
|
||||||
|
|
||||||
# libc/inet
|
|
||||||
OBJS += inet_addr.o inet_network.o inet_netof.o \
|
|
||||||
inet_ntoa.o inet_lnaof.o inet_maddr.o
|
|
||||||
|
|
||||||
# libc/compat
|
|
||||||
OBJS += creat.o ftime.o gethostid.o gtty.o memccpy.o memchr.o \
|
|
||||||
memcmp.o memcpy.o memset.o nice.o pause.o rand.o \
|
|
||||||
sethostid.o setregid.o setreuid.o setrgid.o setruid.o \
|
|
||||||
sigcompat.o strchr.o strrchr.o stty.o times.o tmpnam.o \
|
|
||||||
utime.o
|
|
||||||
|
|
||||||
# libc/runtime
|
|
||||||
OBJS += addsf3.o comparesf2.o divsf3.o fixsfsi.o floatsisf.o \
|
|
||||||
mulsf3.o negsf2.o subsf3.o sc_case.o
|
|
||||||
|
|
||||||
all: ../libc.a
|
|
||||||
|
|
||||||
../libc.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
$(SYSOBJS): $(LIBCDIR)/mips/sys/SYS.h
|
|
||||||
@echo creating $*.o
|
|
||||||
@printf '#include "SYS.h"\nSYS($*)\n' | $(AS) $(ASFLAGS) - -c -o $*.o
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/libcurses
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
|
|
||||||
OBJS = addch.o addstr.o box.o clear.o clrtobot.o clrtoeol.o cr_put.o \
|
|
||||||
cr_tty.o curses.o delch.o deleteln.o delwin.o endwin.o erase.o \
|
|
||||||
fullname.o getch.o getstr.o idlok.o id_subwins.o initscr.o insch.o \
|
|
||||||
insertln.o longname.o move.o mvprintw.o mvscanw.o mvwin.o newwin.o \
|
|
||||||
overlay.o overwrite.o printw.o putchar.o refresh.o scanw.o scroll.o \
|
|
||||||
toucholap.o standout.o touchwin.o tstp.o unctrl.o
|
|
||||||
|
|
||||||
all: ../libcurses.a
|
|
||||||
|
|
||||||
../libcurses.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/libtermlib
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
|
|
||||||
OBJS = termcap.o tgoto.o tputs.o tcattr.o
|
|
||||||
|
|
||||||
all: ../libtermlib.a
|
|
||||||
|
|
||||||
../libtermlib.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
|
|
||||||
vpath %.c $(TOPSRC)/src/libwiznet
|
|
||||||
|
|
||||||
CFLAGS += -B$(TOPSRC)/lib/ $(DEFS) -Wa,-x -Wall -Werror
|
|
||||||
|
|
||||||
OBJS = w5100.o socket.o ethernet.o client.o server.o udp.o
|
|
||||||
|
|
||||||
all: ../libwiznet.a
|
|
||||||
|
|
||||||
../libwiznet.a: ../ar ../ranlib $(OBJS)
|
|
||||||
../ar rc $@ $(OBJS)
|
|
||||||
../ranlib $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o a.out *.a
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#
|
|
||||||
# Copyright (c) 1987 Regents of the University of California.
|
|
||||||
# All rights reserved. The Berkeley software License Agreement
|
|
||||||
# specifies the terms and conditions for redistribution.
|
|
||||||
#
|
|
||||||
# crt0 Normal C run time startoff
|
|
||||||
#
|
|
||||||
TOPSRC = $(shell cd ../..; pwd)
|
|
||||||
include $(TOPSRC)/target.mk
|
|
||||||
vpath %.c $(TOPSRC)/src/startup-mips
|
|
||||||
|
|
||||||
CFLAGS = -B$(TOPSRC)/lib/ -O -Wa,-x $(DEFS)
|
|
||||||
|
|
||||||
OBJS = ../crt0.o
|
|
||||||
|
|
||||||
all: $(OBJS)
|
|
||||||
|
|
||||||
../crt0.o: crt0.c
|
|
||||||
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(OBJS) *~
|
|
||||||
1
libexec/.gitignore
vendored
1
libexec/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
862
rootfs.manifest
862
rootfs.manifest
@@ -1,862 +0,0 @@
|
|||||||
#
|
|
||||||
# Manifest file for RetroBSD root filesystem.
|
|
||||||
#
|
|
||||||
default
|
|
||||||
owner 0
|
|
||||||
group 0
|
|
||||||
dirmode 0775
|
|
||||||
filemode 0664
|
|
||||||
|
|
||||||
#
|
|
||||||
# Directories.
|
|
||||||
#
|
|
||||||
dir /bin
|
|
||||||
dir /dev
|
|
||||||
dir /etc
|
|
||||||
dir /lib
|
|
||||||
dir /libexec
|
|
||||||
dir /sbin
|
|
||||||
dir /tmp
|
|
||||||
dir /u
|
|
||||||
|
|
||||||
#
|
|
||||||
# Character devices.
|
|
||||||
#
|
|
||||||
cdev /dev/console
|
|
||||||
major 0
|
|
||||||
minor 0
|
|
||||||
cdev /dev/mem
|
|
||||||
major 1
|
|
||||||
minor 0
|
|
||||||
cdev /dev/kmem
|
|
||||||
major 1
|
|
||||||
minor 1
|
|
||||||
cdev /dev/null
|
|
||||||
major 1
|
|
||||||
minor 2
|
|
||||||
mode 666
|
|
||||||
cdev /dev/zero
|
|
||||||
major 1
|
|
||||||
minor 3
|
|
||||||
mode 666
|
|
||||||
cdev /dev/tty
|
|
||||||
major 2
|
|
||||||
minor 0
|
|
||||||
mode 666
|
|
||||||
cdev /dev/stdin
|
|
||||||
major 3
|
|
||||||
minor 0
|
|
||||||
cdev /dev/stdout
|
|
||||||
major 3
|
|
||||||
minor 1
|
|
||||||
cdev /dev/stderr
|
|
||||||
major 3
|
|
||||||
minor 2
|
|
||||||
cdev /dev/temp0
|
|
||||||
major 4
|
|
||||||
minor 0
|
|
||||||
cdev /dev/temp1
|
|
||||||
major 4
|
|
||||||
minor 1
|
|
||||||
cdev /dev/temp2
|
|
||||||
major 4
|
|
||||||
minor 2
|
|
||||||
|
|
||||||
#
|
|
||||||
# Block devices.
|
|
||||||
#
|
|
||||||
bdev /dev/rd0
|
|
||||||
major 0
|
|
||||||
minor 0
|
|
||||||
bdev /dev/rd0a
|
|
||||||
major 0
|
|
||||||
minor 1
|
|
||||||
bdev /dev/rd0b
|
|
||||||
major 0
|
|
||||||
minor 2
|
|
||||||
bdev /dev/rd0c
|
|
||||||
major 0
|
|
||||||
minor 3
|
|
||||||
bdev /dev/rd0d
|
|
||||||
major 0
|
|
||||||
minor 4
|
|
||||||
bdev /dev/rd1
|
|
||||||
major 1
|
|
||||||
minor 0
|
|
||||||
bdev /dev/rd1a
|
|
||||||
major 1
|
|
||||||
minor 1
|
|
||||||
bdev /dev/rd1b
|
|
||||||
major 1
|
|
||||||
minor 2
|
|
||||||
bdev /dev/rd1c
|
|
||||||
major 1
|
|
||||||
minor 3
|
|
||||||
bdev /dev/rd1d
|
|
||||||
major 1
|
|
||||||
minor 4
|
|
||||||
bdev /dev/rd2
|
|
||||||
major 2
|
|
||||||
minor 0
|
|
||||||
bdev /dev/rd2a
|
|
||||||
major 2
|
|
||||||
minor 1
|
|
||||||
bdev /dev/rd2b
|
|
||||||
major 2
|
|
||||||
minor 2
|
|
||||||
bdev /dev/rd2c
|
|
||||||
major 2
|
|
||||||
minor 3
|
|
||||||
bdev /dev/rd2d
|
|
||||||
major 2
|
|
||||||
minor 4
|
|
||||||
bdev /dev/rd3
|
|
||||||
major 3
|
|
||||||
minor 0
|
|
||||||
bdev /dev/rd3a
|
|
||||||
major 3
|
|
||||||
minor 1
|
|
||||||
bdev /dev/rd3b
|
|
||||||
major 3
|
|
||||||
minor 2
|
|
||||||
bdev /dev/rd3c
|
|
||||||
major 3
|
|
||||||
minor 3
|
|
||||||
bdev /dev/rd3d
|
|
||||||
major 3
|
|
||||||
minor 4
|
|
||||||
bdev /dev/swap
|
|
||||||
major 4
|
|
||||||
minor 64
|
|
||||||
bdev /dev/swap0
|
|
||||||
major 4
|
|
||||||
minor 0
|
|
||||||
bdev /dev/swap1
|
|
||||||
major 4
|
|
||||||
minor 1
|
|
||||||
bdev /dev/swap2
|
|
||||||
major 4
|
|
||||||
minor 2
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /
|
|
||||||
#
|
|
||||||
file /.profile
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /etc
|
|
||||||
#
|
|
||||||
file /etc/fstab
|
|
||||||
file /etc/gettytab
|
|
||||||
file /etc/group
|
|
||||||
file /etc/MAKEDEV
|
|
||||||
mode 0775
|
|
||||||
file /etc/motd
|
|
||||||
file /etc/passwd
|
|
||||||
file /etc/phones
|
|
||||||
file /etc/rc
|
|
||||||
mode 0775
|
|
||||||
file /etc/rc.local
|
|
||||||
mode 0775
|
|
||||||
file /etc/remote
|
|
||||||
file /etc/shadow
|
|
||||||
file /etc/shells
|
|
||||||
file /etc/termcap
|
|
||||||
mode 0444
|
|
||||||
file /etc/ttys
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /bin
|
|
||||||
#
|
|
||||||
default
|
|
||||||
filemode 0775
|
|
||||||
file /bin/adb
|
|
||||||
file /bin/adc-demo
|
|
||||||
file /bin/aout
|
|
||||||
file /bin/apropos
|
|
||||||
file /bin/ar
|
|
||||||
file /bin/as
|
|
||||||
file /bin/awk
|
|
||||||
file /bin/basename
|
|
||||||
file /bin/basic
|
|
||||||
file /bin/bc
|
|
||||||
file /bin/cal
|
|
||||||
file /bin/cat
|
|
||||||
file /bin/cb
|
|
||||||
file /bin/cc
|
|
||||||
file /bin/chat-server
|
|
||||||
file /bin/chflags
|
|
||||||
file /bin/chgrp
|
|
||||||
file /bin/chmod
|
|
||||||
file /bin/chpass
|
|
||||||
mode 04755
|
|
||||||
file /bin/cmp
|
|
||||||
file /bin/col
|
|
||||||
file /bin/comm
|
|
||||||
file /bin/compress
|
|
||||||
file /bin/cp
|
|
||||||
file /bin/cpp
|
|
||||||
file /bin/crontab
|
|
||||||
file /bin/date
|
|
||||||
file /bin/dc
|
|
||||||
file /bin/dd
|
|
||||||
file /bin/df
|
|
||||||
mode 02755
|
|
||||||
file /bin/diff
|
|
||||||
file /bin/diskspeed
|
|
||||||
file /bin/du
|
|
||||||
file /bin/echo
|
|
||||||
file /bin/ed
|
|
||||||
file /bin/egrep
|
|
||||||
file /bin/emg
|
|
||||||
file /bin/env
|
|
||||||
file /bin/expr
|
|
||||||
file /bin/false
|
|
||||||
file /bin/fgrep
|
|
||||||
file /bin/file
|
|
||||||
file /bin/find
|
|
||||||
file /bin/forth
|
|
||||||
file /bin/fstat
|
|
||||||
mode 02755
|
|
||||||
file /bin/glcdtest
|
|
||||||
file /bin/globdump
|
|
||||||
file /bin/globread
|
|
||||||
file /bin/globwrite
|
|
||||||
file /bin/grep
|
|
||||||
file /bin/groups
|
|
||||||
file /bin/head
|
|
||||||
file /bin/hostid
|
|
||||||
file /bin/hostname
|
|
||||||
file /bin/id
|
|
||||||
file /bin/iostat
|
|
||||||
mode 02755
|
|
||||||
file /bin/join
|
|
||||||
file /bin/kill
|
|
||||||
file /bin/la
|
|
||||||
file /bin/last
|
|
||||||
file /bin/lcc
|
|
||||||
file /bin/lcpp
|
|
||||||
file /bin/ld
|
|
||||||
file /bin/ln
|
|
||||||
file /bin/login
|
|
||||||
mode 04755
|
|
||||||
file /bin/lol
|
|
||||||
file /bin/ls
|
|
||||||
file /bin/mail
|
|
||||||
mode 04755
|
|
||||||
file /bin/make
|
|
||||||
file /bin/man
|
|
||||||
file /bin/med
|
|
||||||
file /bin/mesg
|
|
||||||
file /bin/mkdir
|
|
||||||
file /bin/more
|
|
||||||
file /bin/msec
|
|
||||||
file /bin/mv
|
|
||||||
file /bin/nice
|
|
||||||
file /bin/nm
|
|
||||||
file /bin/nohup
|
|
||||||
file /bin/ntpdate
|
|
||||||
file /bin/od
|
|
||||||
file /bin/pagesize
|
|
||||||
file /bin/passwd
|
|
||||||
mode 04755
|
|
||||||
file /bin/picoc
|
|
||||||
file /bin/portio
|
|
||||||
file /bin/pr
|
|
||||||
file /bin/printenv
|
|
||||||
file /bin/printf
|
|
||||||
file /bin/ps
|
|
||||||
mode 02755
|
|
||||||
file /bin/pwd
|
|
||||||
file /bin/pwm
|
|
||||||
file /bin/ranlib
|
|
||||||
file /bin/re
|
|
||||||
file /bin/renice
|
|
||||||
file /bin/renumber
|
|
||||||
file /bin/retroforth
|
|
||||||
file /bin/rev
|
|
||||||
file /bin/rm
|
|
||||||
file /bin/rmail
|
|
||||||
file /bin/rmdir
|
|
||||||
file /bin/rz
|
|
||||||
file /bin/scc
|
|
||||||
file /bin/scm
|
|
||||||
file /bin/sed
|
|
||||||
file /bin/setty
|
|
||||||
file /bin/sh
|
|
||||||
file /bin/size
|
|
||||||
file /bin/sl
|
|
||||||
file /bin/sleep
|
|
||||||
file /bin/smux
|
|
||||||
file /bin/sort
|
|
||||||
file /bin/split
|
|
||||||
file /bin/strip
|
|
||||||
file /bin/stty
|
|
||||||
file /bin/su
|
|
||||||
mode 04755
|
|
||||||
file /bin/sum
|
|
||||||
file /bin/sync
|
|
||||||
file /bin/sysctl
|
|
||||||
file /bin/sz
|
|
||||||
file /bin/tail
|
|
||||||
file /bin/tar
|
|
||||||
file /bin/tee
|
|
||||||
file /bin/telnet
|
|
||||||
file /bin/test
|
|
||||||
file /bin/time
|
|
||||||
file /bin/tip
|
|
||||||
file /bin/touch
|
|
||||||
file /bin/tr
|
|
||||||
file /bin/true
|
|
||||||
file /bin/tsort
|
|
||||||
file /bin/tty
|
|
||||||
file /bin/uname
|
|
||||||
file /bin/uncompress
|
|
||||||
file /bin/uniq
|
|
||||||
file /bin/uucico
|
|
||||||
file /bin/uuclean
|
|
||||||
file /bin/uucp
|
|
||||||
file /bin/uudecode
|
|
||||||
file /bin/uuencode
|
|
||||||
file /bin/uulog
|
|
||||||
file /bin/uuname
|
|
||||||
file /bin/uupoll
|
|
||||||
file /bin/uuq
|
|
||||||
file /bin/uusend
|
|
||||||
file /bin/uusnap
|
|
||||||
file /bin/uux
|
|
||||||
file /bin/uuxqt
|
|
||||||
file /bin/vi
|
|
||||||
file /bin/vmstat
|
|
||||||
mode 02755
|
|
||||||
file /bin/w
|
|
||||||
file /bin/wall
|
|
||||||
mode 02755
|
|
||||||
file /bin/wc
|
|
||||||
file /bin/web-client
|
|
||||||
file /bin/web-server
|
|
||||||
file /bin/whereis
|
|
||||||
file /bin/who
|
|
||||||
file /bin/whoami
|
|
||||||
file /bin/write
|
|
||||||
mode 02755
|
|
||||||
file /bin/xargs
|
|
||||||
file /bin/zcat
|
|
||||||
|
|
||||||
link /bin/[
|
|
||||||
target /bin/test
|
|
||||||
|
|
||||||
link /bin/whatis
|
|
||||||
target /bin/apropos
|
|
||||||
|
|
||||||
link /bin/chfn
|
|
||||||
target /bin/chpass
|
|
||||||
link /bin/chsh
|
|
||||||
target /bin/chpass
|
|
||||||
|
|
||||||
link /bin/rb
|
|
||||||
target /bin/rz
|
|
||||||
link /bin/rx
|
|
||||||
target /bin/rz
|
|
||||||
|
|
||||||
link /bin/sb
|
|
||||||
target /bin/sz
|
|
||||||
link /bin/sx
|
|
||||||
target /bin/sz
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /sbin
|
|
||||||
#
|
|
||||||
file /sbin/chown
|
|
||||||
file /sbin/chroot
|
|
||||||
mode 04755
|
|
||||||
file /sbin/cron
|
|
||||||
file /sbin/devupdate
|
|
||||||
file /sbin/disktool
|
|
||||||
file /sbin/fdisk
|
|
||||||
file /sbin/fsck
|
|
||||||
file /sbin/init
|
|
||||||
mode 0700
|
|
||||||
file /sbin/mkfs
|
|
||||||
file /sbin/mknod
|
|
||||||
file /sbin/mkpasswd
|
|
||||||
file /sbin/mount
|
|
||||||
file /sbin/pstat
|
|
||||||
mode 02755
|
|
||||||
file /sbin/rdprof
|
|
||||||
file /sbin/reboot
|
|
||||||
file /sbin/shutdown
|
|
||||||
mode 04750
|
|
||||||
file /sbin/talloc
|
|
||||||
file /sbin/umount
|
|
||||||
file /sbin/update
|
|
||||||
file /sbin/updatedb
|
|
||||||
file /sbin/vipw
|
|
||||||
|
|
||||||
link /sbin/bootloader
|
|
||||||
target /sbin/reboot
|
|
||||||
link /sbin/fastboot
|
|
||||||
target /sbin/reboot
|
|
||||||
link /sbin/halt
|
|
||||||
target /sbin/reboot
|
|
||||||
link /sbin/poweroff
|
|
||||||
target /sbin/reboot
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /games
|
|
||||||
#
|
|
||||||
default
|
|
||||||
filemode 0775
|
|
||||||
dir /games
|
|
||||||
file /games/adventure
|
|
||||||
file /games/arithmetic
|
|
||||||
file /games/atc
|
|
||||||
file /games/backgammon
|
|
||||||
file /games/banner
|
|
||||||
file /games/battlestar
|
|
||||||
file /games/bcd
|
|
||||||
file /games/boggle
|
|
||||||
file /games/btlgammon
|
|
||||||
file /games/canfield
|
|
||||||
file /games/cfscores
|
|
||||||
file /games/cribbage
|
|
||||||
file /games/factor
|
|
||||||
file /games/fish
|
|
||||||
file /games/fortune
|
|
||||||
file /games/hangman
|
|
||||||
file /games/mille
|
|
||||||
file /games/monop
|
|
||||||
file /games/morse
|
|
||||||
file /games/number
|
|
||||||
file /games/ppt
|
|
||||||
file /games/primes
|
|
||||||
file /games/quiz
|
|
||||||
file /games/rain
|
|
||||||
file /games/robots
|
|
||||||
file /games/rogue
|
|
||||||
file /games/sail
|
|
||||||
file /games/snake
|
|
||||||
file /games/snscore
|
|
||||||
file /games/teachgammon
|
|
||||||
file /games/trek
|
|
||||||
file /games/worm
|
|
||||||
file /games/worms
|
|
||||||
file /games/wump
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /games/lib
|
|
||||||
#
|
|
||||||
default
|
|
||||||
filemode 0444
|
|
||||||
dir /games/lib
|
|
||||||
file /games/lib/adventure.dat
|
|
||||||
file /games/lib/battle_strings
|
|
||||||
file /games/lib/backrules
|
|
||||||
file /games/lib/bogdict
|
|
||||||
file /games/lib/cfscores
|
|
||||||
file /games/lib/crib.instr
|
|
||||||
mode 0666
|
|
||||||
file /games/lib/fortunes.dat
|
|
||||||
file /games/lib/cards.pck
|
|
||||||
file /games/lib/robots_roll
|
|
||||||
mode 0666
|
|
||||||
file /games/lib/snakerawscores
|
|
||||||
mode 0666
|
|
||||||
dir /games/lib/atc
|
|
||||||
file /games/lib/atc/ATC_scores
|
|
||||||
file /games/lib/atc/crossover
|
|
||||||
file /games/lib/atc/default
|
|
||||||
file /games/lib/atc/easy
|
|
||||||
file /games/lib/atc/game_2
|
|
||||||
file /games/lib/atc/Game_List
|
|
||||||
file /games/lib/atc/Killer
|
|
||||||
dir /games/lib/quiz.k
|
|
||||||
file /games/lib/quiz.k/africa
|
|
||||||
file /games/lib/quiz.k/america
|
|
||||||
file /games/lib/quiz.k/areas
|
|
||||||
file /games/lib/quiz.k/arith
|
|
||||||
file /games/lib/quiz.k/asia
|
|
||||||
file /games/lib/quiz.k/babies
|
|
||||||
file /games/lib/quiz.k/bard
|
|
||||||
file /games/lib/quiz.k/chinese
|
|
||||||
file /games/lib/quiz.k/collectives
|
|
||||||
file /games/lib/quiz.k/ed
|
|
||||||
file /games/lib/quiz.k/elements
|
|
||||||
file /games/lib/quiz.k/europe
|
|
||||||
file /games/lib/quiz.k/greek
|
|
||||||
file /games/lib/quiz.k/inca
|
|
||||||
file /games/lib/quiz.k/index
|
|
||||||
file /games/lib/quiz.k/latin
|
|
||||||
file /games/lib/quiz.k/locomotive
|
|
||||||
file /games/lib/quiz.k/midearth
|
|
||||||
file /games/lib/quiz.k/morse
|
|
||||||
file /games/lib/quiz.k/murders
|
|
||||||
file /games/lib/quiz.k/poetry
|
|
||||||
file /games/lib/quiz.k/posneg
|
|
||||||
file /games/lib/quiz.k/pres
|
|
||||||
file /games/lib/quiz.k/province
|
|
||||||
file /games/lib/quiz.k/seq-easy
|
|
||||||
file /games/lib/quiz.k/seq-hard
|
|
||||||
file /games/lib/quiz.k/sexes
|
|
||||||
file /games/lib/quiz.k/sov
|
|
||||||
file /games/lib/quiz.k/spell
|
|
||||||
file /games/lib/quiz.k/state
|
|
||||||
file /games/lib/quiz.k/trek
|
|
||||||
file /games/lib/quiz.k/ucc
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /include
|
|
||||||
#
|
|
||||||
default
|
|
||||||
filemode 0664
|
|
||||||
dir /include
|
|
||||||
dir /include/arpa
|
|
||||||
dir /include/machine
|
|
||||||
dir /include/smallc
|
|
||||||
dir /include/smallc/sys
|
|
||||||
dir /include/sys
|
|
||||||
file /include/alloca.h
|
|
||||||
file /include/a.out.h
|
|
||||||
file /include/ar.h
|
|
||||||
file /include/arpa/inet.h
|
|
||||||
file /include/assert.h
|
|
||||||
file /include/ctype.h
|
|
||||||
file /include/curses.h
|
|
||||||
file /include/dbm.h
|
|
||||||
file /include/fcntl.h
|
|
||||||
file /include/float.h
|
|
||||||
file /include/fstab.h
|
|
||||||
file /include/grp.h
|
|
||||||
file /include/kmem.h
|
|
||||||
file /include/lastlog.h
|
|
||||||
file /include/limits.h
|
|
||||||
file /include/machine/cpu.h
|
|
||||||
file /include/machine/elf_machdep.h
|
|
||||||
file /include/machine/float.h
|
|
||||||
file /include/machine/io.h
|
|
||||||
file /include/machine/limits.h
|
|
||||||
file /include/machine/machparam.h
|
|
||||||
file /include/machine/pic32mx.h
|
|
||||||
file /include/machine/rd_sdramp_config.h
|
|
||||||
file /include/machine/sdram.h
|
|
||||||
file /include/machine/ssd1926.h
|
|
||||||
file /include/machine/usb_ch9.h
|
|
||||||
file /include/machine/usb_device.h
|
|
||||||
file /include/machine/usb_function_cdc.h
|
|
||||||
file /include/machine/usb_function_hid.h
|
|
||||||
file /include/machine/usb_hal_pic32.h
|
|
||||||
file /include/math.h
|
|
||||||
file /include/mtab.h
|
|
||||||
file /include/ndbm.h
|
|
||||||
file /include/nlist.h
|
|
||||||
file /include/paths.h
|
|
||||||
file /include/pcc.h
|
|
||||||
file /include/psout.h
|
|
||||||
file /include/pwd.h
|
|
||||||
file /include/ranlib.h
|
|
||||||
file /include/regexp.h
|
|
||||||
file /include/setjmp.h
|
|
||||||
file /include/sgtty.h
|
|
||||||
file /include/smallc/curses.h
|
|
||||||
file /include/smallc/fcntl.h
|
|
||||||
file /include/smallc/signal.h
|
|
||||||
file /include/smallc/stdio.h
|
|
||||||
file /include/smallc/sys/gpio.h
|
|
||||||
file /include/smallc/sys/spi.h
|
|
||||||
file /include/smallc/wiznet.h
|
|
||||||
file /include/stab.h
|
|
||||||
file /include/stdarg.h
|
|
||||||
file /include/stddef.h
|
|
||||||
file /include/stdint.h
|
|
||||||
file /include/stdio.h
|
|
||||||
file /include/stdlib.h
|
|
||||||
file /include/string.h
|
|
||||||
file /include/strings.h
|
|
||||||
file /include/struct.h
|
|
||||||
file /include/sys/adc.h
|
|
||||||
file /include/sys/buf.h
|
|
||||||
file /include/syscall.h
|
|
||||||
file /include/sys/callout.h
|
|
||||||
file /include/sys/clist.h
|
|
||||||
file /include/sys/conf.h
|
|
||||||
file /include/sys/debug.h
|
|
||||||
file /include/sys/dir.h
|
|
||||||
file /include/sys/disk.h
|
|
||||||
file /include/sys/dkbad.h
|
|
||||||
file /include/sys/dk.h
|
|
||||||
file /include/sys/errno.h
|
|
||||||
file /include/sys/exec_aout.h
|
|
||||||
file /include/sys/exec_elf.h
|
|
||||||
file /include/sys/exec.h
|
|
||||||
file /include/sysexits.h
|
|
||||||
file /include/sys/fcntl.h
|
|
||||||
file /include/sys/file.h
|
|
||||||
file /include/sys/fs.h
|
|
||||||
file /include/sys/glcd.h
|
|
||||||
file /include/sys/glob.h
|
|
||||||
file /include/sys/gpio.h
|
|
||||||
file /include/sys/inode.h
|
|
||||||
file /include/sys/ioctl.h
|
|
||||||
file /include/sys/kernel.h
|
|
||||||
file /include/sys/map.h
|
|
||||||
file /include/sys/mount.h
|
|
||||||
file /include/sys/msgbuf.h
|
|
||||||
file /include/sys/mtio.h
|
|
||||||
file /include/sys/namei.h
|
|
||||||
file /include/sys/oc.h
|
|
||||||
file /include/sys/param.h
|
|
||||||
file /include/sys/picga.h
|
|
||||||
file /include/sys/proc.h
|
|
||||||
file /include/sys/ptrace.h
|
|
||||||
file /include/sys/pty.h
|
|
||||||
file /include/sys/rd_flash.h
|
|
||||||
file /include/sys/rdisk.h
|
|
||||||
file /include/sys/rd_mrams.h
|
|
||||||
file /include/sys/rd_sdramp.h
|
|
||||||
file /include/sys/rd_sramc.h
|
|
||||||
file /include/sys/reboot.h
|
|
||||||
file /include/sys/resource.h
|
|
||||||
file /include/sys/select.h
|
|
||||||
file /include/sys/signal.h
|
|
||||||
file /include/sys/signalvar.h
|
|
||||||
file /include/sys/spi_bus.h
|
|
||||||
file /include/sys/spi.h
|
|
||||||
file /include/sys/stat.h
|
|
||||||
file /include/sys/swap.h
|
|
||||||
file /include/sys/sysctl.h
|
|
||||||
file /include/sys/syslog.h
|
|
||||||
file /include/sys/systm.h
|
|
||||||
file /include/sys/time.h
|
|
||||||
file /include/sys/times.h
|
|
||||||
file /include/sys/trace.h
|
|
||||||
file /include/sys/ttychars.h
|
|
||||||
file /include/sys/ttydev.h
|
|
||||||
file /include/sys/tty.h
|
|
||||||
file /include/sys/types.h
|
|
||||||
file /include/sys/uart.h
|
|
||||||
file /include/sys/uio.h
|
|
||||||
file /include/sys/usb_uart.h
|
|
||||||
file /include/sys/user.h
|
|
||||||
file /include/sys/utsname.h
|
|
||||||
file /include/sys/vm.h
|
|
||||||
file /include/sys/vmmac.h
|
|
||||||
file /include/sys/vmmeter.h
|
|
||||||
file /include/sys/vmparam.h
|
|
||||||
file /include/sys/vmsystm.h
|
|
||||||
file /include/sys/wait.h
|
|
||||||
file /include/term.h
|
|
||||||
file /include/termios-todo.h
|
|
||||||
file /include/time.h
|
|
||||||
file /include/ttyent.h
|
|
||||||
file /include/tzfile.h
|
|
||||||
file /include/unistd.h
|
|
||||||
file /include/utmp.h
|
|
||||||
file /include/vmf.h
|
|
||||||
|
|
||||||
symlink /include/errno.h
|
|
||||||
target sys/errno.h
|
|
||||||
|
|
||||||
symlink /include/signal.h
|
|
||||||
target sys/signal.h
|
|
||||||
|
|
||||||
symlink /include/syslog.h
|
|
||||||
target sys/syslog.h
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /lib
|
|
||||||
#
|
|
||||||
file /lib/crt0.o
|
|
||||||
file /lib/libc.a
|
|
||||||
file /lib/libcurses.a
|
|
||||||
file /lib/libtermlib.a
|
|
||||||
file /lib/libwiznet.a
|
|
||||||
file /lib/retroImage
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /libexec
|
|
||||||
#
|
|
||||||
default
|
|
||||||
filemode 0775
|
|
||||||
file /libexec/bigram
|
|
||||||
file /libexec/code
|
|
||||||
file /libexec/diffh
|
|
||||||
file /libexec/getty
|
|
||||||
file /libexec/smallc
|
|
||||||
file /libexec/smlrc
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /share
|
|
||||||
#
|
|
||||||
default
|
|
||||||
filemode 0444
|
|
||||||
dir /share
|
|
||||||
dir /share/dict
|
|
||||||
dir /share/misc
|
|
||||||
file /share/emg.keys
|
|
||||||
file /share/re.help
|
|
||||||
file /share/dict/words
|
|
||||||
file /share/misc/more.help
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /share/example
|
|
||||||
#
|
|
||||||
default
|
|
||||||
filemode 0664
|
|
||||||
dir /share/example
|
|
||||||
file /share/example/ashello.S
|
|
||||||
file /share/example/blkjack.bas
|
|
||||||
file /share/example/chello.c
|
|
||||||
file /share/example/echo.S
|
|
||||||
file /share/example/fact.fth
|
|
||||||
file /share/example/hilow.bas
|
|
||||||
file /share/example/Makefile
|
|
||||||
file /share/example/prime.scm
|
|
||||||
file /share/example/skeleton.c
|
|
||||||
file /share/example/stars.bas
|
|
||||||
file /share/example/stdarg.c
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /share/smallc
|
|
||||||
#
|
|
||||||
dir /share/smallc
|
|
||||||
file /share/smallc/adc.c
|
|
||||||
file /share/smallc/gpio.c
|
|
||||||
file /share/smallc/hello.c
|
|
||||||
file /share/smallc/Makefile
|
|
||||||
file /share/smallc/primelist.c
|
|
||||||
file /share/smallc/primesum.c
|
|
||||||
file /share/smallc/q8.c
|
|
||||||
file /share/smallc/rain.c
|
|
||||||
file /share/smallc/test1.c
|
|
||||||
file /share/smallc/test2.c
|
|
||||||
file /share/smallc/test3.c
|
|
||||||
file /share/smallc/webserver.c
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /share/smallerc
|
|
||||||
#
|
|
||||||
dir /share/smallerc
|
|
||||||
file /share/smallerc/adc.c
|
|
||||||
file /share/smallerc/gpio.c
|
|
||||||
file /share/smallerc/hello.c
|
|
||||||
file /share/smallerc/Makefile
|
|
||||||
file /share/smallerc/primelist.c
|
|
||||||
file /share/smallerc/primesum.c
|
|
||||||
file /share/smallerc/q8.c
|
|
||||||
file /share/smallerc/rain.c
|
|
||||||
file /share/smallerc/test1.c
|
|
||||||
file /share/smallerc/test2.c
|
|
||||||
file /share/smallerc/test3.c
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /var
|
|
||||||
#
|
|
||||||
dir /var
|
|
||||||
dir /var/lock
|
|
||||||
dir /var/log
|
|
||||||
dir /var/run
|
|
||||||
file /var/log/messages
|
|
||||||
file /var/log/wtmp
|
|
||||||
|
|
||||||
#
|
|
||||||
# Files: /share/man
|
|
||||||
#
|
|
||||||
dir /share/man
|
|
||||||
dir /share/man/cat1
|
|
||||||
dir /share/man/cat2
|
|
||||||
dir /share/man/cat3
|
|
||||||
dir /share/man/cat4
|
|
||||||
dir /share/man/cat5
|
|
||||||
dir /share/man/cat6
|
|
||||||
dir /share/man/cat7
|
|
||||||
dir /share/man/cat8
|
|
||||||
file /share/man/cat1/ar.0
|
|
||||||
file /share/man/cat1/chflags.0
|
|
||||||
file /share/man/cat1/chpass.0
|
|
||||||
file /share/man/cat1/cpp.0
|
|
||||||
file /share/man/cat1/crontab.0
|
|
||||||
file /share/man/cat1/emg.0
|
|
||||||
file /share/man/cat1/groups.0
|
|
||||||
file /share/man/cat1/hostname.0
|
|
||||||
file /share/man/cat1/id.0
|
|
||||||
file /share/man/cat1/la.0
|
|
||||||
file /share/man/cat1/lcc.0
|
|
||||||
file /share/man/cat1/ld.0
|
|
||||||
file /share/man/cat1/passwd.0
|
|
||||||
file /share/man/cat1/printf.0
|
|
||||||
file /share/man/cat1/ranlib.0
|
|
||||||
file /share/man/cat1/rz.0
|
|
||||||
file /share/man/cat1/stty.0
|
|
||||||
file /share/man/cat1/sz.0
|
|
||||||
file /share/man/cat1/test.0
|
|
||||||
file /share/man/cat1/uname.0
|
|
||||||
file /share/man/cat1/whoami.0
|
|
||||||
file /share/man/cat1/xargs.0
|
|
||||||
file /share/man/cat3/vmf.0
|
|
||||||
file /share/man/cat5/ar.0
|
|
||||||
file /share/man/cat5/crontab.0
|
|
||||||
file /share/man/cat5/ranlib.0
|
|
||||||
file /share/man/cat6/adventure.0
|
|
||||||
file /share/man/cat6/arithmetic.0
|
|
||||||
file /share/man/cat6/atc.0
|
|
||||||
file /share/man/cat6/backgammon.0
|
|
||||||
file /share/man/cat6/banner.0
|
|
||||||
file /share/man/cat6/battlestar.0
|
|
||||||
file /share/man/cat6/bcd.0
|
|
||||||
file /share/man/cat6/canfield.0
|
|
||||||
file /share/man/cat6/cribbage.0
|
|
||||||
file /share/man/cat6/fish.0
|
|
||||||
file /share/man/cat6/fortune.0
|
|
||||||
file /share/man/cat6/hangman.0
|
|
||||||
file /share/man/cat6/mille.0
|
|
||||||
file /share/man/cat6/monop.0
|
|
||||||
file /share/man/cat6/number.0
|
|
||||||
file /share/man/cat6/quiz.0
|
|
||||||
file /share/man/cat6/rain.0
|
|
||||||
file /share/man/cat6/robots.0
|
|
||||||
file /share/man/cat6/rogue.0
|
|
||||||
file /share/man/cat6/sail.0
|
|
||||||
file /share/man/cat6/snake.0
|
|
||||||
file /share/man/cat6/trek.0
|
|
||||||
file /share/man/cat6/worm.0
|
|
||||||
file /share/man/cat6/worms.0
|
|
||||||
file /share/man/cat6/wump.0
|
|
||||||
file /share/man/cat8/chown.0
|
|
||||||
file /share/man/cat8/chroot.0
|
|
||||||
file /share/man/cat8/cron.0
|
|
||||||
file /share/man/cat8/fdisk.0
|
|
||||||
file /share/man/cat8/fstat.0
|
|
||||||
file /share/man/cat8/init.0
|
|
||||||
file /share/man/cat8/mkfs.0
|
|
||||||
file /share/man/cat8/mknod.0
|
|
||||||
file /share/man/cat8/mkpasswd.0
|
|
||||||
file /share/man/cat8/mount.0
|
|
||||||
file /share/man/cat8/pstat.0
|
|
||||||
file /share/man/cat8/reboot.0
|
|
||||||
file /share/man/cat8/renice.0
|
|
||||||
file /share/man/cat8/shutdown.0
|
|
||||||
file /share/man/cat8/sysctl.0
|
|
||||||
#file /share/man/cat8/talloc.0
|
|
||||||
file /share/man/cat8/umount.0
|
|
||||||
file /share/man/cat8/update.0
|
|
||||||
file /share/man/cat8/vipw.0
|
|
||||||
|
|
||||||
link /share/man/cat1/rb.0
|
|
||||||
target /share/man/cat1/rz.0
|
|
||||||
link /share/man/cat1/rx.0
|
|
||||||
target /share/man/cat1/rz.0
|
|
||||||
|
|
||||||
link /share/man/cat1/sb.0
|
|
||||||
target /share/man/cat1/sz.0
|
|
||||||
link /share/man/cat1/sx.0
|
|
||||||
target /share/man/cat1/sz.0
|
|
||||||
|
|
||||||
link /share/man/cat8/fastboot.0
|
|
||||||
target /share/man/cat8/reboot.0
|
|
||||||
link /share/man/cat8/halt.0
|
|
||||||
target /share/man/cat8/reboot.0
|
|
||||||
|
|
||||||
link /share/man/cat1/chfn.0
|
|
||||||
target /share/man/cat1/chpass.0
|
|
||||||
link /share/man/cat1/chsh.0
|
|
||||||
target /share/man/cat1/chpass.0
|
|
||||||
1
sbin/.gitignore
vendored
1
sbin/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
*
|
|
||||||
755
sdram-fpga.S
Normal file
755
sdram-fpga.S
Normal file
@@ -0,0 +1,755 @@
|
|||||||
|
/*
|
||||||
|
* SDRAM Access Routines for PIC32.
|
||||||
|
*
|
||||||
|
* Retromaster - 10.05.2010
|
||||||
|
*
|
||||||
|
* This file is in the public domain. You can use, modify, and distribute the source code
|
||||||
|
* and executable programs based on the source code. This file is provided "as is" and
|
||||||
|
* without any express or implied warranties whatsoever. Use at your own risk!
|
||||||
|
*
|
||||||
|
* Changes by jmcgee for inclusion in the retrobsd project.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* SDRAM Used: HY57V281620
|
||||||
|
* SDRAM Pin to PIC32 Pin Mapping:
|
||||||
|
* SDRAM PIC32
|
||||||
|
* ------ ------
|
||||||
|
* note: the order of An to RBn DOES matter
|
||||||
|
* At the moment it is a bit of a mess and
|
||||||
|
* needs to be cleaned up.
|
||||||
|
* A0 23 RB11
|
||||||
|
* A1 24 RB12
|
||||||
|
* A2 25 RB13
|
||||||
|
* A3 26 RB14
|
||||||
|
* A4 29 RB5
|
||||||
|
* A5 30 RB4
|
||||||
|
* A6 31 RB3
|
||||||
|
* A7 32 RB2
|
||||||
|
* A8 33 RB6
|
||||||
|
* A9 34 RB7
|
||||||
|
* A10 22 RB15
|
||||||
|
* A11 35 RB9
|
||||||
|
*
|
||||||
|
* BA0 20 RD4
|
||||||
|
* BA1 21 RD5
|
||||||
|
*
|
||||||
|
* note: the order of DQn to RAn does not matter
|
||||||
|
* DQ0 2 RA6
|
||||||
|
* DQ1 4 RA1
|
||||||
|
* DQ2 5 RA7
|
||||||
|
* DQ3 7 RA2
|
||||||
|
* DQ4 8 RA3
|
||||||
|
* DQ5 10 RA4
|
||||||
|
* DQ6 11 RA5
|
||||||
|
* DQ7 13 RA0
|
||||||
|
|
||||||
|
* CLK 38 OC1-RD0
|
||||||
|
* CKE 37 A10
|
||||||
|
* CS 19 RF12
|
||||||
|
* WE 16 RF0
|
||||||
|
* CAS 17 RF1
|
||||||
|
* RAS 18 RF13
|
||||||
|
*
|
||||||
|
* SDRam 42, 44, 45, 47, 48, 50, 51, 53 - (d8-d15) should be pulled up, but
|
||||||
|
* on the prototype board these were simply left floating
|
||||||
|
*
|
||||||
|
* Power connections not listed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrobsd does not currently contain a good header
|
||||||
|
* for pulling the pic32 port addresses into an assembly
|
||||||
|
* file, so define some needed registers here for the moment.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define TRISA 0xBF886000
|
||||||
|
#define T2CON 0xBF800800
|
||||||
|
#define TMR2 0xBF800810
|
||||||
|
#define PR2 0xBF800820
|
||||||
|
#define T2CONSET 0xBF800808
|
||||||
|
|
||||||
|
#define OC1CON 0xBF803000
|
||||||
|
#define OC4CON 0xBF803600
|
||||||
|
#define OCXR_OFFSET 0x10
|
||||||
|
#define OCXRS_OFFSET 0x20
|
||||||
|
|
||||||
|
#define AD1PCFGSET 0xBF809068
|
||||||
|
|
||||||
|
/* Offsets (from TRISA) for the io ports */
|
||||||
|
#define SDR_OFFSET_A 0
|
||||||
|
#define SDR_OFFSET_B 0x40
|
||||||
|
#define SDR_OFFSET_C 0x80
|
||||||
|
#define SDR_OFFSET_D 0xc0
|
||||||
|
#define SDR_OFFSET_E 0x100
|
||||||
|
#define SDR_OFFSET_F 0x140
|
||||||
|
#define SDR_OFFSET_G 0x180
|
||||||
|
|
||||||
|
/* Offsets (from TRISA) for the various port control registers */
|
||||||
|
#define TRIS_OFFSET 0x0
|
||||||
|
#define PORT_OFFSET 0x10
|
||||||
|
#define LAT_OFFSET 0x20
|
||||||
|
#define ODCF_OFFSET 0x30
|
||||||
|
|
||||||
|
/* Offsets (from TRISA) for the various io port bit manipulator registers */
|
||||||
|
#define NOP_OP_OFFSET 0x0
|
||||||
|
#define CLR_OP_OFFSET 0x4
|
||||||
|
#define SET_OP_OFFSET 0x8
|
||||||
|
#define INV_OP_OFFSET 0xc
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Specific assignments of ports ports used
|
||||||
|
* Note: In general, it is not sufficient to
|
||||||
|
* change the constants below - corresponding
|
||||||
|
* changes to the code below will likely be
|
||||||
|
* required if any of the following values
|
||||||
|
* are changed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* DATA_PORT_TRIS must be assigned to a TRIS of the port
|
||||||
|
* that has the low 8 bits tied the 8 data bits on the ram.
|
||||||
|
*/
|
||||||
|
#define SDR_OCR OC1CON
|
||||||
|
|
||||||
|
#define SDR_DATA_IO SDR_OFFSET_A
|
||||||
|
#define SDR_DATA_TRIS SDR_OFFSET_A
|
||||||
|
|
||||||
|
#define SDR_ADDRESS_IO SDR_OFFSET_B
|
||||||
|
#define SDR_ADDRESS_TRIS SDR_OFFSET_B
|
||||||
|
#define ADDRESS_MASK 0xfafc
|
||||||
|
|
||||||
|
#define SDR_BANK_IO SDR_OFFSET_D
|
||||||
|
#define SDR_BANK_TRIS SDR_OFFSET_D
|
||||||
|
#define BANK_0_BIT 4
|
||||||
|
#define BANK_1_BIT 5
|
||||||
|
|
||||||
|
#define SDR_CONTROL_IO SDR_OFFSET_F
|
||||||
|
#define SDR_CONTROL_TRIS SDR_OFFSET_F
|
||||||
|
#define CONTROL_WE_BIT 0
|
||||||
|
#define CONTROL_CAS_BIT 1
|
||||||
|
#define CONTROL_CS_BIT 12
|
||||||
|
#define CONTROL_RAS_BIT 13
|
||||||
|
|
||||||
|
#define SDR_CKE_IO SDR_OFFSET_A
|
||||||
|
#define SDR_CKE_TRIS SDR_OFFSET_A
|
||||||
|
#define CKE_BIT 10
|
||||||
|
#define DATA_DIR_BIT 15
|
||||||
|
|
||||||
|
#define CONTROL_ALL_MASK ( (1<<CONTROL_CS_BIT) | (1<<CONTROL_RAS_BIT) | (1<<CONTROL_CAS_BIT) | (1<<CONTROL_WE_BIT) )
|
||||||
|
#define BANK_ALL_MASK ( (1 << BANK_1_BIT) | ( 1 << BANK_0_BIT ) )
|
||||||
|
|
||||||
|
/* Global Symbols */
|
||||||
|
.globl sdram_init
|
||||||
|
.globl sdram_read
|
||||||
|
.globl sdram_write
|
||||||
|
.globl sdram_active
|
||||||
|
.globl sdram_auto_refresh
|
||||||
|
.globl sdram_precharge
|
||||||
|
.globl sdram_precharge_all
|
||||||
|
.globl sdram_sleep
|
||||||
|
.globl sdram_wake
|
||||||
|
.globl sdram_bank
|
||||||
|
|
||||||
|
.type sdram_init, @function
|
||||||
|
.type sdram_read, @function
|
||||||
|
.type sdram_write, @function
|
||||||
|
.type sdram_active, @function
|
||||||
|
.type sdram_auto_refresh, @function
|
||||||
|
.type sdram_precharge, @function
|
||||||
|
.type sdram_precharge_all, @function
|
||||||
|
.type sdram_sleep, @function
|
||||||
|
.type sdram_wake, @function
|
||||||
|
.type sdram_bank, @function
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This code MUST execute from ram and the ram MUST be configured
|
||||||
|
* for zero wait states. Interrupts MUST disabled before
|
||||||
|
* calling any of these functions, and any DMA MUST also be
|
||||||
|
* disabled.
|
||||||
|
*
|
||||||
|
* Also, the peripheral bus divisor must be set to 1.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section .ramfunc,"ax",@progbits
|
||||||
|
|
||||||
|
/* No instruction reordering */
|
||||||
|
|
||||||
|
.set noreorder
|
||||||
|
|
||||||
|
#define clock4 \
|
||||||
|
nop;nop;nop;nop
|
||||||
|
|
||||||
|
#define clock3 \
|
||||||
|
nop;nop;nop
|
||||||
|
|
||||||
|
#define clock2 \
|
||||||
|
nop;nop
|
||||||
|
|
||||||
|
#define clock1 \
|
||||||
|
nop
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The SDRAM clock is output from the output compare unit.
|
||||||
|
* This macro synchronizes with that clock so that we are
|
||||||
|
* sure to have at least two clock cycles to issue control
|
||||||
|
* line changes and access the data bus before the rising
|
||||||
|
* edge.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define sync_clock \
|
||||||
|
la $t8, TMR2; \
|
||||||
|
li $v0, 2; \
|
||||||
|
lw $v1, ($t8); \
|
||||||
|
bge $v1, $v0, 1f; \
|
||||||
|
nop; \
|
||||||
|
nop; \
|
||||||
|
nop; \
|
||||||
|
1: \
|
||||||
|
nop;
|
||||||
|
|
||||||
|
#define output_column \
|
||||||
|
and $t5, $a0, 0x1f; \
|
||||||
|
sll $t5, 2; \
|
||||||
|
and $t6, $a0, 0x20; \
|
||||||
|
sll $t6, 9; \
|
||||||
|
or $t5, $t6; \
|
||||||
|
lw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0); \
|
||||||
|
and $t6, ~ADDRESS_MASK; \
|
||||||
|
or $t6, $t5; \
|
||||||
|
sw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0);
|
||||||
|
|
||||||
|
#define output_address \
|
||||||
|
sll $t5, $a0, 2; \
|
||||||
|
and $t5, ADDRESS_MASK; \
|
||||||
|
and $t6, $a0, 0x40; \
|
||||||
|
sll $t6, 8; \
|
||||||
|
or $t5, $t6; \
|
||||||
|
and $t6, $a0, 0x100; \
|
||||||
|
sll $t6, 7; \
|
||||||
|
or $t5, $t6; \
|
||||||
|
lw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0); \
|
||||||
|
and $t6, ~ADDRESS_MASK; \
|
||||||
|
or $t6, $t5; \
|
||||||
|
sw $t6, SDR_ADDRESS_TRIS + LAT_OFFSET($t0);
|
||||||
|
|
||||||
|
/*.ent sdram_init*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initializes the SDRAM.
|
||||||
|
* Should be called once sometime after startup
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_init();
|
||||||
|
*/
|
||||||
|
|
||||||
|
sdram_init:
|
||||||
|
|
||||||
|
/* Initialize address lines */
|
||||||
|
la $t0, TRISA /* base of io addresses */
|
||||||
|
li $t1, ADDRESS_MASK
|
||||||
|
sw $t1, SDR_ADDRESS_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
li $t1, 0xFFFF
|
||||||
|
sw $t1, AD1PCFGSET
|
||||||
|
|
||||||
|
li $t1, BANK_ALL_MASK
|
||||||
|
sw $t1, SDR_BANK_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* All address lines low */
|
||||||
|
li $t1, ADDRESS_MASK
|
||||||
|
sw $t1, SDR_ADDRESS_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
li $t1, BANK_ALL_MASK
|
||||||
|
sw $t1, SDR_BANK_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* Initialize data lines */
|
||||||
|
li $t1, 0xFF
|
||||||
|
sw $t1, SDR_DATA_IO + TRIS_OFFSET + SET_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* Initialize SDRAM control lines */
|
||||||
|
li $t1, CONTROL_ALL_MASK
|
||||||
|
sw $t1, SDR_CONTROL_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
li $t1, CONTROL_ALL_MASK
|
||||||
|
sw $t1, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
li $t1, (1<<DATA_DIR_BIT)
|
||||||
|
sw $t1, SDR_CKE_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* Initialize CKE line */
|
||||||
|
// li $t1, (1<<CKE_BIT)
|
||||||
|
li $t1, (1<<CKE_BIT)|(1<<DATA_DIR_BIT)
|
||||||
|
sw $t1, SDR_CKE_IO + TRIS_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* CKE low */
|
||||||
|
li $t1, (1<<CKE_BIT)
|
||||||
|
sw $t1, SDR_CKE_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* SDRAM clock output */
|
||||||
|
|
||||||
|
/* Initialize Timer2 */
|
||||||
|
sw $zero, T2CON
|
||||||
|
sw $zero, TMR2
|
||||||
|
li $t1, 3
|
||||||
|
sw $t1, PR2
|
||||||
|
li $t1, 0x8000
|
||||||
|
sw $t1, T2CONSET
|
||||||
|
|
||||||
|
/* Initialize OC device */
|
||||||
|
sw $zero, SDR_OCR /*OC4CON */
|
||||||
|
li $t1, 1
|
||||||
|
sw $t1, SDR_OCR + OCXRS_OFFSET /*OC4RS*/
|
||||||
|
li $t1, 3
|
||||||
|
sw $t1, SDR_OCR + OCXR_OFFSET /*OC4R*/
|
||||||
|
li $t1, 0x8005
|
||||||
|
sw $t1, SDR_OCR /*OC4CON*/
|
||||||
|
|
||||||
|
/* Clock output starts here */
|
||||||
|
|
||||||
|
/* SD-RAM initialization delay */
|
||||||
|
li $t2, 500
|
||||||
|
move $t1, $zero
|
||||||
|
|
||||||
|
sdram_init_delay_1:
|
||||||
|
addi $t1, $t1, 1
|
||||||
|
bne $t1, $t2, sdram_init_delay_1
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* CKE high */
|
||||||
|
li $t1, (1<<CKE_BIT)
|
||||||
|
sw $t1, SDR_CKE_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
/* Delay some more */
|
||||||
|
li $t2, 3000
|
||||||
|
move $t1, $zero
|
||||||
|
|
||||||
|
sdram_init_delay_2:
|
||||||
|
addi $t1, $t1, 1
|
||||||
|
bne $t1, $t2, sdram_init_delay_2
|
||||||
|
nop
|
||||||
|
|
||||||
|
/* Get ready for the commands we are about to issue. */
|
||||||
|
li $t4, (1<<CONTROL_CAS_BIT)
|
||||||
|
li $t5, (1<<CONTROL_WE_BIT)
|
||||||
|
li $t6, 0x1810 /* Mode Register: CL:2, BL:8 (0x23) */
|
||||||
|
li $t7, CONTROL_ALL_MASK
|
||||||
|
li $t8, 0x8000 /* A10 */
|
||||||
|
|
||||||
|
sw $t8, SDR_ADDRESS_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* A10 = 1 for Precharge ALL */
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Precharge All */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* LLLL */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* LLHL */
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Auto Refresh 1 */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* LLLL */
|
||||||
|
sw $t5, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* LLLH */
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Auto Refresh 2 */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
/* Auto Refresh 3 */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
/* Auto Refresh 4 */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
/* Auto Refresh 5 */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
/* Auto Refresh 6 */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
/* Auto Refresh 7 */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
/* Auto Refresh 8 */
|
||||||
|
li $t4, ADDRESS_MASK
|
||||||
|
sw $t4, SDR_ADDRESS_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Load Mode Register */
|
||||||
|
sw $t6, SDR_ADDRESS_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + CLR_OP_OFFSET($t0)
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + SET_OP_OFFSET($t0)
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
/*.end sdram_init*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sends ACTIVE command
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_active(uint16_t rowaddr);
|
||||||
|
*/
|
||||||
|
sdram_active:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t7, (1<<CONTROL_CS_BIT)|(1<<CONTROL_RAS_BIT)
|
||||||
|
|
||||||
|
/* Set row */
|
||||||
|
output_address
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Active */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sends WRITE command
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_write(uint16_t pseudocoladdr, uint64_t val);
|
||||||
|
* Each pseudo column contains 8 bytes of data (consists of 8 ram columns)
|
||||||
|
*/
|
||||||
|
|
||||||
|
sdram_write:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t4, 0xFF
|
||||||
|
li $t7, (1<<CONTROL_CS_BIT) | (1<<CONTROL_CAS_BIT) | (1<<CONTROL_WE_BIT)
|
||||||
|
li $t3, (1<<DATA_DIR_BIT)
|
||||||
|
|
||||||
|
/* Set column */
|
||||||
|
output_column
|
||||||
|
|
||||||
|
/* Set data lines */
|
||||||
|
srl $t5, $a2, 24
|
||||||
|
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
sw $t3, SDR_CKE_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Write */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LHLL */
|
||||||
|
sw $t4, SDR_DATA_IO + TRIS_OFFSET + INV_OP_OFFSET($t0) /* 1 - enable data lines */
|
||||||
|
srl $t5, $a2, 16
|
||||||
|
clock1
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* HHHH */
|
||||||
|
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 2 */
|
||||||
|
srl $t5, $a2, 8
|
||||||
|
clock1
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 3 */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sb $a2, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 4 */
|
||||||
|
srl $t5, $a3, 24
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 5 */
|
||||||
|
srl $t5, $a3, 16
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 6 */
|
||||||
|
srl $t5, $a3, 8
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sb $t5, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 7 */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sb $a3, SDR_DATA_IO + LAT_OFFSET + NOP_OP_OFFSET($t0) /* 8 */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
sw $t4, SDR_DATA_IO + TRIS_OFFSET + INV_OP_OFFSET($t0) /* Data lines input again */
|
||||||
|
|
||||||
|
clock4 /* make certain sdram output has had time to disable - probably not needed */
|
||||||
|
sw $t3, SDR_CKE_IO + LAT_OFFSET + INV_OP_OFFSET($t0)
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sends READ command
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) uint64_t sdram_read(uint16_t pseudocoladdr);
|
||||||
|
* Each pseudo column contains 8 bytes of data (consists of 8 ram columns)
|
||||||
|
*/
|
||||||
|
sdram_read:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t7, (1<<CONTROL_CS_BIT) | (1<<CONTROL_CAS_BIT)
|
||||||
|
|
||||||
|
/* Set column */
|
||||||
|
output_column
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Read */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LHLH */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t7, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* HHHH */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
clock3
|
||||||
|
lbu $v0, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 1 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
clock3
|
||||||
|
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 2 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sll $v0, $v0, 8
|
||||||
|
or $v0, $v0, $t5
|
||||||
|
clock1
|
||||||
|
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 3 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sll $v0, $v0, 8
|
||||||
|
or $v0, $v0, $t5
|
||||||
|
clock1
|
||||||
|
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 4 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sll $v0, $v0, 8
|
||||||
|
or $v0, $v0, $t5
|
||||||
|
clock1
|
||||||
|
lbu $v1, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 5 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
clock3
|
||||||
|
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 6 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sll $v1, $v1, 8
|
||||||
|
or $v1, $v1, $t5
|
||||||
|
clock1
|
||||||
|
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 7 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sll $v1, $v1, 8
|
||||||
|
or $v1, $v1, $t5
|
||||||
|
clock1
|
||||||
|
lbu $t5, SDR_DATA_IO + PORT_OFFSET + NOP_OP_OFFSET($t0) /* 8 */
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sll $v1, $v1, 8
|
||||||
|
or $v1, $v1, $t5
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sends PRECHARGE ALL command
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_precharge_all(void);
|
||||||
|
*/
|
||||||
|
sdram_precharge_all:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t3, 0x8000 /* A10 */
|
||||||
|
li $t4, (1<<CONTROL_CS_BIT) | (1<<CONTROL_RAS_BIT) | (1<<CONTROL_WE_BIT)
|
||||||
|
|
||||||
|
sw $t3, SDR_ADDRESS_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* A10 = 1 for Precharge ALL */
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Precharge All */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLHL */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sends PRECHARGE command
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_precharge(void);
|
||||||
|
*/
|
||||||
|
sdram_precharge:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t3, 0x8000 /* A10 */
|
||||||
|
li $t4, (1<<CONTROL_CS_BIT) | (1<<CONTROL_RAS_BIT) | (1<<CONTROL_WE_BIT)
|
||||||
|
|
||||||
|
sw $t3, SDR_ADDRESS_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* A10 = 0 for Precharge */
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Precharge All */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLHL */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sends AUTO REFRESH command
|
||||||
|
* All banks must be in PRECHARGEd state
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_auto_refresh(void);
|
||||||
|
*/
|
||||||
|
sdram_auto_refresh:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t4, (1<<CONTROL_CS_BIT)|(1<<CONTROL_RAS_BIT)|(1<<CONTROL_CAS_BIT)
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Auto Refresh */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLH */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Puts the SDRAM into the self refresh mode.
|
||||||
|
* SDRAM retains data in this state.
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_sleep(void);
|
||||||
|
*/
|
||||||
|
sdram_sleep:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t1, (1<<CKE_BIT)
|
||||||
|
li $t4, (1<<CONTROL_CS_BIT)|(1<<CONTROL_RAS_BIT)|(1<<CONTROL_CAS_BIT)
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Auto Refresh */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLH */
|
||||||
|
sw $t1, SDR_CKE_IO + LAT_OFFSET + CLR_OP_OFFSET($t0) /* CKE low */
|
||||||
|
clock2
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t4, SDR_CONTROL_IO + LAT_OFFSET + INV_OP_OFFSET($t0) /* LLLL */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Takes the SDRAM out of the self refresh mode.
|
||||||
|
* Parameters: none
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_wake(void);
|
||||||
|
*/
|
||||||
|
sdram_wake:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
li $t1, (1<<CKE_BIT)
|
||||||
|
|
||||||
|
sync_clock
|
||||||
|
|
||||||
|
.set nomacro
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
sw $t1, SDR_CKE_IO + LAT_OFFSET + SET_OP_OFFSET($t0) /* CKE low */
|
||||||
|
clock3
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
/* Command Inhibit */
|
||||||
|
clock4
|
||||||
|
|
||||||
|
.set macro
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Selects the bank to which commands are issued
|
||||||
|
* Parameters:
|
||||||
|
* C Prototype:
|
||||||
|
* extern __attribute__((far)) void sdram_bank(uint8_t bank);
|
||||||
|
* (only lower 2 bits are of bank are currently significant)
|
||||||
|
*/
|
||||||
|
sdram_bank:
|
||||||
|
|
||||||
|
la $t0, TRISA /* Port Base */
|
||||||
|
lw $t1, SDR_BANK_IO + LAT_OFFSET + NOP_OP_OFFSET($t0);
|
||||||
|
and $t1, ~BANK_ALL_MASK
|
||||||
|
sll $t2, $a0, BANK_0_BIT
|
||||||
|
or $t1, $t2
|
||||||
|
sw $t1, SDR_BANK_IO + LAT_OFFSET + NOP_OP_OFFSET($t0);
|
||||||
|
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
4
share/.gitignore
vendored
4
share/.gitignore
vendored
@@ -1,4 +0,0 @@
|
|||||||
re.help
|
|
||||||
misc
|
|
||||||
unixbench
|
|
||||||
emg.keys
|
|
||||||
25486
share/dict/words
25486
share/dict/words
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
all: ashello echo chello stdarg skeleton
|
all: ashello echo
|
||||||
|
|
||||||
ashello: ashello.o
|
ashello: ashello.o
|
||||||
$(LD) ashello.o -o $@
|
$(LD) ashello.o -o $@
|
||||||
@@ -10,11 +10,5 @@ chello: chello.o
|
|||||||
echo: echo.o
|
echo: echo.o
|
||||||
$(LD) $@.o -o $@
|
$(LD) $@.o -o $@
|
||||||
|
|
||||||
stdarg: stdarg.o
|
|
||||||
$(CC) stdarg.o -o $@
|
|
||||||
|
|
||||||
skeleton: skeleton.o
|
|
||||||
$(CC) skeleton.o -o $@
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o ashello echo chello stdarg skeleton *.dis *~
|
rm -f *.o ashello echo *.dis *~
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ CFLAGS += -Werror
|
|||||||
ASFLAGS += -DCROSS
|
ASFLAGS += -DCROSS
|
||||||
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
|
ASLDFLAGS = --oformat=elf32-tradlittlemips -N -nostartfiles -T $(TOPSRC)/src/elf32-mips.ld
|
||||||
|
|
||||||
all: chello cplus echo stdarg
|
all: hello cplus
|
||||||
|
|
||||||
chello: chello.o
|
hello: hello.o
|
||||||
${CC} ${LDFLAGS} -o chello.elf chello.o ${LIBS}
|
${CC} ${LDFLAGS} -o hello.elf hello.o ${LIBS}
|
||||||
${OBJDUMP} -S chello.elf > chello.dis
|
${OBJDUMP} -S hello.elf > hello.dis
|
||||||
${SIZE} chello.elf
|
${SIZE} hello.elf
|
||||||
${ELF2AOUT} chello.elf $@
|
${ELF2AOUT} hello.elf $@
|
||||||
|
|
||||||
cplus: cplus.o
|
cplus: cplus.o
|
||||||
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
|
${CXX} ${LDFLAGS} -nostdlib -o cplus.elf cplus.o ${LIBS}
|
||||||
@@ -24,6 +24,7 @@ echo: echo.o
|
|||||||
${OBJDUMP} -S $@.elf > $@.dis
|
${OBJDUMP} -S $@.elf > $@.dis
|
||||||
${SIZE} $@.elf
|
${SIZE} $@.elf
|
||||||
${ELF2AOUT} $@.elf $@
|
${ELF2AOUT} $@.elf $@
|
||||||
|
./aout $@ > $@.dis
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o *.elf ${MAN} chello cplus echo stdarg *.elf *.dis tags *~
|
rm -f *.o *.elf ${MAN} hello cplus *.elf *.dis tags *~
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
printf ("Hello, C World!\n");
|
printf ("Hello, C World!\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Generic skeleton for a C program.
|
|
||||||
* When you create your own program based on this skeleton,
|
|
||||||
* you can replace the author's name and copyright with
|
|
||||||
* whatever your want. When you redistribute this skeleton or
|
|
||||||
* enhance it, please leave my name and copyright on it.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1993-2014 Serge Vakulenko, <vak@cronyx.ru>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software
|
|
||||||
* and its documentation for any purpose and without fee is hereby
|
|
||||||
* granted, provided that the above copyright notice appear in all
|
|
||||||
* copies and that both that the copyright notice and this
|
|
||||||
* permission notice and warranty disclaimer appear in supporting
|
|
||||||
* documentation, and that the name of the author not be used in
|
|
||||||
* advertising or publicity pertaining to distribution of the
|
|
||||||
* software without specific, written prior permission.
|
|
||||||
*
|
|
||||||
* The author disclaim all warranties with regard to this
|
|
||||||
* software, including all implied warranties of merchantability
|
|
||||||
* and fitness. In no event shall the author be liable for any
|
|
||||||
* special, indirect or consequential damages or any damages
|
|
||||||
* whatsoever resulting from loss of use, data or profits, whether
|
|
||||||
* in an action of contract, negligence or other tortious action,
|
|
||||||
* arising out of or in connection with the use or performance of
|
|
||||||
* this software.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
const char version[] = "1.0";
|
|
||||||
const char copyright[] = "Copyright (C) 1993-2014 Serge Vakulenko";
|
|
||||||
|
|
||||||
char *progname; /* Name of the current program (argv[0]) */
|
|
||||||
int verbose; /* Option -v */
|
|
||||||
int trace; /* Option -t */
|
|
||||||
int debug; /* Option -d */
|
|
||||||
|
|
||||||
void usage ()
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Generic C skeleton, Version %s, %s\n", version, copyright);
|
|
||||||
fprintf (stderr, "Usage:\n\t%s [-vtd] [-r count] file...\n", progname);
|
|
||||||
fprintf (stderr, "Options:\n");
|
|
||||||
fprintf (stderr, "\t-v\tverbose mode\n");
|
|
||||||
fprintf (stderr, "\t-t\ttrace mode\n");
|
|
||||||
fprintf (stderr, "\t-d\tdebug\n");
|
|
||||||
fprintf (stderr, "\t-r #\trepeat count\n");
|
|
||||||
exit (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
int count = 1; /* Option -r # */
|
|
||||||
|
|
||||||
progname = *argv;
|
|
||||||
for (;;) {
|
|
||||||
switch (getopt (argc, argv, "vtdr:")) {
|
|
||||||
case EOF:
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
++verbose;
|
|
||||||
continue;
|
|
||||||
case 't':
|
|
||||||
++trace;
|
|
||||||
continue;
|
|
||||||
case 'd':
|
|
||||||
++debug;
|
|
||||||
continue;
|
|
||||||
case 'r':
|
|
||||||
count = strtol (optarg, 0, 0);
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
usage ();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
|
||||||
|
|
||||||
if (argc < 1)
|
|
||||||
usage ();
|
|
||||||
|
|
||||||
while (count-- > 0) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0; i<argc; ++i)
|
|
||||||
printf ("%s ", argv[i]);
|
|
||||||
printf ("\n");
|
|
||||||
}
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
void print(char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
int d;
|
|
||||||
char c, *s;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
while (*fmt) {
|
|
||||||
switch (*fmt++) {
|
|
||||||
case 's': /* string */
|
|
||||||
s = va_arg(ap, char*);
|
|
||||||
printf("string %s\n", s);
|
|
||||||
break;
|
|
||||||
case 'd': /* int */
|
|
||||||
d = va_arg(ap, int);
|
|
||||||
printf("int %d\n", d);
|
|
||||||
break;
|
|
||||||
case 'c': /* char */
|
|
||||||
c = va_arg(ap, int);
|
|
||||||
printf("char %c\n", c);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
print("sdcsdc", "abracadabra", 12345, 'Z', "foo", 365, '%');
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
3
share/man/.gitignore
vendored
3
share/man/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
makewhatis.sed
|
|
||||||
man.template
|
|
||||||
whatis
|
|
||||||
0
share/man/cat1/.gitignore
vendored
0
share/man/cat1/.gitignore
vendored
0
share/man/cat2/.gitignore
vendored
0
share/man/cat2/.gitignore
vendored
0
share/man/cat3/.gitignore
vendored
0
share/man/cat3/.gitignore
vendored
0
share/man/cat4/.gitignore
vendored
0
share/man/cat4/.gitignore
vendored
0
share/man/cat5/.gitignore
vendored
0
share/man/cat5/.gitignore
vendored
0
share/man/cat6/.gitignore
vendored
0
share/man/cat6/.gitignore
vendored
0
share/man/cat7/.gitignore
vendored
0
share/man/cat7/.gitignore
vendored
0
share/man/cat8/.gitignore
vendored
0
share/man/cat8/.gitignore
vendored
@@ -1,41 +0,0 @@
|
|||||||
CC = scc
|
|
||||||
PROG = hello primelist primesum test1 test2 test3 gpio adc rain \
|
|
||||||
webserver q8
|
|
||||||
|
|
||||||
all: $(PROG)
|
|
||||||
|
|
||||||
hello: hello.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) hello.c
|
|
||||||
|
|
||||||
primelist: primelist.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primelist.c
|
|
||||||
|
|
||||||
primesum: primesum.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primesum.c
|
|
||||||
|
|
||||||
webserver: webserver.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) webserver.c -lwiznet
|
|
||||||
|
|
||||||
gpio: gpio.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) gpio.c
|
|
||||||
|
|
||||||
adc: adc.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) adc.c
|
|
||||||
|
|
||||||
rain: rain.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) rain.c
|
|
||||||
|
|
||||||
q8: q8.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) q8.c
|
|
||||||
|
|
||||||
test1: test1.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test1.c
|
|
||||||
|
|
||||||
test2: test2.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test2.c
|
|
||||||
|
|
||||||
test3: test3.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test3.c
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o $(PROG)
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of reading ADC data.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
char buf[100];
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int i, fd, value;
|
|
||||||
|
|
||||||
for (i=0; i<16; i++) {
|
|
||||||
sprintf(buf, "/dev/adc%d", i);
|
|
||||||
fd = open(buf, O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
printf("Error: unable to open %s\n", buf);
|
|
||||||
} else {
|
|
||||||
if (read(fd, buf, 20) > 0) {
|
|
||||||
value = strtol (buf, 0, 0);
|
|
||||||
printf("adc%-2d = %d\n", i, value);
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of polling general purpose i/o pins.
|
|
||||||
*/
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/gpio.h>
|
|
||||||
|
|
||||||
main ()
|
|
||||||
{
|
|
||||||
int fd, pnum, value;
|
|
||||||
|
|
||||||
fd = open ("/dev/porta", O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
perror ("/dev/porta");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (pnum=0; pnum<7; pnum++) {
|
|
||||||
value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0);
|
|
||||||
if (value < 0)
|
|
||||||
perror ("GPIO_POLL");
|
|
||||||
printf ("port%c = 0x%04x\n", pnum + 'A', value);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
main()
|
|
||||||
{
|
|
||||||
printf ("Hello, SmallC World!\n");
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* Print the list of prime numbers up to 100.
|
|
||||||
*/
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
for (n=2; n<100; ++n) {
|
|
||||||
if (isprime(n)) {
|
|
||||||
printf("%d ", n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
isprime(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (n == 2)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (n % 2 == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (j=3; j*j<=n; j+=2)
|
|
||||||
if (n % j == 0)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Compute the sum of prime numbers up to 10000.
|
|
||||||
*/
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int sum, n;
|
|
||||||
|
|
||||||
sum = 0;
|
|
||||||
for (n=2; n<10000; ++n) {
|
|
||||||
if (isprime(n)) {
|
|
||||||
sum += n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("Sum of primes less than 10000: %d\n", sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
isprime(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (n == 2)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (n % 2 == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (j=3; j*j<=n; j+=2)
|
|
||||||
if (n % j == 0)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,208 +0,0 @@
|
|||||||
/*
|
|
||||||
* Eight Queens puzzle
|
|
||||||
*
|
|
||||||
* (C) 2010 by Mark Sproul
|
|
||||||
* Open source as per standard Arduino code
|
|
||||||
* Modified by Pito 12/2012 for SmallC
|
|
||||||
*/
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
|
|
||||||
unsigned int gChessBoard[8];
|
|
||||||
unsigned int gLoopCounter;
|
|
||||||
int gValidCount;
|
|
||||||
|
|
||||||
CheckCurrentBoard()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int jj;
|
|
||||||
int theRow;
|
|
||||||
int theLongRow;
|
|
||||||
int theLongColumns;
|
|
||||||
int bitCount;
|
|
||||||
|
|
||||||
//* we know we have 1 in each row,
|
|
||||||
//* Check for 1 in each column
|
|
||||||
theRow = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow |= gChessBoard[ii];
|
|
||||||
}
|
|
||||||
if (theRow != 0x0ff) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* we have 1 in each column, now check the diagonals
|
|
||||||
theLongColumns = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theLongRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theLongRow = theLongRow << ii;
|
|
||||||
|
|
||||||
theLongColumns |= theLongRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* now count the bits
|
|
||||||
bitCount = 0;
|
|
||||||
for (ii=0; ii<16; ii++) {
|
|
||||||
if ((theLongColumns & 0x01) == 0x01) {
|
|
||||||
bitCount++;
|
|
||||||
}
|
|
||||||
theLongColumns = theLongColumns >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitCount != 8) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* we now have to check the other diagonal
|
|
||||||
theLongColumns = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theLongRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theLongRow = theLongRow << 8;
|
|
||||||
theLongRow = theLongRow >> ii;
|
|
||||||
|
|
||||||
theLongColumns |= theLongRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* now count the bits
|
|
||||||
bitCount = 0;
|
|
||||||
for (ii=0; ii<16; ii++) {
|
|
||||||
if ((theLongColumns & 0x01) == 0x01) {
|
|
||||||
bitCount++;
|
|
||||||
}
|
|
||||||
theLongColumns = theLongColumns >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitCount != 8) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckForDone()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int weAreDone;
|
|
||||||
int theRow;
|
|
||||||
|
|
||||||
weAreDone = FALSE;
|
|
||||||
|
|
||||||
//* we know we have 1 in each row,
|
|
||||||
//* Check for 1 in each column
|
|
||||||
theRow = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow |= gChessBoard[ii];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theRow == 0x01) {
|
|
||||||
weAreDone = TRUE;
|
|
||||||
}
|
|
||||||
return weAreDone;
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateQueens()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int keepGoing;
|
|
||||||
int theRow;
|
|
||||||
|
|
||||||
ii = 0;
|
|
||||||
keepGoing = TRUE;
|
|
||||||
while (keepGoing && (ii < 8)) {
|
|
||||||
theRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theRow = (theRow >> 1) & 0x0ff;
|
|
||||||
if (theRow != 0) {
|
|
||||||
gChessBoard[ii] = theRow;
|
|
||||||
keepGoing = FALSE;
|
|
||||||
} else {
|
|
||||||
gChessBoard[ii] = 0x080;
|
|
||||||
}
|
|
||||||
ii++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintChessBoard()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int jj;
|
|
||||||
int theRow;
|
|
||||||
char textString[32];
|
|
||||||
|
|
||||||
printf("\nLoop= %d\n", gLoopCounter);
|
|
||||||
printf("Solution count= %d\n", gValidCount);
|
|
||||||
|
|
||||||
printf("+----------------+\n");
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow = gChessBoard[ii];
|
|
||||||
|
|
||||||
printf("|");
|
|
||||||
for (jj=0; jj<8; jj++) {
|
|
||||||
if (theRow & 0x080) {
|
|
||||||
printf("Q ");
|
|
||||||
} else {
|
|
||||||
printf(". ");
|
|
||||||
}
|
|
||||||
theRow = theRow << 1;
|
|
||||||
}
|
|
||||||
printf("|\n");
|
|
||||||
}
|
|
||||||
printf("+----------------+\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
|
|
||||||
printf("\nEight Queens brute force");
|
|
||||||
printf("\n************************\n");
|
|
||||||
//* put the 8 queens on the board, 1 in each row
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
gChessBoard[ii] = 0x080;
|
|
||||||
}
|
|
||||||
PrintChessBoard();
|
|
||||||
|
|
||||||
gLoopCounter = 0;
|
|
||||||
gValidCount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
gLoopCounter++;
|
|
||||||
|
|
||||||
if (CheckCurrentBoard()) {
|
|
||||||
gValidCount++;
|
|
||||||
PrintChessBoard();
|
|
||||||
} else if ((gLoopCounter % 1000) == 0) {
|
|
||||||
//PrintChessBoard();
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateQueens();
|
|
||||||
if (CheckForDone()) {
|
|
||||||
//int elapsedSeconds;
|
|
||||||
//int elapsedMinutes;
|
|
||||||
//int elapsedHours;
|
|
||||||
|
|
||||||
//elapsedSeconds = millis() / 1000;
|
|
||||||
//elapsedMinutes = elapsedSeconds / 60;
|
|
||||||
//elapsedHours = elapsedMinutes / 60;
|
|
||||||
|
|
||||||
printf("----------------------------------\n");
|
|
||||||
printf("All done\n");
|
|
||||||
|
|
||||||
PrintChessBoard();
|
|
||||||
printf("----------------------------------\n");
|
|
||||||
|
|
||||||
//Serial.print("total seconds=");
|
|
||||||
//Serial.println(elapsedSeconds);
|
|
||||||
|
|
||||||
//Serial.print("hours=");
|
|
||||||
//Serial.println(elapsedHours);
|
|
||||||
|
|
||||||
//Serial.print("minutes=");
|
|
||||||
//Serial.println(elapsedMinutes % 60);
|
|
||||||
|
|
||||||
//Serial.print("seconds=");
|
|
||||||
//Serial.println(elapsedSeconds % 60);
|
|
||||||
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of using termcap library for SmallC.
|
|
||||||
* 11/3/1980 EPS/CITHEP
|
|
||||||
*
|
|
||||||
* Copyright (c) 1980 Regents of the University of California.
|
|
||||||
* All rights reserved. The Berkeley software License Agreement
|
|
||||||
* specifies the terms and conditions for redistribution.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
#define CO 80 /* number of columns */
|
|
||||||
#define LI 24 /* number of lines */
|
|
||||||
|
|
||||||
#define CL "\33[H\33[J" /* clear the screen */
|
|
||||||
#define CM "\33[%u;%uH" /* move the cursor to row, column */
|
|
||||||
#define BC "\b" /* move cursor left */
|
|
||||||
#define DN "\33[B" /* move cursor down */
|
|
||||||
#define ND " " /* move cursor right */
|
|
||||||
|
|
||||||
int xpos[5], ypos[5];
|
|
||||||
char outbuf[BUFSIZ];
|
|
||||||
|
|
||||||
moveto(col, row)
|
|
||||||
int col, row;
|
|
||||||
{
|
|
||||||
printf(CM, row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
onsig(n)
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
moveto(0, LI - 1);
|
|
||||||
fflush(stdout);
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int x, y, j;
|
|
||||||
|
|
||||||
setbuf(stdout, outbuf);
|
|
||||||
for (j = SIGHUP; j <= SIGTERM; j++)
|
|
||||||
if (signal(j, SIG_IGN) != SIG_IGN)
|
|
||||||
signal(j, onsig);
|
|
||||||
|
|
||||||
fputs(CL, stdout);
|
|
||||||
fflush(stdout);
|
|
||||||
for (j = 5; --j >= 0; ) {
|
|
||||||
xpos[j] = 2 + rand() % (CO - 4);
|
|
||||||
ypos[j] = 2 + rand() % (LI - 4);
|
|
||||||
}
|
|
||||||
for (j = 0; ; ) {
|
|
||||||
x = 2 + rand() % (CO - 4);
|
|
||||||
y = 2 + rand() % (LI - 4);
|
|
||||||
moveto(x, y);
|
|
||||||
putchar('.');
|
|
||||||
moveto(xpos[j], ypos[j]);
|
|
||||||
putchar('o');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]);
|
|
||||||
putchar('O');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-1);
|
|
||||||
putchar('-');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs("|.|", stdout);
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar('-');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-2);
|
|
||||||
putchar('-');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs("/ \\", stdout);
|
|
||||||
moveto(xpos[j]-2, ypos[j]);
|
|
||||||
fputs("| O |", stdout);
|
|
||||||
moveto(xpos[j]-1, ypos[j]+1);
|
|
||||||
fputs("\\ /", stdout);
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar('-');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-2);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
moveto(xpos[j]-2, ypos[j]);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
moveto(xpos[j]-1, ypos[j]+1);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
xpos[j] = x;
|
|
||||||
ypos[j] = y;
|
|
||||||
fflush(stdout);
|
|
||||||
usleep(100000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,219 +0,0 @@
|
|||||||
int ga[5];
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
int a, b, c, d;
|
|
||||||
int arr[5];
|
|
||||||
int *pi;
|
|
||||||
char arrc[5];
|
|
||||||
char *pic;
|
|
||||||
int s1, s2;
|
|
||||||
int z;
|
|
||||||
int t;
|
|
||||||
int *pip;
|
|
||||||
int *picp;
|
|
||||||
int e1, e2;
|
|
||||||
|
|
||||||
ga[0] = 10;
|
|
||||||
ga[1] = 20;
|
|
||||||
ga[2] = 30;
|
|
||||||
ga[3] = 40;
|
|
||||||
ga[4] = 50;
|
|
||||||
|
|
||||||
a = 21;
|
|
||||||
b = 31;
|
|
||||||
c = 71;
|
|
||||||
d = 82;
|
|
||||||
|
|
||||||
arr[0] = 10;
|
|
||||||
arr[1] = 20;
|
|
||||||
arr[2] = 30;
|
|
||||||
arr[3] = 40;
|
|
||||||
arr[4] = 50;
|
|
||||||
pi = &arr[0];
|
|
||||||
|
|
||||||
arrc[0] = 13;
|
|
||||||
arrc[1] = 23;
|
|
||||||
arrc[2] = 33;
|
|
||||||
arrc[3] = 43;
|
|
||||||
arrc[4] = 53;
|
|
||||||
pic = &arrc[0];
|
|
||||||
|
|
||||||
printf(" 21 + 31 = %d (52)\n", a + b);
|
|
||||||
printf(" 21 - 31 = %d (-10)\n", a - b);
|
|
||||||
printf(" 21 & 71 = %d (5)\n", a & c);
|
|
||||||
printf(" 21 | 82 = %d (87)\n", a | d);
|
|
||||||
printf(" 21 ^ 82 = %d (71)\n", a ^ d);
|
|
||||||
printf(" 21 * 82 = %d (1722)\n", a * d);
|
|
||||||
printf(" 82 % 21 = %d (19)\n", d % a);
|
|
||||||
printf(" 82 / 21 = %d (3)\n", d / a);
|
|
||||||
printf(" *pi = %d (10)\n", *pi);
|
|
||||||
printf(" *pi + 1 = %d (11)\n", *pi + 1);
|
|
||||||
printf(" *(pi + 1) = %d (20)\n", *(pi + 1));
|
|
||||||
printf("&arr[3] - &arr[0] = %d (3)\n", &arr[3] - &arr[0]);
|
|
||||||
printf(" arr[3]-arr[0] = %d (30)\n", arr[3] - arr[0]);
|
|
||||||
printf(" arr[3]+arr[0] = %d (50)\n", arr[3] + arr[0]);
|
|
||||||
printf(" &ga[3] - &ga[0] = %d (3)\n", &ga[3] - &ga[0]);
|
|
||||||
printf(" ga[3]-ga[0] = %d (30)\n", ga[3] - ga[0]);
|
|
||||||
printf(" ga[3]+ga[0] = %d (50)\n", ga[3] + ga[0]);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" *pic = %d (13)\n", *pic);
|
|
||||||
printf(" *pic + 1 = %d (14)\n", *pic+1);
|
|
||||||
printf(" *(pic + 1) = %d (23)\n", *(pic+1));
|
|
||||||
printf("&arrc[3] - &arrc[0] = %d (3)\n", &arrc[3]-&arrc[0]);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
s1 = 3;
|
|
||||||
s2 = -200;
|
|
||||||
printf(" 82 << 3 = %d (656)\n", d << s1);
|
|
||||||
printf(" 82 >> 3 = %d (10)\n", d >> s1);
|
|
||||||
printf("-200 >> 3 = %d (-25)\n", s2 >> s1);
|
|
||||||
printf("-200 << 3 = %d (-1600)\n", s2 << s1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("-s1 = %d (-3)\n", -s1);
|
|
||||||
printf("-s2 = %d (200)\n", -s2);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("~82 = %d (-83)\n", ~d);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
z = 0;
|
|
||||||
printf("!82 = %d (0)\n", !d);
|
|
||||||
printf(" !0 = %d (1)\n", !z);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" 0 && 0 = %d (0)\n", z && z);
|
|
||||||
printf(" 0 && 21 = %d (0)\n", z && a);
|
|
||||||
printf(" 3 && 21 = %d (1)\n", s1 && a);
|
|
||||||
printf("21 && 3 = %d (1)\n", a && s1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" 0 || 0 = %d (0)\n", z || z);
|
|
||||||
printf(" 0 || 21 = %d (1)\n", z || a);
|
|
||||||
printf(" 3 || 21 = %d (1)\n", s1 || a);
|
|
||||||
printf("21 || 3 = %d (1)\n", a || s1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = 4;
|
|
||||||
printf("pi++ = %d (4)\n", pi++);
|
|
||||||
printf(" pi = %d (8)\n", pi);
|
|
||||||
printf("++pi = %d (12)\n", ++pi);
|
|
||||||
printf("pi-- = %d (12)\n", pi--);
|
|
||||||
printf(" pi = %d (8)\n", pi);
|
|
||||||
printf("--pi = %d (4)\n", --pi);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pic = 4;
|
|
||||||
printf("pic++ = %d (4)\n", pic++);
|
|
||||||
printf(" pic = %d (5)\n", pic);
|
|
||||||
printf("++pic = %d (6)\n", ++pic);
|
|
||||||
printf("pic-- = %d (6)\n", pic--);
|
|
||||||
printf(" pic = %d (5)\n", pic);
|
|
||||||
printf("--pic = %d (4)\n", --pic);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf("t++ = %d (4)\n", t++);
|
|
||||||
printf(" t = %d (5)\n", t);
|
|
||||||
printf("++t = %d (6)\n", ++t);
|
|
||||||
printf("t-- = %d (6)\n", t--);
|
|
||||||
printf(" t = %d (5)\n", t);
|
|
||||||
printf("--t = %d (4)\n", --t);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t==4 = %d (1)\n", t == 4);
|
|
||||||
printf(" t==3 = %d (0)\n", t == 3);
|
|
||||||
printf(" t==5 = %d (0)\n", t == 5);
|
|
||||||
t = -4;
|
|
||||||
printf("t==-4 = %d (1)\n", t == -4);
|
|
||||||
printf("t==-3 = %d (0)\n", t == -3);
|
|
||||||
printf("t==-5 = %d (0)\n", t == -5);
|
|
||||||
printf(" t==4 = %d (0)\n", t == 4);
|
|
||||||
printf(" t==3 = %d (0)\n", t == 3);
|
|
||||||
printf(" t==5 = %d (0)\n", t == 5);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t!=4 = %d (0)\n", t != 4);
|
|
||||||
printf(" t!=3 = %d (1)\n", t != 3);
|
|
||||||
printf(" t!=5 = %d (1)\n", t != 5);
|
|
||||||
t = -4;
|
|
||||||
printf("t!=-4 = %d (0)\n", t != -4);
|
|
||||||
printf("t!=-3 = %d (1)\n", t != -3);
|
|
||||||
printf("t!=-5 = %d (1)\n", t != -5);
|
|
||||||
printf(" t!=4 = %d (1)\n", t != 4);
|
|
||||||
printf(" t!=3 = %d (1)\n", t != 3);
|
|
||||||
printf(" t!=5 = %d (1)\n", t != 5);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t<4 = %d (0)\n", t < 4);
|
|
||||||
printf(" t<3 = %d (0)\n", t < 3);
|
|
||||||
printf(" t<5 = %d (1)\n", t < 5);
|
|
||||||
printf("t<-1 = %d (0)\n", t < -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" t<=4 = %d (1)\n", t <= 4);
|
|
||||||
printf(" t<=3 = %d (0)\n", t <= 3);
|
|
||||||
printf(" t<=5 = %d (1)\n", t <= 5);
|
|
||||||
printf("t<=-1 = %d (0)\n", t <= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t>4 = %d (0)\n", t > 4);
|
|
||||||
printf(" t>3 = %d (1)\n", t > 3);
|
|
||||||
printf(" t>5 = %d (0)\n", t > 5);
|
|
||||||
printf("t>-1 = %d (1)\n", t > -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" t>=4 = %d (1)\n", t >= 4);
|
|
||||||
printf(" t>=3 = %d (1)\n", t >= 3);
|
|
||||||
printf(" t>=5 = %d (0)\n", t >= 5);
|
|
||||||
printf("t>=-1 = %d (1)\n", t >= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = -100;
|
|
||||||
printf(" pi<4 = %d (0)\n", pi < 4);
|
|
||||||
printf(" pi<3 = %d (0)\n", pi < 3);
|
|
||||||
printf("pi<-100 = %d (0)\n", pi < -100);
|
|
||||||
printf(" pi<-1 = %d (1)\n", pi < -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" pi<=4 = %d (0)\n", pi <= 4);
|
|
||||||
printf(" pi<=3 = %d (0)\n", pi <= 3);
|
|
||||||
printf("pi<=-100 = %d (1)\n", pi <= -100);
|
|
||||||
printf(" pi<=-1 = %d (1)\n", pi <= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = -100;
|
|
||||||
printf(" pi>4 = %d (1)\n", pi > 4);
|
|
||||||
printf(" pi>3 = %d (1)\n", pi > 3);
|
|
||||||
printf("pi>-100 = %d (0)\n", pi > -100);
|
|
||||||
printf(" pi>-1 = %d (0)\n", pi > -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" pi>=4 = %d (1)\n", pi >= 4);
|
|
||||||
printf(" pi>=3 = %d (1)\n", pi >= 3);
|
|
||||||
printf("pi>=-100 = %d (1)\n", pi >= -100);
|
|
||||||
printf(" pi>=-1 = %d (0)\n", pi >= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = &arr[0];
|
|
||||||
pip = &arr[3];
|
|
||||||
printf(" *pip - *pi: %d 30\n", *pip - *pi);
|
|
||||||
printf(" pip - pi: %d 3\n", pip - pi);
|
|
||||||
printf(" *pip: %d 40\n", *pip);
|
|
||||||
printf(" *(pip - 3): %d 10\n", *(pip - 3));
|
|
||||||
printf(" *&arr[3]: %d 40\n", *&arr[3]);
|
|
||||||
printf("*(&arr[3] - 3): %d 10\n", *(&arr[3]-3));
|
|
||||||
}
|
|
||||||
|
|
||||||
printt (t, str)
|
|
||||||
int t;
|
|
||||||
char *str;
|
|
||||||
{
|
|
||||||
printf("bool test on value %d %s\n", t, str);
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
int aaa;
|
|
||||||
int bbb;
|
|
||||||
int ccc;
|
|
||||||
char gc;
|
|
||||||
char gbuffer[3];
|
|
||||||
int gibuffer[4];
|
|
||||||
|
|
||||||
extern errno;
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
char b;
|
|
||||||
int la;
|
|
||||||
unsigned int u1, u2;
|
|
||||||
int s1, s2;
|
|
||||||
unsigned char uc1, uc2;
|
|
||||||
char sc1, sc2;
|
|
||||||
int fd;
|
|
||||||
char buffer[6];
|
|
||||||
int ibuffer[7];
|
|
||||||
|
|
||||||
printf(" sizeof(uc1): %d 1\n", sizeof(uc1));
|
|
||||||
printf(" sizeof(sc1): %d 1\n", sizeof(sc1));
|
|
||||||
printf(" sizeof(u1): %d 4\n", sizeof(u1));
|
|
||||||
printf(" sizeof(s1): %d 4\n", sizeof(s1));
|
|
||||||
printf(" sizeof(aaa): %d 4\n", sizeof(aaa));
|
|
||||||
printf(" sizeof(bbb): %d 4\n", sizeof(bbb));
|
|
||||||
printf(" sizeof(gc): %d 1\n", sizeof(gc));
|
|
||||||
printf(" sizeof(buffer): %d 6\n", sizeof(buffer));
|
|
||||||
printf(" sizeof(ibuffer): %d 28\n", sizeof(ibuffer));
|
|
||||||
printf(" sizeof(char): %d 1\n", sizeof(char));
|
|
||||||
printf(" sizeof(int): %d 4\n", sizeof(int));
|
|
||||||
printf(" sizeof(gbuffer): %d 3\n", sizeof(gbuffer));
|
|
||||||
printf(" sizeof(gibuffer): %d 16\n", sizeof(gibuffer));
|
|
||||||
// sizeof(ibuffer[0]) is not supported, so the following can be used...
|
|
||||||
printf("sizeof(ibuffer)/sizeof(int): %d 7\n", sizeof(ibuffer)/sizeof(int));
|
|
||||||
|
|
||||||
aaa = 1;
|
|
||||||
bbb = 2;
|
|
||||||
la = 4;
|
|
||||||
printf("%d 1\n", aaa);
|
|
||||||
printf("%d 2\n", bbb);
|
|
||||||
printf("%d 4\n", la);
|
|
||||||
|
|
||||||
uc1 = 0x80;
|
|
||||||
sc1 = 0x80;
|
|
||||||
s1 = uc1;
|
|
||||||
s2 = sc1;
|
|
||||||
printf("unsigned char (0x80) -> int: %d 128\n", s1);
|
|
||||||
printf(" signed char (0x80) -> int: %d -128\n", s2);
|
|
||||||
|
|
||||||
u1 = uc1;
|
|
||||||
u2 = sc1;
|
|
||||||
printf("unsigned char (0x80) -> unsigned: %d 128\n", u1);
|
|
||||||
printf(" signed char (0x80) -> unsigned: %d -128\n", u2);
|
|
||||||
|
|
||||||
la = errno;
|
|
||||||
printf("errno: %d 0\n", la);
|
|
||||||
|
|
||||||
write(1, "abcd ", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("errno after good write call: %d 0\n", la);
|
|
||||||
|
|
||||||
write(10, "abcde", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("errno after bad write call: %d 9\n", la);
|
|
||||||
|
|
||||||
write(1, "abcd ", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("good write after failed should not overwrite errno: %d 9\n", la);
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
write(1, "abcd ", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("good write after errno set to zero: %d 0\n", la);
|
|
||||||
|
|
||||||
la = write(1, "abcd ", 5);
|
|
||||||
printf("write() return: %d 5\n", la);
|
|
||||||
|
|
||||||
la = write(10, "abcd ", 5);
|
|
||||||
printf("write(bad fd) return: %d -1\n", la);
|
|
||||||
|
|
||||||
fd = open("/a.txt", O_WRONLY | O_CREAT, 0666);
|
|
||||||
if (fd != -1) {
|
|
||||||
printf("open success\n");
|
|
||||||
la = write(fd, "abcd\n", 5);
|
|
||||||
if (la == 5) printf("write success\n"); else printf("write failed\n");
|
|
||||||
la = close(fd);
|
|
||||||
if (la != -1) printf("close success\n"); else printf("close failed\n");
|
|
||||||
} else {
|
|
||||||
printf("open failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer[0] = 0;
|
|
||||||
buffer[1] = 0;
|
|
||||||
buffer[2] = 0;
|
|
||||||
buffer[3] = 0;
|
|
||||||
buffer[4] = 0;
|
|
||||||
buffer[5] = 0;
|
|
||||||
|
|
||||||
fd = open("/a.txt", O_RDONLY, 0666);
|
|
||||||
if (fd != -1) {
|
|
||||||
printf("open success\n");
|
|
||||||
la = read(fd, buffer, 5);
|
|
||||||
printf(buffer);
|
|
||||||
if (la == 5) printf("read success\n"); else printf("read failed\n");
|
|
||||||
la = close(fd);
|
|
||||||
if (la != -1) printf("close success\n"); else printf("close failed\n");
|
|
||||||
} else {
|
|
||||||
printf("open failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer[0] != 'a') printf("data0 readback from file MISMATCH\n");
|
|
||||||
if (buffer[1] != 'b') printf("data1 readback from file MISMATCH\n");
|
|
||||||
if (buffer[2] != 'c') printf("data2 readback from file MISMATCH\n");
|
|
||||||
if (buffer[3] != 'd') printf("data3 readback from file MISMATCH\n");
|
|
||||||
if (buffer[4] != '\n') printf("data4 readback from file MISMATCH\n");
|
|
||||||
|
|
||||||
if (buffer[0] != 'a' || buffer[1] != 'b' || buffer[2] != 'c' ||
|
|
||||||
buffer[3] != 'd' || buffer[4] != '\n') {
|
|
||||||
printf("data readback from file MISMATCH\n");
|
|
||||||
} else {
|
|
||||||
printf("data readback from file OK\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
main()
|
|
||||||
{
|
|
||||||
int t;
|
|
||||||
|
|
||||||
t = 0;
|
|
||||||
if (t) printt(t, "failure"); else printt(t, "success");
|
|
||||||
t = 1;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
t = 8;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
t = -2;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf("switch test: ");
|
|
||||||
switch (t) {
|
|
||||||
case 3:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
printf("success");
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("switch fallthrough test: ");
|
|
||||||
switch (t) {
|
|
||||||
case 3:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
printf("OKSOFAR: ");
|
|
||||||
case 5:
|
|
||||||
printf("success if oksofar printed before this in caps");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
printt (t, str)
|
|
||||||
int t;
|
|
||||||
char *str;
|
|
||||||
{
|
|
||||||
printf("bool test on value %d %s\n", t, str);
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
/*
|
|
||||||
* Web server, written in SmallC.
|
|
||||||
*
|
|
||||||
* A simple web server that shows the value of the analog input pins.
|
|
||||||
* using an Arduino Wiznet Ethernet shield.
|
|
||||||
*
|
|
||||||
* 18 Dec 2009 created by David A. Mellis
|
|
||||||
* 4 Sep 2010 modified by Tom Igoe
|
|
||||||
* 16 Apr 2012 ported to RetroBSD by Serge Vakulenko
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/gpio.h>
|
|
||||||
#include <wiznet.h>
|
|
||||||
|
|
||||||
int client [CLIENT_SIZE];
|
|
||||||
|
|
||||||
char buf [80];
|
|
||||||
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
/* Initialize the Ethernet server library
|
|
||||||
* with the IP address and port you want to use
|
|
||||||
* (port 80 is default for HTTP). */
|
|
||||||
ethernet_init ();
|
|
||||||
server_init (80);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
/* Listen for incoming clients. */
|
|
||||||
if (server_available (client)) {
|
|
||||||
process_request();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
process_request()
|
|
||||||
{
|
|
||||||
int current_line_is_blank;
|
|
||||||
int c, fd, pnum, value;
|
|
||||||
|
|
||||||
/* An http request ends with a blank line. */
|
|
||||||
current_line_is_blank = 1;
|
|
||||||
|
|
||||||
/* Parse the http request. */
|
|
||||||
while (client_connected (client)) {
|
|
||||||
if (client_available (client)) {
|
|
||||||
c = client_getc (client);
|
|
||||||
|
|
||||||
/* If you've gotten to the end of the line (received
|
|
||||||
* a newline character) and the line is blank, the http
|
|
||||||
* request has ended, so you can send a reply. */
|
|
||||||
if (c == '\n' && current_line_is_blank)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (c == '\n') {
|
|
||||||
/* You're starting a new line. */
|
|
||||||
current_line_is_blank = 1;
|
|
||||||
}
|
|
||||||
else if (c != '\r') {
|
|
||||||
/* You've gotten a character on the current line. */
|
|
||||||
current_line_is_blank = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Send a standard http response header. */
|
|
||||||
client_puts (client, "HTTP/1.1 200 OK\n");
|
|
||||||
client_puts (client, "Content-Type: text/html\n\n");
|
|
||||||
|
|
||||||
/* Output the value of each digital pin. */
|
|
||||||
fd = open ("/dev/porta", O_RDONLY);
|
|
||||||
if (fd < 0) {
|
|
||||||
client_puts (client, "Failed to open /dev/porta\n");
|
|
||||||
} else {
|
|
||||||
for (pnum = 0; pnum < 6; pnum++) {
|
|
||||||
value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0);
|
|
||||||
sprintf (buf, "PORT%c = 0x%04x <br />\n", pnum+'A', value);
|
|
||||||
client_puts (client, buf);
|
|
||||||
}
|
|
||||||
close (fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Give the web browser time to receive the data. */
|
|
||||||
usleep (1000);
|
|
||||||
|
|
||||||
/* Close the connection. */
|
|
||||||
client_stop (client);
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
CC = cc
|
|
||||||
PROG = hello primelist primesum test1 test2 test3 gpio adc rain \
|
|
||||||
q8
|
|
||||||
|
|
||||||
all: $(PROG)
|
|
||||||
|
|
||||||
hello: hello.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) hello.c
|
|
||||||
|
|
||||||
primelist: primelist.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primelist.c
|
|
||||||
|
|
||||||
primesum: primesum.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) primesum.c
|
|
||||||
|
|
||||||
gpio: gpio.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) gpio.c
|
|
||||||
|
|
||||||
adc: adc.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) adc.c
|
|
||||||
|
|
||||||
rain: rain.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) rain.c
|
|
||||||
|
|
||||||
q8: q8.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) q8.c
|
|
||||||
|
|
||||||
test1: test1.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test1.c
|
|
||||||
|
|
||||||
test2: test2.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test2.c
|
|
||||||
|
|
||||||
test3: test3.c
|
|
||||||
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) test3.c
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *.o $(PROG)
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of reading ADC data.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
char buf[100];
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int i, fd, value;
|
|
||||||
|
|
||||||
for (i=0; i<16; i++) {
|
|
||||||
sprintf(buf, "/dev/adc%d", i);
|
|
||||||
fd = open(buf, O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
printf("Error: unable to open %s\n", buf);
|
|
||||||
} else {
|
|
||||||
if (read(fd, buf, 20) > 0) {
|
|
||||||
value = strtol (buf, 0, 0);
|
|
||||||
printf("adc%-2d = %d\n", i, value);
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of polling general purpose i/o pins.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/gpio.h>
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int fd, pnum, value;
|
|
||||||
|
|
||||||
fd = open ("/dev/porta", O_RDWR);
|
|
||||||
if (fd < 0) {
|
|
||||||
perror ("/dev/porta");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (pnum=0; pnum<7; pnum++) {
|
|
||||||
value = ioctl (fd, GPIO_POLL | GPIO_PORT (pnum), 0);
|
|
||||||
if (value < 0)
|
|
||||||
perror ("GPIO_POLL");
|
|
||||||
printf ("port%c = 0x%04x\n", pnum + 'A', value);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
printf("Hello, Smaller C World!\n");
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Print the list of prime numbers up to 100.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int isprime(int);
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
for (n=2; n<100; ++n) {
|
|
||||||
if (isprime(n)) {
|
|
||||||
printf("%d ", n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int isprime(int n)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (n == 2)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (n % 2 == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (j=3; j*j<=n; j+=2)
|
|
||||||
if (n % j == 0)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Compute the sum of prime numbers up to 10000.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int isprime(int);
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int sum, n;
|
|
||||||
|
|
||||||
sum = 0;
|
|
||||||
for (n=2; n<10000; ++n) {
|
|
||||||
if (isprime(n)) {
|
|
||||||
sum += n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
printf("Sum of primes less than 10000: %d\n", sum);
|
|
||||||
}
|
|
||||||
|
|
||||||
int isprime(int n)
|
|
||||||
{
|
|
||||||
int j;
|
|
||||||
|
|
||||||
if (n == 2)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (n % 2 == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (j=3; j*j<=n; j+=2)
|
|
||||||
if (n % j == 0)
|
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
/*
|
|
||||||
* Eight Queens puzzle
|
|
||||||
*
|
|
||||||
* (C) 2010 by Mark Sproul
|
|
||||||
* Open source as per standard Arduino code
|
|
||||||
* Modified by Pito 12/2012 for SmallC and then by Alexey Frunze for Smaller C
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
|
|
||||||
unsigned int gChessBoard[8];
|
|
||||||
unsigned int gLoopCounter;
|
|
||||||
int gValidCount;
|
|
||||||
|
|
||||||
int CheckCurrentBoard(void)
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int jj;
|
|
||||||
int theRow;
|
|
||||||
int theLongRow;
|
|
||||||
int theLongColumns;
|
|
||||||
int bitCount;
|
|
||||||
|
|
||||||
//* we know we have 1 in each row,
|
|
||||||
//* Check for 1 in each column
|
|
||||||
theRow = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow |= gChessBoard[ii];
|
|
||||||
}
|
|
||||||
if (theRow != 0x0ff) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* we have 1 in each column, now check the diagonals
|
|
||||||
theLongColumns = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theLongRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theLongRow = theLongRow << ii;
|
|
||||||
|
|
||||||
theLongColumns |= theLongRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* now count the bits
|
|
||||||
bitCount = 0;
|
|
||||||
for (ii=0; ii<16; ii++) {
|
|
||||||
if ((theLongColumns & 0x01) == 0x01) {
|
|
||||||
bitCount++;
|
|
||||||
}
|
|
||||||
theLongColumns = theLongColumns >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitCount != 8) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* we now have to check the other diagonal
|
|
||||||
theLongColumns = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theLongRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theLongRow = theLongRow << 8;
|
|
||||||
theLongRow = theLongRow >> ii;
|
|
||||||
|
|
||||||
theLongColumns |= theLongRow;
|
|
||||||
}
|
|
||||||
|
|
||||||
//* now count the bits
|
|
||||||
bitCount = 0;
|
|
||||||
for (ii=0; ii<16; ii++) {
|
|
||||||
if ((theLongColumns & 0x01) == 0x01) {
|
|
||||||
bitCount++;
|
|
||||||
}
|
|
||||||
theLongColumns = theLongColumns >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitCount != 8) {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CheckForDone(void)
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int weAreDone;
|
|
||||||
int theRow;
|
|
||||||
|
|
||||||
weAreDone = FALSE;
|
|
||||||
|
|
||||||
//* we know we have 1 in each row,
|
|
||||||
//* Check for 1 in each column
|
|
||||||
theRow = 0;
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow |= gChessBoard[ii];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theRow == 0x01) {
|
|
||||||
weAreDone = TRUE;
|
|
||||||
}
|
|
||||||
return weAreDone;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RotateQueens(void)
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int keepGoing;
|
|
||||||
int theRow;
|
|
||||||
|
|
||||||
ii = 0;
|
|
||||||
keepGoing = TRUE;
|
|
||||||
while (keepGoing && (ii < 8)) {
|
|
||||||
theRow = gChessBoard[ii] & 0x0ff;
|
|
||||||
theRow = (theRow >> 1) & 0x0ff;
|
|
||||||
if (theRow != 0) {
|
|
||||||
gChessBoard[ii] = theRow;
|
|
||||||
keepGoing = FALSE;
|
|
||||||
} else {
|
|
||||||
gChessBoard[ii] = 0x080;
|
|
||||||
}
|
|
||||||
ii++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintChessBoard(void)
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
int jj;
|
|
||||||
int theRow;
|
|
||||||
char textString[32];
|
|
||||||
|
|
||||||
printf("\nLoop= %d\n", gLoopCounter);
|
|
||||||
printf("Solution count= %d\n", gValidCount);
|
|
||||||
|
|
||||||
printf("+----------------+\n");
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
theRow = gChessBoard[ii];
|
|
||||||
|
|
||||||
printf("|");
|
|
||||||
for (jj=0; jj<8; jj++) {
|
|
||||||
if (theRow & 0x080) {
|
|
||||||
printf("Q ");
|
|
||||||
} else {
|
|
||||||
printf(". ");
|
|
||||||
}
|
|
||||||
theRow = theRow << 1;
|
|
||||||
}
|
|
||||||
printf("|\n");
|
|
||||||
}
|
|
||||||
printf("+----------------+\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int ii;
|
|
||||||
|
|
||||||
printf("\nEight Queens brute force");
|
|
||||||
printf("\n************************\n");
|
|
||||||
//* put the 8 queens on the board, 1 in each row
|
|
||||||
for (ii=0; ii<8; ii++) {
|
|
||||||
gChessBoard[ii] = 0x080;
|
|
||||||
}
|
|
||||||
PrintChessBoard();
|
|
||||||
|
|
||||||
gLoopCounter = 0;
|
|
||||||
gValidCount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
gLoopCounter++;
|
|
||||||
|
|
||||||
if (CheckCurrentBoard()) {
|
|
||||||
gValidCount++;
|
|
||||||
PrintChessBoard();
|
|
||||||
} else if ((gLoopCounter % 1000) == 0) {
|
|
||||||
//PrintChessBoard();
|
|
||||||
}
|
|
||||||
|
|
||||||
RotateQueens();
|
|
||||||
if (CheckForDone()) {
|
|
||||||
//int elapsedSeconds;
|
|
||||||
//int elapsedMinutes;
|
|
||||||
//int elapsedHours;
|
|
||||||
|
|
||||||
//elapsedSeconds = millis() / 1000;
|
|
||||||
//elapsedMinutes = elapsedSeconds / 60;
|
|
||||||
//elapsedHours = elapsedMinutes / 60;
|
|
||||||
|
|
||||||
printf("----------------------------------\n");
|
|
||||||
printf("All done\n");
|
|
||||||
|
|
||||||
PrintChessBoard();
|
|
||||||
printf("----------------------------------\n");
|
|
||||||
|
|
||||||
//Serial.print("total seconds=");
|
|
||||||
//Serial.println(elapsedSeconds);
|
|
||||||
|
|
||||||
//Serial.print("hours=");
|
|
||||||
//Serial.println(elapsedHours);
|
|
||||||
|
|
||||||
//Serial.print("minutes=");
|
|
||||||
//Serial.println(elapsedMinutes % 60);
|
|
||||||
|
|
||||||
//Serial.print("seconds=");
|
|
||||||
//Serial.println(elapsedSeconds % 60);
|
|
||||||
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
* Example of using termcap library for SmallC.
|
|
||||||
* 11/3/1980 EPS/CITHEP
|
|
||||||
*
|
|
||||||
* Copyright (c) 1980 Regents of the University of California.
|
|
||||||
* All rights reserved. The Berkeley software License Agreement
|
|
||||||
* specifies the terms and conditions for redistribution.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#define CO 80 /* number of columns */
|
|
||||||
#define LI 24 /* number of lines */
|
|
||||||
|
|
||||||
#define CL "\33[H\33[J" /* clear the screen */
|
|
||||||
#define CM "\33[%u;%uH" /* move the cursor to row, column */
|
|
||||||
#define BC "\b" /* move cursor left */
|
|
||||||
#define DN "\33[B" /* move cursor down */
|
|
||||||
#define ND " " /* move cursor right */
|
|
||||||
|
|
||||||
int xpos[5], ypos[5];
|
|
||||||
char outbuf[BUFSIZ];
|
|
||||||
|
|
||||||
void moveto(int col, int row)
|
|
||||||
{
|
|
||||||
printf(CM, row, col);
|
|
||||||
}
|
|
||||||
|
|
||||||
void onsig(int n)
|
|
||||||
{
|
|
||||||
moveto(0, LI - 1);
|
|
||||||
fflush(stdout);
|
|
||||||
_exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int x, y, j;
|
|
||||||
|
|
||||||
setbuf(stdout, outbuf);
|
|
||||||
for (j = SIGHUP; j <= SIGTERM; j++)
|
|
||||||
if (signal(j, SIG_IGN) != SIG_IGN)
|
|
||||||
signal(j, onsig);
|
|
||||||
|
|
||||||
fputs(CL, stdout);
|
|
||||||
fflush(stdout);
|
|
||||||
for (j = 5; --j >= 0; ) {
|
|
||||||
xpos[j] = 2 + rand() % (CO - 4);
|
|
||||||
ypos[j] = 2 + rand() % (LI - 4);
|
|
||||||
}
|
|
||||||
for (j = 0; ; ) {
|
|
||||||
x = 2 + rand() % (CO - 4);
|
|
||||||
y = 2 + rand() % (LI - 4);
|
|
||||||
moveto(x, y);
|
|
||||||
putchar('.');
|
|
||||||
moveto(xpos[j], ypos[j]);
|
|
||||||
putchar('o');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]);
|
|
||||||
putchar('O');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-1);
|
|
||||||
putchar('-');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs("|.|", stdout);
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar('-');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-2);
|
|
||||||
putchar('-');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs("/ \\", stdout);
|
|
||||||
moveto(xpos[j]-2, ypos[j]);
|
|
||||||
fputs("| O |", stdout);
|
|
||||||
moveto(xpos[j]-1, ypos[j]+1);
|
|
||||||
fputs("\\ /", stdout);
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar('-');
|
|
||||||
if (j == 0)
|
|
||||||
j = 4;
|
|
||||||
else
|
|
||||||
--j;
|
|
||||||
moveto(xpos[j], ypos[j]-2);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
moveto(xpos[j]-2, ypos[j]);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
moveto(xpos[j]-1, ypos[j]+1);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(ND, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
fputs(DN, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
fputs(BC, stdout);
|
|
||||||
putchar(' ');
|
|
||||||
xpos[j] = x;
|
|
||||||
ypos[j] = y;
|
|
||||||
fflush(stdout);
|
|
||||||
usleep(100000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int ga[5];
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int a, b, c, d;
|
|
||||||
int arr[5];
|
|
||||||
int *pi;
|
|
||||||
char arrc[5];
|
|
||||||
char *pic;
|
|
||||||
int s1, s2;
|
|
||||||
int z;
|
|
||||||
int t;
|
|
||||||
int *pip;
|
|
||||||
int *picp;
|
|
||||||
int e1, e2;
|
|
||||||
|
|
||||||
ga[0] = 10;
|
|
||||||
ga[1] = 20;
|
|
||||||
ga[2] = 30;
|
|
||||||
ga[3] = 40;
|
|
||||||
ga[4] = 50;
|
|
||||||
|
|
||||||
a = 21;
|
|
||||||
b = 31;
|
|
||||||
c = 71;
|
|
||||||
d = 82;
|
|
||||||
|
|
||||||
arr[0] = 10;
|
|
||||||
arr[1] = 20;
|
|
||||||
arr[2] = 30;
|
|
||||||
arr[3] = 40;
|
|
||||||
arr[4] = 50;
|
|
||||||
pi = &arr[0];
|
|
||||||
|
|
||||||
arrc[0] = 13;
|
|
||||||
arrc[1] = 23;
|
|
||||||
arrc[2] = 33;
|
|
||||||
arrc[3] = 43;
|
|
||||||
arrc[4] = 53;
|
|
||||||
pic = &arrc[0];
|
|
||||||
|
|
||||||
printf(" 21 + 31 = %d (52)\n", a + b);
|
|
||||||
printf(" 21 - 31 = %d (-10)\n", a - b);
|
|
||||||
printf(" 21 & 71 = %d (5)\n", a & c);
|
|
||||||
printf(" 21 | 82 = %d (87)\n", a | d);
|
|
||||||
printf(" 21 ^ 82 = %d (71)\n", a ^ d);
|
|
||||||
printf(" 21 * 82 = %d (1722)\n", a * d);
|
|
||||||
printf(" 82 %% 21 = %d (19)\n", d % a);
|
|
||||||
printf(" 82 / 21 = %d (3)\n", d / a);
|
|
||||||
printf(" *pi = %d (10)\n", *pi);
|
|
||||||
printf(" *pi + 1 = %d (11)\n", *pi + 1);
|
|
||||||
printf(" *(pi + 1) = %d (20)\n", *(pi + 1));
|
|
||||||
printf("&arr[3] - &arr[0] = %d (3)\n", &arr[3] - &arr[0]);
|
|
||||||
printf(" arr[3]-arr[0] = %d (30)\n", arr[3] - arr[0]);
|
|
||||||
printf(" arr[3]+arr[0] = %d (50)\n", arr[3] + arr[0]);
|
|
||||||
printf(" &ga[3] - &ga[0] = %d (3)\n", &ga[3] - &ga[0]);
|
|
||||||
printf(" ga[3]-ga[0] = %d (30)\n", ga[3] - ga[0]);
|
|
||||||
printf(" ga[3]+ga[0] = %d (50)\n", ga[3] + ga[0]);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" *pic = %d (13)\n", *pic);
|
|
||||||
printf(" *pic + 1 = %d (14)\n", *pic+1);
|
|
||||||
printf(" *(pic + 1) = %d (23)\n", *(pic+1));
|
|
||||||
printf("&arrc[3] - &arrc[0] = %d (3)\n", &arrc[3]-&arrc[0]);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
s1 = 3;
|
|
||||||
s2 = -200;
|
|
||||||
printf(" 82 << 3 = %d (656)\n", d << s1);
|
|
||||||
printf(" 82 >> 3 = %d (10)\n", d >> s1);
|
|
||||||
printf("-200 >> 3 = %d (-25)\n", s2 >> s1);
|
|
||||||
printf("-200 << 3 = %d (-1600)\n", s2 << s1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("-s1 = %d (-3)\n", -s1);
|
|
||||||
printf("-s2 = %d (200)\n", -s2);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("~82 = %d (-83)\n", ~d);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
z = 0;
|
|
||||||
printf("!82 = %d (0)\n", !d);
|
|
||||||
printf(" !0 = %d (1)\n", !z);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" 0 && 0 = %d (0)\n", z && z);
|
|
||||||
printf(" 0 && 21 = %d (0)\n", z && a);
|
|
||||||
printf(" 3 && 21 = %d (1)\n", s1 && a);
|
|
||||||
printf("21 && 3 = %d (1)\n", a && s1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" 0 || 0 = %d (0)\n", z || z);
|
|
||||||
printf(" 0 || 21 = %d (1)\n", z || a);
|
|
||||||
printf(" 3 || 21 = %d (1)\n", s1 || a);
|
|
||||||
printf("21 || 3 = %d (1)\n", a || s1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = 4;
|
|
||||||
printf("pi++ = %d (4)\n", pi++);
|
|
||||||
printf(" pi = %d (8)\n", pi);
|
|
||||||
printf("++pi = %d (12)\n", ++pi);
|
|
||||||
printf("pi-- = %d (12)\n", pi--);
|
|
||||||
printf(" pi = %d (8)\n", pi);
|
|
||||||
printf("--pi = %d (4)\n", --pi);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pic = 4;
|
|
||||||
printf("pic++ = %d (4)\n", pic++);
|
|
||||||
printf(" pic = %d (5)\n", pic);
|
|
||||||
printf("++pic = %d (6)\n", ++pic);
|
|
||||||
printf("pic-- = %d (6)\n", pic--);
|
|
||||||
printf(" pic = %d (5)\n", pic);
|
|
||||||
printf("--pic = %d (4)\n", --pic);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf("t++ = %d (4)\n", t++);
|
|
||||||
printf(" t = %d (5)\n", t);
|
|
||||||
printf("++t = %d (6)\n", ++t);
|
|
||||||
printf("t-- = %d (6)\n", t--);
|
|
||||||
printf(" t = %d (5)\n", t);
|
|
||||||
printf("--t = %d (4)\n", --t);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t==4 = %d (1)\n", t == 4);
|
|
||||||
printf(" t==3 = %d (0)\n", t == 3);
|
|
||||||
printf(" t==5 = %d (0)\n", t == 5);
|
|
||||||
t = -4;
|
|
||||||
printf("t==-4 = %d (1)\n", t == -4);
|
|
||||||
printf("t==-3 = %d (0)\n", t == -3);
|
|
||||||
printf("t==-5 = %d (0)\n", t == -5);
|
|
||||||
printf(" t==4 = %d (0)\n", t == 4);
|
|
||||||
printf(" t==3 = %d (0)\n", t == 3);
|
|
||||||
printf(" t==5 = %d (0)\n", t == 5);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t!=4 = %d (0)\n", t != 4);
|
|
||||||
printf(" t!=3 = %d (1)\n", t != 3);
|
|
||||||
printf(" t!=5 = %d (1)\n", t != 5);
|
|
||||||
t = -4;
|
|
||||||
printf("t!=-4 = %d (0)\n", t != -4);
|
|
||||||
printf("t!=-3 = %d (1)\n", t != -3);
|
|
||||||
printf("t!=-5 = %d (1)\n", t != -5);
|
|
||||||
printf(" t!=4 = %d (1)\n", t != 4);
|
|
||||||
printf(" t!=3 = %d (1)\n", t != 3);
|
|
||||||
printf(" t!=5 = %d (1)\n", t != 5);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t<4 = %d (0)\n", t < 4);
|
|
||||||
printf(" t<3 = %d (0)\n", t < 3);
|
|
||||||
printf(" t<5 = %d (1)\n", t < 5);
|
|
||||||
printf("t<-1 = %d (0)\n", t < -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" t<=4 = %d (1)\n", t <= 4);
|
|
||||||
printf(" t<=3 = %d (0)\n", t <= 3);
|
|
||||||
printf(" t<=5 = %d (1)\n", t <= 5);
|
|
||||||
printf("t<=-1 = %d (0)\n", t <= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf(" t>4 = %d (0)\n", t > 4);
|
|
||||||
printf(" t>3 = %d (1)\n", t > 3);
|
|
||||||
printf(" t>5 = %d (0)\n", t > 5);
|
|
||||||
printf("t>-1 = %d (1)\n", t > -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" t>=4 = %d (1)\n", t >= 4);
|
|
||||||
printf(" t>=3 = %d (1)\n", t >= 3);
|
|
||||||
printf(" t>=5 = %d (0)\n", t >= 5);
|
|
||||||
printf("t>=-1 = %d (1)\n", t >= -1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = -100;
|
|
||||||
printf(" pi<4 = %d (0)\n", pi < (int*)4);
|
|
||||||
printf(" pi<3 = %d (0)\n", pi < (int*)3);
|
|
||||||
printf("pi<-100 = %d (0)\n", pi < (int*)-100);
|
|
||||||
printf(" pi<-1 = %d (1)\n", pi < (int*)-1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" pi<=4 = %d (0)\n", pi <= (int*)4);
|
|
||||||
printf(" pi<=3 = %d (0)\n", pi <= (int*)3);
|
|
||||||
printf("pi<=-100 = %d (1)\n", pi <= (int*)-100);
|
|
||||||
printf(" pi<=-1 = %d (1)\n", pi <= (int*)-1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = -100;
|
|
||||||
printf(" pi>4 = %d (1)\n", pi > (int*)4);
|
|
||||||
printf(" pi>3 = %d (1)\n", pi > (int*)3);
|
|
||||||
printf("pi>-100 = %d (0)\n", pi > (int*)-100);
|
|
||||||
printf(" pi>-1 = %d (0)\n", pi > (int*)-1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf(" pi>=4 = %d (1)\n", pi >= (int*)4);
|
|
||||||
printf(" pi>=3 = %d (1)\n", pi >= (int*)3);
|
|
||||||
printf("pi>=-100 = %d (1)\n", pi >= (int*)-100);
|
|
||||||
printf(" pi>=-1 = %d (0)\n", pi >= (int*)-1);
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
pi = &arr[0];
|
|
||||||
pip = &arr[3];
|
|
||||||
printf(" *pip - *pi: %d (30)\n", *pip - *pi);
|
|
||||||
printf(" pip - pi: %d (3)\n", pip - pi);
|
|
||||||
printf(" *pip: %d (40)\n", *pip);
|
|
||||||
printf(" *(pip - 3): %d (10)\n", *(pip - 3));
|
|
||||||
printf(" *&arr[3]: %d (40)\n", *&arr[3]);
|
|
||||||
printf("*(&arr[3] - 3): %d (10)\n", *(&arr[3]-3));
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int aaa;
|
|
||||||
int bbb;
|
|
||||||
int ccc;
|
|
||||||
char gc;
|
|
||||||
char gbuffer[3];
|
|
||||||
int gibuffer[4];
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
char b;
|
|
||||||
int la;
|
|
||||||
unsigned int u1, u2;
|
|
||||||
int s1, s2;
|
|
||||||
unsigned char uc1, uc2;
|
|
||||||
char sc1, sc2;
|
|
||||||
int fd;
|
|
||||||
char buffer[6];
|
|
||||||
int ibuffer[7];
|
|
||||||
|
|
||||||
printf(" sizeof(uc1): %d 1\n", sizeof(uc1));
|
|
||||||
printf(" sizeof(sc1): %d 1\n", sizeof(sc1));
|
|
||||||
printf(" sizeof(u1): %d 4\n", sizeof(u1));
|
|
||||||
printf(" sizeof(s1): %d 4\n", sizeof(s1));
|
|
||||||
printf(" sizeof(aaa): %d 4\n", sizeof(aaa));
|
|
||||||
printf(" sizeof(bbb): %d 4\n", sizeof(bbb));
|
|
||||||
printf(" sizeof(gc): %d 1\n", sizeof(gc));
|
|
||||||
printf(" sizeof(buffer): %d 6\n", sizeof(buffer));
|
|
||||||
printf(" sizeof(ibuffer): %d 28\n", sizeof(ibuffer));
|
|
||||||
printf(" sizeof(char): %d 1\n", sizeof(char));
|
|
||||||
printf(" sizeof(int): %d 4\n", sizeof(int));
|
|
||||||
printf(" sizeof(gbuffer): %d 3\n", sizeof(gbuffer));
|
|
||||||
printf(" sizeof(gibuffer): %d 16\n", sizeof(gibuffer));
|
|
||||||
// sizeof(ibuffer[0]) is not supported, so the following can be used...
|
|
||||||
printf("sizeof(ibuffer)/sizeof(int): %d 7\n", sizeof(ibuffer)/sizeof(int));
|
|
||||||
|
|
||||||
aaa = 1;
|
|
||||||
bbb = 2;
|
|
||||||
la = 4;
|
|
||||||
printf("%d 1\n", aaa);
|
|
||||||
printf("%d 2\n", bbb);
|
|
||||||
printf("%d 4\n", la);
|
|
||||||
|
|
||||||
uc1 = 0x80;
|
|
||||||
sc1 = 0x80;
|
|
||||||
s1 = uc1;
|
|
||||||
s2 = sc1;
|
|
||||||
printf("unsigned char (0x80) -> int: %d 128\n", s1);
|
|
||||||
printf(" signed char (0x80) -> int: %d -128\n", s2);
|
|
||||||
|
|
||||||
u1 = uc1;
|
|
||||||
u2 = sc1;
|
|
||||||
printf("unsigned char (0x80) -> unsigned: %d 128\n", u1);
|
|
||||||
printf(" signed char (0x80) -> unsigned: %d -128\n", u2);
|
|
||||||
|
|
||||||
la = errno;
|
|
||||||
printf("errno: %d 0\n", la);
|
|
||||||
|
|
||||||
write(1, "abcd ", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("errno after good write call: %d 0\n", la);
|
|
||||||
|
|
||||||
write(10, "abcde", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("errno after bad write call: %d 9\n", la);
|
|
||||||
|
|
||||||
write(1, "abcd ", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("good write after failed should not overwrite errno: %d 9\n", la);
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
write(1, "abcd ", 5);
|
|
||||||
la = errno;
|
|
||||||
printf("good write after errno set to zero: %d 0\n", la);
|
|
||||||
|
|
||||||
la = write(1, "abcd ", 5);
|
|
||||||
printf("write() return: %d 5\n", la);
|
|
||||||
|
|
||||||
la = write(10, "abcd ", 5);
|
|
||||||
printf("write(bad fd) return: %d -1\n", la);
|
|
||||||
|
|
||||||
fd = open("/a.txt", O_WRONLY | O_CREAT, 0666);
|
|
||||||
if (fd != -1) {
|
|
||||||
printf("open success\n");
|
|
||||||
la = write(fd, "abcd\n", 5);
|
|
||||||
if (la == 5) printf("write success\n"); else printf("write failed\n");
|
|
||||||
la = close(fd);
|
|
||||||
if (la != -1) printf("close success\n"); else printf("close failed\n");
|
|
||||||
} else {
|
|
||||||
printf("open failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer[0] = 0;
|
|
||||||
buffer[1] = 0;
|
|
||||||
buffer[2] = 0;
|
|
||||||
buffer[3] = 0;
|
|
||||||
buffer[4] = 0;
|
|
||||||
buffer[5] = 0;
|
|
||||||
|
|
||||||
fd = open("/a.txt", O_RDONLY, 0666);
|
|
||||||
if (fd != -1) {
|
|
||||||
printf("open success\n");
|
|
||||||
la = read(fd, buffer, 5);
|
|
||||||
printf(buffer);
|
|
||||||
if (la == 5) printf("read success\n"); else printf("read failed\n");
|
|
||||||
la = close(fd);
|
|
||||||
if (la != -1) printf("close success\n"); else printf("close failed\n");
|
|
||||||
} else {
|
|
||||||
printf("open failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buffer[0] != 'a') printf("data0 readback from file MISMATCH\n");
|
|
||||||
if (buffer[1] != 'b') printf("data1 readback from file MISMATCH\n");
|
|
||||||
if (buffer[2] != 'c') printf("data2 readback from file MISMATCH\n");
|
|
||||||
if (buffer[3] != 'd') printf("data3 readback from file MISMATCH\n");
|
|
||||||
if (buffer[4] != '\n') printf("data4 readback from file MISMATCH\n");
|
|
||||||
|
|
||||||
if (buffer[0] != 'a' || buffer[1] != 'b' || buffer[2] != 'c' ||
|
|
||||||
buffer[3] != 'd' || buffer[4] != '\n') {
|
|
||||||
printf("data readback from file MISMATCH\n");
|
|
||||||
} else {
|
|
||||||
printf("data readback from file OK\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void printt(int t, char* str);
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
int t;
|
|
||||||
|
|
||||||
t = 0;
|
|
||||||
if (t) printt(t, "failure"); else printt(t, "success");
|
|
||||||
t = 1;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
t = 8;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
t = -2;
|
|
||||||
if (t) printt(t, "success"); else printt(t, "failure");
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
t = 4;
|
|
||||||
printf("switch test: ");
|
|
||||||
switch (t) {
|
|
||||||
case 3:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
printf("success");
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
|
|
||||||
printf("switch fallthrough test: ");
|
|
||||||
switch (t) {
|
|
||||||
case 3:
|
|
||||||
printf("failure");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
printf("OKSOFAR: ");
|
|
||||||
case 5:
|
|
||||||
printf("success if oksofar printed before this in caps");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void printt(int t, char* str)
|
|
||||||
{
|
|
||||||
printf("bool test on value %d %s\n", t, str);
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ include $(TOPSRC)/target.mk
|
|||||||
# Programs that live in subdirectories, and have makefiles of their own.
|
# Programs that live in subdirectories, and have makefiles of their own.
|
||||||
#
|
#
|
||||||
SUBDIR = startup-$(MACHINE) libc libm libutil libtermlib libcurses \
|
SUBDIR = startup-$(MACHINE) libc libm libutil libtermlib libcurses \
|
||||||
libvmf libwiznet share cmd games man
|
libvmf libwiznet share cmd games
|
||||||
|
|
||||||
all: $(SUBDIR)
|
all: $(SUBDIR)
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ FRC:
|
|||||||
install: elf32-mips.ld
|
install: elf32-mips.ld
|
||||||
-for i in $(SUBDIR); do \
|
-for i in $(SUBDIR); do \
|
||||||
$(MAKE) -C $$i DESTDIR=$(DESTDIR) all install; done
|
$(MAKE) -C $$i DESTDIR=$(DESTDIR) all install; done
|
||||||
# cp -p elf32-mips.ld $(DESTDIR)/lib/elf32-mips.ld
|
cp -p elf32-mips.ld $(DESTDIR)/lib/elf32-mips.ld
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f a.out core *.s *.o *.a *~
|
rm -f a.out core *.s *.o *.a *~
|
||||||
|
|||||||
72
src/cmd/.gitignore
vendored
72
src/cmd/.gitignore
vendored
@@ -1,72 +0,0 @@
|
|||||||
basename
|
|
||||||
bc
|
|
||||||
cal
|
|
||||||
cat
|
|
||||||
cb
|
|
||||||
chgrp
|
|
||||||
chmod
|
|
||||||
cmp
|
|
||||||
col
|
|
||||||
comm
|
|
||||||
cp
|
|
||||||
dd
|
|
||||||
df
|
|
||||||
diskspeed
|
|
||||||
du
|
|
||||||
echo
|
|
||||||
ed
|
|
||||||
egrep
|
|
||||||
expr
|
|
||||||
expr.c
|
|
||||||
false
|
|
||||||
fgrep
|
|
||||||
file
|
|
||||||
grep
|
|
||||||
head
|
|
||||||
hostid
|
|
||||||
iostat
|
|
||||||
join
|
|
||||||
kill
|
|
||||||
last
|
|
||||||
ln
|
|
||||||
mail
|
|
||||||
mesg
|
|
||||||
mkdir
|
|
||||||
mv
|
|
||||||
nice
|
|
||||||
nohup
|
|
||||||
od
|
|
||||||
pagesize
|
|
||||||
pr
|
|
||||||
printenv
|
|
||||||
ps
|
|
||||||
pwd
|
|
||||||
rev
|
|
||||||
rm
|
|
||||||
rmail
|
|
||||||
rmdir
|
|
||||||
size
|
|
||||||
sleep
|
|
||||||
sort
|
|
||||||
split
|
|
||||||
strip
|
|
||||||
su
|
|
||||||
sum
|
|
||||||
sync
|
|
||||||
tail
|
|
||||||
tar
|
|
||||||
tee
|
|
||||||
time
|
|
||||||
touch
|
|
||||||
tr
|
|
||||||
true
|
|
||||||
tsort
|
|
||||||
tty
|
|
||||||
uniq
|
|
||||||
vmstat
|
|
||||||
w
|
|
||||||
wall
|
|
||||||
wc
|
|
||||||
whereis
|
|
||||||
who
|
|
||||||
write
|
|
||||||
@@ -10,14 +10,13 @@ CFLAGS += -Werror
|
|||||||
|
|
||||||
# Programs that live in subdirectories, and have makefiles of their own.
|
# Programs that live in subdirectories, and have makefiles of their own.
|
||||||
# /bin
|
# /bin
|
||||||
SUBDIR = adb adc-demo aout ar as awk basic cc chflags chpass \
|
SUBDIR = adb adc-demo ar as awk basic cc chflags chpass \
|
||||||
cpp dc diff emg env fdisk find forth fstat glcdtest \
|
cpp dc diff env find forth fstat glcdtest hostname \
|
||||||
hostname id la lcc lcpp ld ls login make man med \
|
id la lcc lcpp ld ls login make man med \
|
||||||
more nm passwd picoc portio printf pwm \
|
more nm passwd picoc portio printf pwm \
|
||||||
rdprof ranlib re renice retroforth scm setty sl \
|
ranlib re renice retroforth scm setty sl \
|
||||||
sed sh smallc smlrc stty sysctl test uname wiznet xargs \
|
sed sh smallc stty sysctl test uname wiznet xargs \
|
||||||
zmodem gtest msec unixbench cron compress date2 tip \
|
zmodem gtest
|
||||||
talloc devupdate uucp smux
|
|
||||||
|
|
||||||
# /sbin
|
# /sbin
|
||||||
SUBDIR += chown chroot disktool fsck getty init \
|
SUBDIR += chown chroot disktool fsck getty init \
|
||||||
@@ -33,11 +32,11 @@ SCRIPT = false nohup true #lorder mkdep
|
|||||||
# C programs that live in the current directory and do not need
|
# C programs that live in the current directory and do not need
|
||||||
# explicit make lines.
|
# explicit make lines.
|
||||||
#
|
#
|
||||||
STD = basename cal cat cb chgrp chmod cmp col comm cp dd \
|
STD = basename cal cat cb chgrp chmod cmp col comm cp date dd du \
|
||||||
diskspeed du echo ed fgrep file grep head hostid join \
|
echo ed fgrep file grep head hostid join kill last ln \
|
||||||
kill last ln mesg mkdir mv nice od pagesize pr printenv \
|
mesg mkdir mv nice od pagesize pr printenv pwd rev rm rmail rmdir \
|
||||||
pwd rev rm rmail rmdir size sleep sort split sum sync \
|
size sleep sort split sum sync tail tar tee time touch tr \
|
||||||
tail tar tee time touch tr tsort tty uniq w wc whereis who
|
tsort tty uniq w wc whereis who
|
||||||
|
|
||||||
# C programs that live in the current directory and need explicit make lines.
|
# C programs that live in the current directory and need explicit make lines.
|
||||||
#
|
#
|
||||||
|
|||||||
1
src/cmd/adb/.gitignore
vendored
1
src/cmd/adb/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
adb
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
TOPSRC = $(shell cd ../../..; pwd)
|
TOPSRC = $(shell cd ../../..; pwd)
|
||||||
include $(TOPSRC)/target.mk
|
include $(TOPSRC)/target.mk
|
||||||
#include $(TOPSRC)/cross.mk
|
#include $(TOPSRC)/cross.mk
|
||||||
#CFLAGS = -DCROSS -I$(TOPSRC)/include -I/usr/include -D__mips__ -ggdb3
|
|
||||||
|
|
||||||
OBJS = message.o access.o command.o expr.o findfn.o format.o input.o \
|
OBJS = message.o access.o command.o expr.o findfn.o format.o input.o \
|
||||||
main.o opset.o output.o pcs.o print.o \
|
main.o opset.o output.o pcs.o print.o \
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
* File handling and access routines
|
* File handling and access routines
|
||||||
*/
|
*/
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
within(adr, lbd, ubd)
|
within(adr, lbd, ubd)
|
||||||
@@ -60,7 +59,7 @@ acces(mode, adr, space, value)
|
|||||||
long adr;
|
long adr;
|
||||||
{
|
{
|
||||||
int w, w1, pmode, rd, file;
|
int w, w1, pmode, rd, file;
|
||||||
BKPTR bkptr;
|
BKPTR bkptr, scanbkpt();
|
||||||
|
|
||||||
if (space == NSP)
|
if (space == NSP)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -90,7 +89,7 @@ acces(mode, adr, space, value)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
w = 0;
|
w = 0;
|
||||||
if (mode==WT && wtflag==O_RDONLY) {
|
if (mode==WT && wtflag==0) {
|
||||||
error("not in write mode");
|
error("not in write mode");
|
||||||
}
|
}
|
||||||
if (! chkmap(&adr, space))
|
if (! chkmap(&adr, space))
|
||||||
|
|||||||
@@ -190,8 +190,7 @@ trypr:
|
|||||||
regptr = getreg(savc);
|
regptr = getreg(savc);
|
||||||
if (regptr != NOREG) {
|
if (regptr != NOREG) {
|
||||||
uframe[regptr] = shorten(dot);
|
uframe[regptr] = shorten(dot);
|
||||||
ptrace(PT_WRITE_U, pid, (char*) (KERNEL_DATA_END - USIZE) +
|
ptrace(PT_WRITE_U, pid, &uframe[regptr] - (int)&corhdr,
|
||||||
((char*)&uframe[regptr] - (char*)&corhdr),
|
|
||||||
uframe[regptr]);
|
uframe[regptr]);
|
||||||
} else if ((modifier = varchk(savc)) != -1) {
|
} else if ((modifier = varchk(savc)) != -1) {
|
||||||
var[modifier] = dot;
|
var[modifier] = dot;
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
TOPSRC = $(shell cd ../../../..; pwd)
|
|
||||||
include $(TOPSRC)/cross.mk
|
|
||||||
|
|
||||||
vpath %.c ..
|
|
||||||
|
|
||||||
# Build a list of the host include directories.
|
|
||||||
CPP = $(shell gcc -print-prog-name=cc1)
|
|
||||||
HOSTINC = $(addprefix -I,$(shell echo | $(CPP) -v 2>&1 | grep '^ /.*include'))
|
|
||||||
HOSTINC += -I/usr/include/i386-linux-gnu
|
|
||||||
|
|
||||||
CFLAGS = -m32 -g -DCROSS -nostdinc -I. $(HOSTINC) -I.. -D__mips__
|
|
||||||
CFLAGS += -Wall -Werror -DNUM_SYMS_CACHE=50 -fno-builtin
|
|
||||||
LDFLAGS += -m32 -g
|
|
||||||
|
|
||||||
OBJS = message.o access.o command.o expr.o findfn.o format.o input.o \
|
|
||||||
main.o opset.o output.o pcs.o print.o \
|
|
||||||
runpcs.o setup.o sym.o
|
|
||||||
HEADERS = a.out.h nlist.h time.h signal.h stdlib.h \
|
|
||||||
sys/exec.h sys/types.h sys/param.h sys/user.h \
|
|
||||||
sys/time.h sys/dir.h sys/resource.h sys/select.h \
|
|
||||||
sys/signal.h sys/wait.h \
|
|
||||||
machine/io.h machine/machparam.h
|
|
||||||
|
|
||||||
all: $(HEADERS) adb
|
|
||||||
|
|
||||||
adb: $(OBJS)
|
|
||||||
$(CC) $(LDFLAGS) $(OBJS) -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f *~ *.o adb *.h */*.h gccdump.s
|
|
||||||
|
|
||||||
$(HEADERS):
|
|
||||||
ln -s -f ../../../../include/a.out.h .
|
|
||||||
ln -s -f ../../../../include/nlist.h .
|
|
||||||
ln -s -f ../../../../include/time.h .
|
|
||||||
ln -s -f ../../../../include/stdlib.h .
|
|
||||||
ln -s -f sys/signal.h .
|
|
||||||
ln -s -f ../../../../../include/sys/exec.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/param.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/user.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/types.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/time.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/dir.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/resource.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/select.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/wait.h sys/
|
|
||||||
ln -s -f ../../../../../include/sys/signal.h sys/
|
|
||||||
ln -s -f ../../../../../include/machine/io.h machine/
|
|
||||||
ln -s -f ../../../../../include/machine/machparam.h machine/
|
|
||||||
|
|
||||||
test:
|
|
||||||
echo '$$q' | ./adb fsck fsck.core
|
|
||||||
@printf '\n----------------------------\n'
|
|
||||||
echo '$$m' | ./adb fsck fsck.core
|
|
||||||
@printf '\n----------------------------\n'
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user