├── .gitignore ├── Makefile ├── README ├── all_lat.sh ├── all_thr.py ├── atomicio.c ├── atomicio.h ├── futex.h ├── futex_lat.c ├── mempipe_lat.c ├── mempipe_thr.c ├── pipe_lat.c ├── pipe_thr.c ├── resolve ├── 48native.mempipe_lat.lat.csv ├── 48native.pipe_lat.lat.csv ├── 48native.tcp_lat.lat.csv ├── 48native.unix_lat.lat.csv ├── 48xennopin.mempipe_lat.lat.csv ├── 48xennopin.pipe_lat.lat.csv ├── 48xennopin.tcp_lat.lat.csv ├── 48xennopin.unix_lat.lat.csv ├── 48xenpin.mempipe_lat.lat.csv ├── 48xenpin.pipe_lat.lat.csv ├── 48xenpin.tcp_lat.lat.csv ├── 48xenpin.unix_lat.lat.csv ├── Makefile ├── concatenate_series_helper.sh ├── lat.sh ├── latency.pdf ├── latency.r ├── plot_ipi.py ├── plot_lat.py └── plot_thr.py ├── results ├── tmpIe94ic.tar.gz ├── tmpK1UpPd.tar.gz ├── tmpR6gPcQ.tar.gz └── tmpw3ZQ5R.tar.gz ├── run.py ├── shm.c ├── shmem_pipe_thr.c ├── stats.c ├── summarise_tsc_counters.c ├── tcp_lat.c ├── tcp_local_lat.c ├── tcp_remote_lat.c ├── tcp_thr.c ├── test.c ├── test.h ├── unix_lat.c ├── unix_thr.c ├── vmsplice_pipe_thr.c ├── web └── processing │ ├── cron.sh │ ├── gen-details-page.py │ ├── gen-overview-entry.py │ ├── html_foot.tmpl │ ├── html_head.tmpl │ ├── html_results_foot.tmpl │ ├── html_results_head.tmpl │ ├── plot_ipi.py │ ├── plot_lat.py │ └── plot_thr.py ├── xen └── mini-os │ ├── COPYING │ ├── Config.mk │ ├── Makefile │ ├── README │ ├── app.lds │ ├── arch │ ├── ia64 │ │ ├── Makefile │ │ ├── __divdi3.S │ │ ├── __udivdi3.S │ │ ├── __udivsi3.S │ │ ├── __umoddi3.S │ │ ├── arch.mk │ │ ├── common.c │ │ ├── debug.c │ │ ├── efi.c │ │ ├── fw.S │ │ ├── gen_off.c │ │ ├── ia64.S │ │ ├── ivt.S │ │ ├── minios-ia64.lds │ │ ├── mm.c │ │ ├── sal.c │ │ ├── sched.c │ │ ├── time.c │ │ └── xencomm.c │ └── x86 │ │ ├── Makefile │ │ ├── Makefile~ │ │ ├── arch.mk │ │ ├── ioremap.c │ │ ├── minios-x86_32.lds │ │ ├── minios-x86_64.lds │ │ ├── mm.c │ │ ├── sched.c │ │ ├── setup.c │ │ ├── time.c │ │ ├── traps.c │ │ ├── x86_32.S │ │ └── x86_64.S │ ├── blkfront.c │ ├── console │ ├── console.c │ └── xencons_ring.c │ ├── daytime.c │ ├── domain_config │ ├── events.c │ ├── fbfront.c │ ├── gntmap.c │ ├── gnttab.c │ ├── hypervisor.c │ ├── include │ ├── arch │ │ ├── cc.h │ │ ├── perf.h │ │ └── sys_arch.h │ ├── blkfront.h │ ├── byteswap.h │ ├── console.h │ ├── ctype.h │ ├── err.h │ ├── errno-base.h │ ├── errno.h │ ├── events.h │ ├── fbfront.h │ ├── fcntl.h │ ├── gntmap.h │ ├── gnttab.h │ ├── hypervisor.h │ ├── ia64 │ │ ├── arch_limits.h │ │ ├── arch_mm.h │ │ ├── arch_sched.h │ │ ├── arch_spinlock.h │ │ ├── asm.h │ │ ├── atomic.h │ │ ├── efi.h │ │ ├── hypercall-ia64.h │ │ ├── ia64_cpu.h │ │ ├── ia64_fpu.h │ │ ├── os.h │ │ ├── page.h │ │ ├── pal.h │ │ ├── privop.h │ │ ├── sal.h │ │ └── traps.h │ ├── ioremap.h │ ├── kernel.h │ ├── lib.h │ ├── linux │ │ └── types.h │ ├── list.h │ ├── lwipopts.h │ ├── mm.h │ ├── netfront.h │ ├── pcifront.h │ ├── posix │ │ ├── arpa │ │ │ └── inet.h │ │ ├── dirent.h │ │ ├── err.h │ │ ├── fcntl.h │ │ ├── limits.h │ │ ├── net │ │ │ └── if.h │ │ ├── netdb.h │ │ ├── netinet │ │ │ ├── in.h │ │ │ └── tcp.h │ │ ├── pthread.h │ │ ├── signal.h │ │ ├── stdlib.h │ │ ├── strings.h │ │ ├── sys │ │ │ ├── ioctl.h │ │ │ ├── mman.h │ │ │ ├── poll.h │ │ │ ├── select.h │ │ │ ├── socket.h │ │ │ └── stat.h │ │ ├── syslog.h │ │ ├── termios.h │ │ ├── time.h │ │ └── unistd.h │ ├── sched.h │ ├── semaphore.h │ ├── spinlock.h │ ├── sys │ │ ├── lock.h │ │ └── time.h │ ├── time.h │ ├── types.h │ ├── wait.h │ ├── waittypes.h │ ├── x86 │ │ ├── arch_limits.h │ │ ├── arch_mm.h │ │ ├── arch_sched.h │ │ ├── arch_spinlock.h │ │ ├── os.h │ │ ├── traps.h │ │ ├── x86_32 │ │ │ └── hypercall-x86_32.h │ │ └── x86_64 │ │ │ └── hypercall-x86_64.h │ ├── xenbus.h │ └── xmalloc.h │ ├── kernel.c │ ├── latency │ ├── client.conf │ ├── doit.sh │ ├── evtchn.c │ └── server.conf │ ├── lib │ ├── ctype.c │ ├── math.c │ ├── printf.c │ ├── stack_chk_fail.c │ ├── string.c │ ├── sys.c │ ├── xmalloc.c │ └── xs.c │ ├── lock.c │ ├── lwip-arch.c │ ├── lwip-net.c │ ├── main.c │ ├── minios.mk │ ├── mm.c │ ├── netfront.c │ ├── pcifront.c │ ├── sched.c │ └── xenbus │ └── xenbus.c ├── xutil.c └── xutil.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *_thr 3 | *_lat 4 | summarise_tsc_counters 5 | .*.swp 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all_target := posix 2 | uname := $(shell uname -s) 3 | ifeq ($(uname),Linux) 4 | all_target := linux 5 | endif 6 | ifeq ($(uname),OpenBSD) 7 | all_target := openbsd 8 | endif 9 | ifeq ($(uname),Darwin) 10 | all_target := darwin 11 | endif 12 | 13 | .PHONY: all clean run 14 | 15 | CFLAGS_Linux = -DUSE_INLINE_ASM -DLinux 16 | CFLAGS_OpenBSD = -DUSE_INLINE_ASM 17 | CFLAGS += -g -Wall -O3 -D_GNU_SOURCE -DNDEBUG -std=gnu99 $(CFLAGS_$(uname)) 18 | 19 | LDFLAGS_Linux := -lrt -lnuma 20 | LDFLAGS += -lm $(LDFLAGS_$(uname)) 21 | 22 | TARGETS_POSIX := pipe_thr tcp_thr tcp_nodelay_thr unix_thr mempipe_spin_thr 23 | TARGETS_Linux += mempipe_thr vmsplice_pipe_thr vmsplice_hugepages_pipe_thr vmsplice_hugepages_coop_pipe_thr vmsplice_coop_pipe_thr 24 | 25 | TARGETS_POSIX += pipe_lat unix_lat tcp_lat tcp_nodelay_lat mempipe_lat 26 | TARGETS_Linux += shmem_pipe_thr futex_lat 27 | 28 | TARGETS_POSIX += summarise_tsc_counters 29 | 30 | TARGETS_OpenBSD := 31 | TARGETS_Darwin := 32 | 33 | TARGETS := $(TARGETS_POSIX) $(TARGETS_$(uname)) 34 | 35 | x-%: 36 | echo $($*) 37 | 38 | all: $(TARGETS) 39 | @ : 40 | 41 | %_lat: atomicio.o test.o xutil.o %_lat.o stats.o 42 | $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 43 | 44 | %_thr: atomicio.o test.o xutil.o %_thr.o stats.o 45 | $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 46 | 47 | tcp_nodelay_thr.o: tcp_thr.c 48 | $(CC) $(CFLAGS) $^ -c -DUSE_NODELAY -o $@ 49 | 50 | tcp_nodelay_lat.o: tcp_lat.c 51 | $(CC) $(CFLAGS) $^ -c -DUSE_NODELAY -o $@ 52 | 53 | mempipe_spin_thr.o: mempipe_thr.c 54 | $(CC) $(CFLAGS) $^ -c -DNO_FUTEX -o $@ 55 | 56 | vmsplice_hugepages_pipe_thr.o: vmsplice_pipe_thr.c 57 | $(CC) $(CFLAGS) $^ -c -DUSE_HUGE_PAGES -o $@ 58 | 59 | vmsplice_hugepages_coop_pipe_thr.o: vmsplice_pipe_thr.c 60 | $(CC) $(CFLAGS) $^ -c -DUSE_HUGE_PAGES -DVMSPLICE_COOP -o $@ 61 | 62 | vmsplice_coop_pipe_thr.o: vmsplice_pipe_thr.c 63 | $(CC) $(CFLAGS) $^ -c -DVMSPLICE_COOP -o $@ 64 | 65 | summarise_tsc_counters: summarise_tsc_counters.o stats.o 66 | $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) 67 | 68 | clean: 69 | rm -f *~ core *.o $(TARGETS) 70 | 71 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ipc-bench 2 | ========= 3 | 4 | Some very crude IPC benchmarks. 5 | 6 | ping-pong latency benchmarks: 7 | * pipes 8 | * unix domain sockets 9 | * tcp sockets 10 | 11 | throughput benchmarks: 12 | * pipes 13 | * unix doamin sockets 14 | * tcp sockets 15 | 16 | one way latency benchmarks: 17 | * shm 18 | 19 | The shared memory benchmark is a kind of "control". If run under a 20 | real-time OS it will give you the intra core communication 21 | latency. 22 | 23 | This software is distributed under the MIT License. -------------------------------------------------------------------------------- /all_lat.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | SIZES="128" 3 | COUNT=10000 4 | LAT_TESTS="pipe_lat tcp_lat unix_lat mempipe_lat tcp_nodelay_lat" 5 | TESTS="${LAT_TESTS}" 6 | 7 | NUM_CORES=$2 8 | 9 | ODIR=$1 10 | rm -rf ${ODIR} 11 | mkdir -p ${ODIR} 12 | 13 | for SIZE in ${SIZES}; do 14 | c1=0 15 | while [[ ${c1} -lt ${NUM_CORES} ]]; do 16 | c2=0 17 | while [[ ${c2} -lt ${NUM_CORES} ]]; do 18 | echo ${c1} to ${c2} 19 | for t in ${TESTS}; do 20 | d="${ODIR}/${SIZE}/${c1}-${c2}-${t}" 21 | mkdir -p ${d} 22 | if [ ${c1} -eq ${c2} ]; then 23 | count=100 24 | else 25 | count=${COUNT} 26 | fi 27 | ./${t} -t -s ${SIZE} -c ${count} -a ${c1} -b ${c2} -o ${d} 28 | done 29 | c2=$(expr ${c2} + 1) 30 | done 31 | c1=$(expr ${c1} + 1) 32 | done 33 | 34 | # post-processing 35 | for t in ${TESTS}; do 36 | ofile=${ODIR}/${t}.csv 37 | c1=0 38 | while [[ ${c1} -lt ${NUM_CORES} ]]; do 39 | c2=0 40 | while [[ ${c2} -lt ${NUM_CORES} ]]; do 41 | d="${ODIR}/${SIZE}/${c1}-${c2}-${t}/01-${t}-headline.log" 42 | speed=`tail -1 ${d} | awk '{print $4}' | sed -e 's/s//g'` 43 | echo -n "${speed} " >> ${ofile} 44 | c2=$(expr ${c2} + 1) 45 | done 46 | echo "" >> ${ofile} 47 | c1=$(expr ${c1} + 1) 48 | done 49 | done 50 | 51 | done 52 | -------------------------------------------------------------------------------- /all_thr.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # This script runs the following battery of tests: 4 | # Chunk sizes: 64, 4096, 65536 5 | # Test types: pipe, unix, tcp, tcp-nodelay, vmsplice-coop, shmem-pipe, mempipe-futex, mempipe-spin 6 | # The latter 3 tests are repeated with a "safe" form that has the writer copy the data from shared memory before verification 7 | # All tests use rep stosq to write buffers (data is the iteration count) and rep scasq to verify at the reader. 8 | # All tests work in place so far as their underlying transport allows (so pipes involve 2 copies, vmsplice involves 1, rings involve 0). 9 | # All tests will be repeated to test bandwidth between cores named on the command line: see below... 10 | 11 | # Parameters for this script: 1st parameter is an output directory (will be created; all tests will be stored below this) 12 | # All following parameters must be integers denoting a core followed by another denoting a numa node. 13 | # If you supply x y z w we will test 0-x allocating from node y, 0-z allocating from node w. 14 | # We omit the mempipe-spin 0-0 test if it would otherwise be run as it's stupid. 15 | 16 | import sys 17 | import errno 18 | import subprocess 19 | import os 20 | 21 | output_dir = sys.argv[1] 22 | try: 23 | os.makedirs(output_dir) 24 | except OSError as e: 25 | if e.errno == errno.EEXIST: 26 | pass 27 | else: 28 | raise 29 | 30 | if len(sys.argv) % 2 == 1: 31 | raise Exception("Must specify an even number of integer arguments after the output directory") 32 | 33 | target_args = [str(int(x)) for x in sys.argv[2:]] 34 | 35 | target_cores = [] 36 | next_core = None 37 | for s in target_args: 38 | if next_core is None: 39 | next_core = s 40 | else: 41 | target_cores.append((next_core, s)) 42 | next_core = None 43 | 44 | chunk_repeats = [("64", "1000000"), ("4096", "1000000"), ("65536", "100000")] 45 | 46 | test_rips = [("pipe_thr", True), ("unix_thr", True), 47 | ("tcp_thr", True), ("tcp_nodelay_thr", True), 48 | ("vmsplice_coop_pipe_thr", True), 49 | ("mempipe_thr", True), ("mempipe_thr", False), 50 | ("mempipe_spin_thr", True), ("mempipe_spin_thr", False), 51 | ("shmem_pipe_thr", True), ("shmem_pipe_thr", False)] 52 | 53 | tests_done = set() 54 | 55 | for test, rip in test_rips: 56 | for chunksize, repeats in chunk_repeats: 57 | for (tcore, tnode) in target_cores: 58 | 59 | if test == "mempipe_spin_thr" and tcore == "0": 60 | continue 61 | 62 | if test not in ("mempipe_thr", "mempipe_spin_thr", "shmem_pipe_thr"): 63 | tnode = "-1" # The other tests don't care about NUMA nodes. 64 | 65 | # This is to skip would-be repeats for the above mentioned tests that don't care about NUMA. 66 | if (test, rip, chunksize, repeats, tcore, tnode) in tests_done: 67 | continue 68 | 69 | tests_done.add((test, rip, chunksize, repeats, tcore, tnode)) 70 | 71 | progname = "./%s" % test 72 | args = [progname, "-s", chunksize, "-c", repeats, "-a", "0", "-b", tcore, "-o", output_dir, "-w", "-v", "-m", "2", "-n", tnode] 73 | # Last four args: write in place, do verify, produce using rep stosq 74 | if rip: 75 | args.append("-r") 76 | sys.stdout.write("%s: " % test) 77 | sys.stdout.flush() 78 | subprocess.check_call(args) 79 | 80 | -------------------------------------------------------------------------------- /atomicio.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: atomicio.c,v 1.26 2010/09/22 22:58:51 djm Exp $ */ 2 | /* 3 | * Copyright (c) 2006 Damien Miller. All rights reserved. 4 | * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved. 5 | * Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. 6 | * 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 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "atomicio.h" 38 | 39 | /* 40 | * ensure all of data on socket comes through. f==read || f==vwrite 41 | */ 42 | size_t 43 | atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n, 44 | int (*cb)(void *, size_t), void *cb_arg) 45 | { 46 | char *s = _s; 47 | size_t pos = 0; 48 | ssize_t res; 49 | struct pollfd pfd; 50 | 51 | pfd.fd = fd; 52 | pfd.events = f == read ? POLLIN : POLLOUT; 53 | while (n > pos) { 54 | res = (f) (fd, s + pos, n - pos); 55 | switch (res) { 56 | case -1: 57 | if (errno == EINTR) 58 | continue; 59 | if (errno == EAGAIN) { 60 | (void)poll(&pfd, 1, -1); 61 | continue; 62 | } 63 | return 0; 64 | case 0: 65 | errno = EPIPE; 66 | return pos; 67 | default: 68 | pos += (size_t)res; 69 | if (cb != NULL && cb(cb_arg, (size_t)res) == -1) { 70 | errno = EINTR; 71 | return pos; 72 | } 73 | } 74 | } 75 | return pos; 76 | } 77 | 78 | size_t 79 | atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n) 80 | { 81 | return atomicio6(f, fd, _s, n, NULL, NULL); 82 | } 83 | 84 | -------------------------------------------------------------------------------- /atomicio.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: atomicio.h,v 1.11 2010/09/22 22:58:51 djm Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 2006 Damien Miller. All rights reserved. 5 | * Copyright (c) 1995,1999 Theo de Raadt. All rights reserved. 6 | * 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 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef _ATOMICIO_H 30 | #define _ATOMICIO_H 31 | 32 | /* 33 | * Ensure all of data on socket comes through. f==read || f==vwrite 34 | */ 35 | size_t 36 | atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n, 37 | int (*cb)(void *, size_t), void *); 38 | size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t); 39 | 40 | #define vwrite (ssize_t (*)(int, void *, size_t))write 41 | 42 | #endif /* _ATOMICIO_H */ 43 | -------------------------------------------------------------------------------- /futex.h: -------------------------------------------------------------------------------- 1 | #ifndef FUTEX_H__ 2 | #define FUTEX_H__ 3 | 4 | static inline unsigned 5 | atomic_cmpxchg(volatile unsigned *loc, unsigned old, unsigned new) 6 | { 7 | unsigned long res; 8 | asm ("lock cmpxchg %3, %1\n" 9 | : "=a" (res), "=m" (*loc) 10 | : "0" (old), 11 | "r" (new), 12 | "m" (*loc) 13 | : "memory"); 14 | return res; 15 | } 16 | 17 | static inline unsigned 18 | atomic_xchg(volatile unsigned *loc, unsigned new) 19 | { 20 | unsigned long res; 21 | asm ("xchg %0, %1\n" 22 | : "=r" (res), 23 | "=m" (*loc) 24 | : "m" (*loc), 25 | "0" (new) 26 | : "memory"); 27 | return res; 28 | } 29 | 30 | static inline int 31 | futex(volatile unsigned *slot, int cmd, unsigned val, const struct timespec *ts, 32 | int *uaddr, int val2) 33 | { 34 | return syscall(SYS_futex, slot, cmd, val, ts, uaddr, val2); 35 | } 36 | 37 | static inline void 38 | futex_wait_while_equal(volatile unsigned *slot, unsigned val) 39 | { 40 | assert((unsigned long)slot % 4 == 0); 41 | if (futex(slot, FUTEX_WAIT, val, NULL, NULL, 0) < 0 && errno != EAGAIN) 42 | err(1, "futex_wait"); 43 | } 44 | 45 | static inline void 46 | futex_wake(volatile unsigned *slot) 47 | { 48 | if (futex(slot, FUTEX_WAKE, 1, NULL, NULL, 0) < 0) 49 | err(1, "futex_wake"); 50 | } 51 | 52 | #endif /* !FUTEX_H__ */ 53 | -------------------------------------------------------------------------------- /mempipe_lat.c: -------------------------------------------------------------------------------- 1 | /* 2 | Measure latency of IPC using tcp sockets 3 | 4 | Copyright (c) 2011 Steven Smith 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the "Software"), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | /* Ultimate in simple IPC protocols: establish a shared memory 29 | segment and then send a ping by setting flags in it, with the other 30 | end spinning reading those flags. 31 | Note that this is a straight up latency test: no actual data is 32 | transferred. */ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include "test.h" 43 | #include "xutil.h" 44 | 45 | #define PAGE_SIZE 4096 46 | 47 | struct shared_page { 48 | int flag1; 49 | int pad[127]; /* Make sure the two flags are in different cache lines 50 | for any conceivable size fo cache line. */ 51 | int flag2; 52 | }; 53 | 54 | static void 55 | init_test(test_data *td) 56 | { 57 | td->data = establish_shm_segment(1, td->numa_node); 58 | } 59 | 60 | static void 61 | child_ping(test_data *td) 62 | { 63 | volatile struct shared_page *sp = td->data; 64 | sp->flag1 = 1; 65 | while (!sp->flag2) 66 | ; 67 | sp->flag1 = 0; 68 | while (sp->flag2) 69 | ; 70 | } 71 | 72 | static void child_finish(test_data *td) { 73 | volatile struct shared_page *sp = td->data; 74 | sp->flag1 = 1; 75 | } 76 | 77 | static void 78 | parent_init(test_data *td) 79 | { 80 | volatile struct shared_page *sp = td->data; 81 | 82 | /* Wait for the child to get ready before starting the test. */ 83 | while (!sp->flag1) 84 | ; 85 | } 86 | 87 | static void parent_ping(test_data* td) { 88 | 89 | volatile struct shared_page *sp = td->data; 90 | 91 | sp->flag2 = 1; 92 | while (sp->flag1) 93 | ; 94 | sp->flag2 = 0; 95 | while (!sp->flag1) 96 | ; 97 | 98 | } 99 | 100 | int 101 | main(int argc, char *argv[]) 102 | { 103 | test_t t = { 104 | .name = "mempipe_lat", 105 | .is_latency_test = 1, 106 | .init_test = init_test, 107 | .init_parent = parent_init, 108 | .parent_ping = parent_ping, 109 | .child_ping = child_ping, 110 | .finish_child = child_finish 111 | }; 112 | run_test(argc, argv, &t); 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /pipe_lat.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Anil Madhavapeddy 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | 41 | #include "test.h" 42 | #include "xutil.h" 43 | 44 | typedef struct { 45 | int ifds[2]; 46 | int ofds[2]; 47 | void* buf; 48 | } pipe_state; 49 | 50 | static void 51 | init_test(test_data *td) 52 | { 53 | pipe_state *ps = xmalloc(sizeof(pipe_state)); 54 | if (pipe(ps->ifds) == -1) 55 | err(1, "pipe"); 56 | if (pipe(ps->ofds) == -1) 57 | err(1, "pipe"); 58 | td->data = (void *)ps; 59 | } 60 | 61 | static void 62 | local_init(test_data *td) 63 | { 64 | pipe_state *ps = (pipe_state *)td->data; 65 | ps->buf = xmalloc(td->size); 66 | } 67 | 68 | static void 69 | child_ping(test_data *td) 70 | { 71 | pipe_state *ps = (pipe_state *)td->data; 72 | xread(ps->ifds[0], ps->buf, td->size); 73 | xwrite(ps->ofds[1], ps->buf, td->size); 74 | } 75 | 76 | static void 77 | parent_ping(test_data *td) 78 | { 79 | pipe_state *ps = (pipe_state *)td->data; 80 | xwrite(ps->ifds[1], ps->buf, td->size); 81 | xread(ps->ofds[0], ps->buf, td->size); 82 | } 83 | 84 | int 85 | main(int argc, char *argv[]) 86 | { 87 | test_t t = { .name = "pipe_lat", 88 | .is_latency_test = 1, 89 | .init_test = init_test, 90 | .init_parent = local_init, 91 | .init_child = local_init, 92 | .parent_ping = parent_ping, 93 | .child_ping = child_ping 94 | }; 95 | run_test(argc, argv, &t); 96 | return 0; 97 | } 98 | -------------------------------------------------------------------------------- /pipe_thr.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Anil Madhavapeddy 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #include "test.h" 44 | #include "xutil.h" 45 | 46 | typedef struct { 47 | int fds[2]; 48 | int fin_fds[2]; 49 | struct iovec buffer; 50 | } pipe_state; 51 | 52 | static void 53 | init_test(test_data *td) 54 | { 55 | pipe_state *ps = xmalloc(sizeof(pipe_state)); 56 | if (pipe(ps->fds) == -1) 57 | err(1, "pipe"); 58 | if (pipe(ps->fin_fds) == -1) 59 | err(1, "pipe"); 60 | td->data = (void *)ps; 61 | } 62 | 63 | static void 64 | init_local(test_data *td) 65 | { 66 | pipe_state *ps = (pipe_state*)td->data; 67 | ps->buffer.iov_base = xmalloc(td->size); 68 | ps->buffer.iov_len = td->size; 69 | } 70 | 71 | static struct iovec* 72 | get_read_buf(test_data *td, int len, int* n_vecs) 73 | { 74 | pipe_state *ps = (pipe_state *)td->data; 75 | xread(ps->fds[0], ps->buffer.iov_base, len); 76 | *n_vecs = 1; 77 | return &ps->buffer; 78 | } 79 | 80 | static void 81 | release_read_buf(test_data *td, struct iovec* vecs, int n_vecs) { 82 | pipe_state *ps = (pipe_state *)td->data; 83 | assert(n_vecs == 1); 84 | assert(vecs == &ps->buffer); 85 | } 86 | 87 | static void child_fin(test_data *td) { 88 | 89 | pipe_state *ps = (pipe_state *)td->data; 90 | xwrite(ps->fin_fds[1], "X", 1); 91 | 92 | } 93 | 94 | static struct iovec* get_write_buf(test_data *td, int len, int* n_vecs) { 95 | pipe_state *ps = (pipe_state *)td->data; 96 | assert(len == td->size); 97 | *n_vecs = 1; 98 | return &ps->buffer; 99 | } 100 | 101 | static void 102 | release_write_buf(test_data *td, struct iovec* vecs, int n_vecs) 103 | { 104 | pipe_state *ps = (pipe_state *)td->data; 105 | assert(vecs == &ps->buffer && n_vecs == 1); 106 | xwrite(ps->fds[1], vecs[0].iov_base, vecs[0].iov_len); 107 | } 108 | 109 | static void parent_fin(test_data *td) { 110 | pipe_state *ps = (pipe_state*)td->data; 111 | xread(ps->fin_fds[0], ps->buffer.iov_base, 1); 112 | } 113 | 114 | int 115 | main(int argc, char *argv[]) 116 | { 117 | test_t t = { 118 | .name = "pipe_thr", 119 | .is_latency_test = 0, 120 | .init_test = init_test, 121 | .init_parent = init_local, 122 | .finish_parent = parent_fin, 123 | .init_child = init_local, 124 | .finish_child = child_fin, 125 | .get_write_buffer = get_write_buf, 126 | .release_write_buffer = release_write_buf, 127 | .get_read_buffer = get_read_buf, 128 | .release_read_buffer = release_read_buf 129 | }; 130 | run_test(argc, argv, &t); 131 | return 0; 132 | } 133 | -------------------------------------------------------------------------------- /resolve/Makefile: -------------------------------------------------------------------------------- 1 | ARCHS=48native 48xennopin 48xenpin 2 | SIZE=128 3 | TESTS=pipe_lat tcp_lat unix_lat mempipe_lat 4 | 5 | find_tests = $(foreach test,$(TESTS),$(arch)-$(test).csv) 6 | allt := $(foreach arch,$(ARCHS),$(find_tests)) 7 | 8 | all: $(allt) 9 | @ : 10 | 11 | %.csv: 12 | export ARCH=$(shell echo $(*F) | awk -F - '{print $$1}'); \ 13 | export TEST=$(shell echo $(*F) | awk -F - '{print $$2}'); \ 14 | export SIZE=$(SIZE); \ 15 | ./lat.sh 16 | 17 | clean: 18 | rm -f *.csv 19 | -------------------------------------------------------------------------------- /resolve/concatenate_series_helper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | for m in mempipe shmem_pipe vmsplice_coop_pipe pipe unix tcp tcp_nodelay; do 5 | testfile=01-${m}_thr-headline.log 6 | for i in 2 3 4 5 6 7 8 9 10; do 7 | if [[ $i == 2 ]]; then 8 | in1=1/$testfile 9 | else 10 | in1=tmp$j 11 | fi 12 | in2=$i/$testfile 13 | out=tmp$i 14 | paste -d ' ' $in1 <(cut -d ' ' -f 11 $in2) > $out 15 | j=$i 16 | done 17 | mv tmp10 $testfile 18 | rm tmp* 19 | done 20 | -------------------------------------------------------------------------------- /resolve/lat.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ofile=${ARCH}.${TEST}.lat.csv 4 | rm -f ${ofile} 5 | for c1 in `jot 48 0`; do 6 | for c2 in `jot 48 0`; do 7 | d="results.${ARCH}/${SIZE}/${c1}-${c2}-${TEST}/01-${TEST}-headline.log" 8 | speed=`tail -1 ${d} | awk '{print $4}' | sed -e 's/s//g'` 9 | echo -n "${speed} " >> ${ofile} 10 | done 11 | echo "" >> ${ofile} 12 | done 13 | -------------------------------------------------------------------------------- /resolve/latency.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avsm/ipc-bench/76c03e880477666b1e2275607dd62a74f02b6daf/resolve/latency.pdf -------------------------------------------------------------------------------- /resolve/latency.r: -------------------------------------------------------------------------------- 1 | library(gplots) 2 | library(RSvgDevice) 3 | 4 | matrix.axes <- function(data) { 5 | a <- ((1:48)-1) / 48 6 | x <- (1:48) - 1 7 | axis(side=1, at=a, labels=x, las=1) 8 | axis(side=2, at=a, labels=x, las=3); 9 | } 10 | 11 | plot_grid <- function (arch, test) { 12 | inp <- as.matrix(read.table(sprintf("%s.%s.lat.csv", arch, test))) 13 | ncols <- 11 14 | col <- colorpanel(ncols, "white", "grey10") 15 | r <- range(inp) # autoscale 16 | t <- sprintf("%s %s (range %f)", arch, test, max(inp) - min(inp)) 17 | filled.contour(inp, zlim=r, plot.axes=matrix.axes(inp), nlevels=ncols, title=title(t)) 18 | } 19 | 20 | for (arch in c("48native", "48xenpin", "48xennopin")) { 21 | for (test in c("mempipe_lat", "pipe_lat", "unix_lat", "tcp_lat")) { 22 | f <- sprintf("latency-%s-%s.pdf", arch, test) 23 | pdf(file=f) 24 | plot_grid(arch, test) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /resolve/plot_ipi.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | 3 | import numpy as np 4 | import numpy.random 5 | import matplotlib 6 | matplotlib.use('Agg') 7 | 8 | import matplotlib.pyplot as plt 9 | import matplotlib.cm as cm 10 | 11 | def get_data_raw(filename): 12 | x, y, v = np.loadtxt(filename, usecols=(0,1,2), unpack=True) 13 | 14 | x_tmp = [] 15 | y_tmp = [] 16 | v_tmp = [] 17 | retdata = {} 18 | j = 0 19 | for i in range(0, len(x)): 20 | if x[i] == 0 and y[i] == 1: 21 | # new series 22 | if i > 0: 23 | retdata[j] = [x_tmp, y_tmp, v_tmp] 24 | # print len(retdata[j][0]) 25 | j = j + 1 26 | x_tmp = [x[i]] 27 | y_tmp = [y[i]] 28 | v_tmp = [v[i]] 29 | else: 30 | # continuing series 31 | x_tmp.append(x[i]) 32 | y_tmp.append(y[i]) 33 | v_tmp.append(v[i]) 34 | print j 35 | return retdata 36 | 37 | def get_data(filename): 38 | data = np.loadtxt(filename) 39 | return [data] 40 | 41 | # --------------------------- 42 | # Handle command line args 43 | 44 | if len(sys.argv) < 4: 45 | print "usage: python plot_ipi.py " 46 | sys.exit(0) 47 | 48 | input_file = sys.argv[1] 49 | max_core_id = int(sys.argv[2]) 50 | title = str(sys.argv[3]) 51 | 52 | datasets = get_data(input_file) 53 | 54 | i = 0 55 | fig = plt.figure(figsize=(4,3)) 56 | for ds in datasets: 57 | # print ds 58 | # heatmap, xedges, yedges = np.histogram2d(ds[0], ds[1], bins=180, weights=ds[2]) 59 | # extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] 60 | 61 | plt.clf() 62 | # print "plotting " + str(k) 63 | # plt.hexbin(ds[0], ds[1], C=ds[2], gridsize=max_core_id, linewidths=1, cmap=cm.jet, bins=None) 64 | plt.matshow(ds, fignum=0, vmin=1800, cmap="Greys") 65 | 66 | # plt.clf() 67 | # plt.imshow(heatmap, extent=extent) 68 | 69 | # add some 70 | plt.ylabel('Core ID') 71 | plt.ylim(0, max_core_id) 72 | plt.xlabel('Core ID') 73 | plt.xlim(0, max_core_id) 74 | plt.title(title) 75 | 76 | cb = plt.colorbar() 77 | cb.set_label('IPI latency in nanoseconds') 78 | 79 | plt.savefig("ipi_run_" + str(i) + ".pdf", format="pdf", bbox_inches='tight') 80 | plt.savefig("ipi_run_" + str(i) + ".png", format="png", bbox_inches='tight') 81 | 82 | i = i + 1 83 | -------------------------------------------------------------------------------- /resolve/plot_lat.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | 3 | import numpy as np 4 | import numpy.random 5 | import matplotlib 6 | matplotlib.use('Agg') 7 | 8 | import matplotlib.pyplot as plt 9 | import matplotlib.cm as cm 10 | import pylab 11 | 12 | def get_data(filename): 13 | data = np.loadtxt(filename) 14 | 15 | x_tmp = [] 16 | y_tmp = [] 17 | v_tmp = [] 18 | retdata = {} 19 | for i in range(0, len(data)): 20 | for j in range(0, len(data[i])): 21 | x_tmp.append(i) 22 | y_tmp.append(j) 23 | v_tmp.append(data[i][j]) 24 | 25 | retdata = [x_tmp, y_tmp, v_tmp] 26 | print len(retdata) 27 | return retdata 28 | 29 | 30 | # --------------------------- 31 | # Handle command line args 32 | 33 | if len(sys.argv) < 2: 34 | print "usage: python plot_lat.py <input file> <title> [fix-scale] [colourmap]" 35 | sys.exit(0) 36 | 37 | input_file = sys.argv[1] 38 | 39 | fix_scale = 0 40 | if len(sys.argv) > 3: 41 | fix_scale = int(sys.argv[3]) 42 | 43 | if len(sys.argv) > 4: 44 | colourmap = sys.argv[4] 45 | else: 46 | colourmap = "Greys" 47 | 48 | raw_data = np.loadtxt(input_file) 49 | data = get_data(input_file) 50 | 51 | fig = plt.figure(figsize=(4,3)) 52 | #f = pylab.Figure(figsize=(2,1.5)) 53 | # print ds 54 | #heatmap, xedges, yedges = np.histogram2d(data[0], data[1], bins=48, weights=data[2]) 55 | #extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] 56 | 57 | #plt.clf() 58 | #plt.hexbin(data[0], data[1], C=data[2], gridsize=40, linewidths=1, cmap=cm.jet, bins=None) 59 | 60 | #plt.clf() 61 | #plt.imshow(heatmap, extent=extent) 62 | 63 | if fix_scale != 0: 64 | plt.matshow(raw_data, vmax=0.000006, vmin=0.000001, fignum=0, cmap=colourmap) 65 | else: 66 | plt.matshow(raw_data, fignum=0, cmap=colourmap) 67 | 68 | # add some 69 | plt.ylabel('Core ID') 70 | plt.ylim(0, 48) 71 | plt.xlabel('Core ID') 72 | plt.xlim(0, 48) 73 | plt.title(sys.argv[2]) 74 | 75 | cb = plt.colorbar(shrink=1.0, format='%.3e') 76 | cb.set_label('Latency in microseconds') 77 | 78 | plt.savefig("lat_" + sys.argv[1] + ".pdf", format="pdf", bbox_inches='tight') 79 | plt.savefig("lat_" + sys.argv[1] + ".png", format="png", bbox_inches='tight') 80 | -------------------------------------------------------------------------------- /results/tmpIe94ic.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avsm/ipc-bench/76c03e880477666b1e2275607dd62a74f02b6daf/results/tmpIe94ic.tar.gz -------------------------------------------------------------------------------- /results/tmpK1UpPd.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avsm/ipc-bench/76c03e880477666b1e2275607dd62a74f02b6daf/results/tmpK1UpPd.tar.gz -------------------------------------------------------------------------------- /results/tmpR6gPcQ.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avsm/ipc-bench/76c03e880477666b1e2275607dd62a74f02b6daf/results/tmpR6gPcQ.tar.gz -------------------------------------------------------------------------------- /results/tmpw3ZQ5R.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avsm/ipc-bench/76c03e880477666b1e2275607dd62a74f02b6daf/results/tmpw3ZQ5R.tar.gz -------------------------------------------------------------------------------- /shm.c: -------------------------------------------------------------------------------- 1 | /* Measure latency of IPC using shm */ 2 | 3 | #include <unistd.h> 4 | #include <stdio.h> 5 | #include <stdlib.h> 6 | #include <sys/time.h> 7 | #include <stdint.h> 8 | #include <sys/types.h> 9 | #include <sys/ipc.h> 10 | #include <sys/shm.h> 11 | 12 | int main(void) 13 | { 14 | int pfds[2]; 15 | 16 | char c; 17 | int shmid; 18 | key_t key; 19 | struct timespec *shm; 20 | 21 | 22 | 23 | struct timespec start, stop; 24 | 25 | int64_t delta; 26 | 27 | int64_t max = 0; 28 | int64_t min = INT64_MAX; 29 | int64_t sum = 0; 30 | int64_t count = 0; 31 | 32 | /* 33 | * We'll name our shared memory segment 34 | * "5678". 35 | */ 36 | key = 5678; 37 | 38 | if (!fork()) { 39 | 40 | /* 41 | * Create the segment. 42 | */ 43 | if ((shmid = shmget(key, 100, IPC_CREAT | 0666)) < 0) { 44 | perror("shmget"); 45 | exit(1); 46 | } 47 | 48 | /* 49 | * Now we attach the segment to our data space. 50 | */ 51 | if ((shm = shmat(shmid, NULL, 0)) == (struct timespec*) -1) { 52 | perror("shmat"); 53 | exit(1); 54 | } 55 | 56 | while (1) { 57 | clock_gettime(CLOCK_MONOTONIC, shm); 58 | 59 | usleep(10000); 60 | } 61 | } else { 62 | sleep(1); 63 | 64 | /* 65 | * Locate the segment. 66 | */ 67 | if ((shmid = shmget(key, 100, 0666)) < 0) { 68 | perror("shmget"); 69 | exit(1); 70 | } 71 | 72 | /* 73 | * Now we attach the segment to our data space. 74 | */ 75 | if ((shm = shmat(shmid, NULL, 0)) == (struct timespec *) -1) { 76 | perror("shmat"); 77 | exit(1); 78 | } 79 | 80 | while (1) { 81 | while ((shm->tv_sec == start.tv_sec) && (shm->tv_nsec == start.tv_nsec)) {} 82 | 83 | clock_gettime(CLOCK_MONOTONIC, &stop); 84 | start = *shm; 85 | delta = ((stop.tv_sec - start.tv_sec) * (int64_t) 1000000000 + 86 | stop.tv_nsec - start.tv_nsec); 87 | 88 | if (delta > max) 89 | max = delta; 90 | else if (delta < min) 91 | min = delta; 92 | 93 | sum += delta; 94 | count++; 95 | 96 | if (!(count % 100)) { 97 | printf("%lli %lli %lli\n", max, min, sum / count); 98 | } 99 | } 100 | } 101 | 102 | return 0; 103 | } 104 | -------------------------------------------------------------------------------- /summarise_tsc_counters.c: -------------------------------------------------------------------------------- 1 | #include <assert.h> 2 | #include <err.h> 3 | #include <math.h> 4 | #include <stdbool.h> 5 | #include <stdio.h> 6 | #include <stdlib.h> 7 | #include "xutil.h" 8 | 9 | static void 10 | read_input(double **_res, int *nr_samples) 11 | { 12 | int n = 0; 13 | int n_alloced = 0; 14 | double *res = NULL; 15 | double i; 16 | int r; 17 | 18 | while (!feof(stdin)) { 19 | if (n_alloced == n) { 20 | n_alloced += 1024; 21 | res = realloc(res, sizeof(res[0]) * n_alloced); 22 | if (!res) 23 | err(1, "realloc"); 24 | } 25 | r = scanf("%le\n", &i); 26 | if (r < 0) 27 | err(1, "scanf"); 28 | if (r == 0 && feof(stdin)) 29 | break; 30 | if (r != 1) 31 | errx(1, "scanf returned unexpected value %d", r); 32 | res[n] = i; 33 | n++; 34 | } 35 | *_res = res; 36 | *nr_samples = n; 37 | } 38 | 39 | int 40 | main() 41 | { 42 | double *times; 43 | int nr_samples; 44 | 45 | read_input(×, &nr_samples); 46 | 47 | summarise_samples(stdout, times, nr_samples); 48 | 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /tcp_local_lat.c: -------------------------------------------------------------------------------- 1 | /* 2 | Measure latency of IPC using tcp sockets 3 | 4 | Copyright (c) 2010 Erik Rigtorp <erik@rigtorp.com> 5 | Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org> 6 | 7 | Permission is hereby granted, free of charge, to any person 8 | obtaining a copy of this software and associated documentation 9 | files (the "Software"), to deal in the Software without 10 | restriction, including without limitation the rights to use, 11 | copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following 14 | conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 21 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26 | OTHER DEALINGS IN THE SOFTWARE. 27 | */ 28 | 29 | #include <unistd.h> 30 | #include <stdio.h> 31 | #include <stdlib.h> 32 | #include <sys/socket.h> 33 | #include <string.h> 34 | #include <sys/time.h> 35 | #include <inttypes.h> 36 | #include <netdb.h> 37 | #include <err.h> 38 | #include "xutil.h" 39 | 40 | int 41 | main(int argc, char *argv[]) 42 | { 43 | int size; 44 | char *buf; 45 | int64_t count, i; 46 | 47 | int yes = 1; 48 | int ret; 49 | struct sockaddr_storage their_addr; 50 | socklen_t addr_size; 51 | struct addrinfo hints; 52 | struct addrinfo *res; 53 | int sockfd, new_fd; 54 | 55 | if (argc != 5) { 56 | printf ("usage: tcp_local_lat <bind-to> <port> <message-size> <roundtrip-count>\n"); 57 | return 1; 58 | } 59 | 60 | size = atoi(argv[3]); 61 | count = atol(argv[4]); 62 | 63 | buf = xmalloc(size); 64 | 65 | memset(&hints, 0, sizeof hints); 66 | hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever 67 | hints.ai_socktype = SOCK_STREAM; 68 | hints.ai_flags = AI_PASSIVE; // fill in my IP for me 69 | if ((ret = getaddrinfo(argv[1], argv[2], &hints, &res)) != 0) 70 | errx(1, "getaddrinfo: %s", gai_strerror(ret)); 71 | 72 | if ((sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) 73 | err(1, "socket"); 74 | 75 | if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) 76 | err(1, "setsockopt"); 77 | 78 | if (bind(sockfd, res->ai_addr, res->ai_addrlen) == -1) 79 | err(1, "bind"); 80 | 81 | if (listen(sockfd, 1) == -1) 82 | err(1, "listen"); 83 | 84 | addr_size = sizeof their_addr; 85 | 86 | if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &addr_size)) == -1) 87 | err(1, "accept"); 88 | 89 | for (i = 0; i < count; i++) { 90 | xread(new_fd, buf, size); 91 | xwrite(new_fd, buf, size); 92 | } 93 | 94 | return 0; 95 | } 96 | -------------------------------------------------------------------------------- /tcp_remote_lat.c: -------------------------------------------------------------------------------- 1 | /* 2 | Measure latency of IPC using tcp sockets 3 | 4 | Copyright (c) 2010 Erik Rigtorp <erik@rigtorp.com> 5 | Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org> 6 | 7 | Permission is hereby granted, free of charge, to any person 8 | obtaining a copy of this software and associated documentation 9 | files (the "Software"), to deal in the Software without 10 | restriction, including without limitation the rights to use, 11 | copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the 13 | Software is furnished to do so, subject to the following 14 | conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 21 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 23 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 24 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 26 | OTHER DEALINGS IN THE SOFTWARE. 27 | */ 28 | 29 | #include <unistd.h> 30 | #include <stdio.h> 31 | #include <stdlib.h> 32 | #include <sys/socket.h> 33 | #include <string.h> 34 | #include <sys/time.h> 35 | #include <inttypes.h> 36 | #include <netdb.h> 37 | #include <err.h> 38 | #include "xutil.h" 39 | 40 | int 41 | main(int argc, char *argv[]) 42 | { 43 | int size; 44 | char *buf; 45 | int64_t count, i, delta; 46 | struct timeval start, stop; 47 | 48 | int ret; 49 | struct addrinfo hints; 50 | struct addrinfo *res; 51 | int sockfd; 52 | 53 | if (argc != 6) { 54 | printf ("usage: tcp_lat <bind-to> <host> <port> <message-size> <roundtrip-count>\n"); 55 | return 1; 56 | } 57 | 58 | size = atoi(argv[4]); 59 | count = atol(argv[5]); 60 | 61 | buf = xmalloc(size); 62 | 63 | memset(&hints, 0, sizeof hints); 64 | hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6, whichever 65 | hints.ai_socktype = SOCK_STREAM; 66 | hints.ai_flags = AI_PASSIVE; // fill in my IP for me 67 | if ((ret = getaddrinfo(argv[1], NULL, &hints, &res)) != 0) 68 | errx(1, "getaddrinfo: %s", gai_strerror(ret)); 69 | 70 | if ((sockfd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) 71 | err(1, "socket"); 72 | 73 | if (bind(sockfd, res->ai_addr, res->ai_addrlen) == -1) 74 | err(1, "bind"); 75 | 76 | if ((ret = getaddrinfo(argv[2], argv[3], &hints, &res)) != 0) 77 | errx(1, "getaddrinfo: %s", gai_strerror(ret)); 78 | 79 | if (connect(sockfd, res->ai_addr, res->ai_addrlen) == -1) 80 | err(1, "connect"); 81 | 82 | gettimeofday(&start, NULL); 83 | 84 | for (i = 0; i < count; i++) { 85 | xwrite(sockfd, buf, size); 86 | xread(sockfd, buf, size); 87 | } 88 | 89 | gettimeofday(&stop, NULL); 90 | 91 | delta = ((stop.tv_sec - start.tv_sec) * (int64_t) 1e6 + 92 | stop.tv_usec - start.tv_usec); 93 | 94 | printf("tcp_remote %d %" PRId64 " %" PRId64 "\n", size, count, delta / (count * 2)); 95 | return 0; 96 | } 97 | -------------------------------------------------------------------------------- /test.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org> 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | */ 25 | 26 | #include <stdio.h> 27 | 28 | #define PRODUCE_GLIBC_MEMSET 1 29 | #define PRODUCE_STOS_MEMSET 2 30 | #define PRODUCE_LOOP 3 31 | 32 | typedef struct { 33 | int num; 34 | int size; 35 | size_t count; 36 | bool per_iter_timings; 37 | void *data; 38 | const char *output_dir; 39 | const char *name; 40 | int write_in_place; 41 | int read_in_place; 42 | int produce_method; 43 | int do_verify; 44 | int first_core; 45 | int second_core; 46 | int numa_node; 47 | } test_data; 48 | 49 | typedef struct { 50 | const char *name; 51 | int is_latency_test; 52 | void (*init_test)(test_data *); 53 | void (*init_parent)(test_data *); 54 | void (*finish_parent)(test_data *); 55 | void (*init_child)(test_data *); 56 | void (*finish_child)(test_data *); 57 | struct iovec* (*get_write_buffer)(test_data *, int size, int* n_vecs); 58 | void (*release_write_buffer)(test_data *, struct iovec* vecs, int n_vecs); 59 | struct iovec* (*get_read_buffer)(test_data *, int size, int* n_vecs); 60 | void (*release_read_buffer)(test_data *, struct iovec* vecs, int n_vecs); 61 | void (*parent_ping)(test_data *); 62 | void (*child_ping)(test_data *); 63 | } test_t; 64 | 65 | static inline unsigned long 66 | rdtsc(void) 67 | { 68 | unsigned long a, d; 69 | asm volatile("rdtsc" 70 | : "=a" (a), "=d" (d) 71 | ); 72 | return (d << 32) | a; 73 | } 74 | 75 | void run_test(int argc, char *argv[], test_t *test); 76 | 77 | void dump_tsc_counters(test_data *td, unsigned long *counts, int nr_samples); 78 | 79 | void logmsg(test_data *td, 80 | const char *file, 81 | const char *fmt, 82 | ...) 83 | __attribute__((format (printf, 3, 4))); 84 | -------------------------------------------------------------------------------- /unix_lat.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org> 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include <unistd.h> 27 | #include <stdbool.h> 28 | #include <stdio.h> 29 | #include <stdlib.h> 30 | #include <sys/socket.h> 31 | #include <string.h> 32 | #include <sys/time.h> 33 | #include <err.h> 34 | #include <inttypes.h> 35 | #include <netdb.h> 36 | 37 | #include <sys/types.h> 38 | #include <sys/wait.h> 39 | #include <errno.h> 40 | 41 | #include "test.h" 42 | #include "xutil.h" 43 | 44 | typedef struct { 45 | int sv[2]; 46 | void* buf; 47 | } test_state; 48 | 49 | static void 50 | init_test(test_data *td) 51 | { 52 | test_state *ts = xmalloc(sizeof(test_state)); 53 | if (socketpair(AF_UNIX, SOCK_STREAM, 0, ts->sv) == -1) 54 | err(1, "socketpair"); 55 | td->data = (void *)ts; 56 | } 57 | 58 | static void 59 | local_init(test_data *td) 60 | { 61 | test_state *ps = (test_state *)td->data; 62 | ps->buf = xmalloc(td->size); 63 | } 64 | 65 | static void 66 | child_ping(test_data *td) 67 | { 68 | test_state *ps = (test_state *)td->data; 69 | xread(ps->sv[1], ps->buf, td->size); 70 | xwrite(ps->sv[1], ps->buf, td->size); 71 | } 72 | 73 | static void 74 | parent_ping(test_data *td) 75 | { 76 | test_state *ps = (test_state *)td->data; 77 | xwrite(ps->sv[0], ps->buf, td->size); 78 | xread(ps->sv[0], ps->buf, td->size); 79 | } 80 | 81 | int 82 | main(int argc, char *argv[]) 83 | { 84 | test_t t = { .name = "unix_lat", 85 | .is_latency_test = 1, 86 | .init_test = init_test, 87 | .init_parent = local_init, 88 | .init_child = local_init, 89 | .parent_ping = parent_ping, 90 | .child_ping = child_ping 91 | }; 92 | run_test(argc, argv, &t); 93 | return 0; 94 | } 95 | -------------------------------------------------------------------------------- /unix_thr.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org> 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include <unistd.h> 27 | #include <stdbool.h> 28 | #include <stdio.h> 29 | #include <stdlib.h> 30 | #include <sys/socket.h> 31 | #include <string.h> 32 | #include <sys/time.h> 33 | #include <err.h> 34 | #include <inttypes.h> 35 | #include <netdb.h> 36 | #include <assert.h> 37 | 38 | #include <sys/types.h> 39 | #include <sys/wait.h> 40 | #include <sys/uio.h> 41 | #include <errno.h> 42 | 43 | #include "test.h" 44 | #include "xutil.h" 45 | 46 | typedef struct { 47 | int sv[2]; 48 | struct iovec buffer; 49 | } test_state; 50 | 51 | static void 52 | init_test(test_data *td) 53 | { 54 | test_state *ts = xmalloc(sizeof(test_state)); 55 | if (socketpair(AF_UNIX, SOCK_STREAM, 0, ts->sv) == -1) 56 | err(1, "socketpair"); 57 | td->data = (void *)ts; 58 | } 59 | 60 | static void 61 | init_local(test_data *td) 62 | { 63 | test_state *ts = (test_state*)td->data; 64 | ts->buffer.iov_base = xmalloc(td->size); 65 | ts->buffer.iov_len = td->size; 66 | } 67 | 68 | static struct iovec* 69 | get_read_buf(test_data *td, int len, int* n_vecs) 70 | { 71 | test_state *ps = (test_state *)td->data; 72 | xread(ps->sv[1], ps->buffer.iov_base, len); 73 | *n_vecs = 1; 74 | return &ps->buffer; 75 | } 76 | 77 | static void 78 | release_read_buf(test_data *td, struct iovec* vecs, int n_vecs) { 79 | test_state *ps = (test_state *)td->data; 80 | assert(n_vecs == 1); 81 | assert(vecs == &ps->buffer); 82 | } 83 | 84 | static void child_fin(test_data *td) { 85 | 86 | test_state *ps = (test_state *)td->data; 87 | xwrite(ps->sv[1], "X", 1); 88 | 89 | } 90 | 91 | static struct iovec* get_write_buf(test_data *td, int len, int* n_vecs) { 92 | test_state *ps = (test_state *)td->data; 93 | assert(len == td->size); 94 | *n_vecs = 1; 95 | return &ps->buffer; 96 | } 97 | 98 | static void 99 | release_write_buf(test_data *td, struct iovec* vecs, int n_vecs) 100 | { 101 | test_state *ps = (test_state *)td->data; 102 | assert(vecs == &ps->buffer && n_vecs == 1); 103 | xwrite(ps->sv[0], vecs[0].iov_base, vecs[0].iov_len); 104 | } 105 | 106 | static void parent_fin(test_data *td) { 107 | test_state *ps = (test_state*)td->data; 108 | xread(ps->sv[0], ps->buffer.iov_base, 1); 109 | } 110 | 111 | int 112 | main(int argc, char *argv[]) 113 | { 114 | test_t t = { 115 | .name = "unix_thr", 116 | .is_latency_test = 0, 117 | .init_test = init_test, 118 | .init_parent = init_local, 119 | .finish_parent = parent_fin, 120 | .init_child = init_local, 121 | .finish_child = child_fin, 122 | .get_write_buffer = get_write_buf, 123 | .release_write_buffer = release_write_buf, 124 | .get_read_buffer = get_read_buf, 125 | .release_read_buffer = release_read_buf 126 | }; 127 | run_test(argc, argv, &t); 128 | return 0; 129 | } 130 | -------------------------------------------------------------------------------- /web/processing/cron.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CUR_DIR=$(pwd) 4 | 5 | RESULTS_DIR=../../results 6 | OUT_DIR=/usr/groups/netos/html/ipc-bench 7 | HTML_OUTFILE=results.html 8 | 9 | cd ${RESULTS_DIR} 10 | RESULTS=$(ls tmp*.tar.gz) 11 | cd ${CUR_DIR} 12 | 13 | # Generate results.html 14 | cat ${PWD}/html_head.tmpl > ${OUT_DIR}/${HTML_OUTFILE}.new 15 | cat ${PWD}/html_results_head.tmpl >> ${OUT_DIR}/${HTML_OUTFILE}.new 16 | for r in ${RESULTS}; do 17 | ARCHIVE=${r} 18 | echo -n "Extracting ${ARCHIVE}..." 19 | tar -xzf ${RESULTS_DIR}/${ARCHIVE} 20 | echo " done!" 21 | NAME=$(echo ${r} | sed 's/\.tar\.gz//g') 22 | DIR=tmp/${NAME} 23 | # Check the extracted data directory exists 24 | if [[ ! -d ${DIR} ]]; then 25 | echo "FATAL: After extraction, ${DIR} did not exist!" 26 | fi 27 | 28 | # Find the target cores used 29 | TARGET_CPUS=$(cat ${DIR}/logs/target_cpus) 30 | 31 | # Now generate the results overview page 32 | python gen-overview-entry.py ${DIR} ${OUT_DIR}/${HTML_OUTFILE}.new \ 33 | ${TARGET_CPUS} ${NAME} 34 | 35 | # Generate details page 36 | mkdir -p ${OUT_DIR}/details 37 | mkdir -p ${DIR}/graphs 38 | cat ${PWD}/html_head.tmpl > ${OUT_DIR}/details/${NAME}.html 39 | python gen-details-page.py ${DIR} ${OUT_DIR}/details ${TARGET_CPUS} ${NAME} 40 | cat ${PWD}/html_foot.tmpl >> ${OUT_DIR}/details/${NAME}.html 41 | 42 | # Move graphs 43 | mkdir -p ${OUT_DIR}/graphs 44 | rm -rf ${OUT_DIR}/graphs/${NAME} 45 | mv ${DIR}/graphs ${OUT_DIR}/graphs/${NAME} 46 | chmod -R g+rx ${OUT_DIR}/graphs/${NAME} 47 | chmod -R o+rx ${OUT_DIR}/graphs/${NAME} 48 | done 49 | cat ${PWD}/html_results_foot.tmpl >> ${OUT_DIR}/${HTML_OUTFILE}.new 50 | cat ${PWD}/html_foot.tmpl >> ${OUT_DIR}/${HTML_OUTFILE}.new 51 | 52 | mv ${OUT_DIR}/${HTML_OUTFILE}.new ${OUT_DIR}/${HTML_OUTFILE} 53 | 54 | 55 | -------------------------------------------------------------------------------- /web/processing/gen-overview-entry.py: -------------------------------------------------------------------------------- 1 | #!/usr/env/python 2 | import sys, os 3 | import re 4 | import subprocess 5 | 6 | data_dir = sys.argv[1] 7 | results_dir = data_dir + "/results" 8 | outfile = sys.argv[2] 9 | target_cpus = sys.argv[3] 10 | name = sys.argv[4] 11 | 12 | github_user = "ms705" 13 | 14 | print "Processing data in %s" % data_dir 15 | print "Target CPUs are: %s" % target_cpus.split(",") 16 | 17 | processor_ids = [] 18 | model_names = [] 19 | for line in open(data_dir + "/logs/cpuinfo").readlines(): 20 | r = re.search("processor\t: ([0-9]+)", line) 21 | if r: 22 | processor_ids.append(r.group(1)) 23 | r = re.search("model name\t: (.+)", line) 24 | if r: 25 | model_names.append(r.group(1)) 26 | 27 | num_cores = len(processor_ids) 28 | 29 | # NUMA-ness & number of nodes 30 | numa_string = "unknown" 31 | try: 32 | l = os.listdir(data_dir + "/logs/sys-node") 33 | if len(l) > 1: 34 | numa_string = "yes (%d)" % len(l) 35 | else: 36 | numa_string = "no" 37 | except: 38 | pass 39 | 40 | # virtualization 41 | virtualized_string = "unknown" 42 | for line in open(data_dir + "/logs/dmesg_virt").readlines(): 43 | r = re.search("bare hardware", line) 44 | if r: 45 | virtualized_string = "no" 46 | break 47 | r = re.search("(Xen|virtual hardware|virtualized system)", line) 48 | # need to differentiate between different forms of virtualization 49 | if r: 50 | virtualized_string = "yes" 51 | break 52 | 53 | # uname/OS 54 | os_string = "unknown" 55 | for line in open(data_dir + "/logs/uname").readlines(): 56 | fields = line.split() 57 | os = fields[0] 58 | ver = fields[1] 59 | arch = fields[2] 60 | os_string = "%s %s, %s" % (os, ver, arch) 61 | 62 | # Generate HTML output 63 | html = "<tr><td>%s</td><td>%d</td><td>%s</td><td>%s</td><td>%s</td>" \ 64 | "<td>%s</td><td>%s</td></tr>" 65 | 66 | thr_graphs_links = "" 67 | for c in target_cpus.split(","): 68 | graph_file = "graphs/%s/core_0_to_%s.png" % (name, c) 69 | if thr_graphs_links != "": 70 | thr_graphs_links = thr_graphs_links + ", " 71 | thr_graphs_links = thr_graphs_links + "<a href=\"%s\">0 to %s</a>" \ 72 | % (graph_file, c) 73 | 74 | details_link = "<a href=\"details/%s.html\">View</a>" % name 75 | 76 | raw_data_link = "<a href=\"https://raw.github.com/%s/ipc-bench/master/" \ 77 | "results/%s.tar.gz\">Download</a>" % (github_user, name) 78 | 79 | out_html = html % (model_names[0], num_cores, numa_string, os_string, 80 | virtualized_string, details_link, raw_data_link) 81 | 82 | out_fd = open(outfile, "a") 83 | out_fd.write(out_html) 84 | out_fd.close() 85 | -------------------------------------------------------------------------------- /web/processing/html_foot.tmpl: -------------------------------------------------------------------------------- 1 | <hr /> 2 | <div style="font-size: 80%; color: gray;"><p>This research is done by the NetOS group at the University of Cambridge Computer Laboratory. If you have any questions or would like to learn more, please contact us directly:</p> 3 | 4 | <p><strong>Email:</strong><br /><a href="mailto:cl-ipc-bench@lists.cam.ac.uk">cl-ipc-bench@lists.cam.ac.uk</a></p> 5 | 6 | <p><strong>Postal address:</strong><br />NetOS group<br />University of Cambridge Computer Laboratory<br />Willam Gates Building<br />15 JJ Thomson Avenue<br />Cambridge CB3 0FD, UK<br />Tel.: +44 1223 763683 7 | </p> 8 | </div> 9 | 10 | </div></div> 11 | 12 | <ul id="site-info"><li class="copy">© 2012 Computer Laboratory, University of Cambridge<br />Information provided by <a href="http://www.cl.cam.ac.uk/~ms705/">Malte Schwarzkopf</a></li></ul> 13 | </div> 14 | </body></html> 15 | -------------------------------------------------------------------------------- /web/processing/html_head.tmpl: -------------------------------------------------------------------------------- 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 | <!-- DO NOT EDIT: file automatically generated by ucampas from 3 | /auto/groups/netos/html/ipc-bench/test-b.html --> 4 | <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type" /><meta content="text/css" http-equiv="Content-Style-Type" /><title>Computer Laboratory: ipc-bench 5 | 6 | 7 | 8 | 17 | 18 | 19 | 33 | 34 | 36 | 37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /web/processing/html_results_foot.tmpl: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /web/processing/html_results_head.tmpl: -------------------------------------------------------------------------------- 1 |

