├── COPYING ├── CREDITS ├── Makefile ├── Makefile.linux ├── Makefile.winnt ├── NEWS ├── RUNNING ├── THANKS ├── TODO ├── bin ├── autotrace.py ├── build-all.sh ├── build-colinux-libs.sh ├── build-colinux.sh ├── build-common.sh ├── build-cross.sh ├── build-kernel.sh ├── comake │ ├── __init__.py │ ├── cdeps.py │ ├── defaults.py │ ├── lib.py │ ├── report.py │ ├── settings.py │ ├── target.py │ └── tools.py ├── make.py ├── mindump-repaint-labels.sh ├── premaid.sh ├── sample.user-build.cfg └── tracewrapper.py ├── build.comake.py ├── conf ├── README ├── busybox-1.00-rc3-config ├── example.conf ├── initrd-linuxrc ├── linux-2.6.25.20-config ├── linux-2.6.26.8-config ├── linux-2.6.33.7-config └── wxWidgets.conf ├── configure ├── doc ├── building ├── cofs ├── colinux-daemon └── debugging ├── patch ├── audio-2.6.25.diff ├── audio-2.6.26.diff ├── audio-2.6.33.diff ├── audio-core.diff ├── base-2.6.25.diff ├── base-2.6.26.diff ├── base-2.6.33.diff ├── cloop-2.6.25.diff ├── cloop-2.6.26.diff ├── cloop-2.6.33.diff ├── cloop-core-2.628.diff ├── cloop-core-2.631.diff ├── cobd-2.6.25.diff ├── cobd-2.6.26.diff ├── cobd-2.6.33.diff ├── cobd-core.diff ├── coconsole-2.6.25.diff ├── coconsole-2.6.26.diff ├── coconsole-2.6.33.diff ├── coconsole-core.diff ├── cofs-2.6.25.diff ├── cofs-2.6.26.diff ├── cofs-2.6.33.diff ├── cofs-core.diff ├── colinux_2.6.26-ext4-7.diff ├── conet-2.6.25.diff ├── conet-2.6.26.diff ├── conet-2.6.33.diff ├── conet-pci-core.diff ├── fltk-1.1.10-linux-patch.diff ├── fltk-1.1.10-win32.diff ├── frame-size-checks.diff ├── gcc412fix.diff ├── kbd-2.6.25.diff ├── kbd-2.6.26.diff ├── kbd-2.6.33.diff ├── kbd-core.diff ├── mouse-2.6.25.diff ├── mouse-2.6.26.diff ├── mouse-2.6.33.diff ├── mouse-core.diff ├── pci-2.6.25.diff ├── pci-2.6.26.diff ├── pci-2.6.33.diff ├── pci-core.diff ├── scsi-2.6.25.diff ├── scsi-2.6.26.diff ├── scsi-2.6.33.diff ├── scsi-core.diff ├── serial-2.6.25.diff ├── serial-2.6.26.diff ├── serial-2.6.33.diff ├── serial-core.diff ├── series-2.6.25.20 ├── series-2.6.26.8 ├── series-2.6.33.7 ├── squashfs3.3-2.6.25.diff ├── squashfs3.3-core.diff ├── squashfs3.4-2.6.26.diff ├── timer-2.6.25.diff ├── timer-2.6.26.diff ├── timer-2.6.33.diff ├── tty-buffer-alloc-2.6.33.diff ├── unionfs-2.5.4_for_2.6.25.20.diff ├── unionfs-2.5.4_for_2.6.26.8.diff ├── unionfs-2.5.4_for_2.6.33.diff ├── unionfs-2.6.25.20.diff ├── unionfs-2.6.26.8.diff ├── video-2.6.25.diff ├── video-2.6.26.diff ├── video-2.6.33.diff └── video-core.diff └── src ├── Makefile ├── build.comake.py ├── colinux ├── VERSION ├── arch │ ├── build.comake.py │ ├── i386 │ │ ├── antinx.c │ │ ├── antinx.h │ │ ├── apic.c │ │ ├── apic.h │ │ ├── build.comake.py │ │ ├── cpuid.c │ │ ├── cpuid.h │ │ ├── defs.h │ │ ├── interrupt.c │ │ ├── manager.c │ │ ├── manager.h │ │ ├── mmu.h │ │ ├── passage.c │ │ ├── utils.c │ │ └── utils.h │ ├── interrupt.h │ ├── manager.h │ ├── mmu.h │ └── passage.h ├── build.comake.py ├── common │ ├── build.comake.py │ ├── common.h │ ├── common_base.h │ ├── config.h │ ├── console.c │ ├── console.h │ ├── debug.c │ ├── debug.h │ ├── errors.c │ ├── import.h │ ├── ioctl.h │ ├── libc.c │ ├── libc.h │ ├── list.h │ ├── messages.c │ ├── messages.h │ ├── module_repr.c │ ├── queue.c │ ├── queue.h │ ├── snprintf.c │ ├── unicode.c │ ├── unicode.h │ └── version.py ├── kernel │ ├── README │ ├── block.c │ ├── block.h │ ├── build.comake.py │ ├── debug.c │ ├── debug.h │ ├── fileblock.c │ ├── fileblock.h │ ├── filesystem.c │ ├── filesystem.h │ ├── manager.c │ ├── manager.h │ ├── monitor.c │ ├── monitor.h │ ├── pages.c │ ├── pages.h │ ├── pci.c │ ├── pci.h │ ├── reversedpfns.c │ ├── reversedpfns.h │ ├── scsi.c │ ├── scsi.h │ ├── transfer.c │ ├── transfer.h │ ├── video.c │ └── video.h ├── os │ ├── README │ ├── alloc.h │ ├── kernel │ │ ├── alloc.h │ │ ├── filesystem.h │ │ ├── manager.h │ │ ├── misc.h │ │ ├── monitor.h │ │ ├── mutex.h │ │ ├── time.h │ │ ├── user.h │ │ └── wait.h │ ├── linux │ │ ├── build │ │ │ └── build.comake.py │ │ ├── ioctl.h │ │ ├── kernel │ │ │ ├── core.c │ │ │ └── module │ │ │ │ ├── Makefile │ │ │ │ ├── Makefile.include │ │ │ │ ├── alloc.c │ │ │ │ ├── build.comake.py │ │ │ │ ├── colinux.c │ │ │ │ ├── conet.c │ │ │ │ ├── debug.c │ │ │ │ ├── file.c │ │ │ │ ├── fs.c │ │ │ │ ├── linux_inc.h │ │ │ │ ├── main.c │ │ │ │ ├── manager.c │ │ │ │ ├── manager.h │ │ │ │ ├── misc.c │ │ │ │ ├── mutex.c │ │ │ │ ├── pages.c │ │ │ │ ├── scsi.c │ │ │ │ ├── time.c │ │ │ │ ├── timer.c │ │ │ │ ├── user.c │ │ │ │ └── wait.c │ │ ├── memory.h │ │ ├── test │ │ │ └── pipe_server.c │ │ └── user │ │ │ ├── alloc.c │ │ │ ├── build.comake.py │ │ │ ├── cobdpath.c │ │ │ ├── conet-daemon │ │ │ ├── build.comake.py │ │ │ ├── daemon.cpp │ │ │ ├── daemon.h │ │ │ ├── tap.c │ │ │ └── tap.h │ │ │ ├── conet-slirp-daemon │ │ │ ├── build.comake.py │ │ │ └── main.c │ │ │ ├── console-fltk │ │ │ ├── build.comake.py │ │ │ └── head.cpp │ │ │ ├── coserial-daemon │ │ │ ├── build.comake.py │ │ │ └── main.c │ │ │ ├── daemon │ │ │ ├── build.comake.py │ │ │ ├── debug.c │ │ │ ├── main.c │ │ │ └── registry.c │ │ │ ├── debug │ │ │ ├── build.comake.py │ │ │ └── main.c │ │ │ ├── exec.c │ │ │ ├── file-unlink.c │ │ │ ├── file-write.c │ │ │ ├── file.c │ │ │ ├── manager.c │ │ │ ├── misc.c │ │ │ ├── process.c │ │ │ ├── reactor.c │ │ │ ├── reactor.h │ │ │ ├── unix.c │ │ │ └── unix.h │ ├── timer.h │ ├── user │ │ ├── cobdpath.h │ │ ├── config.h │ │ ├── daemon.h │ │ ├── exec.h │ │ ├── file.h │ │ ├── manager.h │ │ ├── misc.h │ │ └── reactor.h │ └── winnt │ │ ├── build │ │ └── build.comake.py │ │ ├── ioctl.h │ │ ├── kernel │ │ ├── alloc.c │ │ ├── block.c │ │ ├── build.comake.py │ │ ├── conet.c │ │ ├── conet.h │ │ ├── core.c │ │ ├── ddk.h │ │ ├── driver.h │ │ ├── exceptions.h │ │ ├── fileio.c │ │ ├── fileio.h │ │ ├── filesystem.c │ │ ├── interface.c │ │ ├── lowlevel │ │ │ ├── alloc.c │ │ │ ├── build.comake.py │ │ │ ├── debug.c │ │ │ ├── misc.c │ │ │ ├── mutex.c │ │ │ ├── time.c │ │ │ ├── timer.c │ │ │ ├── user.c │ │ │ └── wait.c │ │ ├── manager.c │ │ ├── manager.h │ │ ├── scsi.c │ │ ├── tap-win32 │ │ │ ├── MAKEFILE │ │ │ ├── SOURCES │ │ │ ├── common.h │ │ │ ├── config-win32.h │ │ │ ├── constants.h │ │ │ ├── dhcp.c │ │ │ ├── dhcp.h │ │ │ ├── endian.h │ │ │ ├── error.c │ │ │ ├── error.h │ │ │ ├── hexdump.c │ │ │ ├── hexdump.h │ │ │ ├── i386 │ │ │ │ ├── OemWin2k.inf │ │ │ │ └── tap.cat │ │ │ ├── instance.c │ │ │ ├── lock.h │ │ │ ├── macinfo.c │ │ │ ├── macinfo.h │ │ │ ├── mem.c │ │ │ ├── proto.h │ │ │ ├── prototypes.h │ │ │ ├── resource.rc │ │ │ ├── tapdrvr.c │ │ │ └── types.h │ │ ├── time.c │ │ └── time.h │ │ ├── memory.h │ │ ├── monitor.h │ │ ├── os.h │ │ └── user │ │ ├── alloc.c │ │ ├── build.comake.py │ │ ├── cobdpath.c │ │ ├── conet-bridged-daemon │ │ ├── build.comake.py │ │ ├── main.c │ │ └── pcap-registry.h │ │ ├── conet-daemon │ │ ├── build.comake.py │ │ ├── daemon.cpp │ │ ├── daemon.h │ │ ├── tap-win32.c │ │ └── tap-win32.h │ │ ├── conet-ndis-daemon │ │ ├── build.comake.py │ │ ├── main.c │ │ └── pcap-registry.h │ │ ├── conet-slirp-daemon │ │ ├── build.comake.py │ │ └── main.c │ │ ├── console-fltk │ │ ├── build.comake.py │ │ └── head.cpp │ │ ├── console-nt │ │ ├── build.comake.py │ │ ├── console.cpp │ │ ├── console.h │ │ ├── head.cpp │ │ ├── os_console.c │ │ ├── os_console.h │ │ ├── widget.cpp │ │ └── widget.h │ │ ├── coserial-daemon │ │ ├── build.comake.py │ │ └── main.c │ │ ├── daemon │ │ ├── build.comake.py │ │ ├── cmdline.c │ │ ├── cmdline.h │ │ ├── debug.c │ │ ├── debug.h │ │ ├── driver.c │ │ ├── driver.h │ │ ├── main.c │ │ ├── main.h │ │ ├── misc.c │ │ ├── misc.h │ │ ├── registry.c │ │ ├── res │ │ │ ├── build.comake.py │ │ │ ├── colinux.ico │ │ │ ├── colinux.rc │ │ │ ├── daemon.rc │ │ │ ├── resources_def.sh │ │ │ ├── service-message.bin │ │ │ ├── service-message.h │ │ │ └── service-message.mc │ │ ├── service.c │ │ └── service.h │ │ ├── debug │ │ ├── build.comake.py │ │ └── main.c │ │ ├── exec.c │ │ ├── file-unlink.c │ │ ├── file-write.c │ │ ├── file.c │ │ ├── install │ │ ├── WinpcapRedir.ini │ │ ├── WriteEnvStr.nsh │ │ ├── build.comake.py │ │ ├── colinux.nsi │ │ ├── colinux_def.sh │ │ ├── header.bmp │ │ ├── iDl.ini │ │ └── startlogo.bmp │ │ ├── manager.c │ │ ├── manager.h │ │ ├── misc.c │ │ ├── misc.h │ │ ├── process.c │ │ ├── reactor.c │ │ ├── reactor.h │ │ ├── timer.c │ │ └── udp.c └── user │ ├── README │ ├── build.comake.py │ ├── cmdline.c │ ├── cmdline.h │ ├── config.c │ ├── config.h │ ├── configurator │ ├── README │ ├── blockdevice.py │ ├── common.py │ ├── configurator.py │ ├── networkdevice.py │ └── xmlwrapper.py │ ├── console-fltk │ ├── about.cpp │ ├── about.h │ ├── build.comake.py │ ├── console.cpp │ ├── console.h │ ├── fontselect.cpp │ ├── fontselect.h │ ├── img │ │ ├── colinux_logo.xpm │ │ └── colinux_logo_3d.xpm │ ├── main.cpp │ ├── main.h │ ├── select_monitor.cpp │ ├── select_monitor.h │ ├── widget.cpp │ └── widget.h │ ├── console-nt │ ├── build.comake.py │ ├── console.cpp │ ├── console.h │ ├── main.cpp │ ├── main.h │ ├── widget.cpp │ └── widget.h │ ├── console-wx │ ├── build.comake.py │ ├── console.h │ └── main.cpp │ ├── context.h │ ├── control │ └── main.c │ ├── daemon-base │ ├── build.comake.py │ ├── main.cpp │ └── main.h │ ├── daemon.c │ ├── daemon.h │ ├── debug.c │ ├── debug.h │ ├── debug │ ├── build.comake.py │ ├── dump.py │ ├── main.c │ ├── main.h │ └── server.py │ ├── elf_load.c │ ├── elf_load.h │ ├── macaddress.c │ ├── macaddress.h │ ├── manager.c │ ├── manager.h │ ├── monitor-find.c │ ├── monitor.c │ ├── monitor.h │ ├── pidfile.c │ ├── reactor.c │ ├── reactor.h │ └── slirp │ ├── COPYRIGHT │ ├── bootp.c │ ├── bootp.h │ ├── build.comake.py │ ├── cksum.c │ ├── co_main.c │ ├── co_main.h │ ├── config.h │ ├── ctl.h │ ├── debug.c │ ├── debug.h │ ├── icmp_var.h │ ├── if.c │ ├── if.h │ ├── ip.h │ ├── ip_icmp.c │ ├── ip_icmp.h │ ├── ip_input.c │ ├── ip_output.c │ ├── libslirp.h │ ├── main.h │ ├── mbuf.c │ ├── mbuf.h │ ├── misc.c │ ├── misc.h │ ├── sbuf.c │ ├── sbuf.h │ ├── slirp.c │ ├── slirp.h │ ├── slirp_config.h │ ├── socket.c │ ├── socket.h │ ├── tcp.h │ ├── tcp_input.c │ ├── tcp_output.c │ ├── tcp_subr.c │ ├── tcp_timer.c │ ├── tcp_timer.h │ ├── tcp_var.h │ ├── tcpip.h │ ├── tftp.c │ ├── tftp.h │ ├── udp.c │ └── udp.h └── intro /CREDITS: -------------------------------------------------------------------------------- 1 | coLinux - Cooperative Linux. 2 | 3 | Sponsored by AIST 2004. (http://www.aist.go.jp/) 4 | 5 | Creator and chief maintainer: 6 | Dan Aloni - responsible for the development of the basic 7 | fundamentals: context switching, hardware abstraction, 8 | basic design. 9 | 10 | Additional developers and contributors: 11 | Jun Okajima (Digital Infra Inc.) - Developer and maintainer of cofbdev 12 | Cooperative Frame Buffer device, not yet merged 13 | 14 | Pat Erley 15 | random patches 16 | 17 | Alejandro R. Sedeno 18 | pcap support, bridged networking 19 | 20 | Ballard, Jonathan H. 21 | various patches, native nt console 22 | 23 | Thomas Fritzsche 24 | scripting 25 | 26 | George Boutwell 27 | scripting, various patches 28 | 29 | Henry Nestler 30 | lots of scripting, kernel, code, etc patches 31 | 32 | Jaroslaw Kowalski 33 | support for installing as a Windows service 34 | 35 | Daniel R. Slater 36 | patches for Windows service support 37 | 38 | Regis NEBOR 39 | NSIS installer script 40 | 41 | Incoroprated code from the following contributers / projects: 42 | slirp, QEMU 43 | Copyright (c) 2004 Fabrice Bellard 44 | Copyright (c) 1995 Danny Gasparovski. 45 | See: src/colinux/user/slirp/COPYRIGHT 46 | 47 | Producer: 48 | Kuniyasu Suzaki, Senior Reseacher, AIST 49 | 50 | Portion of this program is copyright (c) AIST, 2003-. All rights reserved. 51 | Licensed under GPL (see COPYING). 52 | -------------------------------------------------------------------------------- /Makefile.linux: -------------------------------------------------------------------------------- 1 | # Makefile.linux for coLinux (linux) 2 | 3 | # Host System architecture 4 | export COLINUX_HOST_OS := linux 5 | 6 | # Host system directories 7 | export COLINUX_HOST_KERNEL_DIR := \ 8 | $(shell . $(USER_CFG); echo $$COLINUX_HOST_KERNEL_DIR) 9 | 10 | # Define Host specific compiler and linker flags, 11 | # such for specific FLTK library 12 | #export COLINUX_CFLAGS = -I$(HOME)/i686-pc-linux-local/include 13 | #export COLINUX_LFLAGS = -L$(HOME)/i686-pc-linux-local/lib 14 | 15 | # Set different host compiler for kernel, if option enabled 16 | COLINUX_GCC_GUEST_TARGET := \ 17 | $(shell . $(USER_CFG); echo $$COLINUX_GCC_GUEST_TARGET) 18 | 19 | ifneq ($(COLINUX_GCC_GUEST_TARGET),) 20 | export COLINUX_GCC_GUEST_TARGET 21 | PATH := $(shell . $(USER_CFG); echo $$PATH:$$COLINUX_GCC_GUEST_PATH) 22 | endif 23 | 24 | .PHONY: all 25 | all: kernel colinux 26 | 27 | -------------------------------------------------------------------------------- /Makefile.winnt: -------------------------------------------------------------------------------- 1 | # Makefile.winnt for coLinux (mingw32) 2 | 3 | # Host System architecture 4 | export COLINUX_HOST_OS := winnt 5 | 6 | # Host system variables and directories 7 | PREFIX := $(shell . $(USER_CFG); echo $$PREFIX) 8 | 9 | # Need some variables and PATH of cross compiler in make. 10 | export PATH := $(PATH):$(PREFIX)/bin 11 | 12 | .PHONY: all cross cross libs kernel download package installer 13 | all: cross libs kernel colinux 14 | 15 | # 16 | # Check tools and targets via md5sum 17 | # 18 | 19 | cross: 20 | @cd bin && ./build-cross.sh 21 | 22 | libs: 23 | @cd bin && ./build-colinux-libs.sh 24 | 25 | # Download only all missing sources (for cross compile) 26 | download: 27 | @cd bin && ./build-all.sh --download-only 28 | 29 | # Create a pre-distributabel package as ZIP 30 | package: src/colinux/os/winnt/build/linux.sys 31 | @cd bin && ./premaid.sh --update 32 | @. bin/build-common.sh ; build_package 33 | 34 | # Create installer (need wine and running X11) 35 | installer: src/colinux/os/winnt/build/linux.sys 36 | @cd bin && ./premaid.sh --update 37 | @cd src && make installer 38 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Thanks to the following people: 2 | 3 | Eyal Lotem, gnupeaker at yahoo dot com 4 | 5 | For inspiring ideas, brainstorming, food ordering 6 | 7 | 8 | William Lee Irwin III, wli at holomorphy dot com 9 | 10 | For always answering my kernel related questions on IRC. 11 | 12 | See the ChangeLog for the names of specific contributors. -------------------------------------------------------------------------------- /bin/build-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script calls sequenzly all others scripts. 4 | # 5 | # Options can ones of (only ones, or none): 6 | # --rebuild Rebuild all, without checking old targed files. 7 | # Disable md5sum checking, untar and patch source. 8 | # Overwrites kernel-source! (with backup) 9 | # --download-only Download all source files, no compile 10 | # --installer Create Windows installer 11 | 12 | . ./build-common.sh 13 | 14 | ./build-cross.sh $1 && \ 15 | ./build-colinux-libs.sh $1 && \ 16 | ./build-kernel.sh $1 && \ 17 | ./build-colinux.sh $1 && \ 18 | echo "Build-all $1 DONE" 19 | -------------------------------------------------------------------------------- /bin/build-colinux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Builds daemons, ZIP package and Installer. Please read doc/building. 4 | # 5 | # Run './build-colinux.sh --installer', if you have WINE installed 6 | # with NullSoft Installer System v2.05 or later and 7 | # would like an Windows based Installer created. 8 | 9 | . ./build-common.sh 10 | 11 | # nothing to do for download 12 | test "$1" = "--download-only" && exit 0 13 | 14 | # Need Variables in make 15 | export COLINUX_TARGET_KERNEL_SOURCE 16 | export COLINUX_TARGET_KERNEL_BUILD 17 | export COLINUX_TARGET_KERNEL_PATH 18 | 19 | echo "Compiling colinux (daemons)" 20 | cd $TOPDIR/src 21 | if ! make colinux 22 | then 23 | echo "colinux make daemons failed" 24 | exit 1 25 | fi 26 | 27 | echo "Build premaid" 28 | cd $BINDIR 29 | ./premaid.sh 30 | 31 | # Create ZIP files 32 | build_package 33 | 34 | if [ "$1" = "--installer" ] 35 | then 36 | echo "Create installer" 37 | cd $TOPDIR/src 38 | if ! make installer 39 | then 40 | echo "colinux make installer failed" 41 | exit 1 42 | fi 43 | fi 44 | -------------------------------------------------------------------------------- /bin/comake/__init__.py: -------------------------------------------------------------------------------- 1 | import os, sys 2 | 3 | DEFAULT_BUILD_NAME = 'build.comake.py' 4 | COMAKE_OUTPUT_DIRECTORY = '.comake.build' 5 | 6 | def _build_root(): 7 | from os.path import dirname 8 | return dirname(dirname(dirname(__file__))) 9 | 10 | build_root = _build_root() 11 | 12 | def main(args): 13 | os.chdir(build_root) 14 | 15 | if '--help' in args or len(args) == 0: 16 | print "make.py [target_name] (--help) (--dump)" 17 | return 18 | 19 | filename = args[0] 20 | if filename == 'clean': 21 | from comake.target import clean 22 | clean() 23 | else: 24 | from comake.target import create_target_tree, statistics 25 | from comake.target import TargetNotFoundError, BuildCancelError 26 | from comake.tools import TargetNotBuildError 27 | print "Analyzing target tree..." 28 | try: 29 | target_tree = create_target_tree(filename) 30 | except BuildCancelError: 31 | sys.exit(3) 32 | except TargetNotFoundError: 33 | sys.exit(2) 34 | 35 | if '--dump' in args: 36 | target_tree.dump() 37 | else: 38 | print "Starting build" 39 | try: 40 | target_tree.build() 41 | except TargetNotBuildError: 42 | # Don't Traceback Python scripts for build errors 43 | print "Error: Target not build (TargetNotBuildError)" 44 | sys.exit(1) 45 | if statistics.made_targets == 0: 46 | print "No targets were rebuilt." 47 | print "Total number of targets: %d" % (statistics.targets, ) 48 | if statistics.made_targets != 0: 49 | print "Targets rebuilt: %d" % (statistics.made_targets, ) 50 | -------------------------------------------------------------------------------- /bin/comake/lib.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def normal_path(path): 4 | parts = path.split(os.path.sep) 5 | index = 0 6 | while index < len(parts): 7 | if parts[index] == '..' and index > 0: 8 | del parts[index] 9 | del parts[index-1] 10 | index -= 1 11 | else: 12 | index += 1 13 | return os.path.sep.join(parts) 14 | -------------------------------------------------------------------------------- /bin/comake/report.py: -------------------------------------------------------------------------------- 1 | class Report(object): 2 | def __init__(self): 3 | self._indent = 0 4 | self._parent = None 5 | self._title = 'None' 6 | self._title_printed = False 7 | 8 | def title(self, title): 9 | self._title = title 10 | 11 | def sub(self): 12 | report = Report() 13 | report._indent = self._indent + 1 14 | report._parent = self 15 | return report 16 | 17 | def print_title(self): 18 | if self._parent and not self._parent._title_printed: 19 | self._parent.print_title() 20 | self.print_text("[%s]" % (self._title, )) 21 | self._title_printed = True 22 | 23 | def print_text(self, text): 24 | print (self._indent*' ') + text 25 | 26 | -------------------------------------------------------------------------------- /bin/comake/settings.py: -------------------------------------------------------------------------------- 1 | class Settings(object): 2 | pass 3 | 4 | settings = Settings() 5 | -------------------------------------------------------------------------------- /bin/make.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | 5 | def main(): 6 | from comake import main as comake_main 7 | comake_main(sys.argv[1:]) 8 | 9 | if __name__ == "__main__": 10 | main() 11 | -------------------------------------------------------------------------------- /bin/premaid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # copy executable and text files into premaid for win installer 4 | 5 | . ./build-common.sh 6 | 7 | EXEDIR="$TOPDIR/src/colinux/os/winnt/build" 8 | PREMAID="$TOPDIR/src/colinux/os/winnt/user/install/premaid" 9 | 10 | # Update only on request 11 | if [ "$1" = "--update" ] 12 | then 13 | isok=true 14 | for name in $EXEDIR/*.exe $EXEDIR/*.sys \ 15 | $COLINUX_TARGET_KERNEL_BUILD/vmlinux \ 16 | $COLINUX_TARGET_KERNEL_BUILD/vmlinux-modules.tar.gz 17 | do 18 | if [ $PREMAID/`basename $name` -ot $name ] 19 | then 20 | isok=false 21 | fi 22 | done 23 | 24 | if $isok 25 | then 26 | echo "Premaid is up to date" 27 | exit 0 28 | fi 29 | fi 30 | 31 | PATH="$PATH:$PREFIX/bin" 32 | STRIP="$TARGET-strip --strip-all --preserve-dates" 33 | 34 | # Convert files into win-lite CR+LF and store in distdir 35 | # Set current CoLinux-Version number 36 | unix_dos() 37 | { 38 | sed -e "s/\$CO_VERSION/$CO_VERSION/" \ 39 | -e 's/$/\r/' < $1 > $2 || exit $? 40 | } 41 | 42 | mkdir -p $PREMAID 43 | 44 | # link kernel and modules 45 | echo "Links to kernel and modules" 46 | ln -f $COLINUX_TARGET_KERNEL_BUILD/vmlinux $PREMAID/vmlinux || exit $? 47 | ln -f $COLINUX_TARGET_KERNEL_BUILD/vmlinux-modules.tar.gz $PREMAID/vmlinux-modules.tar.gz || exit $? 48 | 49 | echo "Copy and strip executable" 50 | for name in $EXEDIR/*.exe $EXEDIR/*.sys 51 | do 52 | $STRIP -o $PREMAID/`basename $name` $name 53 | done 54 | 55 | echo "Copy and convert text files" 56 | unix_dos ${TOPDIR}/NEWS $PREMAID/NEWS.txt 57 | unix_dos ${TOPDIR}/RUNNING $PREMAID/README.txt 58 | unix_dos ${TOPDIR}/doc/cofs $PREMAID/cofs.txt 59 | unix_dos ${TOPDIR}/doc/colinux-daemon $PREMAID/colinux-daemon.txt 60 | unix_dos ${TOPDIR}/doc/debugging $PREMAID/debugging.txt 61 | unix_dos ${TOPDIR}/conf/example.conf $PREMAID/example.conf 62 | -------------------------------------------------------------------------------- /build.comake.py: -------------------------------------------------------------------------------- 1 | # This is not a standalone Python script, but a build declaration file 2 | # to be read by bin/make.py. Please run bin/make.py --help. 3 | 4 | from comake.settings import settings 5 | 6 | targets['colinux'] = Target( 7 | inputs = [Input('src/build')], 8 | tool = Empty(), 9 | ) 10 | 11 | targets['installer'] = Target( 12 | inputs = [Input('colinux')], 13 | tool = Empty(), 14 | settings_options=Options( 15 | overriders=dict( 16 | final_build_target='installer', 17 | ), 18 | ), 19 | ) 20 | -------------------------------------------------------------------------------- /conf/README: -------------------------------------------------------------------------------- 1 | This directory contains example configuration files for the coLinux daemon. 2 | 3 | It also contains a configuration file that can be used as a .config for 4 | compiling the cooperative Linux kernel. -------------------------------------------------------------------------------- /patch/audio-2.6.25.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.25-source/sound/pci/Kconfig 2 | =================================================================== 3 | --- linux-2.6.25-source.orig/sound/pci/Kconfig 4 | +++ linux-2.6.25-source/sound/pci/Kconfig 5 | @@ -3,6 +3,14 @@ 6 | menu "PCI devices" 7 | depends on SND!=n && PCI 8 | 9 | +config COOPERATIVE_AUDIO 10 | + bool "Cooperative audio support" 11 | + default n 12 | + depends on COOPERATIVE 13 | + select SND_PCM 14 | + help 15 | + Say Y here if you are compiling in Cooperative mode 16 | + 17 | config SND_AD1889 18 | tristate "Analog Devices AD1889" 19 | depends on SND 20 | Index: linux-2.6.25-source/sound/pci/Makefile 21 | =================================================================== 22 | --- linux-2.6.25-source.orig/sound/pci/Makefile 23 | +++ linux-2.6.25-source/sound/pci/Makefile 24 | @@ -28,6 +28,8 @@ 25 | snd-via82xx-objs := via82xx.o 26 | snd-via82xx-modem-objs := via82xx_modem.o 27 | 28 | +obj-$(CONFIG_COOPERATIVE_AUDIO) += coaudio.o 29 | + 30 | # Toplevel Module Dependency 31 | obj-$(CONFIG_SND_AD1889) += snd-ad1889.o 32 | obj-$(CONFIG_SND_ALS300) += snd-als300.o 33 | -------------------------------------------------------------------------------- /patch/audio-2.6.26.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.26-source/sound/pci/Kconfig 2 | =================================================================== 3 | --- linux-2.6.26-source.orig/sound/pci/Kconfig 4 | +++ linux-2.6.26-source/sound/pci/Kconfig 5 | @@ -3,6 +3,14 @@ 6 | menu "PCI devices" 7 | depends on SND!=n && PCI 8 | 9 | +config COOPERATIVE_AUDIO 10 | + bool "Cooperative audio support" 11 | + default n 12 | + depends on COOPERATIVE 13 | + select SND_PCM 14 | + help 15 | + Say Y here if you are compiling in Cooperative mode 16 | + 17 | config SND_AD1889 18 | tristate "Analog Devices AD1889" 19 | depends on SND 20 | Index: linux-2.6.26-source/sound/pci/Makefile 21 | =================================================================== 22 | --- linux-2.6.26-source.orig/sound/pci/Makefile 23 | +++ linux-2.6.26-source/sound/pci/Makefile 24 | @@ -28,6 +28,8 @@ 25 | snd-via82xx-objs := via82xx.o 26 | snd-via82xx-modem-objs := via82xx_modem.o 27 | 28 | +obj-$(CONFIG_COOPERATIVE_AUDIO) += coaudio.o 29 | + 30 | # Toplevel Module Dependency 31 | obj-$(CONFIG_SND_AD1889) += snd-ad1889.o 32 | obj-$(CONFIG_SND_ALS300) += snd-als300.o 33 | -------------------------------------------------------------------------------- /patch/audio-2.6.33.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.33-source/sound/pci/Kconfig 2 | =================================================================== 3 | --- linux-2.6.33-source.orig/sound/pci/Kconfig 4 | +++ linux-2.6.33-source/sound/pci/Kconfig 5 | @@ -9,6 +9,14 @@ 6 | 7 | if SND_PCI 8 | 9 | +config COOPERATIVE_AUDIO 10 | + bool "Cooperative audio support" 11 | + default n 12 | + depends on COOPERATIVE 13 | + select SND_PCM 14 | + help 15 | + Say Y here if you are compiling in Cooperative mode 16 | + 17 | config SND_AD1889 18 | tristate "Analog Devices AD1889" 19 | select SND_AC97_CODEC 20 | Index: linux-2.6.33-source/sound/pci/Makefile 21 | =================================================================== 22 | --- linux-2.6.33-source.orig/sound/pci/Makefile 23 | +++ linux-2.6.33-source/sound/pci/Makefile 24 | @@ -28,6 +28,8 @@ 25 | snd-via82xx-objs := via82xx.o 26 | snd-via82xx-modem-objs := via82xx_modem.o 27 | 28 | +obj-$(CONFIG_COOPERATIVE_AUDIO) += coaudio.o 29 | + 30 | # Toplevel Module Dependency 31 | obj-$(CONFIG_SND_AD1889) += snd-ad1889.o 32 | obj-$(CONFIG_SND_ALS300) += snd-als300.o 33 | -------------------------------------------------------------------------------- /patch/cloop-2.6.25.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.25-source/drivers/block/Kconfig 2 | =================================================================== 3 | --- linux-2.6.25-source.orig/drivers/block/Kconfig 4 | +++ linux-2.6.25-source/drivers/block/Kconfig 5 | @@ -366,6 +366,12 @@ 6 | 7 | If unsure, say Y. 8 | 9 | +config BLK_DEV_CLOOP 10 | + tristate "Compressed Loopback device support (from Knoppix)" 11 | + default m 12 | + help 13 | + Adds an compressed loopback device. 14 | + 15 | config CDROM_PKTCDVD 16 | tristate "Packet writing on CD/DVD media" 17 | depends on !UML 18 | Index: linux-2.6.25-source/drivers/block/Makefile 19 | =================================================================== 20 | --- linux-2.6.25-source.orig/drivers/block/Makefile 21 | +++ linux-2.6.25-source/drivers/block/Makefile 22 | @@ -13,6 +13,8 @@ 23 | obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o 24 | obj-$(CONFIG_BLK_DEV_RAM) += brd.o 25 | obj-$(CONFIG_BLK_DEV_COBD) += cobd.o 26 | +obj-$(CONFIG_BLK_DEV_CLOOP) += cloop.o 27 | +cloop-objs := compressed_loop.o 28 | obj-$(CONFIG_BLK_DEV_LOOP) += loop.o 29 | obj-$(CONFIG_BLK_DEV_XD) += xd.o 30 | obj-$(CONFIG_BLK_CPQ_DA) += cpqarray.o 31 | -------------------------------------------------------------------------------- /patch/cloop-2.6.26.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.26-source/drivers/block/Kconfig 2 | =================================================================== 3 | --- linux-2.6.26-source.orig/drivers/block/Kconfig 4 | +++ linux-2.6.26-source/drivers/block/Kconfig 5 | @@ -366,6 +366,12 @@ 6 | 7 | If unsure, say Y. 8 | 9 | +config BLK_DEV_CLOOP 10 | + tristate "Compressed Loopback device support (from Knoppix)" 11 | + default m 12 | + help 13 | + Adds an compressed loopback device. 14 | + 15 | config CDROM_PKTCDVD 16 | tristate "Packet writing on CD/DVD media" 17 | depends on !UML 18 | Index: linux-2.6.26-source/drivers/block/Makefile 19 | =================================================================== 20 | --- linux-2.6.26-source.orig/drivers/block/Makefile 21 | +++ linux-2.6.26-source/drivers/block/Makefile 22 | @@ -13,6 +13,8 @@ 23 | obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o 24 | obj-$(CONFIG_BLK_DEV_RAM) += brd.o 25 | obj-$(CONFIG_BLK_DEV_COBD) += cobd.o 26 | +obj-$(CONFIG_BLK_DEV_CLOOP) += cloop.o 27 | +cloop-objs := compressed_loop.o 28 | obj-$(CONFIG_BLK_DEV_LOOP) += loop.o 29 | obj-$(CONFIG_BLK_DEV_XD) += xd.o 30 | obj-$(CONFIG_BLK_CPQ_DA) += cpqarray.o 31 | -------------------------------------------------------------------------------- /patch/cloop-2.6.33.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.33-source/drivers/block/Kconfig 2 | =================================================================== 3 | --- linux-2.6.33-source.orig/drivers/block/Kconfig 4 | +++ linux-2.6.33-source/drivers/block/Kconfig 5 | @@ -271,6 +271,12 @@ 6 | instead, which can be configured to be on-disk compatible with the 7 | cryptoloop device. 8 | 9 | +config BLK_DEV_CLOOP 10 | + tristate "Compressed Loopback device support (from Knoppix)" 11 | + default m 12 | + help 13 | + Adds an compressed loopback device. 14 | + 15 | source "drivers/block/drbd/Kconfig" 16 | 17 | config BLK_DEV_NBD 18 | Index: linux-2.6.33-source/drivers/block/Makefile 19 | =================================================================== 20 | --- linux-2.6.33-source.orig/drivers/block/Makefile 21 | +++ linux-2.6.33-source/drivers/block/Makefile 22 | @@ -15,6 +15,8 @@ 23 | obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o 24 | obj-$(CONFIG_BLK_DEV_RAM) += brd.o 25 | obj-$(CONFIG_BLK_DEV_COBD) += cobd.o 26 | +obj-$(CONFIG_BLK_DEV_CLOOP) += cloop.o 27 | +cloop-objs := compressed_loop.o 28 | obj-$(CONFIG_BLK_DEV_LOOP) += loop.o 29 | obj-$(CONFIG_BLK_DEV_XD) += xd.o 30 | obj-$(CONFIG_BLK_CPQ_DA) += cpqarray.o 31 | -------------------------------------------------------------------------------- /patch/fltk-1.1.10-linux-patch.diff: -------------------------------------------------------------------------------- 1 | --- fltk-1.1.10/FL/x.H 2 | +++ fltk-1.1.10/FL/x.H 3 | @@ -140,6 +140,8 @@ 4 | 5 | extern FL_EXPORT int fl_parse_color(const char* p, uchar& r, uchar& g, uchar& b); 6 | 7 | +extern int (*fl_x_global_event_hook)(const XEvent& thisevent); 8 | + 9 | # endif 10 | #endif 11 | 12 | --- fltk-1.1.10/src/Fl_x.cxx 13 | +++ fltk-1.1.10/src/Fl_x.cxx 14 | @@ -556,6 +556,8 @@ 15 | } 16 | } 17 | 18 | +int (*fl_x_global_event_hook)(const XEvent& thisevent) = NULL; 19 | + 20 | //////////////////////////////////////////////////////////////// 21 | 22 | static char unknown[] = ""; 23 | @@ -567,6 +569,12 @@ 24 | fl_xevent = &thisevent; 25 | Window xid = xevent.xany.window; 26 | 27 | + if (fl_x_global_event_hook != NULL) { 28 | + if (fl_x_global_event_hook(thisevent)) { 29 | + return 0; 30 | + } 31 | + } 32 | + 33 | switch (xevent.type) { 34 | 35 | case KeymapNotify: 36 | -------------------------------------------------------------------------------- /patch/fltk-1.1.10-win32.diff: -------------------------------------------------------------------------------- 1 | # 2 | # X11 is disabled, don't try to find it 3 | # 4 | --- fltk-1.1.10/configure 5 | +++ fltk-1.1.10/configure 6 | @@ -11222,7 +11222,7 @@ 7 | fi 8 | 9 | 10 | - if test x$no_x = xyes; then 11 | + if test x$no_x = xyes -a x$have_x != xdisabled; then 12 | { { echo "$as_me:$LINENO: error: Configure could not find required X11 libraries" >&5 13 | echo "$as_me: error: Configure could not find required X11 libraries" >&2;} 14 | { (exit aborting.); exit aborting.; }; } 15 | # 16 | # Fix: undefined reference to `__TrackMouseEvent@4' 17 | # 18 | --- fltk-1.1.10/src/Fl_win32.cxx 19 | +++ fltk-1.1.10/src/Fl_win32.cxx 20 | @@ -85,7 +85,7 @@ 21 | // means that the top level window has been left (otherwise we would have 22 | // got another WM_MOUSEMOVE message before). 23 | 24 | -// #define NO_TRACK_MOUSE 25 | +#define NO_TRACK_MOUSE 26 | 27 | #if !defined(NO_TRACK_MOUSE) 28 | # define USE_TRACK_MOUSE 29 | -------------------------------------------------------------------------------- /patch/frame-size-checks.diff: -------------------------------------------------------------------------------- 1 | * Fix tons of "warning: the frame size of ... bytes is larger than 0 bytes" 2 | 3 | Index: linux-2.6.26-source/Makefile 4 | =================================================================== 5 | --- linux-2.6.26-source.orig/Makefile 6 | +++ linux-2.6.26-source/Makefile 7 | @@ -507,7 +507,7 @@ 8 | KBUILD_CFLAGS += -O2 9 | endif 10 | 11 | -ifneq (CONFIG_FRAME_WARN,0) 12 | +ifneq ($(CONFIG_FRAME_WARN),0) 13 | KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN}) 14 | endif 15 | 16 | -------------------------------------------------------------------------------- /patch/gcc412fix.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.25-source/arch/x86/kernel/vm86_32.c 2 | =================================================================== 3 | --- linux-2.6.25-source.orig/arch/x86/kernel/vm86_32.c 4 | +++ linux-2.6.25-source/arch/x86/kernel/vm86_32.c 5 | @@ -44,6 +44,7 @@ 6 | 7 | #include 8 | #include 9 | +#include 10 | #include 11 | #include 12 | 13 | -------------------------------------------------------------------------------- /patch/scsi-2.6.25.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.25-source/drivers/scsi/Kconfig 2 | =================================================================== 3 | --- linux-2.6.25-source.orig/drivers/scsi/Kconfig 4 | +++ linux-2.6.25-source/drivers/scsi/Kconfig 5 | @@ -327,6 +327,12 @@ 6 | 7 | if SCSI_LOWLEVEL && SCSI 8 | 9 | +config SCSI_COOPERATIVE 10 | + bool "Cooperative Linux support" 11 | + depends on COOPERATIVE 12 | + help 13 | + SCSI Driver for Cooperative Linux 14 | + 15 | config ISCSI_TCP 16 | tristate "iSCSI Initiator over TCP/IP" 17 | depends on SCSI && INET 18 | Index: linux-2.6.25-source/drivers/scsi/Makefile 19 | =================================================================== 20 | --- linux-2.6.25-source.orig/drivers/scsi/Makefile 21 | +++ linux-2.6.25-source/drivers/scsi/Makefile 22 | @@ -52,6 +52,7 @@ 23 | obj-$(CONFIG_SCSI_SIM710) += 53c700.o sim710.o 24 | obj-$(CONFIG_SCSI_ADVANSYS) += advansys.o 25 | obj-$(CONFIG_SCSI_BUSLOGIC) += BusLogic.o 26 | +obj-$(CONFIG_SCSI_COOPERATIVE) += coscsi.o 27 | obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o 28 | obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o 29 | obj-$(CONFIG_SCSI_ARCMSR) += arcmsr/ 30 | Index: linux-2.6.25-source/include/linux/blkdev.h 31 | =================================================================== 32 | --- linux-2.6.25-source.orig/include/linux/blkdev.h 33 | +++ linux-2.6.25-source/include/linux/blkdev.h 34 | @@ -756,7 +756,11 @@ 35 | 36 | extern int blkdev_issue_flush(struct block_device *, sector_t *); 37 | 38 | +#ifdef CONFIG_COOPERATIVE 39 | +#define MAX_PHYS_SEGMENTS 256 40 | +#else 41 | #define MAX_PHYS_SEGMENTS 128 42 | +#endif 43 | #define MAX_HW_SEGMENTS 128 44 | #define SAFE_MAX_SECTORS 255 45 | #define BLK_DEF_MAX_SECTORS 1024 46 | -------------------------------------------------------------------------------- /patch/scsi-2.6.26.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.26-source/drivers/scsi/Kconfig 2 | =================================================================== 3 | --- linux-2.6.26-source.orig/drivers/scsi/Kconfig 4 | +++ linux-2.6.26-source/drivers/scsi/Kconfig 5 | @@ -327,6 +327,12 @@ 6 | 7 | if SCSI_LOWLEVEL && SCSI 8 | 9 | +config SCSI_COOPERATIVE 10 | + bool "Cooperative Linux support" 11 | + depends on COOPERATIVE 12 | + help 13 | + SCSI Driver for Cooperative Linux 14 | + 15 | config ISCSI_TCP 16 | tristate "iSCSI Initiator over TCP/IP" 17 | depends on SCSI && INET 18 | Index: linux-2.6.26-source/drivers/scsi/Makefile 19 | =================================================================== 20 | --- linux-2.6.26-source.orig/drivers/scsi/Makefile 21 | +++ linux-2.6.26-source/drivers/scsi/Makefile 22 | @@ -53,6 +53,7 @@ 23 | obj-$(CONFIG_SCSI_SIM710) += 53c700.o sim710.o 24 | obj-$(CONFIG_SCSI_ADVANSYS) += advansys.o 25 | obj-$(CONFIG_SCSI_BUSLOGIC) += BusLogic.o 26 | +obj-$(CONFIG_SCSI_COOPERATIVE) += coscsi.o 27 | obj-$(CONFIG_SCSI_DPT_I2O) += dpt_i2o.o 28 | obj-$(CONFIG_SCSI_U14_34F) += u14-34f.o 29 | obj-$(CONFIG_SCSI_ARCMSR) += arcmsr/ 30 | Index: linux-2.6.26-source/include/linux/blkdev.h 31 | =================================================================== 32 | --- linux-2.6.26-source.orig/include/linux/blkdev.h 33 | +++ linux-2.6.26-source/include/linux/blkdev.h 34 | @@ -802,7 +802,11 @@ 35 | 36 | extern int blkdev_issue_flush(struct block_device *, sector_t *); 37 | 38 | +#ifdef CONFIG_COOPERATIVE 39 | +#define MAX_PHYS_SEGMENTS 256 40 | +#else 41 | #define MAX_PHYS_SEGMENTS 128 42 | +#endif 43 | #define MAX_HW_SEGMENTS 128 44 | #define SAFE_MAX_SECTORS 255 45 | #define BLK_DEF_MAX_SECTORS 1024 46 | -------------------------------------------------------------------------------- /patch/serial-2.6.25.diff: -------------------------------------------------------------------------------- 1 | Serial support 2 | 3 | Index: linux-2.6.25-source/drivers/serial/Kconfig 4 | =================================================================== 5 | --- linux-2.6.25-source.orig/drivers/serial/Kconfig 6 | +++ linux-2.6.25-source/drivers/serial/Kconfig 7 | @@ -1353,3 +1353,15 @@ 8 | Support for Console on SC2681/SC2692 serial ports. 9 | 10 | endmenu 11 | + 12 | +config SERIAL_COOPERATIVE 13 | + bool "coLinux serial device support" 14 | + depends on COOPERATIVE 15 | + default y 16 | + help 17 | + say Y, if you have colinux 18 | + 19 | +config SERIAL_COOPERATIVE_CONSOLE 20 | + bool "coLinux serial console support" 21 | + depends on SERIAL_COOPERATIVE=y 22 | + select SERIAL_CORE_CONSOLE 23 | Index: linux-2.6.25-source/drivers/serial/Makefile 24 | =================================================================== 25 | --- linux-2.6.25-source.orig/drivers/serial/Makefile 26 | +++ linux-2.6.25-source/drivers/serial/Makefile 27 | @@ -67,3 +67,4 @@ 28 | obj-$(CONFIG_SERIAL_OF_PLATFORM) += of_serial.o 29 | obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o 30 | obj-$(CONFIG_SERIAL_QE) += ucc_uart.o 31 | +obj-$(CONFIG_SERIAL_COOPERATIVE) += coserial.o 32 | Index: linux-2.6.25-source/drivers/serial/coserial.c 33 | =================================================================== 34 | --- linux-2.6.25-source.orig/drivers/serial/coserial.c 35 | +++ linux-2.6.25-source/drivers/serial/coserial.c 36 | @@ -170,11 +170,17 @@ 37 | { 38 | } 39 | 40 | +static int cocd_chars_in_buffer(struct tty_struct *tty) 41 | +{ 42 | + return 0; 43 | +} 44 | + 45 | static struct tty_operations cocd_ops = { 46 | .open = cocd_open, 47 | .close = cocd_close, 48 | .write = cocd_write, 49 | .write_room = cocd_write_room, 50 | + .chars_in_buffer = cocd_chars_in_buffer, 51 | .set_termios = cocd_set_termios, 52 | }; 53 | 54 | -------------------------------------------------------------------------------- /patch/serial-2.6.26.diff: -------------------------------------------------------------------------------- 1 | Serial support 2 | 3 | Index: linux-2.6.26-source/drivers/serial/Kconfig 4 | =================================================================== 5 | --- linux-2.6.26-source.orig/drivers/serial/Kconfig 6 | +++ linux-2.6.26-source/drivers/serial/Kconfig 7 | @@ -1403,3 +1403,15 @@ 8 | default 9600 if (SERIAL_SPORT_BAUD_RATE_9600) 9 | 10 | endmenu 11 | + 12 | +config SERIAL_COOPERATIVE 13 | + bool "coLinux serial device support" 14 | + depends on COOPERATIVE 15 | + default y 16 | + help 17 | + say Y, if you have colinux 18 | + 19 | +config SERIAL_COOPERATIVE_CONSOLE 20 | + bool "coLinux serial console support" 21 | + depends on SERIAL_COOPERATIVE=y 22 | + select SERIAL_CORE_CONSOLE 23 | Index: linux-2.6.26-source/drivers/serial/Makefile 24 | =================================================================== 25 | --- linux-2.6.26-source.orig/drivers/serial/Makefile 26 | +++ linux-2.6.26-source/drivers/serial/Makefile 27 | @@ -68,3 +68,4 @@ 28 | obj-$(CONFIG_SERIAL_KS8695) += serial_ks8695.o 29 | obj-$(CONFIG_KGDB_SERIAL_CONSOLE) += kgdboc.o 30 | obj-$(CONFIG_SERIAL_QE) += ucc_uart.o 31 | +obj-$(CONFIG_SERIAL_COOPERATIVE) += coserial.o 32 | -------------------------------------------------------------------------------- /patch/serial-2.6.33.diff: -------------------------------------------------------------------------------- 1 | Serial support 2 | 3 | Index: linux-2.6.33-source/drivers/char/Kconfig 4 | =================================================================== 5 | --- linux-2.6.33-source.orig/drivers/char/Kconfig 6 | +++ linux-2.6.33-source/drivers/char/Kconfig 7 | @@ -112,7 +112,7 @@ 8 | 9 | config SERIAL_NONSTANDARD 10 | bool "Non-standard serial port support" 11 | - depends on HAS_IOMEM 12 | + depends on HAS_IOMEM && !COOPERATIVE 13 | ---help--- 14 | Say Y here if you have any non-standard serial boards -- boards 15 | which aren't supported using the standard "dumb" serial driver. 16 | Index: linux-2.6.33-source/drivers/serial/Kconfig 17 | =================================================================== 18 | --- linux-2.6.33-source.orig/drivers/serial/Kconfig 19 | +++ linux-2.6.33-source/drivers/serial/Kconfig 20 | @@ -1491,3 +1491,15 @@ 21 | Support for running a console on the GRLIB APBUART 22 | 23 | endmenu 24 | + 25 | +config SERIAL_COOPERATIVE 26 | + bool "coLinux serial device support" 27 | + depends on COOPERATIVE 28 | + default y 29 | + help 30 | + Say Y, if you have colinux 31 | + 32 | +config SERIAL_COOPERATIVE_CONSOLE 33 | + bool "coLinux serial console support" 34 | + depends on SERIAL_COOPERATIVE=y 35 | + select SERIAL_CORE_CONSOLE 36 | Index: linux-2.6.33-source/drivers/serial/Makefile 37 | =================================================================== 38 | --- linux-2.6.33-source.orig/drivers/serial/Makefile 39 | +++ linux-2.6.33-source/drivers/serial/Makefile 40 | @@ -82,3 +82,4 @@ 41 | obj-$(CONFIG_SERIAL_QE) += ucc_uart.o 42 | obj-$(CONFIG_SERIAL_TIMBERDALE) += timbuart.o 43 | obj-$(CONFIG_SERIAL_GRLIB_GAISLER_APBUART) += apbuart.o 44 | +obj-$(CONFIG_SERIAL_COOPERATIVE) += coserial.o 45 | -------------------------------------------------------------------------------- /patch/series-2.6.25.20: -------------------------------------------------------------------------------- 1 | base-2.6.25.diff 2 | gcc412fix.diff 3 | timer-2.6.25.diff 4 | coconsole-core.diff 5 | coconsole-2.6.25.diff 6 | serial-core.diff 7 | serial-2.6.25.diff 8 | conet-pci-core.diff 9 | conet-2.6.25.diff 10 | cobd-core.diff 11 | cobd-2.6.25.diff 12 | kbd-core.diff 13 | kbd-2.6.25.diff 14 | mouse-core.diff 15 | mouse-2.6.25.diff 16 | cofs-core.diff 17 | cofs-2.6.25.diff 18 | unionfs-2.5.4_for_2.6.25.20.diff 19 | unionfs-2.6.25.20.diff 20 | squashfs3.3-core.diff 21 | squashfs3.3-2.6.25.diff 22 | cloop-core-2.628.diff 23 | cloop-2.6.25.diff 24 | pci-core.diff 25 | pci-2.6.25.diff 26 | scsi-core.diff 27 | scsi-2.6.25.diff 28 | audio-core.diff 29 | audio-2.6.25.diff 30 | video-core.diff 31 | video-2.6.25.diff 32 | -------------------------------------------------------------------------------- /patch/series-2.6.26.8: -------------------------------------------------------------------------------- 1 | squashfs3.4-2.6.26.diff 2 | unionfs-2.5.4_for_2.6.26.8.diff 3 | colinux_2.6.26-ext4-7.diff 4 | frame-size-checks.diff 5 | base-2.6.26.diff 6 | timer-2.6.26.diff 7 | coconsole-core.diff 8 | coconsole-2.6.26.diff 9 | serial-core.diff 10 | serial-2.6.26.diff 11 | conet-pci-core.diff 12 | conet-2.6.26.diff 13 | cobd-core.diff 14 | cobd-2.6.26.diff 15 | kbd-core.diff 16 | kbd-2.6.26.diff 17 | mouse-core.diff 18 | mouse-2.6.26.diff 19 | cofs-core.diff 20 | cofs-2.6.26.diff 21 | unionfs-2.6.26.8.diff 22 | cloop-core-2.628.diff 23 | cloop-2.6.26.diff 24 | pci-core.diff 25 | pci-2.6.26.diff 26 | scsi-core.diff 27 | scsi-2.6.26.diff 28 | audio-core.diff 29 | audio-2.6.26.diff 30 | video-core.diff 31 | video-2.6.26.diff 32 | -------------------------------------------------------------------------------- /patch/series-2.6.33.7: -------------------------------------------------------------------------------- 1 | coconsole-core.diff 2 | serial-core.diff 3 | conet-pci-core.diff 4 | cobd-core.diff 5 | kbd-core.diff 6 | mouse-core.diff 7 | cofs-core.diff 8 | pci-core.diff 9 | scsi-core.diff 10 | audio-core.diff 11 | video-core.diff 12 | cloop-core-2.631.diff 13 | unionfs-2.5.4_for_2.6.33.diff 14 | tty-buffer-alloc-2.6.33.diff 15 | base-2.6.33.diff 16 | timer-2.6.33.diff 17 | coconsole-2.6.33.diff 18 | serial-2.6.33.diff 19 | conet-2.6.33.diff 20 | cobd-2.6.33.diff 21 | kbd-2.6.33.diff 22 | mouse-2.6.33.diff 23 | cofs-2.6.33.diff 24 | cloop-2.6.33.diff 25 | pci-2.6.33.diff 26 | scsi-2.6.33.diff 27 | audio-2.6.33.diff 28 | video-2.6.33.diff 29 | -------------------------------------------------------------------------------- /patch/unionfs-2.6.25.20.diff: -------------------------------------------------------------------------------- 1 | # Bugfix this build error: 2 | # ERROR: "security_inode_permission" [fs/unionfs/unionfs.ko] undefined! 3 | 4 | Index: linux-2.6.25-source/security/security.c 5 | =================================================================== 6 | --- linux-2.6.25-source.orig/security/security.c 7 | +++ linux-2.6.25-source/security/security.c 8 | @@ -433,6 +433,7 @@ 9 | return 0; 10 | return security_ops->inode_permission(inode, mask, nd); 11 | } 12 | +EXPORT_SYMBOL(security_inode_permission); 13 | 14 | int security_inode_setattr(struct dentry *dentry, struct iattr *attr) 15 | { 16 | -------------------------------------------------------------------------------- /patch/unionfs-2.6.26.8.diff: -------------------------------------------------------------------------------- 1 | # Bugfix this build error with unionfs as module: 2 | # "security_inode_permission" [fs/unionfs/unionfs.ko] undefined! 3 | 4 | Index: linux-2.6.26.8-source/security/security.c 5 | =================================================================== 6 | --- linux-2.6.26.8-source.orig/security/security.c 7 | +++ linux-2.6.26.8-source/security/security.c 8 | @@ -469,6 +469,7 @@ 9 | return 0; 10 | return security_ops->inode_permission(inode, mask, nd); 11 | } 12 | +EXPORT_SYMBOL_GPL(security_inode_permission); 13 | 14 | int security_inode_setattr(struct dentry *dentry, struct iattr *attr) 15 | { 16 | -------------------------------------------------------------------------------- /patch/video-2.6.25.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.25-source/drivers/video/Kconfig 2 | =================================================================== 3 | --- linux-2.6.25-source.orig/drivers/video/Kconfig 4 | +++ linux-2.6.25-source/drivers/video/Kconfig 5 | @@ -201,6 +201,23 @@ 6 | comment "Frame buffer hardware drivers" 7 | depends on FB 8 | 9 | +config COOPERATIVE_VIDEO 10 | + bool "Cooperative Video" 11 | + default n 12 | + depends on COOPERATIVE 13 | + select FB 14 | + select FB_SYS_FILLRECT 15 | + select FB_SYS_COPYAREA 16 | + select FB_SYS_IMAGEBLIT 17 | + select FB_SYS_FOPS 18 | + select FRAMEBUFFER_CONSOLE if !COOPERATIVE_CONSOLE 19 | + select LOGO if !COOPERATIVE_CONSOLE 20 | + select LOGO_LINUX_CLUT224 if !COOPERATIVE_CONSOLE 21 | + ---help--- 22 | + This enables the Cooperative Framebuffer Video driver. 23 | + 24 | + Say N unless you are compiling a Cooperative kernel. 25 | + 26 | config FB_CIRRUS 27 | tristate "Cirrus Logic support" 28 | depends on FB && (ZORRO || PCI) 29 | Index: linux-2.6.25-source/drivers/video/Makefile 30 | =================================================================== 31 | --- linux-2.6.25-source.orig/drivers/video/Makefile 32 | +++ linux-2.6.25-source/drivers/video/Makefile 33 | @@ -27,6 +27,8 @@ 34 | obj-$(CONFIG_FB_DDC) += fb_ddc.o 35 | obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o 36 | 37 | +obj-$(CONFIG_COOPERATIVE_VIDEO) += covideo.o 38 | + 39 | # Hardware specific drivers go first 40 | obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o 41 | obj-$(CONFIG_FB_ARC) += arcfb.o 42 | -------------------------------------------------------------------------------- /patch/video-2.6.26.diff: -------------------------------------------------------------------------------- 1 | Index: linux-2.6.26-source/drivers/video/Kconfig 2 | =================================================================== 3 | --- linux-2.6.26-source.orig/drivers/video/Kconfig 4 | +++ linux-2.6.26-source/drivers/video/Kconfig 5 | @@ -234,6 +234,23 @@ 6 | comment "Frame buffer hardware drivers" 7 | depends on FB 8 | 9 | +config COOPERATIVE_VIDEO 10 | + bool "Cooperative Video" 11 | + default n 12 | + depends on COOPERATIVE 13 | + select FB 14 | + select FB_SYS_FILLRECT 15 | + select FB_SYS_COPYAREA 16 | + select FB_SYS_IMAGEBLIT 17 | + select FB_SYS_FOPS 18 | + select FRAMEBUFFER_CONSOLE if !COOPERATIVE_CONSOLE 19 | + select LOGO if !COOPERATIVE_CONSOLE 20 | + select LOGO_LINUX_CLUT224 if !COOPERATIVE_CONSOLE 21 | + ---help--- 22 | + This enables the Cooperative Framebuffer Video driver. 23 | + 24 | + Say N unless you are compiling a Cooperative kernel. 25 | + 26 | config FB_CIRRUS 27 | tristate "Cirrus Logic support" 28 | depends on FB && (ZORRO || PCI) 29 | Index: linux-2.6.26-source/drivers/video/Makefile 30 | =================================================================== 31 | --- linux-2.6.26-source.orig/drivers/video/Makefile 32 | +++ linux-2.6.26-source/drivers/video/Makefile 33 | @@ -27,6 +27,8 @@ 34 | obj-$(CONFIG_FB_DDC) += fb_ddc.o 35 | obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o 36 | 37 | +obj-$(CONFIG_COOPERATIVE_VIDEO) += covideo.o 38 | + 39 | # Hardware specific drivers go first 40 | obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o 41 | obj-$(CONFIG_FB_AM200EPD) += am200epd.o 42 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This source code is a part of coLinux source package. 3 | # 4 | # Dan Aloni , 2003 (c) 5 | # 6 | # gmake-compatible old build interface. 7 | # 8 | 9 | .phony: FORCE 10 | 11 | FORCE: 12 | 13 | colinux: FORCE 14 | python ../bin/make.py colinux 15 | 16 | installer: 17 | python ../bin/make.py installer 18 | 19 | clean: 20 | python ../bin/make.py clean 21 | rm -f colinux/arch/current colinux/os/current 22 | rm -f src/colinux/os/darwin/kernel/build 23 | rm -f src/colinux/os/darwin/linuxheaders 24 | -------------------------------------------------------------------------------- /src/colinux/VERSION: -------------------------------------------------------------------------------- 1 | 0.7.9 2 | -------------------------------------------------------------------------------- /src/colinux/arch/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input("current/build.o"), 4 | ] 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/antinx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_I386_ANTINX_H__ 11 | #define __COLINUX_ARCH_I386_ANTINX_H__ 12 | 13 | extern co_rc_t co_arch_anti_nx_init(struct co_monitor *cmon); 14 | extern void co_arch_anti_nx_free(struct co_monitor *cmon); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/apic.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | * This code is based on Linux 2.6.x arch/i386/kernel/apic.c. 10 | */ 11 | 12 | #include 13 | 14 | #include "defs.h" 15 | #include "apic.h" 16 | 17 | co_rc_t co_manager_arch_init_apic(co_archdep_manager_t manager) 18 | { 19 | co_debug("arch APIC initialization"); 20 | 21 | if (!(manager->caps[0] & CO_ARCH_X86_FEATURE_APIC)) { 22 | co_debug_error("no APIC support"); 23 | return CO_RC(ERROR); 24 | } 25 | 26 | co_debug("found APIC support"); 27 | 28 | 29 | 30 | /* 31 | * BIG TODO: 32 | * 33 | * Find if we really need to mangle with APIC in coLinux. 34 | * The SMP problem could be unrelated to APIC. 35 | */ 36 | 37 | return CO_RC(OK); 38 | } 39 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/apic.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_I386_APIC_H__ 11 | #define __COLINUX_ARCH_I386_APIC_H__ 12 | 13 | #include "manager.h" 14 | 15 | extern co_rc_t co_manager_arch_init_apic(co_archdep_manager_t manager); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs = input_list(".c", ".o"), 3 | ) 4 | 5 | targets['Makefile.lib-m'] = Target( 6 | inputs = input_list(".c", ".c"), 7 | tool = MakefileKbuild(), 8 | ) 9 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/cpuid.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_I386_CPUID_H__ 11 | #define __COLINUX_ARCH_I386_CPUID_H__ 12 | 13 | #include 14 | 15 | typedef union { 16 | struct { 17 | unsigned long eax, ebx, ecx, edx; 18 | }; 19 | struct { 20 | unsigned long highest_op; 21 | char id_string[12]; 22 | }; 23 | } cpuid_t; 24 | 25 | bool_t co_i386_has_cpuid(void); 26 | void co_i386_get_cpuid(unsigned long op, cpuid_t *cpuid); 27 | co_rc_t co_i386_get_cpuid_capabilities(unsigned long *caps); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/interrupt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #include 11 | 12 | static inline void call_intr(void *func) 13 | { 14 | asm(" call 1f" "\n" 15 | "1: popl %%eax" "\n" 16 | " addl $2f-1b,%%eax" "\n" 17 | " pushfl" /* flags */ "\n" 18 | " pushl %%cs" /* cs */ "\n" 19 | " pushl %%eax" /* eip (2:) */ "\n" 20 | " jmp *%0" /* jmp func */ "\n" 21 | "2: sti" "\n" 22 | : : "r"(func): "eax", "esp"); 23 | } 24 | 25 | void co_monitor_arch_real_hardware_interrupt(co_monitor_t *cmon) 26 | { 27 | struct { 28 | unsigned long a, b; 29 | } *host; 30 | void *func; 31 | 32 | host = (typeof(host))(cmon->passage_page->host_state.idt.table); 33 | host = &host[co_passage_page->params[0]]; 34 | func = (void *)((host->b & 0xffff0000) | (host->a & 0x0000ffff)); 35 | 36 | call_intr(func); 37 | } 38 | 39 | void co_monitor_arch_enable_interrupts(void) 40 | { 41 | asm("sti\n"); 42 | } 43 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/manager.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | 13 | #include "manager.h" 14 | #include "apic.h" 15 | 16 | co_rc_t co_manager_arch_init(co_manager_t *manager, co_archdep_manager_t *out_archdep) 17 | { 18 | co_rc_t rc; 19 | co_archdep_manager_t archdep; 20 | 21 | *out_archdep = NULL; 22 | 23 | co_debug("arch init"); 24 | 25 | archdep = co_os_malloc(sizeof(*archdep)); 26 | if (archdep == NULL) 27 | return CO_RC(OUT_OF_MEMORY); 28 | 29 | co_memset(archdep, 0, sizeof(*archdep)); 30 | 31 | archdep->has_cpuid = co_i386_has_cpuid(); 32 | if (archdep->has_cpuid == PFALSE) { 33 | co_debug_error("error, no CPUID!"); 34 | rc = CO_RC(ERROR); 35 | goto out_error; 36 | } 37 | 38 | rc = co_i386_get_cpuid_capabilities(archdep->caps); 39 | if (!CO_OK(rc)) { 40 | co_debug_error("error, couldn't get CPU capabilities"); 41 | rc = CO_RC(ERROR); 42 | goto out_error; 43 | } 44 | 45 | rc = co_manager_arch_init_apic(archdep); 46 | if (!CO_OK(rc)) 47 | goto out_error; 48 | 49 | *out_archdep = archdep; 50 | return rc; 51 | 52 | out_error: 53 | co_os_free(archdep); 54 | return rc; 55 | } 56 | 57 | void co_manager_arch_free(co_archdep_manager_t archdep) 58 | { 59 | co_debug("arch free"); 60 | 61 | co_os_free(archdep); 62 | } 63 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_I386_MANAGER_H__ 11 | #define __COLINUX_ARCH_I386_MANAGER_H__ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "cpuid.h" 19 | 20 | struct co_archdep_manager { 21 | bool_t has_cpuid; 22 | unsigned long caps[2]; 23 | }; 24 | 25 | struct co_archdep_monitor { 26 | bool_t antinx_enabled; 27 | unsigned char *fixed_page_table_mapping; 28 | co_pfn_t fixed_page_table_pfn; 29 | unsigned long long *fixed_pte; 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | 13 | #include "utils.h" 14 | 15 | unsigned long co_get_cr4(void) 16 | { 17 | unsigned long cr4 = 0; 18 | asm("mov %%cr4, %0" : "=r"(cr4)); 19 | return cr4; 20 | } 21 | 22 | bool_t co_is_pae_enabled(void) 23 | { 24 | return co_get_cr4() & 0x20; 25 | } 26 | 27 | unsigned long co_get_cr3(void) 28 | { 29 | unsigned long cr3 = 0; 30 | asm("mov %%cr3, %0" : "=r"(cr3)); 31 | return cr3; 32 | } 33 | 34 | unsigned long co_get_dr0(void) 35 | { 36 | unsigned long reg = 0; 37 | asm("mov %%dr0, %0" : "=r"(reg)); 38 | return reg; 39 | } 40 | 41 | unsigned long co_get_dr1(void) 42 | { 43 | unsigned long reg = 0; 44 | asm("mov %%dr1, %0" : "=r"(reg)); 45 | return reg; 46 | } 47 | 48 | unsigned long co_get_dr2(void) 49 | { 50 | unsigned long reg = 0; 51 | asm("mov %%dr2, %0" : "=r"(reg)); 52 | return reg; 53 | } 54 | 55 | unsigned long co_get_dr3(void) 56 | { 57 | unsigned long reg = 0; 58 | asm("mov %%dr3, %0" : "=r"(reg)); 59 | return reg; 60 | } 61 | 62 | unsigned long co_get_dr6(void) 63 | { 64 | unsigned long reg = 0; 65 | asm("mov %%dr6, %0" : "=r"(reg)); 66 | return reg; 67 | } 68 | 69 | unsigned long co_get_dr7(void) 70 | { 71 | unsigned long reg = 0; 72 | asm("mov %%dr7, %0" : "=r"(reg)); 73 | return reg; 74 | } 75 | -------------------------------------------------------------------------------- /src/colinux/arch/i386/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_I386_UTILS_H__ 11 | #define __COLINUX_ARCH_I386_UTILS_H__ 12 | 13 | #include 14 | 15 | extern bool_t co_is_pae_enabled(void); 16 | extern unsigned long co_get_cr3(void); 17 | extern unsigned long co_get_cr4(void); 18 | extern unsigned long co_get_dr0(void); 19 | extern unsigned long co_get_dr1(void); 20 | extern unsigned long co_get_dr2(void); 21 | extern unsigned long co_get_dr3(void); 22 | extern unsigned long co_get_dr6(void); 23 | extern unsigned long co_get_dr7(void); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/colinux/arch/interrupt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_INTERRUPT_H__ 11 | #define __COLINUX_ARCH_INTERRUPT_H__ 12 | 13 | #include 14 | 15 | extern void co_monitor_arch_real_hardware_interrupt(co_monitor_t *cmon); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/colinux/arch/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_MANAGER_H__ 11 | #define __COLINUX_ARCH_MANAGER_H__ 12 | 13 | #include 14 | 15 | typedef struct co_archdep_manager *co_archdep_manager_t; 16 | struct co_manager; 17 | 18 | typedef struct co_archdep_monitor *co_archdep_monitor_t; 19 | struct co_monitor; 20 | 21 | extern co_rc_t co_manager_arch_init(struct co_manager *manager, co_archdep_manager_t *out_archdep); 22 | extern void co_manager_arch_free(co_archdep_manager_t out_archdep); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/colinux/arch/mmu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_MMU_H__ 11 | #define __COLINUX_ARCH_MMU_H__ 12 | 13 | #include 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/colinux/arch/passage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_ARCH_PASSAGE_H__ 11 | #define __COLINUX_ARCH_PASSAGE_H__ 12 | 13 | #include 14 | 15 | extern co_rc_t co_monitor_arch_passage_page_alloc(co_monitor_t *cmon); 16 | extern co_rc_t co_monitor_arch_passage_page_init(co_monitor_t *cmon); 17 | extern void co_monitor_arch_passage_page_free(co_monitor_t *cmon); 18 | extern void co_host_switch_wrapper(co_monitor_t *cmon); 19 | extern void co_monitor_arch_enable_interrupts(void); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/colinux/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['user.a'] = Target( 2 | inputs=[ 3 | Input("user/user.a"), 4 | Input("common/common.a"), 5 | ] 6 | ) 7 | -------------------------------------------------------------------------------- /src/colinux/common/errors.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #include "common.h" 11 | #include "debug.h" 12 | 13 | #ifdef COLINUX_DEBUG 14 | static int file_id_max; 15 | #endif 16 | 17 | #define X(name) "CO_RC_ERROR_"#name, 18 | static const char *co_errors_strings[] = { 19 | "", 20 | CO_ERRORS_X_MACRO 21 | }; 22 | #undef X 23 | 24 | void co_rc_format_error(co_rc_t rc, char *buf, int size) 25 | { 26 | if (CO_OK(rc)) { 27 | co_snprintf(buf, size, "success - line %ld, file id %ld", 28 | CO_RC_GET_LINE(rc), 29 | CO_RC_GET_FILE_ID(rc)); 30 | } else { 31 | unsigned int code; 32 | unsigned int file_id; 33 | const char *code_string; 34 | const char *file_string; 35 | 36 | code = -CO_RC_GET_CODE(rc); 37 | if (code < (sizeof(co_errors_strings)/sizeof(co_errors_strings[0]))) { 38 | code_string = co_errors_strings[code]; 39 | } else { 40 | code_string = ""; 41 | } 42 | 43 | #ifdef COLINUX_DEBUG 44 | if (file_id_max == 0) { 45 | while (colinux_obj_filenames[file_id_max]) 46 | file_id_max++; 47 | } 48 | 49 | file_id = CO_RC_GET_FILE_ID(rc); 50 | if (file_id < file_id_max) { 51 | file_string = colinux_obj_filenames[file_id]; 52 | } else { 53 | file_string = ""; 54 | } 55 | #else 56 | file_id = 0; 57 | file_string = ""; 58 | #endif 59 | 60 | co_snprintf(buf, size, "error - %s, line %ld, file %s (%d)", 61 | code_string, CO_RC_GET_LINE(rc), file_string, file_id); 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /src/colinux/common/import.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __CO_KERNEL_SYMBOLS_IMPORT_H__ 11 | #define __CO_KERNEL_SYMBOLS_IMPORT_H__ 12 | 13 | typedef struct { 14 | unsigned long kernel_start; 15 | unsigned long kernel_end; 16 | unsigned long kernel_init_task_union; 17 | unsigned long kernel_colinux_start; 18 | unsigned long kernel_swapper_pg_dir; 19 | unsigned long kernel_idt_table; 20 | unsigned long kernel_gdt_table; 21 | unsigned long kernel_co_arch_info; 22 | unsigned long kernel_co_info; 23 | } co_symbols_import_t; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/colinux/common/libc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_LINUX_LIBC_H__ 11 | #define __COLINUX_LINUX_LIBC_H__ 12 | 13 | extern void *co_memset(void *s, int c, long n); 14 | extern void *co_memcpy(void *dest, const void *src, long n); 15 | extern int co_memcmp(void *s1, void *, int); 16 | extern void *co_memmove(void *dest, const void *src, long n); 17 | extern void co_bzero(void *s, long n); 18 | extern const char *co_strstr(const char *haystack, const char *needle); 19 | extern int co_strlen(const char *s); 20 | extern int co_strcmp(const char *s1, const char *s2); 21 | extern int co_strncmp(const char *s1, const char *s2, int n); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/colinux/common/messages.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __CO_KERNEL_MESSAGES_H__ 11 | #define __CO_KERNEL_MESSAGES_H__ 12 | 13 | #include "list.h" 14 | #include "queue.h" 15 | #include "common.h" 16 | 17 | #define CO_QUEUE_COUNT_LIMIT_BEFORE_SLEEP 1024 18 | 19 | typedef struct co_message_queue_item { 20 | co_message_t *message; 21 | } co_message_queue_item_t; 22 | 23 | typedef char co_module_name_t[0x20]; 24 | 25 | extern co_rc_t co_message_dup_to_queue(co_message_t *message, co_queue_t *queue); 26 | extern co_rc_t co_message_mov_to_queue(co_message_t *message, co_queue_t *queue); 27 | 28 | extern char *co_module_repr(co_module_t module, co_module_name_t *str); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/colinux/common/module_repr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003-2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #include "messages.h" 11 | 12 | char *co_module_repr(co_module_t module, co_module_name_t *str) 13 | { 14 | switch (module) { 15 | case CO_MODULE_LINUX: co_snprintf((char *)str, sizeof(*str), "linux"); break; 16 | case CO_MODULE_MONITOR: co_snprintf((char *)str, sizeof(*str), "monitor"); break; 17 | case CO_MODULE_DAEMON: co_snprintf((char *)str, sizeof(*str), "daemon"); break; 18 | case CO_MODULE_IDLE: co_snprintf((char *)str, sizeof(*str), "idle"); break; 19 | case CO_MODULE_KERNEL_SWITCH: co_snprintf((char *)str, sizeof(*str), "kernel"); break; 20 | case CO_MODULE_USER_SWITCH: co_snprintf((char *)str, sizeof(*str), "user"); break; 21 | case CO_MODULE_CONSOLE: co_snprintf((char *)str, sizeof(*str), "console"); break; 22 | case CO_MODULE_PRINTK: co_snprintf((char *)str, sizeof(*str), "printk"); break; 23 | case CO_MODULE_CONET0...CO_MODULE_CONET_END - 1: 24 | co_snprintf((char *)str, sizeof(*str), "net%d", module - CO_MODULE_CONET0); 25 | break; 26 | case CO_MODULE_COSCSI0...CO_MODULE_COSCSI_END - 1: 27 | co_snprintf((char *)str, sizeof(*str), "scsi%d", module - CO_MODULE_COSCSI0); 28 | break; 29 | case CO_MODULE_COBD0...CO_MODULE_COBD_END - 1: 30 | co_snprintf((char *)str, sizeof(*str), "cobd%d", module - CO_MODULE_COBD0); 31 | break; 32 | case CO_MODULE_SERIAL0...CO_MODULE_SERIAL_END - 1: 33 | co_snprintf((char *)str, sizeof(*str), "serial%d", module - CO_MODULE_SERIAL0); 34 | break; 35 | default: 36 | co_snprintf((char *)str, sizeof(*str), "unknown<%d>", module); 37 | } 38 | 39 | return (char *)str; 40 | } 41 | -------------------------------------------------------------------------------- /src/colinux/common/unicode.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLINUX_COMMON_UNICODE_H__ 2 | #define __COLINUX_COMMON_UNICODE_H__ 3 | 4 | #include 5 | 6 | typedef unsigned short co_wchar_t; 7 | 8 | extern co_rc_t co_utf8_mbstowcs(co_wchar_t *dest, const char *src, int maxlen); 9 | extern co_rc_t co_utf8_wcstombs(char *dest, const co_wchar_t *src, int maxlen); 10 | 11 | extern co_rc_t co_utf8_dup_to_wc(const char *src, co_wchar_t **wstring, unsigned long *size_out); 12 | extern void co_utf8_free_wc(co_wchar_t *wstring); 13 | 14 | extern int co_utf8_wctowbstrlen(const co_wchar_t *src, int maxlen); 15 | extern int co_utf8_mbstrlen(const char *src); 16 | extern int co_utf8_mcstrlen(co_wchar_t *src); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/common/version.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import os, sys, time 4 | 5 | def main_by_string(input_string): 6 | version = input_string.strip() 7 | output_lines = [] 8 | output_lines.append('#ifndef __COLINUX_VERSION_H__') 9 | output_lines.append('#define __COLINUX_VERSION_H__') 10 | output_lines.append('') 11 | output_lines.append('#define COLINUX_VERSION "%s"' % (version, )) 12 | output_lines.append('#define COLINUX_COMPILE_TIME "%s"' % (time.ctime(), )) 13 | output_lines.append('') 14 | output_lines.append('#endif') 15 | output_lines.append('') 16 | return '\n'.join(output_lines) 17 | 18 | def main_by_params(inputf, outputf): 19 | input_data = open(inputf, 'r').read() 20 | output_data = main_by_string(input_data) 21 | open(outputf, 'w').write(output_data) 22 | 23 | def main_by_strparams(params): 24 | inputf, outputf = params[1:3] 25 | return main_by_params(inputf, outputf) 26 | 27 | def main(): 28 | import sys 29 | return main_by_strparams(sys.argv) 30 | 31 | if __name__ == '__main__': 32 | main() 33 | -------------------------------------------------------------------------------- /src/colinux/kernel/README: -------------------------------------------------------------------------------- 1 | The code in this directory is the OS independent kernel code driver. 2 | 3 | It is responsible for the following: 4 | * Monitor - allocating, maintaining and running the coLinux kernel. 5 | * Manager - manages the running monitors. 6 | -------------------------------------------------------------------------------- /src/colinux/kernel/block.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_KERNEL_BLOCK_H__ 11 | #define __COLINUX_KERNEL_BLOCK_H__ 12 | 13 | #include 14 | 15 | struct co_block_dev; 16 | struct co_monitor; 17 | 18 | typedef struct co_block_dev co_block_dev_t; 19 | 20 | struct co_block_dev { 21 | unsigned long long size; 22 | co_block_dev_desc_t *conf; 23 | co_rc_t (*service)(struct co_monitor *cmon, co_block_dev_t *dev, 24 | co_block_request_t *request); 25 | void (*free)(struct co_monitor *cmon, co_block_dev_t *dev); 26 | unsigned int use_count; 27 | int unit; 28 | } PACKED_STRUCT; 29 | 30 | extern void co_monitor_block_register_device(struct co_monitor *cmon, unsigned int unit, 31 | co_block_dev_t *dev); 32 | extern void co_monitor_block_request(struct co_monitor *cmon, unsigned int unit, 33 | co_block_request_t *request); 34 | extern void co_monitor_block_unregister_device(struct co_monitor *cmon, unsigned int unit); 35 | extern void co_monitor_unregister_and_free_block_devices(struct co_monitor *cmon); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/colinux/kernel/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs = input_list(".c", ".o"), 3 | ) 4 | 5 | targets['Makefile.lib-m'] = Target( 6 | inputs = input_list(".c", ".c"), 7 | tool = MakefileKbuild(), 8 | ) 9 | -------------------------------------------------------------------------------- /src/colinux/kernel/pages.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_KERNEL_MANAGER_PAGES_H__ 11 | #define __COLINUX_KERNEL_MANAGER_PAGES_H__ 12 | 13 | #include "manager.h" 14 | 15 | extern co_rc_t co_manager_get_page(struct co_manager *manager, co_pfn_t *pfn); 16 | extern co_rc_t co_monitor_get_pfn(co_monitor_t *cmon, vm_ptr_t address, co_pfn_t *pfn); 17 | 18 | extern co_rc_t co_monitor_copy_and_create_pfns( 19 | struct co_monitor *monitor, 20 | vm_ptr_t address, 21 | unsigned long size, 22 | char *source 23 | ); 24 | 25 | extern co_rc_t co_monitor_scan_and_create_pfns( 26 | struct co_monitor *monitor, 27 | vm_ptr_t address, 28 | unsigned long size 29 | ); 30 | 31 | extern co_rc_t co_monitor_create_ptes( 32 | struct co_monitor *monitor, 33 | vm_ptr_t address, 34 | unsigned long size, 35 | co_pfn_t *source 36 | ); 37 | 38 | extern co_rc_t co_monitor_copy_region( 39 | struct co_monitor *monitor, 40 | vm_ptr_t address, 41 | unsigned long size, 42 | void *data_to_copy 43 | ); 44 | 45 | extern co_rc_t co_monitor_alloc_and_map_page( 46 | struct co_monitor *monitor, 47 | vm_ptr_t address 48 | ); 49 | 50 | extern co_rc_t co_monitor_free_and_unmap_page( 51 | struct co_monitor *monitor, 52 | vm_ptr_t address 53 | ); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/colinux/kernel/pci.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CO_KERNEL_PCI_H__ 3 | #define __CO_KERNEL_PCI_H__ 4 | 5 | /* 6 | * This source code is a part of coLinux source package. 7 | * 8 | * Copyright (C) 2008 Steve Shoecraft 9 | * 10 | * The code is licensed under the GPL. See the COPYING file in 11 | * the root directory. 12 | * 13 | */ 14 | 15 | extern co_rc_t co_pci_setconfig(co_monitor_t *); 16 | extern void co_pci_request(co_monitor_t *, int); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/kernel/reversedpfns.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_KERNEL_REVERSEDPFNS_H__ 11 | #define __COLINUX_KERNEL_REVERSEDPFNS_H__ 12 | 13 | #include 14 | 15 | extern co_rc_t co_manager_set_reversed_pfn(co_manager_t *manager, co_pfn_t real_pfn, co_pfn_t pseudo_pfn); 16 | extern void co_manager_free_reversed_pfns(co_manager_t *manager); 17 | extern co_rc_t co_manager_alloc_reversed_pfns(co_manager_t *manager); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/colinux/kernel/scsi.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __COLINUX_KERNEL_SCSI_H__ 3 | #define __COLINUX_KERNEL_SCSI_H__ 4 | 5 | /* 6 | * This source code is a part of coLinux source package. 7 | * 8 | * Copyright (C) 2008 Steve Shoecraft 9 | * 10 | * The code is licensed under the GPL. See the COPYING file in 11 | * the root directory. 12 | * 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | #include "monitor.h" 19 | 20 | struct co_scsi_dev; 21 | typedef struct co_scsi_dev co_scsi_dev_t; 22 | 23 | /* Driver */ 24 | struct co_scsi_dev { 25 | int unit; 26 | co_scsi_dev_desc_t *conf; 27 | void *os_handle; 28 | }; 29 | 30 | extern co_rc_t co_monitor_scsi_dev_init(co_scsi_dev_t *dev, int unit, co_scsi_dev_desc_t *conf); 31 | extern void co_monitor_scsi_register_device(struct co_monitor *cmon, unsigned int unit, co_scsi_dev_t *dev); 32 | extern void co_monitor_unregister_and_free_scsi_devices(struct co_monitor *cmon); 33 | extern void co_scsi_request(co_monitor_t *, int op, int unit); 34 | 35 | /* O/S interface */ 36 | extern int scsi_file_open(co_monitor_t *, co_scsi_dev_t *); 37 | extern int scsi_file_close(co_monitor_t *, co_scsi_dev_t *); 38 | extern int scsi_file_io(co_monitor_t *, co_scsi_dev_t *, co_scsi_io_t *); 39 | extern int scsi_file_size(co_monitor_t *, co_scsi_dev_t *,unsigned long long *); 40 | extern int scsi_pass(co_monitor_t *, co_scsi_dev_t *, co_scsi_pass_t *); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /src/colinux/kernel/video.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CO_KERNEL_VIDEO_H__ 3 | #define __CO_KERNEL_VIDEO_H__ 4 | 5 | /* 6 | * This source code is a part of coLinux source package. 7 | * 8 | * Copyright (C) 2008 Steve Shoecraft 9 | * 10 | * The code is licensed under the GPL. See the COPYING file in 11 | * the root directory. 12 | * 13 | */ 14 | 15 | #ifdef CONFIG_COOPERATIVE_VIDEO 16 | struct co_video_dev { 17 | int unit; 18 | int size; /* Size */ 19 | void *buffer; /* Page-aligned buffer */ 20 | int x,y,bpp; /* Current mode */ 21 | }; 22 | 23 | typedef struct co_video_dev co_video_dev_t; 24 | 25 | extern void co_video_request(co_monitor_t *, int, int); 26 | extern int co_monitor_video_device_init(co_monitor_t *, int, co_video_dev_desc_t *); 27 | extern void co_monitor_unregister_video_devices(co_monitor_t *); 28 | extern co_rc_t co_video_attach(co_monitor_t *, co_monitor_ioctl_video_t *); 29 | extern co_rc_t co_video_detach(co_monitor_t *, co_monitor_ioctl_video_t *); 30 | #endif /* CONFIG_COOPERATIVE_VIDEO */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/colinux/os/README: -------------------------------------------------------------------------------- 1 | This directory contains the host OS dependant code. 2 | 3 | The OS independant headers of the OS dependent code are under 4 | the user and kernel subdirectories (for userspace and kernel space). 5 | Common headers (for both userspace and kernel space) are in this 6 | directory. 7 | 8 | For every supported operating system, there is one directory 9 | that contains all its dependent code. The 'current' symlink points 10 | to the currently selected operating system for the build. -------------------------------------------------------------------------------- /src/colinux/os/alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_ALLOC_H__ 12 | #define __CO_OS_ALLOC_H__ 13 | 14 | extern void *co_os_malloc(unsigned long bytes); 15 | extern void *co_os_realloc(void *ptr, unsigned long size); 16 | extern void co_os_free(void *ptr); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_KERNEL_ALLOC_H__ 12 | #define __CO_OS_KERNEL_ALLOC_H__ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | /* 19 | * Interfaces for physical memory allocation. 20 | */ 21 | extern co_rc_t co_os_get_page(struct co_manager *manager, co_pfn_t *pfn); 22 | extern void *co_os_map(struct co_manager *manager, co_pfn_t pfn); 23 | extern void co_os_unmap(struct co_manager *manager, void *ptr, co_pfn_t pfn); 24 | extern void co_os_put_page(struct co_manager *manager, co_pfn_t pfn); 25 | extern void *co_os_alloc_pages(unsigned int pages); 26 | extern void co_os_free_pages(void *ptr, unsigned int pages); 27 | 28 | /* 29 | * Interfaces for mapping physical memory in userspace. 30 | */ 31 | extern co_rc_t co_os_userspace_map(void *address, unsigned int pages, void **user_address, void **handle); 32 | extern void co_os_userspace_unmap(void *user_address, void *handle, unsigned int pages); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_OS_KERNEL_MANAGER_H__ 11 | #define __COLINUX_OS_KERNEL_MANAGER_H__ 12 | 13 | #include 14 | 15 | extern co_rc_t co_os_manager_init(co_manager_t *manager, co_osdep_manager_t *osdep); 16 | extern void co_os_manager_free(co_osdep_manager_t osdep); 17 | 18 | extern co_rc_t co_os_manager_init(co_manager_t *manager, co_osdep_manager_t *osdep); 19 | extern void co_os_manager_free(co_osdep_manager_t osdep); 20 | 21 | extern co_rc_t co_os_manager_userspace_open(co_manager_open_desc_t opened); 22 | extern void co_os_manager_userspace_close(co_manager_open_desc_t opened); 23 | 24 | extern bool_t co_os_manager_userspace_try_send_direct( 25 | co_manager_t *manager, 26 | co_manager_open_desc_t opened, 27 | co_message_t *message); 28 | 29 | extern co_rc_t co_os_manager_userspace_eof( 30 | co_manager_t *manager, 31 | co_manager_open_desc_t opened); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_KERNEL_MISC_H__ 12 | #define __CO_OS_KERNEL_MISC_H__ 13 | 14 | #include 15 | 16 | extern unsigned long co_os_virt_to_phys(void *addr); 17 | extern co_rc_t co_os_physical_memory_pages(unsigned long *pages); 18 | extern co_id_t co_os_current_id(void); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/monitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_KERNEL_MONITOR_H__ 12 | #define __COLINUX_OS_KERNEL_MONITOR_H__ 13 | 14 | #include 15 | #include 16 | 17 | extern void co_monitor_os_console_poll(co_monitor_t *cmon); 18 | extern void co_monitor_os_console_event(co_monitor_t *cmon); 19 | 20 | extern void co_monitor_os_network_poll(co_monitor_t *cmon); 21 | extern void co_monitor_os_network_event(co_monitor_t *cmon); 22 | 23 | extern void co_monitor_os_clear_console_detach_event(co_monitor_t *cmon); 24 | extern void co_monitor_os_set_console_detach_event(co_monitor_t *cmon); 25 | extern void co_monitor_os_wait_console_detach(co_monitor_t *cmon); 26 | 27 | extern void co_monitor_os_idle(co_monitor_t *cmon); 28 | extern void co_monitor_os_wakeup(co_monitor_t *cmon); 29 | 30 | extern co_rc_t co_monitor_os_init(co_monitor_t *cmon); 31 | extern void co_monitor_os_exit(co_monitor_t *cmon); 32 | 33 | extern void co_monitor_os_exclusive(co_monitor_t *cmon); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_KERNEL_MUTEX_H__ 12 | #define __CO_OS_KERNEL_MUTEX_H__ 13 | 14 | #include 15 | 16 | typedef struct co_os_mutex *co_os_mutex_t; 17 | 18 | extern co_rc_t co_os_mutex_create(co_os_mutex_t *mutex_out); 19 | extern void co_os_mutex_acquire(co_os_mutex_t mutex); 20 | extern void co_os_mutex_acquire_critical(co_os_mutex_t mutex); 21 | extern void co_os_mutex_release(co_os_mutex_t mutex); 22 | extern void co_os_mutex_release_critical(co_os_mutex_t mutex); 23 | extern void co_os_mutex_destroy(co_os_mutex_t mutex); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_KERNEL_TIME_H__ 12 | #define __CO_OS_KERNEL_TIME_H__ 13 | 14 | /* 15 | * Obtains the GMT time_t from the host. 16 | */ 17 | 18 | extern unsigned long co_os_get_time(void); 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/user.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_KERNEL_USER_H__ 12 | #define __CO_OS_KERNEL_USER_H__ 13 | 14 | #include 15 | 16 | /* 17 | * Userspace access routines. 18 | */ 19 | 20 | co_rc_t co_copy_to_user(char *user_address, char *kernel_address, unsigned long size); 21 | co_rc_t co_copy_from_user(char *user_address, char *kernel_address, unsigned long size); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/colinux/os/kernel/wait.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_KERNEL_WAIT_H__ 12 | #define __CO_OS_KERNEL_WAIT_H__ 13 | 14 | #include 15 | 16 | /* 17 | * Wait channels. 18 | */ 19 | 20 | typedef struct co_os_wait *co_os_wait_t; 21 | 22 | extern co_rc_t co_os_wait_create(co_os_wait_t *wait_out); 23 | extern void co_os_wait_sleep(co_os_wait_t wait); 24 | extern void co_os_wait_wakeup(co_os_wait_t wait); 25 | extern void co_os_wait_destroy(co_os_wait_t wait); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/colinux/os/linux/ioctl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_LINUX_IOCTL_H__ 12 | #define __CO_LINUX_IOCTL_H__ 13 | 14 | typedef struct co_linux_io { 15 | unsigned long code; 16 | void* input_buffer; 17 | unsigned long input_buffer_size; 18 | void* output_buffer; 19 | unsigned long output_buffer_size; 20 | unsigned long* output_returned; 21 | } co_linux_io_t; 22 | 23 | #define CO_LINUX_IOCTL_ID 0x12340000 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/core.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | COLINUX_DEFINE_MODULE("colinux-driver"); 16 | 17 | co_rc_t co_monitor_os_init(co_monitor_t *cmon) 18 | { 19 | co_rc_t rc = CO_RC_OK; 20 | 21 | cmon->osdep = NULL; 22 | 23 | return rc; 24 | } 25 | 26 | void co_monitor_os_exit(co_monitor_t *cmon) 27 | { 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for the coLinux Linux kernel module. 3 | # 4 | 5 | MODULE_NAME = colinux 6 | 7 | # Softlinks avoids problems with userland builds 8 | obj-y += .module.arch_build/ 9 | obj-y += .module.common_build/ 10 | obj-y += .module.kernel_build/ 11 | 12 | obj-m := $(MODULE_NAME).o 13 | 14 | include $(KBUILD_EXTMOD)/Makefile.$(MODULE_NAME)-objs 15 | 16 | $(MODULE_NAME)-objs += \ 17 | .module.arch_build/lib.a \ 18 | .module.common_build/lib.a \ 19 | .module.kernel_build/lib.a \ 20 | 21 | # Solve circular references between archives 22 | EXTRA_LDFLAGS += --start-group 23 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/Makefile.include: -------------------------------------------------------------------------------- 1 | # Include for all host kernel module builds 2 | 3 | ifeq ($(COLINUX_TARGET_KERNEL_BUILD),) 4 | COLINUX_TARGET_KERNEL_BUILD := $(COLINUX_TARGET_KERNEL_PATH) 5 | endif 6 | 7 | EXTRA_CFLAGS += -DCO_KERNEL -DCO_HOST_KERNEL \ 8 | -I$(COLINUX_BASE)/src \ 9 | -I$(COLINUX_TARGET_KERNEL_BUILD)/include \ 10 | -I$(COLINUX_TARGET_KERNEL_BUILD)/arch/x86/include \ 11 | $(if $(COLINUX_TARGET_KERNEL_SOURCE), \ 12 | -I$(COLINUX_TARGET_KERNEL_BUILD)/include2 \ 13 | -I$(COLINUX_TARGET_KERNEL_SOURCE)/include \ 14 | -I$(COLINUX_TARGET_KERNEL_SOURCE)/arch/x86/include) 15 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/colinux.c: -------------------------------------------------------------------------------- 1 | #include "linux_inc.h" 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/conet.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * The code is licensed under the GPL. See the COPYING file at 5 | * the root directory. 6 | * 7 | */ 8 | 9 | #include 10 | 11 | co_rc_t co_conet_bind_adapter(co_monitor_t *monitor, int conet_unit, char *netcfg_id, int promisc, char macaddr[6]) 12 | { 13 | return CO_RC(ERROR); 14 | } 15 | 16 | co_rc_t co_conet_unbind_adapter(co_monitor_t *monitor, int conet_unit) 17 | { 18 | return CO_RC(ERROR); 19 | } 20 | 21 | co_rc_t co_conet_inject_packet_to_adapter(co_monitor_t *monitor, int conet_unit, void *packet_data, int length) 22 | { 23 | return CO_RC(ERROR); 24 | } 25 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | #include "manager.h" 13 | #include 14 | 15 | static int debug_misc; 16 | module_param(debug_misc, int, 0); 17 | MODULE_PARM_DESC(debug_misc, "Debug level for misc"); 18 | 19 | void co_debug_startup(void) 20 | { 21 | co_global_debug_levels.misc_level = debug_misc; 22 | if (debug_misc) 23 | printk(KERN_INFO "coLinux: debug_misc %d\n", debug_misc); 24 | } 25 | 26 | void co_debug_system(const char *fmt, ...) 27 | { 28 | char buf[0x100]; 29 | va_list ap; 30 | 31 | va_start(ap, fmt); 32 | co_vsnprintf(buf, sizeof(buf), fmt, ap); 33 | printk(KERN_INFO "%s\n", buf); 34 | va_end(ap); 35 | } 36 | 37 | void co_debug_level_system(const char *module, co_debug_facility_t facility, int level, 38 | const char *filename, int line, const char *func, const char *text) 39 | { 40 | const char *fname; 41 | 42 | /* Strip full path from name */ 43 | fname = strrchr(filename, '/'); 44 | if (fname) { 45 | for (fname = fname-1; 46 | fname > filename && *fname != '.' && *fname != '/'; 47 | fname--) 48 | ; 49 | fname++; 50 | } else 51 | fname = filename; 52 | 53 | /* Debug output to Kernel log */ 54 | printk(KERN_INFO "[m:%s f:%d l:%d %s:%d:%s] %s\n", module, facility, level, fname, line, func, text); 55 | } 56 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/linux_inc.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) 4 | #include 5 | #endif 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) 21 | #include 22 | #else 23 | #include 24 | #endif 25 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | 13 | #include 14 | 15 | #include "manager.h" 16 | 17 | static int __init colinux_module_init(void) 18 | { 19 | co_rc_t rc; 20 | 21 | printk(KERN_INFO "colinux: loaded version " COLINUX_VERSION " (compiled on " __DATE__ " " __TIME__ ")\n"); 22 | 23 | co_global_manager = co_os_malloc(sizeof(co_manager_t)); 24 | if (co_global_manager == NULL) { 25 | printk(KERN_ERR "colinux: allocation error\n"); 26 | return -ENOMEM; 27 | } 28 | 29 | rc = co_manager_load(co_global_manager); 30 | if (!CO_OK(rc)) { 31 | if (CO_RC_GET_CODE(rc) == CO_RC_PAE_ENABLED) { 32 | printk("colinux: PAE is enabled, cannot continue\n"); 33 | return -ENOSYS; 34 | } 35 | printk(KERN_ERR "colinux: manager load failure: %x\n", (int)rc); 36 | return -ENXIO; 37 | } 38 | 39 | return 0; 40 | } 41 | 42 | static void __exit colinux_module_exit(void) 43 | { 44 | if (co_global_manager != NULL) { 45 | co_manager_t *manager = co_global_manager; 46 | co_manager_unload(manager); 47 | co_global_manager = NULL; 48 | co_os_free(manager); 49 | } 50 | 51 | printk(KERN_INFO "colinux: module unloaded\n"); 52 | } 53 | 54 | MODULE_LICENSE("GPL"); 55 | module_init(colinux_module_init); 56 | module_exit(colinux_module_exit); 57 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_LINUX_KERNEL_MANAGER_H__ 12 | #define __CO_LINUX_KERNEL_MANAGER_H__ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | struct co_osdep_manager { 21 | struct proc_dir_entry *proc_root; 22 | struct proc_dir_entry *proc_ioctl; 23 | }; 24 | 25 | extern co_manager_t *global_manager; 26 | 27 | struct co_manager_open_desc_os { 28 | wait_queue_head_t waitq; 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/misc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | #include 13 | #include 14 | 15 | unsigned long co_os_virt_to_phys(void *addr) 16 | { 17 | return virt_to_phys(addr); 18 | } 19 | 20 | co_rc_t co_os_physical_memory_pages(unsigned long *pages) 21 | { 22 | *pages = num_physpages; 23 | 24 | /* 25 | * Round to 16 MB boundars, since Linux doesn't return the 26 | * exact amount but a bit lower. 27 | */ 28 | *pages = ~0xfff & ((*pages) + 0xfff); 29 | 30 | return CO_RC(OK); 31 | } 32 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/mutex.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | 13 | #include 14 | #include 15 | 16 | struct co_os_mutex { 17 | struct semaphore sem; 18 | }; 19 | 20 | co_rc_t co_os_mutex_create(co_os_mutex_t *mutex_out) 21 | { 22 | co_os_mutex_t mutex; 23 | 24 | *mutex_out = NULL; 25 | 26 | mutex = co_os_malloc(sizeof(*mutex)); 27 | 28 | if (mutex == NULL) 29 | return CO_RC(OUT_OF_MEMORY); 30 | 31 | init_MUTEX(&mutex->sem); 32 | 33 | *mutex_out = mutex; 34 | 35 | return CO_RC(OK); 36 | } 37 | 38 | void co_os_mutex_acquire(co_os_mutex_t mutex) 39 | { 40 | down(&mutex->sem); 41 | } 42 | 43 | void co_os_mutex_acquire_critical(co_os_mutex_t mutex) 44 | { 45 | co_os_mutex_acquire(mutex); 46 | } 47 | 48 | void co_os_mutex_release(co_os_mutex_t mutex) 49 | { 50 | up(&mutex->sem); 51 | } 52 | 53 | void co_os_mutex_release_critical(co_os_mutex_t mutex) 54 | { 55 | co_os_mutex_release(mutex); 56 | } 57 | 58 | void co_os_mutex_destroy(co_os_mutex_t mutex) 59 | { 60 | if (mutex != NULL) 61 | co_os_free(mutex); 62 | } 63 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/pages.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | 13 | #include 14 | 15 | /* 16 | * Interfaces for physical memory allocation. 17 | */ 18 | co_rc_t co_os_get_page(struct co_manager *manager, co_pfn_t *pfn) 19 | { 20 | struct page *page; 21 | 22 | /* alloc and zero the page */ 23 | page = alloc_pages(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO, 0); 24 | if (!page) 25 | return CO_RC(ERROR); 26 | 27 | *pfn = page_to_pfn(page); 28 | 29 | return CO_RC(OK); 30 | } 31 | 32 | void *co_os_map(struct co_manager *manager, co_pfn_t pfn) 33 | { 34 | return kmap(pfn_to_page(pfn)); 35 | } 36 | 37 | void co_os_unmap(struct co_manager *manager, void *ptr, co_pfn_t pfn) 38 | { 39 | kunmap(pfn_to_page(pfn)); 40 | } 41 | 42 | void co_os_put_page(struct co_manager *manager, co_pfn_t pfn) 43 | { 44 | __free_page(pfn_to_page(pfn)); 45 | } 46 | 47 | void *co_os_alloc_pages(unsigned int pages) 48 | { 49 | return (void *)__get_free_pages(GFP_KERNEL, get_order(pages << PAGE_SHIFT)); 50 | } 51 | 52 | void co_os_free_pages(void *ptr, unsigned int pages) 53 | { 54 | free_pages((unsigned long)ptr, get_order(pages << PAGE_SHIFT)); 55 | } 56 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/scsi.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * The code is licensed under the GPL. See the COPYING file at 5 | * the root directory. 6 | * 7 | */ 8 | 9 | #include 10 | 11 | int scsi_file_open(co_monitor_t *cmon, co_scsi_dev_t *dp) 12 | { 13 | return CO_RC(ERROR); 14 | } 15 | 16 | int scsi_file_close(co_monitor_t *cmon, co_scsi_dev_t *dp) 17 | { 18 | return CO_RC(ERROR); 19 | } 20 | 21 | int scsi_file_io(co_monitor_t *cmon, co_scsi_dev_t *dp, co_scsi_io_t *iop) 22 | { 23 | return CO_RC(ERROR); 24 | } 25 | 26 | int scsi_file_size(co_monitor_t *cmon, co_scsi_dev_t *dp, unsigned long long *size) 27 | { 28 | return CO_RC(ERROR); 29 | } 30 | 31 | int scsi_pass(co_monitor_t *cmon, co_scsi_dev_t *dp, co_scsi_pass_t *pass) 32 | { 33 | return CO_RC(ERROR); 34 | } 35 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | unsigned long co_os_get_time(void) 18 | { 19 | return get_seconds(); 20 | } 21 | 22 | void co_os_get_timestamp(co_timestamp_t *dts) 23 | { 24 | struct timeval tv; 25 | 26 | do_gettimeofday(&tv); 27 | 28 | dts->quad = tv.tv_sec; 29 | dts->quad *= 1000000; 30 | dts->quad += tv.tv_usec; 31 | } 32 | 33 | void co_os_get_timestamp_freq(co_timestamp_t *dts, co_timestamp_t *freq) 34 | { 35 | co_os_get_timestamp(dts); 36 | if (freq) 37 | freq->quad = 1000000; 38 | } 39 | 40 | unsigned long co_os_get_cpu_khz(void) 41 | { 42 | return cpu_khz; 43 | } 44 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/timer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | 13 | #include 14 | #include 15 | 16 | struct co_os_timer { 17 | struct timer_list timer; 18 | long msec; 19 | co_os_func_t func; 20 | void *data; 21 | }; 22 | 23 | static void os_timer(unsigned long data) 24 | { 25 | struct co_os_timer *t = (struct co_os_timer *)data; 26 | t->func(t->data); 27 | t->timer.expires = jiffies + (t->msec+HZ-1)/HZ; 28 | add_timer((struct timer_list *)&t->timer); 29 | } 30 | 31 | co_rc_t co_os_timer_create(co_os_func_t func, void *data, 32 | long msec, co_os_timer_t *timer_out) 33 | { 34 | struct co_os_timer *t; 35 | 36 | t = co_os_malloc(sizeof(*t)); 37 | if (!t) 38 | return CO_RC(OUT_OF_MEMORY); 39 | 40 | init_timer(&t->timer); 41 | 42 | t->timer.data = (unsigned long)t; 43 | t->timer.expires = jiffies + (msec+HZ-1)/HZ; 44 | t->timer.function = os_timer; 45 | t->msec = msec; 46 | t->func = func; 47 | t->data = data; 48 | 49 | *timer_out = (co_os_timer_t)t; 50 | 51 | return CO_RC(OK); 52 | } 53 | 54 | co_rc_t co_os_timer_activate(co_os_timer_t timer) 55 | { 56 | add_timer((struct timer_list *)timer); 57 | return CO_RC(OK); 58 | } 59 | 60 | void co_os_timer_deactivate(co_os_timer_t timer) 61 | { 62 | del_timer((struct timer_list *)timer); 63 | } 64 | 65 | void co_os_timer_destroy(co_os_timer_t timer) 66 | { 67 | co_os_free((struct timer_list *)timer); 68 | } 69 | 70 | void co_os_msleep(unsigned int msecs) 71 | { 72 | msleep(msecs); 73 | } 74 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/user.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | 13 | #include 14 | 15 | co_rc_t co_copy_to_user(char *user_address, char *kernel_address, unsigned long size) 16 | { 17 | int ret; 18 | 19 | ret = copy_to_user(user_address, kernel_address, size); 20 | if (ret) 21 | return CO_RC(ERROR); 22 | 23 | return CO_RC(OK);; 24 | } 25 | 26 | co_rc_t co_copy_from_user(char *user_address, char *kernel_address, unsigned long size) 27 | { 28 | int ret; 29 | 30 | ret = copy_from_user(user_address, kernel_address, size); 31 | if (ret) 32 | return CO_RC(ERROR); 33 | 34 | return CO_RC(OK);; 35 | } 36 | -------------------------------------------------------------------------------- /src/colinux/os/linux/kernel/module/wait.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "linux_inc.h" 12 | 13 | #include 14 | #include 15 | 16 | struct co_os_wait { 17 | wait_queue_head_t head; 18 | }; 19 | 20 | co_rc_t co_os_wait_create(co_os_wait_t *wait_out) 21 | { 22 | co_os_wait_t wait; 23 | 24 | *wait_out = NULL; 25 | 26 | wait = co_os_malloc(sizeof(*wait)); 27 | 28 | if (wait == NULL) 29 | return CO_RC(OUT_OF_MEMORY); 30 | 31 | init_waitqueue_head(&wait->head); 32 | 33 | *wait_out = wait; 34 | 35 | return CO_RC(OK); 36 | } 37 | 38 | void co_os_wait_sleep(co_os_wait_t wait) 39 | { 40 | DEFINE_WAIT(wait_one); 41 | 42 | prepare_to_wait(&wait->head, &wait_one, TASK_INTERRUPTIBLE); 43 | schedule(); 44 | finish_wait(&wait->head, &wait_one); 45 | } 46 | 47 | void co_os_wait_wakeup(co_os_wait_t wait) 48 | { 49 | wake_up_interruptible_all(&wait->head); 50 | } 51 | 52 | void co_os_wait_destroy(co_os_wait_t wait) 53 | { 54 | if (wait != NULL) 55 | co_os_free(wait); 56 | } 57 | -------------------------------------------------------------------------------- /src/colinux/os/linux/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLINUX_OS_LINUX_MEMORY_H__ 2 | #define __COLINUX_OS_LINUX_MEMORY_H__ 3 | 4 | #ifdef __KERNEL__ 5 | # include "colinux/os/linux/kernel/module/linux_inc.h" 6 | #else 7 | # include 8 | #endif 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/alloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | /* Linux host: allocate memory in linux user space */ 12 | 13 | #include 14 | 15 | #include 16 | 17 | void * 18 | co_os_malloc(unsigned long size) 19 | { 20 | return malloc(size); 21 | } 22 | 23 | void * 24 | co_os_realloc(void *ptr, unsigned long size) 25 | { 26 | return realloc(ptr, size); 27 | } 28 | 29 | void 30 | co_os_free(void *ptr) 31 | { 32 | free(ptr); 33 | } 34 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['user-all.a'] = Target( 2 | inputs=[ 3 | Input("user-osdep.a"), 4 | Input("../../../user.a"), 5 | ] 6 | ) 7 | 8 | targets['user-osdep.a'] = Target( 9 | inputs=input_list(".c", ".o"), 10 | ) 11 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/cobdpath.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | co_rc_t co_canonize_cobd_path(co_pathname_t *pathname) 15 | { 16 | return CO_RC(OK); 17 | } 18 | 19 | co_rc_t co_dirname (char *path) 20 | { 21 | dirname(path); 22 | 23 | return CO_RC(OK); 24 | } 25 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/conet-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | # Strip out guest kernel include paths for tap.c builds 2 | targets['tap.o'] = Target( 3 | inputs = [Input('tap.c')], 4 | tool = Compiler(), 5 | mono_options = Options( 6 | overriders = dict( 7 | compiler_includes = [] 8 | ) 9 | ) 10 | ) 11 | 12 | targets['build.o'] = Target( 13 | inputs=[ 14 | Input('daemon.o'), 15 | Input('tap.o') 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/conet-daemon/daemon.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLINUX_LINUX_USER_CONET_DAEMON_DAEMON_H__ 2 | #define __COLINUX_LINUX_USER_CONET_DAEMON_DAEMON_H__ 3 | 4 | #include 5 | 6 | extern "C" { 7 | #include 8 | #include 9 | } 10 | 11 | class user_network_tap_daemon_t : public user_daemon_t { 12 | public: 13 | user_network_tap_daemon_t(); 14 | virtual ~user_network_tap_daemon_t(); 15 | virtual co_module_t get_base_module(); 16 | virtual unsigned int get_unit_count(); 17 | virtual const char *get_daemon_name(); 18 | virtual const char *get_daemon_title(); 19 | virtual void received_from_monitor(co_message_t *message); 20 | virtual void received_from_tap(unsigned char *buffer, unsigned long size); 21 | virtual void handle_extended_parameters(co_command_line_params_t cmdline); 22 | virtual void prepare_for_loop(); 23 | virtual void syntax(); 24 | 25 | protected: 26 | bool_t tap_name_specified; 27 | char tap_name[0x30]; 28 | co_linux_reactor_packet_user_t tap_handle; 29 | }; 30 | 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/conet-daemon/tap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2005 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | #include "tap.h" 19 | 20 | int tap_set_name(int fd, char *dev) 21 | { 22 | struct ifreq ifr; 23 | int err; 24 | 25 | memset(&ifr, 0, sizeof(ifr)); 26 | 27 | ifr.ifr_flags = IFF_TAP | IFF_NO_PI; 28 | strncpy(ifr.ifr_name, dev, IFNAMSIZ); 29 | 30 | if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) 31 | return err; 32 | 33 | strncpy(dev, ifr.ifr_name, IFNAMSIZ); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/conet-daemon/tap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2005 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_LINUX_USER_CONET_DAEMON_TAP_H__ 12 | #define __COLINUX_LINUX_USER_CONET_DAEMON_TAP_H__ 13 | 14 | extern int tap_set_name(int fd, char *dev); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/conet-slirp-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/conet-slirp-daemon/main.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * This source code is a part of coLinux source package. 4 | * 5 | * Dan Aloni , 2004 (c) 6 | * 7 | * The code is licensed under the GPL. See the COPYING file at 8 | * the root directory. 9 | * 10 | */ 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | COLINUX_DEFINE_MODULE("colinux-slirp-net-daemon"); 19 | 20 | static pthread_mutex_t slirp_mutex; 21 | 22 | co_rc_t co_slirp_mutex_init (void) 23 | { 24 | if (pthread_mutex_init(&slirp_mutex, NULL)) { 25 | co_terminal_print("conet-slirp-daemon: Mutex creating failed\n"); 26 | return CO_RC(ERROR); 27 | } 28 | return CO_RC(OK); 29 | } 30 | 31 | void co_slirp_mutex_destroy (void) 32 | { 33 | pthread_mutex_destroy(&slirp_mutex); 34 | } 35 | 36 | void co_slirp_mutex_lock (void) 37 | { 38 | pthread_mutex_lock(&slirp_mutex); 39 | } 40 | 41 | void co_slirp_mutex_unlock (void) 42 | { 43 | pthread_mutex_unlock(&slirp_mutex); 44 | } 45 | 46 | int main(int argc, char *argv[]) 47 | { 48 | co_rc_t rc; 49 | 50 | rc = co_slirp_main(argc, argv); 51 | if (CO_OK(rc)) 52 | return 0; 53 | 54 | return -1; 55 | } 56 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/console-fltk/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('head.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/coserial-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['daemon.o'] = Target( 2 | inputs = input_list(".c", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/daemon/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | void co_daemon_trace_point(co_trace_point_info_t *info) 22 | { 23 | #ifdef COLINUX_DEBUG 24 | /* 25 | * This code sends UDP packet per debug line. 26 | * 27 | * Proves useful for investigating hard crashes. 28 | * 29 | * Make sure you have a fast Ethernet. 30 | */ 31 | 32 | static int sock = -1; /* We only need one global socket */ 33 | if (sock == -1) { 34 | struct sockaddr_in server; 35 | int ret; 36 | sock = socket(AF_INET, SOCK_DGRAM, 0); 37 | 38 | co_bzero((char *) &server, sizeof(server)); 39 | server.sin_family = AF_INET; 40 | 41 | /* 42 | * Hardcoded for the meanwhile. 43 | * 44 | * If someone actually uses this, please send a patch 45 | * to make this more configurable. 46 | */ 47 | server.sin_addr.s_addr = inet_addr("192.168.1.1"); 48 | server.sin_port = htons(5555); 49 | 50 | ret = connect(sock, (struct sockaddr *)&server, sizeof(server)); 51 | } 52 | 53 | send(sock, info, sizeof(*info), 0); 54 | #endif 55 | } 56 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/daemon/registry.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * The code is licensed under the GPL. See the COPYING file at 5 | * the root directory. 6 | * 7 | */ 8 | 9 | #include 10 | #include 11 | 12 | co_rc_t co_config_user_string_read(int monitor_index, const char *device_name, int device_index, const char *value_name, char *value, int size) 13 | { 14 | return CO_RC(ERROR); 15 | } 16 | 17 | co_rc_t co_config_user_string_write(int monitor_index, const char *device_name, int device_index, const char *value_name, const char *value) 18 | { 19 | return CO_RC(ERROR); 20 | } 21 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/debug/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/debug/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | COLINUX_DEFINE_MODULE("colinux-debug-daemon"); 21 | 22 | int main(int argc, char *argv[]) 23 | { 24 | co_rc_t rc; 25 | 26 | rc = co_debug_main(argc, argv); 27 | 28 | if (!CO_OK(rc)) { 29 | if (geteuid() != 0) 30 | printf ("Please run as root\n"); 31 | return -1; 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/exec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | co_rc_t co_launch_process(int *pid, char *command_line, ...) 20 | { 21 | char buf[0x100]; 22 | char buf2[0x100]; 23 | va_list ap; 24 | int ret; 25 | 26 | va_start(ap, command_line); 27 | co_vsnprintf(buf, sizeof(buf), command_line, ap); 28 | va_end(ap); 29 | 30 | snprintf(buf2, sizeof(buf2), "%s &", buf); 31 | 32 | co_debug("executing: %s", buf2); 33 | ret = system(buf2); 34 | 35 | if (ret == -1) { 36 | co_terminal_print("error in execution '%s' (%d)\n", buf2, errno); 37 | return CO_RC(ERROR); 38 | } 39 | 40 | 41 | if (pid) 42 | *pid = 0; /* dummy */ 43 | 44 | return CO_RC(OK); 45 | } 46 | 47 | co_rc_t co_kill_process(int pid) 48 | { 49 | return CO_RC(OK); 50 | } 51 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/file-unlink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Henry Nestler, 2007 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | 13 | #include 14 | 15 | co_rc_t co_os_file_unlink(co_pathname_t pathname) 16 | { 17 | if (unlink((char *)pathname) != 0) 18 | return CO_RC(ERROR); 19 | 20 | return CO_RC(OK); 21 | } 22 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/file-write.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Henry Nestler, 2007 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | co_rc_t co_os_file_write(co_pathname_t pathname, void *buf, unsigned long size) 18 | { 19 | int fd, wr; 20 | 21 | fd = open((char *)pathname, O_WRONLY | O_CREAT | O_TRUNC, 22 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); 23 | if (fd == -1) 24 | return CO_RC(ERROR); 25 | 26 | wr = write(fd, buf, size); 27 | close(fd); 28 | 29 | if (wr != size) 30 | return CO_RC(ERROR); 31 | 32 | return CO_RC(OK); 33 | } 34 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/file.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | co_rc_t co_os_file_load(co_pathname_t pathname, char **out_buf, unsigned long *out_size, unsigned long max_size) 21 | { 22 | int fd, ret; 23 | char *buf; 24 | struct stat st; 25 | 26 | fd = open((char *)pathname, O_RDONLY); 27 | if (fd == -1) 28 | return CO_RC(ERROR); 29 | 30 | ret = fstat(fd, &st); 31 | if (ret == -1) { 32 | close(fd); 33 | return CO_RC(ERROR); 34 | } 35 | 36 | if (max_size && st.st_size > max_size) 37 | st.st_size = max_size; 38 | 39 | buf = (char *)malloc(st.st_size); 40 | if (buf == NULL) { 41 | close(fd); 42 | return CO_RC(OUT_OF_MEMORY); 43 | } 44 | 45 | if (read(fd, buf, st.st_size) != st.st_size) { 46 | free(buf); 47 | close(fd); 48 | return CO_RC(ERROR); 49 | } 50 | 51 | *out_buf = buf; 52 | *out_size = st.st_size; 53 | 54 | close(fd); 55 | return CO_RC(OK); 56 | } 57 | 58 | void co_os_file_free(char *buf) 59 | { 60 | free(buf); 61 | } 62 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/process.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Henry Nestler, 2007 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | 13 | void co_process_high_priority_set(void) 14 | { 15 | /* nothing */ 16 | } 17 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/reactor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_LINUX_USER_REACTOR_H__ 12 | #define __COLINUX_LINUX_USER_REACTOR_H__ 13 | 14 | #include 15 | 16 | struct co_reactor_os_user { 17 | int fd; 18 | 19 | co_rc_t (*read)(co_reactor_user_t user); 20 | void (*write)(co_reactor_user_t user); 21 | }; 22 | 23 | struct co_linux_reactor_packet_user { 24 | struct co_reactor_user user; 25 | struct co_reactor_os_user os_user; 26 | 27 | unsigned char buffer[0x10000]; 28 | unsigned long size; 29 | }; 30 | 31 | typedef struct co_linux_reactor_packet_user *co_linux_reactor_packet_user_t; 32 | 33 | extern co_rc_t co_linux_reactor_packet_user_create( 34 | co_reactor_t reactor, int fd, 35 | co_reactor_user_receive_func_t receive, 36 | co_linux_reactor_packet_user_t *handle_out); 37 | 38 | extern void co_linux_reactor_packet_user_destroy( 39 | co_linux_reactor_packet_user_t user); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/colinux/os/linux/user/unix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_LINUX_USER_UNIX_H__ 12 | #define __COLINUX_LINUX_USER_UNIX_H__ 13 | 14 | #include 15 | 16 | co_rc_t co_os_set_blocking(int sock, bool_t enable); 17 | bool_t co_os_get_blocking(int sock); 18 | co_rc_t co_os_sendn(int sock, char *data, unsigned long size); 19 | co_rc_t co_os_recv(int sock, char *data, unsigned long size, unsigned long *current_size); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/colinux/os/timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_KERNEL_TIMER_H__ 12 | #define __CO_OS_KERNEL_TIMER_H__ 13 | 14 | #include 15 | 16 | typedef struct co_os_timer *co_os_timer_t; 17 | typedef void (*co_os_func_t)(void *); 18 | 19 | extern co_rc_t co_os_timer_create(co_os_func_t func, void *data, 20 | long msec, co_os_timer_t *timer_out); 21 | extern co_rc_t co_os_timer_activate(co_os_timer_t timer); 22 | extern void co_os_timer_deactivate(co_os_timer_t timer); 23 | extern void co_os_timer_destroy(co_os_timer_t timer); 24 | extern void co_os_msleep(unsigned int msecs); 25 | 26 | typedef struct { 27 | union { 28 | struct { 29 | unsigned long low; 30 | unsigned long high; 31 | }; 32 | unsigned long long quad; 33 | }; 34 | } co_timestamp_t; 35 | 36 | extern void co_os_get_timestamp(co_timestamp_t *dts); 37 | extern void co_os_get_timestamp_freq(co_timestamp_t *dts, co_timestamp_t *freq); 38 | extern unsigned long co_os_get_cpu_khz(void); 39 | 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /src/colinux/os/user/cobdpath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_COBDPATH_H__ 12 | #define __COLINUX_OS_USER_COBDPATH_H__ 13 | 14 | #include 15 | 16 | extern co_rc_t co_canonize_cobd_path(co_pathname_t *pathname); 17 | extern co_rc_t co_dirname (char *path); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/colinux/os/user/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Henry Nestler, 2008 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_CONFIG_H__ 12 | #define __COLINUX_OS_USER_CONFIG_H__ 13 | 14 | #if defined __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | co_rc_t co_config_user_string_read(int monitor_index, 21 | const char* device_name, 22 | int device_index, 23 | const char* value_name, 24 | char* value, 25 | int size); 26 | 27 | co_rc_t co_config_user_string_write(int monitor_index, 28 | const char* device_name, 29 | int device_index, 30 | const char* value_name, 31 | const char* value); 32 | 33 | #if defined __cplusplus 34 | } 35 | #endif 36 | 37 | #endif /* __COLINUX_OS_USER_CONFIG_H__ */ 38 | -------------------------------------------------------------------------------- /src/colinux/os/user/daemon.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_DAEMON_H__ 12 | #define __COLINUX_OS_USER_DAEMON_H__ 13 | 14 | #include 15 | #include 16 | 17 | extern void co_daemon_debug(char *str); 18 | extern void co_daemon_print_header(void); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/colinux/os/user/exec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_EXEC_H__ 12 | #define __COLINUX_OS_USER_EXEC_H__ 13 | 14 | #include 15 | 16 | extern co_rc_t co_launch_process(int *pid, char *command_line, ...); 17 | extern co_rc_t co_kill_process(int pid); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/colinux/os/user/file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_FILE_H__ 12 | #define __COLINUX_OS_USER_FILE_H__ 13 | 14 | #include 15 | 16 | extern co_rc_t co_os_file_load(co_pathname_t pathname, 17 | char **out_buf, unsigned long *out_size, unsigned long max_size); 18 | extern void co_os_file_free(char *buf); 19 | 20 | extern co_rc_t co_os_file_write(co_pathname_t pathname, void *buf, unsigned long size); 21 | extern co_rc_t co_os_file_unlink(co_pathname_t pathname); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/colinux/os/user/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_MANAGER_H__ 12 | #define __COLINUX_OS_USER_MANAGER_H__ 13 | 14 | #if defined __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | struct co_manager_handle; 23 | typedef struct co_manager_handle* co_manager_handle_t; 24 | 25 | extern co_manager_handle_t co_os_manager_open(void); 26 | extern co_manager_handle_t co_os_manager_open_quite(void); 27 | extern void co_os_manager_close(co_manager_handle_t handle); 28 | 29 | extern co_rc_t co_os_manager_ioctl( 30 | co_manager_handle_t kernel_device, 31 | unsigned long code, 32 | void* input_buffer, 33 | unsigned long input_buffer_size, 34 | void* output_buffer, 35 | unsigned long output_buffer_size, 36 | unsigned long* output_returned); 37 | 38 | extern co_rc_t co_os_manager_is_installed(bool_t* installed); 39 | 40 | 41 | extern co_rc_t co_os_reactor_monitor_create( 42 | co_reactor_t reactor, 43 | co_manager_handle_t whandle, 44 | co_reactor_user_receive_func_t receive, 45 | co_reactor_user_t* handle_out); 46 | 47 | extern void co_os_reactor_monitor_destroy(co_reactor_user_t handle); 48 | 49 | #if defined __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /* __COLINUX_OS_USER_MANAGER_H__ */ 54 | -------------------------------------------------------------------------------- /src/colinux/os/user/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_MISC_H__ 12 | #define __COLINUX_OS_USER_MISC_H__ 13 | 14 | #if defined __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | typedef void (*co_terminal_print_hook_func_t)(char* str); 21 | 22 | typedef enum { 23 | CO_TERM_COLOR_YELLOW = 1, 24 | CO_TERM_COLOR_WHITE = 2, 25 | } co_terminal_color_t; 26 | 27 | extern void co_terminal_print(const char* format, ...) 28 | __attribute__ ((format (printf, 1, 2))); 29 | extern void co_terminal_print_color(co_terminal_color_t color, const char* format, ...) 30 | __attribute__ ((format (printf, 2, 3))); 31 | extern void co_set_terminal_print_hook(co_terminal_print_hook_func_t func); 32 | extern void co_process_high_priority_set(void); 33 | extern int co_udp_socket_connect(const char* addr, unsigned short int port); 34 | extern int co_udp_socket_send(int sock, const char* buffer, unsigned long size); 35 | extern void co_udp_socket_close(int sock); 36 | 37 | #if defined __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* __COLINUX_OS_USER_MISC_H__ */ 42 | -------------------------------------------------------------------------------- /src/colinux/os/user/reactor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_OS_USER_REACTOR_H__ 12 | #define __COLINUX_OS_USER_REACTOR_H__ 13 | 14 | #include 15 | 16 | extern co_rc_t co_os_reactor_select(co_reactor_t handle, int miliseconds); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef __CO_WINNT_IOCTL_H__ 2 | #define __CO_WINNT_IOCTL_H__ 3 | 4 | #define CO_WINNT_IOCTL(_method_) \ 5 | CTL_CODE(CO_DRIVER_TYPE, _method_, METHOD_BUFFERED, FILE_ANY_ACCESS) 6 | 7 | #define CO_GET_IOCTL_TYPE(ioctl) ((ioctl >> 16) & ((1 << 16) - 1)) 8 | #define CO_GET_IOCTL_ACCESS(ioctl) ((ioctl >> 14) & ((1 << 2) - 1)) 9 | #define CO_GET_IOCTL_METHOD(ioctl) ((ioctl >> 2) & ((1 << 12) - 1)) 10 | #define CO_GET_IOCTL_MTYPE(ioctl) ((ioctl >> 0) & ((1 << 2) - 1)) 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs= 3 | input_list(".c", ".o") + 4 | [Input("lowlevel/build.o")], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/core.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "ddk.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | COLINUX_DEFINE_MODULE("colinux-driver"); 18 | 19 | co_rc_t co_monitor_os_init(co_monitor_t *cmon) 20 | { 21 | co_rc_t rc = CO_RC_OK; 22 | 23 | cmon->osdep = co_os_malloc(sizeof(*cmon->osdep)); 24 | if (cmon->osdep == NULL) { 25 | return CO_RC(OUT_OF_MEMORY); 26 | } 27 | 28 | co_os_mutex_create(&cmon->osdep->mutex); 29 | 30 | /* ligong liu, 2008/04/08, kernel mod conet support */ 31 | cmon->osdep->conet_protocol = NULL; 32 | co_conet_register_protocol(cmon); 33 | 34 | return rc; 35 | } 36 | 37 | void co_monitor_os_exit(co_monitor_t *cmon) 38 | { 39 | co_os_mutex_destroy(cmon->osdep->mutex); 40 | co_conet_unregister_protocol(cmon); 41 | co_os_mutex_destroy(cmon->osdep->conet_mutex); 42 | co_os_free(cmon->osdep); 43 | } 44 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/ddk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __NESTED_WINNT_DDK_H__ 12 | #define __NESTED_WINNT_DDK_H__ 13 | 14 | #include 15 | #include 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_WINNT_DRIVER_H__ 12 | #define __CO_WINNT_DRIVER_H__ 13 | 14 | #define CO_DRIVER_TYPE 0x00008300 15 | #define CO_DRIVER_NAME "CoLinuxDriver" 16 | #define CO_DRIVER_USER_PATH "\\\\.\\" CO_DRIVER_NAME 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/exceptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_WINNT_KERNEL_EXCEPTIONS_H__ 12 | #define __CO_WINNT_KERNEL_EXCEPTIONS_H__ 13 | 14 | #include "ddk.h" 15 | 16 | #include 17 | 18 | #define CO_EXCEPTION_WRAPPER(name, frame_size, pushes) \ 19 | EXCEPTION_DISPOSITION name##Handler(EXCEPTION_RECORD *record, \ 20 | ULONG *EstablisherFrame, \ 21 | struct _CONTEXT *ContextRecord, \ 22 | ULONG *DispatcherContext) \ 23 | { \ 24 | (*((unsigned long *)(EstablisherFrame[7]))) = 1; \ 25 | ContextRecord->Esp = (unsigned long)&EstablisherFrame[0]; \ 26 | ContextRecord->Eip = (unsigned long)EstablisherFrame[-1-(frame_size/4)]; \ 27 | \ 28 | return ExceptionContinueExecution; \ 29 | } \ 30 | \ 31 | asm( \ 32 | ".globl _co_" #name "\n" \ 33 | "_co_" #name ":\n" \ 34 | "pushl %ebp;" \ 35 | "movl %esp, %ebp;" \ 36 | "pushl %ebx;" \ 37 | "pushl %esi;" \ 38 | "pushl %edi;" \ 39 | \ 40 | "pushl $_" #name "Handler;" \ 41 | "pushl %fs:0;" \ 42 | "movl %esp,%fs:0;" \ 43 | pushes \ 44 | "call __imp__" #name "@"#frame_size";" \ 45 | "popl %fs:0;" \ 46 | "popl %ecx;" \ 47 | \ 48 | "popl %edi;" \ 49 | "popl %esi;" \ 50 | "popl %ebx;" \ 51 | "popl %ebp;" \ 52 | "ret;" \ 53 | ""); \ 54 | 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/fileio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_WINNT_KERNEL_FILEIO_H__ 12 | #define __CO_WINNT_KERNEL_FILEIO_H__ 13 | 14 | #include 15 | 16 | #include "ddk.h" 17 | 18 | co_rc_t co_os_file_get_size(HANDLE handle, unsigned long long *out_size); 19 | 20 | co_rc_t co_winnt_utf8_to_unicode(const char *src, UNICODE_STRING *unicode_str); 21 | void co_winnt_free_unicode(UNICODE_STRING *unicode_str); 22 | co_rc_t co_status_convert(NTSTATUS status); 23 | 24 | extern co_rc_t co_os_file_open(char *pathname, PHANDLE FileHandle, 25 | unsigned long open_flags); 26 | 27 | extern co_rc_t co_os_file_create(char *pathname, PHANDLE FileHandle, unsigned long open_flags, 28 | unsigned long file_attribute, unsigned long create_disposition, 29 | unsigned long options); 30 | 31 | extern co_rc_t co_os_file_block_read_write(co_monitor_t *monitor, 32 | HANDLE file_handle, 33 | unsigned long long offset, 34 | vm_ptr_t address, 35 | unsigned long size, 36 | bool_t read); 37 | 38 | extern co_rc_t co_os_file_close(PHANDLE FileHandle); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/lowlevel/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=input_list(".c", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/lowlevel/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "../ddk.h" 12 | #include "../manager.h" 13 | 14 | #include 15 | 16 | #ifdef COLINUX_DEBUG 17 | void co_debug_startup(void) 18 | { 19 | static ULONG debug = 0; 20 | static RTL_QUERY_REGISTRY_TABLE query[2] = {{ 21 | .Flags = RTL_QUERY_REGISTRY_REQUIRED 22 | | RTL_QUERY_REGISTRY_DIRECT 23 | | RTL_QUERY_REGISTRY_NOEXPAND, 24 | .Name = L"Debug", 25 | .EntryContext = &debug, 26 | .DefaultType = REG_DWORD, 27 | }}; 28 | 29 | /* Enable DbgPrint, to see all the co_debug on loading driver. */ 30 | if (RtlQueryRegistryValues( 31 | RTL_REGISTRY_ABSOLUTE, 32 | L"\\Registry\\MACHINE\\SOFTWARE\\coLinux", 33 | query, NULL, NULL) == STATUS_SUCCESS) 34 | co_global_debug_levels.misc_level = debug; 35 | } 36 | 37 | void co_debug_system(const char *fmt, ...) 38 | { 39 | char buf[0x100]; 40 | va_list ap; 41 | 42 | va_start(ap, fmt); 43 | co_vsnprintf(buf, sizeof(buf), fmt, ap); 44 | DbgPrint("%s\n", buf); 45 | va_end(ap); 46 | } 47 | 48 | void co_debug_level_system(const char *module, co_debug_facility_t facility, int level, 49 | const char *filename, int line, const char *func, const char *text) 50 | { 51 | /* Debug output to Dbgview.exe (www.sysinternals.com) */ 52 | DbgPrint("[m:%s f:%d l:%d %s:%d:%s] %s\n", module, facility, level, filename, line, func, text); 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/lowlevel/misc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "../ddk.h" 12 | 13 | #include 14 | 15 | unsigned long co_os_virt_to_phys(void *addr) 16 | { 17 | PHYSICAL_ADDRESS pa; 18 | 19 | pa = MmGetPhysicalAddress((PVOID)addr); 20 | 21 | return pa.QuadPart; 22 | } 23 | 24 | co_rc_t co_os_physical_memory_pages(unsigned long *pages) 25 | { 26 | SYSTEM_BASIC_INFORMATION sbi; 27 | NTSTATUS status; 28 | co_rc_t rc = CO_RC(OK); 29 | 30 | status = NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL); 31 | if (status != STATUS_SUCCESS) 32 | return CO_RC(ERROR); 33 | 34 | *pages = sbi.NumberOfPhysicalPages; 35 | 36 | /* 37 | * Round to 16 MB boundars, since Windows doesn't return the 38 | * exact amount but a bit lower. 39 | */ 40 | *pages = ~0xfff & ((*pages) + 0xfff); 41 | 42 | return rc; 43 | } 44 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/lowlevel/mutex.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "../ddk.h" 12 | 13 | #include 14 | #include 15 | 16 | struct co_os_mutex { 17 | KMUTEX mutex; 18 | }; 19 | 20 | co_rc_t co_os_mutex_create(co_os_mutex_t *mutex_out) 21 | { 22 | co_os_mutex_t mutex; 23 | 24 | *mutex_out = NULL; 25 | 26 | mutex = co_os_malloc(sizeof(*mutex)); 27 | 28 | if (mutex == NULL) 29 | return CO_RC(OUT_OF_MEMORY); 30 | 31 | KeInitializeMutex(&mutex->mutex, 0); 32 | 33 | *mutex_out = mutex; 34 | 35 | return CO_RC(OK); 36 | } 37 | 38 | void co_os_mutex_acquire(co_os_mutex_t mutex) 39 | { 40 | NTSTATUS status; 41 | status = KeWaitForMutexObject(&mutex->mutex, UserRequest, 42 | KernelMode, FALSE, NULL); 43 | 44 | } 45 | 46 | void co_os_mutex_acquire_critical(co_os_mutex_t mutex) 47 | { 48 | if (KeGetCurrentIrql() < DISPATCH_LEVEL) 49 | co_os_mutex_acquire(mutex); 50 | } 51 | 52 | void co_os_mutex_release(co_os_mutex_t mutex) 53 | { 54 | KeReleaseMutex(&mutex->mutex, FALSE); 55 | } 56 | 57 | void co_os_mutex_release_critical(co_os_mutex_t mutex) 58 | { 59 | if (KeGetCurrentIrql() < DISPATCH_LEVEL) 60 | co_os_mutex_release(mutex); 61 | } 62 | 63 | void co_os_mutex_destroy(co_os_mutex_t mutex) 64 | { 65 | if (mutex != NULL) 66 | co_os_free(mutex); 67 | } 68 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/lowlevel/wait.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "../ddk.h" 12 | 13 | #include 14 | #include 15 | 16 | struct co_os_wait { 17 | KEVENT event; 18 | }; 19 | 20 | co_rc_t co_os_wait_create(co_os_wait_t *wait_out) 21 | { 22 | co_os_wait_t wait; 23 | 24 | *wait_out = NULL; 25 | 26 | wait = co_os_malloc(sizeof(*wait)); 27 | 28 | if (wait == NULL) 29 | return CO_RC(OUT_OF_MEMORY); 30 | 31 | KeInitializeEvent(&wait->event, SynchronizationEvent, FALSE); 32 | 33 | *wait_out = wait; 34 | 35 | return CO_RC(OK); 36 | } 37 | 38 | void co_os_wait_sleep(co_os_wait_t wait) 39 | { 40 | KeWaitForSingleObject(&wait->event, UserRequest, UserMode, TRUE, NULL); 41 | } 42 | 43 | void co_os_wait_wakeup(co_os_wait_t wait) 44 | { 45 | KeSetEvent(&wait->event, 1, PFALSE); 46 | } 47 | 48 | void co_os_wait_destroy(co_os_wait_t wait) 49 | { 50 | if (wait != NULL) 51 | co_os_free(wait); 52 | } 53 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/tap-win32/MAKEFILE: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the components of NT OS/2 5 | # 6 | !INCLUDE $(NTMAKEENV)\makefile.def 7 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/tap-win32/endian.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TAP-Win32 -- A kernel driver to provide virtual tap device 3 | * functionality on Windows. Originally derived 4 | * from the CIPE-Win32 project by Damion K. Wilson, 5 | * with extensive modifications by James Yonan. 6 | * 7 | * All source code which derives from the CIPE-Win32 project is 8 | * Copyright (C) Damion K. Wilson, 2003, and is released under the 9 | * GPL version 2 (see below). 10 | * 11 | * All other source code is Copyright (C) 2002-2005 OpenVPN Solutions LLC, 12 | * and is released under the GPL version 2 (see below). 13 | * 14 | * This program is free software; you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License version 2 16 | * as published by the Free Software Foundation. 17 | * 18 | * This program is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | * GNU General Public License for more details. 22 | * 23 | * You should have received a copy of the GNU General Public License 24 | * along with this program (see the file COPYING included with this 25 | * distribution); if not, write to the Free Software Foundation, Inc., 26 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 27 | */ 28 | 29 | #ifdef TAP_LITTLE_ENDIAN 30 | #define ntohs(x) RtlUshortByteSwap(x) 31 | #define htons(x) RtlUshortByteSwap(x) 32 | #define ntohl(x) RtlUlongByteSwap(x) 33 | #define htonl(x) RtlUlongByteSwap(x) 34 | #else 35 | #define ntohs(x) ((USHORT)(x)) 36 | #define htons(x) ((USHORT)(x)) 37 | #define ntohl(x) ((ULONG)(x)) 38 | #define htonl(x) ((ULONG)(x)) 39 | #endif 40 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/tap-win32/i386/tap.cat: -------------------------------------------------------------------------------- 1 | ; **************************************************************************** 2 | ; * Copyright (C) 2002-2005 OpenVPN Solutions LLC * 3 | ; * This program is free software; you can redistribute it and/or modify * 4 | ; * it under the terms of the GNU General Public License version 2 * 5 | ; * as published by the Free Software Foundation. * 6 | ; **************************************************************************** 7 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/time.c: -------------------------------------------------------------------------------- 1 | #include "time.h" 2 | 3 | #define DELTA (134774LL*86400) 4 | #define SCALE (10000000LL) 5 | 6 | unsigned long windows_time_to_unix_time(LARGE_INTEGER time) 7 | { 8 | /* 9 | * Windows' system time is a count of 100-nanosecond intervals since January 1, 1601. 10 | * System time is typically updated approximately every ten milliseconds. This value 11 | * is computed for the GMT time zone. 12 | */ 13 | 14 | /* 15 | * Convert to seconds. 16 | */ 17 | time.QuadPart = time.QuadPart / SCALE; 18 | 19 | /* 20 | * Shift to 1970. 134774*86400 is the number of seconds between January 1, 1601 and 21 | * January 1, 1970. 22 | */ 23 | time.QuadPart -= DELTA; 24 | 25 | return time.QuadPart; 26 | } 27 | 28 | LARGE_INTEGER unix_time_to_windows_time(unsigned long time) 29 | { 30 | LARGE_INTEGER ret_time; 31 | 32 | ret_time.QuadPart = time; 33 | ret_time.QuadPart += DELTA; 34 | ret_time.QuadPart *= SCALE; 35 | 36 | return ret_time; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/kernel/time.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_WINNT_KERNEL_TIME_H__ 12 | #define __CO_WINNT_KERNEL_TIME_H__ 13 | 14 | #include 15 | 16 | #include "ddk.h" 17 | 18 | unsigned long windows_time_to_unix_time(LARGE_INTEGER time); 19 | LARGE_INTEGER unix_time_to_windows_time(unsigned long time); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/memory.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLINUX_OS_WINNT_MEMORY_H__ 2 | #define __COLINUX_OS_WINNT_MEMORY_H__ 3 | 4 | #include 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLINUX_OS_WINNT_MONITOR_H__ 2 | #define __COLINUX_OS_WINNT_MONITOR_H__ 3 | 4 | #include 5 | 6 | #include "kernel/ddk.h" 7 | 8 | typedef struct co_monitor_osdep { 9 | co_os_mutex_t mutex; 10 | 11 | /* ligong liu, support kernel mode conet */ 12 | co_os_mutex_t conet_mutex; 13 | char protocol_name[128]; 14 | void* conet_protocol; 15 | co_list_t conet_adapters; /* lists of conet_adapter */ 16 | } co_monitor_osdep_t; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/os.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLINUX_WINNT_OS_H__ 2 | #define __COLINUX_WINNT_OS_H__ 3 | 4 | #define COLINUX_DRIVER_FILE "linux.sys" 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/alloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | /* WinNT host: allocate memory blocks in WinNT user space */ 12 | 13 | #include 14 | 15 | #include 16 | 17 | void* co_os_malloc(unsigned long size) 18 | { 19 | return malloc(size); 20 | } 21 | 22 | void* co_os_realloc(void* ptr, unsigned long size) 23 | { 24 | return realloc(ptr, size); 25 | } 26 | 27 | void co_os_free(void* ptr) 28 | { 29 | free(ptr); 30 | } 31 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['user-all.a'] = Target( 2 | inputs=[ 3 | Input("user-osdep.a"), 4 | Input("../../../user.a"), 5 | ] 6 | ) 7 | 8 | targets['user-osdep.a'] = Target( 9 | inputs=input_list(".c", ".o"), 10 | ) 11 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-bridged-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-bridged-daemon/pcap-registry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry -- Registry keys and values commonly used in the TAP-Win32 & PCAP 3 | * drivers. Loosely based/borrowed from TAP-Win32/common.h 4 | * 5 | * All source code which derives from the CIPE-Win32 project is 6 | * Copyright (C) Damion K. Wilson, 2003, and is released under the 7 | * GPL version 2 (see below). 8 | * 9 | * All other source code is Copyright (C) James Yonan, 2003-2004, 10 | * and is released under the GPL version 2 (see below). 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program (see the file COPYING included with this 24 | * distribution); if not, write to the Free Software Foundation, Inc., 25 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 | */ 27 | 28 | //================= 29 | // Registry keys 30 | //================= 31 | 32 | #define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 33 | 34 | #define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 35 | 36 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.a'] = Target( 2 | inputs=[ 3 | Input('daemon.o'), 4 | Input('tap-win32.o') 5 | ], 6 | ) 7 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-daemon/daemon.h: -------------------------------------------------------------------------------- 1 | #ifndef __COLINUX_WINNT_USER_CONET_DAEMON_DAEMON_H__ 2 | #define __COLINUX_WINNT_USER_CONET_DAEMON_DAEMON_H__ 3 | 4 | #include 5 | 6 | extern "C" { 7 | #include 8 | #include 9 | } 10 | 11 | class user_network_tap_daemon_t : public user_daemon_t { 12 | public: 13 | user_network_tap_daemon_t(); 14 | virtual ~user_network_tap_daemon_t(); 15 | virtual co_module_t get_base_module(); 16 | virtual unsigned int get_unit_count(); 17 | virtual const char *get_daemon_name(); 18 | virtual const char *get_daemon_title(); 19 | virtual const char *get_extended_syntax(); 20 | virtual void received_from_monitor(co_message_t *message); 21 | virtual void received_from_tap(unsigned char *buffer, unsigned long size); 22 | virtual void handle_extended_parameters(co_command_line_params_t cmdline); 23 | virtual void prepare_for_loop(); 24 | virtual void syntax(); 25 | 26 | protected: 27 | bool_t tap_name_specified; 28 | char tap_name[0x100]; 29 | co_winnt_reactor_packet_user_t tap_handle; 30 | }; 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-daemon/tap-win32.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_TAP_WIN32_H__ 12 | #define __CO_TAP_WIN32_H__ 13 | 14 | extern co_rc_t open_tap_win32(HANDLE *phandle, char *prefered_name); 15 | extern BOOL tap_win32_set_status(HANDLE handle, BOOL status); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-ndis-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-ndis-daemon/pcap-registry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Registry -- Registry keys and values commonly used in the TAP-Win32 & PCAP 3 | * drivers. Loosely based/borrowed from TAP-Win32/common.h 4 | * 5 | * All source code which derives from the CIPE-Win32 project is 6 | * Copyright (C) Damion K. Wilson, 2003, and is released under the 7 | * GPL version 2 (see below). 8 | * 9 | * All other source code is Copyright (C) James Yonan, 2003-2004, 10 | * and is released under the GPL version 2 (see below). 11 | * 12 | * This program is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * This program is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program (see the file COPYING included with this 24 | * distribution); if not, write to the Free Software Foundation, Inc., 25 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 | */ 27 | 28 | //================= 29 | // Registry keys 30 | //================= 31 | 32 | #define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 33 | 34 | #define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" 35 | 36 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-slirp-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/conet-slirp-daemon/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * Alejandro R. Sedeno , 2004 (c) 6 | * Fabrice Bellard, 2003-2004 Copyright (c) 7 | * 8 | * The code is licensed under the GPL. See the COPYING file at 9 | * the root directory. 10 | * 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | COLINUX_DEFINE_MODULE("colinux-slirp-net-daemon"); 21 | 22 | static HANDLE slirp_mutex; 23 | 24 | co_rc_t co_slirp_mutex_init (void) 25 | { 26 | slirp_mutex = CreateMutex(NULL, FALSE, NULL); 27 | if (slirp_mutex == NULL) { 28 | co_terminal_print("conet-slirp-daemon: Mutex creating failed\n"); 29 | return CO_RC(ERROR); 30 | } 31 | return CO_RC(OK); 32 | } 33 | 34 | void co_slirp_mutex_destroy (void) 35 | { 36 | CloseHandle(slirp_mutex); 37 | } 38 | 39 | void co_slirp_mutex_lock (void) 40 | { 41 | WaitForSingleObject(slirp_mutex, INFINITE); 42 | } 43 | 44 | void co_slirp_mutex_unlock (void) 45 | { 46 | ReleaseMutex(slirp_mutex); 47 | } 48 | 49 | int main(int argc, char *argv[]) 50 | { 51 | co_rc_t rc; 52 | 53 | rc = co_slirp_main(argc, argv); 54 | if (CO_OK(rc)) 55 | return 0; 56 | 57 | return -1; 58 | } 59 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/console-fltk/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.a'] = Target( 2 | inputs=[ 3 | Input('head.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/console-nt/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.a'] = Target( 2 | inputs=input_list('.cpp', '.o') 3 | +input_list('.c', '.o'), 4 | ) 5 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/console-nt/console.cpp: -------------------------------------------------------------------------------- 1 | #include "console.h" 2 | 3 | const char* console_window_NT_t::get_name() 4 | { 5 | return "colinux-console-nt.exe"; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/console-nt/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * Ballard, Jonathan H. , 2004 (c) 6 | * 7 | * The code is licensed under the GPL. See the COPYING file at 8 | * the root directory. 9 | * 10 | */ 11 | 12 | #ifndef __COLINUX_WINNT_OS_USER_CONSOLE_WIDGET_H__ 13 | #define __COLINUX_WINNT_OS_USER_CONSOLE_WIDGET_H__ 14 | 15 | #include 16 | 17 | #include 18 | 19 | class console_window_NT_t : public console_window_t { 20 | public: 21 | virtual const char* get_name(); 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/console-nt/head.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003-2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | /* 12 | * WinNT dependent main program for the text mode console. 13 | * Used for building colinux-console-nt.exe 14 | */ 15 | #include 16 | 17 | extern "C" { 18 | #include 19 | #include 20 | } 21 | 22 | #include 23 | #include "console.h" 24 | 25 | COLINUX_DEFINE_MODULE("colinux-console-nt"); 26 | 27 | int main(int argc, char** argv) 28 | { 29 | int status; 30 | 31 | global_window = new console_window_NT_t; 32 | 33 | if (global_window == NULL) { 34 | co_terminal_print("Unable to create console window"); 35 | return -1; 36 | } 37 | 38 | try { 39 | status = co_user_console_main(argc, argv); 40 | } catch(...) { 41 | co_debug("The console program encountered an exception."); 42 | status = -1; 43 | } 44 | 45 | delete global_window; 46 | 47 | return status; 48 | } 49 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/console-nt/os_console.c: -------------------------------------------------------------------------------- 1 | 2 | /* WinNT host: low-level console routines */ 3 | 4 | /* TODO: 5 | * Move all low-level console functions in this file 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #include "os_console.h" 12 | 13 | /* Set cursor size 14 | Parameters: 15 | cursor_type - size of cursor in Linux kernel defines 16 | */ 17 | void co_console_set_cursor_size(void* out_h, const int cursor_type) 18 | { 19 | CONSOLE_CURSOR_INFO curs_info; 20 | 21 | if((HANDLE)out_h == INVALID_HANDLE_VALUE) 22 | return; 23 | 24 | curs_info.bVisible = TRUE; 25 | switch (cursor_type) { 26 | case CO_CUR_NONE: 27 | curs_info.dwSize = 1; 28 | curs_info.bVisible = FALSE; 29 | break; 30 | case CO_CUR_UNDERLINE: 31 | curs_info.dwSize = 16; 32 | break; 33 | case CO_CUR_LOWER_THIRD: 34 | curs_info.dwSize = 33; 35 | break; 36 | case CO_CUR_LOWER_HALF: 37 | curs_info.dwSize = 50; 38 | break; 39 | case CO_CUR_TWO_THIRDS: 40 | curs_info.dwSize = 66; 41 | break; 42 | case CO_CUR_BLOCK: 43 | curs_info.dwSize = 99; 44 | break; 45 | case CO_CUR_DEF: 46 | default: 47 | curs_info.dwSize = 10; /* This will never use in normal way */ 48 | } 49 | 50 | SetConsoleCursorInfo((HANDLE)out_h, &curs_info); 51 | } 52 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/console-nt/os_console.h: -------------------------------------------------------------------------------- 1 | 2 | /* WinNT host: low level console routines */ 3 | 4 | #ifndef __CO_OS_USER_WINNT_OS_CONSOLE_H__ 5 | #define __CO_OS_USER_WINNT_OS_CONSOLE_H__ 6 | 7 | #if defined __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | void co_console_set_cursor_size(void* out_h, const int cursor_type); 12 | /* Set cursor size 13 | Parameters: 14 | out_h - console output handle 15 | cursor_type - size of cursor in Linux kernel defines 16 | */ 17 | 18 | #if defined __cplusplus 19 | } 20 | #endif 21 | 22 | #endif /* __CO_OS_USER_WINNT_OS_CONSOLE_H__ */ 23 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/coserial-daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['daemon.o'] = Target( 2 | inputs = input_list(".c", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/cmdline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_USER_WINNT_DAEMON_CMDLINE_H__ 12 | #define __CO_OS_USER_WINNT_DAEMON_CMDLINE_H__ 13 | 14 | #include 15 | #include 16 | 17 | typedef struct co_winnt_parameters { 18 | bool_t install_service; 19 | bool_t remove_service; 20 | bool_t run_service; 21 | bool_t install_driver; 22 | bool_t status_driver; 23 | bool_t show_status; 24 | bool_t remove_driver; 25 | char service_name[128]; 26 | } co_winnt_parameters_t; 27 | 28 | extern void co_winnt_daemon_syntax(void); 29 | extern co_rc_t co_winnt_daemon_parse_args(co_command_line_params_t cmdline, co_winnt_parameters_t *winnt_parameters); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/debug.c: -------------------------------------------------------------------------------- 1 | #include "debug.h" 2 | 3 | void co_daemon_trace_point(co_trace_point_info_t *info) 4 | { 5 | } 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_USER_WINNT_DAEMON_DEBUG_H__ 12 | #define __CO_OS_USER_WINNT_DAEMON_DEBUG_H__ 13 | 14 | #include 15 | 16 | extern void co_daemon_trace_point(co_trace_point_info_t *info); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/driver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_USER_WINNT_DAEMON_DRIVER_H__ 12 | #define __CO_OS_USER_WINNT_DAEMON_DRIVER_H__ 13 | 14 | #include 15 | 16 | extern co_rc_t co_winnt_status_driver(int verbose); 17 | 18 | extern co_rc_t co_winnt_install_driver(void); 19 | extern co_rc_t co_winnt_initialize_driver(void); 20 | extern co_rc_t co_winnt_remove_driver(void); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_USER_WINNT_DAEMON_MAIN_H__ 12 | #define __CO_OS_USER_WINNT_DAEMON_MAIN_H__ 13 | 14 | #include 15 | 16 | extern co_rc_t co_winnt_daemon_main(co_start_parameters_t *start_parameters); 17 | extern void co_winnt_daemon_stop(void); 18 | 19 | extern bool_t co_running_as_service; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/misc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include "misc.h" 13 | 14 | /* 15 | * Currently there's a bug on SMP that prevents coLinux from 16 | * running stable unless it is pinned to the first processor. 17 | */ 18 | void co_winnt_affinity_workaround(void) 19 | { 20 | char *env; 21 | HANDLE hProcess = GetCurrentProcess(); 22 | 23 | // Prevent coLinux from using CPU0 24 | env = getenv("COLINUX_NO_CPU0_WORKAROUND"); 25 | if (env && strcmp(env, "Y") == 0) { 26 | DWORD ProcessMask, SystemMask, NewMask; 27 | 28 | if (GetProcessAffinityMask (hProcess, &ProcessMask, &SystemMask)) { 29 | NewMask = SystemMask & ~1; 30 | co_debug("AffinityMasks Process %lx, System %lx, New %lx", ProcessMask, SystemMask, NewMask); 31 | if (NewMask != ProcessMask) { 32 | if (!SetProcessAffinityMask(hProcess, NewMask)) { 33 | co_debug("SetProcessAffinityMask failed with 0x%lx", GetLastError()); 34 | } 35 | } 36 | } else 37 | co_debug("GetProcessAffinityMask failed with 0x%lx", GetLastError()); 38 | 39 | return; 40 | } 41 | 42 | env = getenv("COLINUX_NO_SMP_WORKAROUND"); 43 | if (env && strcmp(env, "Y") == 0) 44 | return; 45 | 46 | SetProcessAffinityMask(hProcess, 1); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_USER_WINNT_DAEMON_MISC_H__ 12 | #define __CO_OS_USER_WINNT_DAEMON_MISC_H__ 13 | 14 | #include 15 | 16 | extern void co_winnt_affinity_workaround(void); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/res/colinux.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/da-x/colinux/aef3a72cb898b809962503fdfecea405672a753b/src/colinux/os/winnt/user/daemon/res/colinux.ico -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/res/colinux.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resources_def.inc" 3 | 4 | 2 ICON "colinux.ico" 5 | 6 | 1 VERSIONINFO 7 | FILEVERSION CO_VERSION_DWORD 8 | PRODUCTVERSION CO_VERSION_DWORD 9 | FILEOS VOS__WINDOWS32 10 | { 11 | BLOCK "StringFileInfo"{ 12 | BLOCK "040904B0" { 13 | VALUE "CompanyName","Open Source software" 14 | VALUE "FileDescription", CO_TEXTNAME_STRING 15 | VALUE "FileVersion", CO_VERSION_STRING 16 | VALUE "LegalCopyright","Copyright (c) coLinux project" 17 | VALUE "OriginalFilename", CO_FILENAME_STRING 18 | VALUE "ProductName", "coLinux" 19 | VALUE "ProductVersion", CO_PRODUCT_STRING 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/res/daemon.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "resources_def.inc" 3 | 4 | LANGUAGE LANG_ENGLISH,SUBLANG_DEFAULT 5 | 1 11 "service-message.bin" 6 | 7 | 2 ICON "colinux.ico" 8 | 9 | 1 VERSIONINFO 10 | FILEVERSION CO_VERSION_DWORD 11 | PRODUCTVERSION CO_VERSION_DWORD 12 | FILEOS VOS__WINDOWS32 13 | { 14 | BLOCK "StringFileInfo"{ 15 | BLOCK "040904B0" { 16 | VALUE "CompanyName","Open Source software" 17 | VALUE "FileDescription", "coLinux Main daemon program" 18 | VALUE "FileVersion", CO_VERSION_STRING 19 | VALUE "LegalCopyright","Copyright (c) coLinux project" 20 | VALUE "OriginalFilename","colinux-daemon.exe" 21 | VALUE "ProductName", "coLinux" 22 | VALUE "ProductVersion", CO_PRODUCT_STRING 23 | VALUE "LinuxKernelVersion", CO_KERNEL_STRING 24 | VALUE "GccVersion", CO_GCC_STRING 25 | VALUE "BinutilsVersion", CO_AS_STRING 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/res/resources_def.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Remember: This file runs from / as current directory. 4 | # Standard arguments for this script: 5 | # $1: src/colinux/VERSION 6 | # $2: src/colinux/os/winnt/user/daemon/res/resources_def.inc 7 | 8 | VERSION_FILE=$1 9 | TARGET_FILE=$2 10 | 11 | # Get kernel and gcc version 12 | . bin/build-common.sh --get-vars 13 | 14 | # coLinux full version with "-preXX" and build date 15 | CO_PRODUCT_STRING=`cat $VERSION_FILE`-`date +%Y%m%d` 16 | 17 | # Get 4 digit words from full version 18 | VERSION=`sed -ne 's/\([0-9\.]*\)-[^0-9]*\([0-9]*\).*/\1,\2/p' < $VERSION_FILE` 19 | 20 | # Get SVN revision number 21 | REVISION=`svnversion | sed -rne 's/^([0-9]*).*$/\1/p'` 22 | test -z "$REVISION" && REVISION="0" 23 | 24 | # Fallback 3 digit words without -preXX 25 | test -z "$VERSION" && \ 26 | VERSION=`sed -e 's/\([0-9\.]*\).*/\1/' < $VERSION_FILE`.$REVISION 27 | 28 | # Transform into comma format 29 | CO_VERSION_DWORD=`echo $VERSION | sed -e 's/\./,/g'` 30 | 31 | # Get gcc version from current running (not from config file defined) 32 | GCC_VERSION_STRING="`$TARGET-gcc -dumpversion`-mingw32" 33 | 34 | # Get binutils version from current running 35 | AS_VERSION_STRING="`$TARGET-as --version | sed -rne '1s/^[^0-9]*([0-9\.]+).*$/\1/p'`-mingw32" 36 | 37 | cat > $TARGET_FILE << EOF 38 | #define CO_PRODUCT_STRING "$CO_PRODUCT_STRING" 39 | #define CO_VERSION_STRING "$VERSION" 40 | #define CO_VERSION_DWORD $CO_VERSION_DWORD 41 | #define CO_KERNEL_STRING "$KERNEL_VERSION" 42 | #define CO_GCC_STRING "$GCC_VERSION_STRING" 43 | #define CO_AS_STRING "$AS_VERSION_STRING" 44 | EOF 45 | 46 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/res/service-message.bin: -------------------------------------------------------------------------------- 1 | @@%1 2 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/res/service-message.h: -------------------------------------------------------------------------------- 1 | // ***** service-messages.mc ***** 2 | 3 | // MessageId: MSG_SERVICE_INFO 4 | // MessageText: 5 | // %1 6 | // 7 | #define MSG_SERVICE_INFO 0x40000001L 8 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/res/service-message.mc: -------------------------------------------------------------------------------- 1 | ;// ***** service-messages.mc ***** 2 | 3 | ;// Compile with Message Compiler from SDK: 4 | ;// mc.exe -b service-message.mc 5 | ;// rename service-message_MSG00001.bin service-message.bin 6 | 7 | MessageId=0x1 8 | Severity=Informational 9 | Facility=Application 10 | SymbolicName=MSG_SERVICE_INFO 11 | Language=English 12 | %1 13 | . 14 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/daemon/service.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_USER_WINNT_DAEMON_SERVICE_H__ 12 | #define __CO_OS_USER_WINNT_DAEMON_SERVICE_H__ 13 | 14 | #include "cmdline.h" 15 | 16 | extern void co_winnt_change_directory_for_service(int argc, char **argv); 17 | extern co_rc_t co_winnt_daemon_install_as_service(const char *service_name, const char *original_commandline, int network_types); 18 | extern co_rc_t co_winnt_daemon_remove_service(const char *service_name); 19 | extern bool_t co_winnt_daemon_initialize_service(co_start_parameters_t *start_parameters); 20 | 21 | extern void co_ntevent_print(const char *format, ...) 22 | __attribute__ ((format (printf, 1, 2))); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/debug/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=[ 3 | Input('main.o'), 4 | ], 5 | ) 6 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/debug/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | COLINUX_DEFINE_MODULE("colinux-debug-daemon"); 21 | 22 | int main(int argc, char *argv[]) 23 | { 24 | co_rc_t rc; 25 | 26 | rc = co_debug_main(argc, argv); 27 | 28 | if (!CO_OK(rc)) 29 | return -1; 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/file-unlink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Henry Nestler, 2007 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "misc.h" 15 | 16 | co_rc_t co_os_file_unlink(co_pathname_t pathname) 17 | { 18 | char last_error[0x100]; 19 | 20 | if (!DeleteFile(pathname)) { 21 | co_winnt_get_last_error(last_error, sizeof(last_error)); 22 | co_debug_error("Error unlink file %s: %s", pathname, last_error); 23 | return CO_RC(ERROR); 24 | } 25 | 26 | return CO_RC(OK); 27 | } 28 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/file-write.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Henry Nestler, 2007 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "misc.h" 15 | 16 | co_rc_t co_os_file_write(co_pathname_t pathname, void *buf, unsigned long size) 17 | { 18 | HANDLE handle; 19 | BOOL ret; 20 | unsigned long wrote; 21 | co_rc_t rc = CO_RC_OK; 22 | char last_error[0x100]; 23 | 24 | handle = CreateFile(pathname, 25 | GENERIC_WRITE, 26 | FILE_SHARE_READ, 27 | NULL, 28 | CREATE_ALWAYS, 29 | FILE_ATTRIBUTE_NORMAL, 30 | NULL); 31 | 32 | if (handle == INVALID_HANDLE_VALUE) { 33 | co_winnt_get_last_error(last_error, sizeof(last_error)); 34 | co_debug_error("Error creating file (%s): %s", pathname, last_error); 35 | return CO_RC(ERROR); 36 | } 37 | 38 | ret = WriteFile(handle, buf, size, &wrote, NULL); 39 | if (ret == 0 || size != wrote) { 40 | co_winnt_get_last_error(last_error, sizeof(last_error)); 41 | co_debug_error("Error write file %s: %s", pathname, last_error); 42 | rc = CO_RC(ERROR); 43 | } 44 | 45 | CloseHandle(handle); 46 | return rc; 47 | } 48 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/file.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | #include "misc.h" 17 | 18 | co_rc_t co_os_file_load(co_pathname_t pathname, char **out_buf, unsigned long *out_size, unsigned long max_size) 19 | { 20 | HANDLE handle; 21 | BOOL ret; 22 | unsigned long size, size_read, high; 23 | co_rc_t rc = CO_RC_OK; 24 | char *buf; 25 | 26 | handle = CreateFile(pathname, 27 | GENERIC_READ, 28 | FILE_SHARE_READ, 29 | NULL, 30 | OPEN_EXISTING, 31 | FILE_ATTRIBUTE_NORMAL, 32 | NULL); 33 | 34 | if (handle == INVALID_HANDLE_VALUE) { 35 | co_terminal_print_last_error(pathname); 36 | co_debug_error("Error opening file (%s)", pathname); 37 | rc = CO_RC(ERROR); 38 | goto out; 39 | } 40 | 41 | size = GetFileSize(handle, &high); 42 | 43 | if (max_size && (size > max_size || high)) 44 | size = max_size; 45 | 46 | buf = (char *)malloc(size); 47 | if (buf == NULL) { 48 | rc = CO_RC(OUT_OF_MEMORY); 49 | goto out2; 50 | } 51 | 52 | ret = ReadFile(handle, buf, size, &size_read, NULL); 53 | 54 | if (size != size_read) { 55 | co_terminal_print_last_error(pathname); 56 | co_debug_error("Error reading file %s, %lu != %lu", 57 | pathname, size, size_read); 58 | free(buf); 59 | rc = CO_RC(ERROR); 60 | goto out2; 61 | } 62 | 63 | *out_buf = buf; 64 | *out_size = size; 65 | 66 | out2: 67 | CloseHandle(handle); 68 | out: 69 | return rc; 70 | } 71 | 72 | void co_os_file_free(char *buf) 73 | { 74 | free(buf); 75 | } 76 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/install/WinpcapRedir.ini: -------------------------------------------------------------------------------- 1 | ; Ini file generated by the HM NIS Edit IO designer. 2 | [Settings] 3 | NumFields=3 4 | 5 | [Field 1] 6 | Type=Label 7 | Text=Cooperative Linux depends on the WinPCap library in order to provide Bridged Ethernet support. Please download and install WinPCap from one of the addresses below. 8 | Left=20 9 | Right=270 10 | Top=11 11 | Bottom=50 12 | 13 | [Field 2] 14 | Type=Link 15 | Text=http://www.winpcap.org/ 16 | State=http://www.winpcap.org/ 17 | Left=20 18 | Right=149 19 | Top=51 20 | Bottom=59 21 | 22 | [Field 3] 23 | Type=Link 24 | Text=http://www.winpcap.org/install/ 25 | State=http://www.winpcap.org/install/ 26 | Left=20 27 | Right=200 28 | Top=59 29 | Bottom=68 30 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/install/build.comake.py: -------------------------------------------------------------------------------- 1 | def script_cmdline(scripter, tool_run_inf): 2 | nsis_install_path = r"C:\Program Files\NSIS\makensis" 3 | command_line = 'wine "%s" /V3 %s' % ( 4 | nsis_install_path.replace("\\", "\\\\"), 5 | tool_run_inf.target.inputs[0].pathname) 6 | return command_line 7 | 8 | targets['coLinux.exe'] = Target( 9 | tool = Script(script_cmdline), 10 | inputs = [ 11 | Input('colinux.nsi'), 12 | Input('colinux_def.inc'), 13 | Input('WinpcapRedir.ini'), 14 | Input('iDl.ini'), 15 | Input('premaid/colinux-bridged-net-daemon.exe'), 16 | Input('premaid/colinux-console-fltk.exe'), 17 | Input('premaid/colinux-console-nt.exe'), 18 | Input('premaid/colinux-daemon.exe'), 19 | Input('premaid/colinux-net-daemon.exe'), 20 | Input('premaid/colinux-slirp-net-daemon.exe'), 21 | Input('premaid/linux.sys'), 22 | Input('premaid/README.txt'), 23 | Input('premaid/cofs.txt'), 24 | Input('premaid/colinux-daemon.txt'), 25 | Input('premaid/example.conf'), 26 | Input('premaid/vmlinux'), 27 | Input('premaid/vmlinux-modules.tar.gz'), 28 | Input('premaid/initrd.gz'), 29 | ], 30 | ) 31 | 32 | def script_cmdline(scripter, tool_run_inf): 33 | command_line = 'sh -c ". %s %s %s"' % ( 34 | tool_run_inf.target.inputs[0].pathname, 35 | tool_run_inf.target.inputs[1].pathname, 36 | tool_run_inf.target.pathname) 37 | return command_line 38 | 39 | targets['colinux_def.inc'] = Target( 40 | tool = Script(script_cmdline), 41 | inputs = [ 42 | Input('colinux_def.sh'), 43 | Input('src/colinux/VERSION', root_relative=True), 44 | ] 45 | ) 46 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/install/colinux_def.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This File exports the current version informations and 4 | # creates an NIS installer include file. 5 | 6 | # Remember: This file will be sourced from / as current directory. 7 | # Standard arguments for this script: 8 | # $1: src/colinux/VERSION 9 | # $2: src/colinux/os/winnt/user/install/colinux_def.inc 10 | 11 | VERSION_FILE=$1 12 | TARGET_FILE=$2 13 | 14 | # Fallback for dash with defaults 15 | test -z "$VERSION_FILE" && VERSION_FILE="src/colinux/VERSION" 16 | test -z "$TARGET_FILE" && TARGET_FILE="src/colinux/os/winnt/user/install/colinux_def.inc" 17 | 18 | # Get kernel version 19 | . bin/build-common.sh --get-vars 20 | 21 | # coLinux full version with "-preXX", if exist 22 | PRE_VERSION=`cat $VERSION_FILE` 23 | 24 | # coLinux standard version 25 | VERSION=`echo $PRE_VERSION | sed -e 's/\([^-]*\).*/\1/'` 26 | 27 | cat > $TARGET_FILE << EOF 28 | !define VERSION "$VERSION" 29 | !define LONGVERSION "$VERSION.1" 30 | !define PRE_VERSION "$PRE_VERSION" 31 | !define KERNEL_VERSION "$KERNEL_VERSION" 32 | EOF 33 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/install/header.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/da-x/colinux/aef3a72cb898b809962503fdfecea405672a753b/src/colinux/os/winnt/user/install/header.bmp -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/install/startlogo.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/da-x/colinux/aef3a72cb898b809962503fdfecea405672a753b/src/colinux/os/winnt/user/install/startlogo.bmp -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | */ 9 | 10 | #ifndef __COLINUX_USER_WINNT_MANAGER_H__ 11 | #define __COLINUX_USER_WINNT_MANAGER_H__ 12 | 13 | #include 14 | 15 | struct co_manager_handle { 16 | HANDLE handle; 17 | }; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2004 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __CO_OS_USER_WINNT_MISC_H__ 12 | #define __CO_OS_USER_WINNT_MISC_H__ 13 | 14 | #include 15 | 16 | extern bool_t co_winnt_get_last_error(char *error_message, int buf_size); 17 | extern void co_terminal_print_last_error(const char *message); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/process.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Henry Nestler, 2007 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | void co_process_high_priority_set(void) 17 | { 18 | if (!SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS)) 19 | co_terminal_print_last_error("SetPriorityClass"); 20 | } 21 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/reactor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_WINNT_USER_REACTOR_H__ 12 | #define __COLINUX_WINNT_USER_REACTOR_H__ 13 | 14 | #include 15 | 16 | struct co_reactor_os_user { 17 | HANDLE read_event; 18 | HANDLE write_event; 19 | bool_t read_enabled; 20 | bool_t write_enabled; 21 | 22 | co_rc_t (*read)(co_reactor_user_t user); 23 | void (*write)(co_reactor_user_t user); 24 | }; 25 | 26 | struct co_winnt_reactor_packet_user { 27 | struct co_reactor_user user; 28 | struct co_reactor_os_user os_user; 29 | HANDLE whandle; 30 | HANDLE rhandle; 31 | OVERLAPPED read_overlapped; 32 | OVERLAPPED write_overlapped; 33 | unsigned char buffer[0x10000]; 34 | unsigned long size; 35 | }; 36 | 37 | typedef struct co_winnt_reactor_packet_user *co_winnt_reactor_packet_user_t; 38 | 39 | extern co_rc_t co_winnt_reactor_packet_user_create( 40 | co_reactor_t reactor, HANDLE whandle, HANDLE rhandle, 41 | co_reactor_user_receive_func_t receive, 42 | co_winnt_reactor_packet_user_t *handle_out); 43 | 44 | extern void co_winnt_reactor_packet_user_destroy( 45 | co_winnt_reactor_packet_user_t user); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/colinux/os/winnt/user/udp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * Service support by Jaroslaw Kowalski , 2004 (c) 6 | * 7 | * The code is licensed under the GPL. See the COPYING file at 8 | * the root directory. 9 | * 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | int co_udp_socket_connect(const char *addr, unsigned short int port) 22 | { 23 | struct sockaddr_in server; 24 | int ret, sock; 25 | WSADATA wsaData; 26 | 27 | WSAStartup(MAKEWORD(2,2), &wsaData); 28 | 29 | sock = socket(AF_INET, SOCK_DGRAM, 0); 30 | if (sock == -1) { 31 | printf("unable to create socket %x\n", sock); 32 | return -1; 33 | } 34 | 35 | co_bzero((char *)&server, sizeof(server)); 36 | server.sin_family = AF_INET; 37 | server.sin_addr.s_addr = inet_addr(addr); 38 | server.sin_port = htons(port); 39 | 40 | ret = connect(sock, (struct sockaddr *)&server, sizeof(server)); 41 | if (ret) 42 | return -1; 43 | 44 | return sock; 45 | } 46 | 47 | int co_udp_socket_send(int sock, const char *buffer, unsigned long size) 48 | { 49 | return send(sock, buffer, size, 0); 50 | } 51 | 52 | void co_udp_socket_close(int sock) 53 | { 54 | closesocket(sock); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/colinux/user/README: -------------------------------------------------------------------------------- 1 | The code in this directory is the OS independant userspace code. 2 | 3 | It contains code that is responsible for: 4 | * Parsing and loading the vmlinux file 5 | * Communicating with the OS independant kernel code driver. 6 | * Managing the config file and XML. 7 | * Maintaining a link with the kernel driver. -------------------------------------------------------------------------------- /src/colinux/user/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['user.a'] = Target( 2 | inputs=input_list(".c", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/user/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_CORE_CONFIG_H__ 12 | #define __COLINUX_CORE_CONFIG_H__ 13 | 14 | #include 15 | #include 16 | 17 | #include "macaddress.h" 18 | 19 | extern co_rc_t co_parse_config_args(co_command_line_params_t cmdline, co_start_parameters_t *start_parameters); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /src/colinux/user/configurator/README: -------------------------------------------------------------------------------- 1 | The configuration util is currently a work in progress. 2 | 3 | In order to run the coLinux configurator, you need to install python 4 | 2.3. Windows users can use the installer from www.python.org. 5 | 6 | http://www.python.org/ftp/python/2.3.3/Python-2.3.3.exe 7 | 8 | The configuration util also depends on wxpython which can be obtained 9 | from http://www.wxpython.org: 10 | 11 | http://prdownloads.sourceforge.net/wxpython/wxPythonWIN32-2.5.1.5-Py23.exe 12 | -------------------------------------------------------------------------------- /src/colinux/user/console-fltk/about.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Nuno Lucas 2005 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | #include "about.h" 11 | extern "C" { 12 | #include 13 | } 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | // colinux_logo_3d_xpm data 20 | #include "img/colinux_logo_3d.xpm" 21 | 22 | /** 23 | * Class constructor. 24 | * Set up window layout. 25 | */ 26 | about_box::about_box( ) 27 | : super_( 200, 350, "About CoLinux Console..." ) 28 | { 29 | Fl_Pixmap* logo = new Fl_Pixmap( colinux_logo_3d_xpm ); 30 | 31 | Fl_Box * box = new Fl_Box( 10,10, 180,180 ); 32 | box->box( FL_PLASTIC_UP_BOX ); 33 | box->color( fl_rgb_color(206,224,230) ); // soft blue 34 | box->image( logo ); 35 | 36 | box = new Fl_Box( 10,200, 180,80 ); 37 | box->box( FL_THIN_DOWN_BOX ); 38 | box->labelsize( 14 ); 39 | box->labelfont( FL_HELVETICA_BOLD_ITALIC ); 40 | box->labeltype( FL_ENGRAVED_LABEL ); 41 | box->align( FL_ALIGN_CENTER|FL_ALIGN_INSIDE|FL_ALIGN_WRAP ); 42 | box->label( "C o L i n u x v " COLINUX_VERSION "\n" 43 | __DATE__ " " __TIME__ "\n" 44 | "\n" 45 | "http://www.colinux.org\n" ); 46 | 47 | Fl_Button * btn = new Fl_Button( 10,310, 180,30, "Close" ); 48 | btn->box( FL_PLASTIC_UP_BOX ); 49 | btn->callback( on_close, this ); 50 | 51 | end( ); 52 | } 53 | 54 | /** 55 | * Called on close button click. 56 | */ 57 | void about_box::on_close( Fl_Widget* w, void* v ) 58 | { 59 | about_box* this_ = reinterpret_cast( v ); 60 | Fl::delete_widget( this_ ); 61 | } 62 | -------------------------------------------------------------------------------- /src/colinux/user/console-fltk/about.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Nuno Lucas 2005 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | #ifndef __COLINUX_USER_ABOUT_BOX_H__ 11 | #define __COLINUX_USER_ABOUT_BOX_H__ 12 | 13 | #include 14 | #include 15 | 16 | /** 17 | * Simple About Box 18 | */ 19 | class about_box : public Fl_Window 20 | { 21 | typedef Fl_Window super_; 22 | public: 23 | // Initialize controls 24 | about_box( ); 25 | private: 26 | // On close button click 27 | static void on_close( Fl_Widget* w, void* v ); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/colinux/user/console-fltk/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.a'] = Target( 2 | inputs=input_list(".cpp", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/user/console-fltk/fontselect.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Shai Vaingast, 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | #ifndef __COLINUX_USER_FONT_SELECT_H__ 11 | #define __COLINUX_USER_FONT_SELECT_H__ 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define DISPLAY_STR \ 18 | "coLinux\n" \ 19 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" \ 20 | "abcdefghijklmnopqrstuvwxyz\n" \ 21 | "01234567890123456789012345\n" \ 22 | " !#$\%^&*()_+`~[]{}\\|/?.,><" 23 | bool is_fixed_pitch(Fl_Font test_font); 24 | class FontDisplay : public Fl_Widget 25 | { 26 | void draw(); 27 | public: 28 | FontDisplay(Fl_Boxtype B, int X, int Y, int W, int H, const char* L = 0): 29 | Fl_Widget(X,Y,W,H,L) {box(B); font = 0; size = 14;}; 30 | int get_size(void) { return size; } 31 | int get_font(void) { return font; } 32 | void set_font(int f) { font = f; } 33 | void set_size(int s) { size = s; } 34 | private: 35 | int font, size; 36 | }; 37 | 38 | class FontSelectDialog : public Fl_Window 39 | { 40 | public: 41 | FontSelectDialog(void*ptr, int def_font, int def_size); 42 | void click_font(void); 43 | void click_size(void); 44 | void *ptr_console; 45 | void populate_fonts(bool fixed_pitch, int def_font); 46 | FontDisplay *textobj; 47 | 48 | private: 49 | Fl_Hold_Browser *sizeobj; 50 | Fl_Hold_Browser *fontobj; 51 | int pickedsize, num_fonts; 52 | int **my_sizes; 53 | int *numsizes; 54 | int *lookup; 55 | char str_label[0x200]; 56 | 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/colinux/user/console-fltk/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include "console.h" 12 | 13 | static console_window_t* global_window = NULL; 14 | 15 | console_window_t* co_user_console_get_window(void) 16 | { 17 | return global_window; 18 | } 19 | 20 | void co_user_console_handle_scancode(co_scan_code_t sc) 21 | { 22 | if (!global_window) 23 | return; 24 | 25 | global_window->handle_scancode(sc); 26 | } 27 | 28 | int co_user_console_main(int argc, char** argv) 29 | { 30 | co_rc_t rc; 31 | console_window_t window; 32 | int ret; 33 | 34 | global_window = &window; 35 | 36 | co_debug_start(); 37 | 38 | rc = window.parse_args(argc, argv); 39 | if (!CO_OK(rc)) { 40 | co_debug("Error %08x parsing parameters", (int)rc); 41 | ret = -1; 42 | goto out; 43 | } 44 | 45 | rc = window.start(); 46 | if (!CO_OK(rc)) { 47 | co_debug("Error %08x starting console", (int)rc); 48 | ret = -1; 49 | goto out; 50 | } 51 | 52 | ret = Fl::run(); 53 | out: 54 | co_debug_end(); 55 | 56 | return ret; 57 | } 58 | -------------------------------------------------------------------------------- /src/colinux/user/console-fltk/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_CONSOLE_MAIN_H__ 12 | #define __COLINUX_USER_CONSOLE_MAIN_H__ 13 | 14 | #include 15 | #include "console.h" 16 | 17 | enum REGISTRY_PARAMS { REGISTRY_FONT, REGISTRY_FONT_SIZE, REGISTRY_COPYSPACES, 18 | REGISTRY_EXITDETACH }; 19 | extern int co_user_console_main(int argc, char **argv); 20 | extern void co_user_console_handle_scancode(co_scan_code_t sc); 21 | extern void co_user_console_keyboard_focus_change(unsigned long keyboard_focus); 22 | console_window_t* co_user_console_get_window(void); 23 | extern int PasteClipboardIntoColinux(void); 24 | extern int CopyLinuxIntoClipboard(void); 25 | extern int ReadRegistry(int key); 26 | extern int WriteRegistry(int key, int new_value); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/colinux/user/console-fltk/select_monitor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_SELECT_MONITOR_H__ 12 | #define __COLINUX_USER_SELECT_MONITOR_H__ 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | extern "C" { 20 | #include 21 | #include 22 | #include 23 | } 24 | 25 | class select_monitor_widget_t : public Fl_Double_Window { 26 | public: 27 | select_monitor_widget_t(int w, int h, const char *label = 0) 28 | : Fl_Double_Window(w, h, label), id_map_count(0) {}; 29 | select_monitor_widget_t(int x, int y, int w, int h, const char *label = 0) 30 | : Fl_Double_Window(x, y, w, h, label), id_map_count(0) {}; 31 | 32 | void on_button(Fl_Widget *widget); 33 | void populate(class console_window_t *console_window); 34 | void load_monitors_list(); 35 | 36 | protected: 37 | Fl_Button * select_button; 38 | Fl_Button * cancel_button; 39 | Fl_Hold_Browser * browser; 40 | co_id_t id_map[CO_MAX_MONITORS]; 41 | int id_map_count; 42 | console_window_t * console; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/colinux/user/console-nt/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.a'] = Target( 2 | inputs=input_list(".cpp", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/user/console-nt/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2005 (c) 5 | * Ballard, Jonathan H. , 2004 (c) 6 | * 7 | * The code is licensed under the GPL. See the COPYING file at 8 | * the root directory. 9 | * 10 | */ 11 | 12 | #ifndef __COLINUX_USER_CONSOLE_H__ 13 | #define __COLINUX_USER_CONSOLE_H__ 14 | 15 | extern "C" { 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | } 22 | 23 | #include "widget.h" 24 | 25 | typedef struct co_console_start_parameters { 26 | co_id_t attach_id; 27 | } co_console_start_parameters_t; 28 | 29 | class console_window_t { 30 | public: 31 | console_window_t(); 32 | virtual ~console_window_t(); 33 | 34 | co_rc_t parse_args(int argc, char **argv); 35 | co_rc_t start(); 36 | 37 | co_rc_t attach(); 38 | co_rc_t detach(); 39 | 40 | void event(co_message_t *message); 41 | 42 | void handle_scancode(const co_scan_code_t sc) const; 43 | co_rc_t send_ctrl_alt_del(); 44 | void syntax(); 45 | 46 | virtual const char *get_name(); 47 | 48 | void log(const char *format, ...) const; 49 | bool_t is_attached() { return attached ; }; 50 | 51 | co_rc_t loop(); 52 | 53 | protected: 54 | co_console_start_parameters_t start_parameters; 55 | console_widget_t *widget; 56 | co_id_t instance_id; 57 | co_reactor_t reactor; 58 | co_user_monitor_t *message_monitor; 59 | bool_t attached; 60 | 61 | static co_rc_t message_receive(co_reactor_user_t user, unsigned char *buffer, unsigned long size); 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/colinux/user/console-nt/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | /* 12 | * OS independent main program for the text mode console. 13 | * Used for building colinux-console-nt.exe 14 | */ 15 | 16 | #include "console.h" 17 | #include "main.h" 18 | 19 | extern "C" { 20 | #include 21 | } 22 | 23 | console_window_t* global_window = NULL; 24 | 25 | void co_user_console_handle_scancode(co_scan_code_t sc) 26 | { 27 | if (global_window == NULL) 28 | return; 29 | 30 | global_window->handle_scancode(sc); 31 | } 32 | 33 | int co_user_console_main(int argc, char** argv) 34 | { 35 | co_rc_t rc; 36 | 37 | co_debug_start(); 38 | 39 | rc = global_window->parse_args(argc, argv); 40 | if (!CO_OK(rc)) { 41 | co_debug("The console program was unable to parse the parameters."); 42 | goto co_user_console_main_error; 43 | } 44 | 45 | rc = global_window->start(); 46 | if (!CO_OK(rc)) { 47 | co_debug("The console program could not start."); 48 | goto co_user_console_main_error; 49 | } 50 | 51 | do { 52 | rc = global_window->loop(); 53 | } while (CO_OK(rc) && global_window->is_attached()); 54 | 55 | if (global_window->is_attached()) 56 | global_window->detach(); 57 | 58 | if (CO_OK(rc)) { 59 | co_debug_end(); 60 | return 0; 61 | } 62 | 63 | co_user_console_main_error: 64 | co_debug("The console program encountered an error: %08x", (int)rc); 65 | 66 | co_debug_end(); 67 | 68 | global_window = 0; 69 | 70 | return -1; 71 | } 72 | -------------------------------------------------------------------------------- /src/colinux/user/console-nt/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_CONSOLE_BASE_MAIN_H__ 12 | #define __COLINUX_USER_CONSOLE_BASE_MAIN_H__ 13 | 14 | #include "console.h" 15 | 16 | extern console_window_t *global_window; 17 | extern int co_user_console_main(int argc, char **argv); 18 | extern void co_user_console_handle_scancode(co_scan_code_t sc); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/colinux/user/console-wx/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=input_list(".cpp", ".o"), 3 | options = Options( 4 | appenders = dict( 5 | compiler_flags = [ '`wx-config --cxxflags`' ], 6 | compiler_defines = dict( 7 | WINVER='0x0400', 8 | __GNUWIN32__=None, 9 | __WIN95__=None, 10 | STRICT=None, 11 | HAVE_W32API_H=None, 12 | __WXMSW__=None, 13 | __WINDOWS__=None, 14 | ), 15 | ) 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /src/colinux/user/console-wx/console.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __WXCONSOLE_H 3 | #define __WXCONSOLE_H 4 | 5 | class MyApp : public wxApp 6 | { 7 | public: 8 | virtual bool OnInit(); 9 | }; 10 | 11 | class MyFrame : public wxFrame 12 | { 13 | public: 14 | MyFrame(const wxString& title); 15 | 16 | void OnQuit(wxCommandEvent& event); 17 | void OnAbout(wxCommandEvent& event); 18 | 19 | private: 20 | DECLARE_EVENT_TABLE() 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/colinux/user/context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_CONTEXT_H__ 12 | #define __COLINUX_USER_CONTEXT_H__ 13 | 14 | typedef void *alloc_context_t; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/colinux/user/control/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/da-x/colinux/aef3a72cb898b809962503fdfecea405672a753b/src/colinux/user/control/main.c -------------------------------------------------------------------------------- /src/colinux/user/daemon-base/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.a'] = Target( 2 | inputs=input_list(".cpp", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/user/debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | #include "debug.h" 18 | 19 | #ifdef COLINUX_DEBUG 20 | static co_manager_handle_t handle = NULL; 21 | 22 | void co_debug_start(void) 23 | { 24 | if (handle != NULL) 25 | return; 26 | 27 | handle = co_os_manager_open_quite(); 28 | if (handle) { 29 | co_rc_t rc; 30 | co_manager_ioctl_debug_levels_t levels = {{0}, }; 31 | levels.modify = PFALSE; 32 | 33 | rc = co_manager_debug_levels(handle, &levels); 34 | if (CO_OK(rc)) { 35 | co_global_debug_levels = levels.levels; 36 | } 37 | } 38 | } 39 | 40 | void co_debug_buf(const char *buf, long size) 41 | { 42 | if (handle != NULL) 43 | co_manager_debug(handle, buf, size); 44 | } 45 | 46 | void co_debug_end(void) 47 | { 48 | co_manager_handle_t saved_handle = handle; 49 | 50 | handle = NULL; 51 | 52 | if (saved_handle != NULL) 53 | co_os_manager_close(saved_handle); 54 | } 55 | 56 | void co_debug_level_system(const char *module, co_debug_facility_t facility, int level, 57 | const char *filename, int line, const char *func, const char *text) 58 | { 59 | if (facility == CO_DEBUG_FACILITY_misc) { 60 | int len = strlen(text); 61 | char *format = (len > 0 && text[len-1] == '\n') ? "%s" : "%s\n"; 62 | 63 | /* Warning: co_terminal_print here, would be recursive */ 64 | fprintf(stderr, format, text); 65 | } 66 | } 67 | #else 68 | void co_debug_start(void) { return; } 69 | void co_debug_end(void) { return; } 70 | #endif 71 | -------------------------------------------------------------------------------- /src/colinux/user/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_DEBUG_H__ 12 | #define __COLINUX_USER_DEBUG_H__ 13 | 14 | #include 15 | 16 | extern void co_daemon_trace_point(co_trace_point_info_t *info); 17 | extern void co_debug_start(void); 18 | extern void co_debug_end(void); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /src/colinux/user/debug/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=input_list(".c", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/user/debug/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_DEBUG_MAIN_H__ 12 | #define __COLINUX_USER_DEBUG_MAIN_H__ 13 | 14 | extern co_rc_t co_debug_main(int argc, char *argv[]); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /src/colinux/user/debug/server.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from socket import * 4 | import struct, time, sys 5 | 6 | log = open(sys.argv[1], "a+b") 7 | s = socket(AF_INET, SOCK_DGRAM, 0) 8 | s.bind(("0.0.0.0", 63000)) 9 | while 1: 10 | data, address = s.recvfrom(0x100) 11 | if len(data) == 0: 12 | break 13 | log.write(data) 14 | -------------------------------------------------------------------------------- /src/colinux/user/elf_load.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_ELF_LOAD_H__ 12 | #define __COLINUX_USER_ELF_LOAD_H__ 13 | 14 | #include 15 | 16 | typedef struct co_elf_data co_elf_data_t; 17 | typedef struct co_elf_symbol co_elf_symbol_t; 18 | 19 | struct co_daemon; 20 | 21 | extern co_rc_t co_elf_image_read(co_elf_data_t **pl, void *elf_buf, unsigned long size); 22 | extern co_rc_t co_elf_image_load(struct co_daemon *daemon); 23 | extern co_elf_symbol_t *co_get_symbol_by_name(co_elf_data_t *pl, const char *name); 24 | extern void *co_elf_get_symbol_data(co_elf_data_t *pl, co_elf_symbol_t *symbol); 25 | extern unsigned long co_elf_get_symbol_value(co_elf_symbol_t *symbol); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/colinux/user/macaddress.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "macaddress.h" 15 | 16 | co_rc_t co_parse_mac_address(const char *text, unsigned char *binary) 17 | { 18 | int ret, i; 19 | unsigned int mac[6]; 20 | 21 | if (strlen(text) != 17) 22 | return CO_RC(INVALID_PARAMETER); 23 | 24 | ret = sscanf(text, "%02x:%02x:%02x:%02x:%02x:%02x", 25 | &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]); 26 | 27 | for (i=0; i < 6; i++) 28 | binary[i] = mac[i]; 29 | 30 | if (ret != 6) 31 | return CO_RC(INVALID_PARAMETER); 32 | 33 | return CO_RC(OK); 34 | } 35 | 36 | void co_build_mac_address(char *text, int ntext, const unsigned char *mac) 37 | { 38 | snprintf(text, ntext, "%02x:%02x:%02x:%02x:%02x:%02x", 39 | (unsigned int)mac[0], 40 | (unsigned int)mac[1], 41 | (unsigned int)mac[2], 42 | (unsigned int)mac[3], 43 | (unsigned int)mac[4], 44 | (unsigned int)mac[5]); 45 | } 46 | -------------------------------------------------------------------------------- /src/colinux/user/macaddress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_MACADDRESS_H__ 12 | #define __COLINUX_USER_MACADDRESS_H__ 13 | 14 | #include 15 | 16 | extern co_rc_t co_parse_mac_address(const char *text, unsigned char *binary); 17 | extern void co_build_mac_address(char *text, int ntext, const unsigned char *mac); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/colinux/user/manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_MANAGER_H__ 12 | #define __COLINUX_USER_MANAGER_H__ 13 | 14 | #include 15 | #include 16 | 17 | extern co_rc_t co_manager_io_monitor(co_manager_handle_t handle, 18 | co_monitor_ioctl_op_t op, 19 | co_manager_ioctl_monitor_t *ioctl, 20 | unsigned long in_size, 21 | unsigned long out_size); 22 | 23 | extern co_rc_t co_manager_io_monitor_unisize(co_manager_handle_t handle, 24 | co_monitor_ioctl_op_t op, 25 | co_manager_ioctl_monitor_t *ioctl, 26 | unsigned long size); 27 | 28 | extern co_rc_t co_manager_status(co_manager_handle_t handle, 29 | co_manager_ioctl_status_t *status); 30 | 31 | extern co_rc_t co_manager_info(co_manager_handle_t handle, 32 | co_manager_ioctl_info_t *status); 33 | 34 | extern void co_manager_debug(co_manager_handle_t handle, 35 | const char *buf, long size); 36 | 37 | extern co_rc_t co_manager_debug_reader(co_manager_handle_t handle, 38 | co_manager_ioctl_debug_reader_t *debug_reader); 39 | 40 | #ifdef COLINUX_DEBUG 41 | extern co_rc_t co_manager_debug_levels(co_manager_handle_t handle, 42 | co_manager_ioctl_debug_levels_t *levels); 43 | #endif 44 | 45 | extern co_rc_t co_manager_attach(co_manager_handle_t handle, co_manager_ioctl_attach_t *params); 46 | 47 | co_rc_t co_manager_monitor_list( co_manager_handle_t handle, co_manager_ioctl_monitor_list_t *list ); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /src/colinux/user/monitor-find.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "monitor.h" 5 | #include "manager.h" 6 | 7 | /** 8 | * Returns PID of first monitor. 9 | * 10 | * If none found, returns CO_INVALID_ID. 11 | * 12 | * TODO: Find first monitor not already attached. 13 | */ 14 | co_id_t find_first_monitor(void) 15 | { 16 | co_manager_handle_t handle; 17 | co_manager_ioctl_monitor_list_t list; 18 | co_rc_t rc; 19 | 20 | handle = co_os_manager_open(); 21 | if (handle == NULL) 22 | return CO_INVALID_ID; 23 | 24 | rc = co_manager_monitor_list(handle, &list); 25 | co_os_manager_close(handle); 26 | if (!CO_OK(rc) || list.count == 0) 27 | return CO_INVALID_ID; 28 | 29 | return list.ids[0]; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /src/colinux/user/pidfile.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "monitor.h" 21 | 22 | 23 | co_rc_t read_pid_from_file(co_pathname_t pathname, co_id_t *id) 24 | { 25 | char *buf; 26 | unsigned long size; 27 | co_rc_t rc; 28 | 29 | co_remove_quotation_marks(pathname); 30 | 31 | rc = co_os_file_load(pathname, &buf, &size, 32); 32 | if (!CO_OK(rc)) 33 | return rc; 34 | 35 | if (size > 0) { 36 | *id = atoi(buf); 37 | co_debug("pid %d from file", (int)*id); 38 | } else { 39 | co_debug("file '%s' to small or unreadable", pathname); 40 | rc = CO_RC(INVALID_PARAMETER); 41 | } 42 | 43 | co_os_file_free(buf); 44 | return rc; 45 | } 46 | -------------------------------------------------------------------------------- /src/colinux/user/reactor.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | co_rc_t co_reactor_create(co_reactor_t *out_handle) 6 | { 7 | co_reactor_t reactor; 8 | 9 | reactor = co_os_malloc(sizeof(*reactor)); 10 | if (!reactor) 11 | return CO_RC(OUT_OF_MEMORY); 12 | 13 | co_memset(reactor, 0, sizeof(*reactor)); 14 | 15 | co_list_init(&reactor->users); 16 | 17 | *out_handle = reactor; 18 | 19 | return CO_RC(OK); 20 | } 21 | 22 | co_rc_t co_reactor_select(co_reactor_t reactor, int miliseconds) 23 | { 24 | return co_os_reactor_select(reactor, miliseconds); 25 | } 26 | 27 | void co_reactor_add(co_reactor_t reactor, co_reactor_user_t user) 28 | { 29 | co_list_add_head(&user->node, &reactor->users); 30 | reactor->num_users += 1; 31 | user->reactor = reactor; 32 | } 33 | 34 | void co_reactor_remove(co_reactor_user_t user) 35 | { 36 | user->reactor->num_users -= 1; 37 | co_list_del(&user->node); 38 | } 39 | 40 | void co_reactor_destroy(co_reactor_t reactor) 41 | { 42 | co_os_free(reactor); 43 | } 44 | 45 | -------------------------------------------------------------------------------- /src/colinux/user/reactor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This source code is a part of coLinux source package. 3 | * 4 | * Dan Aloni , 2003 (c) 5 | * 6 | * The code is licensed under the GPL. See the COPYING file at 7 | * the root directory. 8 | * 9 | */ 10 | 11 | #ifndef __COLINUX_USER_REACTOR_H__ 12 | #define __COLINUX_USER_REACTOR_H__ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | struct co_reactor_os_user; 19 | typedef struct co_reactor_os_user *co_reactor_os_user_t; 20 | 21 | struct co_reactor_user; 22 | typedef struct co_reactor_user *co_reactor_user_t; 23 | 24 | typedef struct co_reactor *co_reactor_t; 25 | 26 | typedef co_rc_t (*co_reactor_user_receive_func_t)(co_reactor_user_t user, unsigned char *buffer, unsigned long size); 27 | typedef co_rc_t (*co_reactor_user_send_func_t)(co_reactor_user_t user, unsigned char *buffer, unsigned long size); 28 | 29 | struct co_reactor_user { 30 | co_list_t node; 31 | co_reactor_os_user_t os_data; 32 | void *private_data; 33 | co_reactor_t reactor; 34 | co_rc_t last_read_rc; 35 | 36 | co_reactor_user_receive_func_t received; 37 | co_reactor_user_send_func_t send; 38 | }; 39 | 40 | struct co_reactor { 41 | co_list_t users; 42 | unsigned long num_users; 43 | }; 44 | 45 | extern co_rc_t co_reactor_create(co_reactor_t *out_handle); 46 | extern co_rc_t co_reactor_select(co_reactor_t handle, int miliseconds); 47 | extern void co_reactor_add(co_reactor_t handle, co_reactor_user_t user); 48 | extern void co_reactor_remove(co_reactor_user_t user); 49 | extern void co_reactor_destroy(co_reactor_t handle); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/build.comake.py: -------------------------------------------------------------------------------- 1 | targets['build.o'] = Target( 2 | inputs=input_list(".c", ".o"), 3 | ) 4 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/co_main.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef _WIN32 3 | #define strncasecmp memicmp 4 | #endif 5 | 6 | co_rc_t co_slirp_mutex_init (void); 7 | void co_slirp_mutex_destroy (void); 8 | void co_slirp_mutex_lock (void); 9 | void co_slirp_mutex_unlock (void); 10 | 11 | co_rc_t co_slirp_main(int argc, char *argv[]); 12 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/config.h: -------------------------------------------------------------------------------- 1 | /* Placefolder file for QEMU's config.h */ 2 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/ctl.h: -------------------------------------------------------------------------------- 1 | #define CTL_CMD 0 2 | #define CTL_EXEC 1 3 | #define CTL_ALIAS 2 4 | #define CTL_DNS 3 5 | #define CTL_CLIENT 15 6 | 7 | #define CTL_SPECIAL "10.0.2.0" 8 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1995 Danny Gasparovski. 3 | * 4 | * Please read the file COPYRIGHT for the 5 | * terms and conditions of the copyright. 6 | */ 7 | 8 | #define PRN_STDERR 1 9 | #define PRN_SPRINTF 2 10 | 11 | extern FILE *dfd; 12 | extern FILE *lfd; 13 | extern int dostats; 14 | extern int slirp_debug; 15 | 16 | #define DBG_CALL 0x1 17 | #define DBG_MISC 0x2 18 | #define DBG_ERROR 0x4 19 | #define DEBUG_DEFAULT DBG_CALL|DBG_MISC|DBG_ERROR 20 | 21 | #ifdef DEBUG 22 | #define DEBUG_CALL(x) if (slirp_debug & DBG_CALL) { fprintf(dfd, "%s...\n", x); fflush(dfd); } 23 | #define DEBUG_ARG(x, y) if (slirp_debug & DBG_CALL) { fputc(' ', dfd); fprintf(dfd, x, y); fputc('\n', dfd); fflush(dfd); } 24 | #define DEBUG_ARGS(x) if (slirp_debug & DBG_CALL) { fprintf x ; fflush(dfd); } 25 | #define DEBUG_MISC(x) if (slirp_debug & DBG_MISC) { fprintf x ; fflush(dfd); } 26 | #define DEBUG_ERROR(x) if (slirp_debug & DBG_ERROR) {fprintf x ; fflush(dfd); } 27 | 28 | 29 | #else 30 | 31 | #define DEBUG_CALL(x) 32 | #define DEBUG_ARG(x, y) 33 | #define DEBUG_ARGS(x) 34 | #define DEBUG_MISC(x) 35 | #define DEBUG_ERROR(x) 36 | 37 | #endif 38 | 39 | void debug_init _P((char *, int)); 40 | //void ttystats _P((struct ttys *)); 41 | void allttystats _P((void)); 42 | void ipstats _P((void)); 43 | void vjstats _P((void)); 44 | void tcpstats _P((void)); 45 | void udpstats _P((void)); 46 | void icmpstats _P((void)); 47 | void mbufstats _P((void)); 48 | void sockstats _P((void)); 49 | void slirp_exit _P((int)); 50 | 51 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1995 Danny Gasparovski. 3 | * 4 | * Please read the file COPYRIGHT for the 5 | * terms and conditions of the copyright. 6 | */ 7 | 8 | #ifndef _IF_H_ 9 | #define _IF_H_ 10 | 11 | #define IF_COMPRESS 0x01 /* We want compression */ 12 | #define IF_NOCOMPRESS 0x02 /* Do not do compression */ 13 | #define IF_AUTOCOMP 0x04 /* Autodetect (default) */ 14 | #define IF_NOCIDCOMP 0x08 /* CID compression */ 15 | 16 | /* Needed for FreeBSD */ 17 | #undef if_mtu 18 | extern int if_mtu; 19 | extern int if_mru; /* MTU and MRU */ 20 | extern int if_comp; /* Flags for compression */ 21 | extern int if_maxlinkhdr; 22 | extern int if_queued; /* Number of packets queued so far */ 23 | extern int if_thresh; /* Number of packets queued before we start sending 24 | * (to prevent allocing too many mbufs) */ 25 | 26 | extern struct mbuf if_fastq; /* fast queue (for interactive data) */ 27 | extern struct mbuf if_batchq; /* queue for non-interactive data */ 28 | extern struct mbuf *next_m; 29 | 30 | #define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm)) 31 | 32 | /* Interface statistics */ 33 | struct slirp_ifstats { 34 | u_int out_pkts; /* Output packets */ 35 | u_int out_bytes; /* Output bytes */ 36 | u_int out_errpkts; /* Output Error Packets */ 37 | u_int out_errbytes; /* Output Error Bytes */ 38 | u_int in_pkts; /* Input packets */ 39 | u_int in_bytes; /* Input bytes */ 40 | u_int in_errpkts; /* Input Error Packets */ 41 | u_int in_errbytes; /* Input Error Bytes */ 42 | 43 | u_int bytes_saved; /* Number of bytes that compression "saved" */ 44 | /* ie: number of bytes that didn't need to be sent over the link 45 | * because of compression */ 46 | 47 | u_int in_mbad; /* Bad incoming packets */ 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/libslirp.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBSLIRP_H 2 | #define _LIBSLIRP_H 3 | 4 | #ifdef _WIN32 5 | #include 6 | int inet_aton(const char *cp, struct in_addr *ia); 7 | #include 8 | #else 9 | #include 10 | #include 11 | #endif 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | void slirp_init(void); 18 | 19 | void slirp_select_fill(int *pnfds, 20 | fd_set *readfds, fd_set *writefds, fd_set *xfds); 21 | 22 | void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds); 23 | 24 | void slirp_input(const uint8_t *pkt, int pkt_len); 25 | 26 | /* you must provide the following functions: */ 27 | int slirp_can_output(void); 28 | void slirp_output(const uint8_t *pkt, int pkt_len); 29 | 30 | int slirp_redir(int is_udp, int host_port, 31 | struct in_addr guest_addr, int guest_port); 32 | 33 | extern const char *tftp_prefix; 34 | extern char slirp_hostname[33]; 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/main.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1995 Danny Gasparovski. 3 | * 4 | * Please read the file COPYRIGHT for the 5 | * terms and conditions of the copyright. 6 | */ 7 | 8 | #ifdef HAVE_SYS_SELECT_H 9 | #include 10 | #endif 11 | 12 | #define TOWRITEMAX 512 13 | 14 | extern struct timeval tt; 15 | extern int link_up; 16 | extern int slirp_socket; 17 | extern int slirp_socket_unit; 18 | extern int slirp_socket_port; 19 | extern u_int32_t slirp_socket_addr; 20 | extern char *slirp_socket_passwd; 21 | extern int ctty_closed; 22 | 23 | /* 24 | * Get the difference in 2 times from updtim() 25 | * Allow for wraparound times, "just in case" 26 | * x is the greater of the 2 (current time) and y is 27 | * what it's being compared against. 28 | */ 29 | #define TIME_DIFF(x,y) (x)-(y) < 0 ? ~0-(y)+(x) : (x)-(y) 30 | 31 | extern char *slirp_tty; 32 | extern char *exec_shell; 33 | extern u_int curtime; 34 | extern fd_set *global_readfds, *global_writefds, *global_xfds; 35 | extern struct in_addr ctl_addr; 36 | extern struct in_addr special_addr; 37 | extern struct in_addr alias_addr; 38 | extern struct in_addr our_addr; 39 | extern struct in_addr loopback_addr; 40 | extern char *username; 41 | extern char *socket_path; 42 | extern int towrite_max; 43 | extern int ppp_exit; 44 | extern int so_options; 45 | extern int tcp_keepintvl; 46 | extern uint8_t client_ethaddr[6]; 47 | 48 | #define PROTO_SLIP 0x1 49 | #ifdef USE_PPP 50 | #define PROTO_PPP 0x2 51 | #endif 52 | 53 | void if_encap(const uint8_t *ip_data, int ip_data_len); 54 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/sbuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1995 Danny Gasparovski. 3 | * 4 | * Please read the file COPYRIGHT for the 5 | * terms and conditions of the copyright. 6 | */ 7 | 8 | #ifndef _SBUF_H_ 9 | #define _SBUF_H_ 10 | 11 | #define sbflush(sb) sbdrop((sb),(sb)->sb_cc) 12 | #define sbspace(sb) ((sb)->sb_datalen - (sb)->sb_cc) 13 | 14 | struct sbuf { 15 | u_int sb_cc; /* actual chars in buffer */ 16 | u_int sb_datalen; /* Length of data */ 17 | char *sb_wptr; /* write pointer. points to where the next 18 | * bytes should be written in the sbuf */ 19 | char *sb_rptr; /* read pointer. points to where the next 20 | * byte should be read from the sbuf */ 21 | char *sb_data; /* Actual data */ 22 | }; 23 | 24 | void sbfree _P((struct sbuf *)); 25 | void sbdrop _P((struct sbuf *, int)); 26 | void sbreserve _P((struct sbuf *, int)); 27 | void sbappend _P((struct socket *, struct mbuf *)); 28 | void sbappendsb _P((struct sbuf *, struct mbuf *)); 29 | void sbcopy _P((struct sbuf *, int, int, char *)); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /src/colinux/user/slirp/tcp_subr.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/da-x/colinux/aef3a72cb898b809962503fdfecea405672a753b/src/colinux/user/slirp/tcp_subr.c -------------------------------------------------------------------------------- /src/colinux/user/slirp/tftp.h: -------------------------------------------------------------------------------- 1 | /* tftp defines */ 2 | 3 | #ifdef EMULATE_TFTP_SERVER 4 | #define TFTP_SESSIONS_MAX 3 5 | 6 | #define TFTP_SERVER 69 7 | 8 | #define TFTP_RRQ 1 9 | #define TFTP_WRQ 2 10 | #define TFTP_DATA 3 11 | #define TFTP_ACK 4 12 | #define TFTP_ERROR 5 13 | 14 | #define TFTP_FILENAME_MAX 512 15 | 16 | struct tftp_t { 17 | struct ip ip; 18 | struct udphdr udp; 19 | u_int16_t tp_op; 20 | union { 21 | struct { 22 | u_int16_t tp_block_nr; 23 | u_int8_t tp_buf[512]; 24 | } tp_data; 25 | struct { 26 | u_int16_t tp_error_code; 27 | u_int8_t tp_msg[512]; 28 | } tp_error; 29 | u_int8_t tp_buf[512 + 2]; 30 | } x; 31 | }; 32 | 33 | void tftp_input(struct mbuf *m); 34 | #endif /* EMULATE_TFTP_SERVER */ 35 | -------------------------------------------------------------------------------- /src/intro: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo " 4 | Cooperative Linux support code build system 5 | ------------------------------------------- 6 | 7 | Defaults 8 | 9 | The build defaults to the '$COLINUX_HOST_OS_DEFAULT' OS under the '$COLINUX_ARCH_DEFAULT' architecture. 10 | You can override this by setting COLINUX_ARCH and COLINUX_HOST_OS. 11 | 12 | The colinux/arch/current and colinux/os/current symlinks are updated 13 | automatically according to COLINUX_ARCH and COLINUX_HOST_OS. 14 | 15 | Windows port COLINUX_ARCH=i386 COLINUX_HOST_OS=winnt 16 | 17 | Basically, it's: 18 | 19 | make colinux 20 | 21 | See the Makefile in the colinux/os/winnt/build directory. 22 | 23 | Linux port COLINUX_HOST_OS=linux 24 | 25 | Also needed is the path to the sources of the target kernel. 26 | Currently only 2.6.3 and above are supported. 27 | 28 | COLINUX_HOST_KERNEL_DIR=/path/to/your/kernel/tree 29 | 30 | Or: 31 | 32 | COLINUX_HOST_KERNEL_DIR=/lib/modules/\`uname -r\`/build 33 | 34 | " 35 | 36 | --------------------------------------------------------------------------------