├── .gitignore ├── CHANGES ├── COPYING ├── Makefile ├── Makefile.cfg ├── Makefile.hostdetect ├── README.md ├── example-src ├── Makefile ├── README ├── console-test.c ├── crt0.S ├── dc3.x ├── dc4.x ├── dcload-syscall.h ├── dcload-syscall.s ├── dcload-syscalls.c ├── dcload-syscalls.h └── exception-test.c ├── host-src ├── Makefile ├── misc │ ├── Makefile │ └── lzo.c └── tool │ ├── Makefile │ ├── config.h │ ├── dc-io.h │ ├── dc-tool.c │ ├── shim.c │ ├── syscalls.c │ ├── syscalls.h │ └── unlink.c ├── make-cd ├── IP.BIN └── Makefile ├── minilzo-2.10 ├── COPYING ├── Makefile ├── lzoconf.h ├── lzodefs.h ├── minilzo.c ├── minilzo.h └── testmini.c ├── target-inc ├── _ansi.h ├── _syslist.h ├── ar.h ├── assert.h ├── ctype.h ├── dirent.h ├── errno.h ├── fastmath.h ├── fcntl.h ├── grp.h ├── ieeefp.h ├── locale.h ├── machine │ ├── fastmath.h │ ├── ieeefp.h │ ├── setjmp-dj.h │ ├── setjmp.h │ ├── time.h │ └── types.h ├── malloc.h ├── math.h ├── paths.h ├── process.h ├── pwd.h ├── reent.h ├── regdef.h ├── setjmp.h ├── signal.h ├── stdio.h ├── stdlib.h ├── string.h ├── sys │ ├── _types.h │ ├── config.h │ ├── dirent.h │ ├── errno.h │ ├── fcntl.h │ ├── file.h │ ├── param.h │ ├── reent.h │ ├── resource.h │ ├── signal.h │ ├── stat-dj.h │ ├── stat.h │ ├── syscall.h │ ├── time.h │ ├── timeb.h │ ├── times.h │ ├── types.h │ ├── unistd.h │ ├── utime.h │ └── wait.h ├── termios.h ├── time.h ├── unctrl.h ├── unistd.h ├── utime.h └── utmp.h └── target-src ├── 1st_read ├── Makefile ├── disable.s └── loader.s ├── Makefile └── dcload ├── Makefile ├── asm.h ├── cdfs_redir.s ├── cdfs_syscalls.c ├── dcload-crt0.s ├── dcload.c ├── dcload.x ├── disable.s ├── exception.s ├── go.s ├── memcmp.c ├── memcpy.S ├── memmove.c ├── memset.S ├── scif.c ├── scif.h ├── syscalls.c ├── video.h └── video.s /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.bin 3 | *.lzo 4 | *.srec 5 | *.exe 6 | *.elf 7 | .DS_Store 8 | example-src/console-test 9 | example-src/exception-test 10 | target-src/dcload/dcload 11 | target-src/dcload/exception 12 | host-src/misc/lzo 13 | host-src/tool/dc-tool-ser 14 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | WHAT'S NEW IN 1.0.6 2 | 3 | * Complete redesign of the build system and compatibility improvements for 4 | various OS, including: BSD (FreeBSD), GNU/Linux (Debian/Ubuntu), macOS, 5 | MinGW/MSYS (i.e. DreamSDK), MinGW-w64/MSYS2 and Cygwin. [SiZiOUS] 6 | * Various improvements on the GDB remote debugging feature. [SiZiOUS] 7 | * Some minor fixes. [SiZiOUS] 8 | 9 | WHAT'S NEW IN 1.0.5 10 | 11 | * Some fixes. 12 | * No one ever really documented the changes from 1.0.4 to 1.0.5. 13 | 14 | WHATS NEW IN 1.0.4 15 | 16 | * added 500000 and 1500000 baud for linux systems using ftdi ft232bm 17 | (6.144mhz crystal) based usb-serial coders cables. under ms windows/cygwin 18 | with the appropriate virtual comport drivers (vcp) 19 | http://www.ftdichip.com/ftdriver.htm 20 | a typical dc-tool command line under *nix might look 21 | like this: (In this case under a linux 2.6 kernel) 22 | dc-tool -t /dev/usb/tts/0 -b 1500000 -x 23 | the usb device under linux seems to vary by version and distribution so 24 | you will have to experiment and watch the system log files if you use a 25 | usb-serial codes cable. 26 | * serial protocol for uints now forces little-endian byte order. dc-tool 27 | should work on a Mac now. 28 | * increased the compression buffer size in dc-tool from 8k to 16k - ideally 29 | I'd like to use a 64k buffer, but dcload does not have enough room for a 30 | larger decompression buffer - this helps to increase throughput at the 31 | higher bauds using a usb-serial based coders cable. 32 | * added a time-to-transfer status line to dc-tool - e.g.: 33 | 5.73 seconds to transfer 703023 bytes 34 | * now compiles under current dc toolchain: gcc-3.4.1, binutils-2.15, 35 | newlib-1.12.0 36 | * no need to burn a new dcload-serial boot cd. this version of dc-tool is 37 | compatible with dcload 1.0.3 38 | 39 | WHATS NEW IN 1.0.3 40 | 41 | * proper baudrate changing - dcload and dc-tool should always be compiled 42 | for 57600 now; use the -b option to switch to 115200 at runtime. 43 | * experimental alternate 115200 setting - doesn't work for me, so please email 44 | andrewk@napalm-x.com if it works for you (especially if it works better than 45 | the default 115200). 46 | * added O_BINARY to all open()s in dc-tool to help cygwin users 47 | * included same IP.BIN (with logo/disclaimer) as found in dcload-ip. Please 48 | use it if you distribute either cds or cd images. 49 | 50 | WHATS NEW IN 1.0.2 51 | 52 | * dc-tool supports loading elf and srec (in addition to raw bin) 53 | 54 | WHATS NEW IN 1.0.1 55 | 56 | * minor cleanup / bugfix 57 | 58 | * new disclaimer screen (in target-src/1st_read) 59 | 60 | WHATS NEW IN 1.0.0 61 | 62 | * opendir(), closedir(), readdir() syscalls added 63 | 64 | * lame cdfs redirection (-i option to dc-tool) added 65 | 66 | * -t option to dc-tool added by Florian 'Proff' Schulze 67 | 68 | * -b option to dc-tool added by The Gypsy 69 | 70 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.cfg 2 | 3 | SUBDIRS = host-src target-src example-src 4 | MAKE ?= make 5 | 6 | all: subdirs 7 | 8 | .PHONY : subdirs $(SUBDIRS) 9 | 10 | subdirs: $(SUBDIRS) 11 | 12 | $(SUBDIRS): 13 | $(MAKE) -C $@ 14 | 15 | target-src: host-src 16 | 17 | .PHONY : install 18 | install: 19 | $(MAKE) -C host-src/tool install 20 | 21 | .PHONY : clean 22 | clean: 23 | for dir in $(SUBDIRS); do \ 24 | $(MAKE) -C $$dir clean; \ 25 | done 26 | 27 | .PHONY : distclean 28 | distclean: 29 | for dir in $(SUBDIRS) ; do \ 30 | $(MAKE) -C $$dir distclean; \ 31 | done 32 | 33 | -------------------------------------------------------------------------------- /Makefile.cfg: -------------------------------------------------------------------------------- 1 | # dcload-serial Makefile Configuration 2 | 3 | # Detect the host 4 | ROOTDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) 5 | include $(ROOTDIR)/Makefile.hostdetect 6 | 7 | # Host compiler and flags 8 | HOSTCC = gcc 9 | HOSTCFLAGS = -O2 -I/usr/local/include 10 | HOSTLDFLAGS = -L/usr/local/lib 11 | 12 | ifdef MACOS 13 | ifeq ($(shell uname -m),arm64) 14 | HOSTCFLAGS = -O2 -I/opt/homebrew/include 15 | HOSTLDFLAGS = -L/opt/homebrew/lib 16 | endif 17 | endif 18 | 19 | # For MinGW/MSYS, MinGW-w64/MSYS2 and Cygwin 20 | ifdef WINDOWS 21 | HOSTCFLAGS += -D_WIN32 22 | EXECUTABLEEXTENSION = .exe 23 | endif 24 | 25 | # dc compiler prefix -- this is usually what you used for --prefix when 26 | # building your compiler. 27 | TARGETPREFIX = /opt/toolchains/dc/sh-elf 28 | 29 | # dir to install dc-tool in 30 | TOOLINSTALLDIR = /opt/toolchains/dc/bin 31 | 32 | # To build dc-tool, we need to use libelf or libbfd 33 | # By default, libelf is used, except for MinGW/MSYS which uses libbfd. 34 | # libbfd is installed using dc-chain, an utility provided with KallistiOS. 35 | 36 | # Define this if you want to use libbfd instead of libelf (which is default) 37 | WITH_BFD = 0 38 | 39 | # For MinGW/MSYS, we need to use libbfd instead of libelf 40 | ifdef MINGW 41 | WITH_BFD = 1 42 | endif 43 | 44 | # You may have to change the paths for BFDLIB and BFDINCLUDE to the correct 45 | # ones for your system. These must point to your sh-elf BFD, not the system one! 46 | # If you built your Sega Dreamcast toolchains with dc-chain, you'll have it 47 | # installed in the correct location. 48 | BFDLIB = $(TARGETPREFIX)/lib 49 | BFDINCLUDE = $(TARGETPREFIX)/include 50 | 51 | # When using libelf instead of BFD, these must point to your 52 | # libelf installation (leave empty or undefined if libelf is part of the system) 53 | ELFLIB = $(TARGETPREFIX)/lib 54 | ELFINCLUDE = $(TARGETPREFIX)/include 55 | 56 | # For macOS, libelf is here when installed through Homebrew 57 | ifdef MACOS 58 | ifeq ($(shell uname -m),arm64) 59 | ELFINCLUDE = /opt/homebrew/include/libelf 60 | else 61 | ELFINCLUDE = /usr/local/include/libelf 62 | endif 63 | endif 64 | 65 | # sh-elf-stuff 66 | # You don't need to change these 67 | TARGETCC = $(TARGETPREFIX)/bin/sh-elf-gcc 68 | TARGETCFLAGS = -O2 -ml -m4-single-only 69 | TARGETOBJCOPY = $(TARGETPREFIX)/bin/sh-elf-objcopy -R .stack 70 | TARGETLD = $(TARGETPREFIX)/bin/sh-elf-ld 71 | 72 | # set TARGETCCVER to 3 or 4, depending on your SH compiler version (gcc 3.x or gcc 4.x) 73 | # this line tries to detect the version automatically 74 | # This only matters for building the example sources. 75 | # if version > 4 then it's 4 76 | TARGETCCVER = $(shell $(TARGETCC) --version | head -1 | sed "s/.* \([[:digit:]][[:digit:]]*\)\.[[:digit:]][[:digit:]]*.*/\1/") 77 | ifeq ($(shell test $(TARGETCCVER) -gt 4; echo $$?),0) 78 | TARGETCCVER = 4 79 | endif 80 | 81 | # You generally shouldn't change this unless you are making forked 82 | # versions (or test versions) 83 | # Version numbers must be of the form x.x.x 84 | VERSION = 1.0.6 85 | 86 | # Define this if you want a standalone, statically linked, no dependency binary 87 | #STANDALONE_BINARY = 1 88 | 89 | # This is on by default for Windows (MinGW/MSYS, MinGW-w64/MSYS2 and Cygwin) 90 | ifdef WINDOWS 91 | STANDALONE_BINARY = 1 92 | endif 93 | 94 | # this is the default port for dc-tool, it can be changed on the commandline 95 | # used for *nix systems 96 | SERIALDEVICE = /dev/ttyS0 97 | # alternative setting for USB-based serial interfaces 98 | #SERIALDEVICE = /dev/ttyUSB0 99 | 100 | # macOS -- you'll need to go look in /dev to see what the actual device 101 | # name is, and depending on the device, it must be plugged into the same 102 | # port each time. 103 | #SERIALDEVICE = /dev/cu.usbserial-5B24 104 | 105 | # Windows -- it's usually COM1 106 | ifdef WINDOWS 107 | SERIALDEVICE = COM1 108 | endif 109 | 110 | # default speed for dc-tool - after initial connection is established, connection 111 | # speed will change to this value, same as using the -b argument 112 | # value must be one of 9600, 19200, 38400, 57600, 115200, 230400, 500000, or 1500000 113 | TOOL_DEFAULT_SPEED = 57600 114 | # USB-based serial devices can potentially achieve speeds of 500000 or 1500000 baud 115 | #TOOL_DEFAULT_SPEED = 500000 116 | -------------------------------------------------------------------------------- /Makefile.hostdetect: -------------------------------------------------------------------------------- 1 | # Determine on what platform we are running 2 | 3 | # This is much more simpler than using the "config.guess" mechanism, as we 4 | # don't need the full host triplet, but it will be sufficient here. 5 | 6 | # For a more complete mechanism, based on host triplet and "config.guess", 7 | # check the "dc-chain/Makefile". 8 | 9 | HOST = $(shell uname -s) 10 | 11 | # BSD 12 | ifneq ($(shell echo $(HOST) | grep -i 'BSD$$'),) 13 | BSD := 1 14 | endif 15 | 16 | # macOS 17 | ifeq ($(shell echo $(HOST)),Darwin) 18 | MACOS := 1 19 | endif 20 | 21 | # MinGW/MSYS 22 | ifeq ($(shell echo $(HOST) | cut -c-5),MINGW) 23 | # Both MinGW/MSYS legacy environment and MinGW-w64/MSYS2 environment 24 | MINGW32 := 1 25 | mingw_w64_checker = $(shell echo $$MSYSTEM_CHOST) 26 | ifneq ($(mingw_w64_checker),) 27 | # Only MinGW-w64/MSYS2 environment, both for x86 / x64 28 | MINGW64 := 1 29 | else 30 | # Only original and legacy MinGW/MSYS environment 31 | MINGW := 1 32 | endif 33 | WINDOWS := 1 34 | endif 35 | 36 | # Cygwin 37 | ifeq ($(shell echo $(HOST) | cut -c-6),CYGWIN) 38 | CYGWIN := 1 39 | WINDOWS := 1 40 | endif 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # dcload-serial 1.0.6 2 | 3 | **dcload** is a **Sega Dreamcast** (DC) serial loader written originally by 4 | [Andrew Kieschnick](http://napalm-x.thegypsy.com/andrewk/dc/), a.k.a. 5 | **ADK/Napalm**. It is currently maintained as a part of 6 | [KallistiOS](http://gamedev.allusion.net/softprj/kos/) (KOS). 7 | 8 | **dcload** is a set of programs made to send and receive data from your Sega 9 | Dreamcast system. The classic use of this tool is to send programs to the 10 | Dreamcast in order to run and debug them. To be used, you must have a way to 11 | connect your Dreamcast console to your computer, it can be one of the following: 12 | 13 | * A **Coders Cable** (a serial cable, the historical way to do that). It can be 14 | a cable with the classical `RS-232`/`DE-9` connector or with a 15 | `USB-Serial` module. 16 | * A **Broadband Adapter**, ref. `HIT-400`, often shortened as **BBA**, a 17 | `10/100Mbits` Ethernet network card. 18 | * A **LAN Adapter**, ref. `HIT-300`, a `10Mbits` Ethernet network card. 19 | 20 | If you have a Coders Cable, you have to use `dcload-serial`. For the Broadband 21 | Adapter or LAN Adapter, you have to use `dcload-ip`. 22 | 23 | **dcload** is split in two components: 24 | 25 | * `dcload`, the server part, meant to be run on the Dreamcast; 26 | * `dc-tool`, the client part, executed from your computer. 27 | 28 | ## Features 29 | 30 | * Load `elf`, `srec` and `bin` (binary transfers are compressed). 31 | * PC I/O (read, write from/to the PC). 32 | * Exception handler. 33 | * Debug Dreamcast programs remotely by using the **GDB-over-dcload** feature. 34 | 35 | ## Building 36 | 37 | 1. You should have a working 38 | [KallistiOS](http://gamedev.allusion.net/softprj/kos/) (KOS) environment and 39 | of course the `sh-elf` toolchain installed (if you have installed KOS, you 40 | already have everything ready). 41 | 2. Edit the `Makefile.cfg` file for your system and then run `make`. 42 | 43 | ## Installation 44 | 45 | ### dc-tool (client part) 46 | 47 | Run `make install`: this will install `dc-tool-ser` on your computer (default in 48 | `/opt/toolchains/dc/bin`). 49 | 50 | ### dcload (server part) 51 | 52 | For the Dreamcast part, you have two options. 53 | 54 | * Directly burn to a disc by using `cdrecord`: 55 | 1. Navigate to `make-cd`. 56 | 2. Edit the `Makefile`. 57 | 3. Insert blank CD-R. 58 | 4. Run `make`. If the `1ST_READ.BIN` file hasn't been built yet, this 59 | `Makefile` will build it. 60 | 61 | * Create a **Padus DiscJuggler** (`CDI`) image to burn later (requires 62 | the `mkisofs` and `cdi4dc` tools): 63 | 1. `make -C ./host-src/misc` (build the miniLZO binary) 64 | 2. `make -C ./target-src` (build the `1ST_READ.BIN`) 65 | 3. `mkisofs -C 0,11702 -V dcload-serial -G ./make-cd/IP.BIN -joliet -rock -l -o temp.iso ./target-src/1st_read/1st_read.bin` 66 | 4. `cdi4dc temp.iso dcload-serial.cdi` 67 | 68 | ## Testing 69 | 70 | Everything is located in the `example-src` directory. 71 | 72 | * `dc-tool-ser -x console-test`: tests some PC I/O 73 | * `dc-tool-ser -x exception-test`: generates an exception 74 | 75 | ## KOS GDB-over-dcload 76 | 77 | You have the possibility to use **dcload** to debug remotely Dreamcast binaries. 78 | To run a GNU debugger session over the **dcload** connection: 79 | 80 | 1. Build/obtain an `sh-elf` targetted GNU debugger (can be made with `dc-chain` 81 | utility from [KallistiOS](http://gamedev.allusion.net/softprj/kos/)). 82 | 2. Put a `gdb_init()` call somewhere in the startup area of your 83 | KOS-based program (e.g. it's a good idea to put this call in your `main()`), 84 | then add the `#include ` statement in that file. 85 | 3. Build your program with the `-g` GCC switch to include debugging info. 86 | 4. Launch your program using `dc-tool-ser -g -x `. 87 | 5. Launch `sh-elf-gdb` and connect to the `dc-tool` using `target remote :2159`. 88 | 6. Squash bugs. 89 | 90 | ## Notes 91 | 92 | * **dcload**, both IP and Serial, are maintained by the KOS 93 | team. Please join the [KallistiOS list](http://sf.net/projects/cadcdev/) 94 | for help with these tools. 95 | * Tested systems: Debian GNU/Linux 2.2; Gentoo/Linux 2.6.7; Cygwin; 96 | Mac OSX 10.3.5 (Panther); macOS 10.15.2 (Catalina), MinGW/MSYS, 97 | [DreamSDK](https://www.dreamsdk.org), MinGW-w64/MSYS2. 98 | * To attain the highest speeds with `dcload-serial`, you need to select a `USB-Serial` module that matches the baudrates that the Dreamcast's SH-4 cpu can generate. Above `115200`, the SH-4 cpu generates the following baudrates: `223214`, `260416`, `312500`, `390625`, `520833`, `781250`, `1562500`. 99 | * **Silicon Labs CP2102N**-based chips have a good match with the SH-4, so you're pretty much guaranteed to attain the highest speed, `1562500`. 100 | * **FTDI FT232***-based chips do no match the SH-4 baudrates closely enough, so `781250` will work, but `1.56M` will depend on your specific chip (ie, chip luck) 101 | * Examples of how to launch a program: 102 | * Linux: `dc-tool-ser -t /dev/usb/tts/0 -b 1500000 -x ` 103 | * Windows: `dc-tool-ser -t COM4 -b 500000 -x ` 104 | * macOS: `dc-tool-ser -t /dev/cu.usbserial-A50285BI -b 1500000 -x ` 105 | * As of `1.0.4`, little-endian byte order is enforced in the host so dc-tool 106 | now runs on big-endian systems like a Mac. 107 | * As of `1.0.3`, serial speed is changed at runtime rather than compile time. 108 | * `115200` works fine in most cases but `57600` baud is the standard baud. 109 | There is an `-e` option that will enable an alternate `115200` which may work 110 | better in some rare cases. Use this only if the regular `115200` is unstable. 111 | * `234000` will probably only work with the `-e` option enabled. 112 | * Patches and improvements are welcome. 113 | 114 | ## Modern macOS Notes 115 | 116 | * This was tested on **Catalina 10.15.2** only, however it should work on pretty 117 | much any version of macOS. 118 | * Of course some sort of USB serial adapter must be used. The standard 119 | **FT232RL USB-Serial** boards from China that are sold pretty much everywhere 120 | work great and are super cheap. 121 | * Modern macOS supports the same speeds as the other platforms, currently 122 | up to `1.56M` baud (`-b 1500000`). This was tested using Catalina and an 123 | **FT232RL**. 124 | * Compilation on macOS requires `libelf`, which can be easily installed using 125 | the [Homebrew package manager](https://brew.sh): `brew install libelf` 126 | * The static compilation option cannot be used on macOS due to the way GCC 127 | works on macOS. However, when building the standard dynamically linked build, 128 | only libSystem is linked (confirmed with `otool -L`) which is available on 129 | all macOS systems, so the binary should still be just as portable. 130 | 131 | ## Credits 132 | 133 | * [miniLZO](http://www.oberhumer.com/opensource/lzo/) was written by 134 | [Markus Oberhumer](http://www.oberhumer.com/). 135 | * There are some various files from `newlib-1.8.2` here and `video.s` was 136 | written by [Marcus Comstedt](https://mc.pp.se/dc/). 137 | * Win32 porting and implementation of `-t` by **Florian 'Proff' Schulze**. 138 | * Bugfix and implementation of `-b` by **The Gypsy**. 139 | * Fixes for Cygwin by **Florian 'Proff' Schulze**. 140 | * Minor initialization fix in dcload for `gcc-3.4.x` and Serial protocol endian 141 | fixes by [Paul Boese a.k.a. Axlen](http://archives.dcemulation.org/www.axlen.com/www.geocities.com/pboese_sbcglobal.net/index.html). 142 | * Fixes for Mac OSX (and testing) by **Dan Potter**. 143 | * Fixes for `libbfd` segfaults by **Atani**. 144 | * Tons of improvements and fixes by [SiZiOUS](https://sizious.com). 145 | * Modern macOS testing by [Ben Baron a.k.a. einsteinx2](https://twitter.com/einsteinx2). 146 | -------------------------------------------------------------------------------- /example-src/Makefile: -------------------------------------------------------------------------------- 1 | include ../Makefile.cfg 2 | 3 | CC = $(TARGETCC) 4 | INCLUDE = -I../target-inc 5 | CFLAGS = $(TARGETCFLAGS) 6 | OBJCOPY = $(TARGETOBJCOPY) 7 | 8 | OBJECTS = crt0.o dcload-syscall.o dcload-syscalls.o 9 | 10 | .c.o: 11 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 12 | 13 | .S.o: 14 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 15 | 16 | .s.o: 17 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 18 | 19 | all: console-test.bin exception-test.bin 20 | 21 | console-test.bin: console-test 22 | $(OBJCOPY) -O binary $< $@ 23 | 24 | exception-test.bin: exception-test 25 | $(OBJCOPY) -O binary $< $@ 26 | 27 | console-test: $(OBJECTS) console-test.o 28 | $(CC) $(CFLAGS) -Wl,-Tdc$(TARGETCCVER).x -nostartfiles -nostdlib $^ -o $@ -lgcc 29 | 30 | exception-test: $(OBJECTS) exception-test.o 31 | $(CC) $(CFLAGS) -Wl,-Tdc$(TARGETCCVER).x -nostartfiles -nostdlib $^ -o $@ -lgcc 32 | 33 | .PHONY : clean 34 | clean: 35 | -rm -f *.o console-test exception-test 36 | 37 | .PHONY : distclean 38 | distclean: clean 39 | -rm -f *.bin 40 | -------------------------------------------------------------------------------- /example-src/README: -------------------------------------------------------------------------------- 1 | crt0.S a version of crt0.S 2 | dc.x a linker script for the Dreamcast 3 | dcload-syscall.S assembly to call a dcload syscall 4 | dcload-syscall.h lowlevel dcload syscall header 5 | dcload-syscalls.c dcload syscall c source 6 | dcload-syscalls.h dcload syscall header 7 | 8 | To use this stuff in your own code, #include "dcload-syscalls.h" and link with dcload-syscalls.o and dcload-syscall.o. 9 | 10 | You're welcome to use any of the code in this directory in any way you please. 11 | I'm not responsible if it causes you to fart fire, grow a third eye, etc, etc. 12 | -------------------------------------------------------------------------------- /example-src/console-test.c: -------------------------------------------------------------------------------- 1 | #include "dcload-syscalls.h" 2 | 3 | int main(void) { 4 | int fd; 5 | unsigned char buffer[2048]; 6 | int count; 7 | unsigned char wrkmem[65536]; 8 | 9 | assign_wrkmem(wrkmem); 10 | write(1, "dcload console test program\n\n", 30); 11 | 12 | fd = open("console-test.c", O_RDONLY); 13 | 14 | if(fd == -1) { 15 | write(1, "open failed!\n", 14); 16 | exit(1); 17 | } 18 | 19 | write(1, "Contents of console-test.c:\n\n", 30); 20 | 21 | count = read(fd, buffer, 2048); 22 | 23 | if(count == -1) { 24 | write(1, "read failed!\n", 14); 25 | exit(1); 26 | } 27 | 28 | write(1, buffer, count); 29 | close(fd); 30 | 31 | exit(0); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /example-src/crt0.S: -------------------------------------------------------------------------------- 1 | .section .text 2 | .global start 3 | .global ___exit 4 | .global _atexit 5 | start: 6 | mov.l setup_cache_k,r0 7 | mov.l p2_mask,r1 8 | or r1,r0 9 | jmp @r0 10 | nop 11 | setup_cache: 12 | mov.l ccr_addr,r0 13 | mov.w ccr_data,r1 14 | mov.l r1,@r0 15 | mov.l start_2_k,r0 16 | nop 17 | nop 18 | nop 19 | nop 20 | nop 21 | nop 22 | nop 23 | jmp @r0 24 | nop 25 | start_2: 26 | mov.l old_stack_k,r14 27 | mov.l r15,@r14 28 | mov.l old_pr_k,r14 29 | sts pr,r15 30 | mov.l r15,@r14 31 | mov.l stack_k,r15 32 | 33 | ! zero out bss 34 | mov.l edata_k,r0 35 | mov.l end_k,r1 36 | mov #0,r2 37 | start_l: 38 | mov.l r2,@r0 39 | add #4,r0 40 | cmp/ge r0,r1 41 | bt start_l 42 | 43 | #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY) 44 | mov.l set_fpscr_k, r1 45 | jsr @r1 46 | mov #0,r4 47 | lds r3,fpscr 48 | #endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) */ 49 | 50 | ! call the mainline 51 | mov.l main_k,r0 52 | jsr @r0 53 | or r0,r0 54 | 55 | ! call exit 56 | mov r0,r4 57 | mov.l exit_k,r0 58 | jsr @r0 59 | or r0,r0 60 | 61 | ___exit: 62 | mov.l old_pr_k,r14 63 | mov.l @r14,r15 64 | lds r15,pr 65 | mov.l old_stack_k,r14 66 | mov.l @r14,r15 67 | rts 68 | nop 69 | 70 | _atexit: 71 | rts 72 | nop 73 | 74 | .align 4 75 | #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) 76 | set_fpscr_k: 77 | .long ___set_fpscr 78 | #endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(SH4_SINGLE_ONLY) */ 79 | stack_k: 80 | .long _stack 81 | edata_k: 82 | .long _edata 83 | end_k: 84 | .long _end 85 | main_k: 86 | .long _main 87 | exit_k: 88 | .long _exit 89 | 90 | old_stack_k: 91 | .long _old_stack 92 | old_pr_k: 93 | .long _old_pr 94 | 95 | _old_stack: 96 | .long 0 97 | _old_pr: 98 | .long 0 99 | 100 | setup_cache_k: 101 | .long setup_cache 102 | start_2_k: 103 | .long start_2 104 | p2_mask: 105 | .long 0xa0000000 106 | ccr_addr: 107 | .long 0xff00001c 108 | ccr_data: 109 | .word 0x090b 110 | 111 | .align 4 112 | 113 | #ifdef __ELF__ 114 | .section .stack,"aw" 115 | #else 116 | .section .stack 117 | #endif 118 | ! _stack: .long 0xdeaddead 119 | 120 | -------------------------------------------------------------------------------- /example-src/dc3.x: -------------------------------------------------------------------------------- 1 | /* Sega Dreamcast linker script */ 2 | 3 | OUTPUT_FORMAT("elf32-shl", "elf32-shl", 4 | "elf32-shl") 5 | OUTPUT_ARCH(sh) 6 | ENTRY(start) 7 | SEARCH_DIR(/usr/local/dcdev/sh-elf/lib); 8 | /* Do we need any of these for elf? 9 | __DYNAMIC = 0; */ 10 | 11 | MEMORY 12 | { 13 | ram (rwx) : ORIGIN = 0x8c010000, LENGTH = 0xfe0000 14 | } 15 | 16 | SECTIONS 17 | { 18 | /* Read-only sections, merged into text segment: */ 19 | /* . = 0x1000;*/ 20 | .interp : { *(.interp) } 21 | .hash : { *(.hash) } 22 | .dynsym : { *(.dynsym) } 23 | .dynstr : { *(.dynstr) } 24 | .gnu.version : { *(.gnu.version) } 25 | .gnu.version_d : { *(.gnu.version_d) } 26 | .gnu.version_r : { *(.gnu.version_r) } 27 | .rel.init : { *(.rel.init) } 28 | .rela.init : { *(.rela.init) } 29 | .rel.text : 30 | { 31 | *(.rel.text) 32 | *(.rel.text.*) 33 | *(.rel.gnu.linkonce.t*) 34 | } 35 | .rela.text : 36 | { 37 | *(.rela.text) 38 | *(.rela.text.*) 39 | *(.rela.gnu.linkonce.t*) 40 | } 41 | .rel.fini : { *(.rel.fini) } 42 | .rela.fini : { *(.rela.fini) } 43 | .rel.rodata : 44 | { 45 | *(.rel.rodata) 46 | *(.rel.rodata.*) 47 | *(.rel.gnu.linkonce.r*) 48 | } 49 | .rela.rodata : 50 | { 51 | *(.rela.rodata) 52 | *(.rela.rodata.*) 53 | *(.rela.gnu.linkonce.r*) 54 | } 55 | .rel.data : 56 | { 57 | *(.rel.data) 58 | *(.rel.data.*) 59 | *(.rel.gnu.linkonce.d*) 60 | } 61 | .rela.data : 62 | { 63 | *(.rela.data) 64 | *(.rela.data.*) 65 | *(.rela.gnu.linkonce.d*) 66 | } 67 | .rel.ctors : { *(.rel.ctors) } 68 | .rela.ctors : { *(.rela.ctors) } 69 | .rel.dtors : { *(.rel.dtors) } 70 | .rela.dtors : { *(.rela.dtors) } 71 | .rel.got : { *(.rel.got) } 72 | .rela.got : { *(.rela.got) } 73 | .rel.sdata : 74 | { 75 | *(.rel.sdata) 76 | *(.rel.sdata.*) 77 | *(.rel.gnu.linkonce.s*) 78 | } 79 | .rela.sdata : 80 | { 81 | *(.rela.sdata) 82 | *(.rela.sdata.*) 83 | *(.rela.gnu.linkonce.s*) 84 | } 85 | .rel.sbss : { *(.rel.sbss) } 86 | .rela.sbss : { *(.rela.sbss) } 87 | .rel.bss : { *(.rel.bss) } 88 | .rela.bss : { *(.rela.bss) } 89 | .rel.plt : { *(.rel.plt) } 90 | .rela.plt : { *(.rela.plt) } 91 | .init : 92 | { 93 | KEEP (*(.init)) 94 | } =0 95 | .plt : { *(.plt) } 96 | .text : 97 | { 98 | *(.text) 99 | *(.text.*) 100 | *(.stub) 101 | /* .gnu.warning sections are handled specially by elf32.em. */ 102 | *(.gnu.warning) 103 | *(.gnu.linkonce.t*) 104 | } =0 105 | _etext = .; 106 | PROVIDE (etext = .); 107 | .fini : 108 | { 109 | KEEP (*(.fini)) 110 | } =0 111 | .rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) } 112 | .rodata1 : { *(.rodata1) } 113 | /* Adjust the address for the data segment. We want to adjust up to 114 | the same address within the page on the next page up. */ 115 | . = ALIGN(128) + (. & (128 - 1)); 116 | .data : 117 | { 118 | *(.data) 119 | *(.data.*) 120 | *(.gnu.linkonce.d*) 121 | SORT(CONSTRUCTORS) 122 | } 123 | .data1 : { *(.data1) } 124 | .eh_frame : { *(.eh_frame) } 125 | .gcc_except_table : { *(.gcc_except_table) } 126 | .ctors ALIGN(4): 127 | { 128 | ___ctors = .; 129 | /* gcc uses crtbegin.o to find the start of 130 | the constructors, so we make sure it is 131 | first. Because this is a wildcard, it 132 | doesn't matter if the user does not 133 | actually link against crtbegin.o; the 134 | linker won't look for a file to match a 135 | wildcard. The wildcard also means that it 136 | doesn't matter which directory crtbegin.o 137 | is in. */ 138 | KEEP (*crtbegin.o(.ctors)) 139 | /* We don't want to include the .ctor section from 140 | from the crtend.o file until after the sorted ctors. 141 | The .ctor section from the crtend file contains the 142 | end of ctors marker and it must be last */ 143 | KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors)) 144 | KEEP (*(SORT(.ctors.*))) 145 | KEEP (*(.ctors)) 146 | ___ctors_end = .; 147 | } 148 | .dtors : 149 | { 150 | ___dtors = .; 151 | KEEP (*crtbegin.o(.dtors)) 152 | KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors)) 153 | KEEP (*(SORT(.dtors.*))) 154 | KEEP (*(.dtors)) 155 | ___dtors_end = .; 156 | } 157 | .got : { *(.got.plt) *(.got) } 158 | .dynamic : { *(.dynamic) } 159 | /* We want the small data sections together, so single-instruction offsets 160 | can access them all, and initialized data all before uninitialized, so 161 | we can shorten the on-disk segment size. */ 162 | .sdata : 163 | { 164 | *(.sdata) 165 | *(.sdata.*) 166 | *(.gnu.linkonce.s.*) 167 | } 168 | _edata = .; 169 | PROVIDE (edata = .); 170 | __bss_start = .; 171 | .sbss : 172 | { 173 | *(.dynsbss) 174 | *(.sbss) 175 | *(.sbss.*) 176 | *(.scommon) 177 | } 178 | .bss : 179 | { 180 | *(.dynbss) 181 | *(.bss) 182 | *(.bss.*) 183 | *(COMMON) 184 | /* Align here to ensure that the .bss section occupies space up to 185 | _end. Align after .bss to ensure correct alignment even if the 186 | .bss section disappears because there are no input sections. */ 187 | . = ALIGN(32 / 8); 188 | } 189 | . = ALIGN(32 / 8); 190 | _end = .; 191 | PROVIDE (end = .); 192 | /* Stabs debugging sections. */ 193 | .stab 0 : { *(.stab) } 194 | .stabstr 0 : { *(.stabstr) } 195 | .stab.excl 0 : { *(.stab.excl) } 196 | .stab.exclstr 0 : { *(.stab.exclstr) } 197 | .stab.index 0 : { *(.stab.index) } 198 | .stab.indexstr 0 : { *(.stab.indexstr) } 199 | .comment 0 : { *(.comment) } 200 | /* DWARF debug sections. 201 | Symbols in the DWARF debugging sections are relative to the beginning 202 | of the section so we begin them at 0. */ 203 | /* DWARF 1 */ 204 | .debug 0 : { *(.debug) } 205 | .line 0 : { *(.line) } 206 | /* GNU DWARF 1 extensions */ 207 | .debug_srcinfo 0 : { *(.debug_srcinfo) } 208 | .debug_sfnames 0 : { *(.debug_sfnames) } 209 | /* DWARF 1.1 and DWARF 2 */ 210 | .debug_aranges 0 : { *(.debug_aranges) } 211 | .debug_pubnames 0 : { *(.debug_pubnames) } 212 | /* DWARF 2 */ 213 | .debug_info 0 : { *(.debug_info) } 214 | .debug_abbrev 0 : { *(.debug_abbrev) } 215 | .debug_line 0 : { *(.debug_line) } 216 | .debug_frame 0 : { *(.debug_frame) } 217 | .debug_str 0 : { *(.debug_str) } 218 | .debug_loc 0 : { *(.debug_loc) } 219 | .debug_macinfo 0 : { *(.debug_macinfo) } 220 | /* SGI/MIPS DWARF 2 extensions */ 221 | .debug_weaknames 0 : { *(.debug_weaknames) } 222 | .debug_funcnames 0 : { *(.debug_funcnames) } 223 | .debug_typenames 0 : { *(.debug_typenames) } 224 | .debug_varnames 0 : { *(.debug_varnames) } 225 | /* .stack 0x8c00f400 : { _stack = .; *(.stack) }*/ 226 | /* These must appear regardless of . */ 227 | _stack = 0x8d000000; 228 | } 229 | -------------------------------------------------------------------------------- /example-src/dcload-syscall.h: -------------------------------------------------------------------------------- 1 | #ifndef __DCLOAD_SYSCALL_H__ 2 | #define __DCLOAD_SYSCALL_H__ 3 | 4 | #include 5 | #include 6 | 7 | int dcloadsyscall(unsigned int syscall, ...); 8 | 9 | /* From crt0.S */ 10 | extern noreturn void __exit(int status); 11 | 12 | #define pcreadnr 0 13 | #define pcwritenr 1 14 | #define pcopennr 2 15 | #define pcclosenr 3 16 | #define pccreatnr 4 17 | #define pclinknr 5 18 | #define pcunlinknr 6 19 | #define pcchdirnr 7 20 | #define pcchmodnr 8 21 | #define pclseeknr 9 22 | #define pcfstatnr 10 23 | #define pctimenr 11 24 | #define pcstatnr 12 25 | #define pcutimenr 13 26 | #define pcassignwrkmem 14 27 | #define pcexitnr 15 28 | 29 | #define DCLOADMAGICVALUE 0xdeadbeef 30 | #define DCLOADMAGICADDR (unsigned int *)0x8c004004 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /example-src/dcload-syscall.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .global _dcloadsyscall 3 | _dcloadsyscall: 4 | mov.l dcloadsyscall_k,r0 5 | mov.l @r0,r0 6 | jmp @r0 7 | nop 8 | .align 4 9 | dcloadsyscall_k: 10 | .long 0x8c004008 11 | -------------------------------------------------------------------------------- /example-src/dcload-syscalls.c: -------------------------------------------------------------------------------- 1 | #include "dcload-syscall.h" 2 | 3 | int link(const char *oldpath, const char *newpath) { 4 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 5 | return dcloadsyscall(pclinknr, oldpath, newpath); 6 | else 7 | return -1; 8 | } 9 | 10 | int read(int file, char *ptr, int len) { 11 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 12 | return dcloadsyscall(pcreadnr, file, ptr, len); 13 | else 14 | return -1; 15 | } 16 | 17 | int lseek(int file, int ptr, int dir) { 18 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 19 | return dcloadsyscall(pclseeknr, file, ptr, dir); 20 | else 21 | return -1; 22 | } 23 | 24 | int write(int file, char *ptr, int len) { 25 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 26 | return dcloadsyscall(pcwritenr, file, ptr, len); 27 | else 28 | return -1; 29 | } 30 | 31 | int close(int file) { 32 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 33 | return dcloadsyscall(pcclosenr, file); 34 | else 35 | return -1; 36 | } 37 | 38 | int fstat(int file, struct stat *st) { 39 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 40 | return dcloadsyscall(pcfstatnr, file, st); 41 | else 42 | return -1; 43 | } 44 | 45 | int open(const char *path, int flags) { 46 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 47 | return dcloadsyscall(pcopennr, path, flags); 48 | else 49 | return -1; 50 | } 51 | 52 | int creat(const char *path, int mode) { 53 | if (*DCLOADMAGICADDR == DCLOADMAGICVALUE) 54 | return dcloadsyscall(pccreatnr, path, mode); 55 | else 56 | return -1; 57 | } 58 | 59 | int unlink(const char *path) { 60 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 61 | return dcloadsyscall(pcunlinknr, path); 62 | else 63 | return -1; 64 | } 65 | 66 | noreturn void exit(int status) { 67 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 68 | dcloadsyscall(pcexitnr); 69 | 70 | __exit(status); 71 | } 72 | 73 | int stat(const char *path, struct stat *st) { 74 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 75 | return dcloadsyscall(pcstatnr, path, st); 76 | else 77 | return -1; 78 | } 79 | 80 | int chmod(const char *path, mode_t mode) { 81 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 82 | return dcloadsyscall(pcchmodnr, path, mode); 83 | else 84 | return -1; 85 | } 86 | 87 | int utime(const char *path, char *times) { 88 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 89 | return dcloadsyscall(pcutimenr, path, times); 90 | else 91 | return -1; 92 | } 93 | 94 | int chdir(const char *path) { 95 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 96 | return dcloadsyscall(pcchdirnr, path); 97 | else 98 | return -1; 99 | } 100 | 101 | long time(long *t) { 102 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 103 | return dcloadsyscall(pctimenr, t); 104 | else 105 | return -1; 106 | } 107 | 108 | void assign_wrkmem(unsigned char *wrkmem) { 109 | if(*DCLOADMAGICADDR == DCLOADMAGICVALUE) 110 | dcloadsyscall(pcassignwrkmem, wrkmem); 111 | } 112 | -------------------------------------------------------------------------------- /example-src/dcload-syscalls.h: -------------------------------------------------------------------------------- 1 | #ifndef __DCLOAD_SYSCALLS_H__ 2 | #define __DCLOAD_SYSCALLS_H__ 3 | 4 | #include 5 | 6 | #define O_RDONLY 0 7 | #define O_WRONLY 1 8 | #define O_RDWR 2 9 | 10 | int link(const char *oldpath, const char *newpath); 11 | int read(int file, char *ptr, int len); 12 | int lseek(int file, int ptr, int dir); 13 | int write( int file, char *ptr, int len); 14 | int close(int file); 15 | int fstat(int file, struct stat *st); 16 | int open(const char *path, int flags); 17 | int creat(const char *path, int mode); 18 | int unlink(const char *path); 19 | void exit(int status); 20 | int stat(const char *path, struct stat *st); 21 | int chmod(const char *path, mode_t mode); 22 | int utime(const char *path, char *times); 23 | int chdir(const char *path); 24 | long time(long *t); 25 | void assign_wrkmem(unsigned char *wrkmem); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /example-src/exception-test.c: -------------------------------------------------------------------------------- 1 | int main(void) { 2 | int i; 3 | 4 | i = *((volatile unsigned int *)2); 5 | } 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /host-src/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS = misc tool 2 | MAKE ?= make 3 | 4 | .PHONY : subdirs $(SUBDIRS) 5 | 6 | subdirs: $(SUBDIRS) 7 | 8 | $(SUBDIRS): 9 | $(MAKE) -C $@ 10 | 11 | .PHONY : clean 12 | clean: 13 | for dir in $(SUBDIRS); do \ 14 | $(MAKE) -C $$dir clean; \ 15 | done 16 | 17 | .PHONY : distclean 18 | distclean: 19 | for dir in $(SUBDIRS) ; do \ 20 | $(MAKE) -C $$dir distclean; \ 21 | done 22 | 23 | -------------------------------------------------------------------------------- /host-src/misc/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.cfg 2 | 3 | LZOPATH = ../../minilzo-2.10 4 | 5 | CC = $(HOSTCC) 6 | CFLAGS = $(HOSTCFLAGS) 7 | INCLUDE = -I$(LZOPATH) 8 | LZOFILES = $(LZOPATH)/minilzo.c $(LZOPATH)/minilzo.h $(LZOPATH)/lzoconf.h 9 | 10 | .c.o: 11 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 12 | 13 | all: lzo 14 | 15 | lzo: lzo.c minilzo.o 16 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ $^ 17 | 18 | minilzo.o: $(LZOFILES) 19 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 20 | 21 | .PHONY : clean 22 | clean: 23 | -rm -f *.o 24 | 25 | .PHONY : distclean 26 | distclean: clean 27 | -rm -f lzo -------------------------------------------------------------------------------- /host-src/misc/lzo.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the dcload Dreamcast serial loader 3 | * 4 | * Andrew Kieschnick 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "minilzo.h" 29 | 30 | #define HEAP_ALLOC(var,size) \ 31 | long __LZO_MMODEL var [ ((size) + (sizeof(long) - 1)) / sizeof(long) ] 32 | 33 | static HEAP_ALLOC(wrkmem,LZO1X_1_MEM_COMPRESS); 34 | 35 | void usage(void) { 36 | printf("usage: lzo \n"); 37 | exit(1); 38 | } 39 | 40 | int main(int argc, char *argv[]) 41 | { 42 | int in, out; 43 | unsigned char * data; 44 | unsigned char * cdata; 45 | int r; 46 | lzo_uint length,clength; 47 | 48 | if (argc != 3) 49 | usage(); 50 | 51 | in = open(argv[1], O_RDONLY); 52 | 53 | if (in < 0) { 54 | perror(argv[1]); 55 | exit(1); 56 | } 57 | 58 | out = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644); 59 | 60 | if (out < 0) { 61 | perror(argv[2]); 62 | exit(1); 63 | } 64 | 65 | length = lseek(in, 0, SEEK_END); 66 | lseek(in, 0, SEEK_SET); 67 | 68 | data = malloc(length); 69 | cdata = malloc(length+length/64 + 16 + 3); 70 | 71 | read(in, data, length); 72 | 73 | if (lzo_init() != LZO_E_OK) 74 | { 75 | printf("lzo_init() failed !!!\n"); 76 | exit(1); 77 | } 78 | 79 | r = lzo1x_1_compress(data,length,cdata,&clength,wrkmem); 80 | if (r == LZO_E_OK) 81 | printf("compressed %lu bytes into %lu bytes\n", 82 | (long) length, (long) clength); 83 | else 84 | { 85 | /* this should NEVER happen */ 86 | printf("internal error - compression failed: %d\n", r); 87 | return 2; 88 | } 89 | /* check for an incompressible block */ 90 | if (clength >= length) 91 | { 92 | printf("This block contains incompressible data.\n"); 93 | return 0; 94 | } 95 | 96 | write(out, cdata, clength); 97 | 98 | close(in); 99 | close(out); 100 | exit(0); 101 | } 102 | 103 | -------------------------------------------------------------------------------- /host-src/tool/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.cfg 2 | 3 | LZOPATH = ../../minilzo-2.10 4 | 5 | CC = $(HOSTCC) 6 | CFLAGS = $(HOSTCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" -DDEFAULT_SPEED=$(TOOL_DEFAULT_SPEED) -DSERIALDEVICE="\"$(SERIALDEVICE)\"" -DHAVE_GETOPT 7 | 8 | LDFLAGS = $(HOSTLDFLAGS) 9 | INCLUDE = -I$(LZOPATH) -I/usr/local/include 10 | 11 | # Adding static flag if asked 12 | ifeq ($(STANDALONE_BINARY),1) 13 | LDFLAGS += -static 14 | endif 15 | 16 | # Determine if we need zlib or not in that context for building dc-tool 17 | # The purpose of that is just to have '-lz' once at the end of the command line 18 | ZLIB_REQUIRED := 0 19 | 20 | # Linking with 'libelf' or 'libbfd' (sh-elf), depending of 'Makefile.cfg' 21 | ifeq ($(WITH_BFD),1) 22 | # Starting from Binutils 2.40, SFrame is required when using BFD 23 | LIBSFRAME = 24 | ifneq ("$(wildcard $(TARGETPREFIX)/lib/libsframe.a)","") 25 | LIBSFRAME = -lsframe 26 | endif 27 | 28 | CFLAGS += -DWITH_BFD 29 | LDFLAGS += -L$(BFDLIB) -lbfd $(LIBSFRAME) -liberty -lintl 30 | INCLUDE += -I$(BFDINCLUDE) 31 | 32 | ZLIB_REQUIRED := 1 33 | else 34 | LDFLAGS += -L$(ELFLIB) -lelf 35 | INCLUDE += -I$(ELFINCLUDE) 36 | endif 37 | 38 | # Additional libraries for MinGW/MSYS or MinGW-w64/MSYS2 39 | ifdef MINGW32 40 | LDFLAGS += -lws2_32 -lwsock32 -liconv 41 | ZLIB_REQUIRED := 1 42 | endif 43 | 44 | # Add zlib to the command line end... if required 45 | ifeq ($(ZLIB_REQUIRED),1) 46 | LDFLAGS += -lz 47 | endif 48 | 49 | DCTOOL = dc-tool-ser$(EXECUTABLEEXTENSION) 50 | 51 | OBJECTS = dc-tool.o minilzo.o syscalls.o unlink.o shim.o 52 | LZOFILES = $(LZOPATH)/minilzo.c $(LZOPATH)/minilzo.h $(LZOPATH)/lzoconf.h 53 | 54 | .c.o: 55 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 56 | 57 | all: $(DCTOOL) 58 | 59 | $(DCTOOL): $(OBJECTS) 60 | $(CC) -o $@ $(OBJECTS) $(LDFLAGS) 61 | 62 | minilzo.o: $(LZOFILES) 63 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 64 | 65 | .PHONY : install 66 | install: $(DCTOOL) | $(TOOLINSTALLDIR) 67 | cp $(DCTOOL) $(TOOLINSTALLDIR) 68 | $(TOOLINSTALLDIR): 69 | -mkdir $(TOOLINSTALLDIR) 70 | 71 | .PHONY : clean 72 | clean: 73 | -rm -f $(OBJECTS) 74 | 75 | .PHONY : distclean 76 | distclean: clean 77 | -rm -f $(DCTOOL) 78 | -------------------------------------------------------------------------------- /host-src/tool/config.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CONFIG_H__ 3 | #define __CONFIG_H__ 4 | 5 | #define PACKAGE "dc-tool" 6 | #define PACKAGE_VERSION DCLOAD_VERSION 7 | 8 | #endif /* __CONFIG_H__ */ 9 | -------------------------------------------------------------------------------- /host-src/tool/dc-io.h: -------------------------------------------------------------------------------- 1 | #ifndef __DC_IO_H__ 2 | #define __DC_IO_H__ 3 | 4 | int send_uint(unsigned int value); 5 | unsigned int recv_uint(void); 6 | void recv_data(void *data, unsigned int total, unsigned int verbose); 7 | void send_data(unsigned char *addr, unsigned int size, unsigned int verbose); 8 | 9 | #endif 10 | 11 | 12 | -------------------------------------------------------------------------------- /host-src/tool/shim.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the dcload Dreamcast serial loader 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | * 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #ifdef __MINGW32__ 25 | #include <_mingw.h> 26 | #include 27 | 28 | /* Detect MinGW/MSYS vs. MinGW-w64/MSYS2 */ 29 | # ifdef __MINGW64_VERSION_MAJOR 30 | # define __RT_MINGW_W64__ 31 | # else 32 | # define __RT_MINGW_ORG__ 33 | # endif 34 | 35 | #endif /* __MINGW32__ */ 36 | 37 | /* 38 | * Compatibility layer ('shim') for the original, legacy MinGW/MSYS environment. 39 | * This allow toolchains built on MinGW-w64/MSYS2 to be usable with MinGW/MSYS. 40 | * Mainly, this is for linking 'dc-tool' with 'libbfd'. Declaring these 41 | * functions will let us to build 'dc-tool' even if 'sh-elf' toolchain was built 42 | * on MinGW-w64/MSYS2. 43 | * 44 | * Of course this will work if the compiler used on MinGW-w64/MSYS2 and 45 | * MinGW/MSYS are in the same family (e.g., GCC 9.x on both environments). 46 | */ 47 | #ifdef __RT_MINGW_ORG__ 48 | 49 | // See: https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-crt/stdio/mingw_vasprintf.c 50 | int vasprintf(char ** __restrict__ ret, 51 | const char * __restrict__ format, 52 | va_list ap) { 53 | int len; 54 | /* Get Length */ 55 | len = __mingw_vsnprintf(NULL,0,format,ap); 56 | if (len < 0) return -1; 57 | /* +1 for \0 terminator. */ 58 | *ret = malloc(len + 1); 59 | /* Check malloc fail*/ 60 | if (!*ret) return -1; 61 | /* Write String */ 62 | __mingw_vsnprintf(*ret,len+1,format,ap); 63 | /* Terminate explicitly */ 64 | (*ret)[len] = '\0'; 65 | return len; 66 | } 67 | 68 | // Thanks to Dietrich Epp 69 | // See: https://stackoverflow.com/a/40160038 70 | int __cdecl __MINGW_NOTHROW libintl_asprintf(char **strp, 71 | const char *fmt, ...) { 72 | va_list ap; 73 | va_start(ap, fmt); 74 | 75 | int r = vasprintf(strp, fmt, ap); 76 | va_end(ap); 77 | 78 | return r; 79 | } 80 | 81 | int __cdecl __MINGW_NOTHROW libintl_vasprintf(char **restrict strp, 82 | const char *restrict fmt, 83 | va_list arg ) { 84 | return vasprintf(strp, fmt, arg); 85 | } 86 | 87 | // See: https://stackoverflow.com/a/60380005 88 | int __cdecl __MINGW_NOTHROW __ms_vsnprintf(char *buffer, 89 | size_t count, 90 | const char *format, 91 | va_list argptr) { 92 | return __mingw_vsnprintf(buffer, count, format, argptr); 93 | } 94 | 95 | // Thanks to Kenji Uno and god 96 | // See: https://github.com/HiraokaHyperTools/libacrt_iob_func 97 | // See: https://stackoverflow.com/a/30894349 98 | FILE * __cdecl __MINGW_NOTHROW _imp____acrt_iob_func(int handle) { 99 | switch (handle) { 100 | case 0: return stdin; 101 | case 1: return stdout; 102 | case 2: return stderr; 103 | } 104 | 105 | return NULL; 106 | } 107 | 108 | #endif /* __RT_MINGW_ORG__ */ 109 | -------------------------------------------------------------------------------- /host-src/tool/syscalls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the dcload Dreamcast serial loader 3 | * 4 | * Copyright (C) 2001 Andrew Kieschnick 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #ifndef __SYSCALLS_H__ 23 | #define __SYSCALLS_H__ 24 | 25 | void dc_fstat(void); 26 | void dc_write(void); 27 | void dc_read(void); 28 | void dc_open(void); 29 | void dc_close(void); 30 | void dc_creat(void); 31 | void dc_link(void); 32 | void dc_unlink(void); 33 | void dc_chdir(void); 34 | void dc_chmod(void); 35 | void dc_lseek(void); 36 | void dc_time(void); 37 | void dc_stat(void); 38 | void dc_utime(void); 39 | 40 | void dc_opendir(void); 41 | void dc_readdir(void); 42 | void dc_closedir(void); 43 | void dc_rewinddir(void); 44 | 45 | void dc_cdfs_redir_read_sectors(int isofd); 46 | 47 | void dc_gdbpacket(void); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /host-src/tool/unlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #ifndef S_ISLNK 6 | #ifdef S_IFLNK 7 | #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) 8 | #else 9 | #define S_ISLNK(m) 0 10 | #define lstat stat 11 | #endif 12 | #endif 13 | 14 | int unlink_if_ordinary (const char *name) { 15 | struct stat st; 16 | 17 | if(lstat (name, &st) == 0 && 18 | (S_ISREG (st.st_mode) || S_ISLNK (st.st_mode))) { 19 | return unlink (name); 20 | } 21 | 22 | return 1; 23 | } 24 | -------------------------------------------------------------------------------- /make-cd/IP.BIN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KallistiOS/dcload-serial/2e70c1f84768f868c70c6920c6f1c960211e623d/make-cd/IP.BIN -------------------------------------------------------------------------------- /make-cd/Makefile: -------------------------------------------------------------------------------- 1 | CDRECORD = wodim dev=0,0,0 speed=8 2 | #CDRECORD = wodim dev=ATAPI:0,0,0 speed=8 3 | DD = dd 4 | CP = cp 5 | MKISOFS = genisoimage 6 | CAT = cat 7 | TOUCH = touch 8 | 1ST_READ = ../target-src/1st_read/1st_read.bin 9 | 10 | all: $(1ST_READ) audio.raw burn-audio data.raw burn-data 11 | 12 | $(1ST_READ): 13 | cd ../target-src && make 14 | 15 | audio.raw: 16 | $(DD) if=/dev/zero of=audio.raw bs=2352 count=300 17 | 18 | burn-audio: audio.raw 19 | $(CDRECORD) -multi -audio -tao audio.raw 20 | touch burn-audio 21 | 22 | 1st_read.bin: $(1ST_READ) 23 | cp $(1ST_READ) 1st_read.bin 24 | 25 | data.raw: tmp.iso IP.BIN 26 | ( cat IP.BIN ; dd if=tmp.iso bs=2048 skip=16 ) > data.raw 27 | 28 | tmp.iso: 1st_read.bin burn-audio 29 | $(MKISOFS) -C `$(CDRECORD) -msinfo` -o tmp.iso 1st_read.bin 30 | 31 | burn-data: data.raw 32 | $(CDRECORD) -xa -tao -multi data.raw 33 | -rm -f audio.raw data.raw burn-audio 34 | 35 | .PHONY : clean 36 | clean: 37 | -rm -f tmp.iso burn-audio 1st_read.bin 38 | 39 | .PHONY : distclean 40 | distclean: clean 41 | -rm -f audio.raw data.raw 42 | -------------------------------------------------------------------------------- /minilzo-2.10/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # a very simple Makefile for miniLZO 3 | # 4 | # Copyright (C) 1996-2017 Markus F.X.J. Oberhumer 5 | # 6 | 7 | PROGRAM = testmini 8 | SOURCES = testmini.c minilzo.c 9 | 10 | default: 11 | @echo "" 12 | @echo "Welcome to miniLZO. Please choose one of the following 'make' targets:" 13 | @echo "" 14 | @echo " gcc: gcc" 15 | @echo " unix: hpux hpux9" 16 | @echo " win32: win32-bc win32-cygwin win32-dm win32-lccwin32" 17 | @echo " win32-intelc win32-mingw win32-vc win32-watcomc" 18 | @echo " dos32: dos32-djgpp2 dos32-wc" 19 | @echo "" 20 | 21 | 22 | # Make sure that minilzo.h, lzoconf.h and lzodefs.h are in the 23 | # current dircectory. Otherwise you may want to adjust CPPFLAGS. 24 | CPPFLAGS = -I. -I../include/lzo 25 | 26 | GCC_CFLAGS = -s -Wall -O2 -fomit-frame-pointer 27 | 28 | 29 | # 30 | # gcc (generic) 31 | # 32 | 33 | gcc: 34 | gcc $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM) $(SOURCES) 35 | 36 | cc: 37 | cc $(CPPFLAGS) -o $(PROGRAM) $(SOURCES) 38 | 39 | 40 | # 41 | # UNIX 42 | # 43 | 44 | hpux: 45 | cc -Ae $(CPPFLAGS) -o $(PROGRAM) $(SOURCES) 46 | 47 | hpux9: 48 | cc -Aa -D_HPUX_SOURCE $(CPPFLAGS) -o $(PROGRAM) $(SOURCES) 49 | 50 | 51 | # 52 | # Windows (32-bit) 53 | # 54 | 55 | win32-borlandc win32-bc: 56 | bcc32 -O2 -d -w -w-aus $(CPPFLAGS) $(SOURCES) 57 | 58 | win32-cygwin32 win32-cygwin: 59 | gcc -mcygwin $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM).exe $(SOURCES) 60 | 61 | win32-digitalmars win32-dm: 62 | dmc -mn -o -w- $(CPPFLAGS) $(SOURCES) 63 | 64 | win32-intelc win32-ic: 65 | icl -nologo -MT -W3 -O2 -GF $(CPPFLAGS) $(SOURCES) 66 | 67 | win32-lccwin32: 68 | @echo "NOTE: need lcc 2002-07-25 or newer, older versions have bugs" 69 | lc -A -unused -O $(CPPFLAGS) $(SOURCES) 70 | 71 | win32-mingw32 win32-mingw: 72 | gcc -mno-cygwin $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM).exe $(SOURCES) 73 | 74 | win32-visualc win32-vc: 75 | cl -nologo -MT -W3 -O2 -GF $(CPPFLAGS) $(SOURCES) 76 | 77 | win32-watcomc win32-wc: 78 | wcl386 -bt=nt -zq -mf -5r -zc -w5 -oneatx $(CPPFLAGS) $(SOURCES) 79 | 80 | 81 | # 82 | # DOS (32-bit) 83 | # 84 | 85 | dos32-djgpp2 dos32-dj2: 86 | gcc $(CPPFLAGS) $(GCC_CFLAGS) -o $(PROGRAM).exe $(SOURCES) 87 | 88 | dos32-watcomc dos32-wc: 89 | wcl386 -zq -mf -bt=dos -l=dos4g -5r -ox -zc $(CPPFLAGS) $(SOURCES) 90 | 91 | 92 | # 93 | # other targets 94 | # 95 | 96 | clean: 97 | rm -f $(PROGRAM) $(PROGRAM).exe $(PROGRAM).map $(PROGRAM).tds 98 | rm -f *.err *.o *.obj 99 | 100 | .PHONY: default clean 101 | -------------------------------------------------------------------------------- /minilzo-2.10/minilzo.h: -------------------------------------------------------------------------------- 1 | /* minilzo.h -- mini subset of the LZO real-time data compression library 2 | 3 | This file is part of the LZO real-time data compression library. 4 | 5 | Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer 6 | All Rights Reserved. 7 | 8 | The LZO library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of 11 | the License, or (at your option) any later version. 12 | 13 | The LZO library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with the LZO library; see the file COPYING. 20 | If not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | Markus F.X.J. Oberhumer 24 | 25 | http://www.oberhumer.com/opensource/lzo/ 26 | */ 27 | 28 | /* 29 | * NOTE: 30 | * the full LZO package can be found at 31 | * http://www.oberhumer.com/opensource/lzo/ 32 | */ 33 | 34 | 35 | #ifndef __MINILZO_H_INCLUDED 36 | #define __MINILZO_H_INCLUDED 1 37 | 38 | #define MINILZO_VERSION 0x20a0 /* 2.10 */ 39 | 40 | #if defined(__LZOCONF_H_INCLUDED) 41 | # error "you cannot use both LZO and miniLZO" 42 | #endif 43 | 44 | /* internal Autoconf configuration file - only used when building miniLZO */ 45 | #ifdef MINILZO_HAVE_CONFIG_H 46 | # include 47 | #endif 48 | #include 49 | #include 50 | 51 | #ifndef __LZODEFS_H_INCLUDED 52 | #include "lzodefs.h" 53 | #endif 54 | #undef LZO_HAVE_CONFIG_H 55 | #include "lzoconf.h" 56 | 57 | #if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) 58 | # error "version mismatch in header files" 59 | #endif 60 | 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | 67 | /*********************************************************************** 68 | // 69 | ************************************************************************/ 70 | 71 | /* Memory required for the wrkmem parameter. 72 | * When the required size is 0, you can also pass a NULL pointer. 73 | */ 74 | 75 | #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS 76 | #define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) 77 | #define LZO1X_MEM_DECOMPRESS (0) 78 | 79 | 80 | /* compression */ 81 | LZO_EXTERN(int) 82 | lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, 83 | lzo_bytep dst, lzo_uintp dst_len, 84 | lzo_voidp wrkmem ); 85 | 86 | /* decompression */ 87 | LZO_EXTERN(int) 88 | lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, 89 | lzo_bytep dst, lzo_uintp dst_len, 90 | lzo_voidp wrkmem /* NOT USED */ ); 91 | 92 | /* safe decompression with overrun testing */ 93 | LZO_EXTERN(int) 94 | lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, 95 | lzo_bytep dst, lzo_uintp dst_len, 96 | lzo_voidp wrkmem /* NOT USED */ ); 97 | 98 | 99 | #ifdef __cplusplus 100 | } /* extern "C" */ 101 | #endif 102 | 103 | #endif /* already included */ 104 | 105 | 106 | /* vim:set ts=4 sw=4 et: */ 107 | -------------------------------------------------------------------------------- /minilzo-2.10/testmini.c: -------------------------------------------------------------------------------- 1 | /* testmini.c -- very simple test program for the miniLZO library 2 | 3 | This file is part of the LZO real-time data compression library. 4 | 5 | Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer 6 | All Rights Reserved. 7 | 8 | The LZO library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of 11 | the License, or (at your option) any later version. 12 | 13 | The LZO library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with the LZO library; see the file COPYING. 20 | If not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | Markus F.X.J. Oberhumer 24 | 25 | http://www.oberhumer.com/opensource/lzo/ 26 | */ 27 | 28 | 29 | #include 30 | #include 31 | 32 | 33 | /************************************************************************* 34 | // This program shows the basic usage of the LZO library. 35 | // We will compress a block of data and decompress again. 36 | // 37 | // For more information, documentation, example programs and other support 38 | // files (like Makefiles and build scripts) please download the full LZO 39 | // package from 40 | // http://www.oberhumer.com/opensource/lzo/ 41 | **************************************************************************/ 42 | 43 | /* First let's include "minizo.h". */ 44 | 45 | #include "minilzo.h" 46 | 47 | 48 | /* We want to compress the data block at 'in' with length 'IN_LEN' to 49 | * the block at 'out'. Because the input block may be incompressible, 50 | * we must provide a little more output space in case that compression 51 | * is not possible. 52 | */ 53 | 54 | #define IN_LEN (128*1024ul) 55 | #define OUT_LEN (IN_LEN + IN_LEN / 16 + 64 + 3) 56 | 57 | static unsigned char __LZO_MMODEL in [ IN_LEN ]; 58 | static unsigned char __LZO_MMODEL out [ OUT_LEN ]; 59 | 60 | 61 | /* Work-memory needed for compression. Allocate memory in units 62 | * of 'lzo_align_t' (instead of 'char') to make sure it is properly aligned. 63 | */ 64 | 65 | #define HEAP_ALLOC(var,size) \ 66 | lzo_align_t __LZO_MMODEL var [ ((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t) ] 67 | 68 | static HEAP_ALLOC(wrkmem, LZO1X_1_MEM_COMPRESS); 69 | 70 | 71 | /************************************************************************* 72 | // 73 | **************************************************************************/ 74 | 75 | int main(int argc, char *argv[]) 76 | { 77 | int r; 78 | lzo_uint in_len; 79 | lzo_uint out_len; 80 | lzo_uint new_len; 81 | 82 | if (argc < 0 && argv == NULL) /* avoid warning about unused args */ 83 | return 0; 84 | 85 | printf("\nLZO real-time data compression library (v%s, %s).\n", 86 | lzo_version_string(), lzo_version_date()); 87 | printf("Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer\nAll Rights Reserved.\n\n"); 88 | 89 | 90 | /* 91 | * Step 1: initialize the LZO library 92 | */ 93 | if (lzo_init() != LZO_E_OK) 94 | { 95 | printf("internal error - lzo_init() failed !!!\n"); 96 | printf("(this usually indicates a compiler bug - try recompiling\nwithout optimizations, and enable '-DLZO_DEBUG' for diagnostics)\n"); 97 | return 3; 98 | } 99 | 100 | /* 101 | * Step 2: prepare the input block that will get compressed. 102 | * We just fill it with zeros in this example program, 103 | * but you would use your real-world data here. 104 | */ 105 | in_len = IN_LEN; 106 | lzo_memset(in,0,in_len); 107 | 108 | /* 109 | * Step 3: compress from 'in' to 'out' with LZO1X-1 110 | */ 111 | r = lzo1x_1_compress(in,in_len,out,&out_len,wrkmem); 112 | if (r == LZO_E_OK) 113 | printf("compressed %lu bytes into %lu bytes\n", 114 | (unsigned long) in_len, (unsigned long) out_len); 115 | else 116 | { 117 | /* this should NEVER happen */ 118 | printf("internal error - compression failed: %d\n", r); 119 | return 2; 120 | } 121 | /* check for an incompressible block */ 122 | if (out_len >= in_len) 123 | { 124 | printf("This block contains incompressible data.\n"); 125 | return 0; 126 | } 127 | 128 | /* 129 | * Step 4: decompress again, now going from 'out' to 'in' 130 | */ 131 | new_len = in_len; 132 | r = lzo1x_decompress(out,out_len,in,&new_len,NULL); 133 | if (r == LZO_E_OK && new_len == in_len) 134 | printf("decompressed %lu bytes back into %lu bytes\n", 135 | (unsigned long) out_len, (unsigned long) in_len); 136 | else 137 | { 138 | /* this should NEVER happen */ 139 | printf("internal error - decompression failed: %d\n", r); 140 | return 1; 141 | } 142 | 143 | printf("\nminiLZO simple compression test passed.\n"); 144 | return 0; 145 | } 146 | 147 | 148 | /* vim:set ts=4 sw=4 et: */ 149 | -------------------------------------------------------------------------------- /target-inc/_ansi.h: -------------------------------------------------------------------------------- 1 | /* Provide support for both ANSI and non-ANSI environments. */ 2 | 3 | /* Some ANSI environments are "broken" in the sense that __STDC__ cannot be 4 | relied upon to have it's intended meaning. Therefore we must use our own 5 | concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib 6 | sources! 7 | 8 | To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will 9 | "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header 10 | files aren't affected). */ 11 | 12 | #ifndef _ANSIDECL_H_ 13 | #define _ANSIDECL_H_ 14 | 15 | #include 16 | 17 | /* First try to figure out whether we really are in an ANSI C environment. */ 18 | /* FIXME: This probably needs some work. Perhaps sys/config.h can be 19 | prevailed upon to give us a clue. */ 20 | 21 | #ifdef __STDC__ 22 | #define _HAVE_STDC 23 | #endif 24 | 25 | #ifdef _HAVE_STDC 26 | #define _PTR void * 27 | #define _AND , 28 | #define _NOARGS void 29 | #define _CONST const 30 | #define _VOLATILE volatile 31 | #define _SIGNED signed 32 | #define _DOTS , ... 33 | #define _VOID void 34 | #define _EXFUN(name, proto) name proto 35 | #define _DEFUN(name, arglist, args) name(args) 36 | #define _DEFUN_VOID(name) name(_NOARGS) 37 | #define _CAST_VOID (void) 38 | #ifndef _LONG_DOUBLE 39 | #define _LONG_DOUBLE long double 40 | #endif 41 | #ifndef _PARAMS 42 | #define _PARAMS(paramlist) paramlist 43 | #endif 44 | #else 45 | #define _PTR char * 46 | #define _AND ; 47 | #define _NOARGS 48 | #define _CONST 49 | #define _VOLATILE 50 | #define _SIGNED 51 | #define _DOTS 52 | #define _VOID void 53 | #define _EXFUN(name, proto) name() 54 | #define _DEFUN(name, arglist, args) name arglist args; 55 | #define _DEFUN_VOID(name) name() 56 | #define _CAST_VOID 57 | #define _LONG_DOUBLE double 58 | #ifndef _PARAMS 59 | #define _PARAMS(paramlist) () 60 | #endif 61 | #endif 62 | 63 | /* Support gcc's __attribute__ facility. */ 64 | 65 | #ifdef __GNUC__ 66 | #define _ATTRIBUTE(attrs) __attribute__ (attrs) 67 | #else 68 | #define _ATTRIBUTE(attrs) 69 | #endif 70 | 71 | #endif /* _ANSIDECL_H_ */ 72 | -------------------------------------------------------------------------------- /target-inc/_syslist.h: -------------------------------------------------------------------------------- 1 | /* internal use only -- mapping of "system calls" for libraries that lose 2 | and only provide C names, so that we end up in violation of ANSI */ 3 | #ifndef __SYSLIST_H 4 | #define __SYSLIST_H 5 | #ifdef MISSING_SYSCALL_NAMES 6 | #define _close close 7 | #define _execve execve 8 | #define _fcntl fcntl 9 | #define _fork fork 10 | #define _fstat fstat 11 | #define _getpid getpid 12 | #define _gettimeofday gettimeofday 13 | #define _kill kill 14 | #define _link link 15 | #define _lseek lseek 16 | #define _open open 17 | #define _read read 18 | #define _sbrk sbrk 19 | #define _stat stat 20 | #define _times times 21 | #define _unlink unlink 22 | #define _wait wait 23 | #define _write write 24 | /* functions not yet sysfaked */ 25 | #define _opendir opendir 26 | #define _readdir readdir 27 | #define _closedir closedir 28 | #endif 29 | #endif 30 | -------------------------------------------------------------------------------- /target-inc/ar.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1991, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * (c) UNIX System Laboratories, Inc. 7 | * All or some portions of this file are derived from material licensed 8 | * to the University of California by American Telephone and Telegraph 9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with 10 | * the permission of UNIX System Laboratories, Inc. 11 | * 12 | * This code is derived from software contributed to Berkeley by 13 | * Hugh Smith at The University of Guelph. 14 | * 15 | * Redistribution and use in source and binary forms, with or without 16 | * modification, are permitted provided that the following conditions 17 | * are met: 18 | * 1. Redistributions of source code must retain the above copyright 19 | * notice, this list of conditions and the following disclaimer. 20 | * 2. Redistributions in binary form must reproduce the above copyright 21 | * notice, this list of conditions and the following disclaimer in the 22 | * documentation and/or other materials provided with the distribution. 23 | * 3. All advertising materials mentioning features or use of this software 24 | * must display the following acknowledgement: 25 | * This product includes software developed by the University of 26 | * California, Berkeley and its contributors. 27 | * 4. Neither the name of the University nor the names of its contributors 28 | * may be used to endorse or promote products derived from this software 29 | * without specific prior written permission. 30 | * 31 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 32 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 33 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 34 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 35 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 39 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 40 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 41 | * SUCH DAMAGE. 42 | * 43 | * @(#)ar.h 8.2 (Berkeley) 1/21/94 44 | */ 45 | 46 | #ifndef _AR_H_ 47 | #define _AR_H_ 48 | 49 | /* Pre-4BSD archives had these magic numbers in them. */ 50 | #define OARMAG1 0177555 51 | #define OARMAG2 0177545 52 | 53 | #define ARMAG "!\n" /* ar "magic number" */ 54 | #define SARMAG 8 /* strlen(ARMAG); */ 55 | 56 | #define AR_EFMT1 "#1/" /* extended format #1 */ 57 | 58 | struct ar_hdr { 59 | char ar_name[16]; /* name */ 60 | char ar_date[12]; /* modification time */ 61 | char ar_uid[6]; /* user id */ 62 | char ar_gid[6]; /* group id */ 63 | char ar_mode[8]; /* octal file permissions */ 64 | char ar_size[10]; /* size in bytes */ 65 | #define ARFMAG "`\n" 66 | char ar_fmag[2]; /* consistency check */ 67 | }; 68 | 69 | #endif /* !_AR_H_ */ 70 | -------------------------------------------------------------------------------- /target-inc/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | assert.h 3 | */ 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #include "_ansi.h" 10 | 11 | #undef assert 12 | 13 | #ifdef NDEBUG /* required by ANSI standard */ 14 | #define assert(p) ((void)0) 15 | #else 16 | 17 | #ifdef __STDC__ 18 | #define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e)) 19 | #else /* PCC */ 20 | #define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, "e")) 21 | #endif 22 | 23 | #endif /* NDEBUG */ 24 | 25 | void _EXFUN(__assert,(const char *, int, const char *)); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | -------------------------------------------------------------------------------- /target-inc/ctype.h: -------------------------------------------------------------------------------- 1 | #ifndef _CTYPE_H_ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | #define _CTYPE_H_ 6 | 7 | #include "_ansi.h" 8 | 9 | int _EXFUN(isalnum, (int __c)); 10 | int _EXFUN(isalpha, (int __c)); 11 | int _EXFUN(iscntrl, (int __c)); 12 | int _EXFUN(isdigit, (int __c)); 13 | int _EXFUN(isgraph, (int __c)); 14 | int _EXFUN(islower, (int __c)); 15 | int _EXFUN(isprint, (int __c)); 16 | int _EXFUN(ispunct, (int __c)); 17 | int _EXFUN(isspace, (int __c)); 18 | int _EXFUN(isupper, (int __c)); 19 | int _EXFUN(isxdigit,(int __c)); 20 | int _EXFUN(tolower, (int __c)); 21 | int _EXFUN(toupper, (int __c)); 22 | 23 | #ifndef __STRICT_ANSI__ 24 | int _EXFUN(isascii, (int __c)); 25 | int _EXFUN(toascii, (int __c)); 26 | int _EXFUN(_tolower, (int __c)); 27 | int _EXFUN(_toupper, (int __c)); 28 | #endif 29 | 30 | #define _U 01 31 | #define _L 02 32 | #define _N 04 33 | #define _S 010 34 | #define _P 020 35 | #define _C 040 36 | #define _X 0100 37 | #define _B 0200 38 | 39 | #if !defined(__CYGWIN32__) || defined(__INSIDE_CYGWIN__) || defined(_COMPILING_NEWLIB) 40 | extern _CONST char _ctype_[]; 41 | #else 42 | extern _CONST char _ctype_[] __declspec(dllimport); 43 | #endif 44 | 45 | #define isalpha(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L)) 46 | #define isupper(c) ((_ctype_+1)[(unsigned)(c)]&_U) 47 | #define islower(c) ((_ctype_+1)[(unsigned)(c)]&_L) 48 | #define isdigit(c) ((_ctype_+1)[(unsigned)(c)]&_N) 49 | #define isxdigit(c) ((_ctype_+1)[(unsigned)(c)]&(_X|_N)) 50 | #define isspace(c) ((_ctype_+1)[(unsigned)(c)]&_S) 51 | #define ispunct(c) ((_ctype_+1)[(unsigned)(c)]&_P) 52 | #define isalnum(c) ((_ctype_+1)[(unsigned)(c)]&(_U|_L|_N)) 53 | #define isprint(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N|_B)) 54 | #define isgraph(c) ((_ctype_+1)[(unsigned)(c)]&(_P|_U|_L|_N)) 55 | #define iscntrl(c) ((_ctype_+1)[(unsigned)(c)]&_C) 56 | /* Non-gcc versions will get the library versions, and will be 57 | slightly slower */ 58 | #ifdef __GNUC__ 59 | # define toupper(c) \ 60 | ({ int __x = (c); islower(__x) ? (__x - 'a' + 'A') : __x;}) 61 | # define tolower(c) \ 62 | ({ int __x = (c); isupper(__x) ? (__x - 'A' + 'a') : __x;}) 63 | #endif 64 | 65 | #ifndef __STRICT_ANSI__ 66 | #define isascii(c) ((unsigned)(c)<=0177) 67 | #define toascii(c) ((c)&0177) 68 | #endif 69 | 70 | #ifdef __cplusplus 71 | } 72 | #endif 73 | #endif /* _CTYPE_H_ */ 74 | -------------------------------------------------------------------------------- /target-inc/dirent.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | #include 5 | #ifdef __cplusplus 6 | } 7 | #endif 8 | -------------------------------------------------------------------------------- /target-inc/errno.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /target-inc/fastmath.h: -------------------------------------------------------------------------------- 1 | #ifndef _FASTMATH_H_ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | #define _FASTMATH_H_ 6 | 7 | #include 8 | #include 9 | 10 | #ifdef __cplusplus 11 | } 12 | #endif 13 | #endif /* _FASTMATH_H_ */ 14 | -------------------------------------------------------------------------------- /target-inc/fcntl.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /target-inc/grp.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: grp.h,v 1.7 1995/04/29 05:30:40 cgd Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1989, 1993 5 | * The Regents of the University of California. All rights reserved. 6 | * (c) UNIX System Laboratories, Inc. 7 | * All or some portions of this file are derived from material licensed 8 | * to the University of California by American Telephone and Telegraph 9 | * Co. or Unix System Laboratories, Inc. and are reproduced herein with 10 | * the permission of UNIX System Laboratories, Inc. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * @(#)grp.h 8.2 (Berkeley) 1/21/94 41 | */ 42 | 43 | #ifndef _GRP_H_ 44 | #define _GRP_H_ 45 | 46 | #include 47 | 48 | #if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) 49 | #define _PATH_GROUP "/etc/group" 50 | #endif 51 | 52 | struct group { 53 | char *gr_name; /* group name */ 54 | char *gr_passwd; /* group password */ 55 | gid_t gr_gid; /* group id */ 56 | char **gr_mem; /* group members */ 57 | }; 58 | 59 | 60 | #ifdef __cplusplus 61 | extern "C" { 62 | #endif 63 | 64 | struct group *getgrgid (gid_t); 65 | struct group *getgrnam (const char *); 66 | int getgrnam_r (const char *, struct group *, 67 | char *, size_t, struct group **); 68 | int getgrgid_r (gid_t, struct group *, 69 | char *, size_t, struct group **); 70 | #ifndef _POSIX_SOURCE 71 | struct group *getgrent (void); 72 | void setgrent (void); 73 | void endgrent (void); 74 | void setgrfile (const char *); 75 | #ifndef _XOPEN_SOURCE 76 | char *group_from_gid (gid_t, int); 77 | int setgroupent (int); 78 | #endif /* !_XOPEN_SOURCE */ 79 | #endif /* !_POSIX_SOURCE */ 80 | 81 | #ifdef __cplusplus 82 | } 83 | #endif 84 | 85 | #endif /* !_GRP_H_ */ 86 | -------------------------------------------------------------------------------- /target-inc/ieeefp.h: -------------------------------------------------------------------------------- 1 | #ifndef _IEEE_FP_H_ 2 | #define _IEEE_FP_H_ 3 | 4 | #include "_ansi.h" 5 | 6 | #include 7 | 8 | /* FIXME FIXME FIXME: 9 | Neither of __ieee_{float,double}_shape_tape seem to be used anywhere 10 | except in libm/test. If that is the case, please delete these from here. 11 | If that is not the case, please insert documentation here describing why 12 | they're needed. */ 13 | 14 | #ifdef __IEEE_BIG_ENDIAN 15 | 16 | typedef union 17 | { 18 | double value; 19 | struct { 20 | unsigned int sign : 1; 21 | unsigned int exponent: 11; 22 | unsigned int fraction0:4; 23 | unsigned int fraction1:16; 24 | unsigned int fraction2:16; 25 | unsigned int fraction3:16; 26 | } number; 27 | struct { 28 | unsigned int sign : 1; 29 | unsigned int exponent: 11; 30 | unsigned int quiet:1; 31 | unsigned int function0:3; 32 | unsigned int function1:16; 33 | unsigned int function2:16; 34 | unsigned int function3:16; 35 | } nan; 36 | struct { 37 | unsigned long msw; 38 | unsigned long lsw; 39 | } parts; 40 | long aslong[2]; 41 | } __ieee_double_shape_type; 42 | 43 | #endif 44 | 45 | #ifdef __IEEE_LITTLE_ENDIAN 46 | 47 | typedef union 48 | { 49 | double value; 50 | struct { 51 | #ifdef __SMALL_BITFIELDS 52 | unsigned int fraction3:16; 53 | unsigned int fraction2:16; 54 | unsigned int fraction1:16; 55 | unsigned int fraction0: 4; 56 | #else 57 | unsigned int fraction1:32; 58 | unsigned int fraction0:20; 59 | #endif 60 | unsigned int exponent :11; 61 | unsigned int sign : 1; 62 | } number; 63 | struct { 64 | #ifdef __SMALL_BITFIELDS 65 | unsigned int function3:16; 66 | unsigned int function2:16; 67 | unsigned int function1:16; 68 | unsigned int function0:3; 69 | #else 70 | unsigned int function1:32; 71 | unsigned int function0:19; 72 | #endif 73 | unsigned int quiet:1; 74 | unsigned int exponent: 11; 75 | unsigned int sign : 1; 76 | } nan; 77 | struct { 78 | unsigned long lsw; 79 | unsigned long msw; 80 | } parts; 81 | 82 | long aslong[2]; 83 | } __ieee_double_shape_type; 84 | 85 | #endif 86 | 87 | #ifdef __IEEE_BIG_ENDIAN 88 | 89 | typedef union 90 | { 91 | float value; 92 | struct { 93 | unsigned int sign : 1; 94 | unsigned int exponent: 8; 95 | unsigned int fraction0: 7; 96 | unsigned int fraction1: 16; 97 | } number; 98 | struct { 99 | unsigned int sign:1; 100 | unsigned int exponent:8; 101 | unsigned int quiet:1; 102 | unsigned int function0:6; 103 | unsigned int function1:16; 104 | } nan; 105 | long p1; 106 | } __ieee_float_shape_type; 107 | 108 | #endif 109 | 110 | #ifdef __IEEE_LITTLE_ENDIAN 111 | 112 | typedef union 113 | { 114 | float value; 115 | struct { 116 | unsigned int fraction0: 7; 117 | unsigned int fraction1: 16; 118 | unsigned int exponent: 8; 119 | unsigned int sign : 1; 120 | } number; 121 | struct { 122 | unsigned int function1:16; 123 | unsigned int function0:6; 124 | unsigned int quiet:1; 125 | unsigned int exponent:8; 126 | unsigned int sign:1; 127 | } nan; 128 | long p1; 129 | } __ieee_float_shape_type; 130 | 131 | #endif 132 | 133 | /* FLOATING ROUNDING */ 134 | 135 | typedef int fp_rnd; 136 | #define FP_RN 0 /* Round to nearest */ 137 | #define FP_RM 1 /* Round down */ 138 | #define FP_RP 2 /* Round up */ 139 | #define FP_RZ 3 /* Round to zero (trunate) */ 140 | 141 | fp_rnd _EXFUN(fpgetround,(void)); 142 | fp_rnd _EXFUN(fpsetround, (fp_rnd)); 143 | 144 | /* EXCEPTIONS */ 145 | 146 | typedef int fp_except; 147 | #define FP_X_INV 0x10 /* Invalid operation */ 148 | #define FP_X_DX 0x80 /* Divide by zero */ 149 | #define FP_X_OFL 0x04 /* Overflow exception */ 150 | #define FP_X_UFL 0x02 /* Underflow exception */ 151 | #define FP_X_IMP 0x01 /* imprecise exception */ 152 | 153 | fp_except _EXFUN(fpgetmask,(void)); 154 | fp_except _EXFUN(fpsetmask,(fp_except)); 155 | fp_except _EXFUN(fpgetsticky,(void)); 156 | fp_except _EXFUN(fpsetsticky, (fp_except)); 157 | 158 | /* INTEGER ROUNDING */ 159 | 160 | typedef int fp_rdi; 161 | #define FP_RDI_TOZ 0 /* Round to Zero */ 162 | #define FP_RDI_RD 1 /* Follow float mode */ 163 | 164 | fp_rdi _EXFUN(fpgetroundtoi,(void)); 165 | fp_rdi _EXFUN(fpsetroundtoi,(fp_rdi)); 166 | 167 | int _EXFUN(isnan, (double)); 168 | int _EXFUN(isinf, (double)); 169 | int _EXFUN(finite, (double)); 170 | int _EXFUN(isnanf, (float)); 171 | int _EXFUN(isinff, (float)); 172 | int _EXFUN(finitef, (float)); 173 | 174 | #define __IEEE_DBL_EXPBIAS 1023 175 | #define __IEEE_FLT_EXPBIAS 127 176 | 177 | #define __IEEE_DBL_EXPLEN 11 178 | #define __IEEE_FLT_EXPLEN 8 179 | 180 | 181 | #define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1)) 182 | #define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1)) 183 | 184 | #define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1)) 185 | #define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1)) 186 | 187 | #define __IEEE_DBL_NAN_EXP 0x7ff 188 | #define __IEEE_FLT_NAN_EXP 0xff 189 | 190 | 191 | #define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ 192 | ((*(long *)&(x) & 0x007fffffL)!=0000000000L)) 193 | 194 | #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \ 195 | ((*(long *)&(x) & 0x007fffffL)==0000000000L)) 196 | 197 | #define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L)) 198 | 199 | #ifdef _DOUBLE_IS_32BITS 200 | #undef __IEEE_DBL_EXPBIAS 201 | #define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS 202 | 203 | #undef __IEEE_DBL_EXPLEN 204 | #define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN 205 | 206 | #undef __IEEE_DBL_FRACLEN 207 | #define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN 208 | 209 | #undef __IEEE_DBL_MAXPOWTWO 210 | #define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO 211 | 212 | #undef __IEEE_DBL_NAN_EXP 213 | #define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP 214 | 215 | #undef __ieee_double_shape_type 216 | #define __ieee_double_shape_type __ieee_float_shape_type 217 | 218 | #endif /* _DOUBLE_IS_32BITS */ 219 | 220 | #endif /* _IEEE_FP_H_ */ 221 | -------------------------------------------------------------------------------- /target-inc/locale.h: -------------------------------------------------------------------------------- 1 | /* 2 | locale.h 3 | Values appropriate for the formatting of monetary and other 4 | numberic quantities. 5 | */ 6 | 7 | #ifndef _LOCALE_H_ 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | #define _LOCALE_H_ 12 | 13 | #include "_ansi.h" 14 | 15 | #ifndef NULL 16 | #define NULL 0L 17 | #endif 18 | 19 | #define LC_ALL 0 20 | #define LC_COLLATE 1 21 | #define LC_CTYPE 2 22 | #define LC_MONETARY 3 23 | #define LC_NUMERIC 4 24 | #define LC_TIME 5 25 | 26 | struct lconv { 27 | char *decimal_point; 28 | char *thousands_sep; 29 | char *grouping; 30 | char *int_curr_symbol; 31 | char *currency_symbol; 32 | char *mon_decimal_point; 33 | char *mon_thousands_sep; 34 | char *mon_grouping; 35 | char *positive_sign; 36 | char *negative_sign; 37 | char int_frac_digits; 38 | char frac_digits; 39 | char p_cs_precedes; 40 | char p_sep_by_space; 41 | char n_cs_precedes; 42 | char n_sep_by_space; 43 | char p_sign_posn; 44 | char n_sign_posn; 45 | }; 46 | 47 | #ifndef _REENT_ONLY 48 | char *_EXFUN(setlocale,(int category, const char *locale)); 49 | struct lconv *_EXFUN(localeconv,(void)); 50 | #endif 51 | 52 | struct _reent; 53 | char *_EXFUN(_setlocale_r,(struct _reent *, int category, const char *locale)); 54 | struct lconv *_EXFUN(_localeconv_r,(struct _reent *)); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #endif /* _LOCALE_H_ */ 60 | -------------------------------------------------------------------------------- /target-inc/machine/fastmath.h: -------------------------------------------------------------------------------- 1 | #ifdef __sysvnecv70_target 2 | double EXFUN(fast_sin,(double)); 3 | double EXFUN(fast_cos,(double)); 4 | double EXFUN(fast_tan,(double)); 5 | 6 | double EXFUN(fast_asin,(double)); 7 | double EXFUN(fast_acos,(double)); 8 | double EXFUN(fast_atan,(double)); 9 | 10 | double EXFUN(fast_sinh,(double)); 11 | double EXFUN(fast_cosh,(double)); 12 | double EXFUN(fast_tanh,(double)); 13 | 14 | double EXFUN(fast_asinh,(double)); 15 | double EXFUN(fast_acosh,(double)); 16 | double EXFUN(fast_atanh,(double)); 17 | 18 | double EXFUN(fast_abs,(double)); 19 | double EXFUN(fast_sqrt,(double)); 20 | double EXFUN(fast_exp2,(double)); 21 | double EXFUN(fast_exp10,(double)); 22 | double EXFUN(fast_expe,(double)); 23 | double EXFUN(fast_log10,(double)); 24 | double EXFUN(fast_log2,(double)); 25 | double EXFUN(fast_loge,(double)); 26 | 27 | 28 | #define sin(x) fast_sin(x) 29 | #define cos(x) fast_cos(x) 30 | #define tan(x) fast_tan(x) 31 | #define asin(x) fast_asin(x) 32 | #define acos(x) fast_acos(x) 33 | #define atan(x) fast_atan(x) 34 | #define sinh(x) fast_sinh(x) 35 | #define cosh(x) fast_cosh(x) 36 | #define tanh(x) fast_tanh(x) 37 | #define asinh(x) fast_asinh(x) 38 | #define acosh(x) fast_acosh(x) 39 | #define atanh(x) fast_atanh(x) 40 | #define abs(x) fast_abs(x) 41 | #define sqrt(x) fast_sqrt(x) 42 | #define exp2(x) fast_exp2(x) 43 | #define exp10(x) fast_exp10(x) 44 | #define expe(x) fast_expe(x) 45 | #define log10(x) fast_log10(x) 46 | #define log2(x) fast_log2(x) 47 | #define loge(x) fast_loge(x) 48 | 49 | #ifdef _HAVE_STDC 50 | /* These functions are in assembler, they really do take floats. This 51 | can only be used with a real ANSI compiler */ 52 | 53 | float EXFUN(fast_sinf,(float)); 54 | float EXFUN(fast_cosf,(float)); 55 | float EXFUN(fast_tanf,(float)); 56 | 57 | float EXFUN(fast_asinf,(float)); 58 | float EXFUN(fast_acosf,(float)); 59 | float EXFUN(fast_atanf,(float)); 60 | 61 | float EXFUN(fast_sinhf,(float)); 62 | float EXFUN(fast_coshf,(float)); 63 | float EXFUN(fast_tanhf,(float)); 64 | 65 | float EXFUN(fast_asinhf,(float)); 66 | float EXFUN(fast_acoshf,(float)); 67 | float EXFUN(fast_atanhf,(float)); 68 | 69 | float EXFUN(fast_absf,(float)); 70 | float EXFUN(fast_sqrtf,(float)); 71 | float EXFUN(fast_exp2f,(float)); 72 | float EXFUN(fast_exp10f,(float)); 73 | float EXFUN(fast_expef,(float)); 74 | float EXFUN(fast_log10f,(float)); 75 | float EXFUN(fast_log2f,(float)); 76 | float EXFUN(fast_logef,(float)); 77 | #define sinf(x) fast_sinf(x) 78 | #define cosf(x) fast_cosf(x) 79 | #define tanf(x) fast_tanf(x) 80 | #define asinf(x) fast_asinf(x) 81 | #define acosf(x) fast_acosf(x) 82 | #define atanf(x) fast_atanf(x) 83 | #define sinhf(x) fast_sinhf(x) 84 | #define coshf(x) fast_coshf(x) 85 | #define tanhf(x) fast_tanhf(x) 86 | #define asinhf(x) fast_asinhf(x) 87 | #define acoshf(x) fast_acoshf(x) 88 | #define atanhf(x) fast_atanhf(x) 89 | #define absf(x) fast_absf(x) 90 | #define sqrtf(x) fast_sqrtf(x) 91 | #define exp2f(x) fast_exp2f(x) 92 | #define exp10f(x) fast_exp10f(x) 93 | #define expef(x) fast_expef(x) 94 | #define log10f(x) fast_log10f(x) 95 | #define log2f(x) fast_log2f(x) 96 | #define logef(x) fast_logef(x) 97 | #endif 98 | /* Override the functions defined in math.h */ 99 | #endif /* __sysvnecv70_target */ 100 | -------------------------------------------------------------------------------- /target-inc/machine/ieeefp.h: -------------------------------------------------------------------------------- 1 | #ifndef __IEEE_BIG_ENDIAN 2 | #ifndef __IEEE_LITTLE_ENDIAN 3 | 4 | #if defined(__arm__) || defined(__thumb__) 5 | /* ARM always has big-endian words. Within those words the byte ordering 6 | appears to be big or little endian. Newlib doesn't seem to care about 7 | the byte ordering within words. */ 8 | #define __IEEE_BIG_ENDIAN 9 | #endif 10 | 11 | #ifdef __hppa__ 12 | #define __IEEE_BIG_ENDIAN 13 | #endif 14 | 15 | #ifdef __sparc__ 16 | #ifdef __LITTLE_ENDIAN_DATA__ 17 | #define __IEEE_LITTLE_ENDIAN 18 | #else 19 | #define __IEEE_BIG_ENDIAN 20 | #endif 21 | #endif 22 | 23 | #if defined(__m68k__) || defined(__mc68000__) 24 | #define __IEEE_BIG_ENDIAN 25 | #endif 26 | 27 | #if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) 28 | #define __IEEE_BIG_ENDIAN 29 | #define __SMALL_BITFIELDS 30 | #define _DOUBLE_IS_32BITS 31 | #endif 32 | 33 | #ifdef __H8500__ 34 | #define __IEEE_BIG_ENDIAN 35 | #define __SMALL_BITFIELDS 36 | #define _DOUBLE_IS_32BITS 37 | #endif 38 | 39 | #ifdef __sh__ 40 | #ifdef __LITTLE_ENDIAN__ 41 | #define __IEEE_LITTLE_ENDIAN 42 | #else 43 | #define __IEEE_BIG_ENDIAN 44 | #endif 45 | #if defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) 46 | #define _DOUBLE_IS_32BITS 47 | #endif 48 | #endif 49 | 50 | #ifdef _AM29K 51 | #define __IEEE_BIG_ENDIAN 52 | #endif 53 | 54 | #ifdef _WIN32 55 | #define __IEEE_LITTLE_ENDIAN 56 | #endif 57 | 58 | #ifdef __i386__ 59 | #define __IEEE_LITTLE_ENDIAN 60 | #endif 61 | 62 | #ifdef __i960__ 63 | #define __IEEE_LITTLE_ENDIAN 64 | #endif 65 | 66 | #ifdef __M32R__ 67 | #define __IEEE_BIG_ENDIAN 68 | #endif 69 | 70 | #ifdef __TIC80__ 71 | #define __IEEE_LITTLE_ENDIAN 72 | #endif 73 | 74 | #ifdef __MIPSEL__ 75 | #define __IEEE_LITTLE_ENDIAN 76 | #endif 77 | #ifdef __MIPSEB__ 78 | #define __IEEE_BIG_ENDIAN 79 | #endif 80 | 81 | /* necv70 was __IEEE_LITTLE_ENDIAN. */ 82 | 83 | #ifdef __W65__ 84 | #define __IEEE_LITTLE_ENDIAN 85 | #define __SMALL_BITFIELDS 86 | #define _DOUBLE_IS_32BITS 87 | #endif 88 | 89 | #if defined(__Z8001__) || defined(__Z8002__) 90 | #define __IEEE_BIG_ENDIAN 91 | #endif 92 | 93 | #ifdef __m88k__ 94 | #define __IEEE_BIG_ENDIAN 95 | #endif 96 | 97 | #ifdef __mn10300__ 98 | #define __IEEE_LITTLE_ENDIAN 99 | #endif 100 | 101 | #ifdef __mn10200__ 102 | #define __IEEE_LITTLE_ENDIAN 103 | #define __SMALL_BITFIELDS 104 | #define _DOUBLE_IS_32BITS 105 | #endif 106 | 107 | #ifdef __v800 108 | #define __IEEE_LITTLE_ENDIAN 109 | #endif 110 | 111 | #ifdef __v850 112 | #define __IEEE_LITTLE_ENDIAN 113 | #endif 114 | 115 | #ifdef __D10V__ 116 | #define __IEEE_BIG_ENDIAN 117 | #define _DOUBLE_IS_32BITS 118 | #define __SMALL_BITFIELDS 119 | #endif 120 | 121 | #ifdef __PPC__ 122 | #if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX) 123 | #define __IEEE_BIG_ENDIAN 124 | #else 125 | #if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32) 126 | #define __IEEE_LITTLE_ENDIAN 127 | #endif 128 | #endif 129 | #endif 130 | 131 | #ifdef __arc__ 132 | #ifdef __big_endian__ 133 | #define __IEEE_BIG_ENDIAN 134 | #else 135 | #define __IEEE_LITTLE_ENDIAN 136 | #endif 137 | #endif 138 | 139 | #ifdef __fr30__ 140 | #define __IEEE_BIG_ENDIAN 141 | #endif 142 | 143 | #ifdef __mcore__ 144 | #define __IEEE_BIG_ENDIAN 145 | #endif 146 | 147 | 148 | 149 | #ifndef __IEEE_BIG_ENDIAN 150 | #ifndef __IEEE_LITTLE_ENDIAN 151 | #error Endianess not declared!! 152 | #endif /* not __IEEE_LITTLE_ENDIAN */ 153 | #endif /* not __IEEE_BIG_ENDIAN */ 154 | 155 | #endif /* not __IEEE_LITTLE_ENDIAN */ 156 | #endif /* not __IEEE_BIG_ENDIAN */ 157 | 158 | -------------------------------------------------------------------------------- /target-inc/machine/setjmp-dj.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 3 | ** 4 | ** This file is distributed under the terms listed in the document 5 | ** "copying.dj", available from DJ Delorie at the address above. 6 | ** A copy of "copying.dj" should accompany this file; if not, a copy 7 | ** should be available from where this file was obtained. This file 8 | ** may not be distributed without a verbatim copy of "copying.dj". 9 | ** 10 | ** This file is distributed WITHOUT ANY WARRANTY; without even the implied 11 | ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | */ 13 | 14 | /* Modified to use SETJMP_DJ_H rather than SETJMP_H to avoid 15 | conflicting with setjmp.h. Ian Taylor, Cygnus support, April, 16 | 1993. */ 17 | 18 | #ifndef _SETJMP_DJ_H_ 19 | #define _SETJMP_DJ_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | typedef struct { 26 | unsigned long eax; 27 | unsigned long ebx; 28 | unsigned long ecx; 29 | unsigned long edx; 30 | unsigned long esi; 31 | unsigned long edi; 32 | unsigned long ebp; 33 | unsigned long esp; 34 | unsigned long eip; 35 | } jmp_buf[1]; 36 | 37 | extern int setjmp(jmp_buf); 38 | extern void longjmp(jmp_buf, int); 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /target-inc/machine/setjmp.h: -------------------------------------------------------------------------------- 1 | #if defined(__arm__) || defined(__thumb__) 2 | /* 3 | * All callee preserved registers: 4 | * v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7 5 | */ 6 | #define _JBLEN 23 7 | #endif 8 | 9 | #ifdef __sparc__ 10 | /* 11 | * onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext). 12 | * All else recovered by under/over(flow) handling. 13 | */ 14 | #define _JBLEN 13 15 | #endif 16 | 17 | /* necv70 was 9 as well. */ 18 | 19 | #ifdef __mc68000__ 20 | /* 21 | * onsstack,sigmask,sp,pc,psl,d2-d7,a2-a6, 22 | * fp2-fp7 for 68881. 23 | * All else recovered by under/over(flow) handling. 24 | */ 25 | #define _JBLEN 34 26 | #endif 27 | 28 | #if defined(__Z8001__) || defined(__Z8002__) 29 | /* 16 regs + pc */ 30 | #define _JBLEN 20 31 | #endif 32 | 33 | #ifdef _AM29K 34 | /* 35 | * onsstack,sigmask,sp,pc,npc,psr,g1,o0,wbcnt (sigcontext). 36 | * All else recovered by under/over(flow) handling. 37 | */ 38 | #define _JBLEN 9 39 | #endif 40 | 41 | #if defined(__CYGWIN__) && !defined (_JBLEN) 42 | #define _JBLEN (13 * 4) 43 | #elif defined (__i386__) 44 | #ifdef __unix__ 45 | # define _JBLEN 36 46 | #else 47 | #include "setjmp-dj.h" 48 | #endif 49 | #endif 50 | 51 | #ifdef __i960__ 52 | #define _JBLEN 35 53 | #endif 54 | 55 | #ifdef __M32R__ 56 | /* Only 8 words are currently needed. 10 gives us some slop if we need 57 | to expand. */ 58 | #define _JBLEN 10 59 | #endif 60 | 61 | #ifdef __mips__ 62 | #define _JBLEN 11 63 | #endif 64 | 65 | #ifdef __m88000__ 66 | #define _JBLEN 21 67 | #endif 68 | 69 | #ifdef __H8300__ 70 | #define _JBLEN 5 71 | typedef int jmp_buf[_JBLEN]; 72 | #endif 73 | 74 | #ifdef __H8300H__ 75 | /* same as H8/300 but registers are twice as big */ 76 | #define _JBLEN 5 77 | #define _JBTYPE long 78 | #endif 79 | 80 | #ifdef __H8300S__ 81 | /* same as H8/300 but registers are twice as big */ 82 | #define _JBLEN 5 83 | #define _JBTYPE long 84 | #endif 85 | 86 | #ifdef __H8500__ 87 | #define _JBLEN 4 88 | #endif 89 | 90 | #ifdef __sh__ 91 | #define _JBLEN 20 92 | #endif 93 | 94 | #ifdef __v800 95 | #define _JBLEN 28 96 | #endif 97 | 98 | #ifdef __PPC__ 99 | #define _JBLEN 32 100 | #define _JBTYPE double 101 | #endif 102 | 103 | #ifdef __hppa__ 104 | /* %r30, %r2-%r18, %r27, pad, %fr12-%fr15. 105 | Note space exists for the FP registers, but they are not 106 | saved. */ 107 | #define _JBLEN 28 108 | #endif 109 | 110 | #if defined(__mn10300__) || defined(__mn10200__) 111 | /* A guess */ 112 | #define _JBLEN 10 113 | #endif 114 | 115 | #ifdef __v850 116 | /* I think our setjmp is saving 15 regs at the moment. Gives us one word 117 | slop if we need to expand. */ 118 | #define _JBLEN 16 119 | #endif 120 | 121 | #ifdef __TIC80__ 122 | #define _JBLEN 13 123 | #endif 124 | 125 | #ifdef __D10V__ 126 | #define _JBLEN 8 127 | #endif 128 | 129 | #ifdef __D30V__ 130 | #define _JBLEN ((64 /* GPR */ + (2*2) /* ACs */ + 18 /* CRs */) / 2) 131 | #define _JBTYPE double 132 | #endif 133 | 134 | 135 | #ifdef __fr30__ 136 | #define _JBLEN 10 137 | #endif 138 | 139 | #ifdef __mcore__ 140 | #define _JBLEN 16 141 | #endif 142 | 143 | #ifdef _JBLEN 144 | #ifdef _JBTYPE 145 | typedef _JBTYPE jmp_buf[_JBLEN]; 146 | #else 147 | typedef int jmp_buf[_JBLEN]; 148 | #endif 149 | 150 | #if defined(__CYGWIN32__) || defined(__rtems__) 151 | #include 152 | 153 | /* POSIX sigsetjmp/siglongjmp macros */ 154 | typedef int sigjmp_buf[_JBLEN+2]; 155 | 156 | #define _SAVEMASK _JBLEN 157 | #define _SIGMASK (_JBLEN+1) 158 | 159 | #define sigsetjmp(env, savemask) (env[_SAVEMASK] = savemask,\ 160 | sigprocmask (SIG_SETMASK, 0, (sigset_t *) &env[_SIGMASK]),\ 161 | setjmp (env)) 162 | 163 | #define siglongjmp(env, val) (((env[_SAVEMASK])?\ 164 | sigprocmask (SIG_SETMASK, (sigset_t *) &env[_SIGMASK], 0):0),\ 165 | longjmp (env, val)) 166 | 167 | #endif /* __CYGWIN32__ or __rtems__ */ 168 | #endif 169 | -------------------------------------------------------------------------------- /target-inc/machine/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACHTIME_H_ 2 | #define _MACHTIME_H_ 3 | 4 | #if defined(__arm__) || defined(__thumb__) 5 | #define _CLOCKS_PER_SEC_ 100 6 | #endif 7 | 8 | #endif /* _MACHTIME_H_ */ 9 | 10 | 11 | -------------------------------------------------------------------------------- /target-inc/machine/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACHTYPES_H_ 2 | #define _MACHTYPES_H_ 3 | 4 | #define _CLOCK_T_ unsigned long /* clock() */ 5 | #define _TIME_T_ long /* time() */ 6 | 7 | #endif /* _MACHTYPES_H_ */ 8 | 9 | 10 | -------------------------------------------------------------------------------- /target-inc/malloc.h: -------------------------------------------------------------------------------- 1 | /* malloc.h -- header file for memory routines. */ 2 | 3 | #ifndef _INCLUDE_MALLOC_H_ 4 | #define _INCLUDE_MALLOC_H_ 5 | 6 | #include <_ansi.h> 7 | #include 8 | 9 | #define __need_size_t 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /* This version of struct mallinfo must match the one in 17 | libc/stdlib/mallocr.c. */ 18 | 19 | struct mallinfo { 20 | int arena; /* total space allocated from system */ 21 | int ordblks; /* number of non-inuse chunks */ 22 | int smblks; /* unused -- always zero */ 23 | int hblks; /* number of mmapped regions */ 24 | int hblkhd; /* total space in mmapped regions */ 25 | int usmblks; /* unused -- always zero */ 26 | int fsmblks; /* unused -- always zero */ 27 | int uordblks; /* total allocated space */ 28 | int fordblks; /* total non-inuse space */ 29 | int keepcost; /* top-most, releasable (via malloc_trim) space */ 30 | }; 31 | 32 | /* The routines. */ 33 | 34 | extern _PTR malloc _PARAMS ((size_t)); 35 | extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t)); 36 | 37 | extern _VOID free _PARAMS ((_PTR)); 38 | extern _VOID _free_r _PARAMS ((struct _reent *, _PTR)); 39 | 40 | extern _PTR realloc _PARAMS ((_PTR, size_t)); 41 | extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t)); 42 | 43 | extern _PTR calloc _PARAMS ((size_t, size_t)); 44 | extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t)); 45 | 46 | extern _PTR memalign _PARAMS ((size_t, size_t)); 47 | extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t)); 48 | 49 | extern struct mallinfo mallinfo _PARAMS ((void)); 50 | extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *)); 51 | 52 | extern void malloc_stats _PARAMS ((void)); 53 | extern void _malloc_stats_r _PARAMS ((struct _reent *)); 54 | 55 | extern int mallopt _PARAMS ((int, int)); 56 | extern int _mallopt_r _PARAMS ((struct _reent *, int, int)); 57 | 58 | extern size_t malloc_usable_size _PARAMS ((_PTR)); 59 | extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR)); 60 | 61 | /* These aren't too useful on an embedded system, but we define them 62 | anyhow. */ 63 | 64 | extern _PTR valloc _PARAMS ((size_t)); 65 | extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t)); 66 | 67 | extern _PTR pvalloc _PARAMS ((size_t)); 68 | extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t)); 69 | 70 | extern int malloc_trim _PARAMS ((size_t)); 71 | extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t)); 72 | 73 | /* Some systems provide this, so do too for compatibility. */ 74 | 75 | extern void cfree _PARAMS ((_PTR)); 76 | 77 | /* A compatibility routine for an earlier version of the allocator. */ 78 | 79 | extern _VOID mstats _PARAMS ((char *)); 80 | extern _VOID _mstats_r _PARAMS ((struct _reent *, char *)); 81 | 82 | #ifdef __CYGWIN32__ 83 | 84 | /* Cygwin32 needs to be able to copy all the malloc information from 85 | the parent to the child. However, cygwin32 does not normally copy 86 | any data in the DLL data section. This routine handles copying 87 | that information. */ 88 | 89 | extern int __malloc_copy _PARAMS ((int (*) (void *, void *, void *, int), 90 | void *, int)); 91 | #endif /* __CYGWIN32 */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* _INCLUDE_MALLOC_H_ */ 98 | -------------------------------------------------------------------------------- /target-inc/paths.h: -------------------------------------------------------------------------------- 1 | #ifndef _PATHS_H_ 2 | #define _PATHS_H_ 3 | 4 | #define _PATH_DEV "/dev/" 5 | #define _PATH_BSHELL "/bin/sh" 6 | 7 | #endif /* _PATHS_H_ */ 8 | -------------------------------------------------------------------------------- /target-inc/process.h: -------------------------------------------------------------------------------- 1 | /* process.h. This file comes with MSDOS and WIN32 systems. */ 2 | 3 | #ifndef __PROCESS_H_ 4 | #define __PROCESS_H_ 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | int execl(const char *path, const char *argv0, ...); 11 | int execle(const char *path, const char *argv0, ... /*, char * const *envp */); 12 | int execlp(const char *path, const char *argv0, ...); 13 | int execlpe(const char *path, const char *argv0, ... /*, char * const *envp */); 14 | 15 | int execv(const char *path, char * const *argv); 16 | int execve(const char *path, char * const *argv, char * const *envp); 17 | int execvp(const char *path, char * const *argv); 18 | int execvpe(const char *path, char * const *argv, char * const *envp); 19 | 20 | int spawnl(int mode, const char *path, const char *argv0, ...); 21 | int spawnle(int mode, const char *path, const char *argv0, ... /*, char * const *envp */); 22 | int spawnlp(int mode, const char *path, const char *argv0, ...); 23 | int spawnlpe(int mode, const char *path, const char *argv0, ... /*, char * const *envp */); 24 | 25 | int spawnv(int mode, const char *path, const char * const *argv); 26 | int spawnve(int mode, const char *path, char * const *argv, const char * const *envp); 27 | int spawnvp(int mode, const char *path, const char * const *argv); 28 | int spawnvpe(int mode, const char *path, const char * const *argv, const char * const *envp); 29 | 30 | #ifdef __CYGWIN32__ 31 | /* Secure exec() functions family */ 32 | /* The first arg should really be a HANDLE which is a void *. But we 33 | can't include windows.h here so... */ 34 | #include 35 | pid_t sexecl(void *, const char *path, const char *argv0, ...); 36 | pid_t sexecle(void *, const char *path, const char *argv0, ... /*, char * const *envp */); 37 | pid_t sexeclp(void *, const char *path, const char *argv0, ...); 38 | pid_t sexeclpe(void *, const char *path, const char *argv0, ... /*, char * const *envp */); 39 | 40 | pid_t sexecv(void *, const char *path, const char * const *argv); 41 | pid_t sexecve(void *, const char *path, const char * const *argv, const char * const *envp); 42 | pid_t sexecvp(void *, const char *path, const char * const *argv); 43 | pid_t sexecvpe(void *, const char *path, const char * const *argv, const char * const *envp); 44 | #endif 45 | 46 | int cwait(int *, int, int); 47 | 48 | #define _P_WAIT 1 49 | #define _P_NOWAIT 2 /* always generates error */ 50 | #define _P_OVERLAY 3 51 | #define _P_NOWAITO 4 52 | #define _P_DETACH 5 53 | 54 | #define WAIT_CHILD 1 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /target-inc/pwd.h: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 1989 The Regents of the University of California. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. All advertising materials mentioning features or use of this software 14 | * must display the following acknowledgement: 15 | * This product includes software developed by the University of 16 | * California, Berkeley and its contributors. 17 | * 4. Neither the name of the University nor the names of its contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * @(#)pwd.h 5.13 (Berkeley) 5/28/91 34 | */ 35 | 36 | #ifndef _PWD_H_ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | #define _PWD_H_ 41 | 42 | #include 43 | 44 | #ifndef _POSIX_SOURCE 45 | #define _PATH_PASSWD "/etc/passwd" 46 | 47 | #define _PASSWORD_LEN 128 /* max length, not counting NULL */ 48 | #endif 49 | 50 | struct passwd { 51 | char *pw_name; /* user name */ 52 | char *pw_passwd; /* encrypted password */ 53 | int pw_uid; /* user uid */ 54 | int pw_gid; /* user gid */ 55 | char *pw_comment; /* comment */ 56 | char *pw_gecos; /* Honeywell login info */ 57 | char *pw_dir; /* home directory */ 58 | char *pw_shell; /* default shell */ 59 | }; 60 | 61 | struct passwd *getpwuid(uid_t); 62 | struct passwd *getpwnam(const char *); 63 | int getpwnam_r(const char *, struct passwd *, 64 | char *, size_t , struct passwd **); 65 | int getpwuid_r(uid_t, struct passwd *, char *, 66 | size_t, struct passwd **); 67 | #ifndef _POSIX_SOURCE 68 | struct passwd *getpwent(void); 69 | void setpwent(void); 70 | void endpwent(void); 71 | #endif 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | #endif /* _PWD_H_ */ 77 | -------------------------------------------------------------------------------- /target-inc/reent.h: -------------------------------------------------------------------------------- 1 | /* This header file provides the reentrancy. */ 2 | 3 | /* The reentrant system calls here serve two purposes: 4 | 5 | 1) Provide reentrant versions of the system calls the ANSI C library 6 | requires. 7 | 2) Provide these system calls in a namespace clean way. 8 | 9 | It is intended that *all* system calls that the ANSI C library needs 10 | be declared here. It documents them all in one place. All library access 11 | to the system is via some form of these functions. 12 | 13 | There are three ways a target may provide the needed syscalls. 14 | 15 | 1) Define the reentrant versions of the syscalls directly. 16 | (eg: _open_r, _close_r, etc.). Please keep the namespace clean. 17 | When you do this, set "syscall_dir" to "syscalls" in configure.in, 18 | and add -DREENTRANT_SYSCALLS_PROVIDED to target_cflags in configure.in. 19 | 20 | 2) Define namespace clean versions of the system calls by prefixing 21 | them with '_' (eg: _open, _close, etc.). Technically, there won't be 22 | true reentrancy at the syscall level, but the library will be namespace 23 | clean. 24 | When you do this, set "syscall_dir" to "syscalls" in configure.in. 25 | 26 | 3) Define or otherwise provide the regular versions of the syscalls 27 | (eg: open, close, etc.). The library won't be reentrant nor namespace 28 | clean, but at least it will work. 29 | When you do this, add -DMISSING_SYSCALL_NAMES to target_cflags in 30 | configure.in. 31 | 32 | Stubs of the reentrant versions of the syscalls exist in the libc/reent 33 | source directory and are used if REENTRANT_SYSCALLS_PROVIDED isn't defined. 34 | They use the native system calls: _open, _close, etc. if they're available 35 | (MISSING_SYSCALL_NAMES is *not* defined), otherwise open, close, etc. 36 | (MISSING_SYSCALL_NAMES *is* defined). */ 37 | 38 | /* WARNING: All identifiers here must begin with an underscore. This file is 39 | included by stdio.h and others and we therefore must only use identifiers 40 | in the namespace allotted to us. */ 41 | 42 | #ifndef _REENT_H_ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | #define _REENT_H_ 47 | 48 | #include 49 | #include 50 | #include 51 | 52 | #define __need_size_t 53 | #include 54 | 55 | /* FIXME: not namespace clean */ 56 | struct stat; 57 | struct tms; 58 | struct timeval; 59 | struct timezone; 60 | 61 | /* Reentrant versions of system calls. */ 62 | 63 | extern int _close_r _PARAMS ((struct _reent *, int)); 64 | extern int _execve_r _PARAMS ((struct _reent *, char *, char **, char **)); 65 | extern int _fcntl_r _PARAMS ((struct _reent *, int, int, int)); 66 | extern int _fork_r _PARAMS ((struct _reent *)); 67 | extern int _fstat_r _PARAMS ((struct _reent *, int, struct stat *)); 68 | extern int _getpid_r _PARAMS ((struct _reent *)); 69 | extern int _kill_r _PARAMS ((struct _reent *, int, int)); 70 | extern int _link_r _PARAMS ((struct _reent *, const char *, const char *)); 71 | extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int)); 72 | extern int _open_r _PARAMS ((struct _reent *, const char *, int, int)); 73 | extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t)); 74 | extern void *_sbrk_r _PARAMS ((struct _reent *, size_t)); 75 | extern int _stat_r _PARAMS ((struct _reent *, const char *, struct stat *)); 76 | extern _CLOCK_T_ _times_r _PARAMS ((struct _reent *, struct tms *)); 77 | extern int _unlink_r _PARAMS ((struct _reent *, const char *)); 78 | extern int _wait_r _PARAMS ((struct _reent *, int *)); 79 | extern _ssize_t _write_r _PARAMS ((struct _reent *, int, const void *, size_t)); 80 | 81 | /* This one is not guaranteed to be available on all targets. */ 82 | extern int _gettimeofday_r _PARAMS ((struct _reent *, struct timeval *tp, struct timezone *tzp)); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | #endif /* _REENT_H_ */ 88 | -------------------------------------------------------------------------------- /target-inc/regdef.h: -------------------------------------------------------------------------------- 1 | /* regdef.h -- define register names. */ 2 | 3 | /* This is a standard include file for MIPS targets. Other target 4 | probably don't define it, and attempts to include this file will 5 | fail. */ 6 | 7 | #include 8 | -------------------------------------------------------------------------------- /target-inc/setjmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | setjmp.h 3 | stubs for future use. 4 | */ 5 | 6 | #ifndef _SETJMP_H_ 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | #define _SETJMP_H_ 11 | 12 | #include "_ansi.h" 13 | #include 14 | 15 | void _EXFUN(longjmp,(jmp_buf __jmpb, int __retval)); 16 | int _EXFUN(setjmp,(jmp_buf __jmpb)); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif /* _SETJMP_H_ */ 22 | 23 | -------------------------------------------------------------------------------- /target-inc/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIGNAL_H_ 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | #define _SIGNAL_H_ 6 | 7 | #include "_ansi.h" 8 | #include 9 | 10 | typedef int sig_atomic_t; /* Atomic entity type (ANSI) */ 11 | 12 | #if defined(__STDC__) || defined(__cplusplus) 13 | #define SIG_DFL ((void (*)(int))0) /* Default action */ 14 | #define SIG_IGN ((void (*)(int))1) /* Ignore action */ 15 | #define SIG_ERR ((void (*)(int))-1) /* Error return */ 16 | #else 17 | #define SIG_DFL ((void (*)())0) /* Default action */ 18 | #define SIG_IGN ((void (*)())1) /* Ignore action */ 19 | #define SIG_ERR ((void (*)())-1) /* Error return */ 20 | #endif 21 | 22 | typedef void (*_sig_func_ptr) (int); 23 | 24 | struct _reent; 25 | 26 | _sig_func_ptr _EXFUN(_signal_r, (struct _reent *, int, _sig_func_ptr)); 27 | int _EXFUN(_raise_r, (struct _reent *, int)); 28 | 29 | #ifndef _REENT_ONLY 30 | _sig_func_ptr _EXFUN(signal, (int, _sig_func_ptr)); 31 | int _EXFUN(raise, (int)); 32 | #endif 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | #endif /* _SIGNAL_H_ */ 38 | -------------------------------------------------------------------------------- /target-inc/stdlib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * stdlib.h 3 | * 4 | * Definitions for common types, variables, and functions. 5 | */ 6 | 7 | #ifndef _STDLIB_H_ 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | #define _STDLIB_H_ 12 | 13 | #include "_ansi.h" 14 | 15 | #define __need_size_t 16 | #define __need_wchar_t 17 | #include 18 | 19 | #include 20 | 21 | typedef struct { 22 | int quot; /* quotient */ 23 | int rem; /* remainder */ 24 | } div_t; 25 | 26 | typedef struct { 27 | long quot; /* quotient */ 28 | long rem; /* remainder */ 29 | } ldiv_t; 30 | 31 | #ifndef NULL 32 | #define NULL 0 33 | #endif 34 | 35 | #define EXIT_FAILURE 1 36 | #define EXIT_SUCCESS 0 37 | 38 | #define RAND_MAX 0x7fffffff 39 | 40 | #if (defined(__CYGWIN__) || defined(__CYGWIN32__)) && ! defined(_COMPILING_NEWLIB) 41 | extern __declspec(dllimport) int __mb_cur_max; 42 | #else 43 | extern int __mb_cur_max; 44 | #endif 45 | 46 | #define MB_CUR_MAX __mb_cur_max 47 | 48 | _VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); 49 | int _EXFUN(abs,(int)); 50 | int _EXFUN(atexit,(_VOID (*__func)(_VOID))); 51 | double _EXFUN(atof,(const char *__nptr)); 52 | #ifndef __STRICT_ANSI__ 53 | float _EXFUN(atoff,(const char *__nptr)); 54 | #endif 55 | int _EXFUN(atoi,(const char *__nptr)); 56 | long _EXFUN(atol,(const char *__nptr)); 57 | _PTR _EXFUN(bsearch,(const _PTR __key, 58 | const _PTR __base, 59 | size_t __nmemb, 60 | size_t __size, 61 | int _EXFUN((*_compar),(const _PTR, const _PTR)))); 62 | _PTR _EXFUN(calloc,(size_t __nmemb, size_t __size)); 63 | div_t _EXFUN(div,(int __numer, int __denom)); 64 | _VOID _EXFUN(exit,(int __status) _ATTRIBUTE ((noreturn))); 65 | _VOID _EXFUN(free,(_PTR)); 66 | char * _EXFUN(getenv,(const char *__string)); 67 | char * _EXFUN(_getenv_r,(struct _reent *, const char *__string)); 68 | char * _EXFUN(_findenv,(_CONST char *, int *)); 69 | char * _EXFUN(_findenv_r,(struct _reent *, _CONST char *, int *)); 70 | long _EXFUN(labs,(long)); 71 | ldiv_t _EXFUN(ldiv,(long __numer, long __denom)); 72 | _PTR _EXFUN(malloc,(size_t __size)); 73 | int _EXFUN(mblen,(const char *, size_t)); 74 | int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, int *)); 75 | int _EXFUN(mbtowc,(wchar_t *, const char *, size_t)); 76 | int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, int *)); 77 | int _EXFUN(wctomb,(char *, wchar_t)); 78 | int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, int *)); 79 | size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t)); 80 | size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, int *)); 81 | size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t)); 82 | size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, int *)); 83 | _VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR))); 84 | int _EXFUN(rand,(_VOID)); 85 | _PTR _EXFUN(realloc,(_PTR __r, size_t __size)); 86 | _VOID _EXFUN(srand,(unsigned __seed)); 87 | double _EXFUN(strtod,(const char *__n, char **_end_PTR)); 88 | #ifndef __STRICT_ANSI__ 89 | float _EXFUN(strtodf,(const char *__n, char **_end_PTR)); 90 | #endif 91 | long _EXFUN(strtol,(const char *__n, char **_end_PTR, int __base)); 92 | int _EXFUN(system,(const char *__string)); 93 | unsigned long _EXFUN(strtoul,(const char *_n_PTR, char **_end_PTR, int __base)); 94 | unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *_n_PTR, char **_end_PTR, int __base)); 95 | 96 | #ifndef __STRICT_ANSI__ 97 | _VOID _EXFUN(cfree,(_PTR)); 98 | int _EXFUN(putenv,(const char *__string)); 99 | int _EXFUN(setenv,(const char *__string, const char *__value, int __overwrite)); 100 | int _EXFUN(_setenv_r,(struct _reent *, const char *__string, const char *__value, int __overwrite)); 101 | 102 | char * _EXFUN(gcvt,(double,int,char *)); 103 | char * _EXFUN(gcvtf,(float,int,char *)); 104 | char * _EXFUN(fcvt,(double,int,int *,int *)); 105 | char * _EXFUN(fcvtf,(float,int,int *,int *)); 106 | char * _EXFUN(ecvt,(double,int,int *,int *)); 107 | char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *)); 108 | char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *)); 109 | char * _EXFUN(ecvtf,(float,int,int *,int *)); 110 | char * _EXFUN(dtoa,(double, int, int, int *, int*, char**)); 111 | int _EXFUN(rand_r,(unsigned *__seed)); 112 | 113 | #ifdef __CYGWIN32__ 114 | char * _EXFUN(realpath,(const char *, char *)); 115 | void _EXFUN(unsetenv,(const char *__string)); 116 | int _EXFUN(random,(_VOID)); 117 | long _EXFUN(srandom,(unsigned __seed)); 118 | char * _EXFUN(ptsname, (int)); 119 | int _EXFUN(grantpt, (int)); 120 | int _EXFUN(unlockpt,(int)); 121 | #endif 122 | 123 | #endif /* ! __STRICT_ANSI__ */ 124 | 125 | char * _EXFUN(_dtoa_r,(struct _reent *, double, int, int, int *, int*, char**)); 126 | _PTR _EXFUN(_malloc_r,(struct _reent *, size_t)); 127 | _PTR _EXFUN(_calloc_r,(struct _reent *, size_t, size_t)); 128 | _VOID _EXFUN(_free_r,(struct _reent *, _PTR)); 129 | _PTR _EXFUN(_realloc_r,(struct _reent *, _PTR, size_t)); 130 | _VOID _EXFUN(_mstats_r,(struct _reent *, char *)); 131 | int _EXFUN(_system_r,(struct _reent *, const char *)); 132 | 133 | _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *)); 134 | 135 | #ifdef __cplusplus 136 | } 137 | #endif 138 | #endif /* _STDLIB_H_ */ 139 | -------------------------------------------------------------------------------- /target-inc/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * string.h 3 | * 4 | * Definitions for memory and string functions. 5 | */ 6 | 7 | #ifndef _STRING_H_ 8 | #define _STRING_H_ 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | #include "_ansi.h" 15 | 16 | #define __need_size_t 17 | #include 18 | 19 | #ifndef NULL 20 | #define NULL 0 21 | #endif 22 | 23 | _PTR _EXFUN(memchr,(const _PTR, int, size_t)); 24 | int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); 25 | _PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t)); 26 | _PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); 27 | _PTR _EXFUN(memset,(_PTR, int, size_t)); 28 | char *_EXFUN(strcat,(char *, const char *)); 29 | char *_EXFUN(strchr,(const char *, int)); 30 | int _EXFUN(strcmp,(const char *, const char *)); 31 | int _EXFUN(strcoll,(const char *, const char *)); 32 | char *_EXFUN(strcpy,(char *, const char *)); 33 | size_t _EXFUN(strcspn,(const char *, const char *)); 34 | char *_EXFUN(strerror,(int)); 35 | size_t _EXFUN(strlen,(const char *)); 36 | char *_EXFUN(strncat,(char *, const char *, size_t)); 37 | int _EXFUN(strncmp,(const char *, const char *, size_t)); 38 | char *_EXFUN(strncpy,(char *, const char *, size_t)); 39 | char *_EXFUN(strpbrk,(const char *, const char *)); 40 | char *_EXFUN(strrchr,(const char *, int)); 41 | size_t _EXFUN(strspn,(const char *, const char *)); 42 | char *_EXFUN(strstr,(const char *, const char *)); 43 | 44 | #ifndef _REENT_ONLY 45 | char *_EXFUN(strtok,(char *, const char *)); 46 | #endif 47 | 48 | size_t _EXFUN(strxfrm,(char *, const char *, size_t)); 49 | 50 | #ifndef __STRICT_ANSI__ 51 | char *_EXFUN(strtok_r,(char *, const char *, char **)); 52 | int _EXFUN(bcmp,(const void *, const void *, size_t)); 53 | void _EXFUN(bcopy,(const void *, void *, size_t)); 54 | void _EXFUN(bzero,(void *, size_t)); 55 | int _EXFUN(ffs,(int)); 56 | char *_EXFUN(index,(const char *, int)); 57 | _PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t)); 58 | char *_EXFUN(rindex,(const char *, int)); 59 | int _EXFUN(strcasecmp,(const char *, const char *)); 60 | char *_EXFUN(strdup,(const char *)); 61 | int _EXFUN(strncasecmp,(const char *, const char *, size_t)); 62 | char *_EXFUN(strsep,(char **, const char *)); 63 | char *_EXFUN(strlwr,(char *)); 64 | char *_EXFUN(strupr,(char *)); 65 | #ifdef __CYGWIN32__ 66 | char *_EXFUN(strsignal, (int __signo)); 67 | int _EXFUN(strtosigno, (const char *__name)); 68 | #endif 69 | 70 | /* These function names are used on Windows and perhaps other systems. */ 71 | #ifndef strcmpi 72 | #define strcmpi strcasecmp 73 | #endif 74 | #ifndef stricmp 75 | #define stricmp strcasecmp 76 | #endif 77 | #ifndef strncmpi 78 | #define strncmpi strncasecmp 79 | #endif 80 | #ifndef strnicmp 81 | #define strnicmp strncasecmp 82 | #endif 83 | 84 | #endif /* ! __STRICT_ANSI__ */ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #endif /* _STRING_H_ */ 90 | -------------------------------------------------------------------------------- /target-inc/sys/_types.h: -------------------------------------------------------------------------------- 1 | /* ANSI C namespace clean utility typedefs */ 2 | 3 | /* This file defines various typedefs needed by the system calls that support 4 | the C library. Basically, they're just the POSIX versions with an '_' 5 | prepended. This file lives in the `sys' directory so targets can provide 6 | their own if desired (or they can put target dependant conditionals here). 7 | */ 8 | 9 | #ifndef _SYS__TYPES_H 10 | #define _SYS__TYPES_H 11 | 12 | typedef long _off_t; 13 | typedef long _ssize_t; 14 | 15 | #endif /* _SYS__TYPES_H */ 16 | -------------------------------------------------------------------------------- /target-inc/sys/config.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYS_CONFIG_H__ 2 | #define __SYS_CONFIG_H__ 3 | 4 | /* exceptions first */ 5 | /* ??? Why is much of this stuff duplicated with machine/ieeefp.h? */ 6 | #if defined(__H8300__) || defined(__H8500__) || defined (__H8300H__) || defined(__W65__) || defined (__H8300S__) 7 | #define _FLOAT_ARG float 8 | #define __SMALL_BITFIELDS 9 | #define _DOUBLE_IS_32BITS 10 | #define __IEEE_BIG_ENDIAN 11 | /* ??? This conditional is true for the h8500 and the w65, defining H8300 12 | in those cases probably isn't the right thing to do. */ 13 | #define H8300 1 14 | #endif 15 | 16 | #ifdef __W65__ 17 | #define _DOUBLE_IS_32BITS 18 | #define __SMALL_BITFIELDS 19 | #define __IEEE_BIG_ENDIAN 20 | #undef INT_MAX 21 | #undef UINT_MAX 22 | #define INT_MAX 32767 23 | #define UINT_MAX 65535 24 | 25 | #endif 26 | 27 | /* 16 bit integer machines */ 28 | #if defined(__Z8001__) || defined(__Z8002__) || defined(__H8300__) || defined(__H8500__) || defined(__W65__) || defined (__H8300H__) || defined (__H8300S__) || defined (__mn10200__) 29 | 30 | #undef INT_MAX 31 | #undef UINT_MAX 32 | #define INT_MAX 32767 33 | #define UINT_MAX 65535 34 | #endif 35 | 36 | #if defined(__D10V__) 37 | #undef INT_MAX 38 | #undef UINT_MAX 39 | #define INT_MAX __INT_MAX__ 40 | #define UINT_MAX (__INT_MAX__ * 2U + 1) 41 | #define _DOUBLE_IS_32BITS 42 | #define _POINTER_INT short 43 | #define __IEEE_BIG_ENDIAN 44 | #endif 45 | 46 | #ifdef ___AM29K__ 47 | #define _FLOAT_RET double 48 | #endif 49 | 50 | #ifdef __i386__ 51 | #ifndef __unix__ 52 | /* in other words, go32 */ 53 | #define _FLOAT_RET double 54 | #endif 55 | #endif 56 | 57 | #ifdef __M32R__ 58 | #define __IEEE_BIG_ENDIAN 59 | #endif 60 | 61 | #ifdef __m68k__ 62 | /* This is defined in machine/ieeefp.h; need to check is it redundant here? */ 63 | #define __IEEE_BIG_ENDIAN 64 | #endif 65 | 66 | #ifdef __mn10300__ 67 | #define __IEEE_LITTLE_ENDIAN 68 | #endif 69 | 70 | #ifdef __mn10200__ 71 | #define _DOUBLE_IS_32BITS 72 | #define __SMALL_BITFIELDS 73 | #define __IEEE_LITTLE_ENDIAN 74 | #endif 75 | 76 | #ifdef __TIC80__ 77 | #define __IEEE_LITTLE_ENDIAN 78 | #endif 79 | 80 | #ifdef __v850 81 | #define __IEEE_LITTLE_ENDIAN 82 | #define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__sda__)) 83 | #endif 84 | 85 | #ifdef __D30V__ 86 | #define __IEEE_BIG_ENDIAN 87 | #endif 88 | 89 | /* For the PowerPC eabi, force the _impure_ptr to be in .sdata */ 90 | #if defined(__PPC__) && defined(_CALL_SYSV) 91 | #define __ATTRIBUTE_IMPURE_PTR__ __attribute__((__section__(".sdata"))) 92 | #endif 93 | 94 | #ifdef __sparc__ 95 | #ifdef __LITTLE_ENDIAN_DATA__ 96 | #define __IEEE_LITTLE_ENDIAN 97 | #else 98 | #define __IEEE_BIG_ENDIAN 99 | #endif 100 | #endif 101 | 102 | #if INT_MAX == 32767 103 | typedef long int __int32_t; 104 | typedef unsigned long int __uint32_t; 105 | #else 106 | typedef int __int32_t; 107 | typedef unsigned int __uint32_t; 108 | #endif 109 | 110 | #ifndef _POINTER_INT 111 | #define _POINTER_INT long 112 | #endif 113 | 114 | 115 | #endif /* __SYS_CONFIG_H__ */ 116 | -------------------------------------------------------------------------------- /target-inc/sys/dirent.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | struct dirent { 6 | long d_ino; /* inode number */ 7 | off_t d_off; /* offset to the next dirent */ 8 | unsigned short d_reclen; /* length of this record */ 9 | unsigned char d_type; /* type of file */ 10 | char d_name[256]; /* filename */ 11 | }; 12 | 13 | typedef int DIR; 14 | 15 | DIR *opendir(const char *name); 16 | int closedir(DIR *dir); 17 | struct dirent *readdir(DIR *dir); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | -------------------------------------------------------------------------------- /target-inc/sys/errno.h: -------------------------------------------------------------------------------- 1 | /* errno is not a global variable, because that would make using it 2 | non-reentrant. Instead, its address is returned by the function 3 | __errno. */ 4 | 5 | #ifndef _SYS_ERRNO_H_ 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | #define _SYS_ERRNO_H_ 10 | 11 | #include 12 | 13 | #ifndef _REENT_ONLY 14 | #define errno (*__errno()) 15 | extern int *__errno _PARAMS ((void)); 16 | #endif 17 | 18 | #if !defined(__CYGWIN32__) || defined(__INSIDE_CYGWIN__) 19 | extern _CONST char * _CONST _sys_errlist[]; 20 | extern int _sys_nerr; 21 | #else 22 | extern _CONST char * _CONST _sys_errlist[] __declspec(dllimport); 23 | extern int _sys_nerr __declspec(dllimport); 24 | #endif 25 | 26 | #define __errno_r(ptr) ((ptr)->_errno) 27 | 28 | #define EPERM 1 /* Not super-user */ 29 | #define ENOENT 2 /* No such file or directory */ 30 | #define ESRCH 3 /* No such process */ 31 | #define EINTR 4 /* Interrupted system call */ 32 | #define EIO 5 /* I/O error */ 33 | #define ENXIO 6 /* No such device or address */ 34 | #define E2BIG 7 /* Arg list too long */ 35 | #define ENOEXEC 8 /* Exec format error */ 36 | #define EBADF 9 /* Bad file number */ 37 | #define ECHILD 10 /* No children */ 38 | #define EAGAIN 11 /* No more processes */ 39 | #define ENOMEM 12 /* Not enough core */ 40 | #define EACCES 13 /* Permission denied */ 41 | #define EFAULT 14 /* Bad address */ 42 | #define ENOTBLK 15 /* Block device required */ 43 | #define EBUSY 16 /* Mount device busy */ 44 | #define EEXIST 17 /* File exists */ 45 | #define EXDEV 18 /* Cross-device link */ 46 | #define ENODEV 19 /* No such device */ 47 | #define ENOTDIR 20 /* Not a directory */ 48 | #define EISDIR 21 /* Is a directory */ 49 | #define EINVAL 22 /* Invalid argument */ 50 | #define ENFILE 23 /* Too many open files in system */ 51 | #define EMFILE 24 /* Too many open files */ 52 | #define ENOTTY 25 /* Not a typewriter */ 53 | #define ETXTBSY 26 /* Text file busy */ 54 | #define EFBIG 27 /* File too large */ 55 | #define ENOSPC 28 /* No space left on device */ 56 | #define ESPIPE 29 /* Illegal seek */ 57 | #define EROFS 30 /* Read only file system */ 58 | #define EMLINK 31 /* Too many links */ 59 | #define EPIPE 32 /* Broken pipe */ 60 | #define EDOM 33 /* Math arg out of domain of func */ 61 | #define ERANGE 34 /* Math result not representable */ 62 | #define ENOMSG 35 /* No message of desired type */ 63 | #define EIDRM 36 /* Identifier removed */ 64 | #define ECHRNG 37 /* Channel number out of range */ 65 | #define EL2NSYNC 38 /* Level 2 not synchronized */ 66 | #define EL3HLT 39 /* Level 3 halted */ 67 | #define EL3RST 40 /* Level 3 reset */ 68 | #define ELNRNG 41 /* Link number out of range */ 69 | #define EUNATCH 42 /* Protocol driver not attached */ 70 | #define ENOCSI 43 /* No CSI structure available */ 71 | #define EL2HLT 44 /* Level 2 halted */ 72 | #define EDEADLK 45 /* Deadlock condition */ 73 | #define ENOLCK 46 /* No record locks available */ 74 | #define EBADE 50 /* Invalid exchange */ 75 | #define EBADR 51 /* Invalid request descriptor */ 76 | #define EXFULL 52 /* Exchange full */ 77 | #define ENOANO 53 /* No anode */ 78 | #define EBADRQC 54 /* Invalid request code */ 79 | #define EBADSLT 55 /* Invalid slot */ 80 | #define EDEADLOCK 56 /* File locking deadlock error */ 81 | #define EBFONT 57 /* Bad font file fmt */ 82 | #define ENOSTR 60 /* Device not a stream */ 83 | #define ENODATA 61 /* No data (for no delay io) */ 84 | #define ETIME 62 /* Timer expired */ 85 | #define ENOSR 63 /* Out of streams resources */ 86 | #define ENONET 64 /* Machine is not on the network */ 87 | #define ENOPKG 65 /* Package not installed */ 88 | #define EREMOTE 66 /* The object is remote */ 89 | #define ENOLINK 67 /* The link has been severed */ 90 | #define EADV 68 /* Advertise error */ 91 | #define ESRMNT 69 /* Srmount error */ 92 | #define ECOMM 70 /* Communication error on send */ 93 | #define EPROTO 71 /* Protocol error */ 94 | #define EMULTIHOP 74 /* Multihop attempted */ 95 | #define ELBIN 75 /* Inode is remote (not really error) */ 96 | #define EDOTDOT 76 /* Cross mount point (not really error) */ 97 | #define EBADMSG 77 /* Trying to read unreadable message */ 98 | #define ENOTUNIQ 80 /* Given log. name not unique */ 99 | #define EBADFD 81 /* f.d. invalid for this operation */ 100 | #define EREMCHG 82 /* Remote address changed */ 101 | #define ELIBACC 83 /* Can't access a needed shared lib */ 102 | #define ELIBBAD 84 /* Accessing a corrupted shared lib */ 103 | #define ELIBSCN 85 /* .lib section in a.out corrupted */ 104 | #define ELIBMAX 86 /* Attempting to link in too many libs */ 105 | #define ELIBEXEC 87 /* Attempting to exec a shared library */ 106 | #define ENOSYS 88 /* Function not implemented */ 107 | #define ENMFILE 89 /* No more files */ 108 | #define ENOTEMPTY 90 /* Directory not empty */ 109 | #define ENAMETOOLONG 91 /* File or path name too long */ 110 | #define ELOOP /* Too many symbolic links */ 111 | #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ 112 | #define EPFNOSUPPORT 96 /* Protocol family not supported */ 113 | #define ECONNRESET 104 /* Connection reset by peer */ 114 | #define ENOBUFS 105 /* No buffer space available */ 115 | #define EAFNOSUPPORT 106 116 | #define EPROTOTYPE 107 117 | #define ENOTSOCK 108 118 | #define ENOPROTOOPT 109 119 | #define ESHUTDOWN 110 120 | #define ECONNREFUSED 111 /* Connection refused */ 121 | #define EADDRINUSE 112 /* Address already in use */ 122 | #define ECONNABORTED 113 /* Connection aborted */ 123 | #define ENETUNREACH 114 124 | #define ENETDOWN 115 125 | #define ETIMEDOUT 116 126 | #define EHOSTDOWN 117 127 | #define EHOSTUNREACH 118 128 | #define EINPROGRESS 119 129 | #define EALREADY 120 130 | #define EDESTADDRREQ 121 131 | #define EMSGSIZE 122 132 | #define EPROTONOSUPPORT 123 133 | #define ESOCKTNOSUPPORT 124 134 | #define EADDRNOTAVAIL 125 135 | #define ENETRESET 126 136 | #define EISCONN 127 137 | #define ENOTCONN 128 138 | #define ETOOMANYREFS 129 139 | #define EPROCLIM 130 140 | #define EUSERS 131 141 | #define EDQUOT 132 142 | #define ESTALE 133 143 | #define ENOTSUP 134 144 | #define ENOMEDIUM 135 145 | 146 | /* From cygwin32 */ 147 | #define EWOULDBLOCK EAGAIN /* Operation would block */ 148 | 149 | #define __ELASTERROR 2000 /* Users can add values starting here */ 150 | 151 | #ifdef __cplusplus 152 | } 153 | #endif 154 | #endif /* _SYS_ERRNO_H */ 155 | -------------------------------------------------------------------------------- /target-inc/sys/fcntl.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _FCNTL_ 3 | #ifdef __cplusplus 4 | extern "C" { 5 | #endif 6 | #define _FCNTL_ 7 | #include <_ansi.h> 8 | #define _FOPEN (-1) /* from sys/file.h, kernel use only */ 9 | #define _FREAD 0x0001 /* read enabled */ 10 | #define _FWRITE 0x0002 /* write enabled */ 11 | #define _FNDELAY 0x0004 /* non blocking I/O (4.2 style) */ 12 | #define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ 13 | #define _FMARK 0x0010 /* internal; mark during gc() */ 14 | #define _FDEFER 0x0020 /* internal; defer for next gc pass */ 15 | #define _FASYNC 0x0040 /* signal pgrp when data ready */ 16 | #define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ 17 | #define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ 18 | #define _FCREAT 0x0200 /* open with file create */ 19 | #define _FTRUNC 0x0400 /* open with truncation */ 20 | #define _FEXCL 0x0800 /* error on open if file exists */ 21 | #define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ 22 | #define _FSYNC 0x2000 /* do all writes synchronously */ 23 | #define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ 24 | #define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ 25 | 26 | #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) 27 | 28 | /* 29 | * Flag values for open(2) and fcntl(2) 30 | * The kernel adds 1 to the open modes to turn it into some 31 | * combination of FREAD and FWRITE. 32 | */ 33 | #define O_RDONLY 0 /* +1 == FREAD */ 34 | #define O_WRONLY 1 /* +1 == FWRITE */ 35 | #define O_RDWR 2 /* +1 == FREAD|FWRITE */ 36 | #define O_APPEND _FAPPEND 37 | #define O_CREAT _FCREAT 38 | #define O_TRUNC _FTRUNC 39 | #define O_EXCL _FEXCL 40 | /* O_SYNC _FSYNC not posix, defined below */ 41 | /* O_NDELAY _FNDELAY set in include/fcntl.h */ 42 | /* O_NDELAY _FNBIO set in 5include/fcntl.h */ 43 | #define O_NONBLOCK _FNONBLOCK 44 | #define O_NOCTTY _FNOCTTY 45 | /* For machines which care - */ 46 | #if defined (_WIN32) || defined (__CYGWIN__) 47 | #define _FBINARY 0x10000 48 | #define _FTEXT 0x20000 49 | #define _FNOINHERIT 0x40000 50 | 51 | #define O_BINARY _FBINARY 52 | #define O_TEXT _FTEXT 53 | #define O_NOINHERIT _FNOINHERIT 54 | 55 | /* The windows header files define versions with a leading underscore. */ 56 | #define _O_RDONLY O_RDONLY 57 | #define _O_WRONLY O_WRONLY 58 | #define _O_RDWR O_RDWR 59 | #define _O_APPEND O_APPEND 60 | #define _O_CREAT O_CREAT 61 | #define _O_TRUNC O_TRUNC 62 | #define _O_EXCL O_EXCL 63 | #define _O_TEXT O_TEXT 64 | #define _O_BINARY O_BINARY 65 | #define _O_RAW O_BINARY 66 | #define _O_NOINHERIT O_NOINHERIT 67 | #endif 68 | 69 | #ifndef _POSIX_SOURCE 70 | 71 | #define O_SYNC _FSYNC 72 | 73 | /* 74 | * Flags that work for fcntl(fd, F_SETFL, FXXXX) 75 | */ 76 | #define FAPPEND _FAPPEND 77 | #define FSYNC _FSYNC 78 | #define FASYNC _FASYNC 79 | #define FNBIO _FNBIO 80 | #define FNONBIO _FNONBLOCK /* XXX fix to be NONBLOCK everywhere */ 81 | #define FNDELAY _FNDELAY 82 | 83 | /* 84 | * Flags that are disallowed for fcntl's (FCNTLCANT); 85 | * used for opens, internal state, or locking. 86 | */ 87 | #define FREAD _FREAD 88 | #define FWRITE _FWRITE 89 | #define FMARK _FMARK 90 | #define FDEFER _FDEFER 91 | #define FSHLOCK _FSHLOCK 92 | #define FEXLOCK _FEXLOCK 93 | 94 | /* 95 | * The rest of the flags, used only for opens 96 | */ 97 | #define FOPEN _FOPEN 98 | #define FCREAT _FCREAT 99 | #define FTRUNC _FTRUNC 100 | #define FEXCL _FEXCL 101 | #define FNOCTTY _FNOCTTY 102 | 103 | #endif /* !_POSIX_SOURCE */ 104 | 105 | /* XXX close on exec request; must match UF_EXCLOSE in user.h */ 106 | #define FD_CLOEXEC 1 /* posix */ 107 | 108 | /* fcntl(2) requests */ 109 | #define F_DUPFD 0 /* Duplicate fildes */ 110 | #define F_GETFD 1 /* Get fildes flags (close on exec) */ 111 | #define F_SETFD 2 /* Set fildes flags (close on exec) */ 112 | #define F_GETFL 3 /* Get file flags */ 113 | #define F_SETFL 4 /* Set file flags */ 114 | #ifndef _POSIX_SOURCE 115 | #define F_GETOWN 5 /* Get owner - for ASYNC */ 116 | #define F_SETOWN 6 /* Set owner - for ASYNC */ 117 | #endif /* !_POSIX_SOURCE */ 118 | #define F_GETLK 7 /* Get record-locking information */ 119 | #define F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */ 120 | #define F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */ 121 | #ifndef _POSIX_SOURCE 122 | #define F_RGETLK 10 /* Test a remote lock to see if it is blocked */ 123 | #define F_RSETLK 11 /* Set or unlock a remote lock */ 124 | #define F_CNVT 12 /* Convert a fhandle to an open fd */ 125 | #define F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */ 126 | #endif /* !_POSIX_SOURCE */ 127 | 128 | /* fcntl(2) flags (l_type field of flock structure) */ 129 | #define F_RDLCK 1 /* read lock */ 130 | #define F_WRLCK 2 /* write lock */ 131 | #define F_UNLCK 3 /* remove lock(s) */ 132 | #ifndef _POSIX_SOURCE 133 | #define F_UNLKSYS 4 /* remove remote locks for a given system */ 134 | #endif /* !_POSIX_SOURCE */ 135 | 136 | /*#include */ 137 | 138 | /* file segment locking set data type - information passed to system by user */ 139 | struct flock { 140 | short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ 141 | short l_whence; /* flag to choose starting offset */ 142 | long l_start; /* relative offset, in bytes */ 143 | long l_len; /* length, in bytes; 0 means lock to EOF */ 144 | short l_pid; /* returned with F_GETLK */ 145 | short l_xxx; /* reserved for future use */ 146 | }; 147 | 148 | #ifndef _POSIX_SOURCE 149 | /* extended file segment locking set data type */ 150 | struct eflock { 151 | short l_type; /* F_RDLCK, F_WRLCK, or F_UNLCK */ 152 | short l_whence; /* flag to choose starting offset */ 153 | long l_start; /* relative offset, in bytes */ 154 | long l_len; /* length, in bytes; 0 means lock to EOF */ 155 | short l_pid; /* returned with F_GETLK */ 156 | short l_xxx; /* reserved for future use */ 157 | long l_rpid; /* Remote process id wanting this lock */ 158 | long l_rsys; /* Remote system id wanting this lock */ 159 | }; 160 | #endif /* !_POSIX_SOURCE */ 161 | 162 | 163 | #include 164 | #include /* sigh. for the mode bits for open/creat */ 165 | 166 | extern int open _PARAMS ((const char *, int, ...)); 167 | extern int creat _PARAMS ((const char *, mode_t)); 168 | extern int fcntl _PARAMS ((int, int, ...)); 169 | 170 | /* Provide _ prototypes for functions provided by some versions 171 | of newlib. */ 172 | extern int _open _PARAMS ((const char *, int, ...)); 173 | extern int _fcntl _PARAMS ((int, int, ...)); 174 | 175 | #ifdef __cplusplus 176 | } 177 | #endif 178 | #endif /* !_FCNTL_ */ 179 | -------------------------------------------------------------------------------- /target-inc/sys/file.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | -------------------------------------------------------------------------------- /target-inc/sys/param.h: -------------------------------------------------------------------------------- 1 | /* This is a dummy file, not customized for any 2 | particular system. If there is a param.h in libc/sys/SYSDIR/sys, 3 | it will override this one. */ 4 | 5 | #ifndef _SYS_PARAM_H 6 | #define _SYS_PARAM_H 7 | 8 | #define HZ (60) 9 | #define NOFILE (60) 10 | #define PATHSIZE (1024) 11 | 12 | #ifdef __i386__ 13 | #define BIG_ENDIAN 4321 14 | #define LITTLE_ENDIAN 1234 15 | #define BYTE_ORDER LITTLE_ENDIAN 16 | #endif 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /target-inc/sys/reent.h: -------------------------------------------------------------------------------- 1 | /* This header file provides the reentrancy. */ 2 | 3 | /* WARNING: All identifiers here must begin with an underscore. This file is 4 | included by stdio.h and others and we therefore must only use identifiers 5 | in the namespace allotted to us. */ 6 | 7 | #ifndef _SYS_REENT_H_ 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | #define _SYS_REENT_H_ 12 | 13 | #include <_ansi.h> 14 | #include 15 | 16 | #ifndef __Long 17 | #if __LONG_MAX__ == 2147483647L 18 | #define __Long long 19 | typedef unsigned __Long __ULong; 20 | #elif __INT_MAX__ == 2147483647 21 | #define __Long int 22 | typedef unsigned __Long __ULong; 23 | #endif 24 | #endif 25 | 26 | #ifndef __Long 27 | #define __Long __int32_t 28 | typedef __uint32_t __ULong; 29 | #endif 30 | 31 | struct _glue { 32 | struct _glue *_next; 33 | int _niobs; 34 | struct __sFILE *_iobs; 35 | }; 36 | 37 | struct _Bigint { 38 | struct _Bigint *_next; 39 | int _k, _maxwds, _sign, _wds; 40 | __ULong _x[1]; 41 | }; 42 | 43 | /* 44 | * atexit() support 45 | */ 46 | 47 | #define _ATEXIT_SIZE 32 /* must be at least 32 to guarantee ANSI conformance */ 48 | 49 | struct _atexit { 50 | struct _atexit *_next; /* next in list */ 51 | int _ind; /* next index in this table */ 52 | void (*_fns[_ATEXIT_SIZE])(void); /* the table itself */ 53 | }; 54 | 55 | /* 56 | * Stdio buffers. 57 | * 58 | * This and __sFILE are defined here because we need them for struct _reent, 59 | * but we don't want stdio.h included when stdlib.h is. 60 | */ 61 | 62 | struct __sbuf { 63 | unsigned char *_base; 64 | int _size; 65 | }; 66 | 67 | /* 68 | * We need fpos_t for the following, but it doesn't have a leading "_", 69 | * so we use _fpos_t instead. 70 | */ 71 | 72 | typedef long _fpos_t; /* XXX must match off_t in */ 73 | /* (and must be `long' for now) */ 74 | 75 | /* 76 | * Stdio state variables. 77 | * 78 | * The following always hold: 79 | * 80 | * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), 81 | * _lbfsize is -_bf._size, else _lbfsize is 0 82 | * if _flags&__SRD, _w is 0 83 | * if _flags&__SWR, _r is 0 84 | * 85 | * This ensures that the getc and putc macros (or inline functions) never 86 | * try to write or read from a file that is in `read' or `write' mode. 87 | * (Moreover, they can, and do, automatically switch from read mode to 88 | * write mode, and back, on "r+" and "w+" files.) 89 | * 90 | * _lbfsize is used only to make the inline line-buffered output stream 91 | * code as compact as possible. 92 | * 93 | * _ub, _up, and _ur are used when ungetc() pushes back more characters 94 | * than fit in the current _bf, or when ungetc() pushes back a character 95 | * that does not match the previous one in _bf. When this happens, 96 | * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff 97 | * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. 98 | */ 99 | 100 | struct __sFILE { 101 | unsigned char *_p; /* current position in (some) buffer */ 102 | int _r; /* read space left for getc() */ 103 | int _w; /* write space left for putc() */ 104 | short _flags; /* flags, below; this FILE is free if 0 */ 105 | short _file; /* fileno, if Unix descriptor, else -1 */ 106 | struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ 107 | int _lbfsize; /* 0 or -_bf._size, for inline putc */ 108 | 109 | /* operations */ 110 | _PTR _cookie; /* cookie passed to io functions */ 111 | 112 | int _EXFUN((*_read),(_PTR _cookie, char *_buf, int _n)); 113 | int _EXFUN((*_write),(_PTR _cookie, const char *_buf, int _n)); 114 | _fpos_t _EXFUN((*_seek),(_PTR _cookie, _fpos_t _offset, int _whence)); 115 | int _EXFUN((*_close),(_PTR _cookie)); 116 | 117 | /* separate buffer for long sequences of ungetc() */ 118 | struct __sbuf _ub; /* ungetc buffer */ 119 | unsigned char *_up; /* saved _p when _p is doing ungetc data */ 120 | int _ur; /* saved _r when _r is counting ungetc data */ 121 | 122 | /* tricks to meet minimum requirements even when malloc() fails */ 123 | unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ 124 | unsigned char _nbuf[1]; /* guarantee a getc() buffer */ 125 | 126 | /* separate buffer for fgetline() when line crosses buffer boundary */ 127 | struct __sbuf _lb; /* buffer for fgetline() */ 128 | 129 | /* Unix stdio files get aligned to block boundaries on fseek() */ 130 | int _blksize; /* stat.st_blksize (may be != _bf._size) */ 131 | int _offset; /* current lseek offset */ 132 | 133 | struct _reent *_data; 134 | }; 135 | 136 | /* 137 | * struct _reent 138 | * 139 | * This structure contains *all* globals needed by the library. 140 | * It's raison d'etre is to facilitate threads by making all library routines 141 | * reentrant. IE: All state information is contained here. 142 | */ 143 | 144 | struct _reent { 145 | /* local copy of errno */ 146 | int _errno; 147 | 148 | /* FILE is a big struct and may change over time. To try to achieve binary 149 | compatibility with future versions, put stdin,stdout,stderr here. 150 | These are pointers into member __sf defined below. */ 151 | struct __sFILE *_stdin, *_stdout, *_stderr; 152 | 153 | int _inc; /* used by tmpnam */ 154 | char _emergency[25]; 155 | 156 | int _current_category; /* used by setlocale */ 157 | _CONST char *_current_locale; 158 | 159 | int __sdidinit; /* 1 means stdio has been init'd */ 160 | 161 | void _EXFUN((*__cleanup),(struct _reent *)); 162 | 163 | /* used by mprec routines */ 164 | struct _Bigint *_result; 165 | int _result_k; 166 | struct _Bigint *_p5s; 167 | struct _Bigint **_freelist; 168 | 169 | /* used by some fp conversion routines */ 170 | int _cvtlen; /* should be size_t */ 171 | char *_cvtbuf; 172 | 173 | union { 174 | struct { 175 | unsigned int _rand_next; 176 | char * _strtok_last; 177 | char _asctime_buf[26]; 178 | struct tm _localtime_buf; 179 | int _gamma_signgam; 180 | } _reent; 181 | /* Two next two fields were once used by malloc. They are no longer 182 | used. They are used to preserve the space used before so as to 183 | allow addition of new reent fields and keep binary compatibility. */ 184 | struct { 185 | #define _N_LISTS 30 186 | unsigned char * _nextf[_N_LISTS]; 187 | unsigned int _nmalloc[_N_LISTS]; 188 | } _unused; 189 | } _new; 190 | 191 | /* atexit stuff */ 192 | struct _atexit *_atexit; /* points to head of LIFO stack */ 193 | struct _atexit _atexit0; /* one guaranteed table, required by ANSI */ 194 | 195 | /* signal info */ 196 | void (**(_sig_func))(int); 197 | 198 | /* These are here last so that __sFILE can grow without changing the offsets 199 | of the above members (on the off chance that future binary compatibility 200 | would be broken otherwise). */ 201 | struct _glue __sglue; /* root of glue chain */ 202 | struct __sFILE __sf[3]; /* first three file descriptors */ 203 | }; 204 | 205 | #define _REENT_INIT(var) \ 206 | { 0, &var.__sf[0], &var.__sf[1], &var.__sf[2], 0, "", 0, "C", \ 207 | 0, NULL, NULL, 0, NULL, NULL, 0, NULL, { {1, NULL, "", \ 208 | { 0,0,0,0,0,0,0,0}, 0 } } } 209 | 210 | /* 211 | * All references to struct _reent are via this pointer. 212 | * Internally, newlib routines that need to reference it should use _REENT. 213 | */ 214 | 215 | #ifndef __ATTRIBUTE_IMPURE_PTR__ 216 | #define __ATTRIBUTE_IMPURE_PTR__ 217 | #endif 218 | 219 | extern struct _reent *_impure_ptr __ATTRIBUTE_IMPURE_PTR__; 220 | 221 | void _reclaim_reent _PARAMS ((struct _reent *)); 222 | 223 | /* #define _REENT_ONLY define this to get only reentrant routines */ 224 | 225 | #ifndef _REENT_ONLY 226 | #define _REENT _impure_ptr 227 | #endif 228 | 229 | #ifdef __cplusplus 230 | } 231 | #endif 232 | #endif /* _SYS_REENT_H_ */ 233 | -------------------------------------------------------------------------------- /target-inc/sys/resource.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_RESOURCE_H_ 2 | #define _SYS_RESOURCE_H_ 3 | 4 | #include 5 | 6 | #define RUSAGE_SELF 0 /* calling process */ 7 | #define RUSAGE_CHILDREN -1 /* terminated child processes */ 8 | 9 | struct rusage { 10 | struct timeval ru_utime; /* user time used */ 11 | struct timeval ru_stime; /* system time used */ 12 | }; 13 | 14 | #endif 15 | 16 | -------------------------------------------------------------------------------- /target-inc/sys/signal.h: -------------------------------------------------------------------------------- 1 | /* sys/signal.h */ 2 | 3 | #ifndef _SYS_SIGNAL_H 4 | #define _SYS_SIGNAL_H 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #include "_ansi.h" 11 | 12 | #ifndef __STRICT_ANSI__ 13 | typedef unsigned long sigset_t; 14 | struct sigaction { 15 | void (*sa_handler)(int); 16 | sigset_t sa_mask; 17 | int sa_flags; 18 | }; 19 | #define SA_NOCLDSTOP 1 /* only value supported now for sa_flags */ 20 | #define SIG_SETMASK 0 /* set mask with sigprocmask() */ 21 | #define SIG_BLOCK 1 /* set of signals to block */ 22 | #define SIG_UNBLOCK 2 /* set of signals to, well, unblock */ 23 | 24 | /* These depend upon the type of sigset_t, which right now 25 | is always a long.. They're in the POSIX namespace, but 26 | are not ANSI. */ 27 | #define sigaddset(what,sig) (*(what) |= (1<<(sig))) 28 | #define sigemptyset(what) (*(what) = 0) 29 | 30 | int sigprocmask(int __how, const sigset_t *__a, sigset_t *__b); 31 | 32 | /* protos for functions found in winsup sources */ 33 | #if defined(__CYGWIN32__) 34 | #undef sigaddset 35 | #undef sigemptyset 36 | /* The first argument to kill should be pid_t. Right now 37 | always defines pid_t to be int. If that ever 38 | changes, then we will need to do something else, perhaps along the 39 | lines of . */ 40 | int _EXFUN(kill, (int, int)); 41 | int _EXFUN(sigaction, (int, const struct sigaction *, struct sigaction *)); 42 | int _EXFUN(sigaddset, (sigset_t *, const int)); 43 | int _EXFUN(sigdelset, (sigset_t *, const int)); 44 | int _EXFUN(sigismember, (const sigset_t *, int)); 45 | int _EXFUN(sigfillset, (sigset_t *)); 46 | int _EXFUN(sigemptyset, (sigset_t *)); 47 | int _EXFUN(sigpending, (sigset_t *)); 48 | int _EXFUN(sigsuspend, (const sigset_t *)); 49 | int _EXFUN(sigpause, (int)); 50 | #endif 51 | 52 | #endif /* __STRICT_ANSI__ */ 53 | 54 | #if defined(___AM29K__) 55 | /* These all need to be defined for ANSI C, but I don't think they are 56 | meaningful. */ 57 | #define SIGABRT 1 58 | #define SIGFPE 1 59 | #define SIGILL 1 60 | #define SIGINT 1 61 | #define SIGSEGV 1 62 | #define SIGTERM 1 63 | /* These need to be defined for POSIX, and some others do too. */ 64 | #define SIGHUP 1 65 | #define SIGQUIT 1 66 | #define NSIG 2 67 | #elif defined(__GO32__) 68 | #define SIGINT 1 69 | #define SIGKILL 2 70 | #define SIGPIPE 3 71 | #define SIGFPE 4 72 | #define SIGHUP 5 73 | #define SIGTERM 6 74 | #define SIGSEGV 7 75 | #define SIGTSTP 8 76 | #define SIGQUIT 9 77 | #define SIGTRAP 10 78 | #define SIGILL 11 79 | #define SIGEMT 12 80 | #define SIGALRM 13 81 | #define SIGBUS 14 82 | #define SIGLOST 15 83 | #define SIGSTOP 16 84 | #define SIGABRT 17 85 | #define SIGUSR1 18 86 | #define SIGUSR2 19 87 | #define NSIG 20 88 | #elif defined(__CYGWIN32__) /* BSD signals symantics */ 89 | #define SIGHUP 1 /* hangup */ 90 | #define SIGINT 2 /* interrupt */ 91 | #define SIGQUIT 3 /* quit */ 92 | #define SIGILL 4 /* illegal instruction (not reset when caught) */ 93 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ 94 | #define SIGABRT 6 /* used by abort */ 95 | #define SIGEMT 7 /* EMT instruction */ 96 | #define SIGFPE 8 /* floating point exception */ 97 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 98 | #define SIGBUS 10 /* bus error */ 99 | #define SIGSEGV 11 /* segmentation violation */ 100 | #define SIGSYS 12 /* bad argument to system call */ 101 | #define SIGPIPE 13 /* write on a pipe with no one to read it */ 102 | #define SIGALRM 14 /* alarm clock */ 103 | #define SIGTERM 15 /* software termination signal from kill */ 104 | #define SIGURG 16 /* urgent condition on IO channel */ 105 | #define SIGSTOP 17 /* sendable stop signal not from tty */ 106 | #define SIGTSTP 18 /* stop signal from tty */ 107 | #define SIGCONT 19 /* continue a stopped process */ 108 | #define SIGCHLD 20 /* to parent on child stop or exit */ 109 | #define SIGCLD 20 /* System V name for SIGCHLD */ 110 | #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 111 | #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 112 | #define SIGIO 23 /* input/output possible signal */ 113 | #define SIGPOLL SIGIO /* System V name for SIGIO */ 114 | #define SIGXCPU 24 /* exceeded CPU time limit */ 115 | #define SIGXFSZ 25 /* exceeded file size limit */ 116 | #define SIGVTALRM 26 /* virtual time alarm */ 117 | #define SIGPROF 27 /* profiling time alarm */ 118 | #define SIGWINCH 28 /* window changed */ 119 | #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ 120 | #define SIGUSR1 30 /* user defined signal 1 */ 121 | #define SIGUSR2 31 /* user defined signal 2 */ 122 | #define NSIG 32 /* signal 0 implied */ 123 | #else 124 | #define SIGHUP 1 /* hangup */ 125 | #define SIGINT 2 /* interrupt */ 126 | #define SIGQUIT 3 /* quit */ 127 | #define SIGILL 4 /* illegal instruction (not reset when caught) */ 128 | #define SIGTRAP 5 /* trace trap (not reset when caught) */ 129 | #define SIGIOT 6 /* IOT instruction */ 130 | #define SIGABRT 6 /* used by abort, replace SIGIOT in the future */ 131 | #define SIGEMT 7 /* EMT instruction */ 132 | #define SIGFPE 8 /* floating point exception */ 133 | #define SIGKILL 9 /* kill (cannot be caught or ignored) */ 134 | #define SIGBUS 10 /* bus error */ 135 | #define SIGSEGV 11 /* segmentation violation */ 136 | #define SIGSYS 12 /* bad argument to system call */ 137 | #define SIGPIPE 13 /* write on a pipe with no one to read it */ 138 | #define SIGALRM 14 /* alarm clock */ 139 | #define SIGTERM 15 /* software termination signal from kill */ 140 | 141 | #if defined(__svr4__) 142 | /* svr4 specifics. different signals above 15, and sigaction. */ 143 | #define SIGUSR1 16 144 | #define SIGUSR2 17 145 | #define SIGCLD 18 146 | #define SIGPWR 19 147 | #define SIGWINCH 20 148 | #define SIGPOLL 22 /* 20 for x.out binaries!!!! */ 149 | #define SIGSTOP 23 /* sendable stop signal not from tty */ 150 | #define SIGTSTP 24 /* stop signal from tty */ 151 | #define SIGCONT 25 /* continue a stopped process */ 152 | #define SIGTTIN 26 /* to readers pgrp upon background tty read */ 153 | #define SIGTTOU 27 /* like TTIN for output if (tp->t_local<OSTOP) */ 154 | #define NSIG 28 155 | #else 156 | #define SIGURG 16 /* urgent condition on IO channel */ 157 | #define SIGSTOP 17 /* sendable stop signal not from tty */ 158 | #define SIGTSTP 18 /* stop signal from tty */ 159 | #define SIGCONT 19 /* continue a stopped process */ 160 | #define SIGCHLD 20 /* to parent on child stop or exit */ 161 | #define SIGCLD 20 /* System V name for SIGCHLD */ 162 | #define SIGTTIN 21 /* to readers pgrp upon background tty read */ 163 | #define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */ 164 | #define SIGIO 23 /* input/output possible signal */ 165 | #define SIGPOLL SIGIO /* System V name for SIGIO */ 166 | #define SIGXCPU 24 /* exceeded CPU time limit */ 167 | #define SIGXFSZ 25 /* exceeded file size limit */ 168 | #define SIGVTALRM 26 /* virtual time alarm */ 169 | #define SIGPROF 27 /* profiling time alarm */ 170 | #define SIGWINCH 28 /* window changed */ 171 | #define SIGLOST 29 /* resource lost (eg, record-lock lost) */ 172 | #define SIGUSR1 30 /* user defined signal 1 */ 173 | #define SIGUSR2 31 /* user defined signal 2 */ 174 | #define NSIG 32 /* signal 0 implied */ 175 | #endif 176 | #endif 177 | 178 | #ifdef __cplusplus 179 | } 180 | #endif 181 | #endif /* _SYS_SIGNAL_H */ 182 | -------------------------------------------------------------------------------- /target-inc/sys/stat-dj.h: -------------------------------------------------------------------------------- 1 | /* This is file STAT.H */ 2 | /* 3 | ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 4 | ** 5 | ** This file is distributed under the terms listed in the document 6 | ** "copying.dj", available from DJ Delorie at the address above. 7 | ** A copy of "copying.dj" should accompany this file; if not, a copy 8 | ** should be available from where this file was obtained. This file 9 | ** may not be distributed without a verbatim copy of "copying.dj". 10 | ** 11 | ** This file is distributed WITHOUT ANY WARRANTY; without even the implied 12 | ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | */ 14 | 15 | #ifndef _STAT_H_ 16 | #define _STAT_H_ 17 | 18 | struct stat { 19 | short st_dev; 20 | short st_ino; 21 | unsigned short st_mode; 22 | short st_nlink; 23 | short st_uid; 24 | short st_gid; 25 | short st_rdev; 26 | short st_align_for_word32; 27 | long st_size; 28 | long st_atime; 29 | long st_mtime; 30 | long st_ctime; 31 | long st_blksize; 32 | }; 33 | 34 | #define S_IFMT 0xF000 /* file type mask */ 35 | #define S_IFDIR 0x4000 /* directory */ 36 | #define S_IFIFO 0x1000 /* FIFO special */ 37 | #define S_IFCHR 0x2000 /* character special */ 38 | #define S_IFBLK 0x3000 /* block special */ 39 | #define S_IFREG 0x8000 /* or just 0x0000, regular */ 40 | #define S_IREAD 0x0100 /* owner may read */ 41 | #define S_IWRITE 0x0080 /* owner may write */ 42 | #define S_IEXEC 0x0040 /* owner may execute */ 43 | 44 | #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) 45 | #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) 46 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 47 | #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) 48 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | int stat(const char *, struct stat *); 54 | int fstat(int, struct stat *); 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /target-inc/sys/stat.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_STAT_H 2 | #define _SYS_STAT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include <_ansi.h> 9 | #include 10 | #include 11 | 12 | #ifdef __i386__ 13 | #ifdef __MSDOS__ 14 | #include "stat-dj.h" 15 | #endif 16 | #endif 17 | 18 | /* dj's stat defines _STAT_H_ */ 19 | #ifndef _STAT_H_ 20 | 21 | /* It is intended that the layout of this structure not change when the 22 | sizes of any of the basic types change (short, int, long) [via a compile 23 | time option]. */ 24 | 25 | struct stat { 26 | dev_t st_dev; 27 | ino_t st_ino; 28 | mode_t st_mode; 29 | nlink_t st_nlink; 30 | uid_t st_uid; 31 | gid_t st_gid; 32 | dev_t st_rdev; 33 | off_t st_size; 34 | /* SysV/sco doesn't have the rest... But Solaris, eabi does. */ 35 | #if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__) 36 | time_t st_atime; 37 | time_t st_mtime; 38 | time_t st_ctime; 39 | #else 40 | time_t st_atime; 41 | long st_spare1; 42 | time_t st_mtime; 43 | long st_spare2; 44 | time_t st_ctime; 45 | long st_spare3; 46 | long st_blksize; 47 | long st_blocks; 48 | long st_spare4[2]; 49 | #endif 50 | }; 51 | 52 | #define _IFMT 0170000 /* type of file */ 53 | #define _IFDIR 0040000 /* directory */ 54 | #define _IFCHR 0020000 /* character special */ 55 | #define _IFBLK 0060000 /* block special */ 56 | #define _IFREG 0100000 /* regular */ 57 | #define _IFLNK 0120000 /* symbolic link */ 58 | #define _IFSOCK 0140000 /* socket */ 59 | #define _IFIFO 0010000 /* fifo */ 60 | 61 | #define S_BLKSIZE 1024 /* size of a block */ 62 | 63 | #define S_ISUID 0004000 /* set user id on execution */ 64 | #define S_ISGID 0002000 /* set group id on execution */ 65 | #ifndef _POSIX_SOURCE 66 | #define S_ISVTX 0001000 /* save swapped text even after use */ 67 | #define S_IREAD 0000400 /* read permission, owner */ 68 | #define S_IWRITE 0000200 /* write permission, owner */ 69 | #define S_IEXEC 0000100 /* execute/search permission, owner */ 70 | 71 | #define S_ENFMT 0002000 /* enforcement-mode locking */ 72 | 73 | #define S_IFMT _IFMT 74 | #define S_IFDIR _IFDIR 75 | #define S_IFCHR _IFCHR 76 | #define S_IFBLK _IFBLK 77 | #define S_IFREG _IFREG 78 | #define S_IFLNK _IFLNK 79 | #define S_IFSOCK _IFSOCK 80 | #define S_IFIFO _IFIFO 81 | #endif /* !_POSIX_SOURCE */ 82 | 83 | #ifdef _WIN32 84 | /* The Windows header files define _S_ forms of these, so we do too 85 | for easier portability. */ 86 | #define _S_IFMT _IFMT 87 | #define _S_IFDIR _IFDIR 88 | #define _S_IFCHR _IFCHR 89 | #define _S_IFIFO _IFIFO 90 | #define _S_IFREG _IFREG 91 | #define _S_IREAD 0000400 92 | #define _S_IWRITE 0000200 93 | #define _S_IEXEC 0000100 94 | #endif 95 | 96 | #define S_IRWXU 0000700 /* rwx, owner */ 97 | #define S_IRUSR 0000400 /* read permission, owner */ 98 | #define S_IWUSR 0000200 /* write permission, owner */ 99 | #define S_IXUSR 0000100 /* execute/search permission, owner */ 100 | #define S_IRWXG 0000070 /* rwx, group */ 101 | #define S_IRGRP 0000040 /* read permission, group */ 102 | #define S_IWGRP 0000020 /* write permission, grougroup */ 103 | #define S_IXGRP 0000010 /* execute/search permission, group */ 104 | #define S_IRWXO 0000007 /* rwx, other */ 105 | #define S_IROTH 0000004 /* read permission, other */ 106 | #define S_IWOTH 0000002 /* write permission, other */ 107 | #define S_IXOTH 0000001 /* execute/search permission, other */ 108 | 109 | #define S_ISBLK(m) (((m)&_IFMT) == _IFBLK) 110 | #define S_ISCHR(m) (((m)&_IFMT) == _IFCHR) 111 | #define S_ISDIR(m) (((m)&_IFMT) == _IFDIR) 112 | #define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO) 113 | #define S_ISREG(m) (((m)&_IFMT) == _IFREG) 114 | #define S_ISLNK(m) (((m)&_IFMT) == _IFLNK) 115 | #define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK) 116 | 117 | 118 | int _EXFUN(chmod,(const char *__path, mode_t __mode)); 119 | int _EXFUN(fchmod,(int __fd, mode_t __mode)); 120 | int _EXFUN(fstat,(int __fd, struct stat *__sbuf)); 121 | int _EXFUN(mkdir,(const char *_path, mode_t __mode)); 122 | int _EXFUN(mkfifo,(const char *__path, mode_t __mode)); 123 | int _EXFUN(stat,(const char *__path, struct stat *__sbuf)); 124 | mode_t _EXFUN(umask,(mode_t __mask)); 125 | 126 | #if defined(__rtems__) 127 | int _EXFUN(mknod,(const char *_path, mode_t _mode, dev_t dev)); 128 | #endif 129 | 130 | /* Provide prototypes for most of the _ names that are 131 | provided in newlib for some compilers. */ 132 | int _EXFUN(_fstat,(int __fd, struct stat *__sbuf)); 133 | int _EXFUN(_stat,(const char *__path, struct stat *__sbuf)); 134 | 135 | #ifdef __CYGWIN32__ 136 | int _EXFUN(lstat,(const char *__path, struct stat *__buf)); 137 | #endif 138 | 139 | #if defined(__rtems__) 140 | int _EXFUN(mknod,(const char *_path, mode_t _mode, dev_t dev)); 141 | int _EXFUN(lstat,(const char *_path, struct stat *_sbuf)); 142 | #endif 143 | 144 | #endif /* !_STAT_H_ */ 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | #endif /* _SYS_STAT_H */ 149 | -------------------------------------------------------------------------------- /target-inc/sys/syscall.h: -------------------------------------------------------------------------------- 1 | #define SYS_exit 1 2 | #define SYS_fork 2 3 | 4 | #define SYS_read 3 5 | #define SYS_write 4 6 | #define SYS_open 5 7 | #define SYS_close 6 8 | #define SYS_wait4 7 9 | #define SYS_creat 8 10 | #define SYS_link 9 11 | #define SYS_unlink 10 12 | #define SYS_execv 11 13 | #define SYS_chdir 12 14 | #define SYS_mknod 14 15 | #define SYS_chmod 15 16 | #define SYS_chown 16 17 | #define SYS_lseek 19 18 | #define SYS_getpid 20 19 | #define SYS_isatty 21 20 | #define SYS_fstat 22 21 | #define SYS_time 23 22 | 23 | 24 | #define SYS_ARG 24 25 | #define SYS_stat 38 26 | 27 | #define SYS_pipe 42 28 | #define SYS_execve 59 29 | 30 | #define SYS_utime 201 /* not really a system call */ 31 | #define SYS_wait 202 /* nor is this */ 32 | -------------------------------------------------------------------------------- /target-inc/sys/time.h: -------------------------------------------------------------------------------- 1 | /* time.h -- An implementation of the standard Unix file. 2 | Written by Geoffrey Noer 3 | Public domain; no rights reserved. */ 4 | 5 | #ifndef _SYS_TIME_H_ 6 | #define _SYS_TIME_H_ 7 | 8 | #include <_ansi.h> 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #ifndef _WINSOCK_H 16 | struct timeval { 17 | long tv_sec; 18 | long tv_usec; 19 | }; 20 | 21 | struct timezone { 22 | int tz_minuteswest; 23 | int tz_dsttime; 24 | }; 25 | 26 | #ifdef __CYGWIN32__ 27 | #include 28 | #endif /* __CYGWIN32__ */ 29 | 30 | #endif /* _WINSOCK_H */ 31 | 32 | #define ITIMER_REAL 0 33 | #define ITIMER_VIRTUAL 1 34 | #define ITIMER_PROF 2 35 | 36 | struct itimerval { 37 | struct timeval it_interval; 38 | struct timeval it_value; 39 | }; 40 | 41 | int _EXFUN(gettimeofday, (struct timeval *__p, struct timezone *__z)); 42 | int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *)); 43 | int _EXFUN(utimes, (const char *__path, struct timeval *__tvp)); 44 | int _EXFUN(getitimer, (int __which, struct itimerval *__value)); 45 | int _EXFUN(setitimer, (int __which, const struct itimerval *__value, 46 | struct itimerval *__ovalue)); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | #endif /* _SYS_TIME_H_ */ 52 | -------------------------------------------------------------------------------- /target-inc/sys/timeb.h: -------------------------------------------------------------------------------- 1 | /* timeb.h -- An implementation of the standard Unix file. 2 | Written by Ian Lance Taylor 3 | Public domain; no rights reserved. 4 | 5 | declares the structure used by the ftime function, as 6 | well as the ftime function itself. Newlib does not provide an 7 | implementation of ftime. */ 8 | 9 | #ifndef _SYS_TIMEB_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | #define _SYS_TIMEB_H 16 | 17 | #include <_ansi.h> 18 | #include 19 | 20 | #ifndef __time_t_defined 21 | typedef _TIME_T_ time_t; 22 | #define __time_t_defined 23 | #endif 24 | 25 | struct timeb { 26 | time_t time; 27 | unsigned short millitm; 28 | short timezone; 29 | short dstflag; 30 | }; 31 | 32 | extern int ftime _PARAMS ((struct timeb *)); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif /* ! defined (_SYS_TIMEB_H) */ 39 | -------------------------------------------------------------------------------- /target-inc/sys/times.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_TIMES_H 2 | #ifdef __cplusplus 3 | extern "C" { 4 | #endif 5 | #define _SYS_TIMES_H 6 | 7 | #include <_ansi.h> 8 | #include 9 | 10 | #ifndef __clock_t_defined 11 | typedef _CLOCK_T_ clock_t; 12 | #define __clock_t_defined 13 | #endif 14 | 15 | struct tms { 16 | clock_t tms_utime; /* user time */ 17 | clock_t tms_stime; /* system time */ 18 | clock_t tms_cutime; /* user time, children */ 19 | clock_t tms_cstime; /* system time, children */ 20 | }; 21 | 22 | clock_t _EXFUN(times,(struct tms *)); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | #endif /* !_SYS_TIMES_H */ 28 | -------------------------------------------------------------------------------- /target-inc/sys/types.h: -------------------------------------------------------------------------------- 1 | /* unified sys/types.h: 2 | start with sef's sysvi386 version. 3 | merge go32 version -- a few ifdefs. 4 | h8300hms, h8300xray, and sysvnecv70 disagree on the following types: 5 | 6 | typedef int gid_t; 7 | typedef int uid_t; 8 | typedef int dev_t; 9 | typedef int ino_t; 10 | typedef int mode_t; 11 | typedef int caddr_t; 12 | 13 | however, these aren't "reasonable" values, the sysvi386 ones make far 14 | more sense, and should work sufficiently well (in particular, h8300 15 | doesn't have a stat, and the necv70 doesn't matter.) -- eichin 16 | */ 17 | 18 | #ifndef _SYS_TYPES_H 19 | #define _SYS_TYPES_H 20 | 21 | #if defined (_WIN32) || defined (__CYGWIN__) 22 | #define __MS_types__ 23 | #endif 24 | 25 | #ifdef __i386__ 26 | #if defined (GO32) || defined (__MSDOS__) 27 | #define __MS_types__ 28 | #endif 29 | #endif 30 | 31 | # include 32 | # include 33 | 34 | /* To ensure the stat struct's layout doesn't change when sizeof(int), etc. 35 | changes, we assume sizeof short and long never change and have all types 36 | used to define struct stat use them and not int where possible. 37 | Where not possible, _ST_INTxx are used. It would be preferable to not have 38 | such assumptions, but until the extra fluff is necessary, it's avoided. 39 | No 64 bit targets use stat yet. What to do about them is postponed 40 | until necessary. */ 41 | #ifdef __GNUC__ 42 | #define _ST_INT32 __attribute__ ((__mode__ (__SI__))) 43 | #else 44 | #define _ST_INT32 45 | #endif 46 | 47 | #ifndef _POSIX_SOURCE 48 | 49 | #define physadr physadr_t 50 | #define quad quad_t 51 | 52 | #ifndef _WINSOCK_H 53 | typedef unsigned char u_char; 54 | typedef unsigned short u_short; 55 | typedef unsigned int u_int; 56 | typedef unsigned long u_long; 57 | #endif 58 | 59 | typedef unsigned short ushort; /* System V compatibility */ 60 | typedef unsigned int uint; /* System V compatibility */ 61 | #endif /*!_POSIX_SOURCE */ 62 | 63 | #ifndef __time_t_defined 64 | typedef _TIME_T_ time_t; 65 | #define __time_t_defined 66 | #endif 67 | 68 | typedef long daddr_t; 69 | typedef char * caddr_t; 70 | 71 | #ifdef __MS_types__ 72 | typedef unsigned long ino_t; 73 | #else 74 | #ifdef __sparc__ 75 | typedef unsigned long ino_t; 76 | #else 77 | typedef unsigned short ino_t; 78 | #endif 79 | #endif 80 | 81 | #ifdef __MS_types__ 82 | typedef unsigned long vm_offset_t; 83 | typedef unsigned long vm_size_t; 84 | 85 | #define __BIT_TYPES_DEFINED__ 86 | 87 | typedef char int8_t; 88 | typedef unsigned char u_int8_t; 89 | typedef short int16_t; 90 | typedef unsigned short u_int16_t; 91 | typedef int int32_t; 92 | typedef unsigned int u_int32_t; 93 | typedef long long int64_t; 94 | typedef unsigned long long u_int64_t; 95 | typedef int32_t register_t; 96 | #endif /* __MS_types__ */ 97 | 98 | /* 99 | * All these should be machine specific - right now they are all broken. 100 | * However, for all of Cygnus' embedded targets, we want them to all be 101 | * the same. Otherwise things like sizeof (struct stat) might depend on 102 | * how the file was compiled (e.g. -mint16 vs -mint32, etc.). 103 | */ 104 | 105 | typedef short dev_t; 106 | typedef long off_t; 107 | typedef unsigned short uid_t; 108 | typedef unsigned short gid_t; 109 | typedef int pid_t; 110 | typedef long key_t; 111 | typedef long ssize_t; 112 | 113 | #ifdef __MS_types__ 114 | typedef char * addr_t; 115 | typedef int mode_t; 116 | #else 117 | #if defined (__sparc__) && !defined (__sparc_v9__) 118 | #ifdef __svr4__ 119 | typedef unsigned long mode_t; 120 | #else 121 | typedef unsigned short mode_t; 122 | #endif 123 | #else 124 | typedef unsigned int mode_t _ST_INT32; 125 | #endif 126 | #endif /* ! __MS_types__ */ 127 | 128 | typedef unsigned short nlink_t; 129 | 130 | /* We don't define fd_set and friends if we are compiling POSIX 131 | source, or if we have included the Windows Sockets.h header (which 132 | defines Windows versions of them). Note that a program which 133 | includes the Windows sockets.h header must know what it is doing; 134 | it must not call the cygwin32 select function. */ 135 | #if ! defined (_POSIX_SOURCE) && ! defined (_WINSOCK_H) 136 | 137 | #define NBBY 8 /* number of bits in a byte */ 138 | /* 139 | * Select uses bit masks of file descriptors in longs. 140 | * These macros manipulate such bit fields (the filesystem macros use chars). 141 | * FD_SETSIZE may be defined by the user, but the default here 142 | * should be >= NOFILE (param.h). 143 | */ 144 | #ifndef FD_SETSIZE 145 | #define FD_SETSIZE 64 146 | #endif 147 | 148 | typedef long fd_mask; 149 | #define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */ 150 | #ifndef howmany 151 | #define howmany(x,y) (((x)+((y)-1))/(y)) 152 | #endif 153 | 154 | /* We use a macro for fd_set so that including Sockets.h afterwards 155 | can work. */ 156 | typedef struct _types_fd_set { 157 | fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; 158 | } _types_fd_set; 159 | 160 | #define fd_set _types_fd_set 161 | 162 | #define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS))) 163 | #define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS))) 164 | #define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS))) 165 | #define FD_ZERO(p) bzero((caddr_t)(p), sizeof (*(p))) 166 | 167 | #endif /* ! defined (_POSIX_SOURCE) && ! defined (_WINSOCK_H) */ 168 | 169 | #undef __MS_types__ 170 | #undef _ST_INT32 171 | 172 | #endif /* _SYS_TYPES_H */ 173 | -------------------------------------------------------------------------------- /target-inc/sys/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_UNISTD_H 2 | #define _SYS_UNISTD_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include <_ansi.h> 9 | #include 10 | #define __need_size_t 11 | #include 12 | 13 | extern char **environ; 14 | 15 | void _EXFUN(_exit, (int __status) _ATTRIBUTE ((noreturn))); 16 | 17 | int _EXFUN(access,(const char *__path, int __amode)); 18 | unsigned _EXFUN(alarm, (unsigned __secs)); 19 | int _EXFUN(chdir, (const char *__path)); 20 | int _EXFUN(chmod, (const char *__path, mode_t __mode)); 21 | int _EXFUN(chown, (const char *__path, uid_t __owner, gid_t __group)); 22 | int _EXFUN(close, (int __fildes)); 23 | char _EXFUN(*ctermid, (char *__s)); 24 | char _EXFUN(*cuserid, (char *__s)); 25 | int _EXFUN(dup, (int __fildes)); 26 | int _EXFUN(dup2, (int __fildes, int __fildes2)); 27 | int _EXFUN(execl, (const char *__path, const char *, ...)); 28 | int _EXFUN(execle, (const char *__path, const char *, ...)); 29 | int _EXFUN(execlp, (const char *__file, const char *, ...)); 30 | int _EXFUN(execv, (const char *__path, char * const __argv[])); 31 | int _EXFUN(execve, (const char *__path, char * const __argv[], char * const __envp[])); 32 | int _EXFUN(execvp, (const char *__file, char * const __argv[])); 33 | pid_t _EXFUN(fork, (void)); 34 | long _EXFUN(fpathconf, (int __fd, int __name)); 35 | int _EXFUN(fsync, (int __fd)); 36 | char _EXFUN(*getcwd, (char *__buf, size_t __size)); 37 | gid_t _EXFUN(getegid, (void)); 38 | uid_t _EXFUN(geteuid, (void)); 39 | gid_t _EXFUN(getgid, (void)); 40 | int _EXFUN(getgroups, (int __gidsetsize, gid_t __grouplist[])); 41 | char _EXFUN(*getlogin, (void)); 42 | char _EXFUN(*getpass, (__const char *__prompt)); 43 | size_t _EXFUN(getpagesize, (void)); 44 | pid_t _EXFUN(getpgrp, (void)); 45 | pid_t _EXFUN(getpid, (void)); 46 | pid_t _EXFUN(getppid, (void)); 47 | uid_t _EXFUN(getuid, (void)); 48 | int _EXFUN(isatty, (int __fildes)); 49 | int _EXFUN(link, (const char *__path1, const char *__path2)); 50 | int _EXFUN(nice, (int __nice_value)); 51 | off_t _EXFUN(lseek, (int __fildes, off_t __offset, int __whence)); 52 | long _EXFUN(pathconf, (const char *__path, int __name)); 53 | int _EXFUN(pause, (void)); 54 | int _EXFUN(pipe, (int __fildes[2])); 55 | int _EXFUN(read, (int __fildes, void *__buf, size_t __nbyte)); 56 | int _EXFUN(rmdir, (const char *__path)); 57 | void * _EXFUN(sbrk, (size_t __incr)); 58 | int _EXFUN(setgid, (gid_t __gid)); 59 | int _EXFUN(setpgid, (pid_t __pid, pid_t __pgid)); 60 | pid_t _EXFUN(setsid, (void)); 61 | int _EXFUN(setuid, (uid_t __uid)); 62 | unsigned _EXFUN(sleep, (unsigned int __seconds)); 63 | void _EXFUN(swab, (const void *, void *, ssize_t)); 64 | long _EXFUN(sysconf, (int __name)); 65 | pid_t _EXFUN(tcgetpgrp, (int __fildes)); 66 | int _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id)); 67 | char _EXFUN(*ttyname, (int __fildes)); 68 | int _EXFUN(unlink, (const char *__path)); 69 | int _EXFUN(write, (int __fildes, const void *__buf, size_t __nbyte)); 70 | 71 | /* Provide prototypes for most of the _ names that are 72 | provided in newlib for some compilers. */ 73 | int _EXFUN(_close, (int __fildes)); 74 | pid_t _EXFUN(_fork, (void)); 75 | pid_t _EXFUN(_getpid, (void)); 76 | int _EXFUN(_link, (const char *__path1, const char *__path2)); 77 | off_t _EXFUN(_lseek, (int __fildes, off_t __offset, int __whence)); 78 | int _EXFUN(_read, (int __fildes, void *__buf, size_t __nbyte)); 79 | void * _EXFUN(_sbrk, (size_t __incr)); 80 | int _EXFUN(_unlink, (const char *__path)); 81 | int _EXFUN(_write, (int __fildes, const void *__buf, size_t __nbyte)); 82 | 83 | #if defined(__CYGWIN32__) || defined(__rtems__) 84 | unsigned _EXFUN(usleep, (unsigned int __useconds)); 85 | int _EXFUN(ftruncate, (int __fd, off_t __length)); 86 | int _EXFUN(truncate, (const char *, off_t __length)); 87 | int _EXFUN(gethostname, (char *__name, size_t __len)); 88 | char * _EXFUN(mktemp, (char *)); 89 | int _EXFUN(sync, (void)); 90 | int _EXFUN(readlink, (const char *__path, char *__buf, int __buflen)); 91 | int _EXFUN(symlink, (const char *__name1, const char *__name2)); 92 | #endif 93 | 94 | #define F_OK 0 95 | #define R_OK 4 96 | #define W_OK 2 97 | #define X_OK 1 98 | 99 | #define SEEK_SET 0 100 | #define SEEK_CUR 1 101 | #define SEEK_END 2 102 | 103 | /* 104 | * RTEMS adheres to a later version of POSIX -- 1003.1b. 105 | * 106 | * XXX this version string should change. 107 | */ 108 | 109 | #ifdef __rtems__ 110 | #ifndef _POSIX_JOB_CONTROL 111 | # define _POSIX_JOB_CONTROL 1 112 | #endif 113 | #ifndef _POSIX_SAVED_IDS 114 | # define _POSIX_SAVED_IDS 1 115 | #endif 116 | # define _POSIX_VERSION 199009L 117 | #else 118 | #ifdef __svr4__ 119 | # define _POSIX_JOB_CONTROL 1 120 | # define _POSIX_SAVED_IDS 1 121 | # define _POSIX_VERSION 199009L 122 | #endif 123 | #endif 124 | 125 | #ifdef __CYGWIN32__ 126 | # define _POSIX_JOB_CONTROL 1 127 | # define _POSIX_SAVED_IDS 0 128 | # define _POSIX_VERSION 199009L 129 | #endif 130 | 131 | #define STDIN_FILENO 0 /* standard input file descriptor */ 132 | #define STDOUT_FILENO 1 /* standard output file descriptor */ 133 | #define STDERR_FILENO 2 /* standard error file descriptor */ 134 | 135 | long _EXFUN(sysconf, (int __name)); 136 | 137 | #define _SC_ARG_MAX 0 138 | #define _SC_CHILD_MAX 1 139 | #define _SC_CLK_TCK 2 140 | #define _SC_NGROUPS_MAX 3 141 | #define _SC_OPEN_MAX 4 142 | /* no _SC_STREAM_MAX */ 143 | #define _SC_JOB_CONTROL 5 144 | #define _SC_SAVED_IDS 6 145 | #define _SC_VERSION 7 146 | #define _SC_PAGESIZE 8 147 | 148 | #define _PC_LINK_MAX 0 149 | #define _PC_MAX_CANON 1 150 | #define _PC_MAX_INPUT 2 151 | #define _PC_NAME_MAX 3 152 | #define _PC_PATH_MAX 4 153 | #define _PC_PIPE_BUF 5 154 | #define _PC_CHOWN_RESTRICTED 6 155 | #define _PC_NO_TRUNC 7 156 | #define _PC_VDISABLE 8 157 | #define _PC_ASYNC_IO 9 158 | #define _PC_PRIO_IO 10 159 | #define _PC_SYNC_IO 11 160 | 161 | #ifndef _POSIX_SOURCE 162 | #define MAXNAMLEN 1024 163 | #endif /* _POSIX_SOURCE */ 164 | 165 | /* FIXME: This is temporary until winsup gets sorted out. */ 166 | #ifdef __CYGWIN32__ 167 | #define MAXPATHLEN (260 - 1 /* NUL */) 168 | #else 169 | #define MAXPATHLEN 1024 170 | #endif 171 | 172 | #ifdef __cplusplus 173 | } 174 | #endif 175 | #endif /* _SYS_UNISTD_H */ 176 | -------------------------------------------------------------------------------- /target-inc/sys/utime.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_UTIME_H 2 | #define _SYS_UTIME_H 3 | 4 | /* This is a dummy file, not customized for any 5 | particular system. If there is a utime.h in libc/sys/SYSDIR/sys, 6 | it will override this one. */ 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | struct utimbuf { 13 | time_t actime; 14 | time_t modtime; 15 | }; 16 | 17 | #ifdef __cplusplus 18 | }; 19 | #endif 20 | 21 | #endif /* _SYS_UTIME_H */ 22 | -------------------------------------------------------------------------------- /target-inc/sys/wait.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYS_WAIT_H 2 | #define _SYS_WAIT_H 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | 10 | #define WNOHANG 1 11 | #define WUNTRACED 2 12 | 13 | /* A status looks like: 14 | <2 bytes info> <2 bytes code> 15 | 16 | == 0, child has exited, info is the exit value 17 | == 1..7e, child has exited, info is the signal number. 18 | == 7f, child has stopped, info was the signal number. 19 | == 80, there was a core dump. 20 | */ 21 | 22 | #define WIFEXITED(w) (((w) & 0xff) == 0) 23 | #define WIFSIGNALED(w) (((w) & 0x7f) > 0 && (((w) & 0x7f) < 0x7f)) 24 | #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) 25 | #define WEXITSTATUS(w) (((w) >> 8) & 0xff) 26 | #define WTERMSIG(w) ((w) & 0x7f) 27 | #define WSTOPSIG WEXITSTATUS 28 | 29 | pid_t wait (int *); 30 | pid_t waitpid (pid_t, int *, int); 31 | 32 | /* Provide prototypes for most of the _ names that are 33 | provided in newlib for some compilers. */ 34 | pid_t _wait (int *); 35 | 36 | #ifdef __cplusplus 37 | }; 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /target-inc/termios.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | #include 5 | #ifdef __cplusplus 6 | } 7 | #endif 8 | -------------------------------------------------------------------------------- /target-inc/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * time.h 3 | * 4 | * Struct and function declarations for dealing with time. 5 | */ 6 | 7 | #ifndef _TIME_H_ 8 | #define _TIME_H_ 9 | 10 | #include "_ansi.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #ifndef NULL 17 | #define NULL 0 18 | #endif 19 | 20 | /* Get _CLOCKS_PER_SEC_ */ 21 | #include 22 | 23 | #ifndef _CLOCKS_PER_SEC_ 24 | #define _CLOCKS_PER_SEC_ 1000 25 | #endif 26 | 27 | #define CLOCKS_PER_SEC _CLOCKS_PER_SEC_ 28 | #define CLK_TCK CLOCKS_PER_SEC 29 | #define __need_size_t 30 | #include 31 | 32 | /* Get _CLOCK_T_ and _TIME_T_. */ 33 | #include 34 | 35 | #ifndef __clock_t_defined 36 | typedef _CLOCK_T_ clock_t; 37 | #define __clock_t_defined 38 | #endif 39 | 40 | #ifndef __time_t_defined 41 | typedef _TIME_T_ time_t; 42 | #define __time_t_defined 43 | #endif 44 | 45 | struct tm { 46 | int tm_sec; 47 | int tm_min; 48 | int tm_hour; 49 | int tm_mday; 50 | int tm_mon; 51 | int tm_year; 52 | int tm_wday; 53 | int tm_yday; 54 | int tm_isdst; 55 | }; 56 | 57 | clock_t _EXFUN(clock, (void)); 58 | double _EXFUN(difftime, (time_t _time2, time_t _time1)); 59 | time_t _EXFUN(mktime, (struct tm *_timeptr)); 60 | time_t _EXFUN(time, (time_t *_timer)); 61 | #ifndef _REENT_ONLY 62 | char *_EXFUN(asctime, (const struct tm *_tblock)); 63 | char *_EXFUN(ctime, (const time_t *_time)); 64 | struct tm *_EXFUN(gmtime, (const time_t *_timer)); 65 | struct tm *_EXFUN(localtime,(const time_t *_timer)); 66 | #endif 67 | size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t)); 68 | 69 | char *_EXFUN(asctime_r,(const struct tm *, char *)); 70 | char *_EXFUN(ctime_r, (const time_t *, char *)); 71 | struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *)); 72 | struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *)); 73 | 74 | #ifdef __CYGWIN32__ 75 | #ifndef __STRICT_ANSI__ 76 | extern time_t _timezone __declspec(dllimport); 77 | extern int _daylight __declspec(dllimport); 78 | extern char *_tzname[2] __declspec(dllimport); 79 | 80 | char *_EXFUN(timezone, (void)); 81 | void _EXFUN(tzset, (void)); 82 | #endif 83 | #endif /* __CYGWIN32__ */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | #endif /* _TIME_H_ */ 89 | 90 | -------------------------------------------------------------------------------- /target-inc/unctrl.h: -------------------------------------------------------------------------------- 1 | /* From curses.h. */ 2 | /* 3 | * Copyright (c) 1981, 1993 4 | * The Regents of the University of California. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. All advertising materials mentioning features or use of this software 15 | * must display the following acknowledgement: 16 | * This product includes software developed by the University of 17 | * California, Berkeley and its contributors. 18 | * 4. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #ifndef _UNCTRL_H_ 36 | #define _UNCTRL_H_ 37 | 38 | #include <_ansi.h> 39 | 40 | #define unctrl(c) __unctrl[(c) & 0xff] 41 | #define unctrllen(ch) __unctrllen[(ch) & 0xff] 42 | 43 | extern _CONST char * _CONST __unctrl[256]; /* Control strings. */ 44 | extern _CONST char __unctrllen[256]; /* Control strings length. */ 45 | 46 | #endif /* _UNCTRL_H_ */ 47 | -------------------------------------------------------------------------------- /target-inc/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNISTD_H_ 2 | #define _UNISTD_H_ 3 | 4 | #include 5 | 6 | #endif /* _UNISTD_H_ */ 7 | -------------------------------------------------------------------------------- /target-inc/utime.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | /* The utime function is defined in libc/sys//sys if it exists. */ 6 | #include 7 | 8 | #ifdef __cplusplus 9 | } 10 | #endif 11 | -------------------------------------------------------------------------------- /target-inc/utmp.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | #include 5 | #ifdef __cplusplus 6 | } 7 | #endif 8 | -------------------------------------------------------------------------------- /target-src/1st_read/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.cfg 2 | 3 | TARGET = 1st_read.bin 4 | 5 | all: rm-elf $(TARGET) 6 | 7 | .PHONY : clean 8 | clean: 9 | -rm -f $(TARGET) 1st_read.bin loader.elf 10 | 11 | .PHONY : distclean 12 | distclean: clean 13 | 14 | .PHONY : rm-elf 15 | rm-elf: 16 | -rm -f $(TARGET) loader.elf 17 | 18 | loader.elf: loader.s disable.s ../dcload/dcload.bin ../dcload/exception.bin 19 | $(TARGETCC) $(TARGETCFLAGS) -o $@ loader.s disable.s -nostartfiles \ 20 | -nostdlib -Ttext=0x8c010000 -Wa,-I../dcload 21 | 22 | loader.bin: loader.elf 23 | $(TARGETOBJCOPY) -O binary $^ $@ 24 | 25 | # 1st_read.bin 26 | $(TARGET): loader.bin 27 | $(KOS_BASE)/utils/scramble/scramble $< $@ 28 | -------------------------------------------------------------------------------- /target-src/1st_read/disable.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .global _disable_cache 3 | 4 | _disable_cache: 5 | mov.l disable_cache_k,r0 6 | mov.l p2_mask,r1 7 | or r1,r0 8 | jmp @r0 9 | nop 10 | disable_cache: 11 | mov.l ccr_addr,r0 12 | mov.l ccr_data_k,r1 13 | mov.l @r1,r1 14 | mov.l r1,@r0 15 | nop 16 | nop 17 | nop 18 | nop 19 | nop 20 | nop 21 | nop 22 | nop 23 | rts 24 | nop 25 | 26 | .align 4 27 | 28 | disable_cache_k: 29 | .long disable_cache 30 | p2_mask: 31 | .long 0xa0000000 32 | ccr_addr: 33 | .long 0xff00001c 34 | ccr_data_k: 35 | .long ccr_data 36 | ccr_data: 37 | .long 0x00000808 38 | -------------------------------------------------------------------------------- /target-src/1st_read/loader.s: -------------------------------------------------------------------------------- 1 | ! This file is part of dcload 2 | ! Copyright (C) 2011-2013 Lawrence Sebald 3 | ! 4 | ! This program is free software: you can redistribute it and/or modify 5 | ! it under the terms of the GNU General Public License as published by 6 | ! the Free Software Foundation; either version 2 of the License, or 7 | ! (at your option) any later version. 8 | ! 9 | ! This program is distributed in the hope that it will be useful, 10 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | ! GNU General Public License for more details. 13 | ! 14 | ! You should have received a copy of the GNU General Public License 15 | ! along with this program. If not, see . 16 | 17 | ! This code is responsible for loading the main dcload binary into RAM at a 18 | ! convenient location (0x8c004000) as well as the default exception handler 19 | ! binary to its home (0x8c00f400). 20 | .text 21 | .balign 2 22 | .globl start 23 | start: 24 | ! Disable interrupts 25 | mov.l init_sr, r0 26 | ldc r0, sr 27 | mov.l disable_cache, r4 28 | jsr @r4 29 | nop 30 | ! Clear out the whole area 31 | mov.l dcload_base, r2 32 | mov.l dcload_max_sz, r1 33 | mov #0, r0 34 | cl_loop: 35 | dt r1 36 | mov.l r0, @r2 37 | bf/s cl_loop 38 | add #4, r2 39 | ! Copy the exception binary over to the appropriate location 40 | mov.l exception_base, r2 41 | mov.l exception_size, r1 42 | mov.l exception_ptr, r0 43 | ex_loop: 44 | mov.l @r0+, r3 45 | dt r1 46 | mov.l r3, @r2 47 | bf/s ex_loop 48 | add #4, r2 49 | ! Copy the binary over to the appropriate location 50 | mov.l dcload_base, r2 51 | mov.l dcload_size, r1 52 | mov.l dcload_ptr, r0 53 | loop: 54 | mov.l @r0+, r3 55 | dt r1 56 | mov.l r3, @r2 57 | bf/s loop 58 | add #4, r2 59 | ! Jump to the main dcload binary. 60 | mov.l dcload_base, r4 61 | jmp @r4 62 | nop 63 | 64 | .balign 4 65 | init_sr: 66 | .long 0x500000f0 67 | exception_size: 68 | .long (exception_end - exception) >> 2 69 | exception_ptr: 70 | .long exception 71 | exception_base: 72 | .long 0x8c00f400 73 | dcload_size: 74 | .long (dcload_end - dcload) >> 2 75 | dcload_ptr: 76 | .long dcload 77 | dcload_base: 78 | .long 0x8c004000 79 | disable_cache: 80 | .long _disable_cache 81 | dcload_max_sz: 82 | .long (0x8c010000 - 0x8c004000) >> 2 83 | 84 | ! Include the binaries here, making sure they're aligned to 4 byte boundaries 85 | ! and that they're a multiple of 4 bytes in size. 86 | .section .rodata 87 | .balign 4 88 | dcload: 89 | .incbin "dcload.bin" 90 | .balign 4 91 | dcload_end: 92 | 93 | .section .rodata 94 | .balign 4 95 | exception: 96 | .incbin "exception.bin" 97 | .balign 4 98 | exception_end: 99 | -------------------------------------------------------------------------------- /target-src/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIRS = 1st_read dcload 2 | MAKE ?= make 3 | 4 | .PHONY : subdirs $(SUBDIRS) 5 | 6 | subdirs: $(SUBDIRS) 7 | 8 | $(SUBDIRS): 9 | $(MAKE) -C $@ 10 | 11 | 1st_read: dcload 12 | 13 | .PHONY : clean 14 | clean: 15 | for dir in $(SUBDIRS); do \ 16 | $(MAKE) -C $$dir clean; \ 17 | done 18 | 19 | .PHONY : distclean 20 | distclean: 21 | for dir in $(SUBDIRS) ; do \ 22 | $(MAKE) -C $$dir distclean; \ 23 | done 24 | 25 | -------------------------------------------------------------------------------- /target-src/dcload/Makefile: -------------------------------------------------------------------------------- 1 | include ../../Makefile.cfg 2 | 3 | LZOPATH = ../../minilzo-2.10 4 | LZO = ../../host-src/misc/lzo 5 | 6 | CC = $(TARGETCC) 7 | CFLAGS = $(TARGETCFLAGS) -DDCLOAD_VERSION=\"$(VERSION)\" 8 | INCLUDE = -I$(LZOPATH) -I../../target-inc 9 | 10 | OBJCOPY = $(TARGETOBJCOPY) 11 | 12 | #DCLOBJECTS = dcload-crt0.o syscalls.o memcpy.o memset.o memmove.o memcmp.o scif.o disable.o go.o video.o minilzo.o dcload.o cdfs_redir.o cdfs_syscalls.o bswap.o 13 | DCLOBJECTS = dcload-crt0.o syscalls.o memcpy.o memset.o memmove.o memcmp.o scif.o disable.o go.o video.o minilzo.o dcload.o cdfs_redir.o cdfs_syscalls.o 14 | EXCOBJECTS = exception.o 15 | LZOFILES = $(LZOPATH)/minilzo.c $(LZOPATH)/minilzo.h $(LZOPATH)/lzoconf.h 16 | 17 | .c.o: 18 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 19 | .s.o: 20 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 21 | .S.o: 22 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 23 | 24 | all: dcload.lzo exception.lzo 25 | 26 | dcload.lzo: dcload.bin 27 | $(LZO) $< $@ 28 | 29 | dcload.bin: dcload 30 | $(OBJCOPY) -R .stack -O binary $< $@ 31 | 32 | dcload: $(DCLOBJECTS) 33 | $(CC) $(CFLAGS) -Wl,-Tdcload.x -nostartfiles -nostdlib $^ -o $@ -lgcc 34 | 35 | exception.lzo: exception.bin 36 | $(LZO) $< $@ 37 | 38 | exception.bin: exception 39 | $(OBJCOPY) -O binary $< $@ 40 | 41 | exception: $(EXCOBJECTS) 42 | $(CC) $(CFLAGS) -Wl,-Ttext=0x8c00f400 -nostartfiles -nostdlib $^ -o $@ 43 | 44 | minilzo.o: $(LZOFILES) 45 | $(CC) $(CFLAGS) $(INCLUDE) -o $@ -c $< 46 | 47 | .PHONY : clean 48 | clean: 49 | -rm -f $(DCLOBJECTS) $(EXCOBJECTS) dcload exception dcload.bin exception.bin 50 | 51 | .PHONY : distclean 52 | distclean: clean 53 | -rm -f *.lzo 54 | -------------------------------------------------------------------------------- /target-src/dcload/asm.h: -------------------------------------------------------------------------------- 1 | #ifdef __STDC__ 2 | # define _C_LABEL(x) _ ## x 3 | #else 4 | # define _C_LABEL(x) _/**/x 5 | #endif 6 | #define _ASM_LABEL(x) x 7 | 8 | #define _ENTRY(name) \ 9 | .text; .align 2; .globl name; name: 10 | 11 | #define ENTRY(name) \ 12 | _ENTRY(_C_LABEL(name)) 13 | 14 | #if (defined (__sh2__) || defined (__sh3__) || defined (__SH3E__) \ 15 | || defined (__SH4_SINGLE__) || defined (__SH4__)) || defined(__SH4_SINGLE_ONLY__) 16 | #define DELAYED_BRANCHES 17 | #define SL(branch, dest, in_slot, in_slot_arg2) \ 18 | branch##.s dest; in_slot, in_slot_arg2 19 | #else 20 | #define SL(branch, dest, in_slot, in_slot_arg2) \ 21 | in_slot, in_slot_arg2; branch dest 22 | #endif 23 | -------------------------------------------------------------------------------- /target-src/dcload/cdfs_redir.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .global _cdfs_redir_enable 3 | .global _cdfs_redir_disable 4 | .global _cdfs_redir_save 5 | .align 2 6 | 7 | _cdfs_redir_save: 8 | mov.l cdfs_saved_k, r0 9 | mov.l @r0, r0 10 | tst r0,r0 11 | bf already_saved 12 | mov.l cdfs_entry_k, r0 13 | mov.l @r0,r0 14 | mov.l cdfs_saved_k, r1 15 | mov.l r0, @r1 16 | already_saved: 17 | rts 18 | nop 19 | 20 | _cdfs_redir_disable: 21 | mov.l cdfs_saved_k, r0 22 | mov.l @r0, r0 23 | mov.l cdfs_entry_k, r1 24 | mov.l r0, @r1 25 | rts 26 | nop 27 | 28 | _cdfs_redir_enable: 29 | mov.l cdfs_entry_k, r0 30 | mov.l cdfs_redir_k, r1 31 | mov.l r1, @r0 32 | rts 33 | nop 34 | 35 | .align 4 36 | cdfs_entry_k: 37 | .long 0x8c0000bc 38 | cdfs_saved_k: 39 | .long cdfs_saved 40 | cdfs_saved: 41 | .long 0 42 | cdfs_redir_k: 43 | .long cdfs_redir 44 | 45 | cdfs_redir: 46 | mov r7,r0 47 | mov #10,r1 48 | cmp/hs r0,r1 49 | bf badsyscall 50 | mov.l gd_first_k,r1 51 | shll2 r0 52 | mov.l @(r0,r1),r0 53 | jmp @r0 54 | nop 55 | badsyscall: 56 | mov #-1,r0 57 | rts 58 | nop 59 | 60 | gd_first_k: 61 | .long gdGdcReqCmd 62 | gdGdcReqCmd: 63 | .long _gdGdcReqCmd 64 | gdGdcGetCmdStat: 65 | .long _gdGdcGetCmdStat 66 | gdGdcExecServer: 67 | .long _gdGdcExecServer 68 | gdGdcInitSystem: 69 | .long _gdGdcInitSystem 70 | gdGdcGetDrvStat: 71 | .long _gdGdcGetDrvStat 72 | gdGdcG1DmaEnd: 73 | .long badsyscall 74 | gdGdcReqDmaTrans: 75 | .long badsyscall 76 | gdGdcCheckDmaTrans: 77 | .long badsyscall 78 | gdGdcReadAbort: 79 | .long badsyscall 80 | gdGdcReset: 81 | .long badsyscall 82 | gdGdcChangeDataType: 83 | .long _gdGdcChangeDataType 84 | -------------------------------------------------------------------------------- /target-src/dcload/cdfs_syscalls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the dcload Dreamcast serial loader 3 | * 4 | * Copyright (C) 2001 Andrew Kieschnick 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include "scif.h" 23 | 24 | extern void load_data_block_general(unsigned char *addr, 25 | unsigned int size, unsigned int verbose); 26 | extern unsigned int send_data_block_compressed(unsigned char * addr, 27 | unsigned int size); 28 | extern unsigned int get_uint(void); 29 | extern int put_uint(unsigned int val); 30 | 31 | int gdStatus; 32 | 33 | struct TOC { 34 | unsigned int entry[99]; 35 | unsigned int first, last; 36 | unsigned int dunno; 37 | }; 38 | 39 | int gdGdcReqCmd(int cmd, int *param) { 40 | struct TOC *toc; 41 | int i; 42 | 43 | switch (cmd) { 44 | case 16: /* read sectors */ 45 | scif_putchar(19); 46 | put_uint(param[0]); /* starting sector */ 47 | put_uint(param[1]); /* number of sectors */ 48 | load_data_block_general((unsigned char *)param[2], param[1]*2048, 0); 49 | param[3] = 0; 50 | gdStatus = 2; 51 | return 0; 52 | case 19: /* read toc */ 53 | toc = (struct TOC *)param[1]; 54 | toc->entry[0] = 0x41000096; /* CTRL = 4, ADR = 1, LBA = 150 */ 55 | for(i=1; i<99; i++) 56 | toc->entry[i] = -1; 57 | toc->first = 0x41010000; /* first = track 1 */ 58 | toc->last = 0x41010000; /* last = track 1 */ 59 | gdStatus = 2; 60 | return 0; 61 | case 24: /* init disc */ 62 | gdStatus = 2; 63 | return 0; 64 | default: 65 | gdStatus = 0; 66 | return -1; 67 | } 68 | } 69 | 70 | void gdGdcExecServer(void) { } 71 | 72 | int gdGdcGetCmdStat(int f, int *status) { 73 | if(gdStatus == 0) 74 | status[0] = 0; 75 | 76 | return gdStatus; 77 | } 78 | 79 | void gdGdcGetDrvStat(int *param) { 80 | param[1] = 32; 81 | } 82 | 83 | int gdGdcChangeDataType(int *param) { 84 | return 0; 85 | } 86 | 87 | void gdGdcInitSystem(void) { } 88 | 89 | -------------------------------------------------------------------------------- /target-src/dcload/dcload-crt0.s: -------------------------------------------------------------------------------- 1 | ! crt0.s for dcload 2 | 3 | .section .text 4 | .global start 5 | .global _atexit 6 | .global _dcloadsyscall 7 | start: 8 | bra realstart 9 | nop 10 | 11 | ! for checking if dcload is present 12 | 13 | dcloadmagic: 14 | .long 0xdeadbeef 15 | 16 | ! normal programs use this call 17 | 18 | dcloadsyscall_k: 19 | .long _dcloadsyscall 20 | 21 | ! exception handler uses these calls 22 | 23 | setup_video_k: 24 | .long _setup_video 25 | clrscr_k: 26 | .long _clrscr 27 | draw_string_k: 28 | .long _draw_string 29 | uint_to_string_k: 30 | .long _uint_to_string 31 | exc_to_string_k: 32 | .long _exception_code_to_string 33 | 34 | realstart: 35 | stc sr,r0 36 | mov.l sr_mask,r1 37 | and r1,r0 38 | or #0xf0,r0 39 | ldc r0,sr 40 | mov.l setup_cache_k,r0 41 | mov.l p2_mask,r1 42 | or r1,r0 43 | jmp @r0 44 | nop 45 | 46 | setup_cache: 47 | mov.l ccr_addr,r0 48 | mov.w ccr_data,r1 49 | mov.l r1,@r0 50 | mov.l start_2_k,r0 51 | mov #0,r1 52 | nop 53 | nop 54 | nop 55 | nop 56 | nop 57 | nop 58 | jmp @r0 59 | mov r1,r0 60 | 61 | start_2: 62 | mov.l stack_k,r15 63 | ! zero out bss 64 | mov.l edata_k,r0 65 | mov.l end_k,r1 66 | mov #0,r2 67 | 68 | start_l: 69 | mov.l r2,@r0 70 | add #4,r0 71 | cmp/ge r0,r1 72 | bt start_l 73 | 74 | mov.l set_fpscr_k, r1 75 | jsr @r1 76 | mov #0,r4 77 | lds r3,fpscr 78 | 79 | ! call main 80 | mov.l main_k,r0 81 | jsr @r0 82 | or r0,r0 83 | ! bootloader should never exit, but what the hell 84 | bra realstart 85 | nop 86 | 87 | _atexit: 88 | rts 89 | nop 90 | 91 | 92 | .align 4 93 | sr_mask: 94 | .long 0xefff7fff 95 | set_fpscr_k: 96 | .long ___set_fpscr 97 | stack_k: 98 | .long _stack 99 | edata_k: 100 | .long _edata 101 | end_k: 102 | .long _end 103 | main_k: 104 | .long _main 105 | setup_cache_k: 106 | .long setup_cache 107 | start_2_k: 108 | .long start_2 109 | p2_mask: 110 | .long 0xa0000000 111 | ccr_addr: 112 | .long 0xff00001c 113 | ccr_data: 114 | .word 0x090b 115 | 116 | _dcloadsyscall: 117 | mov.l dcloadmagic_k,r1 118 | mov.l @r1,r1 119 | mov.l correctmagic,r0 120 | cmp/eq r0,r1 121 | bf badsyscall 122 | 123 | mov r4,r0 124 | mov r5,r4 125 | mov r6,r5 126 | mov r7,r6 127 | 128 | mov #21,r1 129 | cmp/hs r0,r1 130 | bf badsyscall 131 | 132 | mov.l first_syscall,r1 133 | shll2 r0 134 | mov.l @(r0,r1),r0 135 | jmp @r0 136 | nop 137 | 138 | badsyscall: 139 | mov #-1,r0 140 | rts 141 | nop 142 | 143 | .align 4 144 | dcloadmagic_k: 145 | .long dcloadmagic 146 | correctmagic: 147 | .long 0xdeadbeef 148 | first_syscall: 149 | .long read_k 150 | read_k: 151 | .long _read 152 | write_k: 153 | .long _write 154 | open_k: 155 | .long _open 156 | close_k: 157 | .long _close 158 | creat_k: 159 | .long _creat 160 | link_k: 161 | .long _link 162 | unlink_k: 163 | .long _unlink 164 | chdir_k: 165 | .long _chdir 166 | chmod_k: 167 | .long _chmod 168 | lseek_k: 169 | .long _lseek 170 | fstat_k: 171 | .long _fstat 172 | time_k: 173 | .long _time 174 | stat_k: 175 | .long _stat 176 | utime_k: 177 | .long _utime 178 | assign_wrkmem_k: 179 | .long _assign_wrkmem 180 | exit_k: 181 | .long _dcexit 182 | opendir_k: 183 | .long _opendir 184 | closedir_k: 185 | .long _closedir 186 | readdir_k: 187 | .long _readdir 188 | unk19_k: 189 | .long 0 190 | gdbpacket_k: 191 | .long _gdbpacket 192 | rewinddir_k: 193 | .long _rewinddir 194 | -------------------------------------------------------------------------------- /target-src/dcload/disable.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .global _disable_cache 3 | 4 | _disable_cache: 5 | mov.l disable_cache_k,r0 6 | mov.l p2_mask,r1 7 | or r1,r0 8 | jmp @r0 9 | nop 10 | disable_cache: 11 | mov.l ccr_addr,r0 12 | mov.l ccr_data_k,r1 13 | mov.l @r1,r1 14 | mov.l r1,@r0 15 | nop 16 | nop 17 | nop 18 | nop 19 | nop 20 | nop 21 | nop 22 | nop 23 | rts 24 | nop 25 | 26 | .align 4 27 | 28 | disable_cache_k: 29 | .long disable_cache 30 | p2_mask: 31 | .long 0xa0000000 32 | ccr_addr: 33 | .long 0xff00001c 34 | ccr_data_k: 35 | .long ccr_data 36 | ccr_data: 37 | .long 0x00000808 38 | -------------------------------------------------------------------------------- /target-src/dcload/go.s: -------------------------------------------------------------------------------- 1 | .section .text 2 | .global _go 3 | 4 | _go: 5 | mov.l stack_addr_k,r0 6 | mov.l @r0,r15 7 | mov.l entry_addr_k,r0 8 | mov.l @r0,r0 9 | lds r0,pr 10 | mov.l sr_data_k,r0 11 | mov.l @r0,r0 12 | ldc r0,sr 13 | mov.l vbr_data_k,r0 14 | mov.l @r0,r0 15 | ldc r0,vbr 16 | mov.l fpscr_data_k,r0 17 | mov.l @r0,r0 18 | lds r0,fpscr 19 | mov #0,r0 20 | mov r0,r1 21 | mov r0,r2 22 | mov r0,r3 23 | mov r0,r5 24 | mov r0,r6 25 | mov r0,r7 26 | mov r0,r8 27 | mov r0,r9 28 | mov r0,r10 29 | mov r0,r11 30 | mov r0,r12 31 | mov r0,r13 32 | mov r0,r14 33 | jmp @r4 34 | mov r0,r4 35 | 36 | .align 4 37 | stack_addr_k: 38 | .long stack_addr 39 | stack_addr: 40 | .long 0x8c00f400 41 | entry_addr_k: 42 | .long entry_addr 43 | entry_addr: 44 | .long 0x8c004000 45 | sr_data_k: 46 | .long sr_data 47 | sr_data: 48 | .long 0x500000f0 49 | vbr_data_k: 50 | .long vbr_data 51 | vbr_data: 52 | .long 0x8c00f400 53 | fpscr_data_k: 54 | .long fpscr_data 55 | fpscr_data: 56 | .long 0x40001 57 | -------------------------------------------------------------------------------- /target-src/dcload/memcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | FUNCTION 3 | <>---compare two memory areas 4 | 5 | INDEX 6 | memcmp 7 | 8 | ANSI_SYNOPSIS 9 | #include 10 | int memcmp(const void *<[s1]>, const void *<[s2]>, size_t <[n]>); 11 | 12 | TRAD_SYNOPSIS 13 | #include 14 | int memcmp(<[s1]>, <[s2]>, <[n]>) 15 | void *<[s1]>; 16 | void *<[s2]>; 17 | size_t <[n]>; 18 | 19 | DESCRIPTION 20 | This function compares not more than <[n]> characters of the 21 | object pointed to by <[s1]> with the object pointed to by <[s2]>. 22 | 23 | 24 | RETURNS 25 | The function returns an integer greater than, equal to or 26 | less than zero according to whether the object pointed to by 27 | <[s1]> is greater than, equal to or less than the object 28 | pointed to by <[s2]>. 29 | 30 | PORTABILITY 31 | <> is ANSI C. 32 | 33 | <> requires no supporting OS subroutines. 34 | 35 | QUICKREF 36 | memcmp ansi pure 37 | */ 38 | 39 | #include 40 | 41 | /* Nonzero if either X or Y is not aligned on a "long" boundary. */ 42 | #define UNALIGNED(X, Y) \ 43 | (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) 44 | 45 | /* How many bytes are copied each iteration of the word copy loop. */ 46 | #define LBLOCKSIZE (sizeof (long)) 47 | 48 | /* Threshhold for punting to the byte copier. */ 49 | #define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE) 50 | 51 | int 52 | _DEFUN(memcmp, (m1, m2, n), 53 | _CONST _PTR m1 _AND _CONST _PTR m2 _AND size_t n) { 54 | #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) 55 | unsigned char *s1 = (unsigned char *) m1; 56 | unsigned char *s2 = (unsigned char *) m2; 57 | 58 | while(n--) { 59 | if(*s1 != *s2) { 60 | return *s1 - *s2; 61 | } 62 | s1++; 63 | s2++; 64 | } 65 | return 0; 66 | #else 67 | unsigned char *s1 = (unsigned char *) m1; 68 | unsigned char *s2 = (unsigned char *) m2; 69 | unsigned long *a1; 70 | unsigned long *a2; 71 | 72 | /* If the size is too small, or either pointer is unaligned, 73 | then we punt to the byte compare loop. Hopefully this will 74 | not turn up in inner loops. */ 75 | if(!TOO_SMALL(n) && !UNALIGNED(s1, s2)) { 76 | /* Otherwise, load and compare the blocks of memory one 77 | word at a time. */ 78 | a1 = (unsigned long *) s1; 79 | a2 = (unsigned long *) s2; 80 | while(n >= LBLOCKSIZE) { 81 | if (*a1 != *a2) 82 | break; 83 | a1++; 84 | a2++; 85 | n -= LBLOCKSIZE; 86 | } 87 | 88 | /* check m mod LBLOCKSIZE remaining characters */ 89 | 90 | s1 = (char *) a1; 91 | s2 = (char *) a2; 92 | } 93 | 94 | while(n--) { 95 | if(*s1 != *s2) 96 | return *s1 - *s2; 97 | s1++; 98 | s2++; 99 | } 100 | 101 | return 0; 102 | #endif /* not PREFER_SIZE_OVER_SPEED */ 103 | } 104 | -------------------------------------------------------------------------------- /target-src/dcload/memcpy.S: -------------------------------------------------------------------------------- 1 | ! 2 | ! Fast SH memcpy 3 | ! 4 | ! by Toshiyasu Morita (tm@netcom.com) 5 | ! hacked by J"orn Rernnecke (amylaar@cygnus.co.uk) ("o for o-umlaut) 6 | ! 7 | ! Entry: r4: destination pointer 8 | ! r5: source pointer 9 | ! r6: byte count 10 | ! 11 | ! Exit: r0: destination pointer 12 | ! r1-r7: trashed 13 | ! 14 | ! Notes: Usually one wants to do small reads and write a longword, but 15 | ! unfortunately it is difficult in some cases to concatanate bytes 16 | ! into a longword on the SH, so this does a longword read and small 17 | ! writes. 18 | ! 19 | ! This implementation makes two assumptions about how it is called: 20 | ! 21 | ! 1.: If the byte count is nonzero, the address of the last byte to be 22 | ! copied is unsigned greater than the address of the first byte to 23 | ! be copied. This could be easily swapped for a signed comparison, 24 | ! but the algorithm used needs some comparison. 25 | ! 26 | ! 2.: When there are two or three bytes in the last word of an 11-or-bore 27 | ! bytes memory chunk to b copied, the rest of the word can be read 28 | ! without size effects. 29 | ! This could be easily changed by increasing the minumum size of 30 | ! a fast memcpy and the amount subtracted from r7 before L_2l_loop be 2, 31 | ! however, this would cost a few extra cyles on average. 32 | ! 33 | 34 | #include "asm.h" 35 | 36 | ENTRY(memcpy) 37 | #ifdef __LITTLE_ENDIAN__ 38 | ! Little endian version copies with increasing addresses. 39 | mov r4,r3 ! Save return value 40 | mov #11,r0 ! Check if small number of bytes 41 | cmp/hs r0,r6 42 | ! r6 becomes src end address 43 | SL(bf, L_small, add r5,r6) 44 | mov #1,r1 45 | tst r1,r5 ! check if source even 46 | SL(bt, L_even, mov r6,r7) 47 | mov.b @r5+,r0 ! no, make it even. 48 | mov.b r0,@r4 49 | add #1,r4 50 | L_even: tst r1,r4 ! check if destination is even 51 | add #-3,r7 52 | SL(bf, L_odddst, mov #2,r1) 53 | tst r1,r4 ! check if destination is 4-byte aligned 54 | mov r4,r0 55 | SL(bt, L_al4dst, sub r5,r0) 56 | mov.w @r5+,r2 57 | mov.w r2,@r4 58 | ! add #2,r4 r4 is dead here. 59 | L_al4dst: 60 | tst r1,r5 61 | bt L_al4both 62 | mov.w @r5+,r1 63 | swap.w r1,r1 64 | add #-6,r0 65 | add #-6,r7 ! r7 := src end address minus 9. 66 | .align 2 67 | L_2l_loop: 68 | mov.l @r5+,r2 ! Read & write two longwords per iteration 69 | xtrct r2,r1 70 | mov.l r1,@(r0,r5) 71 | cmp/hs r7,r5 72 | mov.l @r5+,r1 73 | xtrct r1,r2 74 | mov.l r2,@(r0,r5) 75 | bf L_2l_loop 76 | add #-2,r5 77 | bra L_cleanup 78 | add #5,r0 79 | L_al4both: 80 | add #-4,r0 81 | .align 2 82 | L_al4both_loop: 83 | mov.l @r5+,r4 ! Read longword, write longword per iteration 84 | cmp/hs r7,r5 85 | SL(bf, L_al4both_loop, mov.l r4,@(r0,r5)) 86 | 87 | bra L_cleanup 88 | add #3,r0 89 | 90 | L_odddst: 91 | tst r1,r5 92 | SL(bt, L_al4src, add #-1,r4) 93 | mov.w @r5+,r0 94 | mov.b r0,@(1,r4) 95 | shlr8 r0 96 | mov.b r0,@(2,r4) 97 | add #2,r4 98 | L_al4src: 99 | .align 2 100 | L_odd_loop: 101 | mov.l @r5+,r0 ! Read longword, write byte, word, byte per iteration 102 | cmp/hs r7,r5 103 | mov.b r0,@(1,r4) 104 | shlr8 r0 105 | mov.w r0,@(2,r4) 106 | shlr16 r0 107 | mov.b r0,@(4,r4) 108 | SL(bf, L_odd_loop, add #4,r4) 109 | .align 2 ! avoid nop in more frequently executed code. 110 | L_cleanup2: 111 | mov r4,r0 112 | sub r5,r0 113 | L_cleanup: 114 | cmp/eq r6,r5 115 | bt L_ready 116 | .align 2 117 | L_cleanup_loop: 118 | mov.b @r5+,r1 119 | cmp/eq r6,r5 120 | mov.b r1,@(r0,r5) 121 | bf L_cleanup_loop 122 | L_ready: 123 | rts 124 | mov r3,r0 125 | L_small: 126 | bra L_cleanup2 127 | add #-1,r4 128 | #else 129 | ! Big endian version copies with decreasing addresses. 130 | mov r4,r0 131 | add r6,r0 132 | sub r4,r5 133 | mov #11,r1 134 | cmp/hs r1,r6 135 | SL(bf, L_small, add #-1,r5) 136 | mov r5,r3 137 | add r0,r3 138 | shlr r3 139 | SL(bt, L_even, 140 | mov r4,r7) 141 | mov.b @(r0,r5),r2 142 | add #-1,r3 143 | mov.b r2,@-r0 144 | L_even: 145 | tst #1,r0 146 | add #-1,r5 147 | SL(bf, L_odddst, add #8,r7) 148 | tst #2,r0 149 | bt L_al4dst 150 | add #-1,r3 151 | mov.w @(r0,r5),r1 152 | mov.w r1,@-r0 153 | L_al4dst: 154 | shlr r3 155 | bt L_al4both 156 | mov.w @(r0,r5),r1 157 | swap.w r1,r1 158 | add #4,r7 159 | add #-4,r5 160 | .align 2 161 | L_2l_loop: 162 | mov.l @(r0,r5),r2 163 | xtrct r2,r1 164 | mov.l r1,@-r0 165 | cmp/hs r7,r0 166 | mov.l @(r0,r5),r1 167 | xtrct r1,r2 168 | mov.l r2,@-r0 169 | bt L_2l_loop 170 | bra L_cleanup 171 | add #5,r5 172 | 173 | nop ! avoid nop in executed code. 174 | L_al4both: 175 | add #-2,r5 176 | .align 2 177 | L_al4both_loop: 178 | mov.l @(r0,r5),r1 179 | cmp/hs r7,r0 180 | SL(bt, L_al4both_loop, 181 | mov.l r1,@-r0) 182 | bra L_cleanup 183 | add #3,r5 184 | 185 | nop ! avoid nop in executed code. 186 | L_odddst: 187 | shlr r3 188 | bt L_al4src 189 | mov.w @(r0,r5),r1 190 | mov.b r1,@-r0 191 | shlr8 r1 192 | mov.b r1,@-r0 193 | L_al4src: 194 | add #-2,r5 195 | .align 2 196 | L_odd_loop: 197 | mov.l @(r0,r5),r2 198 | cmp/hs r7,r0 199 | mov.b r2,@-r0 200 | shlr8 r2 201 | mov.w r2,@-r0 202 | shlr16 r2 203 | mov.b r2,@-r0 204 | bt L_odd_loop 205 | 206 | add #3,r5 207 | L_cleanup: 208 | L_small: 209 | cmp/eq r4,r0 210 | bt L_ready 211 | add #1,r4 212 | .align 2 213 | L_cleanup_loop: 214 | mov.b @(r0,r5),r2 215 | cmp/eq r4,r0 216 | mov.b r2,@-r0 217 | bf L_cleanup_loop 218 | L_ready: 219 | rts 220 | nop 221 | #endif 222 | -------------------------------------------------------------------------------- /target-src/dcload/memmove.c: -------------------------------------------------------------------------------- 1 | /* 2 | FUNCTION 3 | <>---move possibly overlapping memory 4 | 5 | INDEX 6 | memmove 7 | 8 | ANSI_SYNOPSIS 9 | #include 10 | void *memmove(void *<[dst]>, const void *<[src]>, size_t <[length]>); 11 | 12 | TRAD_SYNOPSIS 13 | #include 14 | void *memmove(<[dst]>, <[src]>, <[length]>) 15 | void *<[dst]>; 16 | void *<[src]>; 17 | size_t <[length]>; 18 | 19 | DESCRIPTION 20 | This function moves <[length]> characters from the block of 21 | memory starting at <<*<[src]>>> to the memory starting at 22 | <<*<[dst]>>>. <> reproduces the characters correctly 23 | at <<*<[dst]>>> even if the two areas overlap. 24 | 25 | 26 | RETURNS 27 | The function returns <[dst]> as passed. 28 | 29 | PORTABILITY 30 | <> is ANSI C. 31 | 32 | <> requires no supporting OS subroutines. 33 | 34 | QUICKREF 35 | memmove ansi pure 36 | */ 37 | 38 | #include 39 | #include <_ansi.h> 40 | #include 41 | #include 42 | 43 | /* Nonzero if either X or Y is not aligned on a "long" boundary. */ 44 | #define UNALIGNED(X, Y) \ 45 | (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) 46 | 47 | /* How many bytes are copied each iteration of the 4X unrolled loop. */ 48 | #define BIGBLOCKSIZE (sizeof (long) << 2) 49 | 50 | /* How many bytes are copied each iteration of the word copy loop. */ 51 | #define LITTLEBLOCKSIZE (sizeof (long)) 52 | 53 | /* Threshhold for punting to the byte copier. */ 54 | #define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) 55 | 56 | /*SUPPRESS 20*/ 57 | _PTR 58 | _DEFUN(memmove, (dst_void, src_void, length), 59 | _PTR dst_void _AND _CONST _PTR src_void _AND size_t length) { 60 | #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) 61 | char *dst = dst_void; 62 | _CONST char *src = src_void; 63 | 64 | if(src < dst && dst < src + length) { 65 | /* Have to copy backwards */ 66 | src += length; 67 | dst += length; 68 | while(length--) { 69 | *--dst = *--src; 70 | } 71 | } else { 72 | while(length--) { 73 | *dst++ = *src++; 74 | } 75 | } 76 | 77 | return dst_void; 78 | #else 79 | char *dst = dst_void; 80 | _CONST char *src = src_void; 81 | long *aligned_dst; 82 | _CONST long *aligned_src; 83 | int len = length; 84 | 85 | if(src < dst && dst < src + len) { 86 | /* Destructive overlap...have to copy backwards */ 87 | src += len; 88 | dst += len; 89 | while(len--) { 90 | *--dst = *--src; 91 | } 92 | } else { 93 | /* Use optimizing algorithm for a non-destructive copy to closely 94 | match memcpy. If the size is small or either SRC or DST is unaligned, 95 | then punt into the byte copy loop. This should be rare. */ 96 | if(!TOO_SMALL(len) && !UNALIGNED(src, dst)) { 97 | aligned_dst = (long *) dst; 98 | aligned_src = (long *) src; 99 | 100 | /* Copy 4X long words at a time if possible. */ 101 | while(len >= BIGBLOCKSIZE) { 102 | *aligned_dst++ = *aligned_src++; 103 | *aligned_dst++ = *aligned_src++; 104 | *aligned_dst++ = *aligned_src++; 105 | *aligned_dst++ = *aligned_src++; 106 | len -= BIGBLOCKSIZE; 107 | } 108 | 109 | /* Copy one long word at a time if possible. */ 110 | while(len >= LITTLEBLOCKSIZE) { 111 | *aligned_dst++ = *aligned_src++; 112 | len -= LITTLEBLOCKSIZE; 113 | } 114 | 115 | /* Pick up any residual with a byte copier. */ 116 | dst = (char *) aligned_dst; 117 | src = (char *) aligned_src; 118 | } 119 | 120 | while(len--) { 121 | *dst++ = *src++; 122 | } 123 | } 124 | 125 | return dst_void; 126 | #endif /* not PREFER_SIZE_OVER_SPEED */ 127 | } 128 | -------------------------------------------------------------------------------- /target-src/dcload/memset.S: -------------------------------------------------------------------------------- 1 | ! 2 | ! Fast SH memset 3 | ! 4 | ! by Toshiyasu Morita (tm@netcom.com) 5 | ! 6 | ! Entry: r4: destination pointer 7 | ! r5: fill value 8 | ! r6: byte count 9 | ! 10 | ! Exit: r0-r3: trashed 11 | ! 12 | 13 | ! This assumes that the first four bytes of the address space (0..3) are 14 | ! reserved - usually by the linker script. Otherwise, we would had to check 15 | ! for the case of objects of the size 12..15 at address 0..3 . 16 | 17 | #include "asm.h" 18 | 19 | ENTRY(memset) 20 | mov #12,r0 ! Check for small number of bytes 21 | cmp/gt r6,r0 22 | mov r4,r0 23 | SL(bt, L_store_byte_loop_check0, add r4,r6) 24 | 25 | tst #3,r0 ! Align destination 26 | SL(bt, L_dup_bytes, extu.b r5,r5) 27 | .balignw 4,0x0009 28 | L_align_loop: 29 | mov.b r5,@r0 30 | add #1,r0 31 | tst #3,r0 32 | bf L_align_loop 33 | 34 | L_dup_bytes: 35 | swap.b r5,r2 ! Duplicate bytes across longword 36 | or r2,r5 37 | swap.w r5,r2 38 | or r2,r5 39 | 40 | add #-16,r6 41 | 42 | .balignw 4,0x0009 43 | L_store_long_loop: 44 | mov.l r5,@r0 ! Store double longs to memory 45 | cmp/hs r6,r0 46 | mov.l r5,@(4,r0) 47 | SL(bf, L_store_long_loop, add #8,r0) 48 | 49 | add #16,r6 50 | 51 | L_store_byte_loop_check0: 52 | cmp/eq r6,r0 53 | bt L_exit 54 | .balignw 4,0x0009 55 | L_store_byte_loop: 56 | mov.b r5,@r0 ! Store bytes to memory 57 | add #1,r0 58 | cmp/eq r6,r0 59 | bf L_store_byte_loop 60 | 61 | L_exit: 62 | rts 63 | mov r4,r0 64 | 65 | -------------------------------------------------------------------------------- /target-src/dcload/scif.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the dcload Dreamcast serial loader 3 | * 4 | * Copyright (C) 2001 Andrew Kieschnick 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #include "scif.h" 23 | 24 | #define BORDER_FLASH 25 | #define VIDBORDER (volatile unsigned int *)0xa05f8040 26 | 27 | void scif_flush(void) { 28 | int v; 29 | 30 | *SCFSR2 &= 0xbf; 31 | while(!((v = *SCFSR2) & 0x40)); 32 | *SCFSR2 = v & 0xbf; 33 | } 34 | 35 | void scif_init(int bps) { 36 | /* Modified to allow external baudrate (bps == 0) */ 37 | int i; 38 | 39 | *SCSCR2 = bps ? 0x0 : 0x02; /* clear TE and RE bits / if (bps == 0) CKE1 on (bit 1) */ 40 | *SCFCR2 = 0x6; /* set TFRST and RFRST bits in SCFCR2 */ 41 | *SCSMR2 = 0x0; /* set data transfer format 8n1 */ 42 | 43 | if(bps) *SCBRR2 = (50 * 1000000) / (32 * bps) - 1; /* if (bps != 0) set baudrate */ 44 | 45 | for(i = 0; i < 100000; i++); /* delay at least 1 bit interval */ 46 | 47 | *SCFCR2 = 12; 48 | *SCFCR2 = 0x8; /* set MCE in SCFCR2 */ 49 | *SCSPTR2 = 0; 50 | *SCFSR2 = 0x60; 51 | *SCLSR2 = 0; 52 | *SCSCR2 = bps ? 0x30 : 0x32; /* set TE and RE bits / if (bps == 0) CKE1 on (bit 1) */ 53 | 54 | for(i = 0; i < 100000; i++); 55 | } 56 | 57 | unsigned char scif_getchar(void) { 58 | unsigned char foo; 59 | 60 | #ifdef BORDER_FLASH 61 | *VIDBORDER = ~(*VIDBORDER & 0x00ffffff); 62 | #endif 63 | 64 | while (!(*SCFSR2 & 0x2)); /* check RDF */ 65 | foo = *SCFRDR2; /* read data */ 66 | *SCFSR2 &= 0xfffd; /* clear RDF */ 67 | 68 | return foo; 69 | } 70 | 71 | unsigned int scif_isdata(void) { 72 | return (*SCFSR2 & 0x2); 73 | } 74 | 75 | void scif_putchar(unsigned char foo) { 76 | #ifdef BORDER_FLASH 77 | *VIDBORDER = ~(*VIDBORDER & 0x00ffffff); 78 | #endif 79 | 80 | while(!(*SCFSR2 & 0x20)); /* check TDFE */ 81 | *SCFTDR2 = foo; /* send data */ 82 | *SCFSR2 &= 0xff9f; /* clear TDFE and TEND */ 83 | } 84 | 85 | void scif_puts(unsigned char *foo) { 86 | int i = 0; 87 | 88 | while(foo[i] != 0) { 89 | scif_putchar(foo[i]); 90 | if (foo[i] == '\n') 91 | scif_putchar('\r'); 92 | i++; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /target-src/dcload/scif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the dcload Dreamcast serial loader 3 | * 4 | * Copyright (C) 2001 Andrew Kieschnick 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 | * 20 | */ 21 | 22 | #ifndef __SCIF_H__ 23 | #define __SCIF_H__ 24 | 25 | /* serial mode register */ 26 | #define SCSMR2 (volatile unsigned short *) 0xffe80000 27 | 28 | /* bit rate register */ 29 | #define SCBRR2 (volatile unsigned char *) 0xffe80004 30 | 31 | /* serial control register */ 32 | #define SCSCR2 (volatile unsigned short *) 0xffe80008 33 | 34 | /* transmit fifo data register */ 35 | #define SCFTDR2 (volatile unsigned char *) 0xffe8000c 36 | 37 | /* serial status register */ 38 | #define SCFSR2 (volatile unsigned short *) 0xffe80010 39 | 40 | /* receive fifo data register */ 41 | #define SCFRDR2 (volatile unsigned char *) 0xffe80014 42 | 43 | /* fifo control register */ 44 | #define SCFCR2 (volatile unsigned short *) 0xffe80018 45 | 46 | /* fifo data count register */ 47 | #define SCFDR2 (volatile unsigned short *) 0xffe8001c 48 | 49 | /* serial port register */ 50 | #define SCSPTR2 (volatile unsigned short *) 0xffe80020 51 | 52 | /* line status register */ 53 | #define SCLSR2 (volatile unsigned short *) 0xffe80024 54 | 55 | void scif_flush(void); 56 | void scif_init(int bps); 57 | unsigned char scif_getchar(void); 58 | unsigned int scif_isdata(void); 59 | void scif_putchar(unsigned char foo); 60 | void scif_puts(unsigned char *foo); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /target-src/dcload/video.h: -------------------------------------------------------------------------------- 1 | #ifndef __VIDEO_H__ 2 | #define __VIDEO_H__ 3 | 4 | void draw_string(int x, int y, char *string, int colour); 5 | void clrscr(int colour); 6 | void init_video(int cabletype, int pixelmode); 7 | int check_cable(void); 8 | unsigned char *get_font_address(void); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /target-src/dcload/video.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KallistiOS/dcload-serial/2e70c1f84768f868c70c6920c6f1c960211e623d/target-src/dcload/video.s --------------------------------------------------------------------------------