ipc-bench: Results

2 | 3 | 10 | 11 |

On this page, we are listing aggregated ipc-bench results collected by the community. To have your systems included on this page, run ipc-bench and wait for a few days to give us a chance to pull your results into the official repository.

12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /web/processing/plot_ipi.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | 3 | import numpy as np 4 | import numpy.random 5 | import matplotlib 6 | matplotlib.use('Agg') 7 | 8 | import matplotlib.pyplot as plt 9 | import matplotlib.cm as cm 10 | 11 | def get_data_raw(filename): 12 | x, y, v = np.loadtxt(filename, usecols=(0,1,2), unpack=True) 13 | 14 | x_tmp = [] 15 | y_tmp = [] 16 | v_tmp = [] 17 | retdata = {} 18 | j = 0 19 | for i in range(0, len(x)): 20 | if x[i] == 0 and y[i] == 1: 21 | # new series 22 | if i > 0: 23 | retdata[j] = [x_tmp, y_tmp, v_tmp] 24 | # print len(retdata[j][0]) 25 | j = j + 1 26 | x_tmp = [x[i]] 27 | y_tmp = [y[i]] 28 | v_tmp = [v[i]] 29 | else: 30 | # continuing series 31 | x_tmp.append(x[i]) 32 | y_tmp.append(y[i]) 33 | v_tmp.append(v[i]) 34 | print j 35 | return retdata 36 | 37 | def get_data(filename): 38 | data = np.loadtxt(filename) 39 | return [data] 40 | 41 | # --------------------------- 42 | # Handle command line args 43 | 44 | if len(sys.argv) < 4: 45 | print "usage: python plot_ipi.py " 46 | sys.exit(0) 47 | 48 | input_file = sys.argv[1] 49 | max_core_id = int(sys.argv[2]) 50 | title = str(sys.argv[3]) 51 | 52 | datasets = get_data(input_file) 53 | 54 | i = 0 55 | fig = plt.figure(figsize=(4,3)) 56 | for ds in datasets: 57 | # print ds 58 | # heatmap, xedges, yedges = np.histogram2d(ds[0], ds[1], bins=180, weights=ds[2]) 59 | # extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] 60 | 61 | plt.clf() 62 | # print "plotting " + str(k) 63 | # plt.hexbin(ds[0], ds[1], C=ds[2], gridsize=max_core_id, linewidths=1, cmap=cm.jet, bins=None) 64 | plt.matshow(ds, fignum=0, vmin=1800, cmap="Greys") 65 | 66 | # plt.clf() 67 | # plt.imshow(heatmap, extent=extent) 68 | 69 | # add some 70 | plt.ylabel('Core ID') 71 | plt.ylim(0, max_core_id) 72 | plt.xlabel('Core ID') 73 | plt.xlim(0, max_core_id) 74 | plt.title(title) 75 | 76 | cb = plt.colorbar() 77 | cb.set_label('IPI latency in nanoseconds') 78 | 79 | plt.savefig("ipi_run_" + str(i) + ".pdf", format="pdf", bbox_inches='tight') 80 | plt.savefig("ipi_run_" + str(i) + ".png", format="png", bbox_inches='tight') 81 | 82 | i = i + 1 83 | -------------------------------------------------------------------------------- /web/processing/plot_lat.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | 3 | import matplotlib 4 | matplotlib.use("Agg") 5 | import numpy as np 6 | import numpy.random 7 | import matplotlib.pyplot as plt 8 | import matplotlib.cm as cm 9 | import pylab as pyl 10 | import re 11 | 12 | def get_data(filename): 13 | data = np.loadtxt(filename) 14 | 15 | x_tmp = [] 16 | y_tmp = [] 17 | v_tmp = [] 18 | retdata = {} 19 | for i in range(0, len(data)): 20 | for j in range(0, len(data[i])): 21 | x_tmp.append(i) 22 | y_tmp.append(j) 23 | v_tmp.append(data[i][j]) 24 | 25 | retdata = [x_tmp, y_tmp, v_tmp] 26 | print len(retdata) 27 | return retdata 28 | 29 | 30 | # --------------------------- 31 | # Handle command line args 32 | 33 | if len(sys.argv) < 2: 34 | print "usage: python plot_lat.py <input file> <title> <output_dir> <num_cores> [fix-scale]" 35 | sys.exit(0) 36 | 37 | input_file = sys.argv[1] 38 | 39 | fix_scale = 0 40 | if len(sys.argv) > 5: 41 | fix_scale = int(sys.argv[5]) 42 | 43 | num_cores = int(sys.argv[4]) 44 | 45 | output_dir = sys.argv[3] 46 | 47 | raw_data = np.loadtxt(input_file) 48 | data = get_data(input_file) 49 | 50 | fig = plt.figure(figsize=(3,2)) 51 | pyl.rc('font', size='8.0') 52 | #f = pylab.Figure(figsize=(2,1.5)) 53 | # print ds 54 | #heatmap, xedges, yedges = np.histogram2d(data[0], data[1], bins=48, weights=data[2]) 55 | #extent = [xedges[0], xedges[-1], yedges[0], yedges[-1]] 56 | 57 | #plt.clf() 58 | #plt.hexbin(data[0], data[1], C=data[2], gridsize=40, linewidths=1, cmap=cm.jet, bins=None) 59 | 60 | #plt.clf() 61 | #plt.imshow(heatmap, extent=extent) 62 | 63 | if fix_scale != 0: 64 | plt.matshow(raw_data, vmax=0.0001, vmin=0.00001, fignum=0) 65 | else: 66 | plt.matshow(raw_data, fignum=0) 67 | 68 | # add some 69 | plt.ylabel('Core ID') 70 | plt.ylim(-0.5, int(sys.argv[4])-0.5) 71 | plt.xlabel('Core ID') 72 | plt.xlim(-0.5, int(sys.argv[4])-0.5) 73 | test_name = re.search("(.+)\.csv", sys.argv[2]) 74 | plt.title(test_name.group(1)) 75 | 76 | cb = plt.colorbar(shrink=1.0, format='%.3e') 77 | cb.set_label('Latency in microseconds') 78 | 79 | #plt.savefig("lat_" + sys.argv[1] + ".pdf", format="pdf", bbox_inches='tight') 80 | plt.savefig(output_dir + "/lat_" + sys.argv[2] + ".png", format="png", bbox_inches='tight') 81 | -------------------------------------------------------------------------------- /xen/mini-os/COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Citrix Systems, Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 12 | THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 13 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 15 | ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 16 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 17 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 18 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 19 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 20 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 22 | SUCH DAMAGE. 23 | 24 | -------------------------------------------------------------------------------- /xen/mini-os/Config.mk: -------------------------------------------------------------------------------- 1 | # Set mini-os root path, used in mini-os.mk. 2 | MINI-OS_ROOT=$(PWD) 3 | export MINI-OS_ROOT 4 | 5 | libc = $(stubdom) 6 | 7 | XEN_INTERFACE_VERSION := 0x00030205 8 | export XEN_INTERFACE_VERSION 9 | 10 | # Try to find out the architecture family TARGET_ARCH_FAM. 11 | # First check whether x86_... is contained (for x86_32, x86_32y, x86_64). 12 | # If not x86 then use $(XEN_TARGET_ARCH) -> for ia64, ... 13 | ifeq ($(findstring x86_,$(XEN_TARGET_ARCH)),x86_) 14 | TARGET_ARCH_FAM = x86 15 | else 16 | TARGET_ARCH_FAM = $(XEN_TARGET_ARCH) 17 | endif 18 | 19 | # The architecture family directory below mini-os. 20 | TARGET_ARCH_DIR := arch/$(TARGET_ARCH_FAM) 21 | 22 | # Export these variables for possible use in architecture dependent makefiles. 23 | export TARGET_ARCH_DIR 24 | export TARGET_ARCH_FAM 25 | 26 | # This is used for architecture specific links. 27 | # This can be overwritten from arch specific rules. 28 | ARCH_LINKS = 29 | 30 | # The path pointing to the architecture specific header files. 31 | ARCH_INC := $(TARGET_ARCH_FAM) 32 | 33 | # For possible special header directories. 34 | # This can be overwritten from arch specific rules. 35 | EXTRA_INC = $(ARCH_INC) 36 | 37 | # Include the architecture family's special makerules. 38 | # This must be before include minios.mk! 39 | include $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk 40 | 41 | extra_incl := $(foreach dir,$(EXTRA_INC),-isystem $(MINI-OS_ROOT)/include/$(dir)) 42 | 43 | DEF_CPPFLAGS += -isystem $(MINI-OS_ROOT)/include 44 | DEF_CPPFLAGS += -D__MINIOS__ 45 | 46 | ifeq ($(libc),y) 47 | DEF_CPPFLAGS += -DHAVE_LIBC 48 | DEF_CPPFLAGS += -isystem $(MINI-OS_ROOT)/include/posix 49 | DEF_CPPFLAGS += -isystem $(XEN_ROOT)/tools/xenstore 50 | endif 51 | 52 | ifneq ($(LWIPDIR),) 53 | lwip=y 54 | DEF_CPPFLAGS += -DHAVE_LWIP 55 | DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include 56 | DEF_CPPFLAGS += -isystem $(LWIPDIR)/src/include/ipv4 57 | endif 58 | -------------------------------------------------------------------------------- /xen/mini-os/README: -------------------------------------------------------------------------------- 1 | Minimal OS 2 | ---------- 3 | 4 | This shows some of the stuff that any guest OS will have to set up. 5 | 6 | This includes: 7 | 8 | * installing a virtual exception table 9 | * handling virtual exceptions 10 | * handling asynchronous events 11 | * enabling/disabling async events 12 | * parsing start_info struct at start-of-day 13 | * registering virtual interrupt handlers (for timer interrupts) 14 | * a simple page and memory allocator 15 | * minimal libc support 16 | * minimal Copy-on-Write support 17 | * network, block, framebuffer support 18 | * transparent access to FileSystem exports (see tools/fs-back) 19 | 20 | - to build it just type make. 21 | 22 | - to build it with TCP/IP support, download LWIP 1.3 source code and type 23 | 24 | make LWIPDIR=/path/to/lwip/source 25 | 26 | - to build it with much better libc support, see the stubdom/ directory 27 | 28 | - to start it do the following in domain0 (assuming xend is running) 29 | # xm create domain_config 30 | 31 | This starts the kernel and prints out a bunch of stuff and then once every 32 | second the system time. 33 | 34 | If you have setup a disk in the config file (e.g. 35 | disk = [ 'file:/tmp/foo,hda,r' ] ), it will loop reading it. If that disk is 36 | writable (e.g. disk = [ 'file:/tmp/foo,hda,w' ] ), it will write data patterns 37 | and re-read them. 38 | 39 | If you have setup a network in the config file (e.g. vif = [''] ), it will 40 | print incoming packets. 41 | 42 | If you have setup a VFB in the config file (e.g. vfb = ['type=sdl'] ), it will 43 | show a mouse with which you can draw color squares. 44 | 45 | If you have compiled it with TCP/IP support, it will run a daytime server on 46 | TCP port 13. 47 | -------------------------------------------------------------------------------- /xen/mini-os/app.lds: -------------------------------------------------------------------------------- 1 | SECTIONS 2 | { 3 | .app.bss : { 4 | __app_bss_start = . ; 5 | *(.bss .bss.*) 6 | *(COMMON) 7 | *(.lbss .lbss.*) 8 | *(LARGE_COMMON) 9 | __app_bss_end = . ; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Special makefile for ia64. 3 | # 4 | 5 | XEN_ROOT = $(CURDIR)/../../../.. 6 | include $(XEN_ROOT)/Config.mk 7 | 8 | include ../../Config.mk 9 | 10 | include arch.mk 11 | include ../../minios.mk 12 | 13 | ARCH_SRCS := sal.c 14 | ARCH_SRCS += efi.c 15 | ARCH_SRCS += time.c 16 | ARCH_SRCS += ivt.S 17 | ARCH_SRCS += fw.S 18 | ARCH_SRCS += common.c 19 | ARCH_SRCS += time.c 20 | ARCH_SRCS += mm.c 21 | ARCH_SRCS += debug.c 22 | ARCH_SRCS += sched.c 23 | ARCH_SRCS += xencomm.c 24 | ARCH_SRCS += __umoddi3.S 25 | ARCH_SRCS += __udivdi3.S 26 | ARCH_SRCS += __divdi3.S 27 | 28 | ARCH_OBJS := sal.o 29 | ARCH_OBJS += efi.o 30 | ARCH_OBJS += time.o 31 | ARCH_OBJS += ivt.o 32 | ARCH_OBJS += fw.o 33 | ARCH_OBJS += common.o 34 | ARCH_OBJS += time.o 35 | ARCH_OBJS += mm.o 36 | ARCH_OBJS += debug.o 37 | ARCH_OBJS += sched.o 38 | ARCH_OBJS += xencomm.o 39 | ARCH_OBJS += __umoddi3.o 40 | ARCH_OBJS += __udivdi3.o 41 | ARCH_OBJS += __udivsi3.o 42 | ARCH_OBJS += __divdi3.o 43 | ARCH_OBJS := $(addprefix $(OBJ_DIR)/,$(ARCH_OBJS)) 44 | 45 | GEN_OFF_SRC := gen_off.c 46 | GEN_OFF_ASM := gen_off.s 47 | GEN_OFF_H := $(MINI-OS_ROOT)/include/$(ARCH_INC)/offsets.h 48 | 49 | all: $(OBJ_DIR)/$(ARCH_LIB) 50 | 51 | $(GEN_OFF_ASM): $(GEN_OFF_SRC) 52 | $(CC) -S -o $@ $(CPPFLAGS) $< 53 | 54 | $(GEN_OFF_H): $(GEN_OFF_ASM) 55 | sed -ne "/^->/ {s/->/#define /; p}" < $< > $@ 56 | 57 | $(OBJ_DIR)/$(ARCH_LIB): $(GEN_OFF_H) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 58 | $(AR) rv $(ARCH_LIB) $(ARCH_OBJS) 59 | 60 | clean: 61 | rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 62 | rm -f $(GEN_OFF_ASM) 63 | rm -f $(GEN_OFF_H) 64 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/__divdi3.S: -------------------------------------------------------------------------------- 1 | .file "__divdi3.s" 2 | 3 | // $FreeBSD: src/sys/libkern/ia64/__divdi3.S,v 1.1 2000/10/04 17:53:03 dfr Exp $ 4 | // 5 | // Copyright (c) 2000, Intel Corporation 6 | // All rights reserved. 7 | // 8 | // Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache, 9 | // Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab, 10 | // Intel Corporation. 11 | // 12 | // WARRANTY DISCLAIMER 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 18 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING 23 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | // 26 | // Intel Corporation is the author of this code, and requests that all 27 | // problem reports or change requests be submitted to it directly at 28 | // http://developer.intel.com/opensource. 29 | // 30 | 31 | .section .text 32 | .proc __divdi3# 33 | .align 32 34 | .global __divdi3# 35 | .align 32 36 | 37 | // 64-bit signed integer divide 38 | 39 | __divdi3: 40 | 41 | { .mii 42 | alloc r31=ar.pfs,2,0,0,0 43 | nop.i 0 44 | nop.i 0;; 45 | } { .mmi 46 | 47 | // 64-BIT SIGNED INTEGER DIVIDE BEGINS HERE 48 | 49 | setf.sig f8=r32 50 | setf.sig f9=r33 51 | nop.i 0;; 52 | } { .mfb 53 | nop.m 0 54 | fcvt.xf f6=f8 55 | nop.b 0 56 | } { .mfb 57 | nop.m 0 58 | fcvt.xf f7=f9 59 | nop.b 0;; 60 | } { .mfi 61 | nop.m 0 62 | // Step (1) 63 | // y0 = 1 / b in f8 64 | frcpa.s1 f8,p6=f6,f7 65 | nop.i 0;; 66 | } { .mfi 67 | nop.m 0 68 | // Step (2) 69 | // e0 = 1 - b * y0 in f9 70 | (p6) fnma.s1 f9=f7,f8,f1 71 | nop.i 0 72 | } { .mfi 73 | nop.m 0 74 | // Step (3) 75 | // q0 = a * y0 in f10 76 | (p6) fma.s1 f10=f6,f8,f0 77 | nop.i 0;; 78 | } { .mfi 79 | nop.m 0 80 | // Step (4) 81 | // e1 = e0 * e0 in f11 82 | (p6) fma.s1 f11=f9,f9,f0 83 | nop.i 0 84 | } { .mfi 85 | nop.m 0 86 | // Step (5) 87 | // q1 = q0 + e0 * q0 in f10 88 | (p6) fma.s1 f10=f9,f10,f10 89 | nop.i 0;; 90 | } { .mfi 91 | nop.m 0 92 | // Step (6) 93 | // y1 = y0 + e0 * y0 in f8 94 | (p6) fma.s1 f8=f9,f8,f8 95 | nop.i 0;; 96 | } { .mfi 97 | nop.m 0 98 | // Step (7) 99 | // q2 = q1 + e1 * q1 in f9 100 | (p6) fma.s1 f9=f11,f10,f10 101 | nop.i 0;; 102 | } { .mfi 103 | nop.m 0 104 | // Step (8) 105 | // y2 = y1 + e1 * y1 in f8 106 | (p6) fma.s1 f8=f11,f8,f8 107 | nop.i 0;; 108 | } { .mfi 109 | nop.m 0 110 | // Step (9) 111 | // r2 = a - b * q2 in f10 112 | (p6) fnma.s1 f10=f7,f9,f6 113 | nop.i 0;; 114 | } { .mfi 115 | nop.m 0 116 | // Step (10) 117 | // q3 = q2 + r2 * y2 in f8 118 | (p6) fma.s1 f8=f10,f8,f9 119 | nop.i 0;; 120 | } { .mfb 121 | nop.m 0 122 | // Step (11) 123 | // q = trunc (q3) 124 | fcvt.fx.trunc.s1 f8=f8 125 | nop.b 0;; 126 | } { .mmi 127 | // quotient will be in r8 (if b != 0) 128 | getf.sig r8=f8 129 | nop.m 0 130 | nop.i 0;; 131 | } 132 | 133 | // 64-BIT SIGNED INTEGER DIVIDE ENDS HERE 134 | 135 | { .mmb 136 | nop.m 0 137 | nop.m 0 138 | br.ret.sptk b0;; 139 | } 140 | 141 | .endp __divdi3 142 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/__udivdi3.S: -------------------------------------------------------------------------------- 1 | .file "__udivdi3.s" 2 | 3 | // $FreeBSD: src/sys/libkern/ia64/__udivdi3.S,v 1.1 2000/10/04 17:53:03 dfr Exp $ 4 | // 5 | // Copyright (c) 2000, Intel Corporation 6 | // All rights reserved. 7 | // 8 | // Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache, 9 | // Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab, 10 | // Intel Corporation. 11 | // 12 | // WARRANTY DISCLAIMER 13 | // 14 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 18 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 20 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 21 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING 23 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | // 26 | // Intel Corporation is the author of this code, and requests that all 27 | // problem reports or change requests be submitted to it directly at 28 | // http://developer.intel.com/opensource. 29 | // 30 | 31 | .section .text 32 | .proc __udivdi3# 33 | .align 32 34 | .global __udivdi3# 35 | .align 32 36 | 37 | // 64-bit unsigned integer divide 38 | 39 | __udivdi3: 40 | 41 | { .mii 42 | alloc r31=ar.pfs,2,0,0,0 43 | nop.i 0 44 | nop.i 0;; 45 | } 46 | 47 | { .mmi 48 | 49 | // 64-BIT UNSIGNED INTEGER DIVIDE BEGINS HERE 50 | 51 | setf.sig f8=r32 52 | setf.sig f9=r33 53 | nop.i 0;; 54 | } { .mfb 55 | nop.m 0 56 | fma.s1 f6=f8,f1,f0 57 | nop.b 0 58 | } { .mfb 59 | nop.m 0 60 | fma.s1 f7=f9,f1,f0 61 | nop.b 0;; 62 | } { .mfi 63 | nop.m 0 64 | // Step (1) 65 | // y0 = 1 / b in f8 66 | frcpa.s1 f8,p6=f6,f7 67 | nop.i 0;; 68 | } { .mfi 69 | nop.m 0 70 | // Step (2) 71 | // e0 = 1 - b * y0 in f9 72 | (p6) fnma.s1 f9=f7,f8,f1 73 | nop.i 0 74 | } { .mfi 75 | nop.m 0 76 | // Step (3) 77 | // q0 = a * y0 in f10 78 | (p6) fma.s1 f10=f6,f8,f0 79 | nop.i 0;; 80 | } { .mfi 81 | nop.m 0 82 | // Step (4) 83 | // e1 = e0 * e0 in f11 84 | (p6) fma.s1 f11=f9,f9,f0 85 | nop.i 0 86 | } { .mfi 87 | nop.m 0 88 | // Step (5) 89 | // q1 = q0 + e0 * q0 in f10 90 | (p6) fma.s1 f10=f9,f10,f10 91 | nop.i 0;; 92 | } { .mfi 93 | nop.m 0 94 | // Step (6) 95 | // y1 = y0 + e0 * y0 in f8 96 | (p6) fma.s1 f8=f9,f8,f8 97 | nop.i 0;; 98 | } { .mfi 99 | nop.m 0 100 | // Step (7) 101 | // q2 = q1 + e1 * q1 in f9 102 | (p6) fma.s1 f9=f11,f10,f10 103 | nop.i 0;; 104 | } { .mfi 105 | nop.m 0 106 | // Step (8) 107 | // y2 = y1 + e1 * y1 in f8 108 | (p6) fma.s1 f8=f11,f8,f8 109 | nop.i 0;; 110 | } { .mfi 111 | nop.m 0 112 | // Step (9) 113 | // r2 = a - b * q2 in f10 114 | (p6) fnma.s1 f10=f7,f9,f6 115 | nop.i 0;; 116 | } { .mfi 117 | nop.m 0 118 | // Step (10) 119 | // q3 = q2 + r2 * y2 in f8 120 | (p6) fma.s1 f8=f10,f8,f9 121 | nop.i 0;; 122 | } { .mfb 123 | nop.m 0 124 | // (11) q = trunc(q3) 125 | fcvt.fxu.trunc.s1 f8=f8 126 | nop.b 0;; 127 | } { .mmi 128 | // quotient will be in r8 (if b != 0) 129 | getf.sig r8=f8 130 | nop.m 0 131 | nop.i 0;; 132 | } 133 | 134 | // 64-BIT UNSIGNED INTEGER DIVIDE ENDS HERE 135 | 136 | { .mmb 137 | nop.m 0 138 | nop.m 0 139 | br.ret.sptk b0;; 140 | } 141 | 142 | .endp __udivdi3 143 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/__udivsi3.S: -------------------------------------------------------------------------------- 1 | .file "__udivsi3.s" 2 | 3 | // $FreeBSD: src/sys/libkern/ia64/__udivsi3.S,v 1.1.8.1 2005/01/31 23:26:21 imp Exp $ 4 | 5 | //- 6 | // Copyright (c) 2000, Intel Corporation 7 | // All rights reserved. 8 | // 9 | // Contributed 2/15/2000 by Marius Cornea, John Harrison, Cristina Iordache, 10 | // Ted Kubaska, Bob Norin, and Shane Story of the Computational Software Lab, 11 | // Intel Corporation. 12 | // 13 | // WARRANTY DISCLAIMER 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS 19 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 | // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING 24 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | // Intel Corporation is the author of this code, and requests that all 28 | // problem reports or change requests be submitted to it directly at 29 | // http://developer.intel.com/opensource. 30 | // 31 | 32 | .section .text 33 | 34 | // 32-bit unsigned integer divide 35 | 36 | .proc __udivsi3# 37 | .align 32 38 | .global __udivsi3# 39 | .align 32 40 | 41 | __udivsi3: 42 | 43 | { .mii 44 | alloc r31=ar.pfs,2,0,0,0 45 | nop.i 0 46 | nop.i 0;; 47 | } { .mii 48 | nop.m 0 49 | 50 | // 32-BIT UNSIGNED INTEGER DIVIDE BEGINS HERE 51 | 52 | // general register used: 53 | // r32 - 32-bit unsigned integer dividend 54 | // r33 - 32-bit unsigned integer divisor 55 | // r8 - 32-bit unsigned integer result 56 | // r2 - scratch register 57 | // floating-point registers used: f6, f7, f8, f9 58 | // predicate registers used: p6 59 | 60 | zxt4 r32=r32 61 | zxt4 r33=r33;; 62 | } { .mmb 63 | setf.sig f6=r32 64 | setf.sig f7=r33 65 | nop.b 0;; 66 | } { .mfi 67 | nop.m 0 68 | fcvt.xf f6=f6 69 | nop.i 0 70 | } { .mfi 71 | nop.m 0 72 | fcvt.xf f7=f7 73 | mov r2 = 0x0ffdd;; 74 | } { .mfi 75 | setf.exp f9 = r2 76 | // (1) y0 77 | frcpa.s1 f8,p6=f6,f7 78 | nop.i 0;; 79 | } { .mfi 80 | nop.m 0 81 | // (2) q0 = a * y0 82 | (p6) fma.s1 f6=f6,f8,f0 83 | nop.i 0 84 | } { .mfi 85 | nop.m 0 86 | // (3) e0 = 1 - b * y0 87 | (p6) fnma.s1 f7=f7,f8,f1 88 | nop.i 0;; 89 | } { .mfi 90 | nop.m 0 91 | // (4) q1 = q0 + e0 * q0 92 | (p6) fma.s1 f6=f7,f6,f6 93 | nop.i 0 94 | } { .mfi 95 | nop.m 0 96 | // (5) e1 = e0 * e0 + 2^-34 97 | (p6) fma.s1 f7=f7,f7,f9 98 | nop.i 0;; 99 | } { .mfi 100 | nop.m 0 101 | // (6) q2 = q1 + e1 * q1 102 | (p6) fma.s1 f8=f7,f6,f6 103 | nop.i 0;; 104 | } { .mfi 105 | nop.m 0 106 | // (7) q = trunc(q2) 107 | fcvt.fxu.trunc.s1 f8=f8 108 | nop.i 0;; 109 | } { .mmi 110 | // quotient will be in the least significant 32 bits of r8 (if b != 0) 111 | getf.sig r8=f8 112 | nop.m 0 113 | nop.i 0;; 114 | } 115 | 116 | // 32-BIT UNSIGNED INTEGER DIVIDE ENDS HERE 117 | 118 | { .mmb 119 | nop.m 0 120 | nop.m 0 121 | br.ret.sptk b0;; 122 | } 123 | 124 | .endp __udivsi3 125 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/arch.mk: -------------------------------------------------------------------------------- 1 | 2 | ARCH_CFLAGS := -mfixed-range=f2-f5,f12-f15,f32-f127 -mconstant-gp 3 | ARCH_CFLAGS += -O2 4 | ARCH_ASFLAGS := -x assembler-with-cpp 5 | ARCH_ASFLAGS += -mfixed-range=f2-f5,f12-f15,f32-f127 -fomit-frame-pointer 6 | ARCH_ASFLAGS += -fno-builtin -fno-common -fno-strict-aliasing -mconstant-gp 7 | 8 | ARCH_LDFLAGS = -warn-common 9 | 10 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/minios-ia64.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-ia64-little") 2 | OUTPUT_ARCH(ia64) 3 | 4 | ENTRY(phys_start) 5 | 6 | PHDRS 7 | { 8 | code PT_LOAD; 9 | data PT_LOAD; 10 | } 11 | 12 | SECTIONS 13 | { 14 | 15 | phys_start = _start - (((5<<(61))+0x100000000) - (1 << 20)); 16 | 17 | code : { } :code 18 | . = ((5<<(61))+0x100000000); 19 | 20 | _text = .; 21 | 22 | .text : AT(ADDR(.text) - (((5<<(61))+0x100000000) - (1 << 20))) 23 | { 24 | *(.text) 25 | } 26 | 27 | _etext = .; 28 | 29 | data : { } :data 30 | .data : AT(ADDR(.data) - (((5<<(61))+0x100000000) - (1 << 20))) 31 | { *(.data) 32 | } 33 | 34 | .sdata : AT(ADDR(.sdata) - (((5<<(61))+0x100000000) - (1 << 20))) 35 | { *(.sdata) *(.sdata1) *(.srdata) } 36 | 37 | .rodata : AT(ADDR(.rodata) - (((5<<(61))+0x100000000) - (1 << 20))) 38 | { *(.rodata) } 39 | 40 | .rodata.str1.8 : AT(ADDR(.rodata.str1.8) - (((5<<(61))+0x100000000) - (1 << 20))) 41 | { *(.rodata.str1.8) } 42 | 43 | /* newlib initialization functions */ 44 | . = ALIGN(64 / 8); 45 | PROVIDE (__preinit_array_start = .); 46 | .preinit_array : { *(.preinit_array) } 47 | PROVIDE (__preinit_array_end = .); 48 | PROVIDE (__init_array_start = .); 49 | .init_array : { *(.init_array) } 50 | PROVIDE (__init_array_end = .); 51 | PROVIDE (__fini_array_start = .); 52 | .fini_array : { *(.fini_array) } 53 | PROVIDE (__fini_array_end = .); 54 | 55 | .ctors : AT(ADDR(.ctors) - (((5<<(61))+0x100000000) - (1 << 20))) 56 | { 57 | __CTOR_LIST__ = .; 58 | QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) 59 | *(.ctors) 60 | CONSTRUCTORS 61 | QUAD(0) 62 | __CTOR_END__ = .; 63 | } 64 | 65 | .dtors : AT(ADDR(.dtors) - (((5<<(61))+0x100000000) - (1 << 20))) 66 | { 67 | __DTOR_LIST__ = .; 68 | QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2) 69 | *(.dtors) 70 | QUAD(0) 71 | __DTOR_END__ = .; 72 | } 73 | 74 | .IA_64.unwind_info : AT(ADDR(.IA_64.unwind_info) - (((5<<(61))+0x100000000) - (1 << 20))) 75 | { *(.IA_64.unwind_info) } 76 | 77 | .IA_64.unwind : AT(ADDR(.IA_64.unwind) - (((5<<(61))+0x100000000) - (1 << 20))) 78 | { *(.IA_64.unwind) } 79 | 80 | .bss : AT(ADDR(.bss) - (((5<<(61))+0x100000000) - (1 << 20))) 81 | { 82 | *(.bss) 83 | *(.app.bss) 84 | } 85 | 86 | _end = .; 87 | 88 | } 89 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/sal.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com> 3 | * Mostly taken from FreeBSD. 4 | * 5 | **************************************************************************** 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #include <mini-os/os.h> 31 | #include <mini-os/lib.h> 32 | #include <mini-os/console.h> 33 | #include <mini-os/page.h> 34 | 35 | 36 | static struct ia64_fdesc sal_fdesc; 37 | uint64_t ia64_pal_entry; /* PAL_PROC entrypoint */ 38 | 39 | 40 | struct ia64_sal_result 41 | ia64_sal_call(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, 42 | uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8) 43 | { 44 | return ia64_sal_entry(a1, a2, a3, a4, a5, a6, a7, a8); 45 | } 46 | 47 | static struct ia64_sal_result 48 | fake_sal(uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, 49 | uint64_t a5, uint64_t a6, uint64_t a7, uint64_t a8) 50 | { 51 | struct ia64_sal_result res; 52 | res.sal_status = -3; 53 | res.sal_result[0] = 0; 54 | res.sal_result[1] = 0; 55 | res.sal_result[2] = 0; 56 | return res; 57 | } 58 | 59 | /* 60 | * Currently only the SAL_DESC_ENTRYPOINT is checked to get 61 | * the entry points the pal and sal functions. 62 | */ 63 | void 64 | ia64_sal_init(struct sal_system_table *saltab) 65 | { 66 | static int sizes[6] = { 48, 32, 16, 32, 16, 16 }; 67 | uint8_t *p; 68 | int i; 69 | 70 | PRINT_BV("Reading SALtable:\n"); 71 | ia64_sal_entry = fake_sal; 72 | 73 | if (memcmp((void*)(uint64_t)(saltab->sal_signature), SAL_SIGNATURE, 4)) 74 | { 75 | printk("Bad signature for SAL System Table\n"); 76 | return; 77 | } 78 | p = (uint8_t *) (saltab + 1); 79 | for (i = 0; i < saltab->sal_entry_count; i++) { 80 | switch (*p) { 81 | case SAL_DESC_ENTRYPOINT: // 0 82 | { 83 | struct sal_entrypoint_descriptor *dp; 84 | 85 | dp = (struct sal_entrypoint_descriptor*)p; 86 | ia64_pal_entry = 87 | IA64_PHYS_TO_RR7(dp->sale_pal_proc); 88 | PRINT_BV(" PAL Proc at 0x%lx\n", ia64_pal_entry); 89 | sal_fdesc.func = 90 | IA64_PHYS_TO_RR7(dp->sale_sal_proc); 91 | sal_fdesc.gp = IA64_PHYS_TO_RR7(dp->sale_sal_gp); 92 | PRINT_BV(" SAL Proc at 0x%lx, GP at 0x%lx\n", 93 | sal_fdesc.func, sal_fdesc.gp); 94 | ia64_sal_entry = (sal_entry_t *) &sal_fdesc; 95 | break; 96 | } 97 | default: 98 | break; 99 | } 100 | p += sizes[*p]; 101 | } 102 | } 103 | 104 | -------------------------------------------------------------------------------- /xen/mini-os/arch/ia64/sched.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com 3 | * 4 | * Description: ia64 specific part of the scheduler for mini-os 5 | * 6 | **************************************************************************** 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to 10 | * deal in the Software without restriction, including without limitation the 11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | * sell copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | * DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | 28 | #include <mini-os/types.h> 29 | #include <mini-os/sched.h> 30 | #include <mini-os/lib.h> 31 | #include <mini-os/xmalloc.h> 32 | #include <mini-os/mm.h> 33 | 34 | /* The function is implemented in fw.S */ 35 | extern void thread_starter(void); 36 | 37 | void stack_walk(void) 38 | { 39 | /* TODO */ 40 | } 41 | 42 | struct thread* 43 | arch_create_thread(char *name, void (*function)(void *), void *data) 44 | { 45 | struct thread* _thread; 46 | 47 | _thread = (struct thread*)_xmalloc(sizeof(struct thread), 16); 48 | /* Allocate pages for stack, stack will be aligned */ 49 | _thread->stack = (char *)alloc_pages(STACK_SIZE_PAGE_ORDER); 50 | _thread->name = name; 51 | memset((void*)&(_thread->regs), 0, sizeof(_thread->regs)); 52 | _thread->regs.sp = ((uint64_t)_thread->stack) + STACK_SIZE - 16; 53 | _thread->regs.bsp = ((uint64_t)_thread->stack) + 0x10; 54 | _thread->regs.rp = FDESC_FUNC(thread_starter); 55 | _thread->regs.pfs = 0x82; 56 | _thread->regs.r4 = FDESC_FUNC(function); 57 | _thread->regs.r6 = (uint64_t)data; 58 | return _thread; 59 | } 60 | 61 | extern void restore_context(struct thread*); 62 | extern int switch_context(struct thread*, struct thread*); 63 | 64 | void 65 | arch_switch_threads(struct thread* prev, struct thread* next) 66 | { 67 | ia64_set_r13((uint64_t)next); 68 | switch_context(prev, next); 69 | } 70 | 71 | /* Everything initialised, start idle thread */ 72 | void 73 | run_idle_thread(void) 74 | { 75 | //do_busy_loop(); 76 | ia64_set_r13((uint64_t)idle_thread); 77 | restore_context(idle_thread); 78 | printk("%s: restore_context() returned - bad!\n", __func__); 79 | } 80 | -------------------------------------------------------------------------------- /xen/mini-os/arch/x86/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # x86 architecture specific makefiles. 3 | # It's is used for x86_32, x86_32y and x86_64 4 | # 5 | 6 | XEN_ROOT ?= /local/scratch/sos22/xen-4.1.2 7 | include $(XEN_ROOT)/Config.mk 8 | include ../../Config.mk 9 | 10 | # include arch.mk has to be before mini-os.mk! 11 | 12 | include arch.mk 13 | include ../../minios.mk 14 | 15 | # Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S 16 | # This is handled in $(HEAD_ARCH_OBJ) 17 | ARCH_SRCS := $(wildcard *.c) 18 | 19 | # The objects built from the sources. 20 | ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS)) 21 | 22 | all: $(OBJ_DIR)/$(ARCH_LIB) 23 | 24 | # $(HEAD_ARCH_OBJ) is only build here, needed on linking 25 | # in ../../Makefile. 26 | $(OBJ_DIR)/$(ARCH_LIB): $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 27 | $(AR) rv $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) 28 | 29 | clean: 30 | rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 31 | 32 | -------------------------------------------------------------------------------- /xen/mini-os/arch/x86/Makefile~: -------------------------------------------------------------------------------- 1 | # 2 | # x86 architecture specific makefiles. 3 | # It's is used for x86_32, x86_32y and x86_64 4 | # 5 | 6 | XEN_ROOT = $(CURDIR)/../../../.. 7 | include $(XEN_ROOT)/Config.mk 8 | include ../../Config.mk 9 | 10 | # include arch.mk has to be before mini-os.mk! 11 | 12 | include arch.mk 13 | include ../../minios.mk 14 | 15 | # Sources here are all *.c *.S without $(XEN_TARGET_ARCH).S 16 | # This is handled in $(HEAD_ARCH_OBJ) 17 | ARCH_SRCS := $(wildcard *.c) 18 | 19 | # The objects built from the sources. 20 | ARCH_OBJS := $(patsubst %.c,$(OBJ_DIR)/%.o,$(ARCH_SRCS)) 21 | 22 | all: $(OBJ_DIR)/$(ARCH_LIB) 23 | 24 | # $(HEAD_ARCH_OBJ) is only build here, needed on linking 25 | # in ../../Makefile. 26 | $(OBJ_DIR)/$(ARCH_LIB): $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 27 | $(AR) rv $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) 28 | 29 | clean: 30 | rm -f $(OBJ_DIR)/$(ARCH_LIB) $(ARCH_OBJS) $(OBJ_DIR)/$(HEAD_ARCH_OBJ) 31 | 32 | -------------------------------------------------------------------------------- /xen/mini-os/arch/x86/arch.mk: -------------------------------------------------------------------------------- 1 | # 2 | # Architecture special makerules for x86 family 3 | # (including x86_32, x86_32y and x86_64). 4 | # 5 | 6 | ifeq ($(XEN_TARGET_ARCH),x86_32) 7 | ARCH_CFLAGS := -m32 -march=i686 8 | ARCH_LDFLAGS := -m elf_i386 9 | ARCH_ASFLAGS := -m32 10 | EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH) 11 | EXTRA_SRC += arch/$(EXTRA_INC) 12 | endif 13 | 14 | ifeq ($(XEN_TARGET_ARCH),x86_64) 15 | ARCH_CFLAGS := -m64 -mno-red-zone -fno-reorder-blocks 16 | ARCH_CFLAGS += -fno-asynchronous-unwind-tables 17 | ARCH_ASFLAGS := -m64 18 | ARCH_LDFLAGS := -m elf_x86_64 19 | EXTRA_INC += $(TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH) 20 | EXTRA_SRC += arch/$(EXTRA_INC) 21 | endif 22 | 23 | -------------------------------------------------------------------------------- /xen/mini-os/arch/x86/ioremap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009, Netronome Systems, Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | 24 | #include <mini-os/types.h> 25 | #include <mini-os/lib.h> 26 | #include <mini-os/xmalloc.h> 27 | #include <mini-os/mm.h> 28 | #include <mini-os/ioremap.h> 29 | 30 | /* Map a physical address range into virtual address space with provided 31 | * flags. Return a virtual address range it is mapped to. */ 32 | static void *__do_ioremap(unsigned long phys_addr, unsigned long size, 33 | unsigned long prot) 34 | { 35 | unsigned long va; 36 | unsigned long mfns, mfn; 37 | unsigned long num_pages, offset; 38 | int i; 39 | 40 | /* allow non page aligned addresses but for mapping we need to align them */ 41 | offset = (phys_addr & ~PAGE_MASK); 42 | num_pages = (offset + size + PAGE_SIZE - 1) / PAGE_SIZE; 43 | phys_addr &= PAGE_MASK; 44 | mfns = mfn = phys_addr >> PAGE_SHIFT; 45 | 46 | /* sanity checks on list of MFNs */ 47 | for ( i = 0; i < num_pages; i++, mfn++ ) 48 | { 49 | if ( mfn_is_ram(mfn) ) 50 | { 51 | printk("ioremap: mfn 0x%ulx is RAM\n", mfn); 52 | goto mfn_invalid; 53 | } 54 | } 55 | va = (unsigned long)map_frames_ex(&mfns, num_pages, 0, 1, 1, 56 | DOMID_IO, NULL, prot); 57 | return (void *)(va + offset); 58 | 59 | mfn_invalid: 60 | return NULL; 61 | } 62 | 63 | void *ioremap(unsigned long phys_addr, unsigned long size) 64 | { 65 | return __do_ioremap(phys_addr, size, IO_PROT); 66 | } 67 | 68 | void *ioremap_nocache(unsigned long phys_addr, unsigned long size) 69 | { 70 | return __do_ioremap(phys_addr, size, IO_PROT_NOCACHE); 71 | } 72 | 73 | /* Un-map the io-remapped region. Currently no list of existing mappings is 74 | * maintained, so the caller has to supply the size */ 75 | void iounmap(void *virt_addr, unsigned long size) 76 | { 77 | unsigned long num_pages; 78 | unsigned long va = (unsigned long)virt_addr; 79 | 80 | /* work out number of frames to unmap */ 81 | num_pages = ((va & ~PAGE_MASK) + size + PAGE_SIZE - 1) / PAGE_SIZE; 82 | 83 | unmap_frames(va & PAGE_MASK, num_pages); 84 | } 85 | 86 | 87 | 88 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 indent-tabs-mode:nil -*- */ 89 | -------------------------------------------------------------------------------- /xen/mini-os/arch/x86/minios-x86_32.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") 2 | OUTPUT_ARCH(i386) 3 | ENTRY(_start) 4 | SECTIONS 5 | { 6 | . = 0x0; 7 | _text = .; /* Text and read-only data */ 8 | .text : { 9 | *(.text) 10 | *(.gnu.warning) 11 | } = 0x9090 12 | 13 | _etext = .; /* End of text section */ 14 | 15 | .rodata : { *(.rodata) *(.rodata.*) } 16 | . = ALIGN(4096); 17 | _erodata = .; 18 | 19 | /* newlib initialization functions */ 20 | . = ALIGN(32 / 8); 21 | PROVIDE (__preinit_array_start = .); 22 | .preinit_array : { *(.preinit_array) } 23 | PROVIDE (__preinit_array_end = .); 24 | PROVIDE (__init_array_start = .); 25 | .init_array : { *(.init_array) } 26 | PROVIDE (__init_array_end = .); 27 | PROVIDE (__fini_array_start = .); 28 | .fini_array : { *(.fini_array) } 29 | PROVIDE (__fini_array_end = .); 30 | 31 | .ctors : { 32 | __CTOR_LIST__ = .; 33 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 34 | *(.ctors) 35 | CONSTRUCTORS 36 | LONG(0) 37 | __CTOR_END__ = .; 38 | } 39 | 40 | .dtors : { 41 | __DTOR_LIST__ = .; 42 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 43 | *(.dtors) 44 | LONG(0) 45 | __DTOR_END__ = .; 46 | } 47 | 48 | .data : { /* Data */ 49 | *(.data) 50 | } 51 | 52 | _edata = .; /* End of data section */ 53 | 54 | __bss_start = .; /* BSS */ 55 | .bss : { 56 | *(.bss) 57 | *(.app.bss) 58 | } 59 | _end = . ; 60 | 61 | /* Sections to be discarded */ 62 | /DISCARD/ : { 63 | *(.text.exit) 64 | *(.data.exit) 65 | *(.exitcall.exit) 66 | } 67 | 68 | /* Stabs debugging sections. */ 69 | .stab 0 : { *(.stab) } 70 | .stabstr 0 : { *(.stabstr) } 71 | .stab.excl 0 : { *(.stab.excl) } 72 | .stab.exclstr 0 : { *(.stab.exclstr) } 73 | .stab.index 0 : { *(.stab.index) } 74 | .stab.indexstr 0 : { *(.stab.indexstr) } 75 | .comment 0 : { *(.comment) } 76 | } 77 | -------------------------------------------------------------------------------- /xen/mini-os/arch/x86/minios-x86_64.lds: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 2 | OUTPUT_ARCH(i386:x86-64) 3 | ENTRY(_start) 4 | SECTIONS 5 | { 6 | . = 0x0; 7 | _text = .; /* Text and read-only data */ 8 | .text : { 9 | *(.text) 10 | *(.gnu.warning) 11 | } = 0x9090 12 | 13 | _etext = .; /* End of text section */ 14 | 15 | .rodata : { *(.rodata) *(.rodata.*) } 16 | . = ALIGN(4096); 17 | _erodata = .; 18 | 19 | /* newlib initialization functions */ 20 | . = ALIGN(64 / 8); 21 | PROVIDE (__preinit_array_start = .); 22 | .preinit_array : { *(.preinit_array) } 23 | PROVIDE (__preinit_array_end = .); 24 | PROVIDE (__init_array_start = .); 25 | .init_array : { *(.init_array) } 26 | PROVIDE (__init_array_end = .); 27 | PROVIDE (__fini_array_start = .); 28 | .fini_array : { *(.fini_array) } 29 | PROVIDE (__fini_array_end = .); 30 | 31 | .ctors : { 32 | __CTOR_LIST__ = .; 33 | QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) 34 | *(.ctors) 35 | CONSTRUCTORS 36 | QUAD(0) 37 | __CTOR_END__ = .; 38 | } 39 | 40 | .dtors : { 41 | __DTOR_LIST__ = .; 42 | QUAD((__DTOR_END__ - __DTOR_LIST__) / 8 - 2) 43 | *(.dtors) 44 | QUAD(0) 45 | __DTOR_END__ = .; 46 | } 47 | 48 | .data : { /* Data */ 49 | *(.data) 50 | } 51 | 52 | _edata = .; /* End of data section */ 53 | 54 | __bss_start = .; /* BSS */ 55 | .bss : { 56 | *(.bss) 57 | *(.app.bss) 58 | } 59 | _end = . ; 60 | 61 | /* Sections to be discarded */ 62 | /DISCARD/ : { 63 | *(.text.exit) 64 | *(.data.exit) 65 | *(.exitcall.exit) 66 | } 67 | 68 | /* Stabs debugging sections. */ 69 | .stab 0 : { *(.stab) } 70 | .stabstr 0 : { *(.stabstr) } 71 | .stab.excl 0 : { *(.stab.excl) } 72 | .stab.exclstr 0 : { *(.stab.exclstr) } 73 | .stab.index 0 : { *(.stab.index) } 74 | .stab.indexstr 0 : { *(.stab.indexstr) } 75 | .comment 0 : { *(.comment) } 76 | } 77 | -------------------------------------------------------------------------------- /xen/mini-os/arch/x86/setup.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * common.c 3 | * 4 | * Common stuff special to x86 goes here. 5 | * 6 | * Copyright (c) 2002-2003, K A Fraser & R Neugebauer 7 | * Copyright (c) 2005, Grzegorz Milos, Intel Research Cambridge 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to 11 | * deal in the Software without restriction, including without limitation the 12 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 13 | * sell copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | * DEALINGS IN THE SOFTWARE. 26 | * 27 | */ 28 | 29 | #include <mini-os/os.h> 30 | #include <mini-os/lib.h> /* for printk, memcpy */ 31 | 32 | /* 33 | * Shared page for communicating with the hypervisor. 34 | * Events flags go here, for example. 35 | */ 36 | shared_info_t *HYPERVISOR_shared_info; 37 | 38 | /* 39 | * This structure contains start-of-day info, such as pagetable base pointer, 40 | * address of the shared_info structure, and things like that. 41 | */ 42 | union start_info_union start_info_union; 43 | 44 | /* 45 | * Just allocate the kernel stack here. SS:ESP is set up to point here 46 | * in head.S. 47 | */ 48 | char stack[2*STACK_SIZE]; 49 | 50 | extern char shared_info[PAGE_SIZE]; 51 | 52 | /* Assembler interface fns in entry.S. */ 53 | void hypervisor_callback(void); 54 | void failsafe_callback(void); 55 | 56 | #if defined(__x86_64__) 57 | #define __pte(x) ((pte_t) { (x) } ) 58 | #else 59 | #define __pte(x) ({ unsigned long long _x = (x); \ 60 | ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); }) 61 | #endif 62 | 63 | static 64 | shared_info_t *map_shared_info(unsigned long pa) 65 | { 66 | int rc; 67 | 68 | if ( (rc = HYPERVISOR_update_va_mapping( 69 | (unsigned long)shared_info, __pte(pa | 7), UVMF_INVLPG)) ) 70 | { 71 | printk("Failed to map shared_info!! rc=%d\n", rc); 72 | do_exit(); 73 | } 74 | return (shared_info_t *)shared_info; 75 | } 76 | 77 | void 78 | arch_init(start_info_t *si) 79 | { 80 | /* Copy the start_info struct to a globally-accessible area. */ 81 | /* WARN: don't do printk before here, it uses information from 82 | shared_info. Use xprintk instead. */ 83 | memcpy(&start_info, si, sizeof(*si)); 84 | 85 | /* set up minimal memory infos */ 86 | phys_to_machine_mapping = (unsigned long *)start_info.mfn_list; 87 | 88 | /* Grab the shared_info pointer and put it in a safe place. */ 89 | HYPERVISOR_shared_info = map_shared_info(start_info.shared_info); 90 | 91 | /* Set up event and failsafe callback addresses. */ 92 | #ifdef __i386__ 93 | HYPERVISOR_set_callbacks( 94 | __KERNEL_CS, (unsigned long)hypervisor_callback, 95 | __KERNEL_CS, (unsigned long)failsafe_callback); 96 | #else 97 | HYPERVISOR_set_callbacks( 98 | (unsigned long)hypervisor_callback, 99 | (unsigned long)failsafe_callback, 0); 100 | #endif 101 | 102 | } 103 | 104 | void 105 | arch_fini(void) 106 | { 107 | #ifdef __i386__ 108 | HYPERVISOR_set_callbacks(0, 0, 0, 0); 109 | #else 110 | HYPERVISOR_set_callbacks(0, 0, 0); 111 | #endif 112 | } 113 | 114 | void 115 | arch_print_info(void) 116 | { 117 | printk(" stack: %p-%p\n", stack, stack + sizeof(stack)); 118 | } 119 | 120 | 121 | -------------------------------------------------------------------------------- /xen/mini-os/daytime.c: -------------------------------------------------------------------------------- 1 | /* 2 | * daytime.c: a simple network service based on lwIP and mini-os 3 | * 4 | * Tim Deegan <Tim.Deegan@eu.citrix.net>, July 2007 5 | */ 6 | 7 | #include <os.h> 8 | #include <xmalloc.h> 9 | #include <console.h> 10 | #include <netfront.h> 11 | #include <lwip/api.h> 12 | 13 | static char message[29]; 14 | 15 | void run_server(void *p) 16 | { 17 | struct ip_addr listenaddr = { 0 }; 18 | struct netconn *listener; 19 | struct netconn *session; 20 | struct timeval tv; 21 | err_t rc; 22 | 23 | start_networking(); 24 | 25 | if (0) { 26 | struct ip_addr ipaddr = { htonl(0x0a000001) }; 27 | struct ip_addr netmask = { htonl(0xff000000) }; 28 | struct ip_addr gw = { 0 }; 29 | networking_set_addr(&ipaddr, &netmask, &gw); 30 | } 31 | 32 | tprintk("Opening connection\n"); 33 | 34 | listener = netconn_new(NETCONN_TCP); 35 | tprintk("Connection at %p\n", listener); 36 | 37 | rc = netconn_bind(listener, &listenaddr, 13); 38 | if (rc != ERR_OK) { 39 | tprintk("Failed to bind connection: %i\n", rc); 40 | return; 41 | } 42 | 43 | rc = netconn_listen(listener); 44 | if (rc != ERR_OK) { 45 | tprintk("Failed to listen on connection: %i\n", rc); 46 | return; 47 | } 48 | 49 | while (1) { 50 | session = netconn_accept(listener); 51 | if (session == NULL) 52 | continue; 53 | 54 | gettimeofday(&tv, NULL); 55 | sprintf(message, "%20lu.%6.6lu\n", tv.tv_sec, tv.tv_usec); 56 | (void) netconn_write(session, message, strlen(message), NETCONN_COPY); 57 | (void) netconn_disconnect(session); 58 | (void) netconn_delete(session); 59 | } 60 | } 61 | 62 | 63 | int app_main(start_info_t *si) 64 | { 65 | create_thread("server", run_server, NULL); 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /xen/mini-os/domain_config: -------------------------------------------------------------------------------- 1 | # -*- mode: python; -*- 2 | #============================================================================ 3 | # Python configuration setup for 'xm create'. 4 | # This script sets the parameters used when a domain is created using 'xm create'. 5 | # You use a separate script for each domain you want to create, or 6 | # you can set the parameters for the domain on the xm command line. 7 | #============================================================================ 8 | 9 | #---------------------------------------------------------------------------- 10 | # Kernel image file. 11 | kernel = "mini-os.gz" 12 | 13 | # Initial memory allocation (in megabytes) for the new domain. 14 | memory = 32 15 | 16 | # A name for your domain. All domains must have different names. 17 | name = "Mini-OS" 18 | 19 | on_crash = 'destroy' 20 | -------------------------------------------------------------------------------- /xen/mini-os/include/arch/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwip/arch/cc.h 3 | * 4 | * Compiler-specific types and macros for lwIP running on mini-os 5 | * 6 | * Tim Deegan <Tim.Deegan@eu.citrix.net>, July 2007 7 | */ 8 | 9 | #ifndef __LWIP_ARCH_CC_H__ 10 | #define __LWIP_ARCH_CC_H__ 11 | 12 | /* Typedefs for the types used by lwip - */ 13 | #include <mini-os/os.h> 14 | #include <mini-os/types.h> 15 | #include <time.h> 16 | typedef uint8_t u8_t; 17 | typedef int8_t s8_t; 18 | typedef uint16_t u16_t; 19 | typedef int16_t s16_t; 20 | typedef uint32_t u32_t; 21 | typedef int32_t s32_t; 22 | typedef uint64_t u64_t; 23 | typedef int64_t s64_t; 24 | typedef uintptr_t mem_ptr_t; 25 | 26 | typedef uint16_t u_short; 27 | 28 | /* Compiler hints for packing lwip's structures - */ 29 | #define PACK_STRUCT_FIELD(_x) _x 30 | #define PACK_STRUCT_STRUCT __attribute__ ((packed)) 31 | #define PACK_STRUCT_BEGIN 32 | #define PACK_STRUCT_END 33 | 34 | /* Platform specific diagnostic output - */ 35 | 36 | extern void lwip_printk(char *fmt, ...); 37 | #define LWIP_PLATFORM_DIAG(_x) do { lwip_printk _x ; } while (0) 38 | 39 | extern void lwip_die(char *fmt, ...); 40 | #define LWIP_PLATFORM_ASSERT(_x) do { lwip_die(_x); } while(0) 41 | 42 | /* "lightweight" synchronization mechanisms - */ 43 | /* SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable. */ 44 | /* SYS_ARCH_PROTECT(x) - enter protection mode. */ 45 | /* SYS_ARCH_UNPROTECT(x) - leave protection mode. */ 46 | 47 | /* If the compiler does not provide memset() this file must include a */ 48 | /* definition of it, or include a file which defines it. */ 49 | #include <mini-os/lib.h> 50 | 51 | /* This file must either include a system-local <errno.h> which defines */ 52 | /* the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO */ 53 | /* to make lwip/arch.h define the codes which are used throughout. */ 54 | #include <errno.h> 55 | 56 | /* Not required by the docs, but needed for network-order calculations */ 57 | #ifdef HAVE_LIBC 58 | #include <machine/endian.h> 59 | #ifndef BIG_ENDIAN 60 | #error endian.h does not define byte order 61 | #endif 62 | #else 63 | #include <endian.h> 64 | #endif 65 | 66 | #include <inttypes.h> 67 | #define S16_F PRIi16 68 | #define U16_F PRIu16 69 | #define X16_F PRIx16 70 | #define S32_F PRIi32 71 | #define U32_F PRIu32 72 | #define X32_F PRIx32 73 | 74 | #if 0 75 | #ifndef DBG_ON 76 | #define DBG_ON LWIP_DBG_ON 77 | #endif 78 | #define LWIP_DEBUG DBG_ON 79 | //#define IP_DEBUG DBG_ON 80 | #define TCP_DEBUG DBG_ON 81 | #define TCP_INPUT_DEBUG DBG_ON 82 | #define TCP_QLEN_DEBUG DBG_ON 83 | #define TCPIP_DEBUG DBG_ON 84 | #define DBG_TYPES_ON DBG_ON 85 | #endif 86 | 87 | #endif /* __LWIP_ARCH_CC_H__ */ 88 | -------------------------------------------------------------------------------- /xen/mini-os/include/arch/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwip/arch/perf.h 3 | * 4 | * Arch-specific performance measurement for lwIP running on mini-os 5 | * 6 | * Tim Deegan <Tim.Deegan@eu.citrix.net>, July 2007 7 | */ 8 | 9 | #ifndef __LWIP_ARCH_PERF_H__ 10 | #define __LWIP_ARCH_PERF_H__ 11 | 12 | #define PERF_START do { } while(0) 13 | #define PERF_STOP(_x) do { (void)(_x); } while (0) 14 | 15 | #endif /* __LWIP_ARCH_PERF_H__ */ 16 | -------------------------------------------------------------------------------- /xen/mini-os/include/arch/sys_arch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwip/arch/sys_arch.h 3 | * 4 | * Arch-specific semaphores and mailboxes for lwIP running on mini-os 5 | * 6 | * Tim Deegan <Tim.Deegan@eu.citrix.net>, July 2007 7 | */ 8 | 9 | #ifndef __LWIP_ARCH_SYS_ARCH_H__ 10 | #define __LWIP_ARCH_SYS_ARCH_H__ 11 | 12 | #include <mini-os/os.h> 13 | #include <mini-os/xmalloc.h> 14 | #include <mini-os/semaphore.h> 15 | 16 | typedef struct semaphore *sys_sem_t; 17 | #define SYS_SEM_NULL ((sys_sem_t) NULL) 18 | 19 | struct mbox { 20 | int count; 21 | void **messages; 22 | struct semaphore read_sem; 23 | struct semaphore write_sem; 24 | int writer; 25 | int reader; 26 | }; 27 | 28 | typedef struct mbox *sys_mbox_t; 29 | #define SYS_MBOX_NULL ((sys_mbox_t) 0) 30 | 31 | typedef struct thread *sys_thread_t; 32 | 33 | typedef unsigned long sys_prot_t; 34 | 35 | #endif /*__LWIP_ARCH_SYS_ARCH_H__ */ 36 | -------------------------------------------------------------------------------- /xen/mini-os/include/blkfront.h: -------------------------------------------------------------------------------- 1 | #include <mini-os/wait.h> 2 | #include <xen/io/blkif.h> 3 | #include <mini-os/types.h> 4 | struct blkfront_dev; 5 | struct blkfront_aiocb 6 | { 7 | struct blkfront_dev *aio_dev; 8 | uint8_t *aio_buf; 9 | size_t aio_nbytes; 10 | off_t aio_offset; 11 | size_t total_bytes; 12 | uint8_t is_write; 13 | void *data; 14 | 15 | grant_ref_t gref[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 16 | int n; 17 | 18 | void (*aio_cb)(struct blkfront_aiocb *aiocb, int ret); 19 | }; 20 | struct blkfront_info 21 | { 22 | uint64_t sectors; 23 | unsigned sector_size; 24 | int mode; 25 | int info; 26 | int barrier; 27 | int flush; 28 | }; 29 | struct blkfront_dev *init_blkfront(char *nodename, struct blkfront_info *info); 30 | #ifdef HAVE_LIBC 31 | int blkfront_open(struct blkfront_dev *dev); 32 | #endif 33 | void blkfront_aio(struct blkfront_aiocb *aiocbp, int write); 34 | #define blkfront_aio_read(aiocbp) blkfront_aio(aiocbp, 0) 35 | #define blkfront_aio_write(aiocbp) blkfront_aio(aiocbp, 1) 36 | void blkfront_io(struct blkfront_aiocb *aiocbp, int write); 37 | #define blkfront_read(aiocbp) blkfront_io(aiocbp, 0) 38 | #define blkfront_write(aiocbp) blkfront_io(aiocbp, 1) 39 | void blkfront_aio_push_operation(struct blkfront_aiocb *aiocbp, uint8_t op); 40 | int blkfront_aio_poll(struct blkfront_dev *dev); 41 | void blkfront_sync(struct blkfront_dev *dev); 42 | void shutdown_blkfront(struct blkfront_dev *dev); 43 | 44 | extern struct wait_queue_head blkfront_queue; 45 | -------------------------------------------------------------------------------- /xen/mini-os/include/byteswap.h: -------------------------------------------------------------------------------- 1 | #ifndef _BYTESWAP_H_ 2 | #define _BYTESWAP_H_ 3 | 4 | /* Unfortunately not provided by newlib. */ 5 | 6 | #include <mini-os/types.h> 7 | static inline uint16_t bswap_16(uint16_t x) 8 | { 9 | return 10 | ((((x) & 0xff00) >> 8) | (((x) & 0xff) << 8)); 11 | } 12 | 13 | static inline uint32_t bswap_32(uint32_t x) 14 | { 15 | return 16 | ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | 17 | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)); 18 | } 19 | 20 | static inline uint64_t bswap_64(uint64_t x) 21 | { 22 | return 23 | ((((x) & 0xff00000000000000ULL) >> 56) | 24 | (((x) & 0x00ff000000000000ULL) >> 40) | 25 | (((x) & 0x0000ff0000000000ULL) >> 24) | 26 | (((x) & 0x000000ff00000000ULL) >> 8) | 27 | (((x) & 0x00000000ff000000ULL) << 8) | 28 | (((x) & 0x0000000000ff0000ULL) << 24) | 29 | (((x) & 0x000000000000ff00ULL) << 40) | 30 | (((x) & 0x00000000000000ffULL) << 56)); 31 | } 32 | 33 | #endif /* _BYTESWAP_H */ 34 | -------------------------------------------------------------------------------- /xen/mini-os/include/console.h: -------------------------------------------------------------------------------- 1 | /* 2 | **************************************************************************** 3 | * (C) 2006 - Grzegorz Milos - Cambridge University 4 | **************************************************************************** 5 | * 6 | * File: console.h 7 | * Author: Grzegorz Milos 8 | * Changes: 9 | * 10 | * Date: Mar 2006 11 | * 12 | * Environment: Xen Minimal OS 13 | * Description: Console interface. 14 | * 15 | * Handles console I/O. Defines printk. 16 | * 17 | **************************************************************************** 18 | * Permission is hereby granted, free of charge, to any person obtaining a copy 19 | * of this software and associated documentation files (the "Software"), to 20 | * deal in the Software without restriction, including without limitation the 21 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 22 | * sell copies of the Software, and to permit persons to whom the Software is 23 | * furnished to do so, subject to the following conditions: 24 | * 25 | * The above copyright notice and this permission notice shall be included in 26 | * all copies or substantial portions of the Software. 27 | * 28 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 29 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 30 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 31 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 32 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 33 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 34 | * DEALINGS IN THE SOFTWARE. 35 | */ 36 | #ifndef _LIB_CONSOLE_H_ 37 | #define _LIB_CONSOLE_H_ 38 | 39 | #include <mini-os/os.h> 40 | #include <mini-os/traps.h> 41 | #include <mini-os/types.h> 42 | #include <xen/grant_table.h> 43 | #include <xenbus.h> 44 | #include <xen/io/console.h> 45 | #include <stdarg.h> 46 | 47 | struct consfront_dev { 48 | domid_t dom; 49 | 50 | struct xencons_interface *ring; 51 | grant_ref_t ring_ref; 52 | evtchn_port_t evtchn; 53 | 54 | char *nodename; 55 | char *backend; 56 | 57 | xenbus_event_queue events; 58 | 59 | #ifdef HAVE_LIBC 60 | int fd; 61 | #endif 62 | }; 63 | 64 | 65 | 66 | void print(int direct, const char *fmt, va_list args); 67 | void printk(const char *fmt, ...); 68 | void xprintk(const char *fmt, ...); 69 | 70 | #define tprintk(_fmt, _args...) printk("[%s] " _fmt, current->name, ##_args) 71 | 72 | void xencons_rx(char *buf, unsigned len, struct pt_regs *regs); 73 | void xencons_tx(void); 74 | 75 | void init_console(void); 76 | void console_print(struct consfront_dev *dev, char *data, int length); 77 | void fini_console(struct consfront_dev *dev); 78 | 79 | /* Low level functions defined in xencons_ring.c */ 80 | extern struct wait_queue_head console_queue; 81 | struct consfront_dev *xencons_ring_init(void); 82 | struct consfront_dev *init_consfront(char *_nodename); 83 | int xencons_ring_send(struct consfront_dev *dev, const char *data, unsigned len); 84 | int xencons_ring_send_no_notify(struct consfront_dev *dev, const char *data, unsigned len); 85 | int xencons_ring_avail(struct consfront_dev *dev); 86 | int xencons_ring_recv(struct consfront_dev *dev, char *data, unsigned len); 87 | void free_consfront(struct consfront_dev *dev); 88 | 89 | #endif /* _LIB_CONSOLE_H_ */ 90 | -------------------------------------------------------------------------------- /xen/mini-os/include/ctype.h: -------------------------------------------------------------------------------- 1 | #ifndef _CTYPE_H 2 | #define _CTYPE_H 3 | 4 | #ifdef HAVE_LIBC 5 | #include_next <ctype.h> 6 | #else 7 | /* 8 | * NOTE! This ctype does not handle EOF like the standard C 9 | * library is required to. 10 | */ 11 | 12 | #define _U 0x01 /* upper */ 13 | #define _L 0x02 /* lower */ 14 | #define _D 0x04 /* digit */ 15 | #define _C 0x08 /* cntrl */ 16 | #define _P 0x10 /* punct */ 17 | #define _S 0x20 /* white space (space/lf/tab) */ 18 | #define _X 0x40 /* hex digit */ 19 | #define _SP 0x80 /* hard space (0x20) */ 20 | 21 | 22 | extern unsigned char _ctype[]; 23 | 24 | #define __ismask(x) (_ctype[(int)(unsigned char)(x)]) 25 | 26 | #define isalnum(c) ((__ismask(c)&(_U|_L|_D)) != 0) 27 | #define isalpha(c) ((__ismask(c)&(_U|_L)) != 0) 28 | #define iscntrl(c) ((__ismask(c)&(_C)) != 0) 29 | #define isdigit(c) ((__ismask(c)&(_D)) != 0) 30 | #define isgraph(c) ((__ismask(c)&(_P|_U|_L|_D)) != 0) 31 | #define islower(c) ((__ismask(c)&(_L)) != 0) 32 | #define isprint(c) ((__ismask(c)&(_P|_U|_L|_D|_SP)) != 0) 33 | #define ispunct(c) ((__ismask(c)&(_P)) != 0) 34 | #define isspace(c) ((__ismask(c)&(_S)) != 0) 35 | #define isupper(c) ((__ismask(c)&(_U)) != 0) 36 | #define isxdigit(c) ((__ismask(c)&(_D|_X)) != 0) 37 | 38 | #define isascii(c) (((unsigned char)(c))<=0x7f) 39 | #define toascii(c) (((unsigned char)(c))&0x7f) 40 | 41 | static inline unsigned char __tolower(unsigned char c) 42 | { 43 | if (isupper(c)) 44 | c -= 'A'-'a'; 45 | return c; 46 | } 47 | 48 | static inline unsigned char __toupper(unsigned char c) 49 | { 50 | if (islower(c)) 51 | c -= 'a'-'A'; 52 | return c; 53 | } 54 | 55 | #define tolower(c) __tolower(c) 56 | #define toupper(c) __toupper(c) 57 | 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /xen/mini-os/include/err.h: -------------------------------------------------------------------------------- 1 | #ifndef _ERR_H 2 | #define _ERR_H 3 | 4 | #include <mini-os/errno.h> 5 | 6 | /* 7 | * Kernel pointers have redundant information, so we can use a 8 | * scheme where we can return either an error code or a dentry 9 | * pointer with the same return value. 10 | * 11 | * This should be a per-architecture thing, to allow different 12 | * error and pointer decisions. 13 | */ 14 | #define IS_ERR_VALUE(x) ((x) > (unsigned long)-1000L) 15 | 16 | static inline void *ERR_PTR(long error) 17 | { 18 | return (void *) error; 19 | } 20 | 21 | static inline long PTR_ERR(const void *ptr) 22 | { 23 | return (long) ptr; 24 | } 25 | 26 | static inline long IS_ERR(const void *ptr) 27 | { 28 | return IS_ERR_VALUE((unsigned long)ptr); 29 | } 30 | 31 | #endif /* _LINUX_ERR_H */ 32 | -------------------------------------------------------------------------------- /xen/mini-os/include/errno-base.h: -------------------------------------------------------------------------------- 1 | #ifndef _ERRNO_BASE_H 2 | #define _ERRNO_BASE_H 3 | 4 | #define EPERM 1 /* Operation not permitted */ 5 | #define ENOENT 2 /* No such file or directory */ 6 | #define ESRCH 3 /* No such process */ 7 | #define EINTR 4 /* Interrupted system call */ 8 | #define EIO 5 /* I/O error */ 9 | #define ENXIO 6 /* No such device or address */ 10 | #define E2BIG 7 /* Argument list too long */ 11 | #define ENOEXEC 8 /* Exec format error */ 12 | #define EBADF 9 /* Bad file number */ 13 | #define ECHILD 10 /* No child processes */ 14 | #define EAGAIN 11 /* Try again */ 15 | #define ENOMEM 12 /* Out of memory */ 16 | #define EACCES 13 /* Permission denied */ 17 | #define EFAULT 14 /* Bad address */ 18 | #define ENOTBLK 15 /* Block device required */ 19 | #define EBUSY 16 /* Device or resource busy */ 20 | #define EEXIST 17 /* File exists */ 21 | #define EXDEV 18 /* Cross-device link */ 22 | #define ENODEV 19 /* No such device */ 23 | #define ENOTDIR 20 /* Not a directory */ 24 | #define EISDIR 21 /* Is a directory */ 25 | #define EINVAL 22 /* Invalid argument */ 26 | #define ENFILE 23 /* File table overflow */ 27 | #define EMFILE 24 /* Too many open files */ 28 | #define ENOTTY 25 /* Not a typewriter */ 29 | #define ETXTBSY 26 /* Text file busy */ 30 | #define EFBIG 27 /* File too large */ 31 | #define ENOSPC 28 /* No space left on device */ 32 | #define ESPIPE 29 /* Illegal seek */ 33 | #define EROFS 30 /* Read-only file system */ 34 | #define EMLINK 31 /* Too many links */ 35 | #define EPIPE 32 /* Broken pipe */ 36 | #define EDOM 33 /* Math argument out of domain of func */ 37 | #define ERANGE 34 /* Math result not representable */ 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /xen/mini-os/include/events.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | **************************************************************************** 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | * (C) 2005 - Grzegorz Milos - Intel Reseach Cambridge 5 | **************************************************************************** 6 | * 7 | * File: events.h 8 | * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) 9 | * Changes: Grzegorz Milos (gm281@cam.ac.uk) 10 | * 11 | * Date: Jul 2003, changes Jun 2005 12 | * 13 | * Environment: Xen Minimal OS 14 | * Description: Deals with events on the event channels 15 | * 16 | **************************************************************************** 17 | */ 18 | 19 | #ifndef _EVENTS_H_ 20 | #define _EVENTS_H_ 21 | 22 | #include<mini-os/traps.h> 23 | #include<xen/event_channel.h> 24 | 25 | typedef void (*evtchn_handler_t)(evtchn_port_t, struct pt_regs *, void *); 26 | 27 | /* prototypes */ 28 | int do_event(evtchn_port_t port, struct pt_regs *regs); 29 | evtchn_port_t bind_virq(uint32_t virq, evtchn_handler_t handler, void *data); 30 | evtchn_port_t bind_pirq(uint32_t pirq, int will_share, evtchn_handler_t handler, void *data); 31 | evtchn_port_t bind_evtchn(evtchn_port_t port, evtchn_handler_t handler, 32 | void *data); 33 | evtchn_port_t bind_ipi(uint32_t vcpu, evtchn_handler_t handler, void *data); 34 | void unbind_evtchn(evtchn_port_t port); 35 | void init_events(void); 36 | int evtchn_alloc_unbound(domid_t pal, evtchn_handler_t handler, 37 | void *data, evtchn_port_t *port); 38 | int evtchn_bind_interdomain(domid_t pal, evtchn_port_t remote_port, 39 | evtchn_handler_t handler, void *data, 40 | evtchn_port_t *local_port); 41 | void unbind_all_ports(void); 42 | 43 | static inline int notify_remote_via_evtchn(evtchn_port_t port) 44 | { 45 | evtchn_send_t op; 46 | op.port = port; 47 | return HYPERVISOR_event_channel_op(EVTCHNOP_send, &op); 48 | } 49 | 50 | void fini_events(void); 51 | 52 | #endif /* _EVENTS_H_ */ 53 | -------------------------------------------------------------------------------- /xen/mini-os/include/fbfront.h: -------------------------------------------------------------------------------- 1 | #include <xen/io/kbdif.h> 2 | #include <xen/io/fbif.h> 3 | #include <mini-os/semaphore.h> 4 | #include <mini-os/wait.h> 5 | 6 | /* from <linux/input.h> */ 7 | #ifndef BTN_LEFT 8 | #define BTN_LEFT 0x110 9 | #endif 10 | #ifndef BTN_RIGHT 11 | #define BTN_RIGHT 0x111 12 | #endif 13 | #ifndef BTN_MIDDLE 14 | #define BTN_MIDDLE 0x112 15 | #endif 16 | #ifndef KEY_Q 17 | #define KEY_Q 16 18 | #endif 19 | #ifndef KEY_MAX 20 | #define KEY_MAX 0x1ff 21 | #endif 22 | 23 | 24 | struct kbdfront_dev; 25 | struct kbdfront_dev *init_kbdfront(char *nodename, int abs_pointer); 26 | #ifdef HAVE_LIBC 27 | int kbdfront_open(struct kbdfront_dev *dev); 28 | #endif 29 | 30 | int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n); 31 | extern struct wait_queue_head kbdfront_queue; 32 | 33 | void shutdown_kbdfront(struct kbdfront_dev *dev); 34 | 35 | 36 | struct fbfront_dev *init_fbfront(char *nodename, unsigned long *mfns, int width, int height, int depth, int stride, int n); 37 | #ifdef HAVE_LIBC 38 | int fbfront_open(struct fbfront_dev *dev); 39 | #endif 40 | 41 | int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n); 42 | extern struct wait_queue_head fbfront_queue; 43 | void fbfront_update(struct fbfront_dev *dev, int x, int y, int width, int height); 44 | void fbfront_resize(struct fbfront_dev *dev, int width, int height, int stride, int depth, int offset); 45 | 46 | void shutdown_fbfront(struct fbfront_dev *dev); 47 | -------------------------------------------------------------------------------- /xen/mini-os/include/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef _I386_FCNTL_H 2 | #define _I386_FCNTL_H 3 | 4 | #ifdef HAVE_LIBC 5 | #include_next <fcntl.h> 6 | #else 7 | 8 | /* open/fcntl - O_SYNC is only implemented on blocks devices and on files 9 | located on an ext2 file system */ 10 | #define O_ACCMODE 0003 11 | #define O_RDONLY 00 12 | #define O_WRONLY 01 13 | #define O_RDWR 02 14 | #define O_CREAT 0100 /* not fcntl */ 15 | #define O_EXCL 0200 /* not fcntl */ 16 | #define O_NOCTTY 0400 /* not fcntl */ 17 | #define O_TRUNC 01000 /* not fcntl */ 18 | #define O_APPEND 02000 19 | #define O_NONBLOCK 04000 20 | #define O_NDELAY O_NONBLOCK 21 | #define O_SYNC 010000 22 | #define FASYNC 020000 /* fcntl, for BSD compatibility */ 23 | #define O_DIRECT 040000 /* direct disk access hint */ 24 | #define O_LARGEFILE 0100000 25 | #define O_DIRECTORY 0200000 /* must be a directory */ 26 | #define O_NOFOLLOW 0400000 /* don't follow links */ 27 | #define O_NOATIME 01000000 28 | 29 | #define F_DUPFD 0 /* dup */ 30 | #define F_GETFD 1 /* get close_on_exec */ 31 | #define F_SETFD 2 /* set/clear close_on_exec */ 32 | #define F_GETFL 3 /* get file->f_flags */ 33 | #define F_SETFL 4 /* set file->f_flags */ 34 | #define F_GETLK 5 35 | #define F_SETLK 6 36 | #define F_SETLKW 7 37 | 38 | #define F_SETOWN 8 /* for sockets. */ 39 | #define F_GETOWN 9 /* for sockets. */ 40 | #define F_SETSIG 10 /* for sockets. */ 41 | #define F_GETSIG 11 /* for sockets. */ 42 | 43 | #define F_GETLK64 12 /* using 'struct flock64' */ 44 | #define F_SETLK64 13 45 | #define F_SETLKW64 14 46 | 47 | /* for F_[GET|SET]FL */ 48 | #define FD_CLOEXEC 1 /* actually anything with low bit set goes */ 49 | 50 | /* for posix fcntl() and lockf() */ 51 | #define F_RDLCK 0 52 | #define F_WRLCK 1 53 | #define F_UNLCK 2 54 | 55 | /* for old implementation of bsd flock () */ 56 | #define F_EXLCK 4 /* or 3 */ 57 | #define F_SHLCK 8 /* or 4 */ 58 | 59 | /* for leases */ 60 | #define F_INPROGRESS 16 61 | 62 | /* operations for bsd flock(), also used by the kernel implementation */ 63 | #define LOCK_SH 1 /* shared lock */ 64 | #define LOCK_EX 2 /* exclusive lock */ 65 | #define LOCK_NB 4 /* or'd with one of the above to prevent 66 | blocking */ 67 | #define LOCK_UN 8 /* remove lock */ 68 | 69 | #define LOCK_MAND 32 /* This is a mandatory flock */ 70 | #define LOCK_READ 64 /* ... Which allows concurrent read operations */ 71 | #define LOCK_WRITE 128 /* ... Which allows concurrent write operations */ 72 | #define LOCK_RW 192 /* ... Which allows concurrent read & write ops */ 73 | 74 | /* 75 | struct flock { 76 | short l_type; 77 | short l_whence; 78 | off_t l_start; 79 | off_t l_len; 80 | pid_t l_pid; 81 | }; 82 | 83 | struct flock64 { 84 | short l_type; 85 | short l_whence; 86 | loff_t l_start; 87 | loff_t l_len; 88 | pid_t l_pid; 89 | }; 90 | 91 | #define F_LINUX_SPECIFIC_BASE 1024 92 | */ 93 | 94 | #endif 95 | 96 | int open(const char *path, int flags, ...) asm("open64"); 97 | int fcntl(int fd, int cmd, ...); 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /xen/mini-os/include/gntmap.h: -------------------------------------------------------------------------------- 1 | #ifndef __GNTMAP_H__ 2 | #define __GNTMAP_H__ 3 | 4 | #include <os.h> 5 | 6 | /* 7 | * Please consider struct gntmap opaque. If instead you choose to disregard 8 | * this message, I insist that you keep an eye out for raptors. 9 | */ 10 | struct gntmap { 11 | int nentries; 12 | struct gntmap_entry *entries; 13 | }; 14 | 15 | int 16 | gntmap_set_max_grants(struct gntmap *map, int count); 17 | 18 | int 19 | gntmap_munmap(struct gntmap *map, unsigned long start_address, int count); 20 | 21 | void* 22 | gntmap_map_grant_refs(struct gntmap *map, 23 | uint32_t count, 24 | uint32_t *domids, 25 | int domids_stride, 26 | uint32_t *refs, 27 | int writable); 28 | 29 | void 30 | gntmap_init(struct gntmap *map); 31 | 32 | void 33 | gntmap_fini(struct gntmap *map); 34 | 35 | #endif /* !__GNTMAP_H__ */ 36 | -------------------------------------------------------------------------------- /xen/mini-os/include/gnttab.h: -------------------------------------------------------------------------------- 1 | #ifndef __GNTTAB_H__ 2 | #define __GNTTAB_H__ 3 | 4 | #include <xen/grant_table.h> 5 | 6 | void init_gnttab(void); 7 | grant_ref_t gnttab_alloc_and_grant(void **map); 8 | grant_ref_t gnttab_grant_access(domid_t domid, unsigned long frame, 9 | int readonly); 10 | grant_ref_t gnttab_grant_transfer(domid_t domid, unsigned long pfn); 11 | unsigned long gnttab_end_transfer(grant_ref_t gref); 12 | int gnttab_end_access(grant_ref_t ref); 13 | const char *gnttabop_error(int16_t status); 14 | void fini_gnttab(void); 15 | 16 | #endif /* !__GNTTAB_H__ */ 17 | -------------------------------------------------------------------------------- /xen/mini-os/include/hypervisor.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * hypervisor.h 3 | * 4 | * Hypervisor handling. 5 | * 6 | * 7 | * Copyright (c) 2002, K A Fraser 8 | * Copyright (c) 2005, Grzegorz Milos 9 | * Updates: Aravindh Puthiyaparambil <aravindh.puthiyaparambil@unisys.com> 10 | * Updates: Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com> for ia64 11 | */ 12 | 13 | #ifndef _HYPERVISOR_H_ 14 | #define _HYPERVISOR_H_ 15 | 16 | #include <mini-os/types.h> 17 | #include <xen/xen.h> 18 | #if defined(__i386__) 19 | #include <hypercall-x86_32.h> 20 | #elif defined(__x86_64__) 21 | #include <hypercall-x86_64.h> 22 | #elif defined(__ia64__) 23 | #include <hypercall-ia64.h> 24 | #else 25 | #error "Unsupported architecture" 26 | #endif 27 | #include <mini-os/traps.h> 28 | 29 | /* 30 | * a placeholder for the start of day information passed up from the hypervisor 31 | */ 32 | union start_info_union 33 | { 34 | start_info_t start_info; 35 | char padding[512]; 36 | }; 37 | extern union start_info_union start_info_union; 38 | #define start_info (start_info_union.start_info) 39 | 40 | /* hypervisor.c */ 41 | void force_evtchn_callback(void); 42 | void do_hypervisor_callback(struct pt_regs *regs); 43 | void mask_evtchn(uint32_t port); 44 | void unmask_evtchn(uint32_t port); 45 | void clear_evtchn(uint32_t port); 46 | 47 | #endif /* __HYPERVISOR_H__ */ 48 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/arch_limits.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ARCH_LIMITS_H__ 3 | #define __ARCH_LIMITS_H__ 4 | 5 | /* Commonly 16K pages are used. */ 6 | #define __PAGE_SHIFT 14 /* 16K pages */ 7 | #define __PAGE_SIZE (1<<(__PAGE_SHIFT)) 8 | 9 | #define __STACK_SIZE_PAGE_ORDER 2 10 | #define __STACK_SIZE (__PAGE_SIZE * (1 << __STACK_SIZE_PAGE_ORDER)) 11 | 12 | #endif /* __ARCH_LIMITS_H__ */ 13 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/arch_mm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 - Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com> 3 | * 4 | **************************************************************************** 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to 7 | * deal in the Software without restriction, including without limitation the 8 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 | * sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | */ 23 | 24 | #ifndef __ARCH_MM_H__ 25 | #define __ARCH_MM_H__ 26 | 27 | #include "page.h" 28 | #include "ia64_cpu.h" 29 | 30 | #define PFN_PHYS(x) (pfn_to_page(x)) 31 | #define PHYS_PFN(x) (page_to_pfn(x)) 32 | #define to_virt(x) __va(x) 33 | #define to_phys(x) __pa(x) 34 | 35 | #define virt_to_mfn(x) virt_to_pfn(x) 36 | #define virtual_to_mfn(x) (ia64_tpa((uint64_t)(x)) >> PAGE_SHIFT) 37 | 38 | #define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, NULL, 0) 39 | /* TODO */ 40 | #define map_zero(n, a) map_frames_ex(NULL, n, 0, 0, a, DOMID_SELF, NULL, 0) 41 | #define do_map_zero(start, n) ASSERT(n == 0) 42 | 43 | #endif /* __ARCH_MM_H__ */ 44 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/arch_sched.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2006 Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com> 3 | * All rights reserved. 4 | * 5 | * The file contains ia64 specific scheduler declarations. 6 | * 7 | **************************************************************************** 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to 10 | * deal in the Software without restriction, including without limitation the 11 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 12 | * sell copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24 | * DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | #ifndef __ARCH_SCHED_H__ 28 | #define __ARCH_SCHED_H__ 29 | 30 | #include "os.h" 31 | 32 | struct thread; /* Only declaration */ 33 | 34 | struct thread_regs 35 | { 36 | unsigned long unat_b; /* NaT before spilling */ 37 | unsigned long sp; 38 | unsigned long rp; 39 | unsigned long pr; 40 | unsigned long bsp; 41 | unsigned long pfs; 42 | unsigned long rnat; 43 | unsigned long lc; 44 | 45 | unsigned long unat_a; /* NaT after spilling. */ 46 | unsigned long r4; 47 | unsigned long r5; 48 | unsigned long r6; 49 | unsigned long r7; 50 | 51 | unsigned long b1; 52 | unsigned long b2; 53 | unsigned long b3; 54 | unsigned long b4; 55 | unsigned long b5; 56 | 57 | ia64_fpreg_t f2; 58 | ia64_fpreg_t f3; 59 | ia64_fpreg_t f4; 60 | ia64_fpreg_t f5; 61 | ia64_fpreg_t f16; 62 | ia64_fpreg_t f17; 63 | ia64_fpreg_t f18; 64 | ia64_fpreg_t f19; 65 | ia64_fpreg_t f20; 66 | ia64_fpreg_t f21; 67 | ia64_fpreg_t f22; 68 | ia64_fpreg_t f23; 69 | ia64_fpreg_t f24; 70 | ia64_fpreg_t f25; 71 | ia64_fpreg_t f26; 72 | ia64_fpreg_t f27; 73 | ia64_fpreg_t f28; 74 | ia64_fpreg_t f29; 75 | ia64_fpreg_t f30; 76 | ia64_fpreg_t f31; 77 | }; 78 | 79 | typedef struct thread_regs thread_regs_t; 80 | 81 | void arch_switch_threads(struct thread* prev, struct thread* next); 82 | 83 | static inline struct thread* get_current(void) 84 | { 85 | register struct thread *current asm("r13"); 86 | return current; 87 | } 88 | 89 | 90 | #endif /* __ARCH_SCHED_H__ */ 91 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/arch_spinlock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com 3 | * The file contains ia64 special spinlock stuff. 4 | * 5 | **************************************************************************** 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _ARCH_SPINLOCK_H_ 26 | #define _ARCH_SPINLOCK_H_ 27 | 28 | #include "atomic.h" 29 | 30 | #define ARCH_SPIN_LOCK_UNLOCKED { 0 } 31 | 32 | #define SPIN_LOCK_UNUSED 0 33 | #define SPIN_LOCK_USED 1 34 | 35 | 36 | static inline void 37 | _raw_spin_lock(spinlock_t* lck) 38 | { 39 | uint32_t ret; 40 | do { 41 | ret = ia64_cmpxchg_acq_32(&(lck->slock), 42 | SPIN_LOCK_UNUSED, SPIN_LOCK_USED); 43 | } while (ret == SPIN_LOCK_USED); 44 | } 45 | 46 | static inline void 47 | _raw_spin_unlock(spinlock_t *lck) 48 | { 49 | asm volatile ("st4.rel.nta [%0] = r0\n\t" :: "r"(&(lck->slock)) 50 | : "memory" ); 51 | } 52 | 53 | static inline uint32_t 54 | _raw_spin_trylock(spinlock_t* lck) 55 | { 56 | uint32_t ret; 57 | ret = ia64_cmpxchg_acq_32(&(lck->slock), SPIN_LOCK_USED, SPIN_LOCK_USED); 58 | return (ret == SPIN_LOCK_USED); 59 | } 60 | 61 | #endif /* _ARCH_SPINLOCK_H_ */ 62 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com 3 | */ 4 | 5 | #if !defined(_ASM_H_) 6 | #define _ASM_H_ 7 | 8 | #define ENTRY(_name_) \ 9 | .global _name_; \ 10 | .align 16; \ 11 | .proc _name_; \ 12 | _name_:; \ 13 | 14 | 15 | #define END(_name_) \ 16 | .endp _name_ 17 | 18 | #endif /* !defined(_ASM_H_) */ 19 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/ia64_fpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com> 3 | * This code is mostly taken from FreeBSD. 4 | * 5 | **************************************************************************** 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef _IA64_FPU_H_ 31 | #define _IA64_FPU_H_ 32 | 33 | #include "os.h" 34 | 35 | /* 36 | * Floating point status register bits. 37 | */ 38 | #define IA64_FPSR_TRAP_VD UL_CONST(0x0000000000000001) 39 | #define IA64_FPSR_TRAP_DD UL_CONST(0x0000000000000002) 40 | #define IA64_FPSR_TRAP_ZD UL_CONST(0x0000000000000004) 41 | #define IA64_FPSR_TRAP_OD UL_CONST(0x0000000000000008) 42 | #define IA64_FPSR_TRAP_UD UL_CONST(0x0000000000000010) 43 | #define IA64_FPSR_TRAP_ID UL_CONST(0x0000000000000020) 44 | #define IA64_FPSR_SF(i,v) ((v) << ((i)*13+6)) 45 | 46 | #define IA64_SF_FTZ UL_CONST(0x0001) 47 | #define IA64_SF_WRE UL_CONST(0x0002) 48 | #define IA64_SF_PC UL_CONST(0x000c) 49 | #define IA64_SF_PC_0 UL_CONST(0x0000) 50 | #define IA64_SF_PC_1 UL_CONST(0x0004) 51 | #define IA64_SF_PC_2 UL_CONST(0x0008) 52 | #define IA64_SF_PC_3 UL_CONST(0x000c) 53 | #define IA64_SF_RC UL_CONST(0x0030) 54 | #define IA64_SF_RC_NEAREST UL_CONST(0x0000) 55 | #define IA64_SF_RC_NEGINF UL_CONST(0x0010) 56 | #define IA64_SF_RC_POSINF UL_CONST(0x0020) 57 | #define IA64_SF_RC_TRUNC UL_CONST(0x0030) 58 | #define IA64_SF_TD UL_CONST(0x0040) 59 | #define IA64_SF_V UL_CONST(0x0080) 60 | #define IA64_SF_D UL_CONST(0x0100) 61 | #define IA64_SF_Z UL_CONST(0x0200) 62 | #define IA64_SF_O UL_CONST(0x0400) 63 | #define IA64_SF_U UL_CONST(0x0800) 64 | #define IA64_SF_I UL_CONST(0x1000) 65 | 66 | #define IA64_SF_DEFAULT (IA64_SF_PC_3 | IA64_SF_RC_NEAREST) 67 | 68 | #define IA64_FPSR_DEFAULT (IA64_FPSR_TRAP_VD \ 69 | | IA64_FPSR_TRAP_DD \ 70 | | IA64_FPSR_TRAP_ZD \ 71 | | IA64_FPSR_TRAP_OD \ 72 | | IA64_FPSR_TRAP_UD \ 73 | | IA64_FPSR_TRAP_ID \ 74 | | IA64_FPSR_SF(0, IA64_SF_DEFAULT) \ 75 | | IA64_FPSR_SF(1, (IA64_SF_DEFAULT \ 76 | | IA64_SF_TD \ 77 | | IA64_SF_WRE)) \ 78 | | IA64_FPSR_SF(2, (IA64_SF_DEFAULT \ 79 | | IA64_SF_TD)) \ 80 | | IA64_FPSR_SF(3, (IA64_SF_DEFAULT \ 81 | | IA64_SF_TD))) 82 | 83 | 84 | #ifndef __ASSEMBLY__ 85 | 86 | /* This is from sys/cdefs.h in FreeBSD */ 87 | #define __aligned(x) __attribute__((__aligned__(x))) 88 | 89 | /* A single Floating Point register. */ 90 | struct ia64_fpreg 91 | { 92 | uint8_t fpr_bits[16]; 93 | } __aligned(16); 94 | 95 | typedef struct ia64_fpreg ia64_fpreg_t; 96 | 97 | #endif /* __ASSEMBLY__ */ 98 | 99 | #endif /* _IA64_FPU_H_ */ 100 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/pal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com> 3 | * The code is mostly taken from FreeBSD. 4 | * 5 | **************************************************************************** 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | * 28 | */ 29 | 30 | #ifndef _PAL_H_ 31 | #define _PAL_H_ 32 | 33 | /* 34 | * Architected static calling convention procedures. 35 | */ 36 | #define PAL_CACHE_FLUSH 1 37 | #define PAL_CACHE_INFO 2 38 | #define PAL_CACHE_INIT 3 39 | #define PAL_CACHE_SUMMARY 4 40 | #define PAL_MEM_ATTRIB 5 41 | #define PAL_PTCE_INFO 6 42 | #define PAL_VM_INFO 7 43 | #define PAL_VM_SUMMARY 8 44 | #define PAL_BUS_GET_FEATURES 9 45 | #define PAL_BUS_SET_FEATURES 10 46 | #define PAL_DEBUG_INFO 11 47 | #define PAL_FIXED_ADDR 12 48 | #define PAL_FREQ_BASE 13 49 | #define PAL_FREQ_RATIOS 14 50 | #define PAL_PERF_MON_INFO 15 51 | #define PAL_PLATFORM_ADDR 16 52 | #define PAL_PROC_GET_FEATURE 17 53 | #define PAL_PROC_SET_FEATURE 18 54 | #define PAL_RSE_INFO 19 55 | #define PAL_VERSION 20 56 | #define PAL_MC_CLEAR_LOG 21 57 | #define PAL_MC_DRAIN 22 58 | #define PAL_MC_DYNAMIC_STATE 24 59 | #define PAL_MC_ERROR_INFO 25 60 | #define PAL_MC_EXPECTED 23 61 | #define PAL_MC_REGISTER_MEM 27 62 | #define PAL_MC_RESUME 26 63 | #define PAL_HALT 28 64 | #define PAL_HALT_LIGHT 29 65 | #define PAL_COPY_INFO 30 66 | #define PAL_CACHE_LINE_INIT 31 67 | #define PAL_PMI_ENTRYPOINT 32 68 | #define PAL_ENTER_IA_32_ENV 33 69 | #define PAL_VM_PAGE_SIZE 34 70 | #define PAL_MEM_FOR_TEST 37 71 | #define PAL_CACHE_PROT_INFO 38 72 | #define PAL_REGISTER_INFO 39 73 | #define PAL_SHUTDOWN 40 74 | #define PAL_PREFETCH_VISIBILITY 41 75 | 76 | 77 | struct ia64_pal_result 78 | { 79 | int64_t pal_status; 80 | uint64_t pal_result[3]; 81 | }; 82 | 83 | extern struct ia64_pal_result 84 | ia64_call_pal_static(uint64_t proc, uint64_t arg1, 85 | uint64_t arg2, uint64_t arg3); 86 | 87 | #endif /* _PAL_H_ */ 88 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/privop.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * Copyright (C) 2005 Hewlett-Packard Co 4 | * Dan Magenheimer <dan.magenheimer@hp.com> 5 | * 6 | * Paravirtualizations of privileged operations for Xen/ia64 7 | * 8 | */ 9 | 10 | #ifndef _PRIVOP_H_ 11 | #define _PRIVOP_H_ 12 | 13 | #include <xen/arch-ia64.h> 14 | 15 | #define IA64_PARAVIRTUALIZED 16 | 17 | /* At 1 MB, before per-cpu space but still addressable using addl instead 18 | of movl. */ 19 | #define XSI_BASE 0xfffffffffff00000 20 | 21 | /* Address of mapped regs. */ 22 | #define XMAPPEDREGS_BASE (XSI_BASE + XSI_SIZE) 23 | 24 | #ifdef __ASSEMBLY__ 25 | #define XEN_HYPER_RFI break HYPERPRIVOP_RFI 26 | #define XEN_HYPER_RSM_PSR_DT break HYPERPRIVOP_RSM_DT 27 | #define XEN_HYPER_SSM_PSR_DT break HYPERPRIVOP_SSM_DT 28 | #define XEN_HYPER_COVER break HYPERPRIVOP_COVER 29 | #define XEN_HYPER_ITC_D break HYPERPRIVOP_ITC_D 30 | #define XEN_HYPER_ITC_I break HYPERPRIVOP_ITC_I 31 | #define XEN_HYPER_SSM_I break HYPERPRIVOP_SSM_I 32 | #define XEN_HYPER_GET_IVR break HYPERPRIVOP_GET_IVR 33 | #define XEN_HYPER_GET_TPR break HYPERPRIVOP_GET_TPR 34 | #define XEN_HYPER_SET_TPR break HYPERPRIVOP_SET_TPR 35 | #define XEN_HYPER_EOI break HYPERPRIVOP_EOI 36 | #define XEN_HYPER_SET_ITM break HYPERPRIVOP_SET_ITM 37 | #define XEN_HYPER_THASH break HYPERPRIVOP_THASH 38 | #define XEN_HYPER_PTC_GA break HYPERPRIVOP_PTC_GA 39 | #define XEN_HYPER_ITR_D break HYPERPRIVOP_ITR_D 40 | #define XEN_HYPER_GET_RR break HYPERPRIVOP_GET_RR 41 | #define XEN_HYPER_SET_RR break HYPERPRIVOP_SET_RR 42 | #define XEN_HYPER_SET_KR break HYPERPRIVOP_SET_KR 43 | #define XEN_HYPER_FC break HYPERPRIVOP_FC 44 | #define XEN_HYPER_GET_CPUID break HYPERPRIVOP_GET_CPUID 45 | #define XEN_HYPER_GET_PMD break HYPERPRIVOP_GET_PMD 46 | #define XEN_HYPER_GET_EFLAG break HYPERPRIVOP_GET_EFLAG 47 | #define XEN_HYPER_SET_EFLAG break HYPERPRIVOP_SET_EFLAG 48 | #define XEN_HYPER_RSM_BE break HYPERPRIVOP_RSM_BE 49 | #define XEN_HYPER_GET_PSR break HYPERPRIVOP_GET_PSR 50 | 51 | #define XSI_IFS (XSI_BASE + XSI_IFS_OFS) 52 | #define XSI_PRECOVER_IFS (XSI_BASE + XSI_PRECOVER_IFS_OFS) 53 | #define XSI_INCOMPL_REGFR (XSI_BASE + XSI_INCOMPL_REGFR_OFS) 54 | #define XSI_IFA (XSI_BASE + XSI_IFA_OFS) 55 | #define XSI_ISR (XSI_BASE + XSI_ISR_OFS) 56 | #define XSI_IIM (XSI_BASE + XSI_IIM_OFS) 57 | #define XSI_ITIR (XSI_BASE + XSI_ITIR_OFS) 58 | #define XSI_PSR_I_ADDR (XSI_BASE + XSI_PSR_I_ADDR_OFS) 59 | #define XSI_PSR_IC (XSI_BASE + XSI_PSR_IC_OFS) 60 | #define XSI_IPSR (XSI_BASE + XSI_IPSR_OFS) 61 | #define XSI_IIP (XSI_BASE + XSI_IIP_OFS) 62 | #define XSI_BANK1_R16 (XSI_BASE + XSI_BANK1_R16_OFS) 63 | #define XSI_BANKNUM (XSI_BASE + XSI_BANKNUM_OFS) 64 | #define XSI_IHA (XSI_BASE + XSI_IHA_OFS) 65 | #endif 66 | 67 | #ifndef __ASSEMBLY__ 68 | #define XEN_HYPER_SSM_I asm("break %0" : : "i" (HYPERPRIVOP_SSM_I)) 69 | #define XEN_HYPER_GET_IVR asm("break %0" : : "i" (HYPERPRIVOP_GET_IVR)) 70 | 71 | /************************************************/ 72 | /* Instructions paravirtualized for performance */ 73 | /************************************************/ 74 | 75 | /* Xen uses memory-mapped virtual privileged registers for access to many 76 | * performance-sensitive privileged registers. Some, like the processor 77 | * status register (psr), are broken up into multiple memory locations. 78 | * Others, like "pend", are abstractions based on privileged registers. 79 | * "Pend" is guaranteed to be set if reading cr.ivr would return a 80 | * (non-spurious) interrupt. */ 81 | #define XEN_MAPPEDREGS ((struct mapped_regs *)XMAPPEDREGS_BASE) 82 | #define XSI_PSR_I \ 83 | (*XEN_MAPPEDREGS->interrupt_mask_addr) 84 | #define xen_get_virtual_psr_i() \ 85 | (!XSI_PSR_I) 86 | #define xen_set_virtual_psr_i(_val) \ 87 | ({ XSI_PSR_I = (uint8_t)(_val) ? 0 : 1; }) 88 | #define xen_get_virtual_psr_ic() \ 89 | ( XEN_MAPPEDREGS->interrupt_collection_enabled ) 90 | #define xen_set_virtual_psr_ic(_val) \ 91 | ({ XEN_MAPPEDREGS->interrupt_collection_enabled = _val ? 1 : 0; }) 92 | #define xen_get_virtual_pend() (XEN_MAPPEDREGS->pending_interruption) 93 | 94 | #endif /* __ASSEMBLY__ */ 95 | 96 | #endif /* _PRIVOP_H_ */ 97 | 98 | -------------------------------------------------------------------------------- /xen/mini-os/include/ia64/traps.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Done by Dietmar Hahn <dietmar.hahn@fujitsu-siemens.com> 3 | * 4 | **************************************************************************** 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy 6 | * of this software and associated documentation files (the "Software"), to 7 | * deal in the Software without restriction, including without limitation the 8 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9 | * sell copies of the Software, and to permit persons to whom the Software is 10 | * furnished to do so, subject to the following conditions: 11 | * 12 | * The above copyright notice and this permission notice shall be included in 13 | * all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | */ 23 | 24 | #if !defined(_TRAPS_H_) 25 | #define _TRAPS_H_ 26 | 27 | #if !defined(__ASSEMBLY__) 28 | 29 | /* See ia64_cpu.h */ 30 | struct trap_frame; 31 | 32 | #define pt_regs trap_frame 33 | 34 | /* 35 | * A dummy function, which is currently not supported. 36 | */ 37 | inline static void trap_init(void) 38 | { 39 | //printk("trap_init() until now not needed!\n"); 40 | } 41 | inline static void trap_fini(void) 42 | { 43 | //printk("trap_fini() until now not needed!\n"); 44 | } 45 | 46 | 47 | #endif /* !defined(__ASSEMBLY__) */ 48 | 49 | #include "ia64_cpu.h" 50 | 51 | void stack_walk(void); 52 | 53 | #endif /* !defined(_TRAPS_H_) */ 54 | 55 | -------------------------------------------------------------------------------- /xen/mini-os/include/ioremap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2009 Netronome Systems, Inc. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to 6 | * deal in the Software without restriction, including without limitation the 7 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8 | * sell copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | 24 | #ifndef _IOREMAP_H_ 25 | #define _IOREMAP_H_ 26 | 27 | void *ioremap(unsigned long phys_addr, unsigned long size); 28 | void *ioremap_nocache(unsigned long phys_addr, unsigned long size); 29 | void iounmap(void *virt_addr, unsigned long size); 30 | 31 | #endif /* _IOREMAP_H_ */ 32 | 33 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 indent-tabs-mode:nil -*- */ 34 | -------------------------------------------------------------------------------- /xen/mini-os/include/kernel.h: -------------------------------------------------------------------------------- 1 | #ifndef _KERNEL_H_ 2 | #define _KERNEL_H_ 3 | 4 | extern void do_exit(void) __attribute__((noreturn)); 5 | extern void stop_kernel(void); 6 | 7 | #endif /* _KERNEL_H_ */ 8 | -------------------------------------------------------------------------------- /xen/mini-os/include/linux/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_TYPES_H_ 2 | #define _LINUX_TYPES_H_ 3 | #include <mini-os/types.h> 4 | typedef uint64_t __u64; 5 | #endif /* _LINUX_TYPES_H_ */ 6 | -------------------------------------------------------------------------------- /xen/mini-os/include/lwipopts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * lwipopts.h 3 | * 4 | * Configuration for lwIP running on mini-os 5 | * 6 | * Tim Deegan <Tim.Deegan@eu.citrix.net>, July 2007 7 | */ 8 | 9 | #ifndef __LWIP_LWIPOPTS_H__ 10 | #define __LWIP_LWIPOPTS_H__ 11 | 12 | #define SYS_LIGHTWEIGHT_PROT 1 13 | #define MEM_LIBC_MALLOC 1 14 | #define LWIP_TIMEVAL_PRIVATE 0 15 | #define LWIP_DHCP 1 16 | #define LWIP_COMPAT_SOCKETS 0 17 | #define LWIP_IGMP 1 18 | #define LWIP_USE_HEAP_FROM_INTERRUPT 1 19 | #define MEMP_NUM_SYS_TIMEOUT 10 20 | #define TCP_SND_BUF 3000 21 | #define TCP_MSS 1500 22 | 23 | #endif /* __LWIP_LWIPOPTS_H__ */ 24 | -------------------------------------------------------------------------------- /xen/mini-os/include/mm.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | * 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | * Copyright (c) 2005, Keir A Fraser 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | #ifndef _MM_H_ 26 | #define _MM_H_ 27 | 28 | #if defined(__i386__) 29 | #include <xen/arch-x86_32.h> 30 | #elif defined(__x86_64__) 31 | #include <xen/arch-x86_64.h> 32 | #elif defined(__ia64__) 33 | #include <xen/arch-ia64.h> 34 | #else 35 | #error "Unsupported architecture" 36 | #endif 37 | 38 | #include <mini-os/lib.h> 39 | 40 | #include <mini-os/arch_limits.h> 41 | #include <mini-os/arch_mm.h> 42 | 43 | #define STACK_SIZE_PAGE_ORDER __STACK_SIZE_PAGE_ORDER 44 | #define STACK_SIZE __STACK_SIZE 45 | 46 | 47 | void init_mm(void); 48 | unsigned long alloc_pages(int order); 49 | #define alloc_page() alloc_pages(0) 50 | void free_pages(void *pointer, int order); 51 | #define free_page(p) free_pages(p, 0) 52 | 53 | static __inline__ int get_order(unsigned long size) 54 | { 55 | int order; 56 | size = (size-1) >> PAGE_SHIFT; 57 | for ( order = 0; size; order++ ) 58 | size >>= 1; 59 | return order; 60 | } 61 | 62 | void arch_init_demand_mapping_area(unsigned long max_pfn); 63 | void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p); 64 | void arch_init_p2m(unsigned long max_pfn_p); 65 | 66 | unsigned long allocate_ondemand(unsigned long n, unsigned long alignment); 67 | /* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */ 68 | void *map_frames_ex(const unsigned long *f, unsigned long n, unsigned long stride, 69 | unsigned long increment, unsigned long alignment, domid_t id, 70 | int *err, unsigned long prot); 71 | void do_map_frames(unsigned long addr, 72 | const unsigned long *f, unsigned long n, unsigned long stride, 73 | unsigned long increment, domid_t id, int *err, unsigned long prot); 74 | int unmap_frames(unsigned long va, unsigned long num_frames); 75 | unsigned long alloc_contig_pages(int order, unsigned int addr_bits); 76 | #ifdef HAVE_LIBC 77 | extern unsigned long heap, brk, heap_mapped, heap_end; 78 | #endif 79 | 80 | int free_physical_pages(xen_pfn_t *mfns, int n); 81 | void fini_mm(void); 82 | 83 | #endif /* _MM_H_ */ 84 | -------------------------------------------------------------------------------- /xen/mini-os/include/netfront.h: -------------------------------------------------------------------------------- 1 | #include <mini-os/wait.h> 2 | #ifdef HAVE_LWIP 3 | #include <lwip/netif.h> 4 | #endif 5 | struct netfront_dev; 6 | struct netfront_dev *init_netfront(char *nodename, void (*netif_rx)(unsigned char *data, int len), unsigned char rawmac[6], char **ip); 7 | void netfront_xmit(struct netfront_dev *dev, unsigned char* data,int len); 8 | void shutdown_netfront(struct netfront_dev *dev); 9 | #ifdef HAVE_LIBC 10 | int netfront_tap_open(char *nodename); 11 | ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t len); 12 | #endif 13 | 14 | extern struct wait_queue_head netfront_queue; 15 | 16 | #ifdef HAVE_LWIP 17 | /* Call this to bring up the netfront interface and the lwIP stack. 18 | * N.B. _must_ be called from a thread; it's not safe to call this from 19 | * app_main(). */ 20 | void start_networking(void); 21 | void stop_networking(void); 22 | 23 | void networking_set_addr(struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw); 24 | #endif 25 | -------------------------------------------------------------------------------- /xen/mini-os/include/pcifront.h: -------------------------------------------------------------------------------- 1 | #include <mini-os/types.h> 2 | #include <xen/io/pciif.h> 3 | struct pcifront_dev; 4 | void pcifront_watches(void *opaque); 5 | struct pcifront_dev *init_pcifront(char *nodename); 6 | void pcifront_op(struct pcifront_dev *dev, struct xen_pci_op *op); 7 | void pcifront_scan(struct pcifront_dev *dev, void (*fun)(unsigned int domain, unsigned int bus, unsigned slot, unsigned int fun)); 8 | int pcifront_conf_read(struct pcifront_dev *dev, 9 | unsigned int dom, 10 | unsigned int bus, unsigned int slot, unsigned long fun, 11 | unsigned int off, unsigned int size, unsigned int *val); 12 | int pcifront_conf_write(struct pcifront_dev *dev, 13 | unsigned int dom, 14 | unsigned int bus, unsigned int slot, unsigned long fun, 15 | unsigned int off, unsigned int size, unsigned int val); 16 | int pcifront_enable_msi(struct pcifront_dev *dev, 17 | unsigned int dom, 18 | unsigned int bus, unsigned int slot, unsigned long fun); 19 | int pcifront_disable_msi(struct pcifront_dev *dev, 20 | unsigned int dom, 21 | unsigned int bus, unsigned int slot, unsigned long fun); 22 | int pcifront_enable_msix(struct pcifront_dev *dev, 23 | unsigned int dom, 24 | unsigned int bus, unsigned int slot, unsigned long fun, 25 | struct xen_msix_entry *entries, int n); 26 | int pcifront_disable_msix(struct pcifront_dev *dev, 27 | unsigned int dom, 28 | unsigned int bus, unsigned int slot, unsigned long fun); 29 | void shutdown_pcifront(struct pcifront_dev *dev); 30 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/arpa/inet.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_ARPA_INET_H_ 2 | #define _POSIX_ARPA_INET_H_ 3 | 4 | #include <lwip/inet.h> 5 | 6 | #endif /* _POSIX_ARPA_INET_H_ */ 7 | 8 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/dirent.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_DIRENT_H 2 | #define _POSIX_DIRENT_H 3 | 4 | #include <stdint.h> 5 | 6 | struct dirent { 7 | char *d_name; 8 | }; 9 | 10 | typedef struct { 11 | struct dirent dirent; 12 | char *name; 13 | int32_t offset; 14 | char **entries; 15 | int32_t curentry; 16 | int32_t nbentries; 17 | int has_more; 18 | } DIR; 19 | 20 | DIR *opendir(const char *name); 21 | struct dirent *readdir(DIR *dir); 22 | int closedir(DIR *dir); 23 | 24 | #endif /* _POSIX_DIRENT_H */ 25 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/err.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_ERR_H 2 | #define _POSIX_ERR_H 3 | 4 | #include <stdarg.h> 5 | 6 | void err(int eval, const char *fmt, ...); 7 | void errx(int eval, const char *fmt, ...); 8 | void warn(const char *fmt, ...); 9 | void warnx(const char *fmt, ...); 10 | void verr(int eval, const char *fmt, va_list args); 11 | void verrx(int eval, const char *fmt, va_list args); 12 | void vwarn(const char *fmt, va_list args); 13 | void vwarnx(const char *fmt, va_list args); 14 | 15 | #endif /* _POSIX_ERR_H */ 16 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/fcntl.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_FCNTL_H 2 | #define _POSIX_FCNTL_H 3 | 4 | #include_next <fcntl.h> 5 | 6 | #define F_ULOCK 0 7 | #define F_LOCK 1 8 | #define F_TLOCK 2 9 | #define F_TEST 3 10 | 11 | #endif /* _POSIX_FCNTL_H */ 12 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/limits.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_LIMITS_H 2 | #define _POSIX_LIMITS_H 3 | 4 | #include <mini-os/arch_limits.h> 5 | 6 | #define CHAR_BIT 8 7 | 8 | #define SCHAR_MAX 0x7f 9 | #define SCHAR_MIN (-SCHAR_MAX-1) 10 | #define UCHAR_MAX 0xff 11 | 12 | #ifdef __CHAR_UNSIGNED__ 13 | # define CHAR_MIN 0 14 | # define CHAR_MAX UCHAR_MAX 15 | #else 16 | # define CHAR_MIN SCHAR_MIN 17 | # define CHAR_MAX SCHAR_MAX 18 | #endif 19 | 20 | #define INT_MAX 0x7fffffff 21 | #define INT_MIN (-INT_MAX-1) 22 | #define UINT_MAX 0xffffffff 23 | 24 | #define SHRT_MIN (-0x8000) 25 | #define SHRT_MAX 0x7fff 26 | #define USHRT_MAX 0xffff 27 | 28 | #if defined(__x86_64__) || defined(__ia64__) 29 | # define LONG_MAX 0x7fffffffffffffffL 30 | # define ULONG_MAX 0xffffffffffffffffUL 31 | #else 32 | # define LONG_MAX 0x7fffffffL 33 | # define ULONG_MAX 0xffffffffUL 34 | #endif 35 | #define LONG_MIN (-LONG_MAX-1L) 36 | 37 | #define LLONG_MAX 0x7fffffffffffffffLL 38 | #define LLONG_MIN (-LLONG_MAX-1LL) 39 | #define ULLONG_MAX 0xffffffffffffffffULL 40 | 41 | #define LONG_LONG_MIN LLONG_MIN 42 | #define LONG_LONG_MAX LLONG_MAX 43 | #define ULONG_LONG_MAX ULLONG_MAX 44 | 45 | #define PATH_MAX __PAGE_SIZE 46 | #define PAGE_SIZE __PAGE_SIZE 47 | 48 | #endif /* _POSIX_LIMITS_H */ 49 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/netdb.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_NETDB_H_ 2 | #define _POSIX_NETDB_H_ 3 | 4 | struct hostent { 5 | char *h_addr; 6 | }; 7 | #define gethostbyname(buf) NULL 8 | 9 | #endif /* _POSIX_NETDB_H_ */ 10 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/netinet/in.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SYS_IN_H_ 2 | #define _POSIX_SYS_IN_H_ 3 | 4 | #include <fcntl.h> 5 | #include <lwip/sockets.h> 6 | 7 | #endif /* _POSIX_SYS_IN_H_ */ 8 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/netinet/tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SYS_TCP_H_ 2 | #define _POSIX_SYS_TCP_H_ 3 | 4 | #include <lwip/tcp.h> 5 | 6 | #endif /* _POSIX_SYS_TCP_H_ */ 7 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/pthread.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_PTHREAD_H 2 | #define _POSIX_PTHREAD_H 3 | 4 | #include <stdlib.h> 5 | 6 | /* Let's be single-threaded for now. */ 7 | 8 | typedef struct { 9 | void *ptr; 10 | } *pthread_key_t; 11 | static inline int pthread_key_create(pthread_key_t *key, void (*destr_function)(void*)) 12 | { 13 | *key = malloc(sizeof(**key)); 14 | (*key)->ptr = NULL; 15 | return 0; 16 | } 17 | static inline int pthread_setspecific(pthread_key_t key, const void *pointer) 18 | { 19 | key->ptr = (void*) pointer; 20 | return 0; 21 | } 22 | static inline void *pthread_getspecific(pthread_key_t key) 23 | { 24 | return key->ptr; 25 | } 26 | static inline int pthread_key_delete(pthread_key_t key) 27 | { 28 | free(key); 29 | return 0; 30 | } 31 | 32 | 33 | 34 | typedef struct {} pthread_mutexattr_t; 35 | static inline int pthread_mutexattr_init(pthread_mutexattr_t *mattr) { return 0; } 36 | #define PTHREAD_MUTEX_NORMAL 0 37 | #define PTHREAD_MUTEX_RECURSIVE 1 38 | static inline int pthread_mutexattr_settype(pthread_mutexattr_t *mattr, int kind) { return 0; } 39 | static inline int pthread_mutexattr_destroy(pthread_mutexattr_t *mattr) { return 0; } 40 | typedef struct {} pthread_mutex_t; 41 | #define PTHREAD_MUTEX_INITIALIZER {} 42 | static inline int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *mattr) { return 0; } 43 | static inline int pthread_mutex_lock(pthread_mutex_t *mutex) { return 0; } 44 | static inline int pthread_mutex_unlock(pthread_mutex_t *mutex) { return 0; } 45 | 46 | 47 | 48 | typedef struct { 49 | int done; 50 | } pthread_once_t; 51 | #define PTHREAD_ONCE_INIT { 0 } 52 | 53 | static inline int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) 54 | { 55 | if (!once_control->done) { 56 | once_control->done = 1; 57 | init_routine(); 58 | } 59 | return 0; 60 | } 61 | 62 | #define __thread 63 | 64 | #endif /* _POSIX_PTHREAD_H */ 65 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/signal.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SIGNAL_H 2 | #define _POSIX_SIGNAL_H 3 | 4 | #include_next <signal.h> 5 | 6 | int sigaction(int signum, const struct sigaction * __restrict, 7 | struct sigaction * __restrict); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_STDLIB_H 2 | #define _POSIX_STDLIB_H 3 | 4 | #include_next <stdlib.h> 5 | 6 | #define realpath(p,r) strcpy(r,p) 7 | 8 | #endif /* _POSIX_STDLIB_H */ 9 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/strings.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_STRINGS_H 2 | #define _POSIX_STRINGS_H 3 | 4 | #include <string.h> 5 | 6 | #define bzero(ptr, size) (memset((ptr), '\0', (size)), (void) 0) 7 | 8 | int ffs (int i); 9 | int ffsl (long int li); 10 | int ffsll (long long int lli); 11 | 12 | #endif /* _POSIX_STRINGS_H */ 13 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/sys/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SYS_IOCTL_H 2 | #define _POSIX_SYS_IOCTL_H 3 | 4 | int ioctl(int fd, int request, ...); 5 | 6 | #define _IOC_NONE 0 7 | #define _IOC_WRITE 1 8 | #define _IOC_READ 2 9 | 10 | #define _IOC(rw, class, n, size) \ 11 | (((rw ) << 30) | \ 12 | ((class) << 22) | \ 13 | ((n ) << 14) | \ 14 | ((size ) << 0)) 15 | 16 | #endif /* _POSIX_SYS_IOCTL_H */ 17 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/sys/mman.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SYS_MMAN_H 2 | #define _POSIX_SYS_MMAN_H 3 | 4 | #define PROT_READ 0x1 5 | #define PROT_WRITE 0x2 6 | #define PROT_EXEC 0x4 7 | 8 | #define MAP_SHARED 0x01 9 | #define MAP_PRIVATE 0x02 10 | #define MAP_ANON 0x20 11 | 12 | /* Pages are always resident anyway */ 13 | #define MAP_LOCKED 0x0 14 | 15 | #define MAP_FAILED ((void*)0) 16 | 17 | void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) asm("mmap64"); 18 | int munmap(void *start, size_t length); 19 | #define munlock(addr, len) ((void)(addr), (void)(len), 0) 20 | #define mlock(addr, len) ((void)(addr), (void)(len), 0) 21 | 22 | #endif /* _POSIX_SYS_MMAN_H */ 23 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/sys/poll.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This code is mostly taken from FreeBSD sys/sys/poll.h 3 | * Changes: Stefano Stabellini <stefano.stabellini@eu.citrix.com> 4 | * 5 | **************************************************************************** 6 | * Copyright (c) 1997 Peter Wemm <peter@freebsd.org> 7 | * All rights reserved. 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 | * 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. The name of the author may not be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | 33 | #ifndef _POSIX_SYS_POLL_H_ 34 | #define _POSIX_SYS_POLL_H_ 35 | 36 | /* 37 | * This file is intended to be compatible with the traditional poll.h. 38 | */ 39 | 40 | typedef unsigned int nfds_t; 41 | 42 | /* 43 | * This structure is passed as an array to poll(2). 44 | */ 45 | struct pollfd { 46 | int fd; /* which file descriptor to poll */ 47 | short events; /* events we are interested in */ 48 | short revents; /* events found on return */ 49 | }; 50 | 51 | /* 52 | * Requestable events. If poll(2) finds any of these set, they are 53 | * copied to revents on return. 54 | * XXX Note that FreeBSD doesn't make much distinction between POLLPRI 55 | * and POLLRDBAND since none of the file types have distinct priority 56 | * bands - and only some have an urgent "mode". 57 | * XXX Note POLLIN isn't really supported in true SVSV terms. Under SYSV 58 | * POLLIN includes all of normal, band and urgent data. Most poll handlers 59 | * on FreeBSD only treat it as "normal" data. 60 | */ 61 | #define POLLIN 0x0001 /* any readable data available */ 62 | #define POLLPRI 0x0002 /* OOB/Urgent readable data */ 63 | #define POLLOUT 0x0004 /* file descriptor is writeable */ 64 | #define POLLRDNORM 0x0040 /* non-OOB/URG data available */ 65 | #define POLLWRNORM POLLOUT /* no write type differentiation */ 66 | #define POLLRDBAND 0x0080 /* OOB/Urgent readable data */ 67 | #define POLLWRBAND 0x0100 /* OOB/Urgent data can be written */ 68 | 69 | /* 70 | * These events are set if they occur regardless of whether they were 71 | * requested. 72 | */ 73 | #define POLLERR 0x0008 /* some poll error occurred */ 74 | #define POLLHUP 0x0010 /* file descriptor was "hung up" */ 75 | #define POLLNVAL 0x0020 /* requested events "invalid" */ 76 | 77 | int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout); 78 | 79 | #endif /* _POSIX_SYS_POLL_H_ */ 80 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/sys/select.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SELECT_H 2 | #define _POSIX_SELECT_H 3 | 4 | #include <sys/time.h> 5 | #include <lwip/sockets.h> 6 | int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 7 | 8 | #endif /* _POSIX_SELECT_H */ 9 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/sys/socket.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SYS_SOCKET_H_ 2 | #define _POSIX_SYS_SOCKET_H_ 3 | 4 | #include <fcntl.h> 5 | #include <lwip/sockets.h> 6 | 7 | int accept(int s, struct sockaddr *addr, socklen_t *addrlen); 8 | int bind(int s, struct sockaddr *name, socklen_t namelen); 9 | int shutdown(int s, int how); 10 | int getpeername (int s, struct sockaddr *name, socklen_t *namelen); 11 | int getsockname (int s, struct sockaddr *name, socklen_t *namelen); 12 | int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); 13 | int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); 14 | int close(int s); 15 | int connect(int s, struct sockaddr *name, socklen_t namelen); 16 | int listen(int s, int backlog); 17 | int recv(int s, void *mem, int len, unsigned int flags); 18 | //int read(int s, void *mem, int len); 19 | int recvfrom(int s, void *mem, int len, unsigned int flags, 20 | struct sockaddr *from, socklen_t *fromlen); 21 | int send(int s, void *dataptr, int size, unsigned int flags); 22 | int sendto(int s, void *dataptr, int size, unsigned int flags, 23 | struct sockaddr *to, socklen_t tolen); 24 | int socket(int domain, int type, int protocol); 25 | //int write(int s, void *dataptr, int size); 26 | int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, 27 | struct timeval *timeout); 28 | //int ioctl(int s, long cmd, void *argp); 29 | int getsockname(int s, struct sockaddr *name, socklen_t *namelen); 30 | 31 | #endif /* _POSIX_SYS_SOCKET_H_ */ 32 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/sys/stat.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SYS_STAT_H 2 | #define _POSIX_SYS_STAT_H 3 | 4 | #include_next <sys/stat.h> 5 | int fstat(int fd, struct stat *buf) asm("fstat64"); 6 | 7 | #endif /* _POSIX_SYS_STAT_H */ 8 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/syslog.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_SYSLOG_H 2 | #define _POSIX_SYSLOG_H 3 | 4 | #include <stdarg.h> 5 | 6 | #define LOG_PID 0 7 | #define LOG_CONS 0 8 | #define LOG_NDELAY 0 9 | #define LOG_ODELAY 0 10 | #define LOG_NOWAIT 0 11 | 12 | #define LOG_KERN 0 13 | #define LOG_USER 0 14 | #define LOG_MAIL 0 15 | #define LOG_NEWS 0 16 | #define LOG_UUCP 0 17 | #define LOG_DAEMON 0 18 | #define LOG_AUTH 0 19 | #define LOG_CRON 0 20 | #define LOG_LPR 0 21 | 22 | /* TODO: support */ 23 | #define LOG_EMERG 0 24 | #define LOG_ALERT 1 25 | #define LOG_CRIT 2 26 | #define LOG_ERR 3 27 | #define LOG_WARNING 4 28 | #define LOG_NOTICE 5 29 | #define LOG_INFO 6 30 | #define LOG_DEBUG 7 31 | 32 | void openlog(const char *ident, int option, int facility); 33 | void syslog(int priority, const char *format, ...); 34 | void closelog(void); 35 | void vsyslog(int priority, const char *format, va_list ap); 36 | 37 | #endif /* _POSIX_SYSLOG_H */ 38 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/termios.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_TERMIOS_H 2 | #define _POSIX_TERMIOS_H 3 | 4 | #define NCC 32 5 | 6 | struct termios { 7 | unsigned long c_iflag; 8 | unsigned long c_oflag; 9 | unsigned long c_lflag; 10 | unsigned long c_cflag; 11 | unsigned char c_cc[NCC]; 12 | }; 13 | 14 | /* modem lines */ 15 | #define TIOCM_DTR 0x002 16 | #define TIOCM_RTS 0x004 17 | #define TIOCM_CTS 0x020 18 | #define TIOCM_CAR 0x040 19 | #define TIOCM_RI 0x080 20 | #define TIOCM_DSR 0x100 21 | 22 | /* c_iflag */ 23 | #define IGNBRK 0x00000001 24 | #define BRKINT 0x00000002 25 | #define IGNPAR 0x00000004 26 | #define PARMRK 0x00000008 27 | #define INPCK 0x00000010 28 | #define ISTRIP 0x00000020 29 | #define INLCR 0x00000040 30 | #define IGNCR 0x00000080 31 | #define ICRNL 0x00000100 32 | #define IUCLC 0x00000200 33 | #define IXON 0x00000400 34 | #define IXANY 0x00000800 35 | #define IXOFF 0x00001000 36 | #define IMAXBEL 0x00002000 37 | #define IUTF8 0x00004000 38 | 39 | /* c_oflag */ 40 | #define OPOST 0x00000001 41 | #define OLCUC 0x00000002 42 | #define ONLCR 0x00000004 43 | #define OCRNL 0x00000008 44 | #define ONOCR 0x00000010 45 | #define ONLRET 0x00000020 46 | #define OFILL 0x00000040 47 | #define OFDEL 0x00000080 48 | 49 | /* c_lflag */ 50 | #define ISIG 0x00000001 51 | #define ICANON 0x00000002 52 | #define XCASE 0x00000004 53 | #define ECHO 0x00000008 54 | #define ECHOE 0x00000010 55 | #define ECHOK 0x00000020 56 | #define ECHONL 0x00000040 57 | #define NOFLSH 0x00000080 58 | #define TOSTOP 0x00000100 59 | #define ECHOCTL 0x00000200 60 | #define ECHOPRT 0x00000400 61 | #define ECHOKE 0x00000800 62 | #define FLUSHO 0x00002000 63 | #define PENDIN 0x00004000 64 | #define IEXTEN 0x00008000 65 | 66 | /* c_cflag */ 67 | #define CSIZE 0x00000030 68 | #define CS8 0x00000030 69 | #define CSTOPB 0x00000040 70 | #define CREAD 0x00000080 71 | #define PARENB 0x00000100 72 | #define PARODD 0x00000200 73 | #define HUPCL 0x00000400 74 | #define CLOCAL 0x00000800 75 | 76 | /* c_cc */ 77 | #define VTIME 5 78 | #define VMIN 6 79 | 80 | #define TCSANOW 0 81 | #define TCSADRAIN 1 82 | #define TCSAFLUSH 2 83 | 84 | int tcsetattr(int fildes, int action, const struct termios *tios); 85 | int tcgetattr(int fildes, struct termios *tios); 86 | 87 | #endif /* _POSIX_TERMIOS_H */ 88 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/time.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_TIME_H 2 | #define _POSIX_TIME_H 3 | 4 | #include <sys/time.h> 5 | #define CLOCK_MONOTONIC 2 6 | #include_next <time.h> 7 | 8 | int nanosleep(const struct timespec *req, struct timespec *rem); 9 | int clock_gettime(clockid_t clock_id, struct timespec *tp); 10 | 11 | #endif /* _POSIX_TIME_H */ 12 | -------------------------------------------------------------------------------- /xen/mini-os/include/posix/unistd.h: -------------------------------------------------------------------------------- 1 | #ifndef _POSIX_UNISTD_H 2 | #define _POSIX_UNISTD_H 3 | 4 | #include_next <unistd.h> 5 | 6 | uid_t getuid(void); 7 | uid_t geteuid(void); 8 | gid_t getgid(void); 9 | gid_t getegid(void); 10 | int gethostname(char *name, size_t namelen); 11 | size_t getpagesize(void); 12 | int ftruncate(int fd, off_t length); 13 | int lockf(int fd, int cmd, off_t len); 14 | int nice(int inc); 15 | 16 | #endif /* _POSIX_UNISTD_H */ 17 | -------------------------------------------------------------------------------- /xen/mini-os/include/sched.h: -------------------------------------------------------------------------------- 1 | #ifndef __SCHED_H__ 2 | #define __SCHED_H__ 3 | 4 | #include <mini-os/list.h> 5 | #include <mini-os/time.h> 6 | #include <mini-os/arch_sched.h> 7 | #ifdef HAVE_LIBC 8 | #include <sys/reent.h> 9 | #endif 10 | 11 | struct thread 12 | { 13 | char *name; 14 | char *stack; 15 | #if !defined(__ia64__) 16 | /* keep in that order */ 17 | unsigned long sp; /* Stack pointer */ 18 | unsigned long ip; /* Instruction pointer */ 19 | #else /* !defined(__ia64__) */ 20 | thread_regs_t regs; 21 | #endif /* !defined(__ia64__) */ 22 | struct minios_list_head thread_list; 23 | uint32_t flags; 24 | s_time_t wakeup_time; 25 | #ifdef HAVE_LIBC 26 | struct _reent reent; 27 | #endif 28 | }; 29 | 30 | extern struct thread *idle_thread; 31 | void idle_thread_fn(void *unused); 32 | 33 | #define RUNNABLE_FLAG 0x00000001 34 | 35 | #define is_runnable(_thread) (_thread->flags & RUNNABLE_FLAG) 36 | #define set_runnable(_thread) (_thread->flags |= RUNNABLE_FLAG) 37 | #define clear_runnable(_thread) (_thread->flags &= ~RUNNABLE_FLAG) 38 | 39 | #define switch_threads(prev, next) arch_switch_threads(prev, next) 40 | 41 | /* Architecture specific setup of thread creation. */ 42 | struct thread* arch_create_thread(char *name, void (*function)(void *), 43 | void *data); 44 | 45 | void init_sched(void); 46 | void run_idle_thread(void); 47 | struct thread* create_thread(char *name, void (*function)(void *), void *data); 48 | void exit_thread(void) __attribute__((noreturn)); 49 | void schedule(void); 50 | 51 | #ifdef __INSIDE_MINIOS__ 52 | #define current get_current() 53 | #endif 54 | 55 | void wake(struct thread *thread); 56 | void block(struct thread *thread); 57 | void msleep(uint32_t millisecs); 58 | 59 | #endif /* __SCHED_H__ */ 60 | -------------------------------------------------------------------------------- /xen/mini-os/include/semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef _SEMAPHORE_H_ 2 | #define _SEMAPHORE_H_ 3 | 4 | #include <mini-os/wait.h> 5 | #include <mini-os/spinlock.h> 6 | 7 | /* 8 | * Implementation of semaphore in Mini-os is simple, because 9 | * there are no preemptive threads, the atomicity is guaranteed. 10 | */ 11 | 12 | struct semaphore 13 | { 14 | int count; 15 | struct wait_queue_head wait; 16 | }; 17 | 18 | /* 19 | * the semaphore definition 20 | */ 21 | struct rw_semaphore { 22 | signed long count; 23 | spinlock_t wait_lock; 24 | struct minios_list_head wait_list; 25 | int debug; 26 | }; 27 | 28 | #define __SEMAPHORE_INITIALIZER(name, n) \ 29 | { \ 30 | .count = n, \ 31 | .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \ 32 | } 33 | 34 | #define __MUTEX_INITIALIZER(name) \ 35 | __SEMAPHORE_INITIALIZER(name,1) 36 | 37 | #define __DECLARE_SEMAPHORE_GENERIC(name,count) \ 38 | struct semaphore name = __SEMAPHORE_INITIALIZER(name,count) 39 | 40 | #define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1) 41 | 42 | #define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0) 43 | 44 | static inline void init_SEMAPHORE(struct semaphore *sem, int count) 45 | { 46 | sem->count = count; 47 | init_waitqueue_head(&sem->wait); 48 | } 49 | 50 | #define init_MUTEX(sem) init_SEMAPHORE(sem, 1) 51 | 52 | static inline int trydown(struct semaphore *sem) 53 | { 54 | unsigned long flags; 55 | int ret = 0; 56 | local_irq_save(flags); 57 | if (sem->count > 0) { 58 | ret = 1; 59 | sem->count--; 60 | } 61 | local_irq_restore(flags); 62 | return ret; 63 | } 64 | 65 | static void inline down(struct semaphore *sem) 66 | { 67 | unsigned long flags; 68 | while (1) { 69 | wait_event(sem->wait, sem->count > 0); 70 | local_irq_save(flags); 71 | if (sem->count > 0) 72 | break; 73 | local_irq_restore(flags); 74 | } 75 | sem->count--; 76 | local_irq_restore(flags); 77 | } 78 | 79 | static void inline up(struct semaphore *sem) 80 | { 81 | unsigned long flags; 82 | local_irq_save(flags); 83 | sem->count++; 84 | wake_up(&sem->wait); 85 | local_irq_restore(flags); 86 | } 87 | 88 | /* FIXME! Thre read/write semaphores are unimplemented! */ 89 | static inline void init_rwsem(struct rw_semaphore *sem) 90 | { 91 | sem->count = 1; 92 | } 93 | 94 | static inline void down_read(struct rw_semaphore *sem) 95 | { 96 | } 97 | 98 | 99 | static inline void up_read(struct rw_semaphore *sem) 100 | { 101 | } 102 | 103 | static inline void up_write(struct rw_semaphore *sem) 104 | { 105 | } 106 | 107 | static inline void down_write(struct rw_semaphore *sem) 108 | { 109 | } 110 | 111 | #endif /* _SEMAPHORE_H */ 112 | -------------------------------------------------------------------------------- /xen/mini-os/include/spinlock.h: -------------------------------------------------------------------------------- 1 | #ifndef __ASM_SPINLOCK_H 2 | #define __ASM_SPINLOCK_H 3 | 4 | #include <mini-os/lib.h> 5 | 6 | /* 7 | * Your basic SMP spinlocks, allowing only a single CPU anywhere 8 | */ 9 | 10 | typedef struct { 11 | volatile unsigned int slock; 12 | } spinlock_t; 13 | 14 | 15 | #include <mini-os/arch_spinlock.h> 16 | 17 | 18 | #define SPINLOCK_MAGIC 0xdead4ead 19 | 20 | #define SPIN_LOCK_UNLOCKED ARCH_SPIN_LOCK_UNLOCKED 21 | 22 | #define spin_lock_init(x) do { *(x) = SPIN_LOCK_UNLOCKED; } while(0) 23 | 24 | /* 25 | * Simple spin lock operations. There are two variants, one clears IRQ's 26 | * on the local processor, one does not. 27 | * 28 | * We make no fairness assumptions. They have a cost. 29 | */ 30 | 31 | #define spin_is_locked(x) arch_spin_is_locked(x) 32 | 33 | #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x)) 34 | 35 | 36 | #define _spin_trylock(lock) ({_raw_spin_trylock(lock) ? \ 37 | 1 : ({ 0;});}) 38 | 39 | #define _spin_lock(lock) \ 40 | do { \ 41 | _raw_spin_lock(lock); \ 42 | } while(0) 43 | 44 | #define _spin_unlock(lock) \ 45 | do { \ 46 | _raw_spin_unlock(lock); \ 47 | } while (0) 48 | 49 | 50 | #define spin_lock(lock) _spin_lock(lock) 51 | #define spin_unlock(lock) _spin_unlock(lock) 52 | 53 | #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /xen/mini-os/include/sys/lock.h: -------------------------------------------------------------------------------- 1 | #ifndef _MINIOS_SYS_LOCK_H_ 2 | #define _MINIOS_SYS_LOCK_H_ 3 | 4 | #ifdef HAVE_LIBC 5 | 6 | /* Due to inclusion loop, we can not include sched.h, so have to hide things */ 7 | 8 | #include <mini-os/waittypes.h> 9 | 10 | 11 | typedef struct { 12 | int busy; 13 | struct wait_queue_head wait; 14 | } _LOCK_T; 15 | 16 | #define __LOCK_INIT(class,lock) \ 17 | class _LOCK_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER(lock.wait) } 18 | int ___lock_init(_LOCK_T *lock); 19 | int ___lock_acquire(_LOCK_T *lock); 20 | int ___lock_try_acquire(_LOCK_T *lock); 21 | int ___lock_release(_LOCK_T *lock); 22 | int ___lock_close(_LOCK_T *lock); 23 | #define __lock_init(__lock) ___lock_init(&__lock) 24 | #define __lock_acquire(__lock) ___lock_acquire(&__lock) 25 | #define __lock_release(__lock) ___lock_release(&__lock) 26 | #define __lock_try_acquire(__lock) ___lock_try_acquire(&__lock) 27 | #define __lock_close(__lock) 0 28 | 29 | 30 | typedef struct { 31 | struct thread *owner; 32 | int count; 33 | struct wait_queue_head wait; 34 | } _LOCK_RECURSIVE_T; 35 | 36 | #define __LOCK_INIT_RECURSIVE(class, lock) \ 37 | class _LOCK_RECURSIVE_T lock = { .wait = __WAIT_QUEUE_HEAD_INITIALIZER((lock).wait) } 38 | 39 | int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock); 40 | int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock); 41 | int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock); 42 | int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock); 43 | int ___lock_close_recursive(_LOCK_RECURSIVE_T *lock); 44 | #define __lock_init_recursive(__lock) ___lock_init_recursive(&__lock) 45 | #define __lock_acquire_recursive(__lock) ___lock_acquire_recursive(&__lock) 46 | #define __lock_release_recursive(__lock) ___lock_release_recursive(&__lock) 47 | #define __lock_try_acquire_recursive(__lock) ___lock_try_acquire_recursive(&__lock) 48 | #define __lock_close_recursive(__lock) 0 49 | 50 | #endif 51 | 52 | #endif /* _MINIOS_SYS_LOCK_H_ */ 53 | -------------------------------------------------------------------------------- /xen/mini-os/include/sys/time.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | **************************************************************************** 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | * (C) 2005 - Grzegorz Milos - Intel Research Cambridge 5 | **************************************************************************** 6 | * 7 | * File: time.h 8 | * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) 9 | * Changes: Grzegorz Milos (gm281@cam.ac.uk) 10 | * Robert Kaiser (kaiser@informatik.fh-wiesbaden.de) 11 | * 12 | * Date: Jul 2003, changes: Jun 2005, Sep 2006 13 | * 14 | * Environment: Xen Minimal OS 15 | * Description: Time and timer functions 16 | * 17 | **************************************************************************** 18 | */ 19 | 20 | #ifndef _MINIOS_SYS_TIME_H_ 21 | #define _MINIOS_SYS_TIME_H_ 22 | 23 | #ifdef HAVE_LIBC 24 | #include_next <sys/time.h> 25 | #else 26 | struct timespec { 27 | time_t tv_sec; 28 | long tv_nsec; 29 | }; 30 | 31 | struct timezone { 32 | }; 33 | 34 | struct timeval { 35 | time_t tv_sec; /* seconds */ 36 | suseconds_t tv_usec; /* microseconds */ 37 | }; 38 | 39 | int gettimeofday(struct timeval *tv, void *tz); 40 | #endif 41 | 42 | #endif /* _MINIOS_SYS_TIME_H_ */ 43 | -------------------------------------------------------------------------------- /xen/mini-os/include/time.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | **************************************************************************** 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | * (C) 2005 - Grzegorz Milos - Intel Research Cambridge 5 | **************************************************************************** 6 | * 7 | * File: time.h 8 | * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) 9 | * Changes: Grzegorz Milos (gm281@cam.ac.uk) 10 | * Robert Kaiser (kaiser@informatik.fh-wiesbaden.de) 11 | * 12 | * Date: Jul 2003, changes: Jun 2005, Sep 2006 13 | * 14 | * Environment: Xen Minimal OS 15 | * Description: Time and timer functions 16 | * 17 | **************************************************************************** 18 | */ 19 | 20 | #ifndef _MINIOS_TIME_H_ 21 | #define _MINIOS_TIME_H_ 22 | #include <mini-os/types.h> 23 | 24 | /* 25 | * System Time 26 | * 64 bit value containing the nanoseconds elapsed since boot time. 27 | * This value is adjusted by frequency drift. 28 | * NOW() returns the current time. 29 | * The other macros are for convenience to approximate short intervals 30 | * of real time into system time 31 | */ 32 | typedef int64_t s_time_t; 33 | #define NOW() ((s_time_t)monotonic_clock()) 34 | #define SECONDS(_s) (((s_time_t)(_s)) * 1000000000UL ) 35 | #define TENTHS(_ts) (((s_time_t)(_ts)) * 100000000UL ) 36 | #define HUNDREDTHS(_hs) (((s_time_t)(_hs)) * 10000000UL ) 37 | #define MILLISECS(_ms) (((s_time_t)(_ms)) * 1000000UL ) 38 | #define MICROSECS(_us) (((s_time_t)(_us)) * 1000UL ) 39 | #define Time_Max ((s_time_t) 0x7fffffffffffffffLL) 40 | #define FOREVER Time_Max 41 | #define NSEC_TO_USEC(_nsec) ((_nsec) / 1000UL) 42 | #define NSEC_TO_MSEC(_nsec) ((_nsec) / 1000000ULL) 43 | #define NSEC_TO_SEC(_nsec) ((_nsec) / 1000000000ULL) 44 | 45 | /* wall clock time */ 46 | typedef long time_t; 47 | typedef long suseconds_t; 48 | 49 | #include <sys/time.h> 50 | 51 | #ifdef HAVE_LIBC 52 | #include_next <time.h> 53 | #endif 54 | 55 | /* prototypes */ 56 | void init_time(void); 57 | void fini_time(void); 58 | s_time_t get_s_time(void); 59 | s_time_t get_v_time(void); 60 | uint64_t monotonic_clock(void); 61 | void block_domain(s_time_t until); 62 | 63 | #endif /* _MINIOS_TIME_H_ */ 64 | -------------------------------------------------------------------------------- /xen/mini-os/include/types.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*- 2 | **************************************************************************** 3 | * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge 4 | **************************************************************************** 5 | * 6 | * File: types.h 7 | * Author: Rolf Neugebauer (neugebar@dcs.gla.ac.uk) 8 | * Changes: 9 | * 10 | * Date: May 2003 11 | * 12 | * Environment: Xen Minimal OS 13 | * Description: a random collection of type definitions 14 | * 15 | **************************************************************************** 16 | * $Id: h-insert.h,v 1.4 2002/11/08 16:03:55 rn Exp $ 17 | **************************************************************************** 18 | */ 19 | 20 | #ifndef _TYPES_H_ 21 | #define _TYPES_H_ 22 | #include <stddef.h> 23 | 24 | /* FreeBSD compat types */ 25 | #ifndef HAVE_LIBC 26 | typedef unsigned char u_char; 27 | typedef unsigned int u_int; 28 | typedef unsigned long u_long; 29 | #endif 30 | #ifdef __i386__ 31 | typedef long long quad_t; 32 | typedef unsigned long long u_quad_t; 33 | 34 | typedef struct { unsigned long pte_low, pte_high; } pte_t; 35 | 36 | #elif defined(__x86_64__) || defined(__ia64__) 37 | typedef long quad_t; 38 | typedef unsigned long u_quad_t; 39 | 40 | typedef struct { unsigned long pte; } pte_t; 41 | #endif /* __i386__ || __x86_64__ */ 42 | 43 | #ifdef __x86_64__ 44 | #define __pte(x) ((pte_t) { (x) } ) 45 | #else 46 | #define __pte(x) ({ unsigned long long _x = (x); \ 47 | ((pte_t) {(unsigned long)(_x), (unsigned long)(_x>>32)}); }) 48 | #endif 49 | 50 | #ifdef HAVE_LIBC 51 | #include <limits.h> 52 | #include <stdint.h> 53 | #else 54 | #ifdef __i386__ 55 | typedef unsigned int uintptr_t; 56 | typedef int intptr_t; 57 | #elif defined(__x86_64__) || defined(__ia64__) 58 | typedef unsigned long uintptr_t; 59 | typedef long intptr_t; 60 | #endif /* __i386__ || __x86_64__ */ 61 | typedef unsigned char uint8_t; 62 | typedef signed char int8_t; 63 | typedef unsigned short uint16_t; 64 | typedef signed short int16_t; 65 | typedef unsigned int uint32_t; 66 | typedef signed int int32_t; 67 | #ifdef __i386__ 68 | typedef signed long long int64_t; 69 | typedef unsigned long long uint64_t; 70 | #elif defined(__x86_64__) || defined(__ia64__) 71 | typedef signed long int64_t; 72 | typedef unsigned long uint64_t; 73 | #endif 74 | typedef uint64_t uintmax_t; 75 | typedef int64_t intmax_t; 76 | typedef uint64_t off_t; 77 | #endif 78 | 79 | typedef intptr_t ptrdiff_t; 80 | 81 | 82 | #ifndef HAVE_LIBC 83 | typedef long ssize_t; 84 | #endif 85 | 86 | #endif /* _TYPES_H_ */ 87 | -------------------------------------------------------------------------------- /xen/mini-os/include/wait.h: -------------------------------------------------------------------------------- 1 | #ifndef __WAIT_H__ 2 | #define __WAIT_H__ 3 | 4 | #include <mini-os/sched.h> 5 | #include <mini-os/os.h> 6 | #include <mini-os/waittypes.h> 7 | 8 | #define DEFINE_WAIT(name) \ 9 | struct wait_queue name = { \ 10 | .thread = get_current(), \ 11 | .thread_list = MINIOS_LIST_HEAD_INIT((name).thread_list), \ 12 | } 13 | 14 | 15 | static inline void init_waitqueue_head(struct wait_queue_head *h) 16 | { 17 | MINIOS_INIT_LIST_HEAD(&h->thread_list); 18 | } 19 | 20 | static inline void init_waitqueue_entry(struct wait_queue *q, struct thread *thread) 21 | { 22 | q->thread = thread; 23 | MINIOS_INIT_LIST_HEAD(&q->thread_list); 24 | } 25 | 26 | 27 | static inline void add_wait_queue(struct wait_queue_head *h, struct wait_queue *q) 28 | { 29 | if (minios_list_empty(&q->thread_list)) 30 | minios_list_add(&q->thread_list, &h->thread_list); 31 | } 32 | 33 | static inline void remove_wait_queue(struct wait_queue *q) 34 | { 35 | minios_list_del(&q->thread_list); 36 | } 37 | 38 | static inline void wake_up(struct wait_queue_head *head) 39 | { 40 | unsigned long flags; 41 | struct minios_list_head *tmp, *next; 42 | local_irq_save(flags); 43 | minios_list_for_each_safe(tmp, next, &head->thread_list) 44 | { 45 | struct wait_queue *curr; 46 | curr = minios_list_entry(tmp, struct wait_queue, thread_list); 47 | wake(curr->thread); 48 | } 49 | local_irq_restore(flags); 50 | } 51 | 52 | #define add_waiter(w, wq) do { \ 53 | unsigned long flags; \ 54 | local_irq_save(flags); \ 55 | add_wait_queue(&wq, &w); \ 56 | block(get_current()); \ 57 | local_irq_restore(flags); \ 58 | } while (0) 59 | 60 | #define remove_waiter(w) do { \ 61 | unsigned long flags; \ 62 | local_irq_save(flags); \ 63 | remove_wait_queue(&w); \ 64 | local_irq_restore(flags); \ 65 | } while (0) 66 | 67 | #define wait_event_deadline(wq, condition, deadline) do { \ 68 | unsigned long flags; \ 69 | DEFINE_WAIT(__wait); \ 70 | if(condition) \ 71 | break; \ 72 | for(;;) \ 73 | { \ 74 | /* protect the list */ \ 75 | local_irq_save(flags); \ 76 | add_wait_queue(&wq, &__wait); \ 77 | get_current()->wakeup_time = deadline; \ 78 | clear_runnable(get_current()); \ 79 | local_irq_restore(flags); \ 80 | if((condition) || (deadline && NOW() >= deadline)) \ 81 | break; \ 82 | schedule(); \ 83 | } \ 84 | local_irq_save(flags); \ 85 | /* need to wake up */ \ 86 | wake(get_current()); \ 87 | remove_wait_queue(&__wait); \ 88 | local_irq_restore(flags); \ 89 | } while(0) 90 | 91 | #define wait_event(wq, condition) wait_event_deadline(wq, condition, 0) 92 | 93 | 94 | 95 | #endif /* __WAIT_H__ */ 96 | -------------------------------------------------------------------------------- /xen/mini-os/include/waittypes.h: -------------------------------------------------------------------------------- 1 | #ifndef __WAITTYPE_H__ 2 | #define __WAITTYPE_H__ 3 | 4 | #include <mini-os/list.h> 5 | 6 | struct thread; 7 | struct wait_queue 8 | { 9 | struct thread *thread; 10 | struct minios_list_head thread_list; 11 | }; 12 | 13 | struct wait_queue_head 14 | { 15 | /* TODO - lock required? */ 16 | struct minios_list_head thread_list; 17 | }; 18 | 19 | #define DECLARE_WAIT_QUEUE_HEAD(name) \ 20 | struct wait_queue_head name = \ 21 | { .thread_list = { &(name).thread_list, &(name).thread_list} } 22 | 23 | #define __WAIT_QUEUE_HEAD_INITIALIZER(name) { \ 24 | .thread_list = { &(name).thread_list, &(name).thread_list } } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /xen/mini-os/include/x86/arch_limits.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ARCH_LIMITS_H__ 3 | #define __ARCH_LIMITS_H__ 4 | 5 | #define __PAGE_SHIFT 12 6 | 7 | #ifdef __ASSEMBLY__ 8 | #define __PAGE_SIZE (1 << __PAGE_SHIFT) 9 | #else 10 | #ifdef __x86_64__ 11 | #define __PAGE_SIZE (1UL << __PAGE_SHIFT) 12 | #else 13 | #define __PAGE_SIZE (1ULL << __PAGE_SHIFT) 14 | #endif 15 | #endif 16 | 17 | #define __STACK_SIZE_PAGE_ORDER 4 18 | #define __STACK_SIZE (__PAGE_SIZE * (1 << __STACK_SIZE_PAGE_ORDER)) 19 | 20 | #endif /* __ARCH_LIMITS_H__ */ 21 | -------------------------------------------------------------------------------- /xen/mini-os/include/x86/arch_sched.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __ARCH_SCHED_H__ 3 | #define __ARCH_SCHED_H__ 4 | 5 | #include "arch_limits.h" 6 | 7 | static inline struct thread* get_current(void) 8 | { 9 | struct thread **current; 10 | #ifdef __i386__ 11 | register unsigned long sp asm("esp"); 12 | #else 13 | register unsigned long sp asm("rsp"); 14 | #endif 15 | current = (void *)(unsigned long)(sp & ~(__STACK_SIZE-1)); 16 | return *current; 17 | } 18 | 19 | extern void __arch_switch_threads(unsigned long *prevctx, unsigned long *nextctx); 20 | 21 | #define arch_switch_threads(prev,next) __arch_switch_threads(&(prev)->sp, &(next)->sp) 22 | 23 | 24 | 25 | #endif /* __ARCH_SCHED_H__ */ 26 | -------------------------------------------------------------------------------- /xen/mini-os/include/x86/arch_spinlock.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef __ARCH_ASM_SPINLOCK_H 4 | #define __ARCH_ASM_SPINLOCK_H 5 | 6 | #include <mini-os/lib.h> 7 | #include "os.h" 8 | 9 | 10 | #define ARCH_SPIN_LOCK_UNLOCKED { 1 } 11 | 12 | /* 13 | * Simple spin lock operations. There are two variants, one clears IRQ's 14 | * on the local processor, one does not. 15 | * 16 | * We make no fairness assumptions. They have a cost. 17 | */ 18 | 19 | #define arch_spin_is_locked(x) (*(volatile signed char *)(&(x)->slock) <= 0) 20 | #define spin_unlock_wait(x) do { barrier(); } while(spin_is_locked(x)) 21 | 22 | #define spin_lock_string \ 23 | "1:\n" \ 24 | LOCK \ 25 | "decb %0\n\t" \ 26 | "jns 3f\n" \ 27 | "2:\t" \ 28 | "rep;nop\n\t" \ 29 | "cmpb $0,%0\n\t" \ 30 | "jle 2b\n\t" \ 31 | "jmp 1b\n" \ 32 | "3:\n\t" 33 | 34 | #define spin_lock_string_flags \ 35 | "1:\n" \ 36 | LOCK \ 37 | "decb %0\n\t" \ 38 | "jns 4f\n\t" \ 39 | "2:\t" \ 40 | "testl $0x200, %1\n\t" \ 41 | "jz 3f\n\t" \ 42 | "#sti\n\t" \ 43 | "3:\t" \ 44 | "rep;nop\n\t" \ 45 | "cmpb $0, %0\n\t" \ 46 | "jle 3b\n\t" \ 47 | "#cli\n\t" \ 48 | "jmp 1b\n" \ 49 | "4:\n\t" 50 | 51 | /* 52 | * This works. Despite all the confusion. 53 | * (except on PPro SMP or if we are using OOSTORE) 54 | * (PPro errata 66, 92) 55 | */ 56 | 57 | #define spin_unlock_string \ 58 | "xchgb %b0, %1" \ 59 | :"=q" (oldval), "=m" (lock->slock) \ 60 | :"0" (oldval) : "memory" 61 | 62 | static inline void _raw_spin_unlock(spinlock_t *lock) 63 | { 64 | char oldval = 1; 65 | __asm__ __volatile__( 66 | spin_unlock_string 67 | ); 68 | } 69 | 70 | static inline int _raw_spin_trylock(spinlock_t *lock) 71 | { 72 | char oldval; 73 | __asm__ __volatile__( 74 | "xchgb %b0,%1\n" 75 | :"=q" (oldval), "=m" (lock->slock) 76 | :"0" (0) : "memory"); 77 | return oldval > 0; 78 | } 79 | 80 | static inline void _raw_spin_lock(spinlock_t *lock) 81 | { 82 | __asm__ __volatile__( 83 | spin_lock_string 84 | :"=m" (lock->slock) : : "memory"); 85 | } 86 | 87 | static inline void _raw_spin_lock_flags (spinlock_t *lock, unsigned long flags) 88 | { 89 | __asm__ __volatile__( 90 | spin_lock_string_flags 91 | :"=m" (lock->slock) : "r" (flags) : "memory"); 92 | } 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /xen/mini-os/include/x86/traps.h: -------------------------------------------------------------------------------- 1 | /* 2 | **************************************************************************** 3 | * (C) 2005 - Grzegorz Milos - Intel Reseach Cambridge 4 | **************************************************************************** 5 | * 6 | * File: traps.h 7 | * Author: Grzegorz Milos (gm281@cam.ac.uk) 8 | * 9 | * Date: Jun 2005 10 | * 11 | * Environment: Xen Minimal OS 12 | * Description: Deals with traps 13 | * 14 | **************************************************************************** 15 | */ 16 | 17 | #ifndef _TRAPS_H_ 18 | #define _TRAPS_H_ 19 | 20 | #ifdef __i386__ 21 | struct pt_regs { 22 | long ebx; 23 | long ecx; 24 | long edx; 25 | long esi; 26 | long edi; 27 | long ebp; 28 | long eax; 29 | int xds; 30 | int xes; 31 | long orig_eax; 32 | long eip; 33 | int xcs; 34 | long eflags; 35 | long esp; 36 | int xss; 37 | }; 38 | #elif __x86_64__ 39 | 40 | struct pt_regs { 41 | unsigned long r15; 42 | unsigned long r14; 43 | unsigned long r13; 44 | unsigned long r12; 45 | unsigned long rbp; 46 | unsigned long rbx; 47 | /* arguments: non interrupts/non tracing syscalls only save upto here*/ 48 | unsigned long r11; 49 | unsigned long r10; 50 | unsigned long r9; 51 | unsigned long r8; 52 | unsigned long rax; 53 | unsigned long rcx; 54 | unsigned long rdx; 55 | unsigned long rsi; 56 | unsigned long rdi; 57 | unsigned long orig_rax; 58 | /* end of arguments */ 59 | /* cpu exception frame or undefined */ 60 | unsigned long rip; 61 | unsigned long cs; 62 | unsigned long eflags; 63 | unsigned long rsp; 64 | unsigned long ss; 65 | /* top of stack page */ 66 | }; 67 | 68 | 69 | #endif 70 | 71 | void dump_regs(struct pt_regs *regs); 72 | void stack_walk(void); 73 | 74 | #define TRAP_PF_PROT 0x1 75 | #define TRAP_PF_WRITE 0x2 76 | #define TRAP_PF_USER 0x4 77 | 78 | #endif /* _TRAPS_H_ */ 79 | -------------------------------------------------------------------------------- /xen/mini-os/include/xmalloc.h: -------------------------------------------------------------------------------- 1 | #ifndef __XMALLOC_H__ 2 | #define __XMALLOC_H__ 3 | 4 | #ifdef HAVE_LIBC 5 | 6 | #include <stdlib.h> 7 | #include <malloc.h> 8 | /* Allocate space for typed object. */ 9 | #define _xmalloc(size, align) memalign(align, size) 10 | #define xfree(ptr) free(ptr) 11 | 12 | #else 13 | 14 | #include <limits.h> 15 | 16 | #define DEFAULT_ALIGN (sizeof(unsigned long)) 17 | #define malloc(size) _xmalloc(size, DEFAULT_ALIGN) 18 | #define free(ptr) xfree(ptr) 19 | #define realloc(ptr, size) _realloc(ptr, size) 20 | 21 | /* Free any of the above. */ 22 | extern void xfree(const void *); 23 | 24 | /* Underlying functions */ 25 | extern void *_xmalloc(size_t size, size_t align); 26 | extern void *_realloc(void *ptr, size_t size); 27 | 28 | #endif 29 | 30 | static inline void *_xmalloc_array(size_t size, size_t align, size_t num) 31 | { 32 | /* Check for overflow. */ 33 | if (size && num > UINT_MAX / size) 34 | return NULL; 35 | return _xmalloc(size * num, align); 36 | } 37 | 38 | /* Allocate space for typed object. */ 39 | #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type))) 40 | 41 | /* Allocate space for array of typed objects. */ 42 | #define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num)) 43 | 44 | #endif /* __XMALLOC_H__ */ 45 | -------------------------------------------------------------------------------- /xen/mini-os/latency/client.conf: -------------------------------------------------------------------------------- 1 | kernel = "/mnt/ise2/ipc-bench/xen/mini-os/mini-os.gz" 2 | 3 | memory = 64 4 | 5 | name = "client" 6 | 7 | # List of which CPUS this domain is allowed to use, default Xen picks 8 | #cpus = "" # leave to Xen to pick 9 | #cpus = "0" # all vcpus run on CPU0 10 | #cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 11 | #cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 12 | cpus = "1" 13 | 14 | # Number of Virtual CPUS to use, default is 1 15 | #vcpus = 1 16 | 17 | vif = [] 18 | disk = [] 19 | 20 | extra="client" 21 | -------------------------------------------------------------------------------- /xen/mini-os/latency/doit.sh: -------------------------------------------------------------------------------- 1 | xm des client 2 | xm des server 3 | xm create -q server.conf 4 | xm create -q client.conf 5 | sleep 2 6 | xenstore-write /local/domain/$(xm domid server)/client_dom $(xm domid client) 7 | xenstore-write /local/domain/$(xm domid client)/server_dom $(xm domid server) 8 | echo Server event channel port? 9 | read port 10 | xenstore-write /local/domain/$(xm domid client)/server_port $port 11 | -------------------------------------------------------------------------------- /xen/mini-os/latency/server.conf: -------------------------------------------------------------------------------- 1 | kernel = "/mnt/ise2/ipc-bench/xen/mini-os/mini-os.gz" 2 | 3 | memory = 64 4 | 5 | name = "server" 6 | 7 | # List of which CPUS this domain is allowed to use, default Xen picks 8 | #cpus = "" # leave to Xen to pick 9 | #cpus = "0" # all vcpus run on CPU0 10 | #cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 11 | #cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 12 | cpus = "0" 13 | 14 | # Number of Virtual CPUS to use, default is 1 15 | #vcpus = 1 16 | 17 | vif = [] 18 | disk = [] 19 | 20 | extra="server" 21 | -------------------------------------------------------------------------------- /xen/mini-os/lib/ctype.c: -------------------------------------------------------------------------------- 1 | #ifndef HAVE_LIBC 2 | #include <ctype.h> 3 | 4 | unsigned char _ctype[] = { 5 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ 6 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ 7 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ 8 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ 9 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ 10 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ 11 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ 12 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ 13 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ 14 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ 15 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ 16 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ 17 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ 18 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ 19 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ 20 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ 21 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ 22 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ 23 | _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ 24 | _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ 25 | _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ 26 | _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ 27 | _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ 28 | _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ 29 | #endif 30 | -------------------------------------------------------------------------------- /xen/mini-os/lib/stack_chk_fail.c: -------------------------------------------------------------------------------- 1 | #include <mini-os/kernel.h> 2 | #include <mini-os/console.h> 3 | 4 | void __stack_chk_fail(void) 5 | { 6 | printk("stack smashing detected\n"); 7 | do_exit(); 8 | } 9 | -------------------------------------------------------------------------------- /xen/mini-os/lock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * locks for newlib 3 | * 4 | * Samuel Thibault <Samuel.Thibault@eu.citrix.net>, July 20008 5 | */ 6 | 7 | #ifdef HAVE_LIBC 8 | 9 | #include <sys/lock.h> 10 | #include <sched.h> 11 | #include <wait.h> 12 | 13 | int ___lock_init(_LOCK_T *lock) 14 | { 15 | lock->busy = 0; 16 | init_waitqueue_head(&lock->wait); 17 | return 0; 18 | } 19 | 20 | int ___lock_acquire(_LOCK_T *lock) 21 | { 22 | unsigned long flags; 23 | while(1) { 24 | wait_event(lock->wait, !lock->busy); 25 | local_irq_save(flags); 26 | if (!lock->busy) 27 | break; 28 | local_irq_restore(flags); 29 | } 30 | lock->busy = 1; 31 | local_irq_restore(flags); 32 | return 0; 33 | } 34 | 35 | int ___lock_try_acquire(_LOCK_T *lock) 36 | { 37 | unsigned long flags; 38 | int ret = -1; 39 | local_irq_save(flags); 40 | if (!lock->busy) { 41 | lock->busy = 1; 42 | ret = 0; 43 | } 44 | local_irq_restore(flags); 45 | return ret; 46 | } 47 | 48 | int ___lock_release(_LOCK_T *lock) 49 | { 50 | unsigned long flags; 51 | local_irq_save(flags); 52 | lock->busy = 0; 53 | wake_up(&lock->wait); 54 | local_irq_restore(flags); 55 | return 0; 56 | } 57 | 58 | 59 | int ___lock_init_recursive(_LOCK_RECURSIVE_T *lock) 60 | { 61 | lock->owner = NULL; 62 | init_waitqueue_head(&lock->wait); 63 | return 0; 64 | } 65 | 66 | int ___lock_acquire_recursive(_LOCK_RECURSIVE_T *lock) 67 | { 68 | unsigned long flags; 69 | if (lock->owner != get_current()) { 70 | while (1) { 71 | wait_event(lock->wait, lock->owner == NULL); 72 | local_irq_save(flags); 73 | if (lock->owner == NULL) 74 | break; 75 | local_irq_restore(flags); 76 | } 77 | lock->owner = get_current(); 78 | local_irq_restore(flags); 79 | } 80 | lock->count++; 81 | return 0; 82 | } 83 | 84 | int ___lock_try_acquire_recursive(_LOCK_RECURSIVE_T *lock) 85 | { 86 | unsigned long flags; 87 | int ret = -1; 88 | local_irq_save(flags); 89 | if (!lock->owner) { 90 | ret = 0; 91 | lock->owner = get_current(); 92 | lock->count++; 93 | } 94 | local_irq_restore(flags); 95 | return ret; 96 | } 97 | 98 | int ___lock_release_recursive(_LOCK_RECURSIVE_T *lock) 99 | { 100 | unsigned long flags; 101 | BUG_ON(lock->owner != get_current()); 102 | if (--lock->count) 103 | return 0; 104 | local_irq_save(flags); 105 | lock->owner = NULL; 106 | wake_up(&lock->wait); 107 | local_irq_restore(flags); 108 | return 0; 109 | } 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /xen/mini-os/minios.mk: -------------------------------------------------------------------------------- 1 | # 2 | # The file contains the common make rules for building mini-os. 3 | # 4 | 5 | debug = y 6 | 7 | # Define some default flags. 8 | # NB. '-Wcast-qual' is nasty, so I omitted it. 9 | DEF_CFLAGS += -fno-builtin -Wall -Werror -Wredundant-decls -Wno-format -Wno-redundant-decls 10 | DEF_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,) 11 | DEF_CFLAGS += $(call cc-option,$(CC),-fgnu89-inline) 12 | DEF_CFLAGS += -Wstrict-prototypes -Wnested-externs -Wpointer-arith -Winline 13 | DEF_CPPFLAGS += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION) 14 | 15 | DEF_ASFLAGS += -D__ASSEMBLY__ 16 | DEF_LDFLAGS += 17 | 18 | ifeq ($(debug),y) 19 | DEF_CFLAGS += -g 20 | #DEF_CFLAGS += -DMM_DEBUG 21 | #DEF_CFLAGS += -DFS_DEBUG 22 | #DEF_CFLAGS += -DLIBC_DEBUG 23 | DEF_CFLAGS += -DGNT_DEBUG 24 | DEF_CFLAGS += -DGNTMAP_DEBUG 25 | else 26 | DEF_CFLAGS += -O3 27 | endif 28 | 29 | # Make the headers define our internal stuff 30 | DEF_CFLAGS += -D__INSIDE_MINIOS__ 31 | 32 | # Build the CFLAGS and ASFLAGS for compiling and assembling. 33 | # DEF_... flags are the common mini-os flags, 34 | # ARCH_... flags may be defined in arch/$(TARGET_ARCH_FAM/rules.mk 35 | CFLAGS := $(DEF_CFLAGS) $(ARCH_CFLAGS) 36 | CPPFLAGS := $(DEF_CPPFLAGS) $(ARCH_CPPFLAGS) 37 | ASFLAGS := $(DEF_ASFLAGS) $(ARCH_ASFLAGS) 38 | LDFLAGS := $(DEF_LDFLAGS) $(ARCH_LDFLAGS) 39 | 40 | # Special build dependencies. 41 | # Rebuild all after touching this/these file(s) 42 | EXTRA_DEPS = $(MINI-OS_ROOT)/minios.mk \ 43 | $(MINI-OS_ROOT)/$(TARGET_ARCH_DIR)/arch.mk 44 | 45 | # Find all header files for checking dependencies. 46 | HDRS := $(wildcard $(MINI-OS_ROOT)/include/*.h) 47 | HDRS += $(wildcard $(MINI-OS_ROOT)/include/xen/*.h) 48 | HDRS += $(wildcard $(ARCH_INC)/*.h) 49 | # For special wanted header directories. 50 | extra_heads := $(foreach dir,$(EXTRA_INC),$(wildcard $(dir)/*.h)) 51 | HDRS += $(extra_heads) 52 | 53 | # Add the special header directories to the include paths. 54 | override CPPFLAGS := $(CPPFLAGS) $(extra_incl) 55 | 56 | # The name of the architecture specific library. 57 | # This is on x86_32: libx86_32.a 58 | # $(ARCH_LIB) has to built in the architecture specific directory. 59 | ARCH_LIB_NAME = $(XEN_TARGET_ARCH) 60 | ARCH_LIB := lib$(ARCH_LIB_NAME).a 61 | 62 | # This object contains the entrypoint for startup from Xen. 63 | # $(HEAD_ARCH_OBJ) has to be built in the architecture specific directory. 64 | HEAD_ARCH_OBJ := $(XEN_TARGET_ARCH).o 65 | HEAD_OBJ := $(OBJ_DIR)/$(TARGET_ARCH_DIR)/$(HEAD_ARCH_OBJ) 66 | 67 | 68 | $(OBJ_DIR)/%.o: %.c $(HDRS) Makefile $(EXTRA_DEPS) 69 | $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ 70 | 71 | $(OBJ_DIR)/%.o: %.S $(HDRS) Makefile $(EXTRA_DEPS) 72 | $(CC) $(ASFLAGS) $(CPPFLAGS) -c $< -o $@ 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /xutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011 Anil Madhavapeddy <anil@recoil.org> 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | #include <stdbool.h> 27 | #include <stdio.h> 28 | 29 | void * xmalloc(size_t); 30 | void xread(int, void *, size_t); 31 | void xwrite(int, const void *, size_t); 32 | 33 | void setaffinity(int); 34 | void parse_args(int argc, char *argv[], bool *per_iter_timings, int *size, size_t *count, 35 | int *first_cpu, int *second_cpu, int *parallel, char **output_dir, int *wip, int *rip, int *prod, int *do_verify, 36 | int *numa_node); 37 | void *establish_shm_segment(int nr_pages, int numa_node); 38 | 39 | /* Doesn't really belong here, but doesn't really belong anywhere. */ 40 | void summarise_samples(FILE *f, double *data, int nr_samples); 41 | 42 | #ifndef PAGE_SIZE 43 | #define PAGE_SIZE 4096 44 | #endif 45 | --------------------------------------------------------------------------------
CPU model(s)# coresNUMA (# nodes)Operating systemVirtualizedDetailsRaw data