├── .gitignore ├── CHANGES ├── COPYING ├── Makefile ├── Makefile.cross ├── Makefile.linux ├── README ├── TODO ├── build ├── ar.inf ├── as.inf ├── bootdisk.lst ├── bootnet.lst ├── cc.inf ├── clib.inf ├── cmds.inf ├── ctohtml.inf ├── edit.inf ├── exclrel.lst ├── fdisk.inf ├── floppy.lst ├── ftpd.inf ├── genvmdk.inf ├── group ├── hdmin.lst ├── httpd.inf ├── impdef.inf ├── krnl.ini ├── login.inf ├── make.inf ├── minbootdisk.lst ├── mkboot.inf ├── mkbootdisk.cmd ├── mkbootdisk.sh ├── msh.inf ├── os.ini ├── osnet.ini ├── ossdk.ini ├── passwd ├── pkg.inf ├── rc ├── release.sh ├── sanos.dep ├── sanos.inf ├── sdk.inf ├── sdkdisk.lst ├── setup.inf ├── setup.ini ├── sh.inf ├── sys.inf ├── telnetd.inf ├── win32.inf └── winebuild.cmd ├── doc ├── jbox-df.ppt ├── jbox-intel.ppt ├── jbox-jaoo.ppt ├── jbox-mws.ppt ├── libc.txt ├── sanos-logo.txt └── sanostech.ppt ├── sanos-kvm ├── sdk ├── packages │ ├── nasm-2.09.10.zip │ └── tcc-0.9.24.tar.gz └── src │ ├── as │ ├── Makefile │ ├── assemble.c │ ├── assemble.h │ ├── compiler.h │ ├── crc64.c │ ├── directiv.c │ ├── directiv.h │ ├── eval.c │ ├── eval.h │ ├── exprlib.c │ ├── float.c │ ├── float.h │ ├── hashtbl.c │ ├── hashtbl.h │ ├── ilog2.c │ ├── insns.h │ ├── insnsa.c │ ├── insnsb.c │ ├── insnsi.h │ ├── inttypes.h │ ├── labels.c │ ├── labels.h │ ├── listing.c │ ├── listing.h │ ├── macros.c │ ├── nasm.c │ ├── nasm.h │ ├── nasmlib.c │ ├── nasmlib.h │ ├── opflags.h │ ├── output │ │ ├── dwarf.h │ │ ├── elf.h │ │ ├── nulldbg.c │ │ ├── nullout.c │ │ ├── outbin.c │ │ ├── outcoff.c │ │ ├── outdbg.c │ │ ├── outelf.c │ │ ├── outelf.h │ │ ├── outelf32.c │ │ ├── outform.c │ │ ├── outform.h │ │ ├── outlib.c │ │ ├── outlib.h │ │ ├── outobj.c │ │ ├── pecoff.h │ │ └── stabs.h │ ├── parser.c │ ├── parser.h │ ├── pptok.c │ ├── pptok.h │ ├── preproc.c │ ├── preproc.h │ ├── quote.c │ ├── quote.h │ ├── raa.c │ ├── raa.h │ ├── rbtree.c │ ├── rbtree.h │ ├── regflags.c │ ├── regs.h │ ├── regvals.c │ ├── saa.c │ ├── saa.h │ ├── snprintf.c │ ├── stdscan.c │ ├── stdscan.h │ ├── strfunc.c │ ├── strlcpy.c │ ├── tables.h │ ├── tokens.h │ ├── tokhash.c │ ├── ver.c │ ├── version.h │ └── vsnprintf.c │ ├── cc │ ├── Makefile │ ├── asm.c │ ├── asm386.c │ ├── cc.c │ ├── cc.h │ ├── codegen.c │ ├── codegen386.c │ ├── compiler.c │ ├── config.h │ ├── elf.c │ ├── elf.h │ ├── opcodes.h │ ├── pe.c │ ├── preproc.c │ ├── symbol.c │ ├── tokens.h │ ├── type.c │ └── util.c │ └── pdp11 │ ├── Makefile │ ├── krnl.ini │ ├── os.ini │ ├── pdp11_cis.c │ ├── pdp11_cpu.c │ ├── pdp11_defs.h │ ├── pdp11_fp.c │ ├── pdp11_lp.c │ ├── pdp11_rk.c │ ├── pdp11_rl.c │ ├── pdp11_rp.c │ ├── pdp11_rx.c │ ├── pdp11_stddev.c │ ├── pdp11_sys.c │ ├── pdp11_tm.c │ ├── scp.c │ ├── scp_tty.c │ ├── sim_defs.h │ ├── siminit.c │ ├── unix_v7_rl.dsk │ └── unixv7 ├── src ├── Makefile ├── cmds │ ├── Makefile │ ├── chgrp.c │ ├── chmod.c │ ├── chown.c │ ├── cp.c │ ├── du.c │ ├── find.c │ ├── grep.c │ ├── ls.c │ ├── mkdir.c │ ├── mv.c │ ├── ping.c │ ├── rm.c │ ├── test.c │ ├── touch.c │ └── wc.c ├── include │ ├── alloca.h │ ├── arpa │ │ └── inet.h │ ├── assert.h │ ├── atomic.h │ ├── bitops.h │ ├── config.h │ ├── conio.h │ ├── crtbase.h │ ├── ctype.h │ ├── dirent.h │ ├── dlfcn.h │ ├── errno.h │ ├── fcntl.h │ ├── float.h │ ├── fnmatch.h │ ├── getopt.h │ ├── glob.h │ ├── grp.h │ ├── hash.h │ ├── httpd.h │ ├── inifile.h │ ├── inttypes.h │ ├── io.h │ ├── java │ │ ├── jni.h │ │ └── jni_md.h │ ├── libgen.h │ ├── limits.h │ ├── locale.h │ ├── malloc.h │ ├── math.h │ ├── memory.h │ ├── moddb.h │ ├── net │ │ ├── arp.h │ │ ├── dhcp.h │ │ ├── ether.h │ │ ├── icmp.h │ │ ├── inet.h │ │ ├── ip.h │ │ ├── ipaddr.h │ │ ├── net.h │ │ ├── netif.h │ │ ├── opt.h │ │ ├── pbuf.h │ │ ├── raw.h │ │ ├── socket.h │ │ ├── stats.h │ │ ├── tcp.h │ │ └── udp.h │ ├── netdb.h │ ├── netinet │ │ ├── in.h │ │ ├── in_systm.h │ │ └── tcp.h │ ├── os.h │ ├── os │ │ ├── buf.h │ │ ├── config.h │ │ ├── cpu.h │ │ ├── dbg.h │ │ ├── dev.h │ │ ├── devfs.h │ │ ├── dfs.h │ │ ├── fpu.h │ │ ├── iovec.h │ │ ├── kbd.h │ │ ├── klog.h │ │ ├── kmalloc.h │ │ ├── kmem.h │ │ ├── krnl.h │ │ ├── ldr.h │ │ ├── mach.h │ │ ├── mbr.h │ │ ├── object.h │ │ ├── pci.h │ │ ├── pdir.h │ │ ├── pe.h │ │ ├── pframe.h │ │ ├── pic.h │ │ ├── pit.h │ │ ├── pnpbios.h │ │ ├── procfs.h │ │ ├── queue.h │ │ ├── rnd.h │ │ ├── sched.h │ │ ├── seg.h │ │ ├── syscall.h │ │ ├── syspage.h │ │ ├── timer.h │ │ ├── trap.h │ │ ├── tss.h │ │ ├── user.h │ │ ├── version.h │ │ ├── vfs.h │ │ ├── vga.h │ │ ├── video.h │ │ ├── virtio.h │ │ ├── vmi.h │ │ └── vmm.h │ ├── process.h │ ├── pthread.h │ ├── pwd.h │ ├── regex.h │ ├── rmap.h │ ├── sched.h │ ├── semaphore.h │ ├── setjmp.h │ ├── share.h │ ├── shlib.h │ ├── signal.h │ ├── stdarg.h │ ├── stddef.h │ ├── stdint.h │ ├── stdio.h │ ├── stdlib.h │ ├── string.h │ ├── sys │ │ ├── file.h │ │ ├── mman.h │ │ ├── param.h │ │ ├── poll.h │ │ ├── resource.h │ │ ├── select.h │ │ ├── socket.h │ │ ├── stat.h │ │ ├── time.h │ │ ├── times.h │ │ ├── types.h │ │ ├── uio.h │ │ ├── utsname.h │ │ └── wait.h │ ├── syslog.h │ ├── tar.h │ ├── termios.h │ ├── time.h │ ├── ucontext.h │ ├── unistd.h │ ├── utime.h │ ├── verinfo.h │ └── win32.h ├── lib │ ├── Makefile │ ├── assert.c │ ├── bitops.c │ ├── bsearch.c │ ├── chkstk.asm │ ├── chkstk.s │ ├── conio.c │ ├── crt0.c │ ├── crypt.c │ ├── ctype.c │ ├── dirent.c │ ├── fcvt.c │ ├── fnmatch.c │ ├── fork.c │ ├── getopt.c │ ├── glob.c │ ├── hash.c │ ├── inifile.c │ ├── input.c │ ├── lldiv.asm │ ├── lldvrm.asm │ ├── llmul.asm │ ├── llrem.asm │ ├── llshl.asm │ ├── llshr.asm │ ├── math.c │ ├── math │ │ ├── acos.asm │ │ ├── asin.asm │ │ ├── atan.asm │ │ ├── atan2.asm │ │ ├── ceil.asm │ │ ├── cos.asm │ │ ├── cosh.asm │ │ ├── exp.asm │ │ ├── fabs.asm │ │ ├── floor.asm │ │ ├── fmod.asm │ │ ├── fpconst.asm │ │ ├── fpreset.asm │ │ ├── frexp.asm │ │ ├── ftol.asm │ │ ├── ldexp.asm │ │ ├── log.asm │ │ ├── log10.asm │ │ ├── modf.asm │ │ ├── pow.asm │ │ ├── sin.asm │ │ ├── sinh.asm │ │ ├── sqrt.asm │ │ ├── tan.asm │ │ └── tanh.asm │ ├── mman.c │ ├── moddb.c │ ├── new.cpp │ ├── opts.c │ ├── output.c │ ├── popen.c │ ├── printf.c │ ├── pthread │ │ ├── barrier.c │ │ ├── condvar.c │ │ ├── mutex.c │ │ ├── pthread.c │ │ ├── rwlock.c │ │ └── spinlock.c │ ├── qsort.c │ ├── random.c │ ├── readline.c │ ├── regex │ │ ├── cclass.h │ │ ├── cname.h │ │ ├── engine.c │ │ ├── regcomp.c │ │ ├── regerror.c │ │ ├── regex2.h │ │ ├── regexec.c │ │ └── regfree.c │ ├── rmap.c │ ├── rtttl.c │ ├── scanf.c │ ├── sched.c │ ├── semaphore.c │ ├── setjmp.c │ ├── shlib.c │ ├── stdio.c │ ├── stdlib.c │ ├── strftime.c │ ├── string.c │ ├── strtod.c │ ├── strtol.c │ ├── tcccrt.c │ ├── termios.c │ ├── time.c │ ├── tmpfile.c │ ├── ulldiv.asm │ ├── ulldvrm.asm │ ├── ullrem.asm │ ├── ullshr.asm │ ├── verinfo.c │ ├── vsprintf.c │ └── xtoa.c ├── sys │ ├── Makefile │ ├── boot │ │ ├── Makefile │ │ ├── boot.asm │ │ ├── cdboot.asm │ │ ├── cdemboot.asm │ │ └── netboot.asm │ ├── dev │ │ ├── 3c905c.c │ │ ├── 3c905c.h │ │ ├── Makefile │ │ ├── cons.c │ │ ├── eepro100.c │ │ ├── fd.c │ │ ├── hd.c │ │ ├── kbd.c │ │ ├── kbddk.h │ │ ├── kbdext.h │ │ ├── kbdfr.h │ │ ├── kbduk.h │ │ ├── kbdus.h │ │ ├── klog.c │ │ ├── ne2000.c │ │ ├── null.c │ │ ├── nvram.c │ │ ├── pcnet32.c │ │ ├── ramdisk.c │ │ ├── rnd.c │ │ ├── rtl8139.c │ │ ├── serial.c │ │ ├── sis900.c │ │ ├── sis900.h │ │ ├── smbios.c │ │ ├── tulip.c │ │ ├── vga.c │ │ ├── video.c │ │ ├── virtioblk.c │ │ ├── virtiocon.c │ │ └── virtionet.c │ ├── fs │ │ ├── cdfs │ │ │ ├── cdfs.c │ │ │ └── iso9660.h │ │ ├── devfs │ │ │ └── devfs.c │ │ ├── dfs │ │ │ ├── dfs.c │ │ │ ├── dir.c │ │ │ ├── file.c │ │ │ ├── group.c │ │ │ ├── inode.c │ │ │ └── super.c │ │ ├── pipefs │ │ │ └── pipefs.c │ │ ├── procfs │ │ │ └── procfs.c │ │ └── smbfs │ │ │ ├── smb.h │ │ │ ├── smbcache.c │ │ │ ├── smbfs.c │ │ │ ├── smbproto.c │ │ │ └── smbutil.c │ ├── krnl │ │ ├── Makefile │ │ ├── apm.c │ │ ├── buf.c │ │ ├── cpu.c │ │ ├── dbg.c │ │ ├── dev.c │ │ ├── fpu.c │ │ ├── hndl.c │ │ ├── iomux.c │ │ ├── iop.c │ │ ├── iovec.c │ │ ├── kmalloc.c │ │ ├── kmem.c │ │ ├── krnl.rc │ │ ├── ldr.c │ │ ├── mach.c │ │ ├── object.c │ │ ├── pci.c │ │ ├── pdir.c │ │ ├── pframe.c │ │ ├── pic.c │ │ ├── pit.c │ │ ├── pnpbios.c │ │ ├── queue.c │ │ ├── sched.c │ │ ├── start.c │ │ ├── syscall.c │ │ ├── timer.c │ │ ├── trap.c │ │ ├── user.c │ │ ├── vfs.c │ │ ├── virtio.c │ │ ├── vmi.c │ │ └── vmm.c │ ├── ndis │ │ ├── ndis.c │ │ ├── ndis.def │ │ └── ndis.h │ ├── net │ │ ├── arp.c │ │ ├── dhcp.c │ │ ├── ether.c │ │ ├── icmp.c │ │ ├── inet.c │ │ ├── ip.c │ │ ├── ipaddr.c │ │ ├── loopif.c │ │ ├── netif.c │ │ ├── pbuf.c │ │ ├── raw.c │ │ ├── rawsock.c │ │ ├── socket.c │ │ ├── stats.c │ │ ├── tcp.c │ │ ├── tcp_input.c │ │ ├── tcp_output.c │ │ ├── tcpsock.c │ │ ├── udp.c │ │ └── udpsock.c │ ├── os │ │ ├── Makefile │ │ ├── critsect.c │ │ ├── environ.c │ │ ├── heap.c │ │ ├── heap.h │ │ ├── netdb.c │ │ ├── os.c │ │ ├── resolv.c │ │ ├── resolv.h │ │ ├── signal.c │ │ ├── sntp.c │ │ ├── sysapi.c │ │ ├── syserr.c │ │ ├── syslog.c │ │ ├── thread.c │ │ ├── tls.c │ │ └── userdb.c │ └── osldr │ │ ├── Makefile │ │ ├── bioscall.asm │ │ ├── ldrinit.asm │ │ ├── loadkrnl.c │ │ ├── osldr.c │ │ └── unzip.c ├── utils │ ├── ar │ │ ├── Makefile │ │ └── ar.c │ ├── ctohtml │ │ ├── Makefile │ │ └── ctohtml.c │ ├── edit │ │ ├── Makefile │ │ └── edit.c │ ├── fdisk │ │ ├── Makefile │ │ └── fdisk.c │ ├── ftpd │ │ ├── Makefile │ │ └── ftpd.c │ ├── genvmdk │ │ ├── Makefile │ │ └── genvmdk.c │ ├── httpd │ │ ├── Makefile │ │ ├── file.gif │ │ ├── folder.gif │ │ ├── hbuf.c │ │ ├── hfile.c │ │ ├── hlog.c │ │ ├── httpd.c │ │ ├── httpd.rc │ │ └── hutils.c │ ├── impdef │ │ ├── Makefile │ │ └── impdef.c │ ├── jinit │ │ └── jinit.c │ ├── login │ │ ├── Makefile │ │ └── login.c │ ├── make │ │ ├── Makefile │ │ └── make.c │ ├── mkboot │ │ ├── Makefile │ │ └── mkboot.c │ ├── msh │ │ ├── Makefile │ │ └── msh.c │ ├── pkg │ │ ├── Makefile │ │ └── pkg.c │ ├── samples │ │ ├── Makefile │ │ ├── calc.c │ │ ├── hello.c │ │ ├── hellos.c │ │ └── webserver.c │ ├── setup │ │ ├── Makefile │ │ └── setup.c │ ├── sh │ │ ├── Makefile │ │ ├── builtins.c │ │ ├── chartype.c │ │ ├── chartype.h │ │ ├── cmds.c │ │ ├── input.c │ │ ├── input.h │ │ ├── interp.c │ │ ├── interp.h │ │ ├── job.c │ │ ├── job.h │ │ ├── node.c │ │ ├── node.h │ │ ├── parser.c │ │ ├── parser.h │ │ ├── sh.c │ │ ├── sh.h │ │ ├── stmalloc.c │ │ └── stmalloc.h │ └── telnetd │ │ ├── Makefile │ │ └── telnetd.c └── win32 │ ├── advapi32 │ ├── Makefile │ ├── advapi32.c │ └── advapi32.def │ ├── kernel32 │ ├── Makefile │ ├── kernel32.c │ └── kernel32.def │ ├── msvcrt │ ├── except.c │ ├── file.c │ ├── float.c │ ├── malloc.c │ ├── msvcrt.c │ ├── msvcrt.def │ └── msvcrt.h │ ├── user32 │ ├── Makefile │ ├── user32.c │ └── user32.def │ ├── winmm │ ├── Makefile │ ├── winmm.c │ └── winmm.def │ └── wsock32 │ ├── wsock32.c │ └── wsock32.def ├── tools ├── ar.exe ├── bochs │ ├── BIOS-bochs │ ├── VGABIOS-elpin-2.40 │ ├── VGABIOS-lgpl │ ├── bochs.exe │ ├── bochsdbg.exe │ ├── bochsrc.txt │ └── bximage.exe ├── ctags.exe ├── cygwin1.dll ├── linecount.exe ├── loc.cmd ├── mkisofs.exe ├── qemu │ ├── SDL.dll │ ├── bios.bin │ ├── fmod.dll │ ├── qemu-img.exe │ ├── qemu.exe │ ├── runsanos.cmd │ ├── runsanosfloppy.cmd │ └── vgabios-cirrus.bin └── zip.exe └── utils ├── buildimg └── buildimg.c ├── cifstest ├── cifstest.c └── smb.h ├── dbggw ├── dbggw.c ├── junk.c ├── rdp.c └── rdp.h ├── dfs ├── bitops.c ├── bitops.h ├── blockdev.c ├── blockdev.h ├── buf.c ├── buf.h ├── dfs.c ├── dfs.h ├── dir.c ├── file.c ├── getopt.c ├── getopt.h ├── group.c ├── inode.c ├── mbr.h ├── mkdfs.c ├── super.c ├── types.h ├── vfs.c ├── vfs.h └── vmdk.c ├── echosrv └── echosrv.c ├── emul ├── build │ ├── advapi32.dsp │ ├── jexec.dsp │ ├── kernel32.dsp │ ├── msvcrt.dsp │ ├── os.dsp │ ├── osemul.dsw │ ├── osexec.dsp │ ├── test.dsp │ ├── user32.dsp │ ├── winmm.dsp │ └── wsock32.dsp ├── include │ ├── os.h │ ├── pe.h │ ├── sockcall.h │ ├── syscall.h │ ├── vfs.h │ └── win32.h └── src │ ├── advapi32 │ ├── advapi32.c │ └── advapi32.def │ ├── jexec │ ├── jawt.h │ ├── jawt_md.h │ ├── jexec.c │ ├── jni.h │ ├── jni_md.h │ ├── jvmdi.h │ ├── jvmpi.h │ ├── stdarg.h │ └── stdio.h │ ├── kernel32 │ ├── kernel32.c │ └── kernel32.def │ ├── msvcrt │ ├── atox.c │ ├── bsearch.c │ ├── ctype.c │ ├── file.c │ ├── float.c │ ├── malloc.c │ ├── memmove.c │ ├── msvcrt.c │ ├── msvcrt.def │ ├── msvcrt.h │ ├── new.cpp │ ├── qsort.c │ ├── setjmp.c │ ├── string.c │ ├── strtol.c │ └── time.c │ ├── os │ ├── critsect.c │ ├── format.c │ ├── heap.c │ ├── heap.h │ ├── mod.c │ ├── mod.h │ └── os.c │ ├── osexec │ ├── bitops.c │ ├── bitops.h │ ├── buf.c │ ├── buf.h │ ├── dfs.c │ ├── dfs.h │ ├── dir.c │ ├── file.c │ ├── group.c │ ├── inode.c │ ├── osexec.c │ ├── super.c │ ├── types.h │ └── vfs.c │ ├── test │ ├── test.c │ └── test2.c │ ├── user32 │ ├── user32.c │ └── user32.def │ ├── winmm │ ├── winmm.c │ └── winmm.def │ └── wsock32 │ ├── wsock32.c │ └── wsock32.def ├── mkfloppy └── mkfloppy.c ├── mkpart └── mkpart.c ├── mkpkg ├── inifile.c ├── inifile.h └── mkpkg.c ├── pmdump ├── getopt.c ├── getopt.h ├── pmdump.c ├── rdp.c └── rdp.h ├── samples ├── fib.c ├── hello.c └── webserver.c └── sow └── sow.c /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | dbg/**/* 3 | img/**/* 4 | lib/**/* 5 | obj/**/* 6 | install/**/* 7 | linux/**/* 8 | *.obj 9 | *.exe 10 | *.o 11 | *.a 12 | *.dll 13 | *.exp 14 | *.lib 15 | krnl.def 16 | os.def 17 | 18 | -------------------------------------------------------------------------------- /Makefile.cross: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for cross-compiling Sanos under Windows 3 | # 4 | 5 | SRC=src 6 | SDKSRC=sdk/src 7 | OUTPUT=cross 8 | INSTALL=$(OUTPUT)/install 9 | IMG=$(OUTPUT)/img 10 | 11 | ROOT=$(CURDIR)/cross/install 12 | CCPREFIX=$(ROOT)/usr 13 | 14 | all: sdkdisk 15 | 16 | source: 17 | mkdir -p $(OUTPUT) $(INSTALL) $(IMG) \ 18 | $(INSTALL)/bin $(INSTALL)/boot $(INSTALL)/dev $(INSTALL)/etc \ 19 | $(INSTALL)/mnt $(INSTALL)/proc $(INSTALL)/tmp $(INSTALL)/usr $(INSTALL)/var \ 20 | $(INSTALL)/usr/bin $(INSTALL)/usr/lib $(INSTALL)/usr/src 21 | cp build/os.ini $(INSTALL)/etc/ 22 | cp build/krnl.ini $(INSTALL)/boot/ 23 | cp $(SRC)/Makefile $(INSTALL)/usr/src/ 24 | cp -r $(SRC)/include $(INSTALL)/usr/ 25 | cp -r $(SRC)/lib $(INSTALL)/usr/src/ 26 | cp -r $(SRC)/sys $(INSTALL)/usr/src/ 27 | cp -r $(SRC)/utils $(INSTALL)/usr/src/ 28 | cp -r $(SRC)/cmds $(INSTALL)/usr/src/ 29 | cp -r $(SRC)/win32 $(INSTALL)/usr/src/ 30 | cp -r $(SDKSRC)/cc $(INSTALL)/usr/src/utils/ 31 | cp -r $(SDKSRC)/as $(INSTALL)/usr/src/utils/ 32 | 33 | sanos: 34 | make -C $(ROOT)/usr/src cross 35 | make -C $(ROOT)/usr/src clean 36 | 37 | sdkdisk: $(IMG)/sanos.vmdk 38 | 39 | $(IMG)/sanos.vmdk: source sanos 40 | mkdfs -d $(IMG)/sanos.vmdk -t vmdk -b $(INSTALL)/boot/boot -l $(INSTALL)/boot/osldr.dll -k $(INSTALL)/boot/krnl.dll -c 100M -i -f -S $(INSTALL) -T / 41 | 42 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/README -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | TODO for sanos 2 | -------------- 3 | 4 | - More unix utilities: xargs, cut, sort, uniq 5 | 6 | - Change control87() to use the MSVCRT definitions of FPU control flags. 7 | 8 | - Implement 48-bit LBA support in IDE driver 9 | 10 | - Improve sysalloc() in heap.c to enable dynamic expansion of wilderness region. 11 | 12 | - Implement UDMA mode for ATAPI devices 13 | 14 | - Replace syslog() in sysapi.c with: 15 | int vsyslog(int syscallno, va_list params); 16 | int syslog(int syscallno, ...); 17 | 18 | - Keyboard locks up when pressing CAPSLOCK 19 | - Check ext flags in processing modifier keys (shift, alt, etc.) 20 | 21 | - Implement ICMP messages host unreachable, net unreachable and port unreachable 22 | 23 | - Finish implementation of NDIS subsystem 24 | 25 | - Add support for shared interrupts to driver isr handlers 26 | 27 | - Use bitmap for port number handling 28 | 29 | - Multicast filtering support in network drivers 30 | 31 | - Implement mremap() and use it in heap.c for realloc() of large blocks 32 | 33 | - Implement krealloc() in kmalloc.c 34 | 35 | - Handle reopening of files in smbfs after reconnect 36 | 37 | - What happens if a tcp pcb is freed in tcp_input() while sending segments on another socket in tcp_output()? 38 | 39 | IDEAS for new features 40 | ---------------------- 41 | 42 | - Vulnerability test with Nessus 43 | 44 | - Use type object in struct object 45 | 46 | - String substitution in inf files 47 | - Replace all ${key} with value in [strings] section 48 | - Support merging of ini files 49 | 50 | - sysctl() functionality 51 | 52 | - DNS resolver cache 53 | 54 | - Dynamic DNS registration 55 | 56 | - Multiple consoles (switch consoles with ALT-) 57 | 58 | - DOS boot loader 59 | 60 | - FATFS support 61 | 62 | - ACPI support 63 | 64 | - Memory paging support 65 | 66 | -------------------------------------------------------------------------------- /build/ar.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=ar 3 | description=Library archive utility 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/ar/ 9 | 10 | [files] 11 | /usr/src/utils/ar/ 12 | /usr/bin/ar.exe 13 | 14 | [dependencies] 15 | cc 16 | clib 17 | make 18 | 19 | [build] 20 | make -C /usr/src/utils/ar 21 | 22 | [install] 23 | make -C /usr/src/utils/ar install 24 | 25 | [license] 26 | Sanos BSD license. See COPYING file. 27 | 28 | -------------------------------------------------------------------------------- /build/as.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=as 3 | version=2.09.10 4 | description=Assembler for x86 5 | author=Simon Tatham, Julian Hall et al. 6 | original=nasm-2.09.10.zip 7 | homepage=http://www.nasm.us/ 8 | 9 | [source] 10 | /usr/src/utils/as/ 11 | 12 | [prebuilt] 13 | /usr/bin/as.exe 14 | 15 | [files] 16 | /usr/src/utils/as/ 17 | /usr/bin/as.exe 18 | 19 | [build] 20 | make -C /usr/src/utils/as 21 | 22 | [readme] 23 | NASM, the Netwide Assembler. 24 | 25 | Many many developers all over the net respect NASM for what it is 26 | - a widespread (thus netwide), portable (thus netwide!), very 27 | flexible and mature assembler tool with support for many output 28 | formats (thus netwide!!). 29 | 30 | [license] 31 | Copyright 1996-2010 the NASM Authors - All rights reserved. 32 | 33 | Redistribution and use in source and binary forms, with or without 34 | modification, are permitted provided that the following 35 | conditions are met: 36 | 37 | * Redistributions of source code must retain the above copyright 38 | notice, this list of conditions and the following disclaimer. 39 | * Redistributions in binary form must reproduce the above 40 | copyright notice, this list of conditions and the following 41 | disclaimer in the documentation and/or other materials provided 42 | with the distribution. 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 45 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 46 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 47 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 48 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 49 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 50 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 51 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 52 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 53 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 54 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 55 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 56 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 57 | -------------------------------------------------------------------------------- /build/bootdisk.lst: -------------------------------------------------------------------------------- 1 | ; 2 | ; File list for sanos boot floppy 3 | ; 4 | 5 | ; Directories 6 | 7 | /bin 8 | /boot 9 | /etc 10 | /dev 11 | /mnt 12 | /proc 13 | /usr 14 | /tmp 15 | /var 16 | 17 | ; Boot files 18 | 19 | /boot/boot boot\boot 20 | /boot/cdboot boot\cdboot 21 | /boot/cdemboot boot\cdemboot 22 | /boot/netboot boot\netboot 23 | /boot/osldr.dll boot\osldr.dll 24 | /boot/os.dll boot\os.dll 25 | /boot/krnl.ini boot\krnl.ini 26 | 27 | ; System files 28 | 29 | /bin/sh.exe bin\sh.exe 30 | /bin/telnetd.exe bin\telnetd.exe 31 | /bin/ftpd.exe bin\ftpd.exe 32 | /bin/setup.exe bin\setup.exe 33 | /bin/fdisk.exe bin\fdisk.exe 34 | /bin/mkboot.exe bin\mkboot.exe 35 | /bin/edit.exe bin\edit.exe 36 | /bin/login.exe bin\login.exe 37 | 38 | ; Drivers 39 | 40 | /boot/pcnet32.sys boot\pcnet32.sys 41 | /boot/ne2000.sys boot\ne2000.sys 42 | /boot/3c905c.sys boot\3c905c.sys 43 | /boot/rtl8139.sys boot\rtl8139.sys 44 | /boot/eepro100.sys boot\eepro100.sys 45 | /boot/sis900.sys boot\sis900.sys 46 | /boot/tulip.sys boot\tulip.sys 47 | /boot/virtionet.sys boot\virtionet.sys 48 | 49 | ; Win32 wrapper DLLs 50 | 51 | /bin/msvcrt.dll bin\msvcrt.dll 52 | /bin/kernel32.dll bin\kernel32.dll 53 | /bin/user32.dll bin\user32.dll 54 | /bin/advapi32.dll bin\advapi32.dll 55 | /bin/winmm.dll bin\winmm.dll 56 | /bin/wsock32.dll bin\wsock32.dll 57 | 58 | ; Java launcher 59 | 60 | /bin/jinit.exe bin\jinit.exe 61 | 62 | ; Configuration files 63 | 64 | /etc/os.ini etc\os.ini 65 | /etc/setup.ini etc\setup.ini 66 | -------------------------------------------------------------------------------- /build/bootnet.lst: -------------------------------------------------------------------------------- 1 | ; 2 | ; File list for sanos network boot image 3 | ; 4 | 5 | ; Directories 6 | 7 | /bin 8 | /boot 9 | /dev 10 | /proc 11 | /etc 12 | /mnt 13 | /usr 14 | /tmp 15 | 16 | ; System files 17 | 18 | /boot/os.dll win\install\boot\os.dll 19 | /bin/sh.exe win\install\bin\msh.exe 20 | 21 | ; Drivers 22 | 23 | /boot/rtl8139.sys win\install\boot\rtl8139.sys 24 | 25 | ; Configuration files 26 | 27 | /boot/krnl.ini build\krnl.ini 28 | /etc/os.ini build\osnet.ini 29 | 30 | -------------------------------------------------------------------------------- /build/cc.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=cc 3 | version=0.9.24 4 | description=C compiler 5 | author=Fabrice Bellard 6 | original=tcc-0.9.24.tar.gz 7 | homepage=http://bellard.org/tcc/ 8 | 9 | [source] 10 | /usr/src/utils/cc/ 11 | 12 | [prebuilt] 13 | /usr/bin/cc.exe 14 | 15 | [files] 16 | /usr/src/utils/cc/ 17 | /usr/bin/cc.exe 18 | 19 | [build] 20 | make -C /usr/src/utils/cc 21 | 22 | [readme] 23 | The Tiny C Compiler (aka TCC, tCc, or TinyCC) is an x86 C compiler created by 24 | Fabrice Bellard. It is designed to work for slow computers with little disk 25 | space (e.g. on rescue disks). 26 | 27 | TCC implements all of ANSI C (C89/C90), much of the new ISO C99 standard, and 28 | many GNU C extensions including inline assembly. 29 | 30 | The Sanos version of TCC also includes many MSVC extensions. 31 | 32 | [license] 33 | TCC is distributed under the GNU Lesser General Public License (see 34 | COPYING file). 35 | -------------------------------------------------------------------------------- /build/clib.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=clib 3 | description=C runtime library 4 | author=Michael Ringgaard et al. 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/lib/ 9 | /usr/include/ 10 | 11 | [prebuilt] 12 | /usr/lib/libc.a 13 | /usr/lib/os.def 14 | 15 | [files] 16 | /usr/src/lib/ 17 | /usr/include/ 18 | /usr/lib/libc.a 19 | 20 | [license] 21 | See Sanos COPYING file. 22 | 23 | -------------------------------------------------------------------------------- /build/cmds.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=cmds 3 | description=Shell command utilities 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/cmds/ 9 | 10 | [files] 11 | /usr/src/cmds/ 12 | /bin/find.exe 13 | /bin/grep.exe 14 | /bin/ping.exe 15 | 16 | [dependencies] 17 | sdk 18 | 19 | [build] 20 | make -C /usr/src/cmds 21 | 22 | [install] 23 | make -C /usr/src/cmds install 24 | 25 | [license] 26 | Sanos BSD license. See COPYING file. 27 | 28 | -------------------------------------------------------------------------------- /build/ctohtml.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=ctohtml 3 | description=Convert C source files to HTML 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/ctohtml/ 9 | 10 | [files] 11 | /usr/src/utils/ctohtml/ 12 | /usr/bin/ctohtml.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/ctohtml 19 | 20 | [install] 21 | make -C /usr/src/utils/ctohtml install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/edit.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=edit 3 | description=Text editor 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/edit/ 9 | 10 | [files] 11 | /usr/src/utils/edit/ 12 | /bin/edit.exe 13 | /bin/less.exe 14 | 15 | [dependencies] 16 | sdk 17 | 18 | [build] 19 | make -C /usr/src/utils/edit 20 | 21 | [install] 22 | make -C /usr/src/utils/edit install 23 | 24 | [license] 25 | Sanos BSD license. See COPYING file. 26 | 27 | -------------------------------------------------------------------------------- /build/exclrel.lst: -------------------------------------------------------------------------------- 1 | CVS 2 | *.suo 3 | *.ncb 4 | *.obj 5 | junk.c 6 | -------------------------------------------------------------------------------- /build/fdisk.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=fdisk 3 | description=Disk partitioning utility 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/fdisk/ 9 | 10 | [files] 11 | /usr/src/utils/fdisk/ 12 | /bin/fdisk.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/fdisk 19 | 20 | [install] 21 | make -C /usr/src/utils/fdisk install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/floppy.lst: -------------------------------------------------------------------------------- 1 | ; 2 | ; File list for sanos boot floppy 3 | ; 4 | 5 | ; Directories 6 | 7 | /bin 8 | /boot 9 | /etc 10 | /dev 11 | /mnt 12 | /proc 13 | /usr 14 | /tmp 15 | /var 16 | 17 | ; Boot files 18 | 19 | /boot/boot boot/boot 20 | /boot/osldr.dll boot/osldr.dll 21 | /boot/krnl.ini boot/krnl.ini 22 | /boot/os.dll boot/os.dll 23 | 24 | ; System files 25 | 26 | /bin/sh.exe bin/sh.exe 27 | /bin/setup.exe bin/setup.exe 28 | /bin/fdisk.exe bin/fdisk.exe 29 | /bin/mkboot.exe bin/mkboot.exe 30 | /bin/edit.exe bin/edit.exe 31 | /bin/pkg.exe bin/pkg.exe 32 | 33 | ; Drivers 34 | 35 | /boot/pcnet32.sys boot/pcnet32.sys 36 | /boot/ne2000.sys boot/ne2000.sys 37 | /boot/3c905c.sys boot/3c905c.sys 38 | /boot/rtl8139.sys boot/rtl8139.sys 39 | /boot/eepro100.sys boot/eepro100.sys 40 | /boot/sis900.sys boot/sis900.sys 41 | /boot/tulip.sys boot/tulip.sys 42 | 43 | ; Configuration files 44 | 45 | /etc/os.ini etc/os.ini 46 | /etc/setup.ini etc/setup.ini 47 | -------------------------------------------------------------------------------- /build/ftpd.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=ftpd 3 | description=FTP server 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/ftpd/ 9 | 10 | [files] 11 | /usr/src/utils/ftpd/ 12 | /bin/ftpd.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/ftpd 19 | 20 | [install] 21 | make -C /usr/src/utils/ftpd install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/genvmdk.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=genvmdk 3 | description=Generate VMDK disk image 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/genvmdk/ 9 | 10 | [files] 11 | /usr/src/utils/genvmdk/ 12 | /bin/genvmdk.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/genvmdk 19 | 20 | [install] 21 | make -C /usr/src/utils/genvmdk install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/group: -------------------------------------------------------------------------------- 1 | root:*:0:root 2 | users:*:100:root,mri 3 | ftp:*:50:ftp 4 | guests:*:200:guest 5 | -------------------------------------------------------------------------------- /build/hdmin.lst: -------------------------------------------------------------------------------- 1 | ; 2 | ; File list for bootstrap sanos hard disk image 3 | ; 4 | 5 | ; Directories 6 | 7 | /bin 8 | /boot 9 | /etc 10 | /dev 11 | /mnt 12 | /proc 13 | /usr 14 | /tmp 15 | /var 16 | 17 | ; Boot files 18 | 19 | /boot/boot boot/boot 20 | /boot/osldr.dll boot/osldr.dll 21 | /boot/os.dll boot/os.dll 22 | 23 | ; System files 24 | 25 | /bin/sh.exe bin/sh.exe 26 | /bin/pkg.exe bin/pkg.exe 27 | /bin/edit.exe bin/edit.exe 28 | 29 | ; Drivers 30 | 31 | /boot/pcnet32.sys boot/pcnet32.sys 32 | /boot/ne2000.sys boot/ne2000.sys 33 | /boot/3c905c.sys boot/3c905c.sys 34 | /boot/rtl8139.sys boot/rtl8139.sys 35 | /boot/eepro100.sys boot/eepro100.sys 36 | /boot/sis900.sys boot/sis900.sys 37 | /boot/tulip.sys boot/tulip.sys 38 | /boot/virtionet.sys boot/virtionet.sys 39 | 40 | ; Configuration files 41 | 42 | /boot/krnl.ini boot/krnl.ini 43 | /etc/os.ini etc/os.ini 44 | -------------------------------------------------------------------------------- /build/httpd.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=httpd 3 | description=HTTP server library 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/httpd/ 9 | 10 | [files] 11 | /usr/src/utils/httpd/ 12 | /bin/httpd.dll 13 | /usr/lib/httpd.def 14 | 15 | [dependencies] 16 | sdk 17 | 18 | [build] 19 | make -C /usr/src/utils/httpd 20 | 21 | [install] 22 | make -C /usr/src/utils/httpd install 23 | 24 | [license] 25 | Sanos BSD license. See COPYING file. 26 | 27 | -------------------------------------------------------------------------------- /build/impdef.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=impdef 3 | description=Generate import definitions for DLLs 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/impdef/ 9 | 10 | [files] 11 | /usr/src/utils/impdef/ 12 | /usr/bin/impdef.exe 13 | 14 | [dependencies] 15 | cc 16 | clib 17 | make 18 | 19 | [build] 20 | make -C /usr/src/utils/impdef 21 | 22 | [install] 23 | make -C /usr/src/utils/impdef install 24 | 25 | [license] 26 | Sanos BSD license. See COPYING file. 27 | 28 | -------------------------------------------------------------------------------- /build/login.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=login 3 | description=User login 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/login/ 9 | 10 | [files] 11 | /usr/src/utils/login/ 12 | /bin/login.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/login 19 | 20 | [install] 21 | make -C /usr/src/utils/login install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/make.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=make 3 | description=Make utility to maintain groups of programs 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/make/ 9 | 10 | [files] 11 | /usr/src/utils/make/ 12 | /usr/bin/make.exe 13 | 14 | [dependencies] 15 | cc 16 | clib 17 | 18 | [build] 19 | cd /usr/src/utils/make ; cc make.c 20 | 21 | [install] 22 | cd /usr/src/utils/make ; cc make.c ; cp make.exe /usr/bin/ 23 | 24 | [license] 25 | Sanos BSD license. See COPYING file. 26 | 27 | -------------------------------------------------------------------------------- /build/minbootdisk.lst: -------------------------------------------------------------------------------- 1 | ; 2 | ; File list for minimal sanos boot floppy 3 | ; 4 | 5 | ; Directories 6 | 7 | /bin 8 | /boot 9 | /dev 10 | /proc 11 | 12 | ; System files 13 | 14 | /boot/os.dll boot\os.dll 15 | /bin/sh.exe bin\sh.exe 16 | 17 | -------------------------------------------------------------------------------- /build/mkboot.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=mkboot 3 | description=Kernel install utility 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/mkboot/ 9 | 10 | [files] 11 | /usr/src/utils/mkboot/ 12 | /bin/mkboot.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/mkboot 19 | 20 | [install] 21 | make -C /usr/src/utils/mkboot install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/mkbootdisk.cmd: -------------------------------------------------------------------------------- 1 | if not exist win\img mkdir win\img 2 | win\tools\mkdfs -d win\img\sanos.flp -b win\install\boot\boot -l win\install\boot\osldr.dll -k win\install\boot\krnl.dll -c 1440 -i -f -S win\install -T . 3 | -------------------------------------------------------------------------------- /build/mkbootdisk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Initialize file system 4 | mkfs rd0 5 | 6 | # Mount file system 7 | mkdir /rd 8 | mount rd0 /rd 9 | 10 | # Create directories 11 | mkdir /rd/boot 12 | mkdir /rd/bin 13 | mkdir /rd/dev 14 | mkdir /rd/proc 15 | 16 | # Install system 17 | mkboot -d /rd -b /boot/boot -l /boot/osldr.dll -k /boot/krnl.dll 18 | cp /boot/os.dll /rd/boot/ 19 | cp /bin/sh.exe /rd/bin/ 20 | 21 | if [ "$PKG" -eq "1" ] ; then 22 | # Install package manager and networking 23 | cp /boot/rtl8139.sys /rd/boot/ 24 | cp /bin/pkg.exe /rd/bin/ 25 | 26 | mkdir /rd/etc 27 | echo '[os]' > /rd/etc/os.ini 28 | echo 'libpath=/bin;/usr/bin' >> /rd/etc/os.ini 29 | echo '[netif]' >> /rd/etc/os.ini 30 | echo 'eth0' >> /rd/etc/os.ini 31 | 32 | echo '[bindings]' > /rd/boot/krnl.ini 33 | echo 'pci unit 10EC8139=rtl8139.sys' >> /rd/boot/krnl.ini 34 | fi 35 | 36 | # Unmount file system 37 | umount /rd 38 | 39 | # Generate VMDK image 40 | genvmdk /dev/rd0 /var/rd.vmdk 41 | 42 | -------------------------------------------------------------------------------- /build/msh.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=msh 3 | description=Mini shell 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/msh/ 9 | 10 | [files] 11 | /usr/src/utils/msh/ 12 | /bin/msh.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/msh 19 | 20 | [install] 21 | make -C /usr/src/utils/msh install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/os.ini: -------------------------------------------------------------------------------- 1 | # 2 | # os.ini 3 | # 4 | # Copyright (c) 2001 Michael Ringgaard. All rights reserved. 5 | # 6 | # OS configuration 7 | # 8 | 9 | [os] 10 | libpath=.;/bin;/usr/bin 11 | 12 | [netif] 13 | eth0 14 | 15 | 16 | -------------------------------------------------------------------------------- /build/osnet.ini: -------------------------------------------------------------------------------- 1 | # 2 | # os.ini 3 | # 4 | # Copyright (c) 2001 Michael Ringgaard. All rights reserved. 5 | # 6 | # OS configuration 7 | # 8 | 9 | [os] 10 | libpath=c:\bin 11 | user=root 12 | logfile=/dev/syslog 13 | 14 | [netif] 15 | eth0 16 | 17 | [mount] 18 | /usr=\\xpc.jbox.dk\sanos,smbfs,user=sanos,password=sanos 19 | -------------------------------------------------------------------------------- /build/ossdk.ini: -------------------------------------------------------------------------------- 1 | # 2 | # os.ini 3 | # 4 | # Copyright (c) 2001 Michael Ringgaard. All rights reserved. 5 | # 6 | # OS configuration 7 | # 8 | 9 | [os] 10 | libpath=.;/bin;/usr/bin 11 | 12 | [netif] 13 | eth0 14 | -------------------------------------------------------------------------------- /build/passwd: -------------------------------------------------------------------------------- 1 | root:lZ.MD9LskdaOg:0:0:root:/:/bin/sh.exe 2 | mri:TP995I53UweNY:100:100:Michael Ringgaard:/usr:/bin/sh.exe 3 | ftp:*:14:50:FTP user:/: 4 | guest::200:200:guest:/usr:/bin/sh.exe 5 | -------------------------------------------------------------------------------- /build/pkg.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=pkg 3 | description=Package management tool 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/pkg/ 9 | 10 | [files] 11 | /usr/src/utils/pkg/ 12 | /bin/pkg.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/pkg 19 | 20 | [install] 21 | make -C /usr/src/utils/pkg install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/rc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | [ -x /dev/eth0 ] && pkg -c 3 | # telnetd & 4 | # ftpd & 5 | -------------------------------------------------------------------------------- /build/sanos.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=sanos 3 | description=Sanos operating system 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/Makefile 9 | 10 | [files] 11 | /usr/src/Makefile 12 | 13 | [dependencies] 14 | ar 15 | as 16 | cc 17 | clib 18 | cmds 19 | ctohtml 20 | edit 21 | fdisk 22 | ftpd 23 | genvmdk 24 | impdef 25 | login 26 | make 27 | mkboot 28 | msh 29 | pkg 30 | sdk 31 | setup 32 | sh 33 | sys 34 | telnetd 35 | 36 | [license] 37 | Sanos BSD license. See COPYING file. 38 | 39 | -------------------------------------------------------------------------------- /build/sdk.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=sdk 3 | description=Sanos Development Kit 4 | homepage=http://www.jbox.dk/sanos/sdk.htm 5 | 6 | [dependencies] 7 | cc 8 | as 9 | clib 10 | make 11 | impdef 12 | ar 13 | 14 | [readme] 15 | This is a meta-package with the basic packages needed for building applications 16 | and libraries in C under Sanos. 17 | -------------------------------------------------------------------------------- /build/sdkdisk.lst: -------------------------------------------------------------------------------- 1 | ; 2 | ; File list for sanos SDK floppy 3 | ; 4 | 5 | ; Directories 6 | 7 | /bin 8 | /dev 9 | /proc 10 | /etc 11 | /tmp 12 | /usr 13 | /usr/bin 14 | /usr/include 15 | /usr/lib 16 | /usr/src 17 | 18 | ; System files 19 | 20 | /boot/krnl.ini build\krnlrel.ini 21 | /boot/os.dll bin\os.dll 22 | /bin/sh.exe bin\sh.exe 23 | /bin/edit.exe bin\edit.exe 24 | 25 | ; Drivers 26 | 27 | /boot/pcnet32.sys bin\pcnet32.sys 28 | /boot/ne2000.sys bin\ne2000.sys 29 | /boot/tulip.sys bin\tulip.sys 30 | 31 | ; Configuration files 32 | 33 | /etc/os.ini build\ossdk.ini 34 | 35 | ; Compiler 36 | 37 | /usr/bin/cc.exe img\usr\bin\cc.exe 38 | 39 | ; Libraries 40 | 41 | /usr/lib/os.def img\usr\lib\os.def 42 | /usr/lib/libc.a img\usr\lib\libc.a 43 | 44 | ; Include files 45 | 46 | /usr/include img\usr\include 47 | 48 | ; Examples 49 | 50 | /usr/src/hello.c utils\samples\hello.c 51 | /usr/src/fib.c utils\samples\fib.c 52 | /usr/src/webserver.c utils\samples\webserver.c 53 | /usr/src/edit.c src\utils\edit\edit.c 54 | /usr/src/telnetd.c src\utils\telnetd\telnetd.c 55 | /usr/src/login.c src\utils\login\login.c 56 | -------------------------------------------------------------------------------- /build/setup.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=setup 3 | description=Setup program 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/setup/ 9 | 10 | [files] 11 | /usr/src/utils/setup/ 12 | /bin/setup.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/setup 19 | 20 | [install] 21 | make -C /usr/src/utils/setup install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/setup.ini: -------------------------------------------------------------------------------- 1 | # 2 | # setup.ini 3 | # 4 | # Copyright (c) 2001 Michael Ringgaard. All rights reserved. 5 | # 6 | # Setup configuration 7 | # 8 | 9 | [setup] 10 | product=Sanos OS 11 | actions=actions 12 | 13 | [actions] 14 | format 15 | sysprep 16 | mount 17 | kernel 18 | mkdirs 19 | copy 20 | unmount 21 | 22 | [format] 23 | device=hd0a 24 | blocksize=4096 25 | cache=1024 26 | quick=0 27 | 28 | [sysprep] 29 | device=hd0a 30 | bootstrap=/boot/boot 31 | loader=/boot/osldr.dll 32 | 33 | [mount] 34 | mntfrom=hd0a 35 | mntto=/mnt 36 | fstype=dfs 37 | 38 | [kernel] 39 | kernel=/boot/krnl.dll 40 | target=/mnt/boot 41 | 42 | [mkdirs] 43 | /mnt/bin 44 | /mnt/etc 45 | /mnt/dev 46 | /mnt/mnt 47 | /mnt/proc 48 | /mnt/usr 49 | /mnt/tmp 50 | /mnt/var 51 | 52 | [copy] 53 | /mnt/boot/boot=/boot/boot 54 | /mnt/boot/cdboot=/boot/cdboot 55 | /mnt/boot/cdemboot=/boot/cdemboot 56 | /mnt/boot/netboot=/boot/netboot 57 | /mnt/boot/os.dll=/boot/os.dll 58 | /mnt/boot/krnl.ini=/boot/krnl.ini 59 | 60 | /mnt/boot/3c905c.sys=/boot/3c905c.sys 61 | /mnt/boot/pcnet32.sys=/boot/pcnet32.sys 62 | /mnt/boot/ne2000.sys=/boot/ne2000.sys 63 | /mnt/boot/rtl8139.sys=/boot/rtl8139.sys 64 | /mnt/boot/eepro100.sys=/boot/eepro100.sys 65 | /mnt/boot/sis900.sys=/boot/sis900.sys 66 | /mnt/boot/tulip.sys=/boot/tulip.sys 67 | 68 | /mnt/bin/sh.exe=/bin/sh.exe 69 | /mnt/bin/edit.exe=/bin/edit.exe 70 | /mnt/bin/ftpd.exe=/bin/ftpd.exe 71 | /mnt/bin/telnetd.exe=/bin/telnetd.exe 72 | /mnt/bin/login.exe=/bin/login.exe 73 | 74 | /mnt/bin/msvcrt.dll=/bin/msvcrt.dll 75 | /mnt/bin/kernel32.dll=/bin/kernel32.dll 76 | /mnt/bin/user32.dll=/bin/user32.dll 77 | /mnt/bin/advapi32.dll=/bin/advapi32.dll 78 | /mnt/bin/wsock32.dll=/bin/wsock32.dll 79 | /mnt/bin/winmm.dll=/bin/winmm.dll 80 | /mnt/bin/jinit.exe=/bin/jinit.exe 81 | 82 | /mnt/etc/os.ini=/etc/os.ini 83 | 84 | [unmount] 85 | path=/mnt 86 | -------------------------------------------------------------------------------- /build/sh.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=sh 3 | description=Shell 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/sh/ 9 | 10 | [files] 11 | /usr/src/utils/sh/ 12 | /bin/sh.exe 13 | 14 | [dependencies] 15 | sdk 16 | cmds 17 | 18 | [build] 19 | make -C /usr/src/utils/sh 20 | 21 | [install] 22 | make -C /usr/src/utils/sh install 23 | 24 | [license] 25 | Sanos BSD license. See COPYING file. 26 | 27 | -------------------------------------------------------------------------------- /build/sys.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=sys 3 | description=Sanos kernel 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/sys/ 9 | 10 | [files] 11 | /usr/src/sys/ 12 | /boot/boot 13 | /boot/cdboot 14 | /boot/cdemboot 15 | /boot/netboot 16 | /boot/osldr.dll 17 | /boot/krnl.dll 18 | /boot/os.dll 19 | /boot/3c905c.sys 20 | /boot/eepro100.sys 21 | /boot/ne2000.sys 22 | /boot/pcnet32.sys 23 | /boot/rtl8139.sys 24 | /boot/sis900.sys 25 | /boot/tulip.sys 26 | /boot/virtionet.sys 27 | /usr/lib/krnl.def 28 | /usr/lib/os.def 29 | 30 | [dependencies] 31 | sdk 32 | mkboot 33 | 34 | [build] 35 | make -C /usr/src/sys 36 | 37 | [install] 38 | make -C /usr/src/sys install 39 | 40 | [license] 41 | Sanos BSD license. See COPYING file. 42 | 43 | -------------------------------------------------------------------------------- /build/telnetd.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=telnetd 3 | description=Telnet server 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/utils/telnetd/ 9 | 10 | [files] 11 | /usr/src/utils/telnetd/ 12 | /bin/telnetd.exe 13 | 14 | [dependencies] 15 | sdk 16 | 17 | [build] 18 | make -C /usr/src/utils/telnetd 19 | 20 | [install] 21 | make -C /usr/src/utils/telnetd install 22 | 23 | [license] 24 | Sanos BSD license. See COPYING file. 25 | 26 | -------------------------------------------------------------------------------- /build/win32.inf: -------------------------------------------------------------------------------- 1 | [package] 2 | name=win32 3 | description=Win32 thunking layer 4 | author=Michael Ringgaard 5 | homepage=http://www.jbox.dk/sanos/ 6 | 7 | [source] 8 | /usr/src/win32/ 9 | 10 | [files] 11 | /usr/src/win32/ 12 | /bin/advapi32.dll 13 | /bin/kernel32.dll 14 | /bin/user32.dll 15 | /bin/winmm.dll 16 | 17 | [dependencies] 18 | sdk 19 | 20 | [build] 21 | make -C /usr/src/win32/advapi32 22 | make -C /usr/src/win32/kernel32 23 | make -C /usr/src/win32/user32 24 | make -C /usr/src/win32/winmm 25 | 26 | [install] 27 | make -C /usr/src/win32/advapi32 install 28 | make -C /usr/src/win32/kernel32 install 29 | make -C /usr/src/win32/user32 install 30 | make -C /usr/src/win32/winmm install 31 | 32 | [license] 33 | Sanos BSD license. See COPYING file. 34 | 35 | -------------------------------------------------------------------------------- /build/winebuild.cmd: -------------------------------------------------------------------------------- 1 | call ..\msvc\vc 2 | 3 | set OPTS=-nologo 4 | 5 | if %1==PRERELEASE set OPTS=%OPTS% PRERELEASEBUILD=1 6 | if %1==RELEASE set OPTS=%OPTS% RELEASEBUILD=1 7 | 8 | nmake %OPTS% %2 %3 %4 %5 %6 %7 %8 %9 9 | 10 | -------------------------------------------------------------------------------- /doc/jbox-df.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/doc/jbox-df.ppt -------------------------------------------------------------------------------- /doc/jbox-intel.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/doc/jbox-intel.ppt -------------------------------------------------------------------------------- /doc/jbox-jaoo.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/doc/jbox-jaoo.ppt -------------------------------------------------------------------------------- /doc/jbox-mws.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/doc/jbox-mws.ppt -------------------------------------------------------------------------------- /doc/sanos-logo.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | SSSSSSSSSSSSS AAAAAAAAAAAAA NNNNNNN NN OOOOOOOOOOOOO SSSSSSSSSSSSS 8 | SSSSSSSSSSSSSSS AAAAAAAAAAAAAAA NNNNNNNNN NNN OOOOOOOOOOOOOOO SSSSSSSSSSSSSSS 9 | SSSSSSSSSSSSSSS AAAAAAAAAAAAAAA NNNNNNNNN NNN OOOOOOOOOOOOOOO SSSSSSSSSSSSSSS 10 | SSS AAA AAA NNN NNN NNN OOO OOO SSS 11 | SSS AAA AAA NNN NNN NNN OOO OOO SSS 12 | SSSSSSSSSSSSSS AAAAAAAAAAAAAAA NNN NNN NNN OOO OOO SSSSSSSSSSSSSS 13 | SSSSSSSSSSSSSSS AAAAAAAAAAAAAAA NNN NNN NNN OOO OOO SSSSSSSSSSSSSSS 14 | SSSSSSSSSSSSSS AAAAAAAAAAAAAAA NNN NNN NNN OOO OOO SSSSSSSSSSSSSS 15 | SSS AAA AAA NNN NNN NNN OOO OOO SSS 16 | SSS AAA AAA NNN NNN NNN OOO OOO SSS 17 | SSSSSSSSSSSSSSS AAA AAA NNN NNNNNNNNN OOOOOOOOOOOOOOO SSSSSSSSSSSSSSS 18 | SSSSSSSSSSSSSSS AAA AAA NNN NNNNNNNNN OOOOOOOOOOOOOOO SSSSSSSSSSSSSSS 19 | SSSSSSSSSSSSS AAA AAA NN NNNNNNN OOOOOOOOOOOOO SSSSSSSSSSSSS 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/sanostech.ppt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/doc/sanostech.ppt -------------------------------------------------------------------------------- /sanos-kvm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #kvm -drive file=linux/img/sanos.vmdk,if=virtio,boot=on -net user -net nic -redir tcp:2323::23 -redir tcp:8080::80 3 | qemu-system-x86_64 -sdl -enable-kvm -drive file=linux/img/sanos.vmdk,if=virtio -net user -net nic,model=rtl8139 -redir tcp:2323::23 -redir tcp:8080::80 4 | -------------------------------------------------------------------------------- /sdk/packages/nasm-2.09.10.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/sdk/packages/nasm-2.09.10.zip -------------------------------------------------------------------------------- /sdk/packages/tcc-0.9.24.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/sdk/packages/tcc-0.9.24.tar.gz -------------------------------------------------------------------------------- /sdk/src/as/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for assembler 3 | # 4 | 5 | OUTDEFS=-DOF_ONLY -DOF_ELF32 -DOF_WIN32 -DOF_COFF -DOF_OBJ -DOF_BIN -DOF_DBG -DOF_DEFAULT=of_elf32 6 | CFLAGS=-I. -DHAVE_SNPRINTF -DHAVE_VSNPRINTF -DUSE_LOCAL_HEAP $(OUTDEFS) 7 | 8 | SRCFILES=nasm.c nasmlib.c ver.c raa.c saa.c rbtree.c float.c insnsa.c insnsb.c \ 9 | directiv.c assemble.c labels.c hashtbl.c crc64.c parser.c \ 10 | preproc.c quote.c pptok.c macros.c listing.c eval.c exprlib.c stdscan.c \ 11 | strfunc.c tokhash.c regvals.c regflags.c ilog2.c strlcpy.c \ 12 | output/outform.c output/outlib.c output/nulldbg.c output/nullout.c output/outbin.c \ 13 | output/outcoff.c output/outelf.c output/outelf32.c output/outobj.c output/outdbg.c \ 14 | 15 | all: as.exe 16 | 17 | as.exe: $(SRCFILES) 18 | $(CC) $(CFLAGS) -o as.exe $(SRCFILES) -noshare 19 | 20 | install: as.exe 21 | cp as.exe $(ROOT)/usr/bin/as.exe 22 | 23 | cross: install 24 | 25 | clean: 26 | rm as.exe 27 | -------------------------------------------------------------------------------- /sdk/src/as/directiv.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated from directiv.dat 3 | * by directiv.pl; do not edit. 4 | */ 5 | 6 | #ifndef NASM_DIRECTIVES_H 7 | #define NASM_DIRECTIVES_H 8 | 9 | enum directives { 10 | D_none, 11 | D_unknown, 12 | D_ABSOLUTE, 13 | D_BITS, 14 | D_COMMON, 15 | D_CPU, 16 | D_DEBUG, 17 | D_DEFAULT, 18 | D_EXTERN, 19 | D_FLOAT, 20 | D_GLOBAL, 21 | D_LIST, 22 | D_SECTION, 23 | D_SEGMENT, 24 | D_WARNING, 25 | D_SECTALIGN, 26 | D_EXPORT, 27 | D_GROUP, 28 | D_IMPORT, 29 | D_LIBRARY, 30 | D_MAP, 31 | D_MODULE, 32 | D_ORG, 33 | D_OSABI, 34 | D_SAFESEH, 35 | D_UPPERCASE 36 | }; 37 | 38 | extern const char * const directives[26]; 39 | enum directives find_directive(const char *token); 40 | 41 | #endif /* NASM_DIRECTIVES_H */ 42 | -------------------------------------------------------------------------------- /sdk/src/as/listing.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * listing.h header file for listing.c 36 | */ 37 | 38 | #ifndef NASM_LISTING_H 39 | #define NASM_LISTING_H 40 | 41 | extern ListGen nasmlist; 42 | extern int user_nolist; /* fbk - 9/1/00 */ 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /sdk/src/as/parser.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * parser.h header file for the parser module of the Netwide 36 | * Assembler 37 | */ 38 | 39 | #ifndef NASM_PARSER_H 40 | #define NASM_PARSER_H 41 | 42 | void parser_global_info(struct location *locp); 43 | insn *parse_line(int pass, char *buffer, insn *result, ldfunc ldef); 44 | void cleanup_insn(insn *instruction); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /sdk/src/as/quote.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | #ifndef NASM_QUOTE_H 35 | #define NASM_QUOTE_H 36 | 37 | #include "compiler.h" 38 | 39 | char *nasm_quote(char *str, size_t len); 40 | size_t nasm_unquote(char *str, char **endptr); 41 | char *nasm_skip_string(char *str); 42 | 43 | #endif /* NASM_QUOTE_H */ 44 | 45 | -------------------------------------------------------------------------------- /sdk/src/as/snprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * snprintf() 3 | * 4 | * Implement snprintf() in terms of vsnprintf() 5 | */ 6 | 7 | #include "compiler.h" 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "nasmlib.h" 14 | 15 | int snprintf(char *str, size_t size, const char *format, ...) 16 | { 17 | va_list ap; 18 | int rv; 19 | 20 | va_start(ap, format); 21 | rv = vsnprintf(str, size, format, ap); 22 | va_end(ap); 23 | 24 | return rv; 25 | } 26 | -------------------------------------------------------------------------------- /sdk/src/as/stdscan.h: -------------------------------------------------------------------------------- 1 | /* ----------------------------------------------------------------------- * 2 | * 3 | * Copyright 1996-2009 The NASM Authors - All Rights Reserved 4 | * See the file AUTHORS included with the NASM distribution for 5 | * the specific copyright holders. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following 9 | * conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above 14 | * copyright notice, this list of conditions and the following 15 | * disclaimer in the documentation and/or other materials provided 16 | * with the distribution. 17 | * 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 19 | * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 20 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 23 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | * 32 | * ----------------------------------------------------------------------- */ 33 | 34 | /* 35 | * stdscan.h header file for stdscan.c 36 | */ 37 | 38 | #ifndef NASM_STDSCAN_H 39 | #define NASM_STDSCAN_H 40 | 41 | /* Standard scanner */ 42 | void stdscan_set(char *str); 43 | char *stdscan_get(void); 44 | void stdscan_reset(void); 45 | int stdscan(void *private_data, struct tokenval *tv); 46 | int nasm_token_hash(const char *token, struct tokenval *tv); 47 | void stdscan_cleanup(void); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /sdk/src/as/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1998 Todd C. Miller 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | #include 18 | #include 19 | #include "compiler.h" 20 | 21 | /* 22 | * Copy src to string dst of size siz. At most siz-1 characters 23 | * will be copied. Always NUL terminates (unless siz == 0). 24 | * Returns strlen(src); if retval >= siz, truncation occurred. 25 | */ 26 | #ifndef HAVE_STRLCPY 27 | 28 | size_t strlcpy(char *dst, const char *src, size_t siz) 29 | { 30 | char *d = dst; 31 | const char *s = src; 32 | size_t n = siz; 33 | 34 | /* Copy as many bytes as will fit */ 35 | if (n != 0) { 36 | while (--n != 0) { 37 | if ((*d++ = *s++) == '\0') 38 | break; 39 | } 40 | } 41 | 42 | /* Not enough room in dst, add NUL and traverse rest of src */ 43 | if (n == 0) { 44 | if (siz != 0) 45 | *d = '\0'; /* NUL-terminate dst */ 46 | while (*s++) 47 | ; 48 | } 49 | 50 | return(s - src - 1); /* count does not include NUL */ 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /sdk/src/as/tokens.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated from insns.dat, regs.dat and token.dat 3 | * by tokhash.pl; do not edit. 4 | */ 5 | 6 | #ifndef NASM_TOKENS_H 7 | #define NASM_TOKENS_H 8 | 9 | #define MAX_KEYWORD 16 /* length of longest keyword */ 10 | 11 | #endif /* NASM_TOKENS_H */ 12 | -------------------------------------------------------------------------------- /sdk/src/as/version.h: -------------------------------------------------------------------------------- 1 | #ifndef NASM_VERSION_H 2 | #define NASM_VERSION_H 3 | #define NASM_MAJOR_VER 2 4 | #define NASM_MINOR_VER 9 5 | #define NASM_SUBMINOR_VER 10 6 | #define NASM_PATCHLEVEL_VER 0 7 | #define NASM_VERSION_ID 0x02090a00 8 | #define NASM_VER "2.09.10" 9 | #endif /* NASM_VERSION_H */ 10 | -------------------------------------------------------------------------------- /sdk/src/as/vsnprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * vsnprintf() 3 | * 4 | * Poor substitute for a real vsnprintf() function for systems 5 | * that don't have them... 6 | */ 7 | 8 | #include "compiler.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "nasmlib.h" 16 | 17 | #define BUFFER_SIZE 65536 /* Bigger than any string we might print... */ 18 | 19 | static char snprintf_buffer[BUFFER_SIZE]; 20 | 21 | int vsnprintf(char *str, size_t size, const char *format, va_list ap) 22 | { 23 | int rv, bytes; 24 | 25 | if (size > BUFFER_SIZE) { 26 | nasm_error(ERR_PANIC|ERR_NOFILE, 27 | "vsnprintf: size (%d) > BUFFER_SIZE (%d)", 28 | size, BUFFER_SIZE); 29 | size = BUFFER_SIZE; 30 | } 31 | 32 | rv = vsprintf(snprintf_buffer, format, ap); 33 | if (rv >= BUFFER_SIZE) 34 | nasm_error(ERR_PANIC|ERR_NOFILE, "vsnprintf buffer overflow"); 35 | 36 | if (size > 0) { 37 | if ((size_t)rv < size-1) 38 | bytes = rv; 39 | else 40 | bytes = size-1; 41 | memcpy(str, snprintf_buffer, bytes); 42 | str[bytes] = '\0'; 43 | } 44 | 45 | return rv; 46 | } 47 | -------------------------------------------------------------------------------- /sdk/src/cc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for C compiler 3 | # 4 | 5 | all: cc.exe 6 | 7 | TCC_SRCFILES=asm386.c asm.c cc.c codegen386.c codegen.c compiler.c elf.c pe.c preproc.c symbol.c type.c util.c 8 | TCC_HDRFILES=cc.h config.h elf.h opcodes.h tokens.h 9 | 10 | cc.exe: $(TCC_SRCFILES) $(TCC_HDRFILES) 11 | $(CC) -o cc.exe $(TCC_SRCFILES) -DUSE_LOCAL_HEAP -noshare 12 | 13 | install: cc.exe 14 | cp cc.exe $(ROOT)/usr/bin/cc.exe 15 | 16 | cross: install 17 | 18 | clean: 19 | rm cc.exe 20 | -------------------------------------------------------------------------------- /sdk/src/cc/config.h: -------------------------------------------------------------------------------- 1 | #define CONFIG_TCCDIR "/usr" 2 | #define CONFIG_TCC_CRT_PREFIX "/usr/lib" 3 | #define GCC_MAJOR 2 4 | #define HOST_I386 1 5 | #define TCC_VERSION "0.9.24" 6 | #define TCC_TARGET_PE 7 | #undef _WIN32 8 | 9 | #if defined(__linux) 10 | #define TCC_PLATFORM "Linux" 11 | #elif defined(_MSC_VER) 12 | #define TCC_PLATFORM "Windows" 13 | #else 14 | #define TCC_PLATFORM "Sanos" 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /sdk/src/pdp11/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for PDP-11 emulator with Seventh Edition UNIX 3 | # 4 | 5 | SANOS=..\..\.. 6 | INCLUDE=$(SANOS)\src\include 7 | TOOLS=$(SANOS)\tools 8 | BIN=$(SANOS)\bin 9 | SDK=..\.. 10 | 11 | !IFNDEF MSVC 12 | MSVC=7 13 | !ENDIF 14 | 15 | COMMONCFLAGS=/I$(INCLUDE) /D SANOS 16 | 17 | !IF $(MSVC) == 8 || $(MSVC) == 9 || $(MSVC) == 10 18 | CFLAGS=/nologo /O2 /Ob1 /Oi /Ot /Oy /GS- /GR- /X /GF /Gy /W1 $(COMMONCFLAGS) 19 | !ELSE 20 | CFLAGS=/nologo /O2 /Og /Ob1 /Oi /Ot /Oy /X /GF /Gy /W1 $(COMMONCFLAGS) 21 | !ENDIF 22 | 23 | all: pdp11.exe siminit.exe 24 | 25 | pdp11.exe: pdp11_cis.c pdp11_cpu.c pdp11_fp.c pdp11_lp.c pdp11_rk.c pdp11_rl.c pdp11_rp.c pdp11_rx.c pdp11_stddev.c pdp11_sys.c pdp11_tm.c scp.c scp_tty.c 26 | 27 | pdp11.exe : $(SANOS)/win/lib/os.lib $(SANOS)/win/lib/libc.lib 28 | $(CC) $(CFLAGS) /Fe$@ $** /link /NODEFAULTLIB /FIXED:NO /HEAP:33554432,131072 29 | 30 | siminit.exe : siminit.c $(SANOS)/win/lib/os.lib $(SANOS)/win/lib/libc.lib 31 | $(CC) $(CFLAGS) /Fe$@ $** /link /NODEFAULTLIB /FIXED:NO /HEAP:33554432,131072 32 | 33 | pdp11.iso: pdp11.exe siminit.exe 34 | -@if not exist img mkdir img 35 | -@if not exist img\boot mkdir img\boot 36 | -@if not exist img\bin mkdir img\bin 37 | -@if not exist img\etc mkdir img\etc 38 | -@if not exist img\dev mkdir img\dev 39 | -@if not exist img\proc mkdir img\proc 40 | -@if not exist img\unix mkdir img\unix 41 | -@if not exist img\var mkdir img\var 42 | copy /Y pdp11.exe img\bin 43 | copy /Y siminit.exe img\bin 44 | copy /Y krnl.ini img\boot 45 | copy /Y os.ini img\etc 46 | copy /Y $(SANOS)\win\install\boot\os.dll img\boot 47 | copy /Y unix_v7_rl.dsk img\unix 48 | copy /Y unixv7 img\unix 49 | $(BIN)\mkdfs -d img\BOOTIMG.BIN -b $(SANOS)\win\install\boot\cdemboot -l $(SANOS)\win\install\boot\osldr.dll -k $(SANOS)\win\install\boot\krnl.dll -c 512 -C 1440 -I 8192 -i -f -K rootdev=cd0,rootfs=cdfs,silent 50 | $(TOOLS)\mkisofs -J -c BOOTCAT.BIN -b BOOTIMG.BIN -o pdp11.iso img 51 | 52 | install: pdp11.iso 53 | $(TOOLS)\zip pdp11.zip pdp11.iso 54 | $(TOOLS)\zip pdp11-src.zip *.ini *.c *.h Makefile unix_v7_rl.dsk unixv7 55 | 56 | clean: 57 | del *.exe *.obj *.iso *.zip 58 | rmdir /S /Q img 59 | -------------------------------------------------------------------------------- /sdk/src/pdp11/krnl.ini: -------------------------------------------------------------------------------- 1 | [kernel] 2 | libpath=/boot 3 | onpanic=debug 4 | 5 | [bindings] 6 | pci class 060100=krnl.dll!isapnp 7 | isa class 0700**=krnl.dll!serial 8 | 9 | [drivers] 10 | krnl.dll!null 11 | krnl.dll!console 12 | krnl.dll!nvram 13 | krnl.dll!klog 14 | krnl.dll!apm 15 | krnl.dll!ramdisk:size=16384 16 | -------------------------------------------------------------------------------- /sdk/src/pdp11/os.ini: -------------------------------------------------------------------------------- 1 | [os] 2 | libpath=/bin 3 | init=/bin/siminit 4 | -------------------------------------------------------------------------------- /sdk/src/pdp11/unix_v7_rl.dsk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/sdk/src/pdp11/unix_v7_rl.dsk -------------------------------------------------------------------------------- /sdk/src/pdp11/unixv7: -------------------------------------------------------------------------------- 1 | set cpu 18b 2 | set cpu 512K 3 | set rl0 RL02 4 | att rl0 /var/unix_v7_rl.dsk 5 | boot rl0 6 | -------------------------------------------------------------------------------- /src/cmds/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for shell commands 3 | # 4 | 5 | CMDS=find.exe grep.exe ping.exe 6 | ALLCMDS=chgrp.exe chmod.exe chown.exe cp.exe du.exe ls.exe mkdir.exe mv.exe rm.exe test.exe touch.exe wc.exe $(CMDS) 7 | 8 | cmds: $(CMDS) 9 | all: $(ALLCMDS) 10 | 11 | chgrp.exe: chgrp.c 12 | $(CC) -o $@ $^ 13 | 14 | chmod.exe: chmod.c 15 | $(CC) -o $@ $^ 16 | 17 | chown.exe: chown.c 18 | $(CC) -o $@ $^ 19 | 20 | cp.exe: cp.c 21 | $(CC) -o $@ $^ 22 | 23 | du.exe: du.c 24 | $(CC) -o $@ $^ 25 | 26 | find.exe: find.c 27 | $(CC) -o $@ $^ -DUSE_LOCAL_HEAP -noshare 28 | 29 | grep.exe: grep.c 30 | $(CC) -o $@ $^ 31 | 32 | ls.exe: ls.c 33 | $(CC) -o $@ $^ 34 | 35 | mkdir.exe: mkdir.c 36 | $(CC) -o $@ $^ 37 | 38 | mv.exe: mv.c 39 | $(CC) -o $@ $^ 40 | 41 | ping.exe: ping.c 42 | $(CC) -o $@ $^ 43 | 44 | rm.exe: rm.c 45 | $(CC) -o $@ $^ 46 | 47 | test.exe: test.c 48 | $(CC) -o $@ $^ 49 | 50 | touch.exe: touch.c 51 | $(CC) -o $@ $^ 52 | 53 | wc.exe: wc.c 54 | $(CC) -o $@ $^ 55 | 56 | install: $(CMDS) 57 | cp $(CMDS) $(ROOT)/bin 58 | 59 | install-all: $(ALLCMDS) 60 | cp $(ALLCMDS) /bin 61 | 62 | cross: install 63 | 64 | clean: 65 | rm *.exe 66 | 67 | -------------------------------------------------------------------------------- /src/include/alloca.h: -------------------------------------------------------------------------------- 1 | // 2 | // alloca.h 3 | // 4 | // Allocate memory on the stack 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef ALLOCA_H 39 | #define ALLOCA_H 40 | 41 | #include 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | void *_alloca(size_t size); 48 | #define alloca _alloca 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/include/assert.h: -------------------------------------------------------------------------------- 1 | // 2 | // assert.h 3 | // 4 | // Assert macro 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef ASSERT_H 39 | #define ASSERT_H 40 | 41 | #ifdef NDEBUG 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | void _assert(void *expr, void *filename, unsigned lineno); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #define assert(exp) (void) ((exp) || (_assert(#exp, __FILE__, __LINE__), 0)) 54 | 55 | #else 56 | 57 | #define assert(exp) ((void) 0) 58 | 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/include/conio.h: -------------------------------------------------------------------------------- 1 | // 2 | // conio.h 3 | // 4 | // Console I/O 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef CONIO_H 39 | #define CONIO_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | int cputs(char *string); 46 | int getch(); 47 | int putch(int ch); 48 | int kbhit(); 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/include/java/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jni_md.h 1.11 00/02/02 3 | * 4 | * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved. 5 | * 6 | * This software is the proprietary information of Sun Microsystems, Inc. 7 | * Use is subject to license terms. 8 | * 9 | */ 10 | 11 | #ifndef _JAVASOFT_JNI_MD_H_ 12 | #define _JAVASOFT_JNI_MD_H_ 13 | 14 | #define JNIEXPORT __declspec(dllexport) 15 | #define JNIIMPORT __declspec(dllimport) 16 | #define JNICALL __stdcall 17 | 18 | typedef long jint; 19 | typedef __int64 jlong; 20 | typedef signed char jbyte; 21 | 22 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 23 | -------------------------------------------------------------------------------- /src/include/libgen.h: -------------------------------------------------------------------------------- 1 | // 2 | // libgen.h 3 | // 4 | // Definitions for pattern matching functions 5 | // 6 | // Copyright (C) 2013 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef LIBGEN_H 39 | #define LIBGEN_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | char *basename(char *path); 46 | char *dirname(char *path); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/include/netinet/in_systm.h: -------------------------------------------------------------------------------- 1 | // 2 | // in_systm.h 3 | // 4 | // System specific network type definitions 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef NETINET_IN_SYSTM_H 39 | #define NETINET_IN_SYSTM_H 40 | 41 | typedef unsigned short n_short; 42 | typedef unsigned int n_long; 43 | typedef unsigned int n_time; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/include/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | // 2 | // tcp.h 3 | // 4 | // Definitions for the Internet Transmission Control Protocol (TCP) 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef NETINET_TCP_H 39 | #define NETINET_TCP_H 40 | 41 | #define TCP_NODELAY 0x0001 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/include/os/config.h: -------------------------------------------------------------------------------- 1 | // 2 | // config.h 3 | // 4 | // Kernel configuration 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef CONFIG_H 35 | #define CONFIG_H 36 | 37 | #define LICENSE_BSD 0 38 | #define LICENSE_GPL 1 39 | 40 | #ifndef LICENSE 41 | #define LICENSE LICENSE_BSD 42 | #endif 43 | 44 | #if LICENSE == LICENSE_BSD 45 | #define BSD 46 | #endif 47 | 48 | #if LICENSE == LICENSE_GPL 49 | #define GPL 50 | #endif 51 | 52 | //#define VMACH 53 | #define RANDOMDEV 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /src/include/os/devfs.h: -------------------------------------------------------------------------------- 1 | // 2 | // devfs.h 3 | // 4 | // Device Filesystem 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef DEVFS_H 35 | #define DEVFS_H 36 | 37 | struct devfile { 38 | struct file *filp; 39 | dev_t devno; 40 | int blksize; 41 | int devsize; 42 | 43 | struct devfile *next; 44 | struct devfile *prev; 45 | }; 46 | 47 | void init_devfs(); 48 | 49 | void devfs_setevt(struct dev *dev, int events); 50 | void devfs_clrevt(struct dev *dev, int events); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/include/os/fpu.h: -------------------------------------------------------------------------------- 1 | // 2 | // fpu.h 3 | // 4 | // Floating point unit 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef FPU_H 35 | #define FPU_H 36 | 37 | struct fpu { 38 | unsigned long ocw; 39 | unsigned long osw; 40 | unsigned long otw; 41 | unsigned long oip; 42 | unsigned long ocs; 43 | unsigned long ooo; 44 | unsigned long oos; 45 | unsigned long ost[20]; 46 | }; 47 | 48 | void fpu_enable(struct fpu *state); 49 | void fpu_disable(struct fpu *state); 50 | 51 | void init_fpu(); 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /src/include/os/iovec.h: -------------------------------------------------------------------------------- 1 | // 2 | // iovec.h 3 | // 4 | // Scatter/gather utility routines 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef IOVEC_H 35 | #define IOVEC_H 36 | 37 | int check_iovec(struct iovec *iov, int iovlen, int modify); 38 | size_t get_iovec_size(struct iovec *iov, int iovlen); 39 | struct iovec *dup_iovec(struct iovec *iov, int iovlen); 40 | int read_iovec(struct iovec *iov, int iovlen, char *buf, size_t count); 41 | int write_iovec(struct iovec *iov, int iovlen, char *buf, size_t count); 42 | 43 | #endif 44 | 45 | -------------------------------------------------------------------------------- /src/include/os/ldr.h: -------------------------------------------------------------------------------- 1 | // 2 | // ldr.h 3 | // 4 | // Kernel module loader 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef LDR_H 35 | #define LDR_H 36 | 37 | extern struct moddb kmods; 38 | 39 | void *load_image_file(char *filename, int userspace); 40 | 41 | krnlapi void *resolve(hmodule_t hmod, char *procname); 42 | krnlapi hmodule_t getmodule(char *name); 43 | krnlapi int getmodpath(hmodule_t hmod, char *buffer, int size); 44 | krnlapi hmodule_t load(char *name, int flags); 45 | krnlapi int unload(hmodule_t hmod); 46 | krnlapi void *getentrypoint(hmodule_t hmod); 47 | 48 | void init_kernel_modules(); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/include/os/queue.h: -------------------------------------------------------------------------------- 1 | // 2 | // queue.h 3 | // 4 | // Message queue 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef QUEUE_H 35 | #define QUEUE_H 36 | 37 | struct queue { 38 | struct sem notempty; 39 | struct sem notfull; 40 | int size; 41 | int in; 42 | int out; 43 | void **elems; 44 | }; 45 | 46 | krnlapi struct queue *alloc_queue(int size); 47 | krnlapi void free_queue(struct queue *q); 48 | krnlapi int enqueue(struct queue *q, void *msg, unsigned int timeout); 49 | krnlapi void *dequeue(struct queue *q, unsigned int timeout); 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/include/os/rnd.h: -------------------------------------------------------------------------------- 1 | // 2 | // rnd.h 3 | // 4 | // A strong random number generator 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999 Theodore Ts'o. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions 11 | // are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright 14 | // notice, this list of conditions and the following disclaimer. 15 | // 2. Redistributions in binary form must reproduce the above copyright 16 | // notice, this list of conditions and the following disclaimer in the 17 | // documentation and/or other materials provided with the distribution. 18 | // 3. Neither the name of the project nor the names of its contributors 19 | // may be used to endorse or promote products derived from this software 20 | // without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 26 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | // SUCH DAMAGE. 33 | // 34 | 35 | #ifndef RND_H 36 | #define RND_H 37 | 38 | krnlapi void get_random_bytes(void *buf, int nbytes); 39 | void add_dpc_randomness(void *dpc); 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /src/include/os/tss.h: -------------------------------------------------------------------------------- 1 | // 2 | // tss.h 3 | // 4 | // Task state segment 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef TSS_H 35 | #define TSS_H 36 | 37 | struct tss { 38 | unsigned long link; 39 | unsigned long esp0, ss0; 40 | unsigned long esp1, ss1; 41 | unsigned long esp2, ss2; 42 | unsigned long cr3; 43 | unsigned long eip; 44 | unsigned long eflags; 45 | unsigned long eax, ecx, edx, ebx, esp, ebp; 46 | unsigned long esi, edi; 47 | unsigned long es, cs, ss, ds, fs, gs; 48 | unsigned long ldt; 49 | unsigned long iomap; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/include/os/user.h: -------------------------------------------------------------------------------- 1 | // 2 | // user.h 3 | // 4 | // User management 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef USER_H 35 | #define USER_H 36 | 37 | int getuid(); 38 | int setuid(uid_t uid); 39 | 40 | int getgid(); 41 | int setgid(gid_t gid); 42 | 43 | int geteuid(); 44 | int seteuid(uid_t uid); 45 | 46 | int getegid(); 47 | int setegid(gid_t gid); 48 | 49 | int setgroups(int size, gid_t *list); 50 | int getgroups(int size, gid_t *list); 51 | 52 | int check(int mode, uid_t uid, gid_t gid, int access); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /src/include/os/version.h: -------------------------------------------------------------------------------- 1 | #define VERSION_H 2 | #define OS_NAME "Sanos" 3 | #define OS_COPYRIGHT "Copyright (c) 2001-2012 Michael Ringgaard." 4 | #define OS_LEGAL "All rights reserved." 5 | #define OS_MAJ_VERS 1 6 | #define OS_MIN_VERS 3 7 | #define OS_RELEASE 5 8 | #define OS_BUILD 0 9 | -------------------------------------------------------------------------------- /src/include/os/video.h: -------------------------------------------------------------------------------- 1 | // 2 | // video.h 3 | // 4 | // Video funtions 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef VIDEO_H 35 | #define VIDEO_H 36 | 37 | void init_video(); 38 | 39 | void print_buffer(const char *str, int len); 40 | void print_char(int ch); 41 | void print_string(const char *str); 42 | 43 | void show_cursor(); 44 | void hide_cursor(); 45 | void set_cursor(int col, int line); 46 | 47 | void clear_screen(); 48 | int screen_proc(struct proc_file *pf, void *arg); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/include/process.h: -------------------------------------------------------------------------------- 1 | // 2 | // process.h 3 | // 4 | // Process control functions 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef PROCESS_H 39 | #define PROCESS_H 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | void abort(); 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/include/stdarg.h: -------------------------------------------------------------------------------- 1 | // 2 | // stdarg.h 3 | // 4 | // Variable length argument lists 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef STDARG_H 39 | #define STDARG_H 40 | 41 | #ifndef _VA_LIST_DEFINED 42 | #define _VA_LIST_DEFINED 43 | typedef char *va_list; 44 | #endif 45 | 46 | #define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1)) 47 | 48 | #define va_start(ap, v) (ap = (va_list) &v + _INTSIZEOF(v)) 49 | #define va_arg(ap, t) (*(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t))) 50 | #define va_end(ap) (ap = (va_list) 0) 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /src/include/sys/file.h: -------------------------------------------------------------------------------- 1 | // 2 | // file.h 3 | // 4 | // File locking 5 | // 6 | // Copyright (C) 2013 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef SYS_FILE_H 39 | #define SYS_FILE_H 40 | 41 | #include 42 | 43 | #define LOCK_SH 1 // Shared lock 44 | #define LOCK_EX 2 // Exclusive lock 45 | #define LOCK_UN 3 // Remove lock 46 | 47 | #ifdef __cplusplus 48 | extern "C" { 49 | #endif 50 | 51 | int flock(handle_t f, int operation); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /src/include/sys/param.h: -------------------------------------------------------------------------------- 1 | // 2 | // param.h 3 | // 4 | // System parameters 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #if _MSC_VER > 1000 35 | #pragma once 36 | #endif 37 | 38 | #ifndef SYS_PARAM_H 39 | #define SYS_PARAM_H 40 | 41 | #include 42 | #include 43 | 44 | #define BIG_ENDIAN 4321 45 | #define LITTLE_ENDIAN 1234 46 | #define BYTE_ORDER LITTLE_ENDIAN 47 | 48 | #define MAXPATHLEN PATH_MAX 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /src/lib/assert.c: -------------------------------------------------------------------------------- 1 | // 2 | // assert.c 3 | // 4 | // Assertion helper routine 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #include 35 | #include 36 | 37 | void _assert(void *expr, void *filename, unsigned lineno) { 38 | printf("Assertion failed: %s, file %s, line %d\n", expr, filename, lineno); 39 | exit(3); 40 | } 41 | -------------------------------------------------------------------------------- /src/lib/chkstk.s: -------------------------------------------------------------------------------- 1 | // 2 | // chkstk.s 3 | // 4 | // TCC stack check 5 | // 6 | 7 | .text 8 | 9 | .globl ___chkstk 10 | .globl __chkstk 11 | .globl _alloca 12 | .globl __alloca 13 | 14 | ___chkstk: 15 | __chkstk: 16 | xchg (%esp), %ebp /* store ebp, get ret.addr */ 17 | push %ebp /* push ret.addr */ 18 | lea 4(%esp), %ebp /* setup frame ptr */ 19 | push %ecx /* save ecx */ 20 | mov %ebp, %ecx 21 | L1: 22 | sub $4096,%ecx 23 | test %eax,(%ecx) 24 | sub $4096,%eax 25 | cmp $4096,%eax 26 | jge L1 27 | 28 | sub %eax,%ecx 29 | mov %esp,%eax 30 | test %eax,(%ecx) 31 | mov %ecx,%esp 32 | 33 | mov (%eax),%ecx /* restore ecx */ 34 | mov 4(%eax),%eax 35 | push %eax 36 | ret 37 | 38 | __alloca: 39 | _alloca: 40 | popl %edx /* pop return addr */ 41 | popl %eax /* pop amount to allocate */ 42 | movl %esp,%ecx 43 | addl $3,%eax /* round up to next word */ 44 | andl $0xfffffffc,%eax 45 | subl %eax,%esp 46 | movl %esp,%eax /* base of newly allocated space */ 47 | pushl 8(%ecx) /* copy possible saved registers */ 48 | pushl 4(%ecx) 49 | pushl 0(%ecx) 50 | pushl %eax /* dummy to pop at callsite */ 51 | jmp *%edx /* "return" */ 52 | -------------------------------------------------------------------------------- /src/lib/llshl.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; llshl.asm - long shift left 3 | ; Adapted from Visual Studio C runtime library 4 | ; Portions Copyright (c) Microsoft Corporation. All rights reserved. 5 | ;----------------------------------------------------------------------------- 6 | .386 7 | _TEXT segment use32 para public 'CODE' 8 | public __allshl 9 | 10 | ; 11 | ; llshl - long shift left 12 | ; 13 | ; Purpose: 14 | ; Does a Long Shift Left (signed and unsigned are identical) 15 | ; Shifts a long left any number of bits. 16 | ; 17 | ; Entry: 18 | ; EDX:EAX - long value to be shifted 19 | ; CL - number of bits to shift by 20 | ; 21 | ; Exit: 22 | ; EDX:EAX - shifted value 23 | ; 24 | ; Uses: 25 | ; CL is destroyed. 26 | ; 27 | 28 | __allshl proc near 29 | assume cs:_TEXT 30 | 31 | ; 32 | ; Handle shifts of 64 or more bits (all get 0) 33 | ; 34 | cmp cl, 64 35 | jae short RETZERO 36 | 37 | ; 38 | ; Handle shifts of between 0 and 31 bits 39 | ; 40 | cmp cl, 32 41 | jae short MORE32 42 | shld edx,eax,cl 43 | shl eax,cl 44 | ret 45 | 46 | ; 47 | ; Handle shifts of between 32 and 63 bits 48 | ; 49 | MORE32: 50 | mov edx,eax 51 | xor eax,eax 52 | and cl,31 53 | shl edx,cl 54 | ret 55 | 56 | ; 57 | ; return 0 in edx:eax 58 | ; 59 | RETZERO: 60 | xor eax,eax 61 | xor edx,edx 62 | ret 63 | 64 | __allshl endp 65 | 66 | _TEXT ends 67 | end 68 | -------------------------------------------------------------------------------- /src/lib/llshr.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; llshr.asm - long shift right 3 | ; Adapted from Visual Studio C runtime library 4 | ; Portions Copyright (c) Microsoft Corporation. All rights reserved. 5 | ;----------------------------------------------------------------------------- 6 | .386 7 | _TEXT segment use32 para public 'CODE' 8 | public __allshr 9 | 10 | ; 11 | ; llshr - long shift right 12 | ; 13 | ; Purpose: 14 | ; Does a signed Long Shift Right 15 | ; Shifts a long right any number of bits. 16 | ; 17 | ; Entry: 18 | ; EDX:EAX - long value to be shifted 19 | ; CL - number of bits to shift by 20 | ; 21 | ; Exit: 22 | ; EDX:EAX - shifted value 23 | ; 24 | ; Uses: 25 | ; CL is destroyed. 26 | ; 27 | 28 | __allshr proc near 29 | assume cs:_TEXT 30 | 31 | ; 32 | ; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result 33 | ; depends only on the high order bit of edx). 34 | ; 35 | cmp cl,64 36 | jae short RETSIGN 37 | 38 | ; 39 | ; Handle shifts of between 0 and 31 bits 40 | ; 41 | cmp cl, 32 42 | jae short MORE32 43 | shrd eax,edx,cl 44 | sar edx,cl 45 | ret 46 | 47 | ; 48 | ; Handle shifts of between 32 and 63 bits 49 | ; 50 | MORE32: 51 | mov eax,edx 52 | sar edx,31 53 | and cl,31 54 | sar eax,cl 55 | ret 56 | 57 | ; 58 | ; Return double precision 0 or -1, depending on the sign of edx 59 | ; 60 | RETSIGN: 61 | sar edx,31 62 | mov eax,edx 63 | ret 64 | 65 | __allshr endp 66 | 67 | _TEXT ends 68 | end 69 | -------------------------------------------------------------------------------- /src/lib/math/acos.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; acos.asm - floating point arc cosine 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global acos 9 | global _acos 10 | global __CIacos 11 | 12 | acos: 13 | _acos: 14 | push ebp 15 | mov ebp,esp 16 | fld qword [ebp+8] ; Load real from stack 17 | fld st0 ; Load x 18 | fld st0 ; Load x 19 | fmul ; Multiply (x squared) 20 | fld1 ; Load 1 21 | fsubr ; 1 - (x squared) 22 | fsqrt ; Square root of (1 - x squared) 23 | fxch ; Exchange st, st(1) 24 | fpatan ; This gives the arc cosine ! 25 | pop ebp 26 | ret 27 | 28 | __CIacos: 29 | fld st0 ; Load x 30 | fld st0 ; Load x 31 | fmul ; Multiply (x squared) 32 | fld1 ; Load 1 33 | fsubr ; 1 - (x squared) 34 | fsqrt ; Square root of (1 - x squared) 35 | fxch ; Exchange st, st(1) 36 | fpatan ; This gives the arc cosine ! 37 | ret 38 | -------------------------------------------------------------------------------- /src/lib/math/asin.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; asin.asm - floating point arc sine 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global asin 9 | global _asin 10 | global __CIasin 11 | 12 | asin: 13 | _asin: 14 | push ebp 15 | mov ebp,esp 16 | fld qword [ebp+8] ; Load real from stack 17 | fld st0 ; Load x 18 | fld st0 ; Load x 19 | fmul ; Multiply (x squared) 20 | fld1 ; Load 1 21 | fsubr ; 1 - (x squared) 22 | fsqrt ; Square root of (1 - x squared) 23 | fpatan ; This gives the arc sine ! 24 | pop ebp 25 | ret 26 | 27 | __CIasin: 28 | fld st0 ; Load x 29 | fld st0 ; Load x 30 | fmul ; Multiply (x squared) 31 | fld1 ; Load 1 32 | fsubr ; 1 - (x squared) 33 | fsqrt ; Square root of (1 - x squared) 34 | fpatan ; This gives the arc sine ! 35 | ret 36 | -------------------------------------------------------------------------------- /src/lib/math/atan.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; atan.asm - floating point arc tangent 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global atan 9 | global _atan 10 | 11 | atan: 12 | _atan: 13 | push ebp 14 | mov ebp,esp 15 | fld qword [ebp+8] ; Load real from stack 16 | fld1 ; Load constant 1 17 | fpatan ; Take the arctangent 18 | pop ebp 19 | ret 20 | -------------------------------------------------------------------------------- /src/lib/math/atan2.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; atan2.asm - floating point arc tangent (2 argument) 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global atan2 9 | global _atan2 10 | 11 | atan2: 12 | _atan2: 13 | push ebp 14 | mov ebp,esp 15 | fld qword [ebp+8] ; Load real from stack 16 | fld qword [ebp+16] ; Load real from stack 17 | fpatan ; Take the arctangent 18 | mov esp,ebp 19 | pop ebp 20 | ret 21 | -------------------------------------------------------------------------------- /src/lib/math/ceil.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; ceil.asm - floating point ceiling 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global ceil 9 | global _ceil 10 | 11 | ceil: 12 | _ceil: 13 | push ebp 14 | mov ebp,esp 15 | sub esp,4 ; Allocate temporary space 16 | fld qword [ebp+8] ; Load real from stack 17 | fstcw [ebp-2] ; Save control word 18 | fclex ; Clear exceptions 19 | mov word [ebp-4],0b63h ; Rounding control word 20 | fldcw [ebp-4] ; Set new rounding control 21 | frndint ; Round to integer 22 | fclex ; Clear exceptions 23 | fldcw [ebp-2] ; Restore control word 24 | mov esp,ebp ; Deallocate temporary space 25 | pop ebp 26 | ret 27 | -------------------------------------------------------------------------------- /src/lib/math/cos.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; cos.asm - floating point cosine 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global cos 9 | global _cos 10 | 11 | cos: 12 | _cos: 13 | push ebp 14 | mov ebp,esp ; Point to the stack frame 15 | fld qword [ebp+8] ; Load real from stack 16 | fcos ; Take the cosine 17 | pop ebp 18 | ret 19 | -------------------------------------------------------------------------------- /src/lib/math/exp.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; exp.asm - floating point exponent 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global exp 9 | global _exp 10 | 11 | exp: 12 | _exp: 13 | push ebp 14 | mov ebp,esp 15 | sub esp,8 ; Allocate temporary space 16 | fld qword [ebp+8] ; Load real from stack 17 | fldl2e ; Load log base 2(e) 18 | fmulp st1,st0 ; Multiply x * log base 2(e) 19 | fst st1 ; Push result 20 | frndint ; Round to integer 21 | fsub st1,st0 ; Subtract 22 | fxch ; Exchange st, st(1) 23 | f2xm1 ; Compute 2 to the (x - 1) 24 | fld1 ; Load real number 1 25 | fadd ; 2 to the x 26 | fscale ; Scale by power of 2 27 | fstp st1 ; Set new stack top and pop 28 | fst qword [ebp-8] ; Throw away scale factor 29 | mov esp,ebp ; Deallocate temporary space 30 | pop ebp 31 | ret 32 | -------------------------------------------------------------------------------- /src/lib/math/fabs.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fabs.asm - floating point absolute value 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global fabs 9 | global _fabs 10 | 11 | fabs: 12 | _fabs: 13 | push ebp 14 | mov ebp,esp 15 | fld qword [ebp+8] ; Load real from stack 16 | fabs ; Take the absolute value 17 | pop ebp 18 | ret 19 | -------------------------------------------------------------------------------- /src/lib/math/floor.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; floor.asm - floating point floor 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global floor 9 | global _floor 10 | 11 | floor: 12 | _floor: 13 | push ebp 14 | mov ebp,esp 15 | sub esp,4 ; Allocate temporary space 16 | fld qword [ebp+8] ; Load real from stack 17 | fstcw [ebp-2] ; Save control word 18 | fclex ; Clear exceptions 19 | mov word [ebp-4],0763h ; Rounding control word 20 | fldcw [ebp-4] ; Set new rounding control 21 | frndint ; Round to integer 22 | fclex ; Clear exceptions 23 | fldcw [ebp-2] ; Restore control word 24 | mov esp,ebp 25 | pop ebp 26 | ret 27 | -------------------------------------------------------------------------------- /src/lib/math/fmod.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fmod.asm - floating point remainder of x/y 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global fmod 9 | global _fmod 10 | global __CIfmod 11 | 12 | fmod: 13 | _fmod: 14 | push ebp 15 | mov ebp,esp 16 | fld qword [ebp+16] ; Load real from stack 17 | fld qword [ebp+8] ; Load real from stack 18 | __fmod1: fprem ; Get the partial remainder 19 | fstsw ax ; Get coprocessor status 20 | test ax,0400h ; Complete remainder ? 21 | jnz __fmod1 ; No, go get next remainder 22 | fstp st1 ; Set new top of stack 23 | pop ebp 24 | ret 25 | 26 | __CIfmod: 27 | fxch st1 ; Swap arguments 28 | __CIfmod1: fprem ; Get the partial remainder 29 | fstsw ax ; Get coprocessor status 30 | test ax,0400h ; Complete remainder ? 31 | jnz __CIfmod1 ; No, go get next remainder 32 | fstp st1 ; Set new top of stack 33 | ret 34 | -------------------------------------------------------------------------------- /src/lib/math/fpconst.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fpconst.asm - floating point constants 3 | ;----------------------------------------------------------------------------- 4 | 5 | SECTION .data 6 | 7 | global _fltused 8 | global __fltused 9 | global _infinity 10 | global __infinity 11 | global _nan 12 | global __nan 13 | 14 | ; Floating point used flag 15 | _fltused: 16 | __fltused: dd 9875h 17 | 18 | ; Floating point infinity 19 | _infinity: 20 | __infinity: db 000h, 000h, 000h, 000h, 000h, 000h, 0f0h, 07fh 21 | 22 | ; Floating point NaN 23 | _nan: 24 | __nan: db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0f8h, 0ffh 25 | -------------------------------------------------------------------------------- /src/lib/math/fpreset.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; fpreset.asm - floating point unit reset 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global _fpreset 9 | global __fpreset 10 | 11 | _fpreset: 12 | __fpreset: 13 | finit ; Initialize the FPU 14 | ret 15 | -------------------------------------------------------------------------------- /src/lib/math/frexp.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; frexp.asm - get normalized fraction and exponent 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global frexp 9 | global _frexp 10 | 11 | frexp: 12 | _frexp: 13 | push ebp 14 | mov ebp,esp 15 | push edi ; Save register edi 16 | fld qword [ebp+8] ; Load real from stack 17 | mov edi,dword [ebp+16] ; Put exponent address in edi 18 | ftst ; Test st for zero 19 | fstsw ax ; Put test result in ax 20 | sahf ; Set flags based on test 21 | jnz __frexp1 ; Re-direct if not zero 22 | fld st0 ; Set exponent to zero 23 | jmp __frexp2 ; End of case 24 | __frexp1: fxtract ; Get exponent and significand 25 | fld1 ; Load constant 1 26 | fld1 ; Load constant 1 27 | fadd ; Constant 2 28 | fdiv ; Significand / 2 29 | fxch ; Swap st, st(1) 30 | fld1 ; Load constant 1 31 | fadd ; Increment exponent 32 | fistp dword [edi] ; Store result exponent and pop 33 | __frexp2: pop edi ; Restore register edi 34 | mov esp,ebp 35 | pop ebp 36 | ret 37 | -------------------------------------------------------------------------------- /src/lib/math/ftol.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; ftol.asm - floating point to integer conversion 3 | ;----------------------------------------------------------------------------- 4 | 5 | SECTION .text 6 | 7 | global _ftol 8 | global __ftol 9 | global __ftol2 10 | global __ftol2_sse 11 | 12 | _ftol: 13 | __ftol: 14 | fnstcw word [esp-2] 15 | mov ax, word [esp-2] 16 | or ax, 0C00h 17 | mov word [esp-4], ax 18 | fldcw word [esp-4] 19 | fistp qword [esp-12] 20 | fldcw word [esp-2] 21 | mov eax, dword [esp-12] 22 | mov edx, dword [esp-8] 23 | ret 24 | 25 | __ftol2: 26 | fnstcw word [esp-2] 27 | mov ax, word [esp-2] 28 | or ax, 0C00h 29 | mov word [esp-4], ax 30 | fldcw word [esp-4] 31 | fistp qword [esp-12] 32 | fldcw word [esp-2] 33 | mov eax, dword [esp-12] 34 | mov edx, dword [esp-8] 35 | ret 36 | 37 | ; TODO: what is the correct code for __ftol2_sse 38 | __ftol2_sse: 39 | fnstcw word [esp-2] 40 | mov ax, word [esp-2] 41 | or ax, 0C00h 42 | mov word [esp-4], ax 43 | fldcw word [esp-4] 44 | fistp qword [esp-12] 45 | fldcw word [esp-2] 46 | mov eax, dword [esp-12] 47 | mov edx, dword [esp-8] 48 | ret 49 | -------------------------------------------------------------------------------- /src/lib/math/ldexp.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; ldexp.asm - floating point x * 2 to the n 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global ldexp 9 | global _ldexp 10 | 11 | ldexp: 12 | _ldexp: 13 | push ebp 14 | mov ebp,esp 15 | sub esp,8 ; Allocate temporary space 16 | fild dword [ebp+16] ; Load n as integer 17 | fld qword [ebp+8] ; Load real from stack 18 | fscale ; Compute 2 to the n 19 | fstp st1 ; Set new top of stack 20 | fst qword [ebp-8] ; Store result 21 | mov esp,ebp ; Deallocate temporary space 22 | pop ebp 23 | ret 24 | -------------------------------------------------------------------------------- /src/lib/math/log.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; log.asm - floating point logarithm 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global log 9 | global _log 10 | 11 | log: 12 | _log: 13 | push ebp 14 | mov ebp,esp 15 | fld qword [ebp+8] ; Load real from stack 16 | fldln2 ; Load log base e of 2 17 | fxch st1 ; Exchange st0, st1 18 | fyl2x ; Compute the natural log(x) 19 | pop ebp 20 | ret 21 | -------------------------------------------------------------------------------- /src/lib/math/log10.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; log10.asm - floating point logarithm base 10 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global log10 9 | global _log10 10 | 11 | log10: 12 | _log10: 13 | push ebp 14 | mov ebp,esp 15 | fld qword [ebp+8] ; Load real from stack 16 | fldlg2 ; Load log base 10 of 2 17 | fxch st1 ; Exchange st0, st1 18 | fyl2x ; Compute the log base 10(x) 19 | pop ebp 20 | ret 21 | -------------------------------------------------------------------------------- /src/lib/math/modf.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; modf.asm - get floating point fractional and integer parts 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global modf 9 | global _modf 10 | 11 | modf: 12 | _modf: 13 | push ebp 14 | mov ebp,esp 15 | push edi ; Save register edi 16 | fld qword [ebp+8] ; Load real from stack 17 | mov edi,dword [ebp+16] ; Put integer address in edi 18 | fld st0 ; Duplicate st 19 | frndint ; Round to integer 20 | fcom st1 ; Compare with orignal value 21 | fstsw ax ; Get the FPU status word 22 | test byte [ebp+15],080h ; Test if number is negative 23 | jz __fmodf1 ; Re-direct if positive 24 | sahf ; Store AH to flags 25 | jnb __fmodf2 ; Re-direct if greater or equal 26 | fld1 ; Load the constant 1 27 | fadd ; Increment integer part 28 | jmp __fmodf2 ; End of case 29 | __fmodf1: sahf ; Store AH to flags 30 | jna __fmodf2 ; Re-direct if less or equal 31 | fld1 ; Load constant 1 32 | fsub ; Decrement integer part 33 | __fmodf2: fst qword [edi] ; Store integer part 34 | fsub ; Subtract to get fraction 35 | pop edi ; Restore register edi 36 | mov esp,ebp ; Restore stack pointer 37 | pop ebp 38 | ret 39 | -------------------------------------------------------------------------------- /src/lib/math/sin.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; sin.asm - floating point sine 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global sin 9 | global _sin 10 | 11 | sin: 12 | _sin: 13 | push ebp ; Save register bp 14 | mov ebp,esp ; Point to the stack frame 15 | fld qword [ebp+8] ; Load real from stack 16 | fsin ; Take the sine 17 | pop ebp ; Restore register bp 18 | ret ; Return to caller 19 | -------------------------------------------------------------------------------- /src/lib/math/sqrt.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; sqrt.asm - floating point square root 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global sqrt 9 | global _sqrt 10 | global __CIsqrt 11 | sqrt: 12 | _sqrt: 13 | push ebp 14 | mov ebp,esp 15 | fld qword [ebp+8] ; Load real from stack 16 | fsqrt ; Take the square root 17 | pop ebp 18 | ret 19 | 20 | __CIsqrt: 21 | fsqrt ; Take the square root 22 | ret 23 | -------------------------------------------------------------------------------- /src/lib/math/tan.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; tan.asm - floating point tangent 3 | ; Ported from Al Maromaty's free C Runtime Library 4 | ;----------------------------------------------------------------------------- 5 | 6 | SECTION .text 7 | 8 | global tan 9 | global _tan 10 | 11 | tan: 12 | _tan: 13 | push ebp 14 | mov ebp,esp 15 | sub esp,4 ; Allocate temporary space 16 | fld qword [ebp+8] ; Load real from stack 17 | fptan ; Take the tangent 18 | fstp dword [ebp-4] ; Throw away the constant 1 19 | mov esp,ebp ; Deallocate temporary space 20 | pop ebp 21 | ret 22 | -------------------------------------------------------------------------------- /src/lib/new.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // new.c 3 | // 4 | // Object new and delete operators 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #include 35 | 36 | extern "C" 37 | { 38 | 39 | void *memset(void *, int, size_t); 40 | 41 | int _purecall() { 42 | panic("pure virtual function call attempted"); 43 | return 0; 44 | } 45 | 46 | } 47 | 48 | void *operator new(unsigned int size) { 49 | void *p; 50 | 51 | p = malloc(size); 52 | if (p) memset(p, 0, size); 53 | return p; 54 | } 55 | 56 | void operator delete(void *p) { 57 | if (p) free(p); 58 | } 59 | -------------------------------------------------------------------------------- /src/lib/regex/cclass.h: -------------------------------------------------------------------------------- 1 | // 2 | // cclass.h 3 | // 4 | // Character classes for regular expression library 5 | // 6 | // Ported to sanos by Micheal Ringgaard. 7 | // 8 | // Copyright 1992, 1993, 1994, 1997 Henry Spencer. All rights reserved. 9 | // This software is not subject to any license of the American Telephone 10 | // and Telegraph Company or of the Regents of the University of California. 11 | // 12 | // Permission is granted to anyone to use this software for any purpose on 13 | // any computer system, and to alter it and redistribute it, subject 14 | // to the following restrictions: 15 | // 16 | // 1. The author is not responsible for the consequences of use of this 17 | // software, no matter how awful, even if they arise from flaws in it. 18 | // 19 | // 2. The origin of this software must not be misrepresented, either by 20 | // explicit claim or by omission. Since few users ever read sources, 21 | // credits must appear in the documentation. 22 | // 23 | // 3. Altered versions must be plainly marked as such, and must not be 24 | // misrepresented as being the original software. Since few users 25 | // ever read sources, credits must appear in the documentation. 26 | // 27 | // 4. This notice may not be removed or altered. 28 | // 29 | 30 | // 31 | // Character-class table 32 | // 33 | 34 | static struct cclass { 35 | char *name; 36 | char *chars; 37 | char *multis; 38 | } cclasses[] = { 39 | {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""}, 40 | {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ""}, 41 | {"blank", " \t", ""}, 42 | {"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177", ""}, 43 | {"digit", "0123456789", ""}, 44 | {"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ""}, 45 | {"lower", "abcdefghijklmnopqrstuvwxyz", ""}, 46 | {"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", ""}, 47 | {"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ""}, 48 | {"space", "\t\n\v\f\r ", ""}, 49 | {"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", ""}, 50 | {"xdigit", "0123456789ABCDEFabcdef",""}, 51 | {NULL, 0, ""} 52 | }; 53 | -------------------------------------------------------------------------------- /src/lib/regex/regfree.c: -------------------------------------------------------------------------------- 1 | // 2 | // regfree.c 3 | // 4 | // Free regular expression 5 | // 6 | // Ported to sanos by Michael Ringgaard. 7 | // 8 | // Copyright 1992, 1993, 1994, 1997 Henry Spencer. All rights reserved. 9 | // This software is not subject to any license of the American Telephone 10 | // and Telegraph Company or of the Regents of the University of California. 11 | // 12 | // Permission is granted to anyone to use this software for any purpose on 13 | // any computer system, and to alter it and redistribute it, subject 14 | // to the following restrictions: 15 | // 16 | // 1. The author is not responsible for the consequences of use of this 17 | // software, no matter how awful, even if they arise from flaws in it. 18 | // 19 | // 2. The origin of this software must not be misrepresented, either by 20 | // explicit claim or by omission. Since few users ever read sources, 21 | // credits must appear in the documentation. 22 | // 23 | // 3. Altered versions must be plainly marked as such, and must not be 24 | // misrepresented as being the original software. Since few users 25 | // ever read sources, credits must appear in the documentation. 26 | // 27 | // 4. This notice may not be removed or altered. 28 | // 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include "regex2.h" 36 | 37 | // 38 | // regfree - free everything 39 | // 40 | void regfree(regex_t *preg) { 41 | struct re_guts *g; 42 | 43 | if (preg->re_magic != MAGIC1) return; // oops 44 | g = preg->re_g; 45 | if (g == NULL || g->magic != MAGIC2) return; // oops again 46 | 47 | preg->re_magic = 0; // mark it invalid 48 | g->magic = 0; // mark it invalid 49 | 50 | if (g->strip != NULL) free(g->strip); 51 | if (g->sets != NULL) free(g->sets); 52 | if (g->setbits != NULL) free(g->setbits); 53 | if (g->must != NULL) free(g->must); 54 | free(g); 55 | } 56 | -------------------------------------------------------------------------------- /src/lib/ullshr.asm: -------------------------------------------------------------------------------- 1 | ;----------------------------------------------------------------------------- 2 | ; ullshr.asm - long shift right 3 | ; Adapted from Visual Studio C runtime library 4 | ; Portions Copyright (c) Microsoft Corporation. All rights reserved. 5 | ;----------------------------------------------------------------------------- 6 | .386 7 | _TEXT segment use32 para public 'CODE' 8 | public __aullshr 9 | 10 | ; 11 | ; ullshr - long shift right 12 | ; 13 | ; Purpose: 14 | ; Does a unsigned Long Shift Right 15 | ; Shifts a long right any number of bits. 16 | ; 17 | ; Entry: 18 | ; EDX:EAX - long value to be shifted 19 | ; CL - number of bits to shift by 20 | ; 21 | ; Exit: 22 | ; EDX:EAX - shifted value 23 | ; 24 | ; Uses: 25 | ; CL is destroyed. 26 | ; 27 | 28 | __aullshr proc near 29 | assume cs:_TEXT 30 | 31 | ; 32 | ; Handle shifts of 64 bits or more (if shifting 64 bits or more, the result 33 | ; depends only on the high order bit of edx). 34 | ; 35 | cmp cl,64 36 | jae short RETZERO 37 | 38 | ; 39 | ; Handle shifts of between 0 and 31 bits 40 | ; 41 | cmp cl, 32 42 | jae short MORE32 43 | shrd eax,edx,cl 44 | shr edx,cl 45 | ret 46 | 47 | ; 48 | ; Handle shifts of between 32 and 63 bits 49 | ; 50 | MORE32: 51 | mov eax,edx 52 | xor edx,edx 53 | and cl,31 54 | shr eax,cl 55 | ret 56 | 57 | ; 58 | ; return 0 in edx:eax 59 | ; 60 | RETZERO: 61 | xor eax,eax 62 | xor edx,edx 63 | ret 64 | 65 | __aullshr endp 66 | 67 | _TEXT ends 68 | end 69 | -------------------------------------------------------------------------------- /src/sys/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Main makefile for Sanos operating system 3 | # 4 | 5 | all: boot osldr krnl dev os 6 | 7 | boot: 8 | make -C boot 9 | 10 | osldr: 11 | make -C osldr 12 | 13 | krnl: 14 | make -C krnl 15 | 16 | dev: krnl 17 | make -C dev 18 | 19 | os: 20 | make -C os 21 | 22 | clean: 23 | make -C boot clean 24 | make -C osldr clean 25 | make -C krnl clean 26 | make -C dev clean 27 | make -C os clean 28 | 29 | install: boot osldr krnl dev os 30 | make -C boot install 31 | make -C osldr install 32 | make -C krnl install 33 | make -C dev install 34 | make -C os install 35 | 36 | cross: 37 | make -C boot cross 38 | make -C osldr cross 39 | make -C krnl cross 40 | make -C dev cross 41 | make -C os cross 42 | 43 | .PHONY: boot osldr krnl dev os 44 | 45 | -------------------------------------------------------------------------------- /src/sys/boot/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for boot sectors 3 | # 4 | 5 | all: boot cdboot cdemboot netboot 6 | 7 | boot: boot.asm 8 | $(AS) -f bin $< -o $@ 9 | 10 | cdboot: cdboot.asm 11 | $(AS) -f bin $< -o $@ 12 | 13 | cdemboot: cdemboot.asm 14 | $(AS) -f bin $< -o $@ 15 | 16 | netboot: netboot.asm 17 | $(AS) -f bin $< -o $@ 18 | 19 | install: boot cdboot cdemboot netboot 20 | cp boot cdboot cdemboot netboot /boot 21 | mkboot -b /boot/boot 22 | 23 | cross: boot cdboot cdemboot netboot 24 | cp boot cdboot cdemboot netboot $(ROOT)/boot 25 | 26 | clean: 27 | rm boot cdboot cdemboot netboot 28 | 29 | -------------------------------------------------------------------------------- /src/sys/dev/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for device drivers 3 | # 4 | 5 | LIB=$(ROOT)/usr/src/lib 6 | DRIVERS=3c905c.sys eepro100.sys ne2000.sys pcnet32.sys rtl8139.sys sis900.sys tulip.sys virtionet.sys 7 | 8 | all: $(DRIVERS) 9 | 10 | 3c905c.sys: 3c905c.c $(LIB)/string.c 11 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 12 | 13 | eepro100.sys: eepro100.c $(LIB)/opts.c $(LIB)/string.c $(LIB)/strtol.c $(LIB)/ctype.c 14 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 15 | 16 | ne2000.sys: ne2000.c $(LIB)/opts.c $(LIB)/string.c $(LIB)/strtol.c $(LIB)/ctype.c 17 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 18 | 19 | pcnet32.sys: pcnet32.c $(LIB)/string.c $(LIB)/ctype.c 20 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 21 | 22 | rtl8139.sys: rtl8139.c $(LIB)/opts.c $(LIB)/string.c $(LIB)/strtol.c $(LIB)/ctype.c 23 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 24 | 25 | sis900.sys: sis900.c $(LIB)/opts.c $(LIB)/string.c $(LIB)/strtol.c $(LIB)/ctype.c 26 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 27 | 28 | tulip.sys: tulip.c $(LIB)/opts.c $(LIB)/string.c $(LIB)/strtol.c $(LIB)/ctype.c 29 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 30 | 31 | virtionet.sys: virtionet.c $(LIB)/string.c 32 | $(CC) -shared -entry _start@12 -nostdlib -lkrnl -o $@ -D KERNEL $** 33 | 34 | install: $(DRIVERS) 35 | cp $(DRIVERS) $(ROOT)/boot/ 36 | 37 | cross: install 38 | 39 | clean: 40 | rm $(DRIVERS) 41 | 42 | -------------------------------------------------------------------------------- /src/sys/dev/kbdfr.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/src/sys/dev/kbdfr.h -------------------------------------------------------------------------------- /src/sys/fs/smbfs/smb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/src/sys/fs/smbfs/smb.h -------------------------------------------------------------------------------- /src/sys/krnl/krnl.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define NUMSTR(n) #n 4 | #define VERS(a,b,c,d) NUMSTR(a) "." NUMSTR(b) "." NUMSTR(c) "." NUMSTR(d) 5 | 6 | LANGUAGE 0, 0 7 | 8 | 1 VERSIONINFO 9 | FILEVERSION OS_MAJ_VERS,OS_MIN_VERS,OS_RELEASE,OS_BUILD 10 | PRODUCTVERSION OS_MAJ_VERS,OS_MIN_VERS,OS_RELEASE,OS_BUILD 11 | FILEFLAGSMASK 0x3FL 12 | #if defined(RELEASE) 13 | #if OS_BUILD == 0 14 | FILEFLAGS 0x00L 15 | #else 16 | FILEFLAGS 0x04L 17 | #endif 18 | #elif defined(DEBUG) 19 | FILEFLAGS 0x01L 20 | #elif defined(PRERELEASE) 21 | FILEFLAGS 0x02L 22 | #else 23 | FILEFLAGS 0x08L 24 | #endif 25 | FILEOS 0x80000L 26 | FILETYPE 0x10L 27 | FILESUBTYPE 0x0L 28 | BEGIN 29 | BLOCK "StringFileInfo" 30 | BEGIN 31 | BLOCK "00000000" 32 | BEGIN 33 | VALUE "FileDescription", OS_NAME " Operating System Kernel" 34 | VALUE "OriginalFilename", "krnl.dll" 35 | VALUE "FileVersion", VERS(OS_MAJ_VERS,OS_MIN_VERS,OS_RELEASE,OS_BUILD) 36 | VALUE "ProductName", OS_NAME 37 | VALUE "ProductVersion", VERS(OS_MAJ_VERS,OS_MIN_VERS,OS_RELEASE,OS_BUILD) 38 | VALUE "Home Page", "http://www.jbox.dk/sanos" 39 | VALUE "Author", "Michael Ringgaard " 40 | VALUE "LegalCopyright", OS_COPYRIGHT 41 | VALUE "LegalTrademarks", OS_LEGAL 42 | 43 | #if LICENSE == 1 44 | VALUE "License", "GPL" 45 | #else 46 | VALUE "License", "BSD" 47 | #endif 48 | 49 | #if defined(RELEASE) 50 | #if OS_BUILD == 0 51 | VALUE "Build", "Release" 52 | #else 53 | VALUE "Build", "Patch" 54 | #endif 55 | #elif defined(DEBUG) 56 | VALUE "Build", "Debug" 57 | #elif defined(PRERELEASE) 58 | VALUE "Build", "Pre-release" 59 | #else 60 | VALUE "Build", "Private" 61 | #endif 62 | END 63 | END 64 | BLOCK "VarFileInfo" 65 | BEGIN 66 | VALUE "Translation", 0x0, 0 67 | END 68 | END 69 | -------------------------------------------------------------------------------- /src/sys/ndis/ndis.def: -------------------------------------------------------------------------------- 1 | LIBRARY NDIS 2 | 3 | EXPORTS 4 | RtlEqualUnicodeString 5 | DbgPrint 6 | 7 | READ_PORT_UCHAR 8 | READ_PORT_USHORT 9 | WRITE_PORT_USHORT 10 | KeStallExecutionProcessor 11 | 12 | NdisMRegisterMiniport 13 | NdisInitializeWrapper 14 | NdisAllocateBuffer 15 | NdisMFreeSharedMemory 16 | NdisMFreeMapRegisters 17 | NdisMAllocateSharedMemory 18 | NdisMAllocateMapRegisters 19 | NdisAdjustBufferLength 20 | NdisReleaseSpinLock 21 | NDIS_BUFFER_TO_SPAN_PAGES 22 | NdisQueryBufferOffset 23 | NdisAcquireSpinLock 24 | NdisReadPciSlotInformation 25 | NdisWritePciSlotInformation 26 | NdisMSynchronizeWithInterrupt 27 | NdisMCancelTimer 28 | NdisMSetPeriodicTimer 29 | NdisQueryBuffer 30 | NdisFreePacket 31 | NdisFreeBuffer 32 | NdisUnchainBufferAtFront 33 | NdisFreeBufferPool 34 | NdisAllocatePacket 35 | NdisFreePacketPool 36 | NdisAllocateBufferPool 37 | NdisAllocatePacketPool 38 | NdisFreeMemory 39 | NdisFreeSpinLock 40 | NdisMDeregisterAdapterShutdownHandler 41 | NdisMDeregisterIoPortRange 42 | NdisMDeregisterInterrupt 43 | NdisMRegisterInterrupt 44 | NdisMSetAttributesEx 45 | NdisWriteErrorLogEntry 46 | NdisMRegisterIoPortRange 47 | NdisMInitializeTimer 48 | NdisMRegisterAdapterShutdownHandler 49 | NdisAllocateSpinLock 50 | NdisCloseConfiguration 51 | NdisReadNetworkAddress 52 | NdisReadConfiguration 53 | NdisMQueryAdapterResources 54 | NdisOpenConfiguration 55 | NdisAllocateMemoryWithTag 56 | NdisTerminateWrapper 57 | -------------------------------------------------------------------------------- /src/sys/net/ipaddr.c: -------------------------------------------------------------------------------- 1 | // 2 | // ipaddr.c 3 | // 4 | // IP address functions 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // Portions Copyright (C) 2001, Swedish Institute of Computer Science. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions 11 | // are met: 12 | // 13 | // 1. Redistributions of source code must retain the above copyright 14 | // notice, this list of conditions and the following disclaimer. 15 | // 2. Redistributions in binary form must reproduce the above copyright 16 | // notice, this list of conditions and the following disclaimer in the 17 | // documentation and/or other materials provided with the distribution. 18 | // 3. Neither the name of the project nor the names of its contributors 19 | // may be used to endorse or promote products derived from this software 20 | // without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 26 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | // SUCH DAMAGE. 33 | // 34 | 35 | #include 36 | 37 | struct ip_addr ip_addr_any = {0x00000000}; 38 | struct ip_addr ip_addr_broadcast = {0xFFFFFFFF}; 39 | -------------------------------------------------------------------------------- /src/sys/os/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for os.dll 3 | # 4 | 5 | LIB=$(ROOT)/usr/src/lib 6 | 7 | SRCS=\ 8 | critsect.c \ 9 | environ.c \ 10 | heap.c \ 11 | netdb.c \ 12 | os.c \ 13 | resolv.c \ 14 | signal.c \ 15 | sntp.c \ 16 | sysapi.c \ 17 | syserr.c \ 18 | syslog.c \ 19 | thread.c \ 20 | tls.c \ 21 | userdb.c 22 | 23 | LIB_SRCS=\ 24 | $(LIB)/bitops.c \ 25 | $(LIB)/crypt.c \ 26 | $(LIB)/ctype.c \ 27 | $(LIB)/fcvt.c \ 28 | $(LIB)/inifile.c \ 29 | $(LIB)/moddb.c \ 30 | $(LIB)/opts.c \ 31 | $(LIB)/strftime.c \ 32 | $(LIB)/string.c \ 33 | $(LIB)/strtol.c \ 34 | $(LIB)/tcccrt.c \ 35 | $(LIB)/time.c \ 36 | $(LIB)/verinfo.c \ 37 | $(LIB)/vsprintf.c 38 | 39 | LIB_OBJS=modf.o 40 | 41 | all: os.dll 42 | 43 | os.dll: $(SRCS) $(LIB_SRCS) $(LIB_OBJS) 44 | $(CC) -shared -entry _start@12 -fixed 0x7FF00000 -nostdlib -o os.dll -def os.def $(SRCS) $(LIB_SRCS) $(LIB_OBJS) -D OS_LIB 45 | 46 | modf.o: $(LIB)/math/modf.asm 47 | $(AS) $** -o $@ 48 | 49 | install: os.dll 50 | cp os.dll $(ROOT)/boot/os.dll 51 | cp os.def $(ROOT)/usr/lib/os.def 52 | 53 | cross: install 54 | 55 | clean: 56 | rm $(LIB_OBJS) os.dll os.def 57 | 58 | -------------------------------------------------------------------------------- /src/sys/osldr/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for osldr.dll 3 | # 4 | 5 | SRCS=osldr.c loadkrnl.c unzip.c 6 | OBJS=bioscall.o 7 | LIBSRCS=$(ROOT)/usr/src/lib/vsprintf.c $(ROOT)/usr/src/lib/string.c 8 | 9 | all: osldr.dll 10 | 11 | osldr.dll: $(SRCS) $(OBJS) $(LIBSRCS) ldrinit.exe 12 | $(CC) -shared -entry _start@12 -fixed 0x00090000 -filealign 4096 -stub ldrinit.exe -nostdlib -o osldr.dll $(SRCS) $(OBJS) $(LIBSRCS) -D OSLDR -D KERNEL 13 | 14 | bioscall.o: bioscall.asm 15 | $(AS) $** -o $@ 16 | 17 | ldrinit.exe: ldrinit.asm 18 | $(AS) -f bin $** -o $@ 19 | 20 | install: osldr.dll 21 | cp osldr.dll /boot/osldr.dll 22 | mkboot -l /boot/osldr.dll 23 | 24 | cross: osldr.dll 25 | cp osldr.dll $(ROOT)/boot/osldr.dll 26 | 27 | clean: 28 | rm $(OBJS) osldr.dll ldrinit.exe 29 | 30 | -------------------------------------------------------------------------------- /src/utils/ar/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for ar utility 3 | # 4 | 5 | all: ar.exe 6 | 7 | ar.exe: ar.c 8 | $(CC) ar.c 9 | 10 | install: ar.exe 11 | cp ar.exe $(ROOT)/usr/bin/ar.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm ar.exe 17 | -------------------------------------------------------------------------------- /src/utils/ctohtml/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for ctohtml utility 3 | # 4 | 5 | all: ctohtml.exe 6 | 7 | ctohtml.exe: ctohtml.c 8 | $(CC) ctohtml.c 9 | 10 | install: ctohtml.exe 11 | cp ctohtml.exe $(ROOT)/usr/bin/ctohtml.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm ctohtml.exe 17 | -------------------------------------------------------------------------------- /src/utils/edit/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for edit 3 | # 4 | 5 | all: edit.exe less.exe 6 | 7 | edit.exe: edit.c 8 | $(CC) edit.c 9 | 10 | less.exe: edit.c 11 | $(CC) -o less.exe edit.c -DLESS 12 | 13 | install: edit.exe less.exe 14 | cp edit.exe $(ROOT)/bin/edit.exe 15 | cp less.exe $(ROOT)/bin/less.exe 16 | 17 | cross: install 18 | 19 | clean: 20 | rm edit.exe less.exe 21 | -------------------------------------------------------------------------------- /src/utils/fdisk/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for fdisk 3 | # 4 | 5 | all: fdisk.exe 6 | 7 | fdisk.exe: fdisk.c 8 | $(CC) fdisk.c 9 | 10 | install: fdisk.exe 11 | cp fdisk.exe $(ROOT)/bin/fdisk.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm fdisk.exe 17 | -------------------------------------------------------------------------------- /src/utils/ftpd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Make file for ftpd 3 | # 4 | 5 | all: ftpd.exe 6 | 7 | ftpd.exe: ftpd.c 8 | $(CC) ftpd.c 9 | 10 | install: ftpd.exe 11 | cp ftpd.exe $(ROOT)/bin/ftpd.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm ftpd.exe 17 | -------------------------------------------------------------------------------- /src/utils/genvmdk/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for genvmdk 3 | # 4 | 5 | all: genvmdk.exe 6 | 7 | genvmdk.exe: genvmdk.c 8 | $(CC) genvmdk.c 9 | 10 | install: genvmdk.exe 11 | cp genvmdk.exe $(ROOT)/bin/genvmdk.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm genvmdk.exe 17 | 18 | -------------------------------------------------------------------------------- /src/utils/httpd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for httpd 3 | # 4 | 5 | all: httpd.dll 6 | 7 | #TODO: add httpd.res 8 | httpd.dll: httpd.c hbuf.c hfile.c hlog.c hutils.c 9 | $(CC) -shared -D HTTPD_LIB httpd.c hbuf.c hfile.c hlog.c hutils.c -def httpd.def 10 | 11 | install: httpd.dll 12 | cp httpd.dll /bin/httpd.dll 13 | cp httpd.def /usr/lib/httpd.def 14 | 15 | clean: 16 | rm httpd.dll httpd.def 17 | 18 | -------------------------------------------------------------------------------- /src/utils/httpd/file.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/src/utils/httpd/file.gif -------------------------------------------------------------------------------- /src/utils/httpd/folder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/src/utils/httpd/folder.gif -------------------------------------------------------------------------------- /src/utils/httpd/httpd.rc: -------------------------------------------------------------------------------- 1 | LANGUAGE 0, 0 2 | 3 | folder.gif 10 "folder.gif" 4 | file.gif 10 "file.gif" 5 | -------------------------------------------------------------------------------- /src/utils/impdef/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for impdef utility 3 | # 4 | 5 | all: impdef.exe 6 | 7 | impdef.exe: impdef.c 8 | $(CC) impdef.c 9 | 10 | install: impdef.exe 11 | cp impdef.exe $(ROOT)/usr/bin/impdef.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm impdef.exe 17 | -------------------------------------------------------------------------------- /src/utils/login/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for login 3 | # 4 | 5 | all: login.exe 6 | 7 | login.exe: login.c 8 | $(CC) login.c 9 | 10 | install: login.exe 11 | cp login.exe $(ROOT)/bin/login.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm login.exe 17 | -------------------------------------------------------------------------------- /src/utils/make/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for make 3 | # 4 | 5 | all: make.exe 6 | 7 | make.exe: make.c 8 | $(CC) make.c 9 | 10 | install: make.exe 11 | cp make.exe $(ROOT)/usr/bin/make.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm make.exe 17 | -------------------------------------------------------------------------------- /src/utils/mkboot/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for mkboot 3 | # 4 | 5 | all: mkboot.exe 6 | 7 | mkboot.exe: mkboot.c 8 | $(CC) mkboot.c 9 | 10 | install: mkboot.exe 11 | cp mkboot.exe $(ROOT)/bin/mkboot.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm mkboot.exe 17 | 18 | -------------------------------------------------------------------------------- /src/utils/msh/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for mini shell 3 | # 4 | 5 | all: msh.exe 6 | 7 | msh.exe: msh.c 8 | $(CC) msh.c 9 | 10 | install: msh.exe 11 | cp msh.exe /bin/msh.exe 12 | 13 | clean: 14 | rm msh.exe 15 | -------------------------------------------------------------------------------- /src/utils/pkg/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for pkg 3 | # 4 | 5 | all: pkg.exe 6 | 7 | pkg.exe: pkg.c 8 | $(CC) pkg.c 9 | 10 | install: pkg.exe 11 | cp pkg.exe $(ROOT)/bin/pkg.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm pkg.exe 17 | -------------------------------------------------------------------------------- /src/utils/samples/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for sanos sample programs 3 | # 4 | 5 | all: hello.exe hellos.exe calc.exe webserver.exe 6 | 7 | # Hello world using C runtime library 8 | hello.exe: hello.c 9 | $(CC) hello.c 10 | 11 | # Hello world using direct Sanos API 12 | hellos.exe: hellos.c 13 | $(CC) hellos.c -nostdlib -los 14 | 15 | # Simple webserver 16 | webserver.exe: webserver.c 17 | $(CC) webserver.c 18 | 19 | # Simple calculator 20 | calc.exe: calc.c 21 | $(CC) calc.c 22 | 23 | clean: 24 | rm hello.exe hellos.exe calc.exe webserver.exe 25 | -------------------------------------------------------------------------------- /src/utils/samples/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) { 4 | printf("hello world\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /src/utils/samples/hellos.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int mainCRTStartup() { 4 | write(fdout, "hello world\n", 12); 5 | } 6 | -------------------------------------------------------------------------------- /src/utils/setup/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for setup 3 | # 4 | 5 | all: setup.exe 6 | 7 | setup.exe: setup.c 8 | $(CC) setup.c 9 | 10 | install: setup.exe 11 | cp setup.exe $(ROOT)/bin/setup.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm setup.exe 17 | -------------------------------------------------------------------------------- /src/utils/sh/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for shell 3 | # 4 | 5 | all: sh.exe 6 | 7 | SH_SRCFILES=node.c stmalloc.c input.c chartype.c parser.c job.c interp.c sh.c builtins.c cmds.c 8 | SH_HDRFILES=node.h stmalloc.h input.h chartype.h parser.h job.h interp.h sh.h 9 | CMDS= \ 10 | ../../cmds/chgrp.c \ 11 | ../../cmds/chmod.c \ 12 | ../../cmds/chown.c \ 13 | ../../cmds/cp.c \ 14 | ../../cmds/du.c \ 15 | ../../cmds/ls.c \ 16 | ../../cmds/mkdir.c \ 17 | ../../cmds/mv.c \ 18 | ../../cmds/ping.c \ 19 | ../../cmds/rm.c \ 20 | ../../cmds/test.c \ 21 | ../../cmds/touch.c \ 22 | ../../cmds/wc.c 23 | 24 | sh.exe: $(SH_SRCFILES) $(SH_HDRFILES) $(CMDS) 25 | $(CC) -o sh.exe $(SH_SRCFILES) $(CMDS) -D SHELL 26 | 27 | install: sh.exe 28 | cp sh.exe $(ROOT)/bin/sh.exe 29 | 30 | cross: install 31 | 32 | clean: 33 | rm sh.exe 34 | 35 | -------------------------------------------------------------------------------- /src/utils/sh/input.h: -------------------------------------------------------------------------------- 1 | // 2 | // input.h 3 | // 4 | // Shell input 5 | // 6 | // Copyright (C) 2011 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef INPUT_H 35 | #define INPUT_H 36 | 37 | #define FILEBUFSIZ 512 38 | 39 | struct inputfile { 40 | struct inputfile *prev; 41 | int lineno; 42 | int fd; 43 | 44 | char *buf; 45 | char *ptr; 46 | char *end; 47 | }; 48 | 49 | int pushfile(struct inputfile **file, int fd); 50 | int pushstr(struct inputfile **file, char *str); 51 | int popfile(struct inputfile **file); 52 | void popallfiles(struct inputfile **file); 53 | 54 | int pgetc(struct inputfile **file, int peek); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /src/utils/sh/interp.h: -------------------------------------------------------------------------------- 1 | // 2 | // interp.h 3 | // 4 | // Shell command interpreter 5 | // 6 | // Copyright (C) 2012 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #ifndef INTERP_H 35 | #define INTERP_H 36 | 37 | int interp(struct job *parent, union node *node); 38 | 39 | #endif 40 | 41 | -------------------------------------------------------------------------------- /src/utils/sh/node.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/src/utils/sh/node.h -------------------------------------------------------------------------------- /src/utils/telnetd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Make file for telnetd 3 | # 4 | 5 | all: telnetd.exe 6 | 7 | telnetd.exe: telnetd.c 8 | $(CC) telnetd.c 9 | 10 | install: telnetd.exe 11 | cp telnetd.exe $(ROOT)/bin/telnetd.exe 12 | 13 | cross: install 14 | 15 | clean: 16 | rm telnetd.exe 17 | -------------------------------------------------------------------------------- /src/win32/advapi32/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for advapi32 library 3 | # 4 | 5 | all: advapi32.dll 6 | 7 | advapi32.dll: advapi32.c 8 | $(CC) -shared -o $@ $^ 9 | 10 | install: advapi32.dll 11 | cp advapi32.dll /bin/advapi32.dll 12 | 13 | clean: 14 | rm advapi32.dll 15 | -------------------------------------------------------------------------------- /src/win32/advapi32/advapi32.def: -------------------------------------------------------------------------------- 1 | LIBRARY ADVAPI32 2 | 3 | EXPORTS 4 | GetUserNameA 5 | RegCloseKey 6 | RegEnumKeyExA 7 | RegOpenKeyExA 8 | RegOpenKeyExW 9 | RegQueryInfoKeyA 10 | RegQueryValueExA 11 | RegQueryValueExW 12 | RegCreateKeyExA 13 | RegEnumValueA 14 | RegDeleteValueA 15 | RegSetValueExA 16 | RegFlushKey 17 | RegDeleteKeyA 18 | RegisterEventSourceA 19 | DeregisterEventSource 20 | ReportEventA 21 | CryptAcquireContextA 22 | CryptReleaseContext 23 | CryptGenRandom 24 | StartServiceCtrlDispatcherA 25 | SetServiceStatus 26 | RegisterServiceCtrlHandlerA 27 | AllocateAndInitializeSid 28 | AddAccessAllowedAce 29 | CopySid 30 | FreeSid 31 | GetLengthSid 32 | GetSecurityDescriptorDacl 33 | OpenProcessToken 34 | GetTokenInformation 35 | InitializeAcl 36 | InitializeSecurityDescriptor 37 | SetSecurityDescriptorDacl 38 | -------------------------------------------------------------------------------- /src/win32/kernel32/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for kernel32 library 3 | # 4 | 5 | all: kernel32.dll 6 | 7 | kernel32.dll: kernel32.c 8 | $(CC) -shared -o $@ $^ 9 | 10 | install: kernel32.dll 11 | cp kernel32.dll /bin/kernel32.dll 12 | 13 | clean: 14 | rm kernel32.dll 15 | -------------------------------------------------------------------------------- /src/win32/msvcrt/malloc.c: -------------------------------------------------------------------------------- 1 | // 2 | // malloc.c 3 | // 4 | // Heap allocation 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #include "msvcrt.h" 35 | 36 | void *_malloc(size_t size) { 37 | TRACEX("_malloc"); 38 | return malloc(size); 39 | } 40 | 41 | void *_calloc(size_t num, size_t size) { 42 | TRACEX("_calloc"); 43 | return calloc(num, size); 44 | } 45 | 46 | void *_realloc(void *mem, size_t size) { 47 | TRACEX("_realloc"); 48 | return realloc(mem, size); 49 | } 50 | 51 | void _free(void *mem) { 52 | TRACEX("_free"); 53 | free(mem); 54 | } 55 | -------------------------------------------------------------------------------- /src/win32/user32/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for user32 library 3 | # 4 | 5 | all: user32.dll 6 | 7 | user32.dll: user32.c 8 | $(CC) -shared -o $@ $^ 9 | 10 | install: user32.dll 11 | cp user32.dll /bin/user32.dll 12 | 13 | clean: 14 | rm user32.dll 15 | -------------------------------------------------------------------------------- /src/win32/user32/user32.c: -------------------------------------------------------------------------------- 1 | // 2 | // user32.c 3 | // 4 | // Win32 USER32 emulation 5 | // 6 | // Copyright (C) 2002 Michael Ringgaard. All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions 10 | // are met: 11 | // 12 | // 1. Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // 2. Redistributions in binary form must reproduce the above copyright 15 | // notice, this list of conditions and the following disclaimer in the 16 | // documentation and/or other materials provided with the distribution. 17 | // 3. Neither the name of the project nor the names of its contributors 18 | // may be used to endorse or promote products derived from this software 19 | // without specific prior written permission. 20 | // 21 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 25 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | // SUCH DAMAGE. 32 | // 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | int WINAPI MessageBoxA( 39 | HWND hWnd, 40 | LPCTSTR lpText, 41 | LPCTSTR lpCaption, 42 | UINT uType) { 43 | TRACE("MessageBoxA"); 44 | syslog(LOG_INFO, "Messagebox %s: %s", lpCaption, lpText); 45 | panic("MessageBoxA not implemented"); 46 | return 0; 47 | } 48 | 49 | int __stdcall DllMain(handle_t hmod, int reason, void *reserved) { 50 | return TRUE; 51 | } 52 | -------------------------------------------------------------------------------- /src/win32/user32/user32.def: -------------------------------------------------------------------------------- 1 | LIBRARY USER32 2 | 3 | EXPORTS 4 | MessageBoxA 5 | -------------------------------------------------------------------------------- /src/win32/winmm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for winmm library 3 | # 4 | 5 | all: winmm.dll 6 | 7 | winmm.dll: winmm.c 8 | $(CC) -shared -o $@ $^ 9 | 10 | install: winmm.dll 11 | cp winmm.dll /bin/winmm.dll 12 | 13 | clean: 14 | rm winmm.dll 15 | -------------------------------------------------------------------------------- /src/win32/winmm/winmm.def: -------------------------------------------------------------------------------- 1 | LIBRARY WINMM 2 | 3 | EXPORTS 4 | timeBeginPeriod 5 | timeEndPeriod 6 | timeGetTime 7 | -------------------------------------------------------------------------------- /tools/ar.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/ar.exe -------------------------------------------------------------------------------- /tools/bochs/BIOS-bochs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/bochs/BIOS-bochs -------------------------------------------------------------------------------- /tools/bochs/VGABIOS-elpin-2.40: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/bochs/VGABIOS-elpin-2.40 -------------------------------------------------------------------------------- /tools/bochs/VGABIOS-lgpl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/bochs/VGABIOS-lgpl -------------------------------------------------------------------------------- /tools/bochs/bochs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/bochs/bochs.exe -------------------------------------------------------------------------------- /tools/bochs/bochsdbg.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/bochs/bochsdbg.exe -------------------------------------------------------------------------------- /tools/bochs/bochsrc.txt: -------------------------------------------------------------------------------- 1 | #======================================================================= 2 | # Bochs configuration for sanos 3 | #======================================================================= 4 | 5 | megs: 32 6 | 7 | boot: floppy 8 | #boot: disk 9 | #boot: cdrom 10 | 11 | floppya: image=..\..\img\sanos.flp, status=inserted 12 | 13 | ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 14 | ata1: enabled=0, ioaddr1=0x170, ioaddr2=0x370, irq=15 15 | 16 | #ata0-master: type=disk, mode=flat, path="..\..\img\sanos.img", cylinders=81, heads=16, spt=63 17 | #ata0-slave: type=cdrom, path=..\..\img\sanos.iso, status=inserted 18 | 19 | #ne2k: ioaddr=0x300, irq=3, mac=b0:c4:20:00:00:00, ethmod=win32, ethdev=\Device\NPF_NdisWanIp 20 | ne2k: ioaddr=0x240, irq=9, mac=b0:c4:20:00:00:01, ethmod=vnet, ethdev="c:/temp" 21 | 22 | i440fxsupport: enabled=1, slot1=pcivga, slot2=ne2k 23 | 24 | config_interface: textconfig 25 | 26 | #display_library: rfb, options="timeout=60" # time to wait for client 27 | display_library: win32, options="legacyF12" # use F12 to toggle mouse 28 | 29 | romimage: file=BIOS-bochs, address=0xf0000 30 | #vgaromimage: file=bios/VGABIOS-elpin-2.40 31 | vgaromimage: file=VGABIOS-lgpl 32 | 33 | vga: extension=vbe 34 | #vga: extension=none 35 | vga_update_interval: 300000 36 | 37 | ips: 100000000 38 | clock: sync=none, time0=local 39 | 40 | log: bochsout.txt 41 | panic: action=ask 42 | error: action=report 43 | info: action=report 44 | debug: action=ignore 45 | #pass: action=fatal 46 | 47 | #debugger_log: /dev/null 48 | #debugger_log: debugger.out 49 | debugger_log: - 50 | 51 | keyboard_serial_delay: 250 52 | keyboard_paste_delay: 100000 53 | floppy_command_delay: 500 54 | -------------------------------------------------------------------------------- /tools/bochs/bximage.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/bochs/bximage.exe -------------------------------------------------------------------------------- /tools/ctags.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/ctags.exe -------------------------------------------------------------------------------- /tools/cygwin1.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/cygwin1.dll -------------------------------------------------------------------------------- /tools/linecount.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/linecount.exe -------------------------------------------------------------------------------- /tools/loc.cmd: -------------------------------------------------------------------------------- 1 | dir /b /s src\*.c src\*.h src\*.asm src\*.cpp | tools\linecount 2 | -------------------------------------------------------------------------------- /tools/mkisofs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/mkisofs.exe -------------------------------------------------------------------------------- /tools/qemu/SDL.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/qemu/SDL.dll -------------------------------------------------------------------------------- /tools/qemu/bios.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/qemu/bios.bin -------------------------------------------------------------------------------- /tools/qemu/fmod.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/qemu/fmod.dll -------------------------------------------------------------------------------- /tools/qemu/qemu-img.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/qemu/qemu-img.exe -------------------------------------------------------------------------------- /tools/qemu/qemu.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/qemu/qemu.exe -------------------------------------------------------------------------------- /tools/qemu/runsanos.cmd: -------------------------------------------------------------------------------- 1 | qemu -hda ..\..\img\sanos.vmdk -boot c -redir tcp:2323::23 -redir tcp:8080::80 -L . -no-kqemu 2 | -------------------------------------------------------------------------------- /tools/qemu/runsanosfloppy.cmd: -------------------------------------------------------------------------------- 1 | start qemu -L . -hda ..\..\img\sanos.vmdk -fda ..\..\img\sanos.flp -cdrom ..\..\img\sanos.iso -boot a -redir tcp:2323::23 2 | -------------------------------------------------------------------------------- /tools/qemu/vgabios-cirrus.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/qemu/vgabios-cirrus.bin -------------------------------------------------------------------------------- /tools/zip.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/tools/zip.exe -------------------------------------------------------------------------------- /utils/cifstest/smb.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/utils/cifstest/smb.h -------------------------------------------------------------------------------- /utils/dbggw/rdp.h: -------------------------------------------------------------------------------- 1 | // 2 | // rdp.h 3 | // 4 | // Copyright (c) 2001 Michael Ringgaard. All rights reserved. 5 | // 6 | // Remote debugging protocol 7 | // 8 | 9 | #ifndef RDP_H 10 | #define RDP_H 11 | 12 | typedef unsigned long tid_t; 13 | typedef void *hmodule_t; 14 | 15 | // 16 | // Context structure from os.h 17 | // 18 | 19 | struct context 20 | { 21 | unsigned long es, ds; 22 | unsigned long edi, esi, ebp, ebx, edx, ecx, eax; 23 | unsigned long traptype; 24 | unsigned long errcode; 25 | 26 | unsigned long eip, ecs; 27 | unsigned long eflags; 28 | unsigned long esp, ess; 29 | }; 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #define GLOBAL_PROCID 1 37 | #define GLOBAL_HPROC 0x0123 38 | 39 | #define MAX_DBG_CHUNKSIZE 4096 40 | #define MAX_DBG_PACKETLEN (MAX_DBG_CHUNKSIZE + sizeof(union dbg_body)) 41 | 42 | struct dbg_session 43 | { 44 | HANDLE target; 45 | unsigned char next_reqid; 46 | 47 | struct dbg_event *event_head; 48 | struct dbg_event *event_tail; 49 | 50 | struct dbg_connect conn; 51 | 52 | struct dbg_hdr hdr; 53 | char dbg_data[MAX_DBG_PACKETLEN]; 54 | union dbg_body *body; 55 | }; 56 | 57 | struct dbg_session *dbg_create_session(char *port); 58 | void dbg_close_session(struct dbg_session *s, int resume); 59 | 60 | struct dbg_event *dbg_next_event(struct dbg_session *s); 61 | void dbg_release_event(struct dbg_event *e); 62 | 63 | int dbg_continue(struct dbg_session *s); 64 | 65 | int dbg_read_memory(struct dbg_session *s, void *addr, int size, void *buffer); 66 | int dbg_write_memory(struct dbg_session *s, void *addr, int size, void *buffer); 67 | 68 | int dbg_get_context(struct dbg_session *s, tid_t tid, struct context *ctxt); 69 | int dbg_set_context(struct dbg_session *s, tid_t tid, struct context *ctxt); 70 | 71 | int dbg_suspend_threads(struct dbg_session *s, tid_t *threadids, int count); 72 | int dbg_resume_threads(struct dbg_session *s, tid_t *threadids, int count); 73 | 74 | int dbg_get_selector(struct dbg_session *s, int sel, struct segment *seg); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /utils/dfs/bitops.h: -------------------------------------------------------------------------------- 1 | #ifndef BITOPS_H 2 | #define BITOPS_H 3 | 4 | #define BITS_PER_BYTE 8 5 | 6 | #ifndef __linux__ 7 | #define USE_I386_BITOPS 8 | #endif 9 | 10 | #ifdef USE_I386_BITOPS 11 | 12 | __inline void set_bit(void *bitmap, int pos) 13 | { 14 | __asm 15 | { 16 | mov eax, pos 17 | mov ebx, bitmap 18 | bts dword ptr [ebx], eax 19 | } 20 | } 21 | 22 | __inline void clear_bit(void *bitmap, int pos) 23 | { 24 | __asm 25 | { 26 | mov eax, pos 27 | mov ebx, bitmap 28 | btr dword ptr [ebx], eax 29 | } 30 | } 31 | 32 | __inline int test_bit(void *bitmap, int pos) 33 | { 34 | int result; 35 | 36 | __asm 37 | { 38 | mov eax, pos 39 | mov ebx, bitmap 40 | bt dword ptr [ebx], eax 41 | sbb eax, eax 42 | mov result, eax 43 | } 44 | 45 | return result; 46 | } 47 | 48 | #else 49 | 50 | static __inline void set_bit(void *bitmap, int pos) 51 | { 52 | *(((unsigned char *) bitmap) + (pos / BITS_PER_BYTE)) |= (1 << (pos % BITS_PER_BYTE)); 53 | } 54 | 55 | static __inline void clear_bit(void *bitmap, int pos) 56 | { 57 | *(((unsigned char *) bitmap) + (pos / BITS_PER_BYTE)) &= ~(1 << (pos % BITS_PER_BYTE)); 58 | } 59 | 60 | static __inline int test_bit(void *bitmap, int pos) 61 | { 62 | return *(((unsigned char *) bitmap) + (pos / BITS_PER_BYTE)) & (1 << (pos % BITS_PER_BYTE)); 63 | } 64 | 65 | #endif 66 | 67 | static __inline void set_bits(void *bitmap, int pos, int len) 68 | { 69 | while (len-- > 0) set_bit(bitmap, pos++); 70 | } 71 | 72 | int find_first_zero_bit(void *bitmap, int len); 73 | int find_next_zero_bit(void *bitmap, int len, int start); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /utils/dfs/blockdev.h: -------------------------------------------------------------------------------- 1 | #ifndef BLOCKDEV_H 2 | #define BLOCKDEV_H 3 | 4 | #include "types.h" 5 | 6 | struct blockdevice; 7 | 8 | struct blockdriver 9 | { 10 | const char *format_name; 11 | int instance_size; 12 | int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); 13 | int (*bdrv_open)(struct blockdevice *bs, const char *filename); 14 | int (*bdrv_read)(struct blockdevice *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); 15 | int (*bdrv_write)(struct blockdevice *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors); 16 | void (*bdrv_close)(struct blockdevice *bs); 17 | int (*bdrv_create)(const char *filename, int64_t total_sectors, int flags); 18 | int (*bdrv_is_allocated)(struct blockdevice *bs, int64_t sector_num, int nb_sectors, int *pnum); 19 | int (*bdrv_set_key)(struct blockdevice *bs, const char *key); 20 | }; 21 | 22 | struct blockdevice 23 | { 24 | int64_t total_sectors; 25 | struct blockdriver *drv; 26 | void *opaque; 27 | char filename[1024]; 28 | 29 | // NOTE: the following infos are only hints for real hardware drivers. 30 | // They are not used by the block driver 31 | 32 | int cyls, heads, secs, translation; 33 | int type; 34 | char device_name[32]; 35 | }; 36 | 37 | int bdrv_create(char *type, const char *filename, int64_t size_in_sectors, int flags); 38 | int bdrv_open(struct blockdevice *bs, const char *filename, struct blockdriver *drv); 39 | void bdrv_close(struct blockdevice *bs); 40 | int bdrv_read(struct blockdevice *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); 41 | int bdrv_write(struct blockdevice *bs, int64_t sector_num, uint8_t *buf, int nb_sectors); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /utils/dfs/buf.h: -------------------------------------------------------------------------------- 1 | #ifndef BUF_H 2 | #define BUF_H 3 | 4 | struct thread 5 | { 6 | void *ready; 7 | struct thread *next_buffer_waiter; 8 | }; 9 | 10 | #define BUFPOOL_HASHSIZE 512 11 | 12 | #define BUF_STATE_FREE 0 13 | #define BUF_STATE_CLEAN 1 14 | #define BUF_STATE_DIRTY 2 15 | #define BUF_STATE_READING 3 16 | #define BUF_STATE_WRITING 4 17 | #define BUF_STATE_LOCKED 5 18 | #define BUF_STATE_UPDATED 6 19 | #define BUF_STATE_INVALID 7 20 | 21 | struct buf; 22 | 23 | struct buflist 24 | { 25 | struct buf *head; 26 | struct buf *tail; 27 | }; 28 | 29 | struct buflink 30 | { 31 | struct buf *next; 32 | struct buf *prev; 33 | }; 34 | 35 | struct buf 36 | { 37 | struct buflink bucket; 38 | struct buflink chain; 39 | unsigned short state; 40 | unsigned short locks; 41 | struct thread *waiters; 42 | vfs_blkno_t blkno; 43 | char *data; 44 | }; 45 | 46 | struct bufpool 47 | { 48 | vfs_devno_t devno; 49 | int poolsize; 50 | int bufsize; 51 | int blks_per_buffer; 52 | 53 | struct buf *bufbase; 54 | char *database; 55 | 56 | struct buflist dirty; // List of dirty buffers (head is least recently changed) 57 | struct buflist clean; // List of clean buffers (head is least recently used) 58 | struct buf *freelist; // List of free buffers 59 | 60 | struct buf *hashtable[BUFPOOL_HASHSIZE]; 61 | }; 62 | 63 | struct bufpool *init_buffer_pool(vfs_devno_t devno, int poolsize, int bufsize); 64 | void free_buffer_pool(struct bufpool *pool); 65 | struct buf *get_buffer(struct bufpool *pool, vfs_blkno_t blkno); 66 | struct buf *alloc_buffer(struct bufpool *pool, vfs_blkno_t blkno); 67 | void mark_buffer_updated(struct buf *buf); 68 | void mark_buffer_invalid(struct buf *buf); 69 | void release_buffer(struct bufpool *pool, struct buf *buf); 70 | void invalidate_buffer(struct bufpool *pool, vfs_blkno_t blkno); 71 | void flush_buffers(struct bufpool *pool); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /utils/dfs/getopt.h: -------------------------------------------------------------------------------- 1 | #ifndef GETOPT_H 2 | #define GETOPT_H 3 | 4 | extern int opterr; 5 | extern int optind; 6 | extern int optopt; 7 | extern char *optarg; 8 | 9 | int getopt(int argc, char **argv, char *opts); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /utils/dfs/mbr.h: -------------------------------------------------------------------------------- 1 | // 2 | // mbr.h 3 | // 4 | // Copyright (c) 2001 Michael Ringgaard. All rights reserved. 5 | // 6 | // Master Boot Record 7 | // 8 | 9 | #ifndef MBR_H 10 | #define MBR_H 11 | 12 | #define MBR_SIGNATURE 0xAA55 13 | 14 | #define SANOS_BOOT_PARTITION_ID 6 15 | 16 | #pragma pack(push) 17 | #pragma pack(1) 18 | 19 | struct disk_partition 20 | { 21 | unsigned char bootid; // Bootable? 0=no, 128=yes 22 | unsigned char beghead; // Beginning head number 23 | unsigned char begsect; // Beginning sector number 24 | unsigned char begcyl; // 10 bit nmbr, with high 2 bits put in begsect 25 | unsigned char systid; // Operating System type indicator code 26 | unsigned char endhead; // Ending head number 27 | unsigned char endsect; // Ending sector number 28 | unsigned char endcyl; // Also a 10 bit nmbr, with same high 2 bit trick 29 | unsigned int relsect; // First sector relative to start of disk 30 | unsigned int numsect; // Number of sectors in partition 31 | }; 32 | 33 | struct master_boot_record 34 | { 35 | char bootstrap[446]; 36 | struct disk_partition parttab[4]; 37 | unsigned short signature; 38 | }; 39 | 40 | struct boot_sector 41 | { 42 | char prolog[4]; 43 | char label[8]; 44 | unsigned short ldrsize; 45 | unsigned long ldrstart; 46 | char bootstrap[492]; 47 | unsigned short signature; 48 | }; 49 | 50 | #pragma pack(pop) 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /utils/dfs/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | #define VFS_S_IFMT 0170000 // File type mask 5 | #define VFS_S_IFREG 0100000 // Regular file 6 | #define VFS_S_IFDIR 0040000 // Directory 7 | 8 | #define VFS_S_IREAD 0000400 // Read permission, owner 9 | #define VFS_S_IWRITE 0000200 // Write permission, owner 10 | #define VFS_S_IEXEC 0000100 // Execute/search permission, owner 11 | 12 | #define VFS_S_ISREG(m) (((m) & VFS_S_IFMT) == VFS_S_IFREG) 13 | #define VFS_S_ISDIR(m) (((m) & VFS_S_IFMT) == VFS_S_IFDIR) 14 | 15 | #define VFS_S_IRWXU 00700 16 | #define VFS_S_IRWXG 00070 17 | #define VFS_S_IRWXO 00007 18 | 19 | typedef unsigned int vfs_devno_t; 20 | typedef unsigned int vfs_blkno_t; 21 | typedef unsigned int vfs_ino_t; 22 | typedef unsigned int vfs_loff_t; 23 | typedef unsigned int vfs_time_t; 24 | 25 | #ifdef WIN32 26 | typedef signed char int8_t; 27 | typedef short int16_t; 28 | typedef int int32_t; 29 | typedef __int64 int64_t; 30 | 31 | typedef unsigned char uint8_t; 32 | typedef unsigned short uint16_t; 33 | typedef unsigned int uint32_t; 34 | typedef unsigned __int64 uint64_t; 35 | #endif 36 | 37 | #ifdef __linux__ 38 | typedef signed char int8_t; 39 | typedef short int16_t; 40 | typedef int int32_t; 41 | typedef long long int64_t; 42 | 43 | typedef unsigned char uint8_t; 44 | typedef unsigned short uint16_t; 45 | typedef unsigned int uint32_t; 46 | typedef unsigned long long uint64_t; 47 | #endif 48 | 49 | #endif 50 | 51 | -------------------------------------------------------------------------------- /utils/echosrv/echosrv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void panic(char *msg) 5 | { 6 | printf("panic: %s\n", msg); 7 | exit(1); 8 | } 9 | 10 | void main(int argc, char *argv[]) 11 | { 12 | WSADATA wsadata; 13 | SOCKADDR_IN sin; 14 | int rc; 15 | SOCKET listener; 16 | SOCKET s; 17 | char buf[4096]; 18 | int len; 19 | int bytes; 20 | 21 | // Initialize winsock 22 | rc = WSAStartup(MAKEWORD(2, 2), &wsadata); 23 | if (rc != 0) panic("error in WSAStartup"); 24 | 25 | // Create listen socket 26 | listener = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); 27 | if (listener == INVALID_SOCKET) panic("error in socket"); 28 | 29 | // Bind the socket to the service port 30 | memset(&sin, 0, sizeof(sin)); 31 | sin.sin_family = AF_INET; 32 | sin.sin_addr.s_addr = INADDR_ANY; 33 | sin.sin_port = htons(80); 34 | if (bind(listener, (LPSOCKADDR) &sin, sizeof(sin)) == SOCKET_ERROR) panic("error in bind"); 35 | 36 | // Listen for incoming connections on the socket 37 | if (listen(listener, 5) == SOCKET_ERROR) panic("error in listen"); 38 | 39 | // Wait and accept new connection from client 40 | while (1) 41 | { 42 | printf("waiting for connection...\n"); 43 | s = accept(listener, NULL, NULL); 44 | if (s == INVALID_SOCKET) panic("error in accept"); 45 | 46 | printf("connected\n"); 47 | 48 | while ((len = recv(s, buf, 4096, 0)) > 0) 49 | { 50 | printf("recv %d bytes\n", len); 51 | bytes = send(s, buf, len, 0); 52 | if (bytes != len) printf("send %d bytes, %d bytes sent\n", len, bytes); 53 | } 54 | 55 | printf("closing connection\n"); 56 | closesocket(s); 57 | printf("connection closed\n"); 58 | } 59 | 60 | closesocket(listener); 61 | } 62 | -------------------------------------------------------------------------------- /utils/emul/src/advapi32/advapi32.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define USERNAME "root" 5 | 6 | BOOL WINAPI GetUserNameA 7 | ( 8 | LPTSTR lpBuffer, 9 | LPDWORD nSize 10 | ) 11 | { 12 | strcpy(lpBuffer, USERNAME); 13 | return TRUE; 14 | } 15 | 16 | LONG WINAPI RegCloseKey 17 | ( 18 | HKEY hKey 19 | ) 20 | { 21 | panic("RegCloseKey not implemented"); 22 | return -1; 23 | } 24 | 25 | LONG WINAPI RegEnumKeyExA 26 | ( 27 | HKEY hKey, 28 | DWORD dwIndex, 29 | LPTSTR lpName, 30 | LPDWORD lpcName, 31 | LPDWORD lpReserved, 32 | LPTSTR lpClass, 33 | LPDWORD lpcClass, 34 | PFILETIME lpftLastWriteTime 35 | ) 36 | { 37 | panic("RegEnumKeyExA not implemented"); 38 | return -1; 39 | } 40 | 41 | LONG WINAPI RegOpenKeyExA 42 | ( 43 | HKEY hKey, 44 | LPCTSTR lpSubKey, 45 | DWORD ulOptions, 46 | REGSAM samDesired, 47 | PHKEY phkResult 48 | ) 49 | { 50 | syslog(LOG_DEBUG, "warning: RegOpenKeyEx(%p,%s) ignored\n", hKey, lpSubKey); 51 | //panic("RegOpenKeyExA not implemented"); 52 | return -1; 53 | } 54 | 55 | LONG WINAPI RegQueryInfoKeyA 56 | ( 57 | HKEY hKey, 58 | LPTSTR lpClass, 59 | LPDWORD lpcClass, 60 | LPDWORD lpReserved, 61 | LPDWORD lpcSubKeys, 62 | LPDWORD lpcMaxSubKeyLen, 63 | LPDWORD lpcMaxClassLen, 64 | LPDWORD lpcValues, 65 | LPDWORD lpcMaxValueNameLen, 66 | LPDWORD lpcMaxValueLen, 67 | LPDWORD lpcbSecurityDescriptor, 68 | PFILETIME lpftLastWriteTime 69 | ) 70 | { 71 | panic("RegQueryInfoKeyA not implemented"); 72 | return -1; 73 | } 74 | 75 | LONG WINAPI RegQueryValueExA 76 | ( 77 | HKEY hKey, 78 | LPCTSTR lpValueName, 79 | LPDWORD lpReserved, 80 | LPDWORD lpType, 81 | LPBYTE lpData, 82 | LPDWORD lpcbData 83 | ) 84 | { 85 | panic("RegQueryValueExA not implemented"); 86 | return -1; 87 | } 88 | 89 | int __stdcall DllMain(handle_t hmod, int reason, void *reserved) 90 | { 91 | return TRUE; 92 | } 93 | -------------------------------------------------------------------------------- /utils/emul/src/advapi32/advapi32.def: -------------------------------------------------------------------------------- 1 | LIBRARY ADVAPI32 2 | DESCRIPTION 'ADVAPI32' 3 | 4 | EXPORTS 5 | GetUserNameA 6 | RegCloseKey 7 | RegEnumKeyExA 8 | RegOpenKeyExA 9 | RegQueryInfoKeyA 10 | RegQueryValueExA 11 | -------------------------------------------------------------------------------- /utils/emul/src/jexec/jawt_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jawt_md.h 1.4 00/02/02 3 | * 4 | * Copyright 1999, 2000 Sun Microsystems, Inc. All Rights Reserved. 5 | * 6 | * This software is the proprietary information of Sun Microsystems, Inc. 7 | * Use is subject to license terms. 8 | * 9 | */ 10 | 11 | #ifndef _JAVASOFT_JAWT_MD_H_ 12 | #define _JAVASOFT_JAWT_MD_H_ 13 | 14 | #include 15 | #include "jawt.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /* 22 | * Win32-specific declarations for AWT native interface. 23 | * See notes in jawt.h for an example of use. 24 | */ 25 | typedef struct jawt_Win32DrawingSurfaceInfo { 26 | /* Native window, DDB, or DIB handle */ 27 | union { 28 | HWND hwnd; 29 | HBITMAP hbitmap; 30 | void* pbits; 31 | }; 32 | /* 33 | * This HDC should always be used instead of the HDC returned from 34 | * BeginPaint() or any calls to GetDC(). 35 | */ 36 | HDC hdc; 37 | HPALETTE hpalette; 38 | } JAWT_Win32DrawingSurfaceInfo; 39 | 40 | #ifdef __cplusplus 41 | } 42 | #endif 43 | 44 | #endif /* !_JAVASOFT_JAWT_MD_H_ */ 45 | -------------------------------------------------------------------------------- /utils/emul/src/jexec/jni_md.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @(#)jni_md.h 1.11 00/02/02 3 | * 4 | * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved. 5 | * 6 | * This software is the proprietary information of Sun Microsystems, Inc. 7 | * Use is subject to license terms. 8 | * 9 | */ 10 | 11 | #ifndef _JAVASOFT_JNI_MD_H_ 12 | #define _JAVASOFT_JNI_MD_H_ 13 | 14 | #define JNIEXPORT __declspec(dllexport) 15 | #define JNIIMPORT __declspec(dllimport) 16 | #define JNICALL __stdcall 17 | 18 | typedef long jint; 19 | typedef __int64 jlong; 20 | typedef signed char jbyte; 21 | 22 | #endif /* !_JAVASOFT_JNI_MD_H_ */ 23 | -------------------------------------------------------------------------------- /utils/emul/src/jexec/stdarg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/utils/emul/src/jexec/stdarg.h -------------------------------------------------------------------------------- /utils/emul/src/jexec/stdio.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ringgaard/sanos/b6ea5cb56f9f6b76c7664865067ac812a7efdc96/utils/emul/src/jexec/stdio.h -------------------------------------------------------------------------------- /utils/emul/src/kernel32/kernel32.def: -------------------------------------------------------------------------------- 1 | LIBRARY KERNEL32 2 | DESCRIPTION 'KERNEL32' 3 | 4 | EXPORTS 5 | CloseHandle 6 | CreateEventA 7 | CreateFileA 8 | CreatePipe 9 | CreateProcessA 10 | CreateSemaphoreA 11 | DebugBreak 12 | DeleteFileA 13 | DisableThreadLibraryCalls 14 | DuplicateHandle 15 | EnterCriticalSection 16 | FindClose 17 | FindFirstFileA 18 | FindNextFileA 19 | FlushFileBuffers 20 | FormatMessageA 21 | FreeLibrary 22 | GetCurrentDirectoryA 23 | GetCurrentProcess 24 | GetCurrentThread 25 | GetCurrentThreadId 26 | GetEnvironmentVariableA 27 | GetExitCodeProcess 28 | GetFileAttributesA 29 | GetLastError 30 | GetLogicalDrives 31 | GetModuleFileNameA 32 | GetNumberOfConsoleInputEvents 33 | GetProcAddress 34 | GetStdHandle 35 | GetSystemDirectoryA 36 | GetSystemInfo 37 | GetSystemTime 38 | GetSystemTimeAsFileTime 39 | GetTempPathA 40 | GetThreadContext 41 | GetThreadLocale 42 | GetThreadPriority 43 | GetThreadTimes 44 | GetTimeZoneInformation 45 | GetVersionExA 46 | GetWindowsDirectoryA 47 | InitializeCriticalSection 48 | InterlockedDecrement 49 | InterlockedIncrement 50 | IsDBCSLeadByte 51 | LeaveCriticalSection 52 | LoadLibraryA 53 | PeekConsoleInputA 54 | QueryPerformanceCounter 55 | QueryPerformanceFrequency 56 | PeekNamedPipe 57 | ReleaseSemaphore 58 | RemoveDirectoryA 59 | ResetEvent 60 | ResumeThread 61 | SetConsoleCtrlHandler 62 | SetEndOfFile 63 | SetEvent 64 | SetFileAttributesA 65 | SetFilePointer 66 | SetFileTime 67 | SetHandleInformation 68 | SetThreadContext 69 | SetThreadPriority 70 | SetUnhandledExceptionFilter 71 | Sleep 72 | SuspendThread 73 | SystemTimeToFileTime 74 | TerminateProcess 75 | TlsAlloc 76 | TlsGetValue 77 | TlsSetValue 78 | VirtualAlloc 79 | VirtualFree 80 | VirtualQuery 81 | WaitForMultipleObjects 82 | WaitForSingleObject 83 | WideCharToMultiByte 84 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/atox.c: -------------------------------------------------------------------------------- 1 | #include "msvcrt.h" 2 | 3 | long atol(const char *nptr) 4 | { 5 | int c; 6 | long total; 7 | int sign; 8 | 9 | while (isspace((int)(unsigned char) *nptr)) ++nptr; 10 | 11 | c = (int)(unsigned char) *nptr++; 12 | sign = c; 13 | if (c == '-' || c == '+') c = (int)(unsigned char) *nptr++; 14 | 15 | total = 0; 16 | while (isdigit(c)) 17 | { 18 | total = 10 * total + (c - '0'); 19 | c = (int)(unsigned char) *nptr++; 20 | } 21 | 22 | if (sign == '-') 23 | return -total; 24 | else 25 | return total; 26 | } 27 | 28 | int atoi(const char *nptr) 29 | { 30 | return (int) atol(nptr); 31 | } 32 | 33 | double atof(const char *nptr) 34 | { 35 | panic("atof not implemented"); 36 | return 0; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/bsearch.c: -------------------------------------------------------------------------------- 1 | #include "msvcrt.h" 2 | 3 | void *bsearch(const void *key, const void *base, size_t num, size_t width, int (__cdecl *compare)(const void *, const void *)) 4 | { 5 | char *lo = (char *) base; 6 | char *hi = (char *) base + (num - 1) * width; 7 | char *mid; 8 | unsigned int half; 9 | int result; 10 | 11 | while (lo <= hi) 12 | { 13 | if (half = num / 2) 14 | { 15 | mid = lo + (num & 1 ? half : (half - 1)) * width; 16 | if (!(result = (*compare)(key,mid))) 17 | return mid; 18 | else if (result < 0) 19 | { 20 | hi = mid - width; 21 | num = num & 1 ? half : half-1; 22 | } 23 | else 24 | { 25 | lo = mid + width; 26 | num = half; 27 | } 28 | } 29 | else if (num) 30 | return ((*compare)(key,lo) ? NULL : lo); 31 | else 32 | break; 33 | } 34 | 35 | return NULL; 36 | } 37 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/malloc.c: -------------------------------------------------------------------------------- 1 | #include "msvcrt.h" 2 | 3 | void *_malloc(size_t size) 4 | { 5 | return malloc(size); 6 | } 7 | 8 | void *_calloc(size_t num, size_t size) 9 | { 10 | return calloc(num, size); 11 | } 12 | 13 | void *_realloc(void *mem, size_t size) 14 | { 15 | return realloc(mem, size); 16 | } 17 | 18 | void _free(void *mem) 19 | { 20 | free(mem); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/memmove.c: -------------------------------------------------------------------------------- 1 | #include "msvcrt.h" 2 | 3 | void *memmove(void *dst, const void *src, size_t count) 4 | { 5 | void *ret = dst; 6 | 7 | if (dst <= src || (char *)dst >= ((char *)src + count)) 8 | { 9 | while (count--) 10 | { 11 | *(char *) dst = *(char *) src; 12 | dst = (char *) dst + 1; 13 | src = (char *) src + 1; 14 | } 15 | } 16 | else 17 | { 18 | dst = (char *) dst + count - 1; 19 | src = (char *) src + count - 1; 20 | 21 | while (count--) 22 | { 23 | *(char *) dst = *(char *) src; 24 | dst = (char *) dst - 1; 25 | src = (char *) src - 1; 26 | } 27 | } 28 | 29 | return ret; 30 | } 31 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/msvcrt.def: -------------------------------------------------------------------------------- 1 | LIBRARY MSVCRT 2 | DESCRIPTION 'MSVCRT' 3 | 4 | EXPORTS 5 | ??2@YAPAXI@Z 6 | ??3@YAXPAX@Z 7 | malloc=_malloc 8 | free=_free 9 | calloc=_calloc 10 | realloc=_realloc 11 | rename=_rename 12 | 13 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/new.cpp: -------------------------------------------------------------------------------- 1 | extern "C" 2 | { 3 | #include "os.h" 4 | } 5 | 6 | void *operator new(unsigned int size) 7 | { 8 | void *p; 9 | 10 | p = malloc(size); 11 | if (p) memset(p, 0, size); 12 | return p; 13 | } 14 | 15 | void operator delete(void *p) 16 | { 17 | if (p) free(p); 18 | } 19 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/setjmp.c: -------------------------------------------------------------------------------- 1 | #include "msvcrt.h" 2 | 3 | int _setjmp3(void *env) 4 | { 5 | //syslog(LOG_DEBUG, "setjmp called\n"); 6 | return 0; 7 | } 8 | 9 | void longjmp(void *env, int value) 10 | { 11 | panic("longjmp not implemented"); 12 | } 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/string.c: -------------------------------------------------------------------------------- 1 | #include "msvcrt.h" 2 | 3 | char *strchr(const char *string, int ch) 4 | { 5 | while (*string && *string != (char) ch) string++; 6 | 7 | if (*string == (char) ch) return (char *) string; 8 | 9 | return NULL; 10 | } 11 | 12 | int strncmp(const char *first, const char *last, size_t count) 13 | { 14 | if (!count) return 0; 15 | 16 | while (--count && *first && *first == *last) 17 | { 18 | first++; 19 | last++; 20 | } 21 | 22 | return *(unsigned char *) first - *(unsigned char *) last; 23 | } 24 | 25 | char *strncpy(char *dest, const char *source, size_t count) 26 | { 27 | char *start = dest; 28 | 29 | while (count && (*dest++ = *source++)) count--; 30 | 31 | if (count) 32 | { 33 | while (--count) *dest++ = '\0'; 34 | } 35 | 36 | return start; 37 | } 38 | 39 | char *strrchr(const char *string, int ch) 40 | { 41 | char *start = (char *) string; 42 | 43 | while (*string++); 44 | 45 | while (--string != start && *string != (char) ch); 46 | 47 | if (*string == (char) ch) return (char *) string; 48 | 49 | return NULL; 50 | } 51 | 52 | char *strstr(const char * str1, const char *str2) 53 | { 54 | char *cp = (char *) str1; 55 | char *s1, *s2; 56 | 57 | if (!*str2) return (char *) str1; 58 | 59 | while (*cp) 60 | { 61 | s1 = cp; 62 | s2 = (char *) str2; 63 | 64 | while (*s1 && *s2 && !(*s1 - *s2)) s1++, s2++; 65 | if (!*s2) return cp; 66 | cp++; 67 | } 68 | 69 | return NULL; 70 | } 71 | 72 | char *_strdup(const char *string) 73 | { 74 | char *memory; 75 | 76 | if (!string) return NULL; 77 | 78 | if (memory = _malloc(strlen(string) + 1)) return strcpy(memory, string); 79 | 80 | return NULL; 81 | } 82 | -------------------------------------------------------------------------------- /utils/emul/src/msvcrt/time.c: -------------------------------------------------------------------------------- 1 | #include "msvcrt.h" 2 | 3 | time_t time(time_t *timer) 4 | { 5 | return (time_t) get_time(); 6 | } 7 | -------------------------------------------------------------------------------- /utils/emul/src/os/critsect.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | __inline long atomic_add(long *dest, long add_value) 5 | { 6 | __asm 7 | { 8 | mov edx, dest; 9 | mov eax, add_value; 10 | mov ecx, eax; 11 | lock xadd dword ptr [edx], eax; 12 | add eax, ecx; 13 | } 14 | } 15 | 16 | void init_critsect(critsect_t cs) 17 | { 18 | cs->count = -1; 19 | cs->recursion = 0; 20 | cs->owner = NOHANDLE; 21 | cs->event = create_event(0, 0); 22 | } 23 | 24 | void delete_critsect(critsect_t cs) 25 | { 26 | close_handle(cs->event); 27 | } 28 | 29 | void enter_critsect(critsect_t cs) 30 | { 31 | handle_t self = get_current_thread(); 32 | 33 | if (cs->owner == self) 34 | { 35 | cs->recursion++; 36 | } 37 | else 38 | { 39 | if (atomic_add(&cs->count, 1) > 0) wait_for_object(cs->event, INFINITE); 40 | cs->owner = self; 41 | } 42 | } 43 | 44 | void leave_critsect(critsect_t cs) 45 | { 46 | handle_t self = get_current_thread(); 47 | 48 | if (cs->owner != self) return; 49 | if (cs->recursion > 0) 50 | { 51 | cs->recursion--; 52 | } 53 | else 54 | { 55 | cs->owner = NOHANDLE; 56 | if (atomic_add(&cs->count, -1) >= 0) set_event(cs->event); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /utils/emul/src/os/heap.h: -------------------------------------------------------------------------------- 1 | #ifndef HEAP_H 2 | #define HEAP_H 3 | 4 | void *heap_alloc(size_t size); 5 | void *heap_realloc(void *mem, size_t size); 6 | void *heap_calloc(size_t num, size_t size); 7 | void heap_free(void *p); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /utils/emul/src/os/mod.h: -------------------------------------------------------------------------------- 1 | #ifndef MOD_H 2 | #define MOD_H 3 | 4 | struct module 5 | { 6 | hmodule_t hmod; 7 | char *name; 8 | char *path; 9 | struct module *next; 10 | struct module *prev; 11 | int refcnt; 12 | }; 13 | 14 | extern hmodule_t hexecmod; 15 | 16 | void init_modules(hmodule_t hmod, char *libpath); 17 | void *get_entrypoint(hmodule_t hmod); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /utils/emul/src/osexec/bitops.h: -------------------------------------------------------------------------------- 1 | #ifndef BITOPS_H 2 | #define BITOPS_H 3 | 4 | #define BITS_PER_BYTE 8 5 | 6 | #define USE_I386_BITOPS 7 | 8 | #ifdef USE_I386_BITOPS 9 | 10 | __inline void set_bit(void *bitmap, int pos) 11 | { 12 | __asm 13 | { 14 | mov eax, pos 15 | mov ebx, bitmap 16 | bts dword ptr [ebx], eax 17 | } 18 | } 19 | 20 | __inline void clear_bit(void *bitmap, int pos) 21 | { 22 | __asm 23 | { 24 | mov eax, pos 25 | mov ebx, bitmap 26 | btr dword ptr [ebx], eax 27 | } 28 | } 29 | 30 | __inline int test_bit(void *bitmap, int pos) 31 | { 32 | int result; 33 | 34 | __asm 35 | { 36 | mov eax, pos 37 | mov ebx, bitmap 38 | bt dword ptr [ebx], eax 39 | sbb eax, eax 40 | mov result, eax 41 | } 42 | 43 | return result; 44 | } 45 | 46 | #else 47 | 48 | __inline void set_bit(void *bitmap, int pos) 49 | { 50 | *(((unsigned char *) bitmap) + (pos / BITS_PER_BYTE)) |= (1 << (pos % BITS_PER_BYTE)); 51 | } 52 | 53 | __inline void clear_bit(void *bitmap, int pos) 54 | { 55 | *(((unsigned char *) bitmap) + (pos / BITS_PER_BYTE)) &= ~(1 << (pos % BITS_PER_BYTE)); 56 | } 57 | 58 | __inline int test_bit(void *bitmap, int pos) 59 | { 60 | return *(((unsigned char *) bitmap) + (pos / BITS_PER_BYTE)) & (1 << (pos % BITS_PER_BYTE)); 61 | } 62 | 63 | #endif 64 | 65 | __inline void set_bits(void *bitmap, int pos, int len) 66 | { 67 | while (len-- > 0) set_bit(bitmap, pos++); 68 | } 69 | 70 | int find_first_zero_bit(void *bitmap, int len); 71 | int find_next_zero_bit(void *bitmap, int len, int start); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /utils/emul/src/osexec/buf.h: -------------------------------------------------------------------------------- 1 | #ifndef BUF_H 2 | #define BUF_H 3 | 4 | struct thread 5 | { 6 | void *ready; 7 | struct thread *next_buffer_waiter; 8 | }; 9 | 10 | #define BUFPOOL_HASHSIZE 512 11 | 12 | #define BUF_STATE_FREE 0 13 | #define BUF_STATE_CLEAN 1 14 | #define BUF_STATE_DIRTY 2 15 | #define BUF_STATE_READING 3 16 | #define BUF_STATE_WRITING 4 17 | #define BUF_STATE_LOCKED 5 18 | #define BUF_STATE_UPDATED 6 19 | #define BUF_STATE_INVALID 7 20 | 21 | struct buf; 22 | 23 | struct buflist 24 | { 25 | struct buf *head; 26 | struct buf *tail; 27 | }; 28 | 29 | struct buflink 30 | { 31 | struct buf *next; 32 | struct buf *prev; 33 | }; 34 | 35 | struct buf 36 | { 37 | struct buflink bucket; 38 | struct buflink chain; 39 | unsigned short state; 40 | unsigned short locks; 41 | struct thread *waiters; 42 | blkno_t blkno; 43 | char *data; 44 | }; 45 | 46 | struct bufpool 47 | { 48 | devno_t devno; 49 | int poolsize; 50 | int bufsize; 51 | int blks_per_buffer; 52 | 53 | struct buf *bufbase; 54 | char *database; 55 | 56 | struct buflist dirty; // List of dirty buffers (head is least recently changed) 57 | struct buflist clean; // List of clean buffers (head is least recently used) 58 | struct buf *freelist; // List of free buffers 59 | 60 | struct buf *hashtable[BUFPOOL_HASHSIZE]; 61 | }; 62 | 63 | struct bufpool *init_buffer_pool(devno_t devno, int poolsize, int bufsize); 64 | void free_buffer_pool(struct bufpool *pool); 65 | struct buf *get_buffer(struct bufpool *pool, blkno_t blkno); 66 | struct buf *alloc_buffer(struct bufpool *pool, blkno_t blkno); 67 | void mark_buffer_updated(struct buf *buf); 68 | void mark_buffer_invalid(struct buf *buf); 69 | void release_buffer(struct bufpool *pool, struct buf *buf); 70 | void flush_buffers(struct bufpool *pool); 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /utils/emul/src/osexec/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | typedef unsigned int devno_t; 5 | typedef unsigned int blkno_t; 6 | typedef unsigned int ino_t; 7 | typedef unsigned int loff_t; 8 | 9 | typedef unsigned int ino_t; 10 | typedef long time_t; 11 | typedef unsigned int size_t; 12 | 13 | void *kmalloc(int size); 14 | void kfree(void *p); 15 | 16 | time_t time(time_t *timer); 17 | 18 | void *memcpy(void *, const void *, size_t); 19 | int memcmp(const void *, const void *, size_t); 20 | void *memset(void *, int, size_t); 21 | 22 | char *strcpy(char *, const char *); 23 | char *strcat(char *, const char *); 24 | int strcmp(const char *, const char *); 25 | size_t strlen(const char *); 26 | 27 | int atoi(const char *s); 28 | 29 | #define NULL ((void *)0) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /utils/emul/src/test/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | hmodule_t module; 4 | 5 | void print_banner(); 6 | 7 | __declspec(dllimport) int add(int a, int b); 8 | __declspec(dllimport) int printf(const char *fmt, ...); 9 | 10 | int __stdcall main(hmodule_t hmod, char *cmdline, int reserved) 11 | { 12 | handle_t f; 13 | int i; 14 | 15 | module = hmod; 16 | 17 | print_banner(); 18 | printf("2+3=%d\n", add(2, 3)); 19 | printf("cmdline: %s\n", cmdline); 20 | 21 | f = open_file("test.txt", O_CREAT | O_WRONLY); 22 | for (i = 0; i < 10; i++) 23 | { 24 | write_file(f, "hello world\n", 12); 25 | } 26 | close_handle(f); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /utils/emul/src/test/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern handle_t module; 4 | 5 | void print_banner() 6 | { 7 | syslog(LOG_DEBUG, "hello from test\n"); 8 | } 9 | -------------------------------------------------------------------------------- /utils/emul/src/user32/user32.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int WINAPI MessageBoxA 5 | ( 6 | HWND hWnd, 7 | LPCTSTR lpText, 8 | LPCTSTR lpCaption, 9 | UINT uType 10 | ) 11 | { 12 | panic("MessageBoxA not implemented"); 13 | return 0; 14 | } 15 | 16 | int __stdcall DllMain(handle_t hmod, int reason, void *reserved) 17 | { 18 | return TRUE; 19 | } 20 | -------------------------------------------------------------------------------- /utils/emul/src/user32/user32.def: -------------------------------------------------------------------------------- 1 | LIBRARY USER32 2 | DESCRIPTION 'USER32' 3 | 4 | EXPORTS 5 | MessageBoxA 6 | -------------------------------------------------------------------------------- /utils/emul/src/winmm/winmm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | MMRESULT WINAPI timeBeginPeriod 5 | ( 6 | UINT uPeriod 7 | ) 8 | { 9 | syslog(LOG_DEBUG, "timeBeginPeriod: timer resolution is %d\n", uPeriod); 10 | return 0; 11 | } 12 | 13 | MMRESULT WINAPI timeEndPeriod 14 | ( 15 | UINT uPeriod 16 | ) 17 | { 18 | syslog(LOG_DEBUG, "timeEndPeriod: timer resolution is %d\n", uPeriod); 19 | return 0; 20 | } 21 | 22 | DWORD timeGetTime(VOID) 23 | { 24 | return get_tick_count(); 25 | } 26 | 27 | int __stdcall DllMain(handle_t hmod, int reason, void *reserved) 28 | { 29 | return TRUE; 30 | } 31 | -------------------------------------------------------------------------------- /utils/emul/src/winmm/winmm.def: -------------------------------------------------------------------------------- 1 | LIBRARY WINMM 2 | DESCRIPTION 'WINMM' 3 | 4 | EXPORTS 5 | timeBeginPeriod 6 | timeEndPeriod 7 | timeGetTime 8 | -------------------------------------------------------------------------------- /utils/emul/src/wsock32/wsock32.def: -------------------------------------------------------------------------------- 1 | LIBRARY WSOCK32 2 | DESCRIPTION 'WSOCK32' 3 | 4 | EXPORTS 5 | WSAStartup @115 6 | recv = winsock_recv @16 7 | send = winsock_send @19 8 | listen = winsock_listen @13 9 | bind = winsock_bind @2 10 | accept = winsock_accept @1 11 | recvfrom = winsock_recvfrom @17 12 | sendto = winsock_sendto @20 13 | select = winsock_select @18 14 | connect = winsock_connect @4 15 | closesocket = winsock_closesocket @3 16 | shutdown = winsock_shutdown @22 17 | gethostname = winsock_gethostname @57 18 | gethostbyaddr = winsock_gethostbyaddr @51 19 | gethostbyname = winsock_gethostbyname @52 20 | htons = winsock_htons @9 21 | htonl = winsock_htonl @8 22 | ntohs = winsock_ntohs @15 23 | ntohl = winsock_ntohl @14 24 | getsockopt = winsock_getsockopt @7 25 | setsockopt = winsock_setsockopt @21 26 | getprotobyname = winsock_getprotobyname @53 27 | getsockname = winsock_getsockname @6 28 | socket = winsock_socket @23 29 | ;WSASendDisconnect @74 30 | ioctlsocket = winsock_ioctlsocket @12 31 | __WSAFDIsSet @151 32 | WSAGetLastError @111 33 | WSACleanup @116 34 | -------------------------------------------------------------------------------- /utils/mkpkg/inifile.h: -------------------------------------------------------------------------------- 1 | #ifndef INIFILE_H 2 | #define INIFILE_H 3 | 4 | struct property; 5 | 6 | struct section { 7 | char *name; 8 | struct section *next; 9 | struct property *properties; 10 | }; 11 | 12 | struct property { 13 | char *name; 14 | char *value; 15 | struct property *next; 16 | }; 17 | 18 | struct section *find_section(struct section *sect, char *name); 19 | int get_section_size(struct section *sect); 20 | char *find_property(struct section *sect, char *name); 21 | char *get_property(struct section *sections, char *sectname, char *propname, char *defval); 22 | int get_numeric_property(struct section *sections, char *sectname, char *propname, int defval); 23 | void free_properties(struct section *sect); 24 | struct section *parse_properties(char *props); 25 | struct section *read_properties(char *filename); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /utils/pmdump/getopt.h: -------------------------------------------------------------------------------- 1 | #ifndef GETOPT_H 2 | #define GETOPT_H 3 | 4 | extern int opterr; 5 | extern int optind; 6 | extern int optopt; 7 | extern char *optarg; 8 | 9 | int getopt(int argc, char **argv, char *opts); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /utils/pmdump/rdp.h: -------------------------------------------------------------------------------- 1 | // 2 | // rdp.h 3 | // 4 | // Copyright (c) 2001 Michael Ringgaard. All rights reserved. 5 | // 6 | // Remote debugging protocol 7 | // 8 | 9 | #ifndef RDP_H 10 | #define RDP_H 11 | 12 | typedef unsigned long tid_t; 13 | typedef void *hmodule_t; 14 | 15 | // 16 | // Context structure from os.h 17 | // 18 | 19 | struct context 20 | { 21 | unsigned long es, ds; 22 | unsigned long edi, esi, ebp, ebx, edx, ecx, eax; 23 | unsigned long traptype; 24 | unsigned long errcode; 25 | 26 | unsigned long eip, ecs; 27 | unsigned long eflags; 28 | unsigned long esp, ess; 29 | }; 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #define GLOBAL_PROCID 1 37 | #define GLOBAL_HPROC 0x0123 38 | 39 | #define MAX_DBG_CHUNKSIZE 4096 40 | #define MAX_DBG_PACKETLEN (MAX_DBG_CHUNKSIZE + sizeof(union dbg_body)) 41 | 42 | struct dbg_session 43 | { 44 | HANDLE target; 45 | unsigned char next_reqid; 46 | 47 | struct dbg_event *event_head; 48 | struct dbg_event *event_tail; 49 | 50 | struct dbg_connect conn; 51 | 52 | struct dbg_hdr hdr; 53 | char dbg_data[MAX_DBG_PACKETLEN]; 54 | union dbg_body *body; 55 | }; 56 | 57 | struct dbg_session *dbg_create_session(char *port); 58 | void dbg_close_session(struct dbg_session *s, int resume); 59 | 60 | struct dbg_event *dbg_next_event(struct dbg_session *s); 61 | void dbg_release_event(struct dbg_event *e); 62 | 63 | int dbg_continue(struct dbg_session *s); 64 | 65 | int dbg_read_memory(struct dbg_session *s, void *addr, int size, void *buffer); 66 | int dbg_write_memory(struct dbg_session *s, void *addr, int size, void *buffer); 67 | 68 | int dbg_get_context(struct dbg_session *s, tid_t tid, struct context *ctxt); 69 | int dbg_set_context(struct dbg_session *s, tid_t tid, struct context *ctxt); 70 | 71 | int dbg_suspend_threads(struct dbg_session *s, tid_t *threadids, int count); 72 | int dbg_resume_threads(struct dbg_session *s, tid_t *threadids, int count); 73 | 74 | int dbg_get_selector(struct dbg_session *s, int sel, struct segment *seg); 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /utils/samples/fib.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fib(int n) 4 | { 5 | if (n <= 2) 6 | return 1; 7 | else 8 | return fib(n - 1) + fib(n - 2); 9 | } 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | int n; 14 | 15 | if (argc < 2) 16 | { 17 | printf("usage: fib n\nCompute nth Fibonacci number\n"); 18 | return 1; 19 | } 20 | 21 | n = atoi(argv[1]); 22 | printf("fib(%d) = %d\n", n, fib(n)); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /utils/samples/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) 4 | { 5 | printf("hello world\n"); 6 | return 0; 7 | } 8 | --------------------------------------------------------------------------------