Barrelfish

changeset 362:ffe335a112d3

remove support for Beehive

see the mailing list discussion at the end of December 2011 for motivation
author Andrew Baumann <andrew.baumann@microsoft.com>
date Mon Jan 23 11:04:15 2012 -0800 (3 months ago)
parents df5797c6cafd
children c61156a06c77
files README capabilities/caps.hl doc/007-Beehive/Beehive.tex doc/007-Beehive/Hakefile errors/errno.fugu hake/Args.hs hake/Beehive.hs hake/RuleDefs.hs hake/beehive-dM-noSTDC.txt hake/beehive-dM.txt hake/menu.lst.beehive hake/symbolic_targets.mk if/arch/beehive.if if/intermon.if if/monitor.if if/platform/beehive.if include/Hakefile include/arch/beehive/_fpmath.h include/arch/beehive/arch/inttypes.h include/arch/beehive/arch/setjmp.h include/arch/beehive/arch/stdint.h include/arch/beehive/barrelfish/bmp_chan.h include/arch/beehive/barrelfish/bulk_transfer_arch.h include/arch/beehive/barrelfish/core_state_arch.h include/arch/beehive/barrelfish/cpu_arch.h include/arch/beehive/barrelfish/curdispatcher_arch.h include/arch/beehive/barrelfish/dispatcher_arch.h include/arch/beehive/barrelfish/invocations_arch.h include/arch/beehive/barrelfish/lmp_chan_arch.h include/arch/beehive/barrelfish/pmap_arch.h include/arch/beehive/barrelfish/syscall_arch.h include/arch/beehive/barrelfish_kpi/bmp.h include/arch/beehive/barrelfish_kpi/cpu_arch.h include/arch/beehive/barrelfish_kpi/dispatcher_shared_arch.h include/arch/beehive/barrelfish_kpi/generic_arch.h include/arch/beehive/barrelfish_kpi/lmp_arch.h include/arch/beehive/barrelfish_kpi/paging_arch.h include/arch/beehive/barrelfish_kpi/registers_arch.h include/arch/beehive/barrelfish_kpi/spinlocks_arch.h include/arch/beehive/barrelfish_kpi/unknown_arch.h include/arch/beehive/beej7.h include/arch/beehive/bench/bench_arch.h include/arch/beehive/corearea.h include/arch/beehive/dcache.h include/arch/beehive/fenv.h include/arch/beehive/float.h include/arch/beehive/machine/_limits.h include/arch/beehive/machine/endian.h include/arch/beehive/regconvention.h include/arch/beehive/simctrl.h include/arch/beehive/stopcode.h include/barrelfish/barrelfish.h include/barrelfish/caddr.h include/barrelfish/core_state.h include/barrelfish/dispatcher.h include/barrelfish/idc.h include/barrelfish/idc_export.h include/barrelfish/ump_impl.h include/barrelfish/vspace_mmu_aware.h include/barrelfish/waitset.h include/barrelfish_kpi/capabilities.h include/barrelfish_kpi/cpu.h include/barrelfish_kpi/init.h include/barrelfish_kpi/legacy_idc_buffer.h include/barrelfish_kpi/syscalls.h include/bexec.h include/flounder/flounder_support_bmp.h include/target/beehive/barrelfish/dispatcher_target.h include/target/beehive/barrelfish_kpi/coredata_target.h include/target/beehive/barrelfish_kpi/dispatcher_shared_target.h include/thc/thcinternal.h include/thc/thcsync.h include/trace/trace.h kernel/Hakefile kernel/arch/beehive/Hakefile kernel/arch/beehive/beekernel.h kernel/arch/beehive/bmp.h kernel/arch/beehive/boot.S kernel/arch/beehive/context.S kernel/arch/beehive/core1.S kernel/arch/beehive/dcache.S kernel/arch/beehive/exec.c kernel/arch/beehive/findbits.S kernel/arch/beehive/gdb_arch.c kernel/arch/beehive/hyper.c kernel/arch/beehive/init.c kernel/arch/beehive/kputchar.c kernel/arch/beehive/microbenchmarks.c kernel/arch/beehive/misc.c kernel/arch/beehive/page_mappings_arch.c kernel/arch/beehive/ringbmp.c kernel/arch/beehive/ringtest.S kernel/arch/beehive/serial.c kernel/arch/beehive/slave.S kernel/arch/beehive/slavecode.mem kernel/arch/beehive/startup_arch.c kernel/arch/beehive/syscall.c kernel/arch/x86/ipi_notify.c kernel/capabilities.c kernel/dispatch.c kernel/include/arch/beehive/arch_gdb_stub.h kernel/include/arch/beehive/conio.h kernel/include/arch/beehive/hyper.h kernel/include/arch/beehive/irq.h kernel/include/arch/beehive/kputchar.h kernel/include/arch/beehive/misc.h kernel/include/arch/beehive/offsets.h kernel/include/arch/beehive/paging_kernel_arch.h kernel/include/dispatch.h kernel/include/kernel.h lib/barrelfish/Hakefile lib/barrelfish/arch/beehive/bmp_chan.c lib/barrelfish/arch/beehive/cswitch.S lib/barrelfish/arch/beehive/dcache.S lib/barrelfish/arch/beehive/dcachergn.c lib/barrelfish/arch/beehive/debug.c lib/barrelfish/arch/beehive/dispatch.c lib/barrelfish/arch/beehive/entry.S lib/barrelfish/arch/beehive/findbits.S lib/barrelfish/arch/beehive/pmap_arch.c lib/barrelfish/arch/beehive/syscalls.S lib/barrelfish/arch/beehive/syscalls.c lib/barrelfish/capabilities.c lib/barrelfish/deferred.c lib/barrelfish/dispatch.c lib/barrelfish/domain.c lib/barrelfish/flounder_support.c lib/barrelfish/idc.c lib/barrelfish/include/arch/beehive/arch/registers.h lib/barrelfish/include/arch/beehive/arch/syscall.h lib/barrelfish/include/arch/beehive/arch/threads.h lib/barrelfish/include/threads.h lib/barrelfish/init.c lib/barrelfish/morecore.c lib/barrelfish/spawn_client.c lib/barrelfish/vspace/arch/beehive/layout.c lib/barrelfish/vspace/memobj_anon.c lib/barrelfish/vspace/memobj_pinned.c lib/barrelfish/vspace/mmu_aware.c lib/barrelfish/vspace/utils.c lib/barrelfish/vspace/vspace.c lib/bench/Hakefile lib/bench/arch/beehive/bench_arch.c lib/c/src/arch-beehive/jmp.S lib/c/src/gdtoa/beehive/arith.h lib/c/src/gdtoa/beehive/gd_qnan.h lib/c/src/sys-barrelfish/sys_morecore.c lib/crt/arch/beehive/crt0.S lib/crt/crtbegin.c lib/msun/beehive/fenv.c lib/spawndomain/Hakefile lib/spawndomain/arch/beehive/spawn_arch.c lib/spawndomain/multiboot.c lib/spawndomain/spawn.c lib/spawndomain/spawn_vspace.c lib/thc/thc.c lib/thc/thcsync.c tools/asmoffsets/asmoffsets.c tools/flounder/Arch.hs tools/flounder/BMP.hs tools/flounder/GCBackend.hs tools/flounder/GHBackend.hs tools/flounder/Main.lhs tools/harness/barrelfish.py tools/harness/machines/__init__.py tools/harness/machines/bsim.py usr/bench/bmp_bench/Hakefile usr/bench/bmp_bench/bb_pingpong.c usr/bench/bmp_bench/bb_test.c usr/bench/bmp_bench/bmpbench.c usr/bench/bmp_bench/bmpbench.h usr/bench/flounder_stubs/empty.c usr/init/Hakefile usr/init/init.c usr/init/spawn.c usr/init_null/Hakefile usr/init_null/init_null.c usr/mem_serv/Hakefile usr/mem_serv/mem_serv.c usr/mem_serv_dist/Hakefile usr/mem_serv_dist/mem_serv.h usr/monitor/Hakefile usr/monitor/arch/beehive/boot.c usr/monitor/arch/beehive/endpoint.c usr/monitor/arch/beehive/inter.c usr/monitor/arch/beehive/monitor_server.c usr/monitor/bmp_support.c usr/monitor/connection.h usr/monitor/include/arch/beehive/monitor_invocations.h usr/monitor/inter.c usr/monitor/main.c usr/monitor/monitor.h usr/monitor/monitor_server.c usr/monitor/rcap_db_common.c usr/monitor/spawn.c usr/ramfsd/main.c usr/spawnd/bsp_bootup.c
line diff
     1.1 --- a/README	Fri Jan 20 14:32:03 2012 -0800
     1.2 +++ b/README	Mon Jan 23 11:04:15 2012 -0800
     1.3 @@ -30,10 +30,9 @@
     1.4   * Lenovo X200 and X301 laptops
     1.5   * ASUS Eee PC 1015PEM netbooks
     1.6  
     1.7 -In addition, ports to the ARM and Beehive processor architectures are in
     1.8 -progress. These are less complete than the x86 and SCC ports, and are
     1.9 -not described in this document, but feel free to ask for help on the
    1.10 -mailing list.
    1.11 +In addition, a port to the ARM architectures is in progress. This is 
    1.12 +less complete than the x86 and SCC ports, and not described in this 
    1.13 +document, but feel free to ask for help on the mailing list.
    1.14  
    1.15  The e1000n driver should work with most recent Intel gigabit ethernet
    1.16  controllers (see the list in devices/e1000.dev). We've mostly used the
     2.1 --- a/capabilities/caps.hl	Fri Jan 20 14:32:03 2012 -0800
     2.2 +++ b/capabilities/caps.hl	Mon Jan 23 11:04:15 2012 -0800
     2.3 @@ -302,17 +302,6 @@
     2.4      eq uint16 chanid;
     2.5  };
     2.6  
     2.7 -/* Beehive HW message passing endpoint */
     2.8 -cap BMPEndPoint {
     2.9 -    eq uint8 coreid;
    2.10 -    eq uint16 chanid;
    2.11 -};
    2.12 -
    2.13 -cap BMPTable {
    2.14 -    /* BMP association table */
    2.15 -    is_always_copy;
    2.16 -};
    2.17 -
    2.18  cap Domain {
    2.19      /* Domain capability (opaque type, used by the monitors) */
    2.20      eq uint32 domainid;
     3.1 --- a/doc/007-Beehive/Beehive.tex	Fri Jan 20 14:32:03 2012 -0800
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,215 +0,0 @@
     3.4 -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     3.5 -% Copyright (c) 2011, ETH Zurich.
     3.6 -% All rights reserved.
     3.7 -%
     3.8 -% This file is distributed under the terms in the attached LICENSE file.
     3.9 -% If you do not find this file, copies can be found by writing to:
    3.10 -% ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
    3.11 -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    3.12 -
    3.13 -\documentclass[a4paper,twoside]{report} % for a report (default)
    3.14 -
    3.15 -\usepackage{bftn,color} % You need this
    3.16 -
    3.17 -\title{Barrelfish on the Beehive experimental platform}   % title of report
    3.18 -\author{Richard Black}	% author
    3.19 -\tnnumber{007}  % give the number of the tech report
    3.20 -\tnkey{Beehive} % Short title, will appear in footer
    3.21 -
    3.22 -% \date{Month Year} % Not needed - will be taken from version history
    3.23 -
    3.24 -%% \newcommand{\note}[1]{}
    3.25 -\newcommand{\note}[1]{[\textcolor{red}{\textit{#1}}]}
    3.26 -
    3.27 -\begin{document}
    3.28 -\maketitle
    3.29 -
    3.30 -%
    3.31 -% Include version history first
    3.32 -%
    3.33 -\begin{versionhistory}
    3.34 -\vhEntry{1.0}{14.06.2010}{RJB}{Initial version}
    3.35 -%\vhEntry{1.01}{14.06.2010}{AS}{Added discussion of design and unresolved issues}
    3.36 -\end{versionhistory}
    3.37 -
    3.38 -% \intro{Abstract}		% Insert abstract here
    3.39 -% \intro{Acknowledgements}	% Uncomment (if needed) for acknowledgements
    3.40 -% \tableofcontents		% Uncomment (if needed) for final draft
    3.41 -% \listoffigures		% Uncomment (if needed) for final draft
    3.42 -% \listoftables			% Uncomment (if needed) for final draft
    3.43 -
    3.44 -\chapter{Introduction}
    3.45 -
    3.46 -This report describes the port of the Barrlelfish operating system to
    3.47 -the Beehive multi-core experimental platform.
    3.48 -
    3.49 -\note{This is what a note does.}
    3.50 -
    3.51 -\note{summarise chapters}
    3.52 -
    3.53 -\note{executive summary}
    3.54 -
    3.55 -\chapter{Barrelfish implementation on Beehive}
    3.56 -
    3.57 -\section{Hypervisor}
    3.58 -
    3.59 -\section{Memory map}
    3.60 -
    3.61 -\section{System calls}
    3.62 -
    3.63 -\section{Timer interrupts}
    3.64 -
    3.65 -\section{BMP interconnect driver}
    3.66 -
    3.67 -\emph{Beehive} is an experimental FPGA-based multicore architecture
    3.68 -under development at Microsoft Research\cite{beehive:hwman} targeting
    3.69 -the RAMP BEE-3 platform\cite{davis:bee3}. The current design has 13
    3.70 -RISC cores on a ring network with a memory controller, gigabit
    3.71 -Ethernet, and other IO devices. Like SCC, each core has a private
    3.72 -non-coherent cache and hardware support for message passing. However,
    3.73 -Beehive's message-passing mechanism bypasses the caches and memory
    3.74 -system entirely.  Each core may directly send a message of up to 63
    3.75 -words to another core on the ring.  Incoming messages are placed in a
    3.76 -FIFO which can be cheaply (three cycles) polled. The FIFO holds 1024
    3.77 -words and has no hardware flow control -- software must ensure that it
    3.78 -does not overflow.
    3.79 -
    3.80 -As with SCC, the challenge for a Beehive interconnect driver is to
    3.81 -provide secure efficient multiplexing of the shared hardware message
    3.82 -channel.  We do this at two levels. Between CPU drivers, a single
    3.83 -point-to-point message channel is implemented with credit-based flow
    3.84 -control, with 64 words of the 1024-word buffer reserved for each
    3.85 -sender core.  User channels are multiplexed over this by prepending a
    3.86 -one-word header to each message. At user-level, the interconnect
    3.87 -driver similarly maintains an incoming message buffer. The generated
    3.88 -stubs pack message arguments into variable-length fragments of up to
    3.89 -57 words of payload (the remainder is used for headers or reserved for
    3.90 -credit messages), perform flow-control on the user-level buffer, and
    3.91 -handle incoming messages when notified by the interconnect driver.
    3.92 -
    3.93 -\subsection{Kernel BMP protocol}
    3.94 -
    3.95 -At the hardware level messages have a single word header containing
    3.96 -the length of the message, the core number and the type followed by
    3.97 -between 1 and 63 words of payload.  Messages of length zero are
    3.98 -reserved for communication between the master core and the debug unit.
    3.99 -A single type (2) is used for BMP messages.  Each core has a 1024 word
   3.100 -FIFO which must not overflow.
   3.101 -
   3.102 -To ensure that the FIFO does not overflow the kernel BMP components
   3.103 -use a credit based flow control mechanism.  The first word of the
   3.104 -message (after the hardware header) is divided into two fields; one of
   3.105 -which contains any credit being sent, and the other provides
   3.106 -demultiplexing into multiple user level channels.
   3.107 -
   3.108 -Each core is initialised with 64 words of credit for each other core
   3.109 -and once this is consumed transmission must wait for credit to be sent
   3.110 -from the destination.  The sending of a credit acknowledgement also
   3.111 -requires space in the destination FIFO and so itself consumes credit.
   3.112 -To avoid sending a credit acknowledgement for a credit
   3.113 -acknowledgement, credits are not sent if the available amount is less
   3.114 -than or equal to 2 words.
   3.115 -
   3.116 -When sending a message the code ensures that it has enough credit to
   3.117 -send the message and still have 2 words of credit remaining.  This
   3.118 -permits it to send an acknowledgement for the other core without first
   3.119 -having to wait for an acknowledgment from the other core, which seems
   3.120 -sufficient to avoid deadlocking (but may not strictly be necessary).
   3.121 -
   3.122 -The MTU for BMP messages is calculated as follows.  The hardware
   3.123 -supports 64 words, 62 plus kernel BMP header plus header, but this is
   3.124 -also the flow control limit.  Since we might have sent an ACK already
   3.125 -which is not acked a common value of credit is 62.  Since we have to
   3.126 -keep enough credit to be able to send an ACK subsequent to sending a
   3.127 -message, the maximum sized message is 60 words, i.e. 58 words of
   3.128 -payload.
   3.129 -
   3.130 -As a possible future change, we observe that core 0 is always the DRAM
   3.131 -controller, and cores do not need to send themselves messages,
   3.132 -therefore there are a maximum of 14 cores on the ring to divide out
   3.133 -the FIFO between.  This would permit 73 words of credit per core
   3.134 -rather than 64 which would translate into a kernel MTU of 67 instead
   3.135 -of 58 words.
   3.136 -
   3.137 -\subsection{Kernel BMP processing}
   3.138 -
   3.139 -The state machine for processing BMP has to take carefully into
   3.140 -consideration the fact that there are no interrupts for the FIFO, or
   3.141 -for timers, the multiplexed nature of the FIFO, and the neccessity to
   3.142 -receive credit in order to trasnmit.
   3.143 -
   3.144 -One entry point is when the core is idle; the FIFO should be processed
   3.145 -completely until it is idle with any incoming message potentially
   3.146 -causing a domain to become runnable and the scheduler then being
   3.147 -called.  Once the FIFO is idle it should continue to be polled until
   3.148 -the timer interrupt fire.  During this time credit acknowledgements
   3.149 -must be sent as appropriate.
   3.150 -
   3.151 -The second entry point is when a send is desired.  This has to deal
   3.152 -with the possibility that there is insufficient credit.  If there is
   3.153 -insufficient credit then the code must process messages, delivering
   3.154 -them on incoming channels, and sending and receiving credit, until
   3.155 -there is enough credit to send the required message.  Then the message
   3.156 -can be sent.  After the message is sent the FIFO must again be
   3.157 -processed until it is idle.
   3.158 -
   3.159 -Note that if a message is desired to be sent when there is
   3.160 -insufficient credit the code currently processes the FIO until there
   3.161 -is credit which can be a substantially long time.  An alternative
   3.162 -would be to return a ``busy'' code the caller which would have the
   3.163 -difficulty that it is impossible to subsequently advise when a retry
   3.164 -might succeed.
   3.165 -
   3.166 -To mitigate busy waiting on transmit the third entry point is called
   3.167 -on a timer tick before the scheduler is called.  This once again
   3.168 -processes the FIFO until it is idle (including the sending of
   3.169 -acknowledgements).  This processing has the benefit of providing the
   3.170 -scheduler with as much information as possible before the timer tick
   3.171 -is delivered.
   3.172 -
   3.173 -There is an additional entry point that currently for debug purposes
   3.174 -the \texttt{sys\_nop} system call also pumps messages from the FIFO.
   3.175 -
   3.176 -The \texttt{sys\_yield} call currently does not pump the FIFO, but
   3.177 -probably should.
   3.178 -
   3.179 -\subsection{User-level BMP component}
   3.180 -
   3.181 -\chapter{Performance measurements}
   3.182 -
   3.183 -Several unconventional features of Beehive make performance of any
   3.184 -communication system a challenge.  In particular, the small,
   3.185 -direct-mapped instruction cache and low instruction density mean 
   3.186 -I-cache miss rate tends to dominate performance.
   3.187 -We found that a single word echo between user programs on
   3.188 -different cores has a latency of 56k$\pm$1k cycles with more than 80\%
   3.189 -of this cost attributable to I-cache misses (each taking
   3.190 -$\approx54$ cycles).
   3.191 -
   3.192 -It is more instructive to look at the count of instructions executed,
   3.193 -even though instruction density is low.  It takes about 2900
   3.194 -instructions to send a request: 230 in user stubs,
   3.195 -630 in the capability invocation, 100 in sending the message, 600
   3.196 -returning from the system call, and 1300 for stubs, threads package
   3.197 -and kernel to idle. 
   3.198 -
   3.199 -The receive path is about 3200 instructions: 100
   3.200 -to receive the message in the CPU driver, 570 to look up the endpoint
   3.201 -capability and copy the message to the user's channel buffer, 480 to
   3.202 -make the process runnable, and a further 2000 to upcall the process
   3.203 -and dispatch the message through the stub to application code.
   3.204 -
   3.205 -While the performance of the processor is low, and both Barrelfish
   3.206 -and the FPGA processor core have scope for optimization,
   3.207 -the interconnect driver does provide secure multiplexed
   3.208 -messaging on this non-cache-coherent hardware at a cost which is low
   3.209 -considering the general cost of execution on the platform.
   3.210 -
   3.211 -
   3.212 -
   3.213 -\chapter{General observations}
   3.214 -
   3.215 -\bibliographystyle{abbrvnat}
   3.216 -\bibliography{defs,barrelfish}
   3.217 -
   3.218 -\end{document}
     4.1 --- a/doc/007-Beehive/Hakefile	Fri Jan 20 14:32:03 2012 -0800
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,13 +0,0 @@
     4.4 -----------------------------------------------------------------------
     4.5 --- Copyright (c) 2010, ETH Zurich.
     4.6 --- All rights reserved.
     4.7 ---
     4.8 --- This file is distributed under the terms in the attached LICENSE file.
     4.9 --- If you do not find this file, copies can be found by writing to:
    4.10 --- ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
    4.11 ---
    4.12 --- Hakefile for /doc/007-Beehive
    4.13 ---
    4.14 -----------------------------------------------------------------------
    4.15 -
    4.16 -[ buildTechNote "Beehive.tex" "TN-007-Beehive.pdf" True False [] ]
     5.1 --- a/errors/errno.fugu	Fri Jan 20 14:32:03 2012 -0800
     5.2 +++ b/errors/errno.fugu	Mon Jan 23 11:04:15 2012 -0800
     5.3 @@ -31,9 +31,6 @@
     5.4      failure LRPC_NOT_ENDPOINT   "Slot specified for LRPC does not contain an endpoint cap",
     5.5      failure INVALID_EPLEN       "Endpoint buffer has invalid length",
     5.6  
     5.7 -    // BMP (Beehive messaging)
     5.8 -    failure BMP_TX_BUSY         "BMP send failed; insufficient TX credits to remote core",
     5.9 -
    5.10      // XXX: this should go away -AB
    5.11      failure IDC_MSG_BOUNDS      "Attempted to retrieve a word beyond the size of an LMP message structure",
    5.12  
    5.13 @@ -81,12 +78,6 @@
    5.14      // IO capability
    5.15      failure IO_PORT_INVALID     "IO port out of range",
    5.16  
    5.17 -    // errors related to BMP table
    5.18 -    failure BMP_LOOKUP          "Specified capability was not found while inserting in IRQ table",
    5.19 -    failure BMP_NOT_ENDPOINT    "Specified capability is not an endpoint cap",
    5.20 -    failure BMP_NO_LISTENER     "No listener on specified endpoint cap", // ??
    5.21 -    failure BMP_INVALID         "BMP association ID out of range",
    5.22 -
    5.23      // Dispatcher setup and spawn core invocations
    5.24      failure DISP_CSPACE_ROOT    "Error setting CSpace root on dispatcher",
    5.25      failure DISP_CSPACE_INVALID "Invalid capability type given for CSpace root on dispatcher",
    5.26 @@ -244,7 +235,7 @@
    5.27      failure CORESET_NEW             "Failure in coreset_new()",
    5.28      failure CORESET_GET_NEXT_DONE   "No more elements left in coreset_get_next()",
    5.29  
    5.30 -    // IDC (and LMP/UMP/BMP channels)
    5.31 +    // IDC (and LMP/UMP channels)
    5.32      failure NO_LMP_MSG          "No LMP message available",
    5.33      failure LMP_RECV_BUF_OVERFLOW "LMP message in endpoint is longer than user-provided buffer",
    5.34      failure NO_UMP_MSG          "No UMP message available",
    5.35 @@ -261,18 +252,13 @@
    5.36      failure CHAN_DEREGISTER_RECV "Failure in *_chan_deregister_recv()",
    5.37      failure LMP_CHAN_INIT       "Failure in lmp_chan_init()",
    5.38      failure UMP_CHAN_INIT       "Failure in ump_chan_init()",
    5.39 -    failure BMP_CHAN_INIT       "Failure in bmp_chan_init()",
    5.40      failure LMP_CHAN_RECV       "Failure in lmp_chan_recv()",
    5.41      failure UMP_CHAN_RECV       "Failure in ump_chan_recv()",
    5.42 -    failure BMP_CHAN_RECV       "Failure in bmp_chan_recv()",
    5.43      failure LMP_CHAN_SEND       "Failure in lmp_chan_send()",
    5.44 -    failure BMP_CHAN_SEND       "Failure in bmp_chan_send()",
    5.45      failure LMP_CHAN_BIND       "Failure in lmp_chan_bind()",
    5.46      failure UMP_CHAN_BIND       "Failure in ump_chan_bind()",
    5.47 -    failure BMP_CHAN_BIND       "Failure in bmp_chan_bind()",
    5.48      failure LMP_CHAN_ACCEPT     "Failure in lmp_chan_accept()",
    5.49      failure UMP_CHAN_ACCEPT     "Failure in ump_chan_accept()",
    5.50 -    failure BMP_CHAN_ACCEPT     "Failure in bmp_chan_accept()",
    5.51      failure LMP_ALLOC_RECV_SLOT "Failure in lmp_chan_alloc_recv_slot()",
    5.52      failure LMP_NOT_CONNECTED   "Channel is disconnected",
    5.53      failure MSGBUF_OVERFLOW     "Attempted to demarshall beyond bounds of message buffer",
    5.54 @@ -286,13 +272,10 @@
    5.55      failure NAMESERVICE_NOT_BOUND "Name service client is not bound",
    5.56      failure BIND_LMP_REQ        "Failure sending bind_lmp_request to monitor",
    5.57      failure BIND_UMP_REQ        "Failure sending bind_ump_request to monitor",
    5.58 -    failure BIND_BMP_REQ        "Failure sending bind_bmp_request to monitor",
    5.59      failure BIND_LMP_REPLY      "Failure sending bind_lmp_reply to monitor",
    5.60      failure BIND_UMP_REPLY      "Failure sending bind_ump_reply to monitor",
    5.61 -    failure BIND_BMP_REPLY      "Failure sending bind_bmp_reply to monitor",
    5.62      failure NO_LMP_BIND_HANDLER "LMP connection handler not registered for this service",
    5.63      failure NO_UMP_BIND_HANDLER "UMP connection handler not registered for this service",
    5.64 -    failure NO_BMP_BIND_HANDLER "BMP connection handler not registered for this service",
    5.65      failure MONITOR_CAP_SEND    "Failed sending capability via monitor",
    5.66      failure MONITOR_RPC_BIND    "Error in monitor_rpc_init()",
    5.67  
    5.68 @@ -604,7 +587,6 @@
    5.69      failure COPY_PACN_CAP       "Failed to copy phys addr CNode cap to monitor",
    5.70      failure COPY_IRQ_CAP        "Failed to copy IRQ cap to monitor",
    5.71      failure COPY_IO_CAP         "Failed to copy IO cap to monitor",
    5.72 -    failure COPY_BMP_CAP        "Failed to copy BMP cap to monitor",
    5.73      failure COPY_UMP_CAP        "Failed to copy UMP cap to monitor",
    5.74      failure NO_MATCHING_RAM_CAP "No suitably-sized RAM cap found when initialising local memory allocator",
    5.75  };
     6.1 --- a/hake/Args.hs	Fri Jan 20 14:32:03 2012 -0800
     6.2 +++ b/hake/Args.hs	Mon Jan 23 11:04:15 2012 -0800
     6.3 @@ -68,12 +68,12 @@
     6.4        architectures = allArchitectures
     6.5  }
     6.6  
     6.7 -allArchitectures = [ "x86_64", "x86_32", "arm", "arm11mp", "beehive", "scc", "xscale" ]
     6.8 -allArchitectureFamilies = [ "x86_64", "x86_32", "arm", "beehive", "scc" ]
     6.9 +allArchitectures = [ "x86_64", "x86_32", "arm", "arm11mp", "scc", "xscale" ]
    6.10 +allArchitectureFamilies = [ "x86_64", "x86_32", "arm", "scc" ]
    6.11  
    6.12  -- all known flounder backends that we might want to generate defs for
    6.13  allFlounderBackends
    6.14 -    = [ "lmp", "ump", "ump_ipi", "bmp", "loopback", "rpcclient", "msgbuf", "multihop", "ahci" ]
    6.15 +    = [ "lmp", "ump", "ump_ipi", "loopback", "rpcclient", "msgbuf", "multihop", "ahci" ]
    6.16  
    6.17  defaultBuildFn :: [String] -> String -> Args -> HRule
    6.18  defaultBuildFn _ f _ = 
     7.1 --- a/hake/Beehive.hs	Fri Jan 20 14:32:03 2012 -0800
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,179 +0,0 @@
     7.4 ---------------------------------------------------------------------------
     7.5 --- Copyright (c) 2009, 2010, ETH Zurich.
     7.6 --- All rights reserved.
     7.7 ---
     7.8 --- This file is distributed under the terms in the attached LICENSE file.
     7.9 --- If you do not find this file, copies can be found by writing to:
    7.10 --- ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
    7.11 ---
    7.12 --- Architectural definitions for Barrelfish on Beehive.
    7.13 --- 
    7.14 ---------------------------------------------------------------------------
    7.15 -
    7.16 -module Beehive where
    7.17 -
    7.18 -import List
    7.19 -import HakeTypes
    7.20 -import Path
    7.21 -import qualified Config
    7.22 -import qualified ArchDefaults
    7.23 -
    7.24 --------------------------------------------------------------------------
    7.25 ---
    7.26 --- Architecture specific definitions for Beehive
    7.27 ---
    7.28 --------------------------------------------------------------------------
    7.29 -
    7.30 -arch = "beehive"
    7.31 -archFamily = "beehive"
    7.32 -
    7.33 -cpp      = "cpp"
    7.34 -compiler = "Bcc"
    7.35 -cxxcompiler = "Bcc"
    7.36 -objcopy  = "Beehive-is-not-a-gnu-bfd-target"
    7.37 -objdump  = "Beehive-is-not-a-gnu-bfd-target"
    7.38 -ar       = "Bar"
    7.39 -ranlib   = "Branlib"
    7.40 -
    7.41 -
    7.42 -ourCommonFlags = [ Str "-fno-omit-frame-pointer" ]
    7.43 -ourExcludeFlags = [ Str "-Ulinux", Str "-U__linux__", Str "-g" ]
    7.44 -
    7.45 -
    7.46 -cFlags = [ f | f <- ( ArchDefaults.commonCFlags ++ 
    7.47 -                      ArchDefaults.commonFlags ++ 
    7.48 -                      ourCommonFlags ) \\ ourExcludeFlags ]
    7.49 -
    7.50 -cxxFlags = [ f | f <- ( ArchDefaults.commonCxxFlags ++ 
    7.51 -                        ArchDefaults.commonFlags ++ 
    7.52 -                        ourCommonFlags ) \\ ourExcludeFlags ]
    7.53 -
    7.54 -cDefines = ArchDefaults.cDefines options
    7.55 -cStdIncs = ArchDefaults.cStdIncs arch archFamily
    7.56 -
    7.57 -ldFlags = [ Str $ unwords $ (words Config.cOptFlags) \\ ["-g"],
    7.58 -            Str "-Wl,-N",
    7.59 -            Str "-Wl,-codebase=0", Str "-Wl,-datafloat",
    7.60 -            In InstallTree arch "/lib/crt0.o",
    7.61 -            In InstallTree arch "/lib/crtbegin.o", 
    7.62 -            Str "-fno-builtin" ]
    7.63 -
    7.64 -ldCxxFlags = ldFlags
    7.65 -
    7.66 -stdLibs = ArchDefaults.stdLibs arch 
    7.67 -          ++ [ Str "-lgcc" ]
    7.68 -
    7.69 -options = (ArchDefaults.options arch archFamily) { 
    7.70 -            optFlags = cFlags,
    7.71 -            optCxxFlags = cxxFlags,
    7.72 -            optDefines = cDefines,
    7.73 -            optLdFlags = ldFlags,
    7.74 -            optLdCxxFlags = ldCxxFlags,
    7.75 -            optLibs = stdLibs,
    7.76 -            optInterconnectDrivers = ["lmp", "bmp"],
    7.77 -            optFlounderBackends = ["lmp", "bmp"]
    7.78 -          }
    7.79 -
    7.80 ---
    7.81 --- The kernel is "different"
    7.82 ---
    7.83 -
    7.84 -kernelCFlags = [ Str s | s <- [ "-fno-builtin",
    7.85 -                                "-fno-omit-frame-pointer",
    7.86 -                                "-nostdinc",
    7.87 -                                "-std=c99",
    7.88 -                                "-Wall",
    7.89 -                                "-Wshadow",
    7.90 -                                "-Wstrict-prototypes",
    7.91 -                                "-Wold-style-definition",
    7.92 -                                "-Wmissing-prototypes",
    7.93 -                                "-Wmissing-declarations",
    7.94 -                                "-Wmissing-field-initializers",
    7.95 -                                "-Wredundant-decls",
    7.96 -                                "-Werror",
    7.97 -                                "-imacros deputy/nodeputy.h" ]]
    7.98 -                                -- "-Wmissing-noreturn" ]]
    7.99 -
   7.100 -kernelLdFlags = [ Str "-Wl,-N",
   7.101 -                  Str "-Wl,-codebase=2000", Str "-Wl,-datafloat",
   7.102 -                  NStr "-Wl,-map,", Out arch "kernel.map",
   7.103 -                  Str "-fno-builtin"
   7.104 -                ]
   7.105 -
   7.106 -
   7.107 -------------------------------------------------------------------------
   7.108 ---
   7.109 --- Now, commands to actually do something
   7.110 ---
   7.111 -------------------------------------------------------------------------
   7.112 -
   7.113 ---
   7.114 --- Compilers
   7.115 ---
   7.116 -cCompiler = ArchDefaults.cCompiler arch compiler
   7.117 -cPreprocessor = ArchDefaults.cPreprocessor arch compiler
   7.118 -cxxCompiler = ArchDefaults.cxxCompiler arch cxxcompiler
   7.119 -cToAssembler = ArchDefaults.cToAssembler arch compiler
   7.120 -assembler = ArchDefaults.assembler arch compiler
   7.121 -linker = ArchDefaults.linker arch compiler
   7.122 -cxxlinker = ArchDefaults.cxxlinker arch cxxcompiler
   7.123 -
   7.124 ---
   7.125 --- Create a library from a set of object files
   7.126 ---
   7.127 -
   7.128 ---
   7.129 --- Create a library from a set of object files
   7.130 ---
   7.131 -archive :: Options -> [String] -> String -> [ RuleToken ]
   7.132 -archive opts objs libname =
   7.133 -    [ Str "rm -f ", Out arch libname ]
   7.134 -    ++ 
   7.135 -    [ NL, Str (ar ++ " cr "), Out arch libname ] 
   7.136 -    ++ 
   7.137 -    [ In BuildTree arch o | o <- objs ]
   7.138 -    ++ 
   7.139 -    [ NL, Str ranlib, Out arch libname ]
   7.140 -
   7.141 ---
   7.142 --- Create C file dependencies
   7.143 ---
   7.144 -makeDepend opts phase src obj depfile =
   7.145 -    let incls = (optIncludes opts) ++ (extraIncludes opts)
   7.146 -        flags = (optFlags opts) 
   7.147 -                ++ (optDefines opts)
   7.148 -                ++ [ Str f | f <- extraFlags opts ]
   7.149 -                ++ [ Str f | f <- extraDefines opts ]
   7.150 -        cpp_undef = "-undef -U__unix -U__unix__ -Uunix -U__CYGWIN__ -U__CYGWIN32__"
   7.151 -    in
   7.152 -      [ Str ('@':cpp), Str cpp_undef,
   7.153 -        Str "-imacros", NoDep SrcTree "src" "/hake/beehive-dM-noSTDC.txt" ]
   7.154 -      ++ filter (\f -> not (isPrefixOf "-Wmissing-field-initializers" (formatToken f))) flags
   7.155 -      ++ [ Str "-nostdinc -std=c99 -imacros" ] 
   7.156 -      ++ [ NoDep SrcTree "src" "/include/deputy/nodeputy.h" ]
   7.157 -      ++ concat [ [ NStr "-I", i ] | i <- incls ] 
   7.158 -      ++ (optDependencies opts) ++ (extraDependencies opts)
   7.159 -      ++ [ Str "-M -MF", 
   7.160 -           Out arch depfile,
   7.161 -           Str "-MQ", NoDep BuildTree arch obj, 
   7.162 -           Str "-MQ", NoDep BuildTree arch depfile,
   7.163 -           In (if phase == "src" then SrcTree else BuildTree) phase src
   7.164 -         ] 
   7.165 -
   7.166 -makeCxxDepend = makeDepend
   7.167 -
   7.168 ---
   7.169 --- Link the kernel (CPU Driver)
   7.170 --- 
   7.171 -
   7.172 -linkKernel :: Options -> [String] -> [String] -> String -> HRule
   7.173 -linkKernel opts objs libs kbin = 
   7.174 -    Rules [ Rule (
   7.175 -           [ Str compiler ]
   7.176 -           ++ (optLdFlags opts)
   7.177 -           ++ (extraLdFlags opts)
   7.178 -           ++ [ Str "-o", Out arch kbin ]
   7.179 -           ++ [ In BuildTree arch o | o <- objs ]
   7.180 -           ++ [ In BuildTree arch l | l <- libs ]
   7.181 -           ++ [ Str "-lgcc" ]
   7.182 -    ) ]
     8.1 --- a/hake/RuleDefs.hs	Fri Jan 20 14:32:03 2012 -0800
     8.2 +++ b/hake/RuleDefs.hs	Mon Jan 23 11:04:15 2012 -0800
     8.3 @@ -19,7 +19,6 @@
     8.4  import qualified SCC
     8.5  import qualified ARM
     8.6  import qualified ARM11MP
     8.7 -import qualified Beehive
     8.8  import qualified XScale
     8.9  import HakeTypes
    8.10  import qualified Args
    8.11 @@ -81,7 +80,6 @@
    8.12  options "scc" = SCC.options
    8.13  options "arm" = ARM.options
    8.14  options "arm11mp" = ARM11MP.options
    8.15 -options "beehive" = Beehive.options
    8.16  options "xscale" = XScale.options
    8.17  
    8.18  kernelCFlags "x86_64" = X86_64.kernelCFlags
    8.19 @@ -89,7 +87,6 @@
    8.20  kernelCFlags "scc" = SCC.kernelCFlags
    8.21  kernelCFlags "arm" = ARM.kernelCFlags
    8.22  kernelCFlags "arm11mp" = ARM11MP.kernelCFlags
    8.23 -kernelCFlags "beehive" = Beehive.kernelCFlags
    8.24  kernelCFlags "xscale" = XScale.kernelCFlags
    8.25  
    8.26  kernelLdFlags "x86_64" = X86_64.kernelLdFlags
    8.27 @@ -97,7 +94,6 @@
    8.28  kernelLdFlags "scc" = SCC.kernelLdFlags
    8.29  kernelLdFlags "arm" = ARM.kernelLdFlags
    8.30  kernelLdFlags "arm11mp" = ARM11MP.kernelLdFlags
    8.31 -kernelLdFlags "beehive" = Beehive.kernelLdFlags
    8.32  kernelLdFlags "xscale" = XScale.kernelLdFlags
    8.33  
    8.34  archFamily :: String -> String
    8.35 @@ -168,13 +164,11 @@
    8.36      | optArch opts == "scc"     = SCC.cCompiler opts phase src obj
    8.37      | optArch opts == "arm"     = ARM.cCompiler opts phase src obj
    8.38      | optArch opts == "arm11mp" = ARM11MP.cCompiler opts phase src obj
    8.39 -    | optArch opts == "beehive" = Beehive.cCompiler opts phase src obj
    8.40      | optArch opts == "xscale" = XScale.cCompiler opts phase src obj
    8.41      | otherwise = [ ErrorMsg ("no C compiler for " ++ (optArch opts)) ]
    8.42  
    8.43  cPreprocessor :: Options -> String -> String -> String -> [ RuleToken ]
    8.44  cPreprocessor opts phase src obj
    8.45 -    | optArch opts == "beehive" = Beehive.cPreprocessor opts phase src obj
    8.46      | otherwise = [ ErrorMsg ("no C preprocessor for " ++ (optArch opts)) ]
    8.47  
    8.48  --
    8.49 @@ -183,7 +177,6 @@
    8.50  cxxCompiler :: Options -> String -> String -> String -> [ RuleToken ]
    8.51  cxxCompiler opts phase src obj
    8.52      | optArch opts == "x86_64"  = X86_64.cxxCompiler opts phase src obj
    8.53 -    | optArch opts == "beehive" = Beehive.cxxCompiler opts phase src obj
    8.54      | otherwise = [ ErrorMsg ("no C++ compiler for " ++ (optArch opts)) ]
    8.55  
    8.56  
    8.57 @@ -202,8 +195,6 @@
    8.58          ARM.makeDepend opts phase src obj depfile
    8.59      | optArch opts == "arm11mp" = 
    8.60          ARM11MP.makeDepend opts phase src obj depfile
    8.61 -    | optArch opts == "beehive" = 
    8.62 -        Beehive.makeDepend opts phase src obj depfile
    8.63      | optArch opts == "xscale" = 
    8.64          XScale.makeDepend opts phase src obj depfile
    8.65      | otherwise = [ ErrorMsg ("no dependency generator for " ++ (optArch opts)) ]
    8.66 @@ -212,8 +203,6 @@
    8.67  makeCxxDepend opts phase src obj depfile
    8.68      | optArch opts == "x86_64" = 
    8.69          X86_64.makeCxxDepend opts phase src obj depfile
    8.70 -    | optArch opts == "beehive" = 
    8.71 -        Beehive.makeCxxDepend opts phase src obj depfile
    8.72      | otherwise = [ ErrorMsg ("no C++ dependency generator for " ++ (optArch opts)) ]
    8.73  
    8.74  cToAssembler :: Options -> String -> String -> String -> String -> [ RuleToken ]
    8.75 @@ -223,7 +212,6 @@
    8.76      | optArch opts == "scc"     = SCC.cToAssembler opts phase src afile objdepfile
    8.77      | optArch opts == "arm"     = ARM.cToAssembler opts phase src afile objdepfile
    8.78      | optArch opts == "arm11mp" = ARM11MP.cToAssembler opts phase src afile objdepfile
    8.79 -    | optArch opts == "beehive" = Beehive.cToAssembler opts phase src afile objdepfile
    8.80      | optArch opts == "xscale" = XScale.cToAssembler opts phase src afile objdepfile
    8.81      | otherwise = [ ErrorMsg ("no C compiler for " ++ (optArch opts)) ]
    8.82  
    8.83 @@ -237,7 +225,6 @@
    8.84      | optArch opts == "scc"     = SCC.assembler opts src obj
    8.85      | optArch opts == "arm"     = ARM.assembler opts src obj
    8.86      | optArch opts == "arm11mp" = ARM11MP.assembler opts src obj
    8.87 -    | optArch opts == "beehive" = Beehive.assembler opts src obj
    8.88      | optArch opts == "xscale" = XScale.assembler opts src obj
    8.89      | otherwise = [ ErrorMsg ("no assembler for " ++ (optArch opts)) ]
    8.90  
    8.91 @@ -248,7 +235,6 @@
    8.92      | optArch opts == "scc"     = SCC.archive opts objs libname
    8.93      | optArch opts == "arm"     = ARM.archive opts objs libname
    8.94      | optArch opts == "arm11mp" = ARM11MP.archive opts objs libname
    8.95 -    | optArch opts == "beehive" = Beehive.archive opts objs libname
    8.96      | optArch opts == "xscale" = XScale.archive opts objs libname
    8.97      | otherwise = [ ErrorMsg ("Can't build a library for " ++ (optArch opts)) ]
    8.98  
    8.99 @@ -259,7 +245,6 @@
   8.100      | optArch opts == "scc"    = SCC.linker opts objs libs bin
   8.101      | optArch opts == "arm" = ARM.linker opts objs libs bin
   8.102      | optArch opts == "arm11mp" = ARM11MP.linker opts objs libs bin
   8.103 -    | optArch opts == "beehive" = Beehive.linker opts objs libs bin
   8.104      | optArch opts == "xscale" = XScale.linker opts objs libs bin
   8.105      | otherwise = [ ErrorMsg ("Can't link executables for " ++ (optArch opts)) ]
   8.106  
   8.107 @@ -720,7 +705,6 @@
   8.108      | optArch opts == "scc"    = SCC.linkKernel opts objs [libraryPath l | l <- libs ] kernelPath
   8.109      | optArch opts == "arm" = ARM.linkKernel opts objs [libraryPath l | l <- libs ] kernelPath
   8.110      | optArch opts == "arm11mp" = ARM11MP.linkKernel opts objs [libraryPath l | l <- libs ] kernelPath
   8.111 -    | optArch opts == "beehive" = Beehive.linkKernel opts objs [libraryPath l | l <- libs ] kernelPath
   8.112      | optArch opts == "xscale" = XScale.linkKernel opts objs [libraryPath l | l <- libs ] kernelPath
   8.113      | otherwise = 
   8.114          Rule [ Str ("Error: Can't link kernel for '" ++ (optArch opts) ++ "'") ]
     9.1 --- a/hake/beehive-dM-noSTDC.txt	Fri Jan 20 14:32:03 2012 -0800
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,104 +0,0 @@
     9.4 -#define __DBL_MIN_EXP__ (-1021)
     9.5 -#define __FLT_MIN__ 1.17549435e-38F
     9.6 -#define __DEC64_DEN__ 0.000000000000001E-383DD
     9.7 -#define __CHAR_BIT__ 8
     9.8 -#define __WCHAR_MAX__ 2147483647
     9.9 -#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
    9.10 -#define __FLT_EVAL_METHOD__ 0
    9.11 -#define __DBL_MIN_10_EXP__ (-307)
    9.12 -#define __FINITE_MATH_ONLY__ 0
    9.13 -#define __GNUC_PATCHLEVEL__ 3
    9.14 -#define __DEC64_MAX_EXP__ 384
    9.15 -#define __SHRT_MAX__ 32767
    9.16 -#define __LDBL_MAX__ 1.7976931348623157e+308L
    9.17 -#define __UINTMAX_TYPE__ long long unsigned int
    9.18 -#define __DEC32_EPSILON__ 1E-6DF
    9.19 -#define __CHAR_UNSIGNED__ 1
    9.20 -#define __LDBL_MAX_EXP__ 1024
    9.21 -#define __SCHAR_MAX__ 127
    9.22 -#define __DBL_DIG__ 15
    9.23 -#define __SIZEOF_INT__ 4
    9.24 -#define __SIZEOF_POINTER__ 4
    9.25 -#define __USER_LABEL_PREFIX__ _
    9.26 -#define __LDBL_HAS_INFINITY__ 1
    9.27 -#define __BEEHIVE__ 1
    9.28 -#define __FLT_EPSILON__ 1.19209290e-7F
    9.29 -#define __LDBL_MIN__ 2.2250738585072014e-308L
    9.30 -#define __DEC32_MAX__ 9.999999E96DF
    9.31 -#define __SIZEOF_LONG__ 4
    9.32 -#define __DECIMAL_DIG__ 17
    9.33 -#define __LDBL_HAS_QUIET_NAN__ 1
    9.34 -#define __GNUC__ 4
    9.35 -#define __FLT_HAS_DENORM__ 1
    9.36 -#define __SIZEOF_LONG_DOUBLE__ 8
    9.37 -#define __DBL_MAX__ 1.7976931348623157e+308
    9.38 -#define __DBL_HAS_INFINITY__ 1
    9.39 -#define __DEC32_MIN_EXP__ (-95)
    9.40 -#define __LDBL_HAS_DENORM__ 1
    9.41 -#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
    9.42 -#define __USING_SJLJ_EXCEPTIONS__ 1
    9.43 -#define __DEC32_MIN__ 1E-95DF
    9.44 -#define __DBL_MAX_EXP__ 1024
    9.45 -#define __DEC128_EPSILON__ 1E-33DL
    9.46 -#define __LONG_LONG_MAX__ 9223372036854775807LL
    9.47 -#define __SIZEOF_SIZE_T__ 4
    9.48 -#define __SIZEOF_WINT_T__ 4
    9.49 -#define __GXX_ABI_VERSION 1002
    9.50 -#define __FLT_MIN_EXP__ (-125)
    9.51 -#define __DBL_MIN__ 2.2250738585072014e-308
    9.52 -#define __DEC128_MIN__ 1E-6143DL
    9.53 -#define __REGISTER_PREFIX__ 
    9.54 -#define __DBL_HAS_DENORM__ 1
    9.55 -#define __NO_INLINE__ 1
    9.56 -#define __FLT_MANT_DIG__ 24
    9.57 -#define __VERSION__ "4.3.3"
    9.58 -#define __DEC64_EPSILON__ 1E-15DD
    9.59 -#define __DEC128_MIN_EXP__ (-6143)
    9.60 -#define __SIZE_TYPE__ unsigned int
    9.61 -#define __DEC32_DEN__ 0.000001E-95DF
    9.62 -#define __ELF__ 1
    9.63 -#define __FLT_RADIX__ 2
    9.64 -#define __LDBL_EPSILON__ 2.2204460492503131e-16L
    9.65 -#define __SIZEOF_PTRDIFF_T__ 4
    9.66 -#define __FLT_HAS_QUIET_NAN__ 1
    9.67 -#define __FLT_MAX_10_EXP__ 38
    9.68 -#define __LONG_MAX__ 2147483647L
    9.69 -#define __FLT_HAS_INFINITY__ 1
    9.70 -#define __DEC64_MAX__ 9.999999999999999E384DD
    9.71 -#define __DEC64_MANT_DIG__ 16
    9.72 -#define __DEC32_MAX_EXP__ 96
    9.73 -#define __DEC128_DEN__ 0.000000000000000000000000000000001E-6143DL
    9.74 -#define __LDBL_MANT_DIG__ 53
    9.75 -#define __DBL_HAS_QUIET_NAN__ 1
    9.76 -#define __WCHAR_TYPE__ int
    9.77 -#define __SIZEOF_FLOAT__ 4
    9.78 -#define __DEC64_MIN_EXP__ (-383)
    9.79 -#define __FLT_DIG__ 6
    9.80 -#define __INT_MAX__ 2147483647
    9.81 -#define __FLT_MAX_EXP__ 128
    9.82 -#define __DBL_MANT_DIG__ 53
    9.83 -#define __DEC64_MIN__ 1E-383DD
    9.84 -#define __WINT_TYPE__ unsigned int
    9.85 -#define __SIZEOF_SHORT__ 2
    9.86 -#define __LDBL_MIN_EXP__ (-1021)
    9.87 -#define __LDBL_MAX_10_EXP__ 308
    9.88 -#define __DBL_EPSILON__ 2.2204460492503131e-16
    9.89 -#define __SIZEOF_WCHAR_T__ 4
    9.90 -#define __DEC_EVAL_METHOD__ 2
    9.91 -#define __INTMAX_MAX__ 9223372036854775807LL
    9.92 -#define __FLT_DENORM_MIN__ 1.40129846e-45F
    9.93 -#define __FLT_MAX__ 3.40282347e+38F
    9.94 -#define __SIZEOF_DOUBLE__ 8
    9.95 -#define __FLT_MIN_10_EXP__ (-37)
    9.96 -#define __INTMAX_TYPE__ long long int
    9.97 -#define __DEC128_MAX_EXP__ 6144
    9.98 -#define __GNUC_MINOR__ 3
    9.99 -#define __DEC32_MANT_DIG__ 7
   9.100 -#define __DBL_MAX_10_EXP__ 308
   9.101 -#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
   9.102 -#define __PTRDIFF_TYPE__ int
   9.103 -#define __DEC128_MANT_DIG__ 34
   9.104 -#define __LDBL_MIN_10_EXP__ (-307)
   9.105 -#define __SIZEOF_LONG_LONG__ 8
   9.106 -#define __LDBL_DIG__ 15
   9.107 -#define __GNUC_GNU_INLINE__ 1
    10.1 --- a/hake/beehive-dM.txt	Fri Jan 20 14:32:03 2012 -0800
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,106 +0,0 @@
    10.4 -#define __DBL_MIN_EXP__ (-1021)
    10.5 -#define __FLT_MIN__ 1.17549435e-38F
    10.6 -#define __DEC64_DEN__ 0.000000000000001E-383DD
    10.7 -#define __CHAR_BIT__ 8
    10.8 -#define __WCHAR_MAX__ 2147483647
    10.9 -#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
   10.10 -#define __FLT_EVAL_METHOD__ 0
   10.11 -#define __DBL_MIN_10_EXP__ (-307)
   10.12 -#define __FINITE_MATH_ONLY__ 0
   10.13 -#define __GNUC_PATCHLEVEL__ 3
   10.14 -#define __DEC64_MAX_EXP__ 384
   10.15 -#define __SHRT_MAX__ 32767
   10.16 -#define __LDBL_MAX__ 1.7976931348623157e+308L
   10.17 -#define __UINTMAX_TYPE__ long long unsigned int
   10.18 -#define __DEC32_EPSILON__ 1E-6DF
   10.19 -#define __CHAR_UNSIGNED__ 1
   10.20 -#define __LDBL_MAX_EXP__ 1024
   10.21 -#define __SCHAR_MAX__ 127
   10.22 -#define __DBL_DIG__ 15
   10.23 -#define __SIZEOF_INT__ 4
   10.24 -#define __SIZEOF_POINTER__ 4
   10.25 -#define __USER_LABEL_PREFIX__ _
   10.26 -#define __STDC_HOSTED__ 1
   10.27 -#define __LDBL_HAS_INFINITY__ 1
   10.28 -#define __BEEHIVE__ 1
   10.29 -#define __FLT_EPSILON__ 1.19209290e-7F
   10.30 -#define __LDBL_MIN__ 2.2250738585072014e-308L
   10.31 -#define __DEC32_MAX__ 9.999999E96DF
   10.32 -#define __SIZEOF_LONG__ 4
   10.33 -#define __DECIMAL_DIG__ 17
   10.34 -#define __LDBL_HAS_QUIET_NAN__ 1
   10.35 -#define __GNUC__ 4
   10.36 -#define __FLT_HAS_DENORM__ 1
   10.37 -#define __SIZEOF_LONG_DOUBLE__ 8
   10.38 -#define __DBL_MAX__ 1.7976931348623157e+308
   10.39 -#define __DBL_HAS_INFINITY__ 1
   10.40 -#define __DEC32_MIN_EXP__ (-95)
   10.41 -#define __LDBL_HAS_DENORM__ 1
   10.42 -#define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL
   10.43 -#define __USING_SJLJ_EXCEPTIONS__ 1
   10.44 -#define __DEC32_MIN__ 1E-95DF
   10.45 -#define __DBL_MAX_EXP__ 1024
   10.46 -#define __DEC128_EPSILON__ 1E-33DL
   10.47 -#define __LONG_LONG_MAX__ 9223372036854775807LL
   10.48 -#define __SIZEOF_SIZE_T__ 4
   10.49 -#define __SIZEOF_WINT_T__ 4
   10.50 -#define __GXX_ABI_VERSION 1002
   10.51 -#define __FLT_MIN_EXP__ (-125)
   10.52 -#define __DBL_MIN__ 2.2250738585072014e-308
   10.53 -#define __DEC128_MIN__ 1E-6143DL
   10.54 -#define __REGISTER_PREFIX__ 
   10.55 -#define __DBL_HAS_DENORM__ 1
   10.56 -#define __NO_INLINE__ 1
   10.57 -#define __FLT_MANT_DIG__ 24
   10.58 -#define __VERSION__ "4.3.3"
   10.59 -#define __DEC64_EPSILON__ 1E-15DD
   10.60 -#define __DEC128_MIN_EXP__ (-6143)
   10.61 -#define __SIZE_TYPE__ unsigned int
   10.62 -#define __DEC32_DEN__ 0.000001E-95DF
   10.63 -#define __ELF__ 1
   10.64 -#define __FLT_RADIX__ 2
   10.65 -#define __LDBL_EPSILON__ 2.2204460492503131e-16L
   10.66 -#define __SIZEOF_PTRDIFF_T__ 4
   10.67 -#define __FLT_HAS_QUIET_NAN__ 1
   10.68 -#define __FLT_MAX_10_EXP__ 38
   10.69 -#define __LONG_MAX__ 2147483647L
   10.70 -#define __FLT_HAS_INFINITY__ 1
   10.71 -#define __DEC64_MAX__ 9.999999999999999E384DD
   10.72 -#define __DEC64_MANT_DIG__ 16
   10.73 -#define __DEC32_MAX_EXP__ 96
   10.74 -#define __DEC128_DEN__ 0.000000000000000000000000000000001E-6143DL
   10.75 -#define __LDBL_MANT_DIG__ 53
   10.76 -#define __DBL_HAS_QUIET_NAN__ 1
   10.77 -#define __WCHAR_TYPE__ int
   10.78 -#define __SIZEOF_FLOAT__ 4
   10.79 -#define __DEC64_MIN_EXP__ (-383)
   10.80 -#define __FLT_DIG__ 6
   10.81 -#define __INT_MAX__ 2147483647
   10.82 -#define __FLT_MAX_EXP__ 128
   10.83 -#define __DBL_MANT_DIG__ 53
   10.84 -#define __DEC64_MIN__ 1E-383DD
   10.85 -#define __WINT_TYPE__ unsigned int
   10.86 -#define __SIZEOF_SHORT__ 2
   10.87 -#define __LDBL_MIN_EXP__ (-1021)
   10.88 -#define __LDBL_MAX_10_EXP__ 308
   10.89 -#define __DBL_EPSILON__ 2.2204460492503131e-16
   10.90 -#define __SIZEOF_WCHAR_T__ 4
   10.91 -#define __DEC_EVAL_METHOD__ 2
   10.92 -#define __INTMAX_MAX__ 9223372036854775807LL
   10.93 -#define __FLT_DENORM_MIN__ 1.40129846e-45F
   10.94 -#define __FLT_MAX__ 3.40282347e+38F
   10.95 -#define __SIZEOF_DOUBLE__ 8
   10.96 -#define __FLT_MIN_10_EXP__ (-37)
   10.97 -#define __INTMAX_TYPE__ long long int
   10.98 -#define __DEC128_MAX_EXP__ 6144
   10.99 -#define __GNUC_MINOR__ 3
  10.100 -#define __DEC32_MANT_DIG__ 7
  10.101 -#define __DBL_MAX_10_EXP__ 308
  10.102 -#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
  10.103 -#define __STDC__ 1
  10.104 -#define __PTRDIFF_TYPE__ int
  10.105 -#define __DEC128_MANT_DIG__ 34
  10.106 -#define __LDBL_MIN_10_EXP__ (-307)
  10.107 -#define __SIZEOF_LONG_LONG__ 8
  10.108 -#define __LDBL_DIG__ 15
  10.109 -#define __GNUC_GNU_INLINE__ 1
    11.1 --- a/hake/menu.lst.beehive	Fri Jan 20 14:32:03 2012 -0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,42 +0,0 @@
    11.4 -# spawnd is used to control which cpus are booted
    11.5 -#
    11.6 -# "spawnd boot" will use the skb and pci to figure out and
    11.7 -#  boot all cores in the machine
    11.8 -#
    11.9 -# "spawnd boot bootbees=3-5" will not use the skb and
   11.10 -# boot the list of cores passed as argument.
   11.11 -# The hardware id of the cores to boot should be specified.
   11.12 -# This list may not include the bsp core id.
   11.13 -
   11.14 -# NB: Beehive currently executes programs in-place without
   11.15 -# relocation, requiring a separate copy of each binary for
   11.16 -# each core on which it will run. This is achieved by the
   11.17 -# |2 |3 etc. annotations on the module name, which are
   11.18 -# ignored by Bsplice when deciding which file to open.
   11.19 -
   11.20 -timeout 0
   11.21 -
   11.22 -title	Barrelfish
   11.23 -root	(nd)
   11.24 -hypervisor	/beehive/sbin/hyper
   11.25 -kernel	/beehive/sbin/cpu loglevel=3
   11.26 -module  /beehive/sbin/cpu|3
   11.27 -module	/beehive/sbin/init
   11.28 -
   11.29 -# Domains spawned by init
   11.30 -module	/beehive/sbin/mem_serv
   11.31 -module	/beehive/sbin/monitor
   11.32 -module	/beehive/sbin/monitor|3
   11.33 -
   11.34 -# Special boot time domains spawned by monitor
   11.35 -module	/beehive/sbin/chips boot
   11.36 -module	/beehive/sbin/ramfsd boot
   11.37 -#module  /beehive/sbin/skb boot
   11.38 -#module  /beehive/sbin/pci boot
   11.39 -module  /beehive/sbin/spawnd boot bootbees=3
   11.40 -module  /beehive/sbin/spawnd|3 nospawn
   11.41 -module  /beehive/sbin/startd boot
   11.42 -
   11.43 -# General user domains
   11.44 -#module	/beehive/sbin/serial
   11.45 -#module	/beehive/sbin/fish
    12.1 --- a/hake/symbolic_targets.mk	Fri Jan 20 14:32:03 2012 -0800
    12.2 +++ b/hake/symbolic_targets.mk	Mon Jan 23 11:04:15 2012 -0800
    12.3 @@ -211,16 +211,6 @@
    12.4  MODULES_arm11mp=\
    12.5  	sbin/cpu.bin
    12.6  
    12.7 -# Beehive-specific modules to build by default
    12.8 -MODULES_beehive=\
    12.9 -	sbin/hyper \
   12.10 -	sbin/bmp_bench \
   12.11 -	sbin/bulkbench \
   12.12 -	sbin/thc_v_flounder_empty \
   12.13 -	sbin/thcidctest \
   12.14 -	sbin/thcminitest \
   12.15 -	sbin/thctest \
   12.16 -
   12.17  # construct list of all modules to be built (arch-specific and common for each arch)
   12.18  MODULES=$(foreach a,$(HAKE_ARCHS),$(foreach m,$(MODULES_$(a)),$(a)/$(m)) \
   12.19                                    $(foreach m,$(MODULES_COMMON),$(a)/$(m))) \
   12.20 @@ -285,20 +275,6 @@
   12.21  else ifeq ($(ARCH),arm11mp)
   12.22  	QEMU_CMD=qemu-system-arm -cpu mpcore -M realview -kernel arm11mp/sbin/cpu.bin
   12.23  	GDB=arm-none-linux-gnueabi-gdb
   12.24 -else ifeq ($(ARCH),beehive)
   12.25 -
   12.26 -simulate: ./beehive/sbin/spliced.img
   12.27 -	Bsimimg -slave=$(SRCDIR)/kernel/arch/beehive/slavecode.mem -noaddrcheck -ncores=3 -ibase=1000 -datarota=2 ./beehive/sbin/spliced.img
   12.28 -.PHONY : simulate
   12.29 -
   12.30 -trace: ./beehive/sbin/spliced.img
   12.31 -	Bsimimg -slave=$(SRCDIR)/kernel/arch/beehive/slavecode.mem -noaddrcheck -ncores=3 -ibase=1000 -datarota=2 -instructions=instructions.txt -events=events.txt -cache=cache.txt ./beehive/sbin/spliced.img | tee sim.out
   12.32 -
   12.33 -.PHONY : trace
   12.34 -
   12.35 -./beehive/sbin/spliced.img: ./menu.lst $(MODULES)
   12.36 -	Bsplice -o ./beehive/sbin/spliced.img -s ./beehive/sbin/beehive.splice -i menu.lst
   12.37 -
   12.38  endif
   12.39  
   12.40  
   12.41 @@ -424,7 +400,6 @@
   12.42  	./docs/TN-004-VirtualMemory.pdf \
   12.43  	./docs/TN-005-SCC.pdf \
   12.44  	./docs/TN-006-Routing.pdf \
   12.45 -	./docs/TN-007-Beehive.pdf \
   12.46  	./docs/TN-008-Tracing.pdf \
   12.47  	./docs/TN-009-Notifications.pdf \
   12.48  	./docs/TN-010-Spec.pdf \
    13.1 --- a/if/arch/beehive.if	Fri Jan 20 14:32:03 2012 -0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,11 +0,0 @@
    13.4 -/*
    13.5 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
    13.6 - * All rights reserved.
    13.7 - *
    13.8 - * This file is distributed under the terms in the attached LICENSE file.
    13.9 - * If you do not find this file, copies can be found by writing to:
   13.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   13.11 - */
   13.12 -
   13.13 -alias errval uint32;
   13.14 -alias cycles uint32;
    14.1 --- a/if/intermon.if	Fri Jan 20 14:32:03 2012 -0800
    14.2 +++ b/if/intermon.if	Mon Jan 23 11:04:15 2012 -0800
    14.3 @@ -90,16 +90,6 @@
    14.4                                 errval err,
    14.5                                 caprep notify);
    14.6  
    14.7 -        message bind_bmp_request(iref iref,
    14.8 -                                 mon_id_t mon_id,
    14.9 -                                 uint32 chanid,
   14.10 -                                 uint32 ep_len);
   14.11 -        message bind_bmp_reply(con_id_t con_id,
   14.12 -                               mon_id_t mon_id,
   14.13 -                               errval err,
   14.14 -                               uint32 chanid,
   14.15 -                               uint32 ep_len);
   14.16 -
   14.17          message cap_send_request(con_id_t con_id,
   14.18                                   capid_t capid,
   14.19                                   caprep cap,
    15.1 --- a/if/monitor.if	Fri Jan 20 14:32:03 2012 -0800
    15.2 +++ b/if/monitor.if	Mon Jan 23 11:04:15 2012 -0800
    15.3 @@ -98,30 +98,6 @@
    15.4                          errval err,
    15.5  			cap notify);
    15.6  
    15.7 -          message bind_bmp_client_request(
    15.8 -                        iref iref,
    15.9 -                        uintptr conn_id,
   15.10 -                        cap lmp_ep);
   15.11 -
   15.12 -          message bind_bmp_service_request(
   15.13 -                        uintptr service_id,
   15.14 -                        uintptr mon_id,
   15.15 -                        cap bee_ep,
   15.16 -                        size remote_ep_len);
   15.17 -
   15.18 -          call bind_bmp_reply_monitor(
   15.19 -                        uintptr mon_id,
   15.20 -                        uintptr conn_id,
   15.21 -                        cap lmp_ep,
   15.22 -                        errval err);
   15.23 -
   15.24 -          response bind_bmp_reply_client(
   15.25 -                        uintptr mon_id,
   15.26 -                        uintptr conn_id,
   15.27 -                        cap bee_ep,
   15.28 -                        size remote_ep_len,
   15.29 -                        errval err);
   15.30 -
   15.31            call ipi_alloc_notify_request(cap ep, uintptr state);
   15.32  	  response ipi_alloc_notify_reply(uintptr state, cap notify, errval err);
   15.33  
    16.1 --- a/if/platform/beehive.if	Fri Jan 20 14:32:03 2012 -0800
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,12 +0,0 @@
    16.4 -/*
    16.5 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
    16.6 - * All rights reserved.
    16.7 - *
    16.8 - * This file is distributed under the terms in the attached LICENSE file.
    16.9 - * If you do not find this file, copies can be found by writing to:
   16.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   16.11 - */
   16.12 -
   16.13 -alias genpaddr uint64;
   16.14 -alias genvaddr uint64;
   16.15 -alias rsrcid   uint32;
    17.1 --- a/include/Hakefile	Fri Jan 20 14:32:03 2012 -0800
    17.2 +++ b/include/Hakefile	Mon Jan 23 11:04:15 2012 -0800
    17.3 @@ -13,7 +13,6 @@
    17.4  [ includeFile (options arch) f
    17.5        | f <- [ 
    17.6     "assert.h",
    17.7 -   "bexec.h",
    17.8     "complex.h",
    17.9     "cpiobin.h",
   17.10     "ctype.h",
    18.1 --- a/include/arch/beehive/_fpmath.h	Fri Jan 20 14:32:03 2012 -0800
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,49 +0,0 @@
    18.4 -/*-
    18.5 - * Copyright (c) 2002, 2003 David Schultz <das@FreeBSD.ORG>
    18.6 - * All rights reserved.
    18.7 - *
    18.8 - * Redistribution and use in source and binary forms, with or without
    18.9 - * modification, are permitted provided that the following conditions
   18.10 - * are met:
   18.11 - * 1. Redistributions of source code must retain the above copyright
   18.12 - *    notice, this list of conditions and the following disclaimer.
   18.13 - * 2. Redistributions in binary form must reproduce the above copyright
   18.14 - *    notice, this list of conditions and the following disclaimer in the
   18.15 - *    documentation and/or other materials provided with the distribution.
   18.16 - *
   18.17 - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18.18 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18.19 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   18.20 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18.21 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   18.22 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   18.23 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   18.24 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   18.25 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   18.26 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   18.27 - * SUCH DAMAGE.
   18.28 - *
   18.29 - * $FreeBSD$
   18.30 - */
   18.31 -
   18.32 -union IEEEl2bits {
   18.33 -	long double	e;
   18.34 -	struct {
   18.35 -		unsigned int	manl	:32;
   18.36 -		unsigned int	manh	:20;
   18.37 -		unsigned int	exp	:11;
   18.38 -		unsigned int	sign	:1;
   18.39 -	} bits;
   18.40 -};
   18.41 -
   18.42 -#define	LDBL_NBIT	0
   18.43 -#define	mask_nbit_l(u)	((void)0)
   18.44 -
   18.45 -#define	LDBL_MANH_SIZE	32
   18.46 -#define	LDBL_MANL_SIZE	32
   18.47 -
   18.48 -#define	LDBL_TO_ARRAY32(u, a) do {			\
   18.49 -	(a)[0] = (uint32_t)(u).bits.manl;		\
   18.50 -	(a)[1] = (uint32_t)(u).bits.manh;		\
   18.51 -} while(0)
   18.52 -
    19.1 --- a/include/arch/beehive/arch/inttypes.h	Fri Jan 20 14:32:03 2012 -0800
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,87 +0,0 @@
    19.4 -/*
    19.5 - * Australian Public Licence B (OZPLB)
    19.6 - * 
    19.7 - * Version 1-0
    19.8 - * 
    19.9 - * Copyright (c) 2004 National ICT Australia
   19.10 - * 
   19.11 - * All rights reserved. 
   19.12 - * 
   19.13 - * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
   19.14 - *               National ICT Australia
   19.15 - *               http://www.ertos.nicta.com.au
   19.16 - * 
   19.17 - * Permission is granted by National ICT Australia, free of charge, to
   19.18 - * any person obtaining a copy of this software and any associated
   19.19 - * documentation files (the "Software") to deal with the Software without
   19.20 - * restriction, including (without limitation) the rights to use, copy,
   19.21 - * modify, adapt, merge, publish, distribute, communicate to the public,
   19.22 - * sublicense, and/or sell, lend or rent out copies of the Software, and
   19.23 - * to permit persons to whom the Software is furnished to do so, subject
   19.24 - * to the following conditions:
   19.25 - * 
   19.26 - *     * Redistributions of source code must retain the above copyright
   19.27 - *       notice, this list of conditions and the following disclaimers.
   19.28 - * 
   19.29 - *     * Redistributions in binary form must reproduce the above
   19.30 - *       copyright notice, this list of conditions and the following
   19.31 - *       disclaimers in the documentation and/or other materials provided
   19.32 - *       with the distribution.
   19.33 - * 
   19.34 - *     * Neither the name of National ICT Australia, nor the names of its
   19.35 - *       contributors, may be used to endorse or promote products derived
   19.36 - *       from this Software without specific prior written permission.
   19.37 - * 
   19.38 - * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
   19.39 - * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
   19.40 - * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
   19.41 - * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
   19.42 - * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
   19.43 - * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
   19.44 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
   19.45 - * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
   19.46 - * ERRORS, WHETHER OR NOT DISCOVERABLE.
   19.47 - * 
   19.48 - * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
   19.49 - * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
   19.50 - * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
   19.51 - * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
   19.52 - * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
   19.53 - * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
   19.54 - * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
   19.55 - * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
   19.56 - * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
   19.57 - * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
   19.58 - * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
   19.59 - * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
   19.60 - * DAMAGES OR OTHER LIABILITY.
   19.61 - * 
   19.62 - * If applicable legislation implies representations, warranties, or
   19.63 - * conditions, or imposes obligations or liability on National ICT
   19.64 - * Australia or one of its contributors in respect of the Software that
   19.65 - * cannot be wholly or partly excluded, restricted or modified, the
   19.66 - * liability of National ICT Australia or the contributor is limited, to
   19.67 - * the full extent permitted by the applicable legislation, at its
   19.68 - * option, to:
   19.69 - * a.  in the case of goods, any one or more of the following:
   19.70 - * i.  the replacement of the goods or the supply of equivalent goods;
   19.71 - * ii.  the repair of the goods;
   19.72 - * iii. the payment of the cost of replacing the goods or of acquiring
   19.73 - *  equivalent goods;
   19.74 - * iv.  the payment of the cost of having the goods repaired; or
   19.75 - * b.  in the case of services:
   19.76 - * i.  the supplying of the services again; or
   19.77 - * ii.  the payment of the cost of having the services supplied again.
   19.78 - * 
   19.79 - * The construction, validity and performance of this licence is governed
   19.80 - * by the laws in force in New South Wales, Australia.
   19.81 - */
   19.82 -/*
   19.83 -  Author: Ben Leslie
   19.84 -*/
   19.85 -#define __LENGTH_8_MOD "hh"
   19.86 -#define __LENGTH_16_MOD "h"
   19.87 -#define __LENGTH_32_MOD
   19.88 -#define __LENGTH_64_MOD "ll"
   19.89 -#define __LENGTH_MAX_MOD "ll"
   19.90 -#define __LENGTH_PTR_MOD
    20.1 --- a/include/arch/beehive/arch/setjmp.h	Fri Jan 20 14:32:03 2012 -0800
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,14 +0,0 @@
    20.4 -/*
    20.5 - * Copyright (c) 2009, ETH Zurich.
    20.6 - * All rights reserved.
    20.7 - *
    20.8 - * This file is distributed under the terms in the attached LICENSE file.
    20.9 - * If you do not find this file, copies can be found by writing to:
   20.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   20.11 - */
   20.12 -
   20.13 -/* ISO/IEC 9899:1990 Sec 7.6 "jmp_buf is an array type" */
   20.14 -typedef uintptr_t jmp_buf[32];
   20.15 -
   20.16 -
   20.17 -    
    21.1 --- a/include/arch/beehive/arch/stdint.h	Fri Jan 20 14:32:03 2012 -0800
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,93 +0,0 @@
    21.4 -/*
    21.5 - * Australian Public Licence B (OZPLB)
    21.6 - * 
    21.7 - * Version 1-0
    21.8 - * 
    21.9 - * Copyright (c) 2004 National ICT Australia
   21.10 - * 
   21.11 - * All rights reserved. 
   21.12 - * 
   21.13 - * Developed by: Embedded, Real-time and Operating Systems Program (ERTOS)
   21.14 - *               National ICT Australia
   21.15 - *               http://www.ertos.nicta.com.au
   21.16 - * 
   21.17 - * Permission is granted by National ICT Australia, free of charge, to
   21.18 - * any person obtaining a copy of this software and any associated
   21.19 - * documentation files (the "Software") to deal with the Software without
   21.20 - * restriction, including (without limitation) the rights to use, copy,
   21.21 - * modify, adapt, merge, publish, distribute, communicate to the public,
   21.22 - * sublicense, and/or sell, lend or rent out copies of the Software, and
   21.23 - * to permit persons to whom the Software is furnished to do so, subject
   21.24 - * to the following conditions:
   21.25 - * 
   21.26 - *     * Redistributions of source code must retain the above copyright
   21.27 - *       notice, this list of conditions and the following disclaimers.
   21.28 - * 
   21.29 - *     * Redistributions in binary form must reproduce the above
   21.30 - *       copyright notice, this list of conditions and the following
   21.31 - *       disclaimers in the documentation and/or other materials provided
   21.32 - *       with the distribution.
   21.33 - * 
   21.34 - *     * Neither the name of National ICT Australia, nor the names of its
   21.35 - *       contributors, may be used to endorse or promote products derived
   21.36 - *       from this Software without specific prior written permission.
   21.37 - * 
   21.38 - * EXCEPT AS EXPRESSLY STATED IN THIS LICENCE AND TO THE FULL EXTENT
   21.39 - * PERMITTED BY APPLICABLE LAW, THE SOFTWARE IS PROVIDED "AS-IS", AND
   21.40 - * NATIONAL ICT AUSTRALIA AND ITS CONTRIBUTORS MAKE NO REPRESENTATIONS,
   21.41 - * WARRANTIES OR CONDITIONS OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
   21.42 - * BUT NOT LIMITED TO ANY REPRESENTATIONS, WARRANTIES OR CONDITIONS
   21.43 - * REGARDING THE CONTENTS OR ACCURACY OF THE SOFTWARE, OR OF TITLE,
   21.44 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT,
   21.45 - * THE ABSENCE OF LATENT OR OTHER DEFECTS, OR THE PRESENCE OR ABSENCE OF
   21.46 - * ERRORS, WHETHER OR NOT DISCOVERABLE.
   21.47 - * 
   21.48 - * TO THE FULL EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL
   21.49 - * NATIONAL ICT AUSTRALIA OR ITS CONTRIBUTORS BE LIABLE ON ANY LEGAL
   21.50 - * THEORY (INCLUDING, WITHOUT LIMITATION, IN AN ACTION OF CONTRACT,
   21.51 - * NEGLIGENCE OR OTHERWISE) FOR ANY CLAIM, LOSS, DAMAGES OR OTHER
   21.52 - * LIABILITY, INCLUDING (WITHOUT LIMITATION) LOSS OF PRODUCTION OR
   21.53 - * OPERATION TIME, LOSS, DAMAGE OR CORRUPTION OF DATA OR RECORDS; OR LOSS
   21.54 - * OF ANTICIPATED SAVINGS, OPPORTUNITY, REVENUE, PROFIT OR GOODWILL, OR
   21.55 - * OTHER ECONOMIC LOSS; OR ANY SPECIAL, INCIDENTAL, INDIRECT,
   21.56 - * CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES, ARISING OUT OF OR IN
   21.57 - * CONNECTION WITH THIS LICENCE, THE SOFTWARE OR THE USE OF OR OTHER
   21.58 - * DEALINGS WITH THE SOFTWARE, EVEN IF NATIONAL ICT AUSTRALIA OR ITS
   21.59 - * CONTRIBUTORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH CLAIM, LOSS,
   21.60 - * DAMAGES OR OTHER LIABILITY.
   21.61 - * 
   21.62 - * If applicable legislation implies representations, warranties, or
   21.63 - * conditions, or imposes obligations or liability on National ICT
   21.64 - * Australia or one of its contributors in respect of the Software that
   21.65 - * cannot be wholly or partly excluded, restricted or modified, the
   21.66 - * liability of National ICT Australia or the contributor is limited, to
   21.67 - * the full extent permitted by the applicable legislation, at its
   21.68 - * option, to:
   21.69 - * a.  in the case of goods, any one or more of the following:
   21.70 - * i.  the replacement of the goods or the supply of equivalent goods;
   21.71 - * ii.  the repair of the goods;
   21.72 - * iii. the payment of the cost of replacing the goods or of acquiring
   21.73 - *  equivalent goods;
   21.74 - * iv.  the payment of the cost of having the goods repaired; or
   21.75 - * b.  in the case of services:
   21.76 - * i.  the supplying of the services again; or
   21.77 - * ii.  the payment of the cost of having the services supplied again.
   21.78 - * 
   21.79 - * The construction, validity and performance of this licence is governed
   21.80 - * by the laws in force in New South Wales, Australia.
   21.81 - */
   21.82 -/*
   21.83 -  Author: Ben Leslie
   21.84 -*/
   21.85 -
   21.86 -typedef signed char int8_t;
   21.87 -typedef short int16_t;
   21.88 -typedef int int32_t;
   21.89 -typedef long long int64_t;
   21.90 -
   21.91 -typedef unsigned char uint8_t;
   21.92 -typedef unsigned short uint16_t;
   21.93 -typedef unsigned int uint32_t;
   21.94 -typedef unsigned long long uint64_t;
   21.95 -
   21.96 -#define __PTR_SIZE 32
    22.1 --- a/include/arch/beehive/barrelfish/bmp_chan.h	Fri Jan 20 14:32:03 2012 -0800
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,171 +0,0 @@
    22.4 -/**
    22.5 - * \file
    22.6 - * \brief Bidirectional Beehive messaging channel
    22.7 - */
    22.8 -
    22.9 -/*
   22.10 - * Copyright (c) 2009, 2010, ETH Zurich.
   22.11 - * All rights reserved.
   22.12 - *
   22.13 - * This file is distributed under the terms in the attached LICENSE file.
   22.14 - * If you do not find this file, copies can be found by writing to:
   22.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   22.16 - */
   22.17 -
   22.18 -#ifndef BARRELFISH_BMP_CHAN_H
   22.19 -#define BARRELFISH_BMP_CHAN_H
   22.20 -
   22.21 -#include <barrelfish/waitset.h>
   22.22 -#include <barrelfish/lmp_endpoints.h>
   22.23 -#include <barrelfish/syscall_arch.h>
   22.24 -#include <barrelfish_kpi/bmp.h>
   22.25 -#include <barrelfish/monitor_client.h>
   22.26 -#include <trace/trace.h>
   22.27 -
   22.28 -struct bmp_chan;
   22.29 -
   22.30 -/// Default size of BMP endpoint buffer (in words), must be >= BMP_MSG_LENGTH
   22.31 -// We make this reasonably large, because the flow control logic sends
   22.32 -// an ack whenever there is less than BMP_MSG_LENGTH space remaining.
   22.33 -#define DEFAULT_BMP_BUF_WORDS           (BMP_MSG_LENGTH * 2)
   22.34 -
   22.35 -struct bmp_bind_continuation {
   22.36 -    /**
   22.37 -     * \brief Handler which runs when a binding succeeds or fails
   22.38 -     * \param st State pointer set in closure
   22.39 -     * \param err Success/failure of binding
   22.40 -     * \param c On success, contains pointer to channel
   22.41 -     */
   22.42 -    void (*handler)(void *st, errval_t err, struct bmp_chan *c);
   22.43 -    void *st;
   22.44 -};
   22.45 -
   22.46 -/// A bidirectional Beehive channel
   22.47 -struct bmp_chan {
   22.48 -    struct monitor_cap_handlers cap_handlers;   /* XXX: must be first */
   22.49 -
   22.50 -    struct bmp_chan *next, *prev;  ///< Next/prev in list of channels with send events
   22.51 -    struct capref outepcap;        ///< Cap to remote Beehive endpoint
   22.52 -    size_t outeplen;               ///< Size of remote endpoint buffer
   22.53 -    struct lmp_endpoint *inep;     ///< Incoming LMP endpoint
   22.54 -    struct capref inepcap;         ///< Cap to incoming LMP endpoint
   22.55 -    struct waitset_chanstate send_waitset; ///< State belonging to waitset (for send)
   22.56 -
   22.57 -    /// connection state
   22.58 -    enum {BMP_DISCONNECTED,     ///< Disconnected
   22.59 -          BMP_BIND_WAIT,        ///< Waiting for bind reply
   22.60 -          BMP_CONNECTED,        ///< Connection established
   22.61 -    } connstate;
   22.62 -
   22.63 -    uintptr_t monitor_id;       ///< Local monitor's connection ID for this channel
   22.64 -    struct monitor_binding *monitor_binding; ///< Monitor binding used for cap xfer
   22.65 -
   22.66 -    /* Arguments for an ongoing bind attempt */
   22.67 -    iref_t iref;                ///< IREF to which we bound
   22.68 -    struct bmp_bind_continuation bind_continuation; ///< Continuation for bind
   22.69 -};
   22.70 -
   22.71 -/// Fixed-length version of #lmp_recv_buf
   22.72 -struct bmp_recv_msg {
   22.73 -    struct lmp_recv_buf buf;
   22.74 -    uintptr_t words[BMP_MSG_LENGTH]; ///< Payload (fixed length)
   22.75 -};
   22.76 -
   22.77 -/// Static initialiser for lmp_recv_msg
   22.78 -#define BMP_RECV_MSG_INIT { .buf.buflen = BMP_MSG_LENGTH }
   22.79 -
   22.80 -struct event_queue_node;
   22.81 -
   22.82 -void bmp_chan_init(struct bmp_chan *c);
   22.83 -errval_t bmp_chan_bind(struct bmp_chan *c, struct bmp_bind_continuation cont,
   22.84 -                       struct event_queue_node *qnode,  iref_t iref,
   22.85 -                       struct monitor_binding *monitor_binding,
   22.86 -                       size_t ep_buflen);
   22.87 -errval_t bmp_chan_accept(struct bmp_chan *c, uintptr_t mon_id,
   22.88 -                         struct capref remote_ep, size_t remote_ep_len,
   22.89 -                         size_t local_ep_len);
   22.90 -void bmp_chan_send_bind_reply(struct monitor_binding *mb,
   22.91 -                              struct bmp_chan *c, errval_t err,
   22.92 -                              uintptr_t monitor_id);
   22.93 -errval_t bmp_chan_register_send(struct bmp_chan *c, struct waitset *ws,
   22.94 -                                struct event_closure closure);
   22.95 -errval_t bmp_chan_deregister_send(struct bmp_chan *c);
   22.96 -void bmp_chan_destroy(struct bmp_chan *c);
   22.97 -void bmp_channels_retry_send_disabled(dispatcher_handle_t handle);
   22.98 -void bmp_init(void);
   22.99 -
  22.100 -/**
  22.101 - * \brief Register an event handler to be notified when messages can be received
  22.102 - *
  22.103 - * In the future, call the closure on the given waitset when it is likely that
  22.104 - * a message can be received on the channel. A channel may only be registered
  22.105 - * with a single receive event handler on a single waitset at any one time.
  22.106 - *
  22.107 - * \param c channel
  22.108 - * \param ws Waitset
  22.109 - * \param closure Event handler
  22.110 - */
  22.111 -static inline errval_t bmp_chan_register_recv(struct bmp_chan *c,
  22.112 -                                              struct waitset *ws,
  22.113 -                                              struct event_closure closure)
  22.114 -{
  22.115 -    return lmp_endpoint_register(c->inep, ws, closure);
  22.116 -}
  22.117 -
  22.118 -/**
  22.119 - * \brief Cancel an event registration made with bmp_chan_register_recv()
  22.120 - *
  22.121 - * \param c channel
  22.122 - */
  22.123 -static inline errval_t bmp_chan_deregister_recv(struct bmp_chan *c)
  22.124 -{
  22.125 -    return lmp_endpoint_deregister(c->inep);
  22.126 -}
  22.127 -
  22.128 -/**
  22.129 - * \brief Receive a message from a BMP channel, if possible
  22.130 - *
  22.131 - * Non-blocking. May fail if no message is available.
  22.132 - *
  22.133 - * \param c  channel
  22.134 - * \param msg BMP message buffer, to be filled-in
  22.135 - */
  22.136 -static inline errval_t bmp_chan_recv(struct bmp_chan *c,
  22.137 -                                     struct bmp_recv_msg *msg)
  22.138 -{
  22.139 -    assert(msg != NULL);
  22.140 -    assert(msg->buf.buflen == BMP_MSG_LENGTH);
  22.141 -    return lmp_endpoint_recv(c->inep, &msg->buf, NULL);
  22.142 -}
  22.143 -
  22.144 -/**
  22.145 - * \brief Send a message to a BMP channel, if possible
  22.146 - *
  22.147 - * Non-blocking. May fail if the channel cannot currently transmit.
  22.148 - *
  22.149 - * \param c  channel
  22.150 - * \param ptr Message payload as an array of words
  22.151 - * \param len Length of message payload, in words
  22.152 - */
  22.153 -static inline errval_t bmp_chan_send(struct bmp_chan *c,
  22.154 -                                     uintptr_t *ptr, size_t len)
  22.155 -{
  22.156 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_SEND, (uintptr_t)c);
  22.157 -
  22.158 -    assert(c != NULL);
  22.159 -    assert(ptr != NULL);
  22.160 -    assert(len > 0 && len <= BMP_MSG_LENGTH);
  22.161 -
  22.162 -    struct idc_send_msg msg;
  22.163 -
  22.164 -    idc_msg_init(&msg);
  22.165 -    idc_msg_encode_word(&msg, len);
  22.166 -    idc_msg_encode_word(&msg, (uintptr_t)ptr);
  22.167 -
  22.168 -    errval_t err;
  22.169 -    err = cap_invoke(c->outepcap, &msg).error;
  22.170 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_SEND, ((uintptr_t)c)|1);
  22.171 -    return err;
  22.172 -}
  22.173 -
  22.174 -#endif // BARRELFISH_BMP_CHAN_H
    23.1 --- a/include/arch/beehive/barrelfish/bulk_transfer_arch.h	Fri Jan 20 14:32:03 2012 -0800
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,32 +0,0 @@
    23.4 -/**
    23.5 - * \file
    23.6 - * \brief Unidirectional bulk data transfer via shared memory
    23.7 - */
    23.8 -
    23.9 -/*
   23.10 - * Copyright (c) 2009, 2010, ETH Zurich.
   23.11 - * All rights reserved.
   23.12 - *
   23.13 - * This file is distributed under the terms in the attached LICENSE file.
   23.14 - * If you do not find this file, copies can be found by writing to:
   23.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   23.16 - */
   23.17 -
   23.18 -#ifndef ARCH_BULK_TRANSFER_H
   23.19 -#define ARCH_BULK_TRANSFER_H
   23.20 -
   23.21 -// Provided by assembler
   23.22 -//extern void bee_dcache_flush_rgn(void * a,size_t n);
   23.23 -extern void bee_dcache_empty_rgn(void * a,size_t n);
   23.24 -
   23.25 -static inline void bulk_arch_prepare_send(void *mem, size_t size)
   23.26 -{
   23.27 -    bee_dcache_flush_rgn(mem, size);
   23.28 -}
   23.29 -
   23.30 -static inline void bulk_arch_prepare_recv(void *mem, size_t size)
   23.31 -{
   23.32 -    bee_dcache_empty_rgn(mem, size);
   23.33 -}
   23.34 -
   23.35 -#endif
    24.1 --- a/include/arch/beehive/barrelfish/core_state_arch.h	Fri Jan 20 14:32:03 2012 -0800
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,30 +0,0 @@
    24.4 -/**
    24.5 - * \file
    24.6 - * \brief
    24.7 - */
    24.8 -
    24.9 -/*
   24.10 - * Copyright (c) 2008, 2009, 2010, ETH Zurich.
   24.11 - * All rights reserved.
   24.12 - *
   24.13 - * This file is distributed under the terms in the attached LICENSE file.
   24.14 - * If you do not find this file, copies can be found by writing to:
   24.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   24.16 - */
   24.17 -
   24.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_CORESTATE_H
   24.19 -#define ARCH_BEEHIVE_BARRELFISH_CORESTATE_H
   24.20 -
   24.21 -#include <barrelfish/core_state.h>
   24.22 -
   24.23 -struct vspace_state {
   24.24 -    struct vspace vspace;
   24.25 -    struct pmap pmap;
   24.26 -};
   24.27 -
   24.28 -struct core_state_arch {
   24.29 -    struct core_state_generic c;
   24.30 -    struct vspace_state vspace_state;
   24.31 -};
   24.32 -
   24.33 -#endif
    25.1 --- a/include/arch/beehive/barrelfish/cpu_arch.h	Fri Jan 20 14:32:03 2012 -0800
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,20 +0,0 @@
    25.4 -/**
    25.5 - * \file
    25.6 - * \brief Architecture specific CPU bits.
    25.7 - */
    25.8 -
    25.9 -/*
   25.10 - * Copyright (c) 2010, ETH Zurich.
   25.11 - * All rights reserved.
   25.12 - *
   25.13 - * This file is distributed under the terms in the attached LICENSE file.
   25.14 - * If you do not find this file, copies can be found by writing to:
   25.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   25.16 - */
   25.17 -
   25.18 -#ifndef BEEHIVE_BARRELFISH_CPU_H
   25.19 -#define BEEHIVE_BARRELFISH_CPU_H
   25.20 -
   25.21 -#define CURRENT_CPU_TYPE CPU_BEEHIVE
   25.22 -
   25.23 -#endif
    26.1 --- a/include/arch/beehive/barrelfish/curdispatcher_arch.h	Fri Jan 20 14:32:03 2012 -0800
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,32 +0,0 @@
    26.4 -/**
    26.5 - * \file
    26.6 - * \brief Dispatcher architecture-specific code
    26.7 - */
    26.8 -
    26.9 -/*
   26.10 - * Copyright (c) 2009, ETH Zurich.
   26.11 - * All rights reserved.
   26.12 - *
   26.13 - * This file is distributed under the terms in the attached LICENSE file.
   26.14 - * If you do not find this file, copies can be found by writing to:
   26.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   26.16 - */
   26.17 -
   26.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_CURDISPATCHER_H
   26.19 -#define ARCH_BEEHIVE_BARRELFISH_CURDISPATCHER_H
   26.20 -
   26.21 -/**
   26.22 - * \brief Returns pointer to current dispatcher, using thread register
   26.23 - */
   26.24 -static inline dispatcher_handle_t curdispatcher(void)
   26.25 -{
   26.26 -    dispatcher_handle_t ret;
   26.27 -
   26.28 -    // We keep the dispatcher pointer in the platform usage register.
   26.29 -    // This register is not used by the compiler.
   26.30 -    __asm("ld %0, p1" : "=r" (ret) : );
   26.31 -
   26.32 -    return ret;
   26.33 -}
   26.34 -
   26.35 -#endif // ARCH_BEEHIVE_BARRELFISH_CURDISPATCHER_H
    27.1 --- a/include/arch/beehive/barrelfish/dispatcher_arch.h	Fri Jan 20 14:32:03 2012 -0800
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,32 +0,0 @@
    27.4 -/**
    27.5 - * \file
    27.6 - * \brief Architecture specific dispatcher structure private to the user
    27.7 - */
    27.8 -
    27.9 -/*
   27.10 - * Copyright (c) 2010, ETH Zurich.
   27.11 - * All rights reserved.
   27.12 - *
   27.13 - * This file is distributed under the terms in the attached LICENSE file.
   27.14 - * If you do not find this file, copies can be found by writing to:
   27.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   27.16 - */
   27.17 -
   27.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_DISPATCHER_H
   27.19 -#define ARCH_BEEHIVE_BARRELFISH_DISPATCHER_H
   27.20 -
   27.21 -#include <target/beehive/barrelfish/dispatcher_target.h>
   27.22 -
   27.23 -static inline struct dispatcher_generic*
   27.24 -get_dispatcher_generic(dispatcher_handle_t handle)
   27.25 -{
   27.26 -    struct dispatcher_beehive *disp = (struct dispatcher_beehive*)handle;
   27.27 -    return &disp->generic;
   27.28 -}
   27.29 -
   27.30 -static inline size_t get_dispatcher_size(void)
   27.31 -{
   27.32 -    return sizeof(struct dispatcher_beehive);
   27.33 -}
   27.34 -
   27.35 -#endif // ARCH_BEEHIVE_BARRELFISH_DISPATCHER_H
    28.1 --- a/include/arch/beehive/barrelfish/invocations_arch.h	Fri Jan 20 14:32:03 2012 -0800
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,332 +0,0 @@
    28.4 -/**
    28.5 - * \file
    28.6 - * \brief Low-level capability invocations
    28.7 - */
    28.8 -
    28.9 -/*
   28.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
   28.11 - * All rights reserved.
   28.12 - *
   28.13 - * This file is distributed under the terms in the attached LICENSE file.
   28.14 - * If you do not find this file, copies can be found by writing to:
   28.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   28.16 - */
   28.17 -
   28.18 -#include <barrelfish_kpi/legacy_idc_buffer.h> // for idc_send_msg
   28.19 -#include <barrelfish/syscall_arch.h> // for sys_invoke and cap_invoke
   28.20 -
   28.21 -
   28.22 -/**
   28.23 - * \brief Retype a capability.
   28.24 - *
   28.25 - * Retypes CPtr 'cap' into 2^'objbits' caps of type 'newtype' and places them
   28.26 - * into slots starting at slot 'slot' in the CNode, addressed by 'to', with
   28.27 - * 'bits' address bits of 'to' valid.
   28.28 - *
   28.29 - * See also cap_retype(), which wraps this.
   28.30 - *
   28.31 - * \param root          Capability of the CNode to invoke
   28.32 - * \param cap           Address of cap to retype.
   28.33 - * \param newtype       Kernel object type to retype to.
   28.34 - * \param objbits       Size of created objects, for variable-sized types
   28.35 - * \param to            Address of CNode cap to place retyped caps into.
   28.36 - * \param slot          Slot in CNode cap to start placement.
   28.37 - * \param bits          Number of valid address bits in 'to'.
   28.38 - *
   28.39 - * \return Error code
   28.40 - */
   28.41 -static inline errval_t invoke_cnode_retype(struct capref root, caddr_t cap,
   28.42 -                                           enum objtype newtype, int objbits,
   28.43 -                                           caddr_t to, caddr_t slot, int bits)
   28.44 -{
   28.45 -    assert(cap != CPTR_NULL);
   28.46 -    struct idc_send_msg msg;
   28.47 -
   28.48 -    idc_msg_init(&msg);
   28.49 -    idc_msg_encode_word(&msg, CNodeCmd_Retype);
   28.50 -    idc_msg_encode_word(&msg, cap);
   28.51 -    idc_msg_encode_word(&msg, newtype);
   28.52 -    idc_msg_encode_word(&msg, objbits);
   28.53 -    idc_msg_encode_word(&msg, to);
   28.54 -    idc_msg_encode_word(&msg, slot);
   28.55 -    idc_msg_encode_word(&msg, bits);
   28.56 -
   28.57 -    return cap_invoke(root, &msg).error;
   28.58 -}
   28.59 -
   28.60 -/**
   28.61 - * \brief "Mint" a capability.
   28.62 - *
   28.63 - * Copies CPtr 'from' into slot 'slot' in the CNode, addressed by 'to', within
   28.64 - * the address space, rooted at 'root' and with 'tobits' and 'frombits' address
   28.65 - * bits of 'to' and 'from' valid, respectively.
   28.66 - *
   28.67 - * See also cap_mint(), which wraps this.
   28.68 - *
   28.69 - * \param root          Capability of the CNode to invoke
   28.70 - * \param to            CNode to place copy into.
   28.71 - * \param slot          Slot in CNode cap to place copy into.
   28.72 - * \param from          Address of cap to copy.
   28.73 - * \param tobits        Number of valid address bits in 'to'.
   28.74 - * \param frombits      Number of valid address bits in 'from'.
   28.75 - * \param param1        1st cap-dependent parameter.
   28.76 - * \param param2        2nd cap-dependent parameter.
   28.77 - *
   28.78 - * \return Error code
   28.79 - */
   28.80 -static inline errval_t invoke_cnode_mint(struct capref root, caddr_t to,
   28.81 -                                         caddr_t slot, caddr_t from, int tobits,
   28.82 -                                         int frombits, uint64_t param1,
   28.83 -                                         uint64_t param2)
   28.84 -{
   28.85 -    struct idc_send_msg msg;
   28.86 -
   28.87 -    idc_msg_init(&msg);
   28.88 -    idc_msg_encode_word(&msg, CNodeCmd_Mint);
   28.89 -    idc_msg_encode_word(&msg, to);
   28.90 -    idc_msg_encode_word(&msg, slot);
   28.91 -    idc_msg_encode_word(&msg, from);
   28.92 -    idc_msg_encode_word(&msg, tobits);
   28.93 -    idc_msg_encode_word(&msg, frombits);
   28.94 -    idc_msg_encode_word(&msg, param1);
   28.95 -    idc_msg_encode_word(&msg, param2);
   28.96 -
   28.97 -    return cap_invoke(root, &msg).error;
   28.98 -}
   28.99 -
  28.100 -// Required to compile
  28.101 -static inline errval_t invoke_vnode_unmap(struct capref cap, size_t entry)
  28.102 -{
  28.103 -    assert(!"should not be called");
  28.104 -    return LIB_ERR_NOT_IMPLEMENTED;
  28.105 -}
  28.106 -
  28.107 -/**
  28.108 - * \brief Copy a capability.
  28.109 - *
  28.110 - * Copies CPtr 'from' into slot 'slot' in the CNode, addressed by 'to', within
  28.111 - * the address space, rooted at 'root' and with 'tobits' and 'frombits' address
  28.112 - * bits of 'to' and 'from' valid, respectively.
  28.113 - *
  28.114 - * See also cap_copy(), which wraps this.
  28.115 - *
  28.116 - * \param root          Capability of the CNode to invoke
  28.117 - * \param to            CNode to place copy into.
  28.118 - * \param slot          Slot in CNode cap to place copy into.
  28.119 - * \param from          Address of cap to copy.
  28.120 - * \param tobits        Number of valid address bits in 'to'.
  28.121 - * \param frombits      Number of valid address bits in 'from'.
  28.122 - *
  28.123 - * \return Error code
  28.124 - */
  28.125 -static inline errval_t invoke_cnode_copy(struct capref root, caddr_t to,
  28.126 -                                         caddr_t slot, caddr_t from, int tobits,
  28.127 -                                         int frombits)
  28.128 -{
  28.129 -    struct idc_send_msg msg;
  28.130 -
  28.131 -    idc_msg_init(&msg);
  28.132 -    idc_msg_encode_word(&msg, CNodeCmd_Copy);
  28.133 -    idc_msg_encode_word(&msg, to);
  28.134 -    idc_msg_encode_word(&msg, slot);
  28.135 -    idc_msg_encode_word(&msg, from);
  28.136 -    idc_msg_encode_word(&msg, tobits);
  28.137 -    idc_msg_encode_word(&msg, frombits);
  28.138 -
  28.139 -    return cap_invoke(root, &msg).error;
  28.140 -}
  28.141 -
  28.142 -/**
  28.143 - * \brief Delete a capability.
  28.144 - *
  28.145 - * Delete the capability pointed to by 'cap', with 'bits' address bits
  28.146 - * of it valid, from the address space rooted at 'root'.
  28.147 - *
  28.148 - * \param root  Capability of the CNode to invoke
  28.149 - * \param cap   Address of cap to delete.
  28.150 - * \param bits  Number of valid bits within 'cap'.
  28.151 - *
  28.152 - * \return Error code
  28.153 - */
  28.154 -static inline errval_t invoke_cnode_delete(struct capref root, caddr_t cap,
  28.155 -                                           int bits)
  28.156 -{
  28.157 -    struct idc_send_msg msg;
  28.158 -
  28.159 -    idc_msg_init(&msg);
  28.160 -    idc_msg_encode_word(&msg, CNodeCmd_Delete);
  28.161 -    idc_msg_encode_word(&msg, cap);
  28.162 -    idc_msg_encode_word(&msg, bits);
  28.163 -
  28.164 -    return cap_invoke(root, &msg).error;
  28.165 -}
  28.166 -
  28.167 -static inline errval_t invoke_cnode_revoke(struct capref root, caddr_t cap,
  28.168 -                                           int bits)
  28.169 -{
  28.170 -    struct idc_send_msg msg;
  28.171 -
  28.172 -    idc_msg_init(&msg);
  28.173 -    idc_msg_encode_word(&msg, CNodeCmd_Revoke);
  28.174 -    idc_msg_encode_word(&msg, cap);
  28.175 -    idc_msg_encode_word(&msg, bits);
  28.176 -
  28.177 -    return cap_invoke(root, &msg).error;
  28.178 -}
  28.179 -
  28.180 -/**
  28.181 - * \brief Return the physical address and size of a frame capability
  28.182 - *
  28.183 - * \param frame    CSpace address of frame capability
  28.184 - * \param ret      frame_identity struct filled in with relevant data
  28.185 - *
  28.186 - * \return Error code
  28.187 - */
  28.188 -static inline errval_t invoke_frame_identify(struct capref frame,
  28.189 -                                             struct frame_identity *ret)
  28.190 -{
  28.191 -    struct idc_send_msg msg;
  28.192 -
  28.193 -    idc_msg_init(&msg);
  28.194 -    idc_msg_encode_word(&msg, FrameCmd_Identify);
  28.195 -    struct sysret sysret = cap_invoke(frame, &msg);
  28.196 -    assert(ret != NULL);
  28.197 -    if (err_is_ok(sysret.error)) {
  28.198 -        ret->base = sysret.value & (~BASE_PAGE_MASK);
  28.199 -        ret->bits = sysret.value & BASE_PAGE_MASK;
  28.200 -        return sysret.error;
  28.201 -    }
  28.202 -
  28.203 -    ret->base = 0;
  28.204 -    ret->bits = 0;
  28.205 -    return sysret.error;
  28.206 -}
  28.207 -
  28.208 -static inline errval_t invoke_iocap_in(struct capref iocap, enum io_cmd cmd,
  28.209 -                                       uint16_t port, uint32_t *data)
  28.210 -{
  28.211 -    struct idc_send_msg msg;
  28.212 -
  28.213 -    idc_msg_init(&msg);
  28.214 -    idc_msg_encode_word(&msg, cmd);
  28.215 -    idc_msg_encode_word(&msg, port);
  28.216 -    struct sysret sysret = cap_invoke(iocap, &msg);
  28.217 -    if (err_is_ok(sysret.error)) {
  28.218 -        assert(data != NULL);
  28.219 -        *data = sysret.value;
  28.220 -    }
  28.221 -    return sysret.error;
  28.222 -}
  28.223 -
  28.224 -static inline errval_t invoke_iocap_out(struct capref iocap, enum io_cmd cmd,
  28.225 -                                        uint16_t port, uint32_t data)
  28.226 -{
  28.227 -    struct idc_send_msg msg;
  28.228 -
  28.229 -    idc_msg_init(&msg);
  28.230 -    idc_msg_encode_word(&msg, cmd);
  28.231 -    idc_msg_encode_word(&msg, port);
  28.232 -    idc_msg_encode_word(&msg, data);
  28.233 -    return cap_invoke(iocap, &msg).error;
  28.234 -}
  28.235 -
  28.236 -/**
  28.237 - * \brief Setup a dispatcher, possibly making it runnable
  28.238 - *
  28.239 - * \param dispatcher    Address of dispatcher capability
  28.240 - * \param domdispatcher Address of existing dispatcher for domain ID
  28.241 - * \param cspace_root   Root of CSpace for new dispatcher
  28.242 - * \param cspace_root_bits  Number of valid bits in cspace_root
  28.243 - * \param vspace_root   Root of VSpace for new dispatcher
  28.244 - * \param dispatcher_frame Frame capability for dispatcher structure
  28.245 - * \param run           Make runnable if true
  28.246 - *
  28.247 - * Any arguments of CPTR_NULL are ignored.
  28.248 - *
  28.249 - * \return Error code
  28.250 - */
  28.251 -static inline errval_t
  28.252 -invoke_dispatcher(struct capref dispatcher, struct capref domdispatcher,
  28.253 -                  struct capref cspace, struct capref vspace,
  28.254 -                  struct capref dispframe, bool run)
  28.255 -{
  28.256 -    uint8_t root_vbits = get_cap_valid_bits(cspace);
  28.257 -    caddr_t root_caddr = get_cap_addr(cspace) >> (CPTR_BITS - root_vbits);
  28.258 -    caddr_t vtree_caddr = get_cap_addr(vspace);
  28.259 -    caddr_t disp_caddr = get_cap_addr(dispframe);
  28.260 -    caddr_t dd_caddr = get_cap_addr(domdispatcher);
  28.261 -
  28.262 -    struct idc_send_msg msg;
  28.263 -    idc_msg_init(&msg);
  28.264 -    idc_msg_encode_word(&msg, DispatcherCmd_Setup);
  28.265 -    idc_msg_encode_word(&msg, root_caddr);
  28.266 -    idc_msg_encode_word(&msg, root_vbits);
  28.267 -    idc_msg_encode_word(&msg, vtree_caddr);
  28.268 -    idc_msg_encode_word(&msg, disp_caddr);
  28.269 -    idc_msg_encode_word(&msg, run);
  28.270 -    idc_msg_encode_word(&msg, dd_caddr);
  28.271 -    return cap_invoke(dispatcher, &msg).error;
  28.272 -}
  28.273 -
  28.274 -/**
  28.275 - * \brief Setup a VM guest DCB
  28.276 - *
  28.277 - * \param dcb       Dispatcher capability
  28.278 - */
  28.279 -static inline errval_t invoke_dispatcher_setup_guest(struct capref dispatcher,
  28.280 -                                                     caddr_t ep_cap,
  28.281 -                                                     caddr_t vnode,
  28.282 -                                                     caddr_t vmkit_guest,
  28.283 -                                                     caddr_t guest_control_cap)
  28.284 -{
  28.285 -    struct idc_send_msg msg;
  28.286 -    idc_msg_init(&msg);
  28.287 -    idc_msg_encode_word(&msg, DispatcherCmd_SetupGuest);
  28.288 -    idc_msg_encode_word(&msg, ep_cap);
  28.289 -    idc_msg_encode_word(&msg, vnode);
  28.290 -    idc_msg_encode_word(&msg, vmkit_guest);
  28.291 -    idc_msg_encode_word(&msg, guest_control_cap);
  28.292 -    return cap_invoke(dispatcher, &msg).error;
  28.293 -}
  28.294 -
  28.295 -static inline errval_t invoke_irqtable_set(struct capref irqcap, int irq,
  28.296 -                                           struct capref ep)
  28.297 -{
  28.298 -    struct idc_send_msg msg;
  28.299 -
  28.300 -    idc_msg_init(&msg);
  28.301 -    idc_msg_encode_word(&msg, IRQTableCmd_Set);
  28.302 -    idc_msg_encode_word(&msg, irq);
  28.303 -    idc_msg_encode_word(&msg, get_cap_addr(ep));
  28.304 -    return cap_invoke(irqcap, &msg).error;
  28.305 -}
  28.306 -
  28.307 -static inline errval_t invoke_irqtable_delete(struct capref irqcap, int irq)
  28.308 -{
  28.309 -    struct idc_send_msg msg;
  28.310 -
  28.311 -    idc_msg_init(&msg);
  28.312 -    idc_msg_encode_word(&msg, IRQTableCmd_Delete);
  28.313 -    idc_msg_encode_word(&msg, irq);
  28.314 -    return cap_invoke(irqcap, &msg).error;
  28.315 -}
  28.316 -
  28.317 -// XXX TODO: Clean this with proper symbols
  28.318 -static inline errval_t invoke_kernel_get_core_id(struct capref kern_cap,
  28.319 -                                                 coreid_t *core_id)
  28.320 -{
  28.321 -    assert(core_id != 0);
  28.322 -    volatile unsigned int *ptr = (void*)0x02;
  28.323 -    unsigned int val = *ptr;
  28.324 -    *core_id = ((val >> 10) & 0xf);
  28.325 -    return SYS_ERR_OK;
  28.326 -}
  28.327 -
  28.328 -static inline errval_t
  28.329 -invoke_dispatcher_properties(struct capref dispatcher,
  28.330 -                             enum task_type type, unsigned long deadline,
  28.331 -                             unsigned long wcet, unsigned long period,
  28.332 -                             unsigned long release, unsigned short weight)
  28.333 -{
  28.334 -    return LIB_ERR_NOT_IMPLEMENTED;
  28.335 -}
    29.1 --- a/include/arch/beehive/barrelfish/lmp_chan_arch.h	Fri Jan 20 14:32:03 2012 -0800
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,113 +0,0 @@
    29.4 -/**
    29.5 - * \file
    29.6 - * \brief
    29.7 - */
    29.8 -
    29.9 -/*
   29.10 - * Copyright (c) 2007, 2008, ETH Zurich.
   29.11 - * All rights reserved.
   29.12 - *
   29.13 - * This file is distributed under the terms in the attached LICENSE file.
   29.14 - * If you do not find this file, copies can be found by writing to:
   29.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   29.16 - */
   29.17 -
   29.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_LMP_CHAN_H
   29.19 -#define ARCH_BEEHIVE_BARRELFISH_LMP_CHAN_H
   29.20 -
   29.21 -#include <barrelfish/syscall_arch.h> // for cap_invoke
   29.22 -#include <barrelfish/caddr.h>
   29.23 -#include <barrelfish_kpi/lmp.h>
   29.24 -
   29.25 -// Sanity check
   29.26 -#if LMP_MSG_LENGTH != 9
   29.27 -#error "LMP_MSG_LENGTH != 9"
   29.28 -#endif
   29.29 -
   29.30 -// all this code relies massively on the compilers post-inlining optimiser
   29.31 -
   29.32 -/**
   29.33 - * \brief Send a message on the given LMP channel, if possible
   29.34 - *
   29.35 - * Non-blocking, may fail if there is no space in the receiver's endpoint.
   29.36 - *
   29.37 - * \param ep Remote endpoint cap
   29.38 - * \param flags LMP send flags
   29.39 - * \param send_cap (Optional) capability to send with the message
   29.40 - * \param length_words Length of the message in words; payload beyond this
   29.41 - *                      size will not be delivered
   29.42 - * \param arg1..N Message payload
   29.43 - */
   29.44 -static inline errval_t lmp_ep_send(struct capref ep, lmp_send_flags_t flags,
   29.45 -				   struct capref send_cap, uint8_t length_words,
   29.46 -				   uint32_t a, uint32_t b, uint32_t c, uint32_t d,
   29.47 -				   uint32_t e, uint32_t f, uint32_t g, uint32_t h,
   29.48 -				   uint32_t i)
   29.49 -{
   29.50 -    struct idc_send_msg msg;
   29.51 -    
   29.52 -    idc_msg_init(&msg);
   29.53 -    if (length_words > 0) idc_msg_encode_word(&msg, a);
   29.54 -    if (length_words > 1) idc_msg_encode_word(&msg, b);
   29.55 -    if (length_words > 2) idc_msg_encode_word(&msg, c);
   29.56 -    if (length_words > 3) idc_msg_encode_word(&msg, d);
   29.57 -    if (length_words > 4) idc_msg_encode_word(&msg, e);
   29.58 -    if (length_words > 5) idc_msg_encode_word(&msg, f);
   29.59 -    if (length_words > 6) idc_msg_encode_word(&msg, g);
   29.60 -    if (length_words > 7) idc_msg_encode_word(&msg, h);
   29.61 -    if (length_words > 8) idc_msg_encode_word(&msg, i);
   29.62 -
   29.63 -    msg.u.x.header.x.flags.sync = ((flags & LMP_FLAG_SYNC) != 0) ? 1 : 0;
   29.64 -    msg.u.x.header.x.flags.yield = ((flags & LMP_FLAG_YIELD) != 0) ? 1 : 0;
   29.65 -
   29.66 -    if (!capref_is_null(send_cap)) {
   29.67 -	uint8_t send_bits = get_cap_valid_bits(send_cap);
   29.68 -	msg.u.x.header.x.send_bits = send_bits;
   29.69 -	msg.u.x.header.x.send_cptr = get_cap_addr(send_cap) >> (CPTR_BITS - send_bits);
   29.70 -    }
   29.71 -
   29.72 -    return cap_invoke(ep, &msg).error;
   29.73 -}
   29.74 -
   29.75 -// all this code relies massively on the compilers post-inlining optimiser
   29.76 -
   29.77 -#define lmp_ep_send4(_ep, _flags, _send_cap, _a, _b, _c, _d) \
   29.78 -    lmp_ep_send((_ep), (_flags), (_send_cap), 4, (_a), (_b), (_c), (_d), 5, 6, 7, 8, 9)
   29.79 -#define lmp_ep_send3(_ep, _flags, _send_cap, _a, _b, _c) \
   29.80 -    lmp_ep_send((_ep), (_flags), (_send_cap), 3, (_a), (_b), (_c), 4, 5, 6, 7, 8, 9)
   29.81 -#define lmp_ep_send2(_ep, _flags, _send_cap, _a, _b) \
   29.82 -    lmp_ep_send((_ep), (_flags), (_send_cap), 2, (_a), (_b), 3, 4, 5, 6, 7, 8, 9)
   29.83 -#define lmp_ep_send1(_ep, _flags, _send_cap, _a) \
   29.84 -    lmp_ep_send((_ep), (_flags), (_send_cap), 1, (_a), 2, 3, 4, 5, 6, 7, 8, 9)
   29.85 -#define lmp_ep_send0(_ep, _flags, _send_cap) \
   29.86 -    lmp_ep_send((_ep), (_flags), (_send_cap), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
   29.87 -
   29.88 -
   29.89 -#define lmp_chan_send(_lc, _flags, _send_cap, _len, _a, _b, _c, _d, _e, _f, _g, _h, _i) \
   29.90 -  lmp_ep_send((_lc)->remote_cap, (_flags), (_send_cap), (_len), \
   29.91 -		(_a), (_b), (_c), (_d), (_e), (_f), (_g), (_h), (_i))
   29.92 -
   29.93 -// all this code relies massively on the compilers post-inlining optimiser
   29.94 -
   29.95 -#define lmp_chan_send9(_lc, _flags, _send_cap, _a, _b, _c, _d, _e, _f, _g, _h, _i) \
   29.96 -    lmp_chan_send((_lc), (_flags), (_send_cap), 9, (_a), (_b), (_c), (_d), (_e), (_f), (_g), (_h), (_i))
   29.97 -#define lmp_chan_send8(_lc, _flags, _send_cap, _a, _b, _c, _d, _e, _f, _g, _h) \
   29.98 -    lmp_chan_send((_lc), (_flags), (_send_cap), 8, (_a), (_b), (_c), (_d), (_e), (_f), (_g), (_h), 9)
   29.99 -#define lmp_chan_send7(_lc, _flags, _send_cap, _a, _b, _c, _d, _e, _f, _g) \
  29.100 -    lmp_chan_send((_lc), (_flags), (_send_cap), 7, (_a), (_b), (_c), (_d), (_e), (_f), (_g), 8, 9)
  29.101 -#define lmp_chan_send6(_lc, _flags, _send_cap, _a, _b, _c, _d, _e, _f) \
  29.102 -    lmp_chan_send((_lc), (_flags), (_send_cap), 6, (_a), (_b), (_c), (_d), (_e), (_f), 7, 8, 9)
  29.103 -#define lmp_chan_send5(_lc, _flags, _send_cap, _a, _b, _c, _d, _e) \
  29.104 -    lmp_chan_send((_lc), (_flags), (_send_cap), 5, (_a), (_b), (_c), (_d), (_e), 6, 7, 8, 9)
  29.105 -#define lmp_chan_send4(_lc, _flags, _send_cap, _a, _b, _c, _d) \
  29.106 -    lmp_chan_send((_lc), (_flags), (_send_cap), 4, (_a), (_b), (_c), (_d), 5, 6, 7, 8, 9)
  29.107 -#define lmp_chan_send3(_lc, _flags, _send_cap, _a, _b, _c) \
  29.108 -    lmp_chan_send((_lc), (_flags), (_send_cap), 3, (_a), (_b), (_c), 4, 5, 6, 7, 8, 9)
  29.109 -#define lmp_chan_send2(_lc, _flags, _send_cap, _a, _b) \
  29.110 -    lmp_chan_send((_lc), (_flags), (_send_cap), 2, (_a), (_b), 3, 4, 5, 6, 7, 8, 9)
  29.111 -#define lmp_chan_send1(_lc, _flags, _send_cap, _a) \
  29.112 -    lmp_chan_send((_lc), (_flags), (_send_cap), 1, (_a), 2, 3, 4, 5, 6, 7, 8, 9)
  29.113 -#define lmp_chan_send0(_lc, _flags, _send_cap) \
  29.114 -    lmp_chan_send((_lc), (_flags), (_send_cap), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
  29.115 -
  29.116 -#endif // ARCH_BEEHIVE_BARRELFISH_LMP_CHAN_H
    30.1 --- a/include/arch/beehive/barrelfish/pmap_arch.h	Fri Jan 20 14:32:03 2012 -0800
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,26 +0,0 @@
    30.4 -/**
    30.5 - * \file
    30.6 - * \brief pmap management wrappers
    30.7 - */
    30.8 -
    30.9 -/*
   30.10 - * Copyright (c) 2010, ETH Zurich.
   30.11 - * All rights reserved.
   30.12 - *
   30.13 - * This file is distributed under the terms in the attached LICENSE file.
   30.14 - * If you do not find this file, copies can be found by writing to:
   30.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   30.16 - */
   30.17 -
   30.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_PMAP_H
   30.19 -#define ARCH_BEEHIVE_BARRELFISH_PMAP_H
   30.20 -
   30.21 -#include <barrelfish/pmap.h>
   30.22 -
   30.23 -#define ARCH_DEFAULT_PMAP_SIZE sizeof(struct pmap)
   30.24 -
   30.25 -errval_t pmap_init(struct pmap *pmap, struct vspace *vspace,
   30.26 -                   struct capref vnode, struct slot_allocator *opt_slot_alloc);
   30.27 -errval_t pmap_current_init(bool);
   30.28 -
   30.29 -#endif // ARCH_BEEHIVE_BARRELFISH_PMAP_H
    31.1 --- a/include/arch/beehive/barrelfish/syscall_arch.h	Fri Jan 20 14:32:03 2012 -0800
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,65 +0,0 @@
    31.4 -/**
    31.5 - * \file
    31.6 - * \brief User-side system call implementation
    31.7 - */
    31.8 -
    31.9 -/*
   31.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
   31.11 - * All rights reserved.
   31.12 - *
   31.13 - * This file is distributed under the terms in the attached LICENSE file.
   31.14 - * If you do not find this file, copies can be found by writing to:
   31.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   31.16 - */
   31.17 -
   31.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_SYSCALL_H
   31.19 -#define ARCH_BEEHIVE_BARRELFISH_SYSCALL_H
   31.20 -
   31.21 -#include <barrelfish/caddr.h> // for get_cap_valid_bits
   31.22 -#include <barrelfish_kpi/legacy_idc_buffer.h> // for struct idc_send_msg
   31.23 -
   31.24 -// Implemented in assembler
   31.25 -
   31.26 -#if 0 // these are already declared in include/barrelfish/syscalls.h
   31.27 -extern errval_t sys_yield(caddr_t target);
   31.28 -extern errval_t sys_nop(void);
   31.29 -extern errval_t sys_print(const char *string, size_t length);
   31.30 -#endif
   31.31 -
   31.32 -extern errval_t sys_invoke(uintptr_t *const pvalue,
   31.33 -			   uint8_t invokebits,
   31.34 -			   caddr_t invokecptr,
   31.35 -			   struct idc_send_msg *const msg);
   31.36 -
   31.37 -
   31.38 -extern errval_t sys_rundown(void);
   31.39 -
   31.40 -/*
   31.41 - *  This must be here since it is relied on variously by
   31.42 - *  incovations.h, monitor_invocations.h and lmp_chan_arch.h
   31.43 - */
   31.44 -
   31.45 -/**
   31.46 - * \brief Invoke (send a message to) a capability, returning an error and a value
   31.47 - *
   31.48 - * \param to Capability to invoke
   31.49 - * \param msg Message to send
   31.50 - *
   31.51 - * This is needed for some system calls that return a structure of two values.
   31.52 - *
   31.53 - * \returns System return structure (#sysret)
   31.54 - */
   31.55 -static inline struct sysret
   31.56 -cap_invoke(struct capref to, struct idc_send_msg *msg)
   31.57 -{
   31.58 -    // TODO: XXX: This should have a typedef not a uint8_t
   31.59 -    uint8_t invokebits = get_cap_valid_bits(to);
   31.60 -    caddr_t invokecptr = get_cap_addr(to) >> (CPTR_BITS - invokebits);
   31.61 -
   31.62 -    struct sysret retval;
   31.63 -    retval.error = sys_invoke(&retval.value, invokebits, invokecptr, msg);
   31.64 -    return retval;
   31.65 -}
   31.66 -
   31.67 -
   31.68 -#endif // ARCH_BEEHIVE_BARRELFISH_SYSCALL_H
    32.1 --- a/include/arch/beehive/barrelfish_kpi/bmp.h	Fri Jan 20 14:32:03 2012 -0800
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,20 +0,0 @@
    32.4 -/**
    32.5 - * \file
    32.6 - * \brief BMP declarations
    32.7 - */
    32.8 -
    32.9 -/*
   32.10 - * Copyright (c) 2010, ETH Zurich.
   32.11 - * All rights reserved.
   32.12 - *
   32.13 - * This file is distributed under the terms in the attached LICENSE file.
   32.14 - * If you do not find this file, copies can be found by writing to:
   32.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   32.16 - */
   32.17 -
   32.18 -#ifndef BMP_H
   32.19 -#define BMP_H
   32.20 -
   32.21 -#define BMP_MSG_LENGTH 58 /* words */
   32.22 -
   32.23 -#endif // BMP_H
    33.1 --- a/include/arch/beehive/barrelfish_kpi/cpu_arch.h	Fri Jan 20 14:32:03 2012 -0800
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,21 +0,0 @@
    33.4 -/**
    33.5 - * \file
    33.6 - * \brief Arch specific CPU declarations
    33.7 - */
    33.8 -
    33.9 -/*
   33.10 - * Copyright (c) 2010, ETH Zurich.
   33.11 - * All rights reserved.
   33.12 - *
   33.13 - * This file is distributed under the terms in the attached LICENSE file.
   33.14 - * If you do not find this file, copies can be found by writing to:
   33.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   33.16 - */
   33.17 -
   33.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_CPU_H
   33.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_CPU_H
   33.20 -
   33.21 -/// This CPU supports lazy FPU context switching?
   33.22 -#undef FPU_LAZY_CONTEXT_SWITCH
   33.23 -
   33.24 -#endif
    34.1 --- a/include/arch/beehive/barrelfish_kpi/dispatcher_shared_arch.h	Fri Jan 20 14:32:03 2012 -0800
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,54 +0,0 @@
    34.4 -/**
    34.5 - * \file
    34.6 - * \brief Architecture specific dispatcher struct shared between kernel and user
    34.7 - */
    34.8 -
    34.9 -/*
   34.10 - * Copyright (c) 2010, ETH Zurich.
   34.11 - * All rights reserved.
   34.12 - *
   34.13 - * This file is distributed under the terms in the attached LICENSE file.
   34.14 - * If you do not find this file, copies can be found by writing to:
   34.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   34.16 - */
   34.17 -
   34.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
   34.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
   34.20 -
   34.21 -#include <target/beehive/barrelfish_kpi/dispatcher_shared_target.h>
   34.22 -
   34.23 -/**
   34.24 - * \brief Returns whether dispatcher is currently disabled, given IP.
   34.25 - *
   34.26 - * \param disp  Pointer to dispatcher
   34.27 - * \param ip    User-level instruction pointer.
   34.28 - *
   34.29 - * \return true if dispatcher disabled, false otherwise.
   34.30 - */
   34.31 -static inline bool dispatcher_is_disabled_ip(dispatcher_handle_t handle,
   34.32 -                                             uintptr_t rip)
   34.33 -{
   34.34 -    struct dispatcher_shared_generic *disp =
   34.35 -        get_dispatcher_shared_generic(handle);
   34.36 -    return disp->disabled;
   34.37 -}
   34.38 -
   34.39 -static inline arch_registers_state_t*
   34.40 -dispatcher_get_enabled_save_area(dispatcher_handle_t handle)
   34.41 -{
   34.42 -    return dispatcher_beehive_get_enabled_save_area(handle);
   34.43 -}
   34.44 -
   34.45 -static inline arch_registers_state_t*
   34.46 -dispatcher_get_disabled_save_area(dispatcher_handle_t handle)
   34.47 -{
   34.48 -    return dispatcher_beehive_get_disabled_save_area(handle);
   34.49 -}
   34.50 -
   34.51 -static inline arch_registers_state_t*
   34.52 -dispatcher_get_trap_save_area(dispatcher_handle_t handle)
   34.53 -{
   34.54 -    return dispatcher_beehive_get_trap_save_area(handle);
   34.55 -}
   34.56 -
   34.57 -#endif // ARCH_BEEHIVE_BARRELFISH_KPI_DISPATCHER_SHARED_ARCH_H
    35.1 --- a/include/arch/beehive/barrelfish_kpi/generic_arch.h	Fri Jan 20 14:32:03 2012 -0800
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,21 +0,0 @@
    35.4 -/**
    35.5 - * \file
    35.6 - * \brief Generic include for a bunch of arch specific files
    35.7 - */
    35.8 -
    35.9 -/*
   35.10 - * Copyright (c) 2010, ETH Zurich.
   35.11 - * All rights reserved.
   35.12 - *
   35.13 - * This file is distributed under the terms in the attached LICENSE file.
   35.14 - * If you do not find this file, copies can be found by writing to:
   35.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   35.16 - */
   35.17 -
   35.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_GENERIC_H
   35.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_GENERIC_H
   35.20 -
   35.21 -#include <barrelfish_kpi/spinlocks_arch.h>
   35.22 -#include <barrelfish_kpi/unknown_arch.h>
   35.23 -
   35.24 -#endif // ARCH_BEEHIVE_BARRELFISH_KPI_GENERIC_H
    36.1 --- a/include/arch/beehive/barrelfish_kpi/lmp_arch.h	Fri Jan 20 14:32:03 2012 -0800
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,37 +0,0 @@
    36.4 -/**
    36.5 - * \file
    36.6 - * \brief Arch specific LMP declarations
    36.7 - */
    36.8 -
    36.9 -/*
   36.10 - * Copyright (c) 2010, ETH Zurich.
   36.11 - * All rights reserved.
   36.12 - *
   36.13 - * This file is distributed under the terms in the attached LICENSE file.
   36.14 - * If you do not find this file, copies can be found by writing to:
   36.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   36.16 - */
   36.17 -
   36.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_LMP_H
   36.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_LMP_H
   36.20 -
   36.21 -#include <barrelfish_kpi/legacy_idc_buffer.h>
   36.22 -
   36.23 -/**
   36.24 - * \brief Maximum total length of LMP and LRPC messages (payload)
   36.25 - *
   36.26 - * Determined by the size of idc_send_msg.  LMP is done by marshalling
   36.27 - * into an struct idc_send_msg in lmp_chan_arch.h and then invoking
   36.28 - * the endpoint capability passing the idc_send_msg.  This passes
   36.29 - * through the syscal call to handle_invocation in the kernel and
   36.30 - * thence lmp_deliver in the kernel.
   36.31 - */
   36.32 -
   36.33 -// Warning: this is also known to tools/flounder/Args.hs
   36.34 -
   36.35 -#define LMP_MSG_LENGTH          IDC_MSG_LENGTH
   36.36 -
   36.37 -// TODO: XXX Size of LRPC
   36.38 -#define LRPC_MSG_LENGTH         0
   36.39 -
   36.40 -#endif // ARCH_BEEHIVE_BARRELFISH_KPI_LMP_H
    37.1 --- a/include/arch/beehive/barrelfish_kpi/paging_arch.h	Fri Jan 20 14:32:03 2012 -0800
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,27 +0,0 @@
    37.4 -/**
    37.5 - * \file
    37.6 - * \brief Arch specific paging definitions
    37.7 - */
    37.8 -
    37.9 -/*
   37.10 - * Copyright (c) 2010, ETH Zurich.
   37.11 - * All rights reserved.
   37.12 - *
   37.13 - * This file is distributed under the terms in the attached LICENSE file.
   37.14 - * If you do not find this file, copies can be found by writing to:
   37.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   37.16 - */
   37.17 -
   37.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_PAGING_H
   37.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_PAGING_H
   37.20 -
   37.21 -// Required for various APIs to compile even if it means nothing
   37.22 -#define PTABLE_ACCESS_DEFAULT 0
   37.23 -
   37.24 -/* Default page size is 4K */
   37.25 -#define BASE_PAGE_BITS          12
   37.26 -#define BASE_PAGE_SIZE          (1u << BASE_PAGE_BITS)
   37.27 -#define BASE_PAGE_MASK          (BASE_PAGE_SIZE - 1)
   37.28 -#define BASE_PAGE_OFFSET(a)     ((a) & BASE_PAGE_MASK)
   37.29 -
   37.30 -#endif // ARCH_BEEHIVE_BARRELFISH_KPI_PAGING_H
    38.1 --- a/include/arch/beehive/barrelfish_kpi/registers_arch.h	Fri Jan 20 14:32:03 2012 -0800
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,71 +0,0 @@
    38.4 -/**
    38.5 - * \file
    38.6 - * \brief architecture-specific registers code
    38.7 - */
    38.8 -
    38.9 -/*
   38.10 - * Copyright (c) 2010, ETH Zurich.
   38.11 - * All rights reserved.
   38.12 - *
   38.13 - * This file is distributed under the terms in the attached LICENSE file.
   38.14 - * If you do not find this file, copies can be found by writing to:
   38.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   38.16 - */
   38.17 -
   38.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_REGISTERS_H
   38.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_REGISTERS_H
   38.20 -
   38.21 -// saved register 0 contains the count of words in RQ.  Currently
   38.22 -// if that is non-zero we panic.
   38.23 -
   38.24 -union registers_beehive {
   38.25 -    struct registers_beehive_named {
   38.26 -	uint32_t count;
   38.27 -	uint32_t return1, return2;
   38.28 -	uint32_t arg1, arg2, arg3, arg4, arg5, arg6;
   38.29 -	uint32_t save1, save2, save3, save4, save5, save6, save7, save8;
   38.30 -	uint32_t save9, save10, save11, save12, save13, save14;
   38.31 -	uint32_t frame;
   38.32 -	uint32_t t1, t2, t3;
   38.33 -	uint32_t p1;
   38.34 -	uint32_t stack;
   38.35 -	uint32_t vb;
   38.36 -	uint32_t link, pc;
   38.37 -	uint32_t rqvals[64];
   38.38 -    } named;
   38.39 -    uint32_t regs[sizeof(struct registers_beehive_named) / sizeof(uint32_t)];
   38.40 -};
   38.41 -
   38.42 -STATIC_ASSERT_SIZEOF(union registers_beehive, 96 * 4);
   38.43 -
   38.44 -///< Opaque handle for the register state
   38.45 -typedef union registers_beehive arch_registers_state_t;
   38.46 -
   38.47 -///< Opaque handle for the FPU register state
   38.48 -typedef void *arch_registers_fpu_state_t;
   38.49 -
   38.50 -static inline void
   38.51 -registers_set_entry(arch_registers_state_t *regs, lvaddr_t entry)
   38.52 -{
   38.53 -    regs->named.pc = (uint32_t)entry;
   38.54 -}
   38.55 -
   38.56 -static inline void
   38.57 -registers_set_param(arch_registers_state_t *regs, uint32_t param)
   38.58 -{
   38.59 -    regs->named.arg1 = param;
   38.60 -}
   38.61 -
   38.62 -static inline void
   38.63 -registers_get_param(arch_registers_state_t *regs, uint32_t *param)
   38.64 -{
   38.65 -    *param = regs->named.arg1;
   38.66 -}
   38.67 -
   38.68 -static inline uint32_t
   38.69 -registers_get_ip(arch_registers_state_t *regs)
   38.70 -{
   38.71 -    return regs->named.pc;
   38.72 -}
   38.73 -
   38.74 -#endif // ARCH_BEEHIVE_BARRELFISH_KPI_REGISTERS_H
    39.1 --- a/include/arch/beehive/barrelfish_kpi/spinlocks_arch.h	Fri Jan 20 14:32:03 2012 -0800
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,35 +0,0 @@
    39.4 -/**
    39.5 - * \file
    39.6 - * \brief
    39.7 - */
    39.8 -
    39.9 -/*
   39.10 - * Copyright (c) 2010, ETH Zurich.
   39.11 - * All rights reserved.
   39.12 - *
   39.13 - * This file is distributed under the terms in the attached LICENSE file.
   39.14 - * If you do not find this file, copies can be found by writing to:
   39.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   39.16 - */
   39.17 -
   39.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_SPINLOCKS_H
   39.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_SPINLOCKS_H
   39.20 -
   39.21 -// required for kernel printf -- really!
   39.22 -// and it has to be here which is strange
   39.23 -// spinlock_t must be an integer because lots of places initialise it with = 0
   39.24 -typedef int spinlock_t;
   39.25 -
   39.26 -static inline void acquire_spinlock(spinlock_t *lock)
   39.27 -{
   39.28 -    assert(*lock == 0);
   39.29 -    *lock = 1;
   39.30 -}
   39.31 -
   39.32 -static inline void release_spinlock(spinlock_t *lock)
   39.33 -{
   39.34 -    assert(*lock == 1);
   39.35 -    *lock = 0;
   39.36 -}
   39.37 -
   39.38 -#endif // ARCH_BEEHIVE_BARRELFISH_KPI_SPINLOCKS_H
    40.1 --- a/include/arch/beehive/barrelfish_kpi/unknown_arch.h	Fri Jan 20 14:32:03 2012 -0800
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,30 +0,0 @@
    40.4 -/**
    40.5 - * \file
    40.6 - * \brief Not sure where to put these definitions
    40.7 - */
    40.8 -
    40.9 -/*
   40.10 - * Copyright (c) 2010, ETH Zurich.
   40.11 - * All rights reserved.
   40.12 - *
   40.13 - * This file is distributed under the terms in the attached LICENSE file.
   40.14 - * If you do not find this file, copies can be found by writing to:
   40.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   40.16 - */
   40.17 -
   40.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_KPI_UNKNOWN_H
   40.19 -#define ARCH_BEEHIVE_BARRELFISH_KPI_UNKNOWN_H
   40.20 -
   40.21 -// required for lib/lwip/src/barrelfish/idc_barrelfish.c
   40.22 -
   40.23 -// We have a totally ordered memory system, but need to ensure that
   40.24 -// compiler optimised does not reorder across it.
   40.25 -#define mfence() __asm volatile("" : /*outs*/ : /*ins*/ : "memory")
   40.26 -
   40.27 -
   40.28 -// Provided by assembler
   40.29 -extern void bee_dcache_flush_rgn(void * a,size_t n);
   40.30 -
   40.31 -#define cache_flush_range(_b, _l) bee_dcache_flush_rgn((_b), (_l))
   40.32 -
   40.33 -#endif // ARCH_BEEHIVE_BARRELFISH_KPI_UNKNOWN_H
    41.1 --- a/include/arch/beehive/beej7.h	Fri Jan 20 14:32:03 2012 -0800
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,26 +0,0 @@
    41.4 -/**
    41.5 - * \file
    41.6 - * \brief beehive j7 dop definitions
    41.7 - */
    41.8 -
    41.9 -/*
   41.10 - * Copyright (c) 2009, 2010, ETH Zurich.
   41.11 - * All rights reserved.
   41.12 - *
   41.13 - * This file is distributed under the terms in the attached LICENSE file.
   41.14 - * If you do not find this file, copies can be found by writing to:
   41.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   41.16 - */
   41.17 -
   41.18 -#ifndef ARCH_BEEHIVE_J7_H
   41.19 -#define ARCH_BEEHIVE_J7_H
   41.20 -
   41.21 -#define BEE_J7_NOP 0
   41.22 -#define BEE_J7_COREAREA 1
   41.23 -#define BEE_J7_SAVEDPC 2
   41.24 -#define BEE_J7_SAVEDLINK 3
   41.25 -#define BEE_J7_TEST_RQ_EMPTY 4
   41.26 -#define BEE_J7_TEST_RUNNING 5
   41.27 -#define BEE_J7_BREAKPOINT 6
   41.28 -
   41.29 -#endif // ARCH_BEEHIVE_J7_H
    42.1 --- a/include/arch/beehive/bench/bench_arch.h	Fri Jan 20 14:32:03 2012 -0800
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,30 +0,0 @@
    42.4 -/**
    42.5 - * \file
    42.6 - * \brief Arch specific bench include.
    42.7 - */
    42.8 -
    42.9 -/*
   42.10 - * Copyright (c) 2010, ETH Zurich.
   42.11 - * All rights reserved.
   42.12 - *
   42.13 - * This file is distributed under the terms in the attached LICENSE file.
   42.14 - * If you do not find this file, copies can be found by writing to:
   42.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   42.16 - */
   42.17 -
   42.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_BENCH_H
   42.19 -#define ARCH_BEEHIVE_BARRELFISH_BENCH_H
   42.20 -
   42.21 -#include <bench/bench.h>
   42.22 -
   42.23 -void bench_arch_init(void);
   42.24 -
   42.25 -/**
   42.26 - * \brief Take a timestamp
   42.27 - */
   42.28 -static inline cycles_t bench_tsc(void)
   42.29 -{
   42.30 -    return *(volatile size_t *)(0x22);
   42.31 -}
   42.32 -
   42.33 -#endif // ARCH_BEEHIVE_BARRELFISH_BENCH_H
    43.1 --- a/include/arch/beehive/corearea.h	Fri Jan 20 14:32:03 2012 -0800
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,63 +0,0 @@
    43.4 -/**
    43.5 - * \file
    43.6 - * \brief Per-core debug stub save area
    43.7 - */
    43.8 -
    43.9 -/*
   43.10 - * Copyright (c) 2010, ETH Zurich.
   43.11 - * All rights reserved.
   43.12 - *
   43.13 - * This file is distributed under the terms in the attached LICENSE file.
   43.14 - * If you do not find this file, copies can be found by writing to:
   43.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   43.16 - */
   43.17 -
   43.18 -#ifndef ARCH_BEEHIVE_COREAREA_H
   43.19 -#define ARCH_BEEHIVE_COREAREA_H
   43.20 -
   43.21 -#include <barrelfish/static_assert.h>
   43.22 -
   43.23 -struct corearea {
   43.24 -    uint32_t regs[32];
   43.25 -    uint32_t rqarea[64];
   43.26 -    uint32_t flags0;
   43.27 -    uint32_t pad0[7];
   43.28 -    /* This next cache line is invalidated and read by the slave and
   43.29 -     * only ever written and flushed by the master */
   43.30 -    uint32_t master_stops;
   43.31 -    uint32_t master_ticks;
   43.32 -    uint32_t pad1[6];
   43.33 -    /* This next cache line is invalidated and read by the master and
   43.34 -     * only ever written and flushed by the slave */
   43.35 -    uint32_t slave_stops;
   43.36 -    uint32_t slave_ticks;
   43.37 -    uint32_t pad2[6];
   43.38 -    /* This cache line is used for communicating between the debug
   43.39 -     * stub and the kernel */
   43.40 -    uint32_t kernel_begins;  // code address
   43.41 -    uint32_t kernel_ends;    // code address
   43.42 -    uint32_t kernel_ticker;  // code address
   43.43 -    uint32_t kernel_pending; // != 0 implies software interrupt pending
   43.44 -    uint32_t syspad[3];
   43.45 -    uint32_t syscall;        // code address
   43.46 -};
   43.47 -
   43.48 -STATIC_ASSERT_SIZEOF(struct corearea, 128 * 4);
   43.49 -// Flags areas must be each in their own cache line
   43.50 -STATIC_ASSERT((sa_offsetof(struct corearea, flags0) & 31) == 0, "alignment");
   43.51 -STATIC_ASSERT((sa_offsetof(struct corearea, master_stops) & 31) == 0, "alignment");
   43.52 -STATIC_ASSERT((sa_offsetof(struct corearea, slave_stops) & 31) == 0, "alignment");
   43.53 -STATIC_ASSERT((sa_offsetof(struct corearea, kernel_begins) & 31) == 0, "alignment");
   43.54 -
   43.55 -#define COREAREA_FOR_CORE(_core) \
   43.56 -	((struct corearea *)(0x4000 + ((_core) << 9)))
   43.57 -
   43.58 -static inline struct corearea *my_corearea(void)
   43.59 -{
   43.60 -    struct corearea *result;
   43.61 -    __asm("j7 1; ld %[result], link"
   43.62 -	  : [result]"=r" (result) :: "link", "cc");
   43.63 -    return result;
   43.64 -}
   43.65 -
   43.66 -#endif // ARCH_BEEHIVE_COREAREA_H
    44.1 --- a/include/arch/beehive/dcache.h	Fri Jan 20 14:32:03 2012 -0800
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,34 +0,0 @@
    44.4 -/**
    44.5 - * \file
    44.6 - * \brief Prototypes for Cache Management
    44.7 - */
    44.8 -
    44.9 -/*
   44.10 - * Copyright (c) 2010, ETH Zurich.
   44.11 - * All rights reserved.
   44.12 - *
   44.13 - * This file is distributed under the terms in the attached LICENSE file.
   44.14 - * If you do not find this file, copies can be found by writing to:
   44.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   44.16 - */
   44.17 -
   44.18 -#ifndef ARCH_BEEHIVE_DCACHE_H
   44.19 -#define ARCH_BEEHIVE_DCACHE_H
   44.20 -
   44.21 -/*
   44.22 - * Atomically flush and then invalidate the entire cache
   44.23 - */
   44.24 -
   44.25 -extern void bee_dcache_empty_all(void);
   44.26 -
   44.27 -/*
   44.28 - * Flush (with writeback) the entire cache
   44.29 - */
   44.30 -
   44.31 -static inline void bee_dcache_flush_all(void)
   44.32 -{
   44.33 -    __asm volatile ("aqw_long_ld vb,0x8001fc03 ROL 2"
   44.34 -	  ::: "link", "cc");
   44.35 -}
   44.36 -
   44.37 -#endif // ARCH_BEEHIVE_DCACHE_H
    45.1 --- a/include/arch/beehive/fenv.h	Fri Jan 20 14:32:03 2012 -0800
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,217 +0,0 @@
    45.4 -/*-
    45.5 - * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
    45.6 - * All rights reserved.
    45.7 - *
    45.8 - * Redistribution and use in source and binary forms, with or without
    45.9 - * modification, are permitted provided that the following conditions
   45.10 - * are met:
   45.11 - * 1. Redistributions of source code must retain the above copyright
   45.12 - *    notice, this list of conditions and the following disclaimer.
   45.13 - * 2. Redistributions in binary form must reproduce the above copyright
   45.14 - *    notice, this list of conditions and the following disclaimer in the
   45.15 - *    documentation and/or other materials provided with the distribution.
   45.16 - *
   45.17 - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   45.18 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   45.19 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   45.20 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   45.21 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   45.22 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   45.23 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   45.24 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   45.25 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   45.26 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   45.27 - * SUCH DAMAGE.
   45.28 - *
   45.29 - * $FreeBSD: src/lib/msun/mips/fenv.h,v 1.1 2008/04/26 12:20:29 imp Exp $
   45.30 - */
   45.31 -
   45.32 -#ifndef	_FENV_H_
   45.33 -#define	_FENV_H_
   45.34 -
   45.35 -#include <sys/_types.h>
   45.36 -
   45.37 -typedef	__uint32_t	fenv_t;
   45.38 -typedef	__uint32_t	fexcept_t;
   45.39 -
   45.40 -/* Exception flags */
   45.41 -#define	FE_INVALID	0x0001
   45.42 -#define	FE_DIVBYZERO	0x0002
   45.43 -#define	FE_OVERFLOW	0x0004
   45.44 -#define	FE_UNDERFLOW	0x0008
   45.45 -#define	FE_INEXACT	0x0010
   45.46 -#define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
   45.47 -			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
   45.48 -
   45.49 -/* Rounding modes */
   45.50 -#define	FE_TONEAREST	0x0000
   45.51 -#define	FE_TOWARDZERO	0x0001
   45.52 -#define	FE_UPWARD	0x0002
   45.53 -#define	FE_DOWNWARD	0x0003
   45.54 -#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
   45.55 -			 FE_UPWARD | FE_TOWARDZERO)
   45.56 -__BEGIN_DECLS
   45.57 -
   45.58 -/* Default floating-point environment */
   45.59 -extern const fenv_t	__fe_dfl_env;
   45.60 -#define	FE_DFL_ENV	(&__fe_dfl_env)
   45.61 -
   45.62 -/* We need to be able to map status flag positions to mask flag positions */
   45.63 -#define _FPUSW_SHIFT	16
   45.64 -#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
   45.65 -
   45.66 -#ifdef	ARM_HARD_FLOAT
   45.67 -#define	__rfs(__fpsr)	__asm __volatile("rfs %0" : "=r" (*(__fpsr)))
   45.68 -#define	__wfs(__fpsr)	__asm __volatile("wfs %0" : : "r" (__fpsr))
   45.69 -#else
   45.70 -#define __rfs(__fpsr)
   45.71 -#define __wfs(__fpsr)
   45.72 -#endif
   45.73 -
   45.74 -static __inline int
   45.75 -feclearexcept(int __excepts)
   45.76 -{
   45.77 -	fexcept_t __fpsr;
   45.78 -
   45.79 -	__rfs(&__fpsr);
   45.80 -	__fpsr &= ~__excepts;
   45.81 -	__wfs(__fpsr);
   45.82 -	return (0);
   45.83 -}
   45.84 -
   45.85 -static __inline int
   45.86 -fegetexceptflag(fexcept_t *__flagp, int __excepts)
   45.87 -{
   45.88 -	fexcept_t __fpsr;
   45.89 -
   45.90 -	__rfs(&__fpsr);
   45.91 -	*__flagp = __fpsr & __excepts;
   45.92 -	return (0);
   45.93 -}
   45.94 -
   45.95 -static __inline int
   45.96 -fesetexceptflag(const fexcept_t *__flagp, int __excepts)
   45.97 -{
   45.98 -	fexcept_t __fpsr;
   45.99 -
  45.100 -	__rfs(&__fpsr);
  45.101 -	__fpsr &= ~__excepts;
  45.102 -	__fpsr |= *__flagp & __excepts;
  45.103 -	__wfs(__fpsr);
  45.104 -	return (0);
  45.105 -}
  45.106 -
  45.107 -static __inline int
  45.108 -feraiseexcept(int __excepts)
  45.109 -{
  45.110 -	fexcept_t __ex = __excepts;
  45.111 -
  45.112 -	fesetexceptflag(&__ex, __excepts);	/* XXX */
  45.113 -	return (0);
  45.114 -}
  45.115 -
  45.116 -static __inline int
  45.117 -fetestexcept(int __excepts)
  45.118 -{
  45.119 -	fexcept_t __fpsr;
  45.120 -
  45.121 -	__rfs(&__fpsr);
  45.122 -	return (__fpsr & __excepts);
  45.123 -}
  45.124 -
  45.125 -static __inline int
  45.126 -fegetround(void)
  45.127 -{
  45.128 -
  45.129 -	/*
  45.130 -	 * Apparently, the rounding mode is specified as part of the
  45.131 -	 * instruction format on ARM, so the dynamic rounding mode is
  45.132 -	 * indeterminate.  Some FPUs may differ.
  45.133 -	 */
  45.134 -	return (-1);
  45.135 -}
  45.136 -
  45.137 -static __inline int
  45.138 -fesetround(int __round)
  45.139 -{
  45.140 -
  45.141 -	return (-1);
  45.142 -}
  45.143 -
  45.144 -static __inline int
  45.145 -fegetenv(fenv_t *__envp)
  45.146 -{
  45.147 -
  45.148 -	__rfs(__envp);
  45.149 -	return (0);
  45.150 -}
  45.151 -
  45.152 -static __inline int
  45.153 -feholdexcept(fenv_t *__envp)
  45.154 -{
  45.155 -	fenv_t __env;
  45.156 -
  45.157 -	__rfs(&__env);
  45.158 -	*__envp = __env;
  45.159 -	__env &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);
  45.160 -	__wfs(__env);
  45.161 -	return (0);
  45.162 -}
  45.163 -
  45.164 -static __inline int
  45.165 -fesetenv(const fenv_t *__envp)
  45.166 -{
  45.167 -
  45.168 -	__wfs(*__envp);
  45.169 -	return (0);
  45.170 -}
  45.171 -
  45.172 -static __inline int
  45.173 -feupdateenv(const fenv_t *__envp)
  45.174 -{
  45.175 -	fexcept_t __fpsr;
  45.176 -
  45.177 -	__rfs(&__fpsr);
  45.178 -	__wfs(*__envp);
  45.179 -	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
  45.180 -	return (0);
  45.181 -}
  45.182 -
  45.183 -#if __BSD_VISIBLE
  45.184 -
  45.185 -static __inline int
  45.186 -feenableexcept(int __mask)
  45.187 -{
  45.188 -	fenv_t __old_fpsr, __new_fpsr;
  45.189 -
  45.190 -	__rfs(&__old_fpsr);
  45.191 -	__new_fpsr = __old_fpsr | (__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT;
  45.192 -	__wfs(__new_fpsr);
  45.193 -	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
  45.194 -}
  45.195 -
  45.196 -static __inline int
  45.197 -fedisableexcept(int __mask)
  45.198 -{
  45.199 -	fenv_t __old_fpsr, __new_fpsr;
  45.200 -
  45.201 -	__rfs(&__old_fpsr);
  45.202 -	__new_fpsr = __old_fpsr & ~((__mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);
  45.203 -	__wfs(__new_fpsr);
  45.204 -	return ((__old_fpsr >> _FPUSW_SHIFT) & FE_ALL_EXCEPT);
  45.205 -}
  45.206 -
  45.207 -static __inline int
  45.208 -fegetexcept(void)
  45.209 -{
  45.210 -	fenv_t __fpsr;
  45.211 -
  45.212 -	__rfs(&__fpsr);
  45.213 -	return ((__fpsr & _ENABLE_MASK) >> _FPUSW_SHIFT);
  45.214 -}
  45.215 -
  45.216 -#endif /* __BSD_VISIBLE */
  45.217 -
  45.218 -__END_DECLS
  45.219 -
  45.220 -#endif	/* !_FENV_H_ */
    46.1 --- a/include/arch/beehive/float.h	Fri Jan 20 14:32:03 2012 -0800
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,83 +0,0 @@
    46.4 -/*      $NetBSD: float.h,v 1.6 2005/12/11 12:16:47 christos Exp $       */
    46.5 -/*      $NetBSD: float_ieee754.h,v 1.8 2005/12/11 12:25:20 christos Exp $       */
    46.6 -
    46.7 -/*
    46.8 - * Copyright (c) 1992, 1993
    46.9 - *      The Regents of the University of California.  All rights reserved.
   46.10 - *
   46.11 - * Redistribution and use in source and binary forms, with or without
   46.12 - * modification, are permitted provided that the following conditions
   46.13 - * are met:
   46.14 - * 1. Redistributions of source code must retain the above copyright
   46.15 - *    notice, this list of conditions and the following disclaimer.
   46.16 - * 2. Redistributions in binary form must reproduce the above copyright
   46.17 - *    notice, this list of conditions and the following disclaimer in the
   46.18 - *    documentation and/or other materials provided with the distribution.
   46.19 - * 3. Neither the name of the University nor the names of its contributors
   46.20 - *    may be used to endorse or promote products derived from this software
   46.21 - *    without specific prior written permission.
   46.22 - *
   46.23 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   46.24 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   46.25 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   46.26 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   46.27 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   46.28 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   46.29 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   46.30 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   46.31 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   46.32 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   46.33 - * SUCH DAMAGE.
   46.34 - *
   46.35 - *      @(#)float.h     8.1 (Berkeley) 6/10/93
   46.36 - */
   46.37 -
   46.38 -#ifndef _ARM_FLOAT_H_
   46.39 -#define _ARM_FLOAT_H_
   46.40 -
   46.41 -#include <sys/cdefs.h>
   46.42 -
   46.43 -#ifndef FLT_ROUNDS
   46.44 -__BEGIN_DECLS
   46.45 -extern int __flt_rounds(void);
   46.46 -__END_DECLS
   46.47 -#define FLT_ROUNDS      -1 /* __flt_rounds() */
   46.48 -#endif
   46.49 -
   46.50 -#define FLT_EVAL_METHOD (-1)            /* XXX */
   46.51 -
   46.52 -#define LDBL_MANT_DIG   64
   46.53 -#define LDBL_EPSILON    1.0842021724855044340E-19L
   46.54 -#define LDBL_DIG        18
   46.55 -#define LDBL_MIN_EXP    (-16381)
   46.56 -#define LDBL_MIN        1.6810515715560467531E-4932L
   46.57 -#define LDBL_MIN_10_EXP (-4931)
   46.58 -#define LDBL_MAX_EXP    16384
   46.59 -#define LDBL_MAX        1.1897314953572317650E+4932L
   46.60 -#define LDBL_MAX_10_EXP 4932
   46.61 -
   46.62 -#define FLT_RADIX       2               /* b */
   46.63 -
   46.64 -#define FLT_MANT_DIG    24              /* p */
   46.65 -#define FLT_EPSILON     1.19209290E-7F  /* b**(1-p) */
   46.66 -#define FLT_DIG         6               /* floor((p-1)*log10(b))+(b == 10) */
   46.67 -#define FLT_MIN_EXP     (-125)          /* emin */
   46.68 -#define FLT_MIN         1.17549435E-38F /* b**(emin-1) */
   46.69 -#define FLT_MIN_10_EXP  (-37)           /* ceil(log10(b**(emin-1))) */
   46.70 -#define FLT_MAX_EXP     128             /* emax */
   46.71 -#define FLT_MAX         3.40282347E+38F /* (1-b**(-p))*b**emax */
   46.72 -#define FLT_MAX_10_EXP  38              /* floor(log10((1-b**(-p))*b**emax)) */
   46.73 -
   46.74 -#define DBL_MANT_DIG    53
   46.75 -#define DBL_EPSILON     2.2204460492503131E-16
   46.76 -#define DBL_DIG         15
   46.77 -#define DBL_MIN_EXP     (-1021)
   46.78 -#define DBL_MIN         2.2250738585072014E-308
   46.79 -#define DBL_MIN_10_EXP  (-307)
   46.80 -#define DBL_MAX_EXP     1024
   46.81 -#define DBL_MAX         1.7976931348623157E+308
   46.82 -#define DBL_MAX_10_EXP  308
   46.83 -
   46.84 -#define DECIMAL_DIG     17              /* ceil((1+p*log10(b))-(b==10) */
   46.85 -
   46.86 -#endif /* !_ARM_FLOAT_H_ */
    47.1 --- a/include/arch/beehive/machine/_limits.h	Fri Jan 20 14:32:03 2012 -0800
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,100 +0,0 @@
    47.4 -/*-
    47.5 - * Copyright (c) 1988, 1993
    47.6 - *	The Regents of the University of California.  All rights reserved.
    47.7 - *
    47.8 - * Redistribution and use in source and binary forms, with or without
    47.9 - * modification, are permitted provided that the following conditions
   47.10 - * are met:
   47.11 - * 1. Redistributions of source code must retain the above copyright
   47.12 - *    notice, this list of conditions and the following disclaimer.
   47.13 - * 2. Redistributions in binary form must reproduce the above copyright
   47.14 - *    notice, this list of conditions and the following disclaimer in the
   47.15 - *    documentation and/or other materials provided with the distribution.
   47.16 - * 4. Neither the name of the University nor the names of its contributors
   47.17 - *    may be used to endorse or promote products derived from this software
   47.18 - *    without specific prior written permission.
   47.19 - *
   47.20 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   47.21 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   47.22 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   47.23 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   47.24 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   47.25 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   47.26 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   47.27 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   47.28 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   47.29 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   47.30 - * SUCH DAMAGE.
   47.31 - *
   47.32 - *	@(#)limits.h	8.3 (Berkeley) 1/4/94
   47.33 - * $FreeBSD$
   47.34 - */
   47.35 -
   47.36 -#ifndef _MACHINE__LIMITS_H_
   47.37 -#define	_MACHINE__LIMITS_H_
   47.38 -
   47.39 -/*
   47.40 - * According to ANSI (section 2.2.4.2), the values below must be usable by
   47.41 - * #if preprocessing directives.  Additionally, the expression must have the
   47.42 - * same type as would an expression that is an object of the corresponding
   47.43 - * type converted according to the integral promotions.  The subtraction for
   47.44 - * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an
   47.45 - * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2).
   47.46 - * These numbers are for the default configuration of gcc.  They work for
   47.47 - * some other compilers as well, but this should not be depended on.
   47.48 - */
   47.49 -
   47.50 -#define	__CHAR_BIT	8		/* number of bits in a char */
   47.51 -
   47.52 -#define	__SCHAR_MAX	0x7f		/* max value for a signed char */
   47.53 -#define	__SCHAR_MIN	(-0x7f - 1)	/* min value for a signed char */
   47.54 -
   47.55 -#define	__UCHAR_MAX	0xff		/* max value for an unsigned char */
   47.56 -
   47.57 -#define	__USHRT_MAX	0xffff		/* max value for an unsigned short */
   47.58 -#define	__SHRT_MAX	0x7fff		/* max value for a short */
   47.59 -#define	__SHRT_MIN	(-0x7fff - 1)	/* min value for a short */
   47.60 -
   47.61 -#define	__UINT_MAX	0xffffffffU	/* max value for an unsigned int */
   47.62 -#define	__INT_MAX	0x7fffffff	/* max value for an int */
   47.63 -#define	__INT_MIN	(-0x7fffffff - 1)	/* min value for an int */
   47.64 -
   47.65 -/* Bad hack for gcc configured to give 64-bit longs. */
   47.66 -#ifdef _LARGE_LONG
   47.67 -#define	__ULONG_MAX	0xffffffffffffffffUL
   47.68 -#define	__LONG_MAX	0x7fffffffffffffffL
   47.69 -#define	__LONG_MIN	(-0x7fffffffffffffffL - 1)
   47.70 -#else
   47.71 -#define	__ULONG_MAX	0xffffffffUL	/* max value for an unsigned long */
   47.72 -#define	__LONG_MAX	0x7fffffffL	/* max value for a long */
   47.73 -#define	__LONG_MIN	(-0x7fffffffL - 1)	/* min value for a long */
   47.74 -#endif
   47.75 -
   47.76 -			/* max value for an unsigned long long */
   47.77 -#define	__ULLONG_MAX	0xffffffffffffffffULL
   47.78 -#define	__LLONG_MAX	0x7fffffffffffffffLL	/* max value for a long long */
   47.79 -#define	__LLONG_MIN	(-0x7fffffffffffffffLL - 1)  /* min for a long long */
   47.80 -
   47.81 -#define	__SSIZE_MAX	__INT_MAX	/* max value for a ssize_t */
   47.82 -
   47.83 -#define	__SIZE_T_MAX	__UINT_MAX	/* max value for a size_t */
   47.84 -
   47.85 -#define	__OFF_MAX	__LLONG_MAX	/* max value for a off_t */
   47.86 -#define	__OFF_MIN	__LLONG_MIN	/* min value for a off_t */
   47.87 -
   47.88 -/* Quads and long longs are the same size.  Ensure they stay in sync. */
   47.89 -#define	__UQUAD_MAX	__ULLONG_MAX	/* max value for a uquad_t */
   47.90 -#define	__QUAD_MAX	__LLONG_MAX	/* max value for a quad_t */
   47.91 -#define	__QUAD_MIN	__LLONG_MIN	/* min value for a quad_t */
   47.92 -
   47.93 -#ifdef _LARGE_LONG
   47.94 -#define	__LONG_BIT	64
   47.95 -#else
   47.96 -#define	__LONG_BIT	32
   47.97 -#endif
   47.98 -#define	__WORD_BIT	32
   47.99 -
  47.100 -/* Minimum signal stack size. */
  47.101 -#define	__MINSIGSTKSZ	(1024 * 4)
  47.102 -
  47.103 -#endif /* !_MACHINE__LIMITS_H_ */
    48.1 --- a/include/arch/beehive/machine/endian.h	Fri Jan 20 14:32:03 2012 -0800
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,129 +0,0 @@
    48.4 -/*-
    48.5 - * Copyright (c) 2001 David E. O'Brien
    48.6 - *
    48.7 - * Redistribution and use in source and binary forms, with or without
    48.8 - * modification, are permitted provided that the following conditions
    48.9 - * are met:
   48.10 - * 1. Redistributions of source code must retain the above copyright
   48.11 - *    notice, this list of conditions and the following disclaimer.
   48.12 - * 2. Redistributions in binary form must reproduce the above copyright
   48.13 - *    notice, this list of conditions and the following disclaimer in the
   48.14 - *    documentation and/or other materials provided with the distribution.
   48.15 - * 3. Neither the name of the University nor the names of its contributors
   48.16 - *    may be used to endorse or promote products derived from this software
   48.17 - *    without specific prior written permission.
   48.18 - *
   48.19 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   48.20 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   48.21 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   48.22 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   48.23 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   48.24 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   48.25 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   48.26 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   48.27 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   48.28 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   48.29 - * SUCH DAMAGE.
   48.30 - *
   48.31 - *	@(#)endian.h	8.1 (Berkeley) 6/10/93
   48.32 - * $NetBSD: endian.h,v 1.7 1999/08/21 05:53:51 simonb Exp $
   48.33 - * $FreeBSD$
   48.34 - */
   48.35 -
   48.36 -#ifndef _ENDIAN_H_
   48.37 -#define	_ENDIAN_H_
   48.38 -
   48.39 -#include <sys/_types.h>
   48.40 -
   48.41 -/*
   48.42 - * Definitions for byte order, according to byte significance from low
   48.43 - * address to high.
   48.44 - */
   48.45 -#define _LITTLE_ENDIAN  1234    /* LSB first: i386, vax */
   48.46 -#define _BIG_ENDIAN     4321    /* MSB first: 68000, ibm, net */
   48.47 -#define _PDP_ENDIAN     3412    /* LSB first in word, MSW first in long */
   48.48 -
   48.49 -#define	_BYTE_ORDER	_LITTLE_ENDIAN
   48.50 -
   48.51 -#if __BSD_VISIBLE
   48.52 -#define LITTLE_ENDIAN   _LITTLE_ENDIAN
   48.53 -#define BIG_ENDIAN      _BIG_ENDIAN
   48.54 -#define PDP_ENDIAN      _PDP_ENDIAN
   48.55 -#define BYTE_ORDER      _BYTE_ORDER
   48.56 -#endif
   48.57 -
   48.58 -#define _QUAD_HIGHWORD  1
   48.59 -#define _QUAD_LOWWORD 0
   48.60 -#define __ntohl(x)        (__bswap32(x))
   48.61 -#define __ntohs(x)        (__bswap16(x))
   48.62 -#define __htonl(x)        (__bswap32(x))
   48.63 -#define __htons(x)        (__bswap16(x))
   48.64 -
   48.65 -
   48.66 -static __inline __uint64_t
   48.67 -__bswap64(__uint64_t _x)
   48.68 -{
   48.69 -
   48.70 -	return ((_x >> 56) | ((_x >> 40) & 0xff00) | ((_x >> 24) & 0xff0000) |
   48.71 -	    ((_x >> 8) & 0xff000000) | ((_x << 8) & ((__uint64_t)0xff << 32)) |
   48.72 -	    ((_x << 24) & ((__uint64_t)0xff << 40)) | 
   48.73 -	    ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
   48.74 -}
   48.75 -
   48.76 -static __inline __uint32_t
   48.77 -__bswap32_var(__uint32_t v)
   48.78 -{
   48.79 -	__uint32_t t1;
   48.80 -
   48.81 -	__asm __volatile("eor %1, %0, %0, ror #16\n"
   48.82 -	    		"bic %1, %1, #0x00ff0000\n"
   48.83 -			"mov %0, %0, ror #8\n"
   48.84 -			"eor %0, %0, %1, lsr #8\n"
   48.85 -			 : "+r" (v), "=r" (t1));
   48.86 -	
   48.87 -	return (v);
   48.88 -}
   48.89 -
   48.90 -static __inline __uint16_t
   48.91 -__bswap16_var(__uint16_t v)
   48.92 -{
   48.93 -	__uint32_t ret = v & 0xffff;
   48.94 -
   48.95 -	__asm __volatile(
   48.96 -	    "mov    %0, %0, ror #8\n"
   48.97 -	    "orr    %0, %0, %0, lsr #16\n"
   48.98 -	    "bic    %0, %0, %0, lsl #16"
   48.99 -	    : "+r" (ret));
  48.100 -	
  48.101 -	return ((__uint16_t)ret);
  48.102 -}		
  48.103 -
  48.104 -#ifdef __OPTIMIZE__
  48.105 -
  48.106 -#define __bswap32_constant(x)	\
  48.107 -    ((((x) & 0xff000000U) >> 24) |	\
  48.108 -     (((x) & 0x00ff0000U) >>  8) |	\
  48.109 -     (((x) & 0x0000ff00U) <<  8) |	\
  48.110 -     (((x) & 0x000000ffU) << 24))
  48.111 -
  48.112 -#define __bswap16_constant(x)	\
  48.113 -    ((((x) & 0xff00) >> 8) |		\
  48.114 -     (((x) & 0x00ff) << 8))
  48.115 -
  48.116 -#define __bswap16(x)	\
  48.117 -    ((__uint16_t)(__builtin_constant_p(x) ?	\
  48.118 -     __bswap16_constant(x) :			\
  48.119 -     __bswap16_var(x)))
  48.120 -
  48.121 -#define __bswap32(x)	\
  48.122 -    ((__uint32_t)(__builtin_constant_p(x) ? 	\
  48.123 -     __bswap32_constant(x) :			\
  48.124 -     __bswap32_var(x)))
  48.125 -
  48.126 -#else
  48.127 -#define __bswap16(x)	__bswap16_var(x)
  48.128 -#define __bswap32(x)	__bswap32_var(x)
  48.129 -
  48.130 -#endif /* __OPTIMIZE__ */
  48.131 -#endif /* !_ENDIAN_H_ */
  48.132 -
    49.1 --- a/include/arch/beehive/regconvention.h	Fri Jan 20 14:32:03 2012 -0800
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,70 +0,0 @@
    49.4 -/*
    49.5 - * Copyright (c) 2009, ETH Zurich.
    49.6 - * All rights reserved.
    49.7 - *
    49.8 - * This file is distributed under the terms in the attached LICENSE file.
    49.9 - * If you do not find this file, copies can be found by writing to:
   49.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   49.11 - */
   49.12 -
   49.13 -// ------------------------------------------------------------
   49.14 -// Standard assembler definitions
   49.15 -
   49.16 -r0 = $0      // fixed zero
   49.17 -r1 = $1      // function return 1
   49.18 -r2 = $2      // not callee save, function return 2
   49.19 -r3 = $3      // not callee save, function argument 1
   49.20 -r4 = $4      // not callee save, function argument 2
   49.21 -r5 = $5      // not callee save, function argument 3
   49.22 -r6 = $6      // not callee save, function argument 4
   49.23 -r7 = $7      // not callee save, function argument 5
   49.24 -r8 = $8      // not callee save, function argument 6
   49.25 -r9 = $9      // callee save
   49.26 -r10 = $10    // callee save
   49.27 -r11 = $11    // callee save
   49.28 -r12 = $12    // callee save
   49.29 -r13 = $13    // callee save
   49.30 -r14 = $14    // callee save
   49.31 -r15 = $15    // callee save
   49.32 -r16 = $16    // callee save
   49.33 -r17 = $17    // callee save
   49.34 -r18 = $18    // callee save
   49.35 -r19 = $19    // callee save
   49.36 -r20 = $20    // callee save
   49.37 -r21 = $21    // callee save
   49.38 -r22 = $22    // callee save
   49.39 -
   49.40 -fp = $23     // callee save, frame pointer
   49.41 -t1 = $24     // not callee save, temporary 1, not avail for reg alloc
   49.42 -t2 = $25     // not callee save, temporary 2, not avail for reg alloc
   49.43 -t3 = $26     // not callee save, temporary 3, not avail for reg alloc
   49.44 -p1 = $27     // not callee save, platform 1, not avail for reg alloc
   49.45 -sp = $28     // callee save, stack pointer
   49.46 -vb = $29     // not callee save, rw & rb only, not avail for reg alloc
   49.47 -
   49.48 -zero = $0    // fixed zero
   49.49 -void = $0    // discard register
   49.50 -a1 = $3      // not callee save, function argument 1
   49.51 -a2 = $4      // not callee save, function argument 2
   49.52 -a3 = $5      // not callee save, function argument 3
   49.53 -a4 = $6      // not callee save, function argument 4
   49.54 -a5 = $7      // not callee save, function argument 5
   49.55 -a6 = $8      // not callee save, function argument 6
   49.56 -s1 = $9      // callee save
   49.57 -s2 = $10     // callee save
   49.58 -s3 = $11     // callee save
   49.59 -s4 = $12     // callee save
   49.60 -s5 = $13     // callee save
   49.61 -s6 = $14     // callee save
   49.62 -s7 = $15     // callee save
   49.63 -s8 = $16     // callee save
   49.64 -s9 = $17     // callee save
   49.65 -s10 = $18    // callee save
   49.66 -s11 = $19    // callee save
   49.67 -s12 = $20    // callee save
   49.68 -s13 = $21    // callee save
   49.69 -s14 = $22    // callee save
   49.70 -
   49.71 -    .assume   zero,0
   49.72 -
   49.73 -// ------------------------------------------------------------
    50.1 --- a/include/arch/beehive/simctrl.h	Fri Jan 20 14:32:03 2012 -0800
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,40 +0,0 @@
    50.4 -/**
    50.5 - * \file
    50.6 - * \brief simulator control pseudo-instructions
    50.7 - */
    50.8 -
    50.9 -/*
   50.10 - * Copyright (c) 2009, 2010, ETH Zurich.
   50.11 - * All rights reserved.
   50.12 - *
   50.13 - * This file is distributed under the terms in the attached LICENSE file.
   50.14 - * If you do not find this file, copies can be found by writing to:
   50.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   50.16 - */
   50.17 -
   50.18 -#ifndef ARCH_BEEHIVE_SIMCTRL_H
   50.19 -#define ARCH_BEEHIVE_SIMCTRL_H
   50.20 -
   50.21 -#define BEE_SIMCTRL_NOP 0
   50.22 -#define BEE_SIMCTRL_TERMINATE 1
   50.23 -#define BEE_SIMCTRL_TRACEON 2
   50.24 -#define BEE_SIMCTRL_TRACEOFF 3
   50.25 -#define BEE_SIMCTRL_REGISTERS 4
   50.26 -#define BEE_SIMCTRL_ILLEGAL 5
   50.27 -#define BEE_SIMCTRL_NOSEQTRACE 6
   50.28 -#define BEE_SIMCTRL_ADDRCHECK 7
   50.29 -#define BEE_SIMCTRL_CACHE_DELTA 8
   50.30 -#define BEE_SIMCTRL_CACHE_STAT 9
   50.31 -#define BEE_SIMCTRL_BREAK_SIM 10
   50.32 -#define BEE_SIMCTRL_TRACE 11
   50.33 -#define BEE_SIMCTRL_HALT 12
   50.34 -
   50.35 -#ifndef __ASSEMBLER__
   50.36 -#include <sys/cdefs.h>
   50.37 -
   50.38 -#define BEE_SIMCTRL(_s) \
   50.39 -    __asm volatile("simctrl " __XSTRING(_s) ";")
   50.40 -
   50.41 -#endif // __ASSEMBLER__
   50.42 -
   50.43 -#endif // ARCH_BEEHIVE_SIMCTRL_H
    51.1 --- a/include/arch/beehive/stopcode.h	Fri Jan 20 14:32:03 2012 -0800
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,23 +0,0 @@
    51.4 -/**
    51.5 - * \file
    51.6 - * \brief beehive slave stopcode definitions
    51.7 - */
    51.8 -
    51.9 -/*
   51.10 - * Copyright (c) 2010, ETH Zurich.
   51.11 - * All rights reserved.
   51.12 - *
   51.13 - * This file is distributed under the terms in the attached LICENSE file.
   51.14 - * If you do not find this file, copies can be found by writing to:
   51.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   51.16 - */
   51.17 -
   51.18 -#ifndef ARCH_BEEHIVE_STOPCODE_H
   51.19 -#define ARCH_BEEHIVE_STOPCODE_H
   51.20 -
   51.21 -#define STOPCODE_POWERUP 0
   51.22 -#define STOPCODE_TIMER 1
   51.23 -#define STOPCODE_STOP 2
   51.24 -#define STOPCODE_BREAK 3
   51.25 -
   51.26 -#endif // ARCH_BEEHIVE_STOPCODE_H
    52.1 --- a/include/barrelfish/barrelfish.h	Fri Jan 20 14:32:03 2012 -0800
    52.2 +++ b/include/barrelfish/barrelfish.h	Mon Jan 23 11:04:15 2012 -0800
    52.3 @@ -16,13 +16,6 @@
    52.4  #ifndef LIBBARRELFISH_BARRELFISH_H
    52.5  #define LIBBARRELFISH_BARRELFISH_H
    52.6  
    52.7 -/* Beehive does not support translation
    52.8 - * XXX Should really be defined in a plaform config file
    52.9 - */
   52.10 -#ifdef __BEEHIVE__
   52.11 -#define NOTRANS
   52.12 -#endif
   52.13 -
   52.14  /* standard libc types and assert */
   52.15  #include <stdint.h>
   52.16  #include <stddef.h>
    53.1 --- a/include/barrelfish/caddr.h	Fri Jan 20 14:32:03 2012 -0800
    53.2 +++ b/include/barrelfish/caddr.h	Mon Jan 23 11:04:15 2012 -0800
    53.3 @@ -55,7 +55,7 @@
    53.4  
    53.5  /* well-known capabilities */
    53.6  extern struct capref cap_root, cap_monitorep, cap_irq, cap_io, cap_dispatcher,
    53.7 -  cap_selfep, cap_kernel, cap_initep, cap_bmptable, cap_perfmon, cap_dispframe;
    53.8 +  cap_selfep, cap_kernel, cap_initep, cap_perfmon, cap_dispframe;
    53.9  
   53.10  /**
   53.11   * \brief Returns the number of valid bits in the CSpace address of a cap
    54.1 --- a/include/barrelfish/core_state.h	Fri Jan 20 14:32:03 2012 -0800
    54.2 +++ b/include/barrelfish/core_state.h	Mon Jan 23 11:04:15 2012 -0800
    54.3 @@ -46,9 +46,7 @@
    54.4      Header *header_freep;
    54.5      struct vspace_mmu_aware mmu_state;
    54.6  #if 0 // DELETEME
    54.7 -#ifndef NOTRANS
    54.8      struct captrack track_frames[MAX_TRACK_FRAMES];
    54.9 -#endif
   54.10  #endif // 0 DELETEME
   54.11  };
   54.12  
    55.1 --- a/include/barrelfish/dispatcher.h	Fri Jan 20 14:32:03 2012 -0800
    55.2 +++ b/include/barrelfish/dispatcher.h	Mon Jan 23 11:04:15 2012 -0800
    55.3 @@ -21,7 +21,6 @@
    55.4  #include <barrelfish/threads.h>
    55.5  
    55.6  struct lmp_chan;
    55.7 -struct bmp_chan;
    55.8  struct deferred_event;
    55.9  
   55.10  // Architecture generic user only dispatcher struct
   55.11 @@ -51,11 +50,6 @@
   55.12      struct heap lmp_endpoint_heap;
   55.13  #endif // CONFIG_INTERCONNECT_DRIVER_LMP
   55.14  
   55.15 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   55.16 -    /// List of BMP channels waiting to retry a send
   55.17 -    struct bmp_chan *bmp_send_events_list;
   55.18 -#endif
   55.19 -
   55.20      /// Queue of deferred events (i.e. timers)
   55.21      struct deferred_event *deferred_events;
   55.22  
    56.1 --- a/include/barrelfish/idc.h	Fri Jan 20 14:32:03 2012 -0800
    56.2 +++ b/include/barrelfish/idc.h	Mon Jan 23 11:04:15 2012 -0800
    56.3 @@ -52,10 +52,6 @@
    56.4  #include <barrelfish/ump_chan.h>
    56.5  #endif
    56.6  
    56.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
    56.8 -#include <barrelfish/bmp_chan.h>
    56.9 -#endif
   56.10 -
   56.11  #if defined(CONFIG_FLOUNDER_BACKEND_UMP_IPI)
   56.12  #include <arch/x86/barrelfish/ipi_notify.h>
   56.13  #endif
    57.1 --- a/include/barrelfish/idc_export.h	Fri Jan 20 14:32:03 2012 -0800
    57.2 +++ b/include/barrelfish/idc_export.h	Mon Jan 23 11:04:15 2012 -0800
    57.3 @@ -33,12 +33,6 @@
    57.4                                           struct capref notify_cap);
    57.5  #endif // CONFIG_INTERCONNECT_DRIVER_UMP
    57.6  
    57.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
    57.8 -typedef errval_t bmp_connect_callback_fn(void *st, struct monitor_binding *mb,
    57.9 -                                         uintptr_t mon_id, struct capref bee_ep,
   57.10 -                                         size_t remote_ep_len);
   57.11 -#endif // CONFIG_INTERCONNECT_DRIVER_BMP
   57.12 -
   57.13  #ifdef CONFIG_INTERCONNECT_DRIVER_MULTIHOP
   57.14  typedef errval_t multihop_connect_callback_fn(void *st, uint64_t vci);
   57.15  #endif // CONFIG_INTERCONNECT_DRIVER_MULTIHOP
   57.16 @@ -58,9 +52,6 @@
   57.17  #ifdef CONFIG_INTERCONNECT_DRIVER_UMP
   57.18      ump_connect_callback_fn *ump_connect_callback;
   57.19  #endif
   57.20 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   57.21 -    bmp_connect_callback_fn *bmp_connect_callback;
   57.22 -#endif
   57.23  #ifdef CONFIG_INTERCONNECT_DRIVER_MULTIHOP
   57.24    multihop_connect_callback_fn *multihop_connect_callback;
   57.25  #endif
    58.1 --- a/include/barrelfish/ump_impl.h	Fri Jan 20 14:32:03 2012 -0800
    58.2 +++ b/include/barrelfish/ump_impl.h	Mon Jan 23 11:04:15 2012 -0800
    58.3 @@ -31,8 +31,6 @@
    58.4  # else
    58.5  #  define CACHELINE_BYTES 64
    58.6  # endif
    58.7 -#elif defined(__BEEHIVE__)
    58.8 -#  define CACHELINE_BYTES 32
    58.9  #elif defined(__arm__)
   58.10  #  define CACHELINE_BYTES 32
   58.11  #else
    59.1 --- a/include/barrelfish/vspace_mmu_aware.h	Fri Jan 20 14:32:03 2012 -0800
    59.2 +++ b/include/barrelfish/vspace_mmu_aware.h	Mon Jan 23 11:04:15 2012 -0800
    59.3 @@ -24,17 +24,10 @@
    59.4  struct vspace_mmu_aware {
    59.5      size_t size;
    59.6      size_t consumed;
    59.7 -#ifdef NOTRANS
    59.8 -    struct vspace_mmu_vregion_list *head;
    59.9 -    struct memobj *memobj;
   59.10 -    struct vspace_mmu_vregion_list init_list;    ///< One to initialize
   59.11 -    struct memobj_one_frame_one_map init_memobj; ///< One to initialize
   59.12 -#else
   59.13      struct vregion vregion;           ///< Needs just one vregion
   59.14      struct memobj_anon memobj;        ///< Needs just one memobj
   59.15      lvaddr_t offset;    ///< Offset of free space in anon
   59.16      lvaddr_t mapoffset; ///< Offset into the anon that has been mapped in
   59.17 -#endif
   59.18  };
   59.19  
   59.20  errval_t vspace_mmu_aware_init(struct vspace_mmu_aware *state, size_t size);
    60.1 --- a/include/barrelfish/waitset.h	Fri Jan 20 14:32:03 2012 -0800
    60.2 +++ b/include/barrelfish/waitset.h	Mon Jan 23 11:04:15 2012 -0800
    60.3 @@ -37,7 +37,6 @@
    60.4      CHANTYPE_LMP_IN,
    60.5      CHANTYPE_LMP_OUT,
    60.6      CHANTYPE_UMP_IN,
    60.7 -    CHANTYPE_BMP_OUT,
    60.8      CHANTYPE_DEFERRED, ///< Timer events
    60.9      CHANTYPE_EVENT_QUEUE,
   60.10      CHANTYPE_FLOUNDER,
    61.1 --- a/include/barrelfish_kpi/capabilities.h	Fri Jan 20 14:32:03 2012 -0800
    61.2 +++ b/include/barrelfish_kpi/capabilities.h	Mon Jan 23 11:04:15 2012 -0800
    61.3 @@ -46,7 +46,7 @@
    61.4  
    61.5  static inline bool type_is_vnode(enum objtype type)
    61.6  {
    61.7 -    STATIC_ASSERT(27 == ObjType_Num, "Check VNode definitions");
    61.8 +    STATIC_ASSERT(25 == ObjType_Num, "Check VNode definitions");
    61.9  
   61.10      return (type == ObjType_VNode_x86_64_pml4 ||
   61.11              type == ObjType_VNode_x86_64_pdpt ||
   61.12 @@ -70,7 +70,7 @@
   61.13  static inline size_t vnode_objbits(enum objtype type)
   61.14  {
   61.15      // This function should be emitted by hamlet or somesuch.
   61.16 -    STATIC_ASSERT(27 == ObjType_Num, "Check VNode definitions");
   61.17 +    STATIC_ASSERT(25 == ObjType_Num, "Check VNode definitions");
   61.18  
   61.19      if (type == ObjType_VNode_x86_64_pml4 ||
   61.20          type == ObjType_VNode_x86_64_pdpt ||
   61.21 @@ -177,14 +177,6 @@
   61.22  };
   61.23  
   61.24  /**
   61.25 - * BMP Table capability commands.
   61.26 - */
   61.27 -enum bmptable_cmd {
   61.28 -    BMPTableCmd_Set,    ///< Set endpoint for BMP# notifications
   61.29 -    BMPTableCmd_Delete  ///< Remove notification endpoint for BMP#
   61.30 -};
   61.31 -
   61.32 -/**
   61.33   * Notify capability commands.
   61.34   */
   61.35  enum notify_cmd {
    62.1 --- a/include/barrelfish_kpi/cpu.h	Fri Jan 20 14:32:03 2012 -0800
    62.2 +++ b/include/barrelfish_kpi/cpu.h	Mon Jan 23 11:04:15 2012 -0800
    62.3 @@ -20,7 +20,6 @@
    62.4  enum cpu_type {
    62.5      CPU_X86_64,
    62.6      CPU_X86_32,
    62.7 -    CPU_BEEHIVE,
    62.8      CPU_SCC,
    62.9      CPU_ARM, // XXX: Which ARMs to add here?
   62.10      CPU_TYPE_NUM // must be last
    63.1 --- a/include/barrelfish_kpi/init.h	Fri Jan 20 14:32:03 2012 -0800
    63.2 +++ b/include/barrelfish_kpi/init.h	Mon Jan 23 11:04:15 2012 -0800
    63.3 @@ -101,7 +101,7 @@
    63.4  #define TASKCN_SLOT_TRACEBUF    9   ///< Trace buffer cap in task cnode
    63.5  #define TASKCN_SLOT_ARGSPAGE    10  ///< ?
    63.6  #define TASKCN_SLOT_MON_URPC    11  ///< Frame cap for urpc comm.
    63.7 -#define TASKCN_SLOT_BMP_TABLE   12  ///< cap to access BMP association table
    63.8 +/* slot 12 is free */
    63.9  #define TASKCN_SLOT_FDSPAGE     13  ///< cap for performance monitoring
   63.10  #define TASKCN_SLOT_PERF_MON    14  ///< cap for performance monitoring
   63.11  #define TASKCN_SLOTS_USER       15  ///< First free slot in taskcn for user
    64.1 --- a/include/barrelfish_kpi/legacy_idc_buffer.h	Fri Jan 20 14:32:03 2012 -0800
    64.2 +++ b/include/barrelfish_kpi/legacy_idc_buffer.h	Mon Jan 23 11:04:15 2012 -0800
    64.3 @@ -51,8 +51,6 @@
    64.4  typedef unsigned int idc_flag_t;
    64.5  #elif __arm__
    64.6  typedef uint8_t idc_flag_t;
    64.7 -#elif __BEEHIVE__
    64.8 -typedef uint8_t idc_flag_t;
    64.9  #else
   64.10  #error "Unknown architecture."
   64.11  #endif
    65.1 --- a/include/barrelfish_kpi/syscalls.h	Fri Jan 20 14:32:03 2012 -0800
    65.2 +++ b/include/barrelfish_kpi/syscalls.h	Mon Jan 23 11:04:15 2012 -0800
    65.3 @@ -48,7 +48,6 @@
    65.4  /* Architecture-specific syscalls 
    65.5   * FIXME: shouldn't these be in an arch-specific header? -AB */
    65.6  #define SYSCALL_X86_FPU_TRAP_ON     7     ///< Turn FPU trap on (x86)
    65.7 -#define SYSCALL_BEEHIVE_TRACE_RUNDOWN 7   ///< Trace DCB rundown
    65.8  #define SYSCALL_X86_RELOAD_LDT      8     ///< Reload the LDT register (x86_64)
    65.9  
   65.10  #define SYSCALL_COUNT               9     ///< Number of syscalls [0..SYSCALL_COUNT - 1]
    66.1 --- a/include/bexec.h	Fri Jan 20 14:32:03 2012 -0800
    66.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.3 @@ -1,36 +0,0 @@
    66.4 -/**
    66.5 - * \file
    66.6 - * \brief Beehive executable image format
    66.7 - */
    66.8 -
    66.9 -/*
   66.10 - * Copyright (c) 2010, ETH Zurich.
   66.11 - * All rights reserved.
   66.12 - *
   66.13 - * This file is distributed under the terms in the attached LICENSE file.
   66.14 - * If you do not find this file, copies can be found by writing to:
   66.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   66.16 - */
   66.17 -
   66.18 -#ifndef BEXEC_H
   66.19 -#define BEXEC_H
   66.20 -
   66.21 -#define BEXEC_IMAGE_SIZE(b) (((b)->bborg + (b)->bbsize - (b)->btorg)<<2)
   66.22 -#define BEXEC_IMAGE_BASE(b) ((b)->btorg)
   66.23 -
   66.24 -typedef struct bexec {
   66.25 -    unsigned bmagic, btorg, btsize, bdorg, bdsize, bborg, bbsize, bcksum;
   66.26 -} bexec_t, *pbexec_t;
   66.27 -
   66.28 -#define BEXEC_BMAGIC (0xF800220CU)
   66.29 -#define BEXEC_ARGSMAGIC (0x53475241U)
   66.30 -
   66.31 -// XXX: contents of "image pointer" file that appears in the VFS
   66.32 -struct mem_region;
   66.33 -struct bimgref_file {
   66.34 -    uint32_t magic;
   66.35 -    struct mem_region *region;
   66.36 -};
   66.37 -#define BIMGREF_MAGIC 0x42494d47u
   66.38 -
   66.39 -#endif
    67.1 --- a/include/flounder/flounder_support_bmp.h	Fri Jan 20 14:32:03 2012 -0800
    67.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.3 @@ -1,138 +0,0 @@
    67.4 -/**
    67.5 - * \file
    67.6 - * \brief Prototypes for use by flounder-generated stubs
    67.7 - */
    67.8 -
    67.9 -/*
   67.10 - * Copyright (c) 2010, ETH Zurich.
   67.11 - * All rights reserved.
   67.12 - *
   67.13 - * This file is distributed under the terms in the attached LICENSE file.
   67.14 - * If you do not find this file, copies can be found by writing to:
   67.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   67.16 - */
   67.17 -
   67.18 -#ifndef __FLOUNDER_SUPPORT_BMP_H
   67.19 -#define __FLOUNDER_SUPPORT_BMP_H
   67.20 -
   67.21 -#include <barrelfish/bmp_chan.h>
   67.22 -#include <flounder/flounder_support_caps.h>
   67.23 -
   67.24 -/// Type used for indices of BMP message slots
   67.25 -typedef uint16_t bmp_index_t;
   67.26 -#define BMP_INDEX_BITS  16
   67.27 -#define BMP_MSGNUM_BITS 16
   67.28 -
   67.29 -/// Message header word
   67.30 -union bmp_msg_header {
   67.31 -    struct {
   67.32 -        uintptr_t acknum:BMP_INDEX_BITS;
   67.33 -        uintptr_t msgnum:BMP_MSGNUM_BITS;
   67.34 -    } x;
   67.35 -    uintptr_t raw;
   67.36 -};
   67.37 -STATIC_ASSERT_SIZEOF(union bmp_msg_header, sizeof(uintptr_t));
   67.38 -
   67.39 -/// Special message types
   67.40 -enum flounder_bmp_msgnum {
   67.41 -    FL_BMP_ACK = 0,
   67.42 -    FL_BMP_CAP_ACK = (1 << BMP_INDEX_BITS) - 1,
   67.43 -};
   67.44 -
   67.45 -struct flounder_bmp_state {
   67.46 -    struct bmp_chan chan;
   67.47 -
   67.48 -    bmp_index_t sent_id;   ///< Sequence number of next message to be sent
   67.49 -    bmp_index_t seq_id;    ///< Last sequence number received from remote
   67.50 -    bmp_index_t ack_id;    ///< Last sequence number acknowledged by remote
   67.51 -    bmp_index_t last_ack;  ///< Last acknowledgement we sent to remote
   67.52 -
   67.53 -    struct flounder_cap_state capst; ///< State for indirect cap tx/rx machinery
   67.54 -};
   67.55 -
   67.56 -void flounder_stub_bmp_state_init(struct flounder_bmp_state *s, void *binding);
   67.57 -
   67.58 -errval_t flounder_stub_bmp_send_string(struct flounder_bmp_state *s,
   67.59 -                                       int msgnum, const char *str,
   67.60 -                                       size_t *pos, size_t *len);
   67.61 -
   67.62 -errval_t flounder_stub_bmp_recv_string(struct bmp_recv_msg *msg,
   67.63 -                                       char **str, size_t *pos, size_t *len);
   67.64 -
   67.65 -errval_t flounder_stub_bmp_send_buf(struct flounder_bmp_state *s,
   67.66 -                                    int msgnum, const void *buf,
   67.67 -                                    size_t len, size_t *pos);
   67.68 -
   67.69 -errval_t flounder_stub_bmp_recv_buf(struct bmp_recv_msg *msg,
   67.70 -                                    void **buf, size_t *len, size_t *pos);
   67.71 -
   67.72 -/// Computes (from seq/ack numbers) whether we can currently send on the channel
   67.73 -static inline bool flounder_stub_bmp_can_send(struct flounder_bmp_state *s,
   67.74 -                                              size_t totlen)
   67.75 -{
   67.76 -    assert(totlen <= s->chan.outeplen);
   67.77 -    return (bmp_index_t)(s->sent_id - s->ack_id) <= (s->chan.outeplen - totlen);
   67.78 -}
   67.79 -
   67.80 -/// Prepare a header word
   67.81 -static inline uintptr_t flounder_stub_bmp_mkheader(struct flounder_bmp_state *s,
   67.82 -                                                   int msgtype)
   67.83 -{
   67.84 -    assert(msgtype < (1 << BMP_MSGNUM_BITS)); // check for overflow
   67.85 -    union bmp_msg_header h = {
   67.86 -        .x = {
   67.87 -            .acknum = s->seq_id,
   67.88 -            .msgnum = msgtype }};
   67.89 -    return h.raw;
   67.90 -}
   67.91 -
   67.92 -/// Try to send a message
   67.93 -static inline errval_t flounder_stub_bmp_send(struct flounder_bmp_state *s,
   67.94 -                                              uintptr_t *msg, size_t totlen)
   67.95 -{
   67.96 -    assert(flounder_stub_bmp_can_send(s, totlen));
   67.97 -    errval_t err = bmp_chan_send(&s->chan, msg, totlen);
   67.98 -    if (err_is_ok(err)) {
   67.99 -        s->last_ack = s->seq_id;
  67.100 -        s->sent_id += totlen + LMP_RECV_HEADER_LENGTH; /* header on receive LMP side */
  67.101 -    }
  67.102 -    return err;
  67.103 -}
  67.104 -
  67.105 -/// Process a header word
  67.106 -static inline int flounder_stub_bmp_process_header(struct flounder_bmp_state *s,
  67.107 -                                                   uintptr_t header, size_t totlen)
  67.108 -{
  67.109 -    union bmp_msg_header h = { .raw = header };
  67.110 -    s->ack_id = h.x.acknum;
  67.111 -    s->seq_id += totlen + LMP_RECV_HEADER_LENGTH;
  67.112 -    return h.x.msgnum;
  67.113 -}
  67.114 -
  67.115 -/// Should we send an ACK?
  67.116 -static inline bool flounder_stub_bmp_needs_ack(struct flounder_bmp_state *s)
  67.117 -{
  67.118 -    // send a forced ACK if the channel would now not be able
  67.119 -    // to accept another MTU-sized message
  67.120 -    assert(s->chan.inep->buflen >= BMP_MSG_LENGTH);
  67.121 -    return (bmp_index_t)(s->seq_id - s->last_ack)
  67.122 -                >= s->chan.inep->buflen - BMP_MSG_LENGTH;
  67.123 -}
  67.124 -
  67.125 -/// Send an explicit ACK
  67.126 -static inline errval_t flounder_stub_bmp_send_ack(struct flounder_bmp_state *s)
  67.127 -{
  67.128 -    assert(flounder_stub_bmp_can_send(s, 1));
  67.129 -    uintptr_t msg = flounder_stub_bmp_mkheader(s, FL_BMP_ACK);
  67.130 -    return flounder_stub_bmp_send(s, &msg, 1);
  67.131 -}
  67.132 -
  67.133 -/// Send a cap ACK (message that we are ready to receive caps)
  67.134 -static inline errval_t flounder_stub_bmp_send_cap_ack(struct flounder_bmp_state *s)
  67.135 -{
  67.136 -    assert(flounder_stub_bmp_can_send(s, 1));
  67.137 -    uintptr_t msg = flounder_stub_bmp_mkheader(s, FL_BMP_CAP_ACK);
  67.138 -    return flounder_stub_bmp_send(s, &msg, 1);
  67.139 -}
  67.140 -
  67.141 -#endif // __FLOUNDER_SUPPORT_BMP_H
    68.1 --- a/include/target/beehive/barrelfish/dispatcher_target.h	Fri Jan 20 14:32:03 2012 -0800
    68.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.3 @@ -1,29 +0,0 @@
    68.4 -/**
    68.5 - * \file
    68.6 - * \brief Architecture specific dispatcher structure private to the user
    68.7 - */
    68.8 -
    68.9 -/*
   68.10 - * Copyright (c) 2010, ETH Zurich.
   68.11 - * All rights reserved.
   68.12 - *
   68.13 - * This file is distributed under the terms in the attached LICENSE file.
   68.14 - * If you do not find this file, copies can be found by writing to:
   68.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   68.16 - */
   68.17 -
   68.18 -#ifndef TARGET_BEEHIVE_BARRELFISH_DISPATCHER_H
   68.19 -#define TARGET_BEEHIVE_BARRELFISH_DISPATCHER_H
   68.20 -
   68.21 -#include <barrelfish_kpi/dispatcher_shared.h>
   68.22 -#include <barrelfish_kpi/dispatcher_shared_arch.h>
   68.23 -#include <barrelfish/dispatcher.h>
   68.24 -
   68.25 -/// Dispatcher structure (including data accessed only by user code)
   68.26 -struct dispatcher_beehive {
   68.27 -    struct dispatcher_shared_beehive d;  ///< Shared (user/kernel) data. Must be first.
   68.28 -    struct dispatcher_generic generic;   ///< User private data
   68.29 -    /* Incoming LMP endpoints (buffers and receive cap pointers) follow */
   68.30 -};
   68.31 -
   68.32 -#endif // TARGET_BEEHIVE_BARRELFISH_DISPATCHER_H
    69.1 --- a/include/target/beehive/barrelfish_kpi/coredata_target.h	Fri Jan 20 14:32:03 2012 -0800
    69.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.3 @@ -1,52 +0,0 @@
    69.4 -/**
    69.5 - * \file
    69.6 - * \brief Data sent to a newly booted beehive kernel
    69.7 - */
    69.8 -
    69.9 -/*
   69.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
   69.11 - * All rights reserved.
   69.12 - *
   69.13 - * This file is distributed under the terms in the attached LICENSE file.
   69.14 - * If you do not find this file, copies can be found by writing to:
   69.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   69.16 - */
   69.17 -
   69.18 -#ifndef COREDATA_H
   69.19 -#define COREDATA_H
   69.20 -
   69.21 -#include <bexec.h>
   69.22 -
   69.23 -// XXX Shouldn't really be visible outside kernel
   69.24 -typedef struct stringtable {
   69.25 -    unsigned smagic, slength, soffset[];
   69.26 -} *pstringtable_t;
   69.27 -
   69.28 -/**
   69.29 - * \brief Data sent to a newly booted kernel
   69.30 - *
   69.31 - * \bug Should use mackerel to define this struct instead of packing
   69.32 - * it so that it matches up between heterogeneous cores.
   69.33 - */
   69.34 -struct beehive_core_data {
   69.35 -    bexec_t   *cpu_module;    ///< bexec structure for the cpu module
   69.36 -    genpaddr_t module_start;  ///< The start of the cpu module
   69.37 -    genpaddr_t module_end;    ///< The end of the cpu module
   69.38 -
   69.39 -    bexec_t   *monitor_module;    ///< bexec structure for the cpu module
   69.40 -    genpaddr_t monitor_binary;
   69.41 -    genpaddr_t monitor_binary_size;
   69.42 -
   69.43 -    coreid_t src_core_id;
   69.44 -    int      chanid;
   69.45 -
   69.46 -    genpaddr_t memory_base;
   69.47 -    genpaddr_t memory_limit;
   69.48 -
   69.49 -    struct bootinfo *bootinfo;
   69.50 -    pstringtable_t strings;
   69.51 -
   69.52 -} __attribute__ ((packed));
   69.53 -
   69.54 -
   69.55 -#endif
    70.1 --- a/include/target/beehive/barrelfish_kpi/dispatcher_shared_target.h	Fri Jan 20 14:32:03 2012 -0800
    70.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.3 @@ -1,59 +0,0 @@
    70.4 -/**
    70.5 - * \file
    70.6 - * \brief Architecture specific dispatcher struct shared between kernel and user
    70.7 - */
    70.8 -
    70.9 -/*
   70.10 - * Copyright (c) 2010, ETH Zurich.
   70.11 - * All rights reserved.
   70.12 - *
   70.13 - * This file is distributed under the terms in the attached LICENSE file.
   70.14 - * If you do not find this file, copies can be found by writing to:
   70.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   70.16 - */
   70.17 -
   70.18 -#ifndef TARGET_BEEHIVE_BARRELFISH_KPI_DISPATCHER_SHARED_H
   70.19 -#define TARGET_BEEHIVE_BARRELFISH_KPI_DISPATCHER_SHARED_H
   70.20 -
   70.21 -#include <barrelfish_kpi/dispatcher_shared.h>
   70.22 -
   70.23 -///< Architecture specific kernel/user shared dispatcher struct
   70.24 -struct dispatcher_shared_beehive {
   70.25 -    struct dispatcher_shared_generic d; ///< Generic portion
   70.26 -
   70.27 -    union registers_beehive enabled_save_area;  ///< Enabled register save area
   70.28 -    union registers_beehive disabled_save_area; ///< Disabled register save area
   70.29 -    union registers_beehive trap_save_area;     ///< Trap register save area
   70.30 -};
   70.31 -
   70.32 -static inline struct dispatcher_shared_beehive*
   70.33 -get_dispatcher_shared_beehive(dispatcher_handle_t handle)
   70.34 -{
   70.35 -    return (struct dispatcher_shared_beehive*)handle;
   70.36 -}
   70.37 -
   70.38 -static inline union registers_beehive*
   70.39 -dispatcher_beehive_get_enabled_save_area(dispatcher_handle_t handle)
   70.40 -{
   70.41 -    struct dispatcher_shared_beehive *disp =
   70.42 -        get_dispatcher_shared_beehive(handle);
   70.43 -    return &disp->enabled_save_area;
   70.44 -}
   70.45 -
   70.46 -static inline union registers_beehive*
   70.47 -dispatcher_beehive_get_disabled_save_area(dispatcher_handle_t handle)
   70.48 -{
   70.49 -    struct dispatcher_shared_beehive *disp =
   70.50 -        get_dispatcher_shared_beehive(handle);
   70.51 -    return &disp->disabled_save_area;
   70.52 -}
   70.53 -
   70.54 -static inline union registers_beehive*
   70.55 -dispatcher_beehive_get_trap_save_area(dispatcher_handle_t handle)
   70.56 -{
   70.57 -    struct dispatcher_shared_beehive *disp =
   70.58 -        get_dispatcher_shared_beehive(handle);
   70.59 -    return &disp->trap_save_area;
   70.60 -}
   70.61 -
   70.62 -#endif // TARGET_BEEHIVE_BARRELFISH_KPI_DISPATCHER_SHARED_H
    71.1 --- a/include/thc/thcinternal.h	Fri Jan 20 14:32:03 2012 -0800
    71.2 +++ b/include/thc/thcinternal.h	Mon Jan 23 11:04:15 2012 -0800
    71.3 @@ -199,11 +199,6 @@
    71.4  #define KILL_CALLEE_SAVES()						\
    71.5    __asm__ volatile ("" : : : "ebx", "edi", "esi", "esp", "memory", "cc")
    71.6  #endif
    71.7 -#elif defined(__BEEHIVE__)
    71.8 -#define KILL_CALLEE_SAVES()				                \
    71.9 -  __asm__ volatile ("" : : : "r9", "r10", "r11", "r12", "r13",		\
   71.10 -		    "r14", "r15", "r16", "r17", "r18", "r19",		\
   71.11 -		    "r20", "r21", "r22", "sp", "memory", "cc")
   71.12  #elif defined(__arm__)
   71.13  #define KILL_CALLEE_SAVES assert(0 && "THC not yet implemented on ARM")
   71.14  #else
   71.15 @@ -228,10 +223,6 @@
   71.16  #elif defined(__i386__)                             
   71.17  #define FORCE_ARGS_STACK      
   71.18  #define FORCE_ARGS_STACK_CALL 
   71.19 -#elif defined(__BEEHIVE__)
   71.20 -#define FORCE_ARGS_STACK      void*__a, void*__b, void*__c, void*__d, \
   71.21 -                              void*__e, void*__f,
   71.22 -#define FORCE_ARGS_STACK_CALL NULL, NULL, NULL, NULL, NULL, NULL,
   71.23  #elif defined(__arm__)
   71.24  #define FORCE_ARGS_STACK assert(0 && "THC not yet implemented on ARM")
   71.25  #define FORCE_ARGS_STACK_CALL assert(0 && "THC not yet implemented on ARM")
   71.26 @@ -258,15 +249,6 @@
   71.27  #define RESTORE_OLD_STACK_POINTER(OLD_STACK_PTR)			\
   71.28    __asm__ volatile ("movl %0, %%esp       \n\t"				\
   71.29  		    : : "m"(OLD_STACK_PTR))
   71.30 -#elif defined(__BEEHIVE__)
   71.31 -#define GET_STACK_POINTER(STACK_PTR)					\
   71.32 -  __asm__ volatile("aqw_add vb, %0, 0       \n\t"			\
   71.33 -		   "ld      wq, sp          \n\t"			\
   71.34 -		   : : "r"(&(STACK_PTR)) )
   71.35 -#define RESTORE_OLD_STACK_POINTER(OLD_STACK_PTR)			\
   71.36 -  __asm__ volatile("aqr_add vb, %0, 0       \n\t"			\
   71.37 -		   "ld      sp, rq          \n\t"			\
   71.38 -		   : : "r"(&(OLD_STACK_PTR)) )
   71.39  #elif defined(__arm__)
   71.40  #define GET_STACK_POINTER(_) assert(0 && "THC not yet implemented on ARM")
   71.41  #define RESTORE_OLD_STACK_POINTER(_) assert(0 && "THC not yet implemented on ARM")
   71.42 @@ -309,29 +291,6 @@
   71.43      );
   71.44  #define GET_LAZY_AWE(FRAME_PTR)						\
   71.45      *((FRAME_PTR)+2)   /* was passed as first arg */
   71.46 -#elif defined(__BEEHIVE__)
   71.47 -#define INIT_LAZY_AWE(AWE_PTR, LAZY_MARKER)				\
   71.48 -  __asm__ volatile (							\
   71.49 -    " aqr_add vb, fp, 4          \n\t"					\
   71.50 -    " ld   link, rq              \n\t"					\
   71.51 -    " aqw_add vb, %0, 0          \n\t"				        \
   71.52 -    " ld   wq, link              \n\t" /* EIP   (our return address) */ \
   71.53 -    " aqr_add vb, fp, 0          \n\t"					\
   71.54 -    " ld   link, rq              \n\t"					\
   71.55 -    " aqw_add vb, %0, 4          \n\t"				        \
   71.56 -    " ld   wq, link                \n\t" /* EBP */			\
   71.57 -    " aqw_add vb, fp, 4          \n\t"					\
   71.58 -    " ld   wq, %1                \n\t"	/* put marker as ret address  */\
   71.59 -    : : "r"((AWE_PTR)), "r"((LAZY_MARKER)) : "vb" );
   71.60 -#define RETURN_CONT(JMP_ADDR)			                        \
   71.61 -  __asm__ volatile (							\
   71.62 -    " ld   sp, fp                \n\t" /* free frame                 */ \
   71.63 -    " aqr_ld  vb, sp             \n\t"					\
   71.64 -    " ld   fp, rq                \n\t" /* restore frame pointer      */	\
   71.65 -    " j " JMP_ADDR "             \n\t"	                                \
   71.66 -    );
   71.67 -#define GET_LAZY_AWE(FRAME_PTR)						\
   71.68 -    *((FRAME_PTR)+2)   /* was passed as first arg */
   71.69  #elif defined(__arm__)
   71.70  #define INIT_LAZY_AWE(_) assert(0 && "THC not yet implemented on ARM")
   71.71  #define RETURN_CONT(_) assert(0 && "THC not yet implemented on ARM")
   71.72 @@ -405,22 +364,6 @@
   71.73                       : "m" (_NS)                                        \
   71.74                       : "memory", "cc", "eax", "edx");			\
   71.75    }									
   71.76 -#elif defined(__BEEHIVE__)
   71.77 -#define SWIZZLE_DEF(_NAME,_NS,_FN)                                      \
   71.78 -  __attribute__((noinline)) void _NAME(void) {                          \
   71.79 -    __asm__ volatile("aqr_add vb, %0, 0       \n\t"			\
   71.80 -                     "ld      r3, rq          \n\t"			\
   71.81 -                     "sub     r3, r3, 4       \n\t"                     \
   71.82 -                     "aqw_add vb, r3, 0       \n\t"                     \
   71.83 -                     "ld      wq, sp          \n\t"                     \
   71.84 -                     "ld      sp, r3          \n\t"                     \
   71.85 -                     "long_call " _FN "       \n\t"                     \
   71.86 -                     "aqr_add vb, sp, 0       \n\t"                     \
   71.87 -                     "ld      sp, rq          \n\t"                     \
   71.88 -                     :							\
   71.89 -                     : "r" (&(_NS))                                     \
   71.90 -                     : "memory", "cc", "r2", "r3");			\
   71.91 -  }									
   71.92  #elif defined(__arm__)
   71.93  #define SWIZZLE_DEF(_NAME,_NS,_FN) assert(0 && "THC not yet implemented on ARM")
   71.94  #else
    72.1 --- a/include/thc/thcsync.h	Fri Jan 20 14:32:03 2012 -0800
    72.2 +++ b/include/thc/thcsync.h	Mon Jan 23 11:04:15 2012 -0800
    72.3 @@ -38,9 +38,6 @@
    72.4      while (InterlockedCompareExchange(reinterpret_cast<volatile long*>(&l->c), 1L, 0L) == 1) {
    72.5      }
    72.6      ;
    72.7 -#elif defined(__BEEHIVE__)
    72.8 - assert(l->c == 0);
    72.9 - l->c = 1;
   72.10  #else
   72.11    do {
   72.12      if (__sync_bool_compare_and_swap(&l->c, 0, 1)) {
    73.1 --- a/include/trace/trace.h	Fri Jan 20 14:32:03 2012 -0800
    73.2 +++ b/include/trace/trace.h	Mon Jan 23 11:04:15 2012 -0800
    73.3 @@ -15,7 +15,7 @@
    73.4  #ifndef LIBBARRELFISH_TRACE_H
    73.5  #define LIBBARRELFISH_TRACE_H
    73.6  
    73.7 -#if defined(__x86_64__) || defined(__BEEHIVE__)
    73.8 +#if defined(__x86_64__)
    73.9  #define TRACING_EXISTS 1
   73.10  #endif
   73.11  
   73.12 @@ -30,16 +30,6 @@
   73.13  #endif // IN_KERNEL
   73.14  #endif // __x86_64__
   73.15  
   73.16 -#ifdef __BEEHIVE__
   73.17 -#include <bench/bench_arch.h>
   73.18 -#ifndef IN_KERNEL
   73.19 -/* XXX: private includes from libbarrelfish */
   73.20 -#include <barrelfish/dispatcher_arch.h>
   73.21 -#include <barrelfish/curdispatcher_arch.h>
   73.22 -#include <barrelfish/syscall_arch.h>
   73.23 -#endif // IN_KERNEL
   73.24 -#endif // __BEEHIVE__
   73.25 -
   73.26  #include <barrelfish/sys_debug.h>
   73.27  
   73.28  /*
   73.29 @@ -81,13 +71,6 @@
   73.30  #define TRACE_EVENT_SCHED_SCHEDULE      0xED03
   73.31  #define TRACE_EVENT_SCHED_CURRENT       0xED04
   73.32  
   73.33 -#define TRACE_EVENT_BMP_RX              0xBEE1
   73.34 -#define TRACE_EVENT_BMP_PRE_DELIVER     0xBEE2
   73.35 -#define TRACE_EVENT_BMP_POST_DELIVER    0xBEE3
   73.36 -#define TRACE_EVENT_BMP_PUMP            0xBEE4
   73.37 -#define TRACE_EVENT_BMP_SEND            0xBEE5
   73.38 -
   73.39 -
   73.40  #define TRACE_SUBSYS_THREADS            0xEEEE
   73.41  
   73.42  #define TRACE_EVENT_BARRIER_ENTER       0x0100
   73.43 @@ -321,51 +304,6 @@
   73.44  #define TRACE_TIMESTAMP() 0
   73.45  
   73.46  
   73.47 -#elif defined(__BEEHIVE__)
   73.48 -
   73.49 -static inline bool trace_cas(volatile uintptr_t *address, uintptr_t old,
   73.50 -        uintptr_t nw)
   73.51 -{
   73.52 -    uintptr_t discardable;
   73.53 -    uintptr_t difference; // 0 if old was still old
   73.54 -    /* We write the new value somewhere.  Possibly to *address and
   73.55 -     * possibly to discardable.  Putting the new value in wq while we
   73.56 -     * do the test causes this to be (single core) atomic. */
   73.57 -    __asm volatile("ld wq, %[nw]\n\t"
   73.58 -		   "aqr_ld zero, %[addr]\n\t"
   73.59 -		   "sub %[diff], rq, %[old]\n\t"
   73.60 -		   "jnz . + 3\n\t"
   73.61 -		   "aqw_ld zero, %[addr]\n\t"
   73.62 -		   "j . + 2\n\t"
   73.63 -		   "aqw_ld zero, %[discard]\n"
   73.64 -		   : [diff] "=&r" (difference)
   73.65 -		   : [addr] "r" (address)
   73.66 -		   , [nw] "r" (nw)
   73.67 -		   , [old] "r" (old)
   73.68 -		   , [discard] "r" (&discardable)
   73.69 -		   : "memory", "cc");
   73.70 -    return (difference == 0);
   73.71 -}
   73.72 -
   73.73 -#define TRACE_TIMESTAMP() bench_tsc()
   73.74 -
   73.75 -static inline int arch_is_simulator(void)
   73.76 -{
   73.77 -    volatile unsigned int *ptr = (void*)0x02;
   73.78 -    unsigned int val = *ptr;
   73.79 -
   73.80 -    val >>= 18;
   73.81 -    val &= 0x7f;
   73.82 -    return val == 2 ? 1 : 0;
   73.83 -}
   73.84 -
   73.85 -extern void simtrace(uint32_t word1, uint32_t word2);
   73.86 -
   73.87 -
   73.88 -__asm("_simtrace: simctrl 11; j link");
   73.89 -
   73.90 -
   73.91 -
   73.92  #else
   73.93  
   73.94  #warning You need to supply CAS and a timestamp function for this architecture.
   73.95 @@ -464,13 +402,6 @@
   73.96  static inline uintptr_t trace_reserve_and_fill_slot(struct trace_event *ev,
   73.97                                                     struct trace_buffer *buf)
   73.98  {
   73.99 -#ifdef __BEEHIVE__
  73.100 -    /* Top bit is rundown event which must be reprocessed later */
  73.101 -    if (arch_is_simulator() && ((ev->timestamp >> 63) == 0)) {
  73.102 -	simtrace(ev->u.w32.word1, ev->u.w32.word2);
  73.103 -	return SYS_ERR_OK;
  73.104 -    }
  73.105 -#endif
  73.106      uintptr_t i, nw;
  73.107      struct trace_event *slot;
  73.108  
  73.109 @@ -538,9 +469,6 @@
  73.110  	 * and in particular because trace_snapshot uses
  73.111  	 * trace_write_event... */
  73.112  	trace_buf->done_rundown = true;
  73.113 -#ifdef __BEEHIVE__
  73.114 -	trace_snapshot();
  73.115 -#endif
  73.116      }
  73.117      (void) trace_reserve_and_fill_slot(ev, trace_buf);
  73.118  
  73.119 @@ -610,9 +538,6 @@
  73.120  	 * and in particular because sys_rundown uses
  73.121  	 * trace_write_event... */
  73.122  	trace_buf->done_rundown = true;
  73.123 -#ifdef __BEEHIVE__
  73.124 -	(void) sys_rundown();
  73.125 -#endif
  73.126      }
  73.127      (void) trace_reserve_and_fill_slot(ev, trace_buf);
  73.128  
  73.129 @@ -663,14 +588,9 @@
  73.130  #ifdef CONFIG_TRACE
  73.131      struct trace_event ev;
  73.132      ev.timestamp = TRACE_TIMESTAMP();
  73.133 -#ifdef __BEEHIVE__
  73.134 -    ev.u.w32.word1 = arg;
  73.135 -    ev.u.w32.word2 = (subsys << 16) | event;
  73.136 -#else
  73.137      ev.u.ev.subsystem = subsys;
  73.138      ev.u.ev.event     = event;
  73.139      ev.u.ev.arg       = arg;
  73.140 -#endif
  73.141  
  73.142  #if TRACE_ONLY_SUB_NET
  73.143      /* NOTE: This will ensure that only network related messages are logged. PS */
    74.1 --- a/kernel/Hakefile	Fri Jan 20 14:32:03 2012 -0800
    74.2 +++ b/kernel/Hakefile	Mon Jan 23 11:04:15 2012 -0800
    74.3 @@ -138,12 +138,5 @@
    74.4     (let sfiles = [ "boot.S", "exceptions.S", "paging_cp.S" ]
    74.5          cfiles = [ "exn.c", "exec.c", "init.c", "integrator.c", "kludges.c", "kputchar.c", "misc.c", "pl011_uart.c", "paging.c", "phys_mmap.c", "startup_arch.c", "syscall.c" ]
    74.6          mackerelFiles = [ "arm", "arm_icp_pit", "arm_icp_pic0", "pl011_uart" ]
    74.7 -    in mkrules "arm11mp" cfiles sfiles mackerelFiles [] [] [] [] []),
    74.8 -
    74.9 -   -- beehive
   74.10 -   (let sfiles = [ "boot.S", "ringtest.S", "findbits.S", "context.S", "dcache.S" ]
   74.11 -        cfiles = ["exec.c", "gdb_arch.c", "init.c", "misc.c", "serial.c", "startup_arch.c",
   74.12 -                  "syscall.c", "page_mappings_arch.c", "ringbmp.c", "kputchar.c" ] ++ microbench
   74.13 -        mackerelFiles = []
   74.14 -    in mkrules "beehive" cfiles sfiles mackerelFiles [] [] [] [] [])
   74.15 +    in mkrules "arm11mp" cfiles sfiles mackerelFiles [] [] [] [] [])
   74.16    ]
    75.1 --- a/kernel/arch/beehive/Hakefile	Fri Jan 20 14:32:03 2012 -0800
    75.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.3 @@ -1,40 +0,0 @@
    75.4 ---------------------------------------------------------------------------
    75.5 --- Copyright (c) 2007-2010, ETH Zurich.
    75.6 --- All rights reserved.
    75.7 ---
    75.8 --- This file is distributed under the terms in the attached LICENSE file.
    75.9 --- If you do not find this file, copies can be found by writing to:
   75.10 --- ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   75.11 ---
   75.12 --- Hakefile for kernel
   75.13 --- 
   75.14 ---------------------------------------------------------------------------
   75.15 -
   75.16 -let 
   75.17 -    arch = "beehive"
   75.18 -    opts = kernelOptions arch
   75.19 -    objs = [ objectFilePath opts f | f <- [ "core1.S", "ringtest.S",
   75.20 -                                            "slave.S", "dcache.S",
   75.21 -                                            "hyper.c", "serial.c" ] ]
   75.22 -    
   75.23 -    hyperLdFlags = [ Str "-Wl,-N",
   75.24 -                     Str "-Wl,-codebase=1800", Str "-Wl,-datafloat",
   75.25 -                     NStr "-Wl,-map,", Out arch "hyper.map",
   75.26 -                     Str "-fno-builtin"
   75.27 -                   ]
   75.28 -
   75.29 -    linkHyper opts objs libs kbin = 
   75.30 -      Rules [ Rule (
   75.31 -           [ Str "Bcc" ]
   75.32 -           ++ hyperLdFlags
   75.33 -           ++ (extraLdFlags opts)
   75.34 -           ++ [ Str "-o", Out arch kbin ]
   75.35 -           ++ [ In BuildTree arch o | o <- objs ]
   75.36 -           ++ [ In BuildTree arch l | l <- libs ]
   75.37 -           ++ [ Str "-lgcc" ]
   75.38 -      ) ]
   75.39 -in 
   75.40 -  [ compileCFiles opts [ "hyper.c" ], -- serial.c compiled by kernel build
   75.41 -    assembleSFiles opts [ "core1.S", "slave.S" ],
   75.42 -    linkHyper opts objs [] "/sbin/hyper"
   75.43 -  ]
    76.1 --- a/kernel/arch/beehive/beekernel.h	Fri Jan 20 14:32:03 2012 -0800
    76.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.3 @@ -1,86 +0,0 @@
    76.4 -/**
    76.5 - * \file
    76.6 - * \brief Beehive intra-kernel prototypes etc.
    76.7 - */
    76.8 -
    76.9 -/*
   76.10 - * Copyright (c) 2010, ETH Zurich.
   76.11 - * All rights reserved.
   76.12 - *
   76.13 - * This file is distributed under the terms in the attached LICENSE file.
   76.14 - * If you do not find this file, copies can be found by writing to:
   76.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   76.16 - */
   76.17 -
   76.18 -#ifndef KERNEL_ARCH_BEEHIVE_BEEKERNEL_H
   76.19 -#define KERNEL_ARCH_BEEHIVE_BEEKERNEL_H
   76.20 -
   76.21 -#define HANDLE_TIMER_HOW_SYNC 0
   76.22 -#define HANDLE_TIMER_HOW_SYSCALL 1
   76.23 -#define HANDLE_TIMER_HOW_RESUME 2
   76.24 -#define HANDLE_TIMER_HOW_EXECUTE 3
   76.25 -
   76.26 -#ifndef __ASSEMBLER__
   76.27 -
   76.28 -#include <barrelfish_kpi/types.h> // coreid_t
   76.29 -
   76.30 -/**
   76.31 - * \brief Return ID of current core 
   76.32 - *
   76.33 - */
   76.34 -
   76.35 -static inline coreid_t arch_get_core_id(void)
   76.36 -{
   76.37 -    volatile unsigned int *ptr = (void*)0x02;
   76.38 -    unsigned int val = *ptr;
   76.39 - 
   76.40 -    return (val >> 10) & 0xf;
   76.41 -}
   76.42 -
   76.43 -/**
   76.44 - * \brief Returns ID of the Ethernet core, one more than
   76.45 - * last regular core.
   76.46 - *
   76.47 - */
   76.48 -
   76.49 -static inline coreid_t arch_get_max_core_id(void)
   76.50 -{
   76.51 -    volatile unsigned int *ptr = (void*)0x02;
   76.52 -    unsigned int val = *ptr;
   76.53 -    return (val >> 14) & 0xf;
   76.54 -}
   76.55 -
   76.56 -/**
   76.57 - * \brief Returns read of identity register
   76.58 - *
   76.59 - */
   76.60 -
   76.61 -static inline uint32_t arch_read_identity_register(void)
   76.62 -{
   76.63 -    volatile unsigned int *ptr = (void*)0x02;
   76.64 -    unsigned int val = *ptr;
   76.65 -    return val;
   76.66 -}
   76.67 -
   76.68 -/**
   76.69 - * \brief returns non zero if running on simulator
   76.70 - *
   76.71 - */
   76.72 -
   76.73 -#ifndef LIBBARRELFISH_TRACE_H
   76.74 -
   76.75 -static inline int arch_is_simulator(void)
   76.76 -{
   76.77 -    volatile unsigned int *ptr = (void*)0x02;
   76.78 -    unsigned int val = *ptr;
   76.79 -
   76.80 -    val >>= 18;
   76.81 -    val &= 0x7f;
   76.82 -    return val == 2 ? 1 : 0;
   76.83 -}
   76.84 -
   76.85 -#endif // LIBBARRELFISH_TRACE_H
   76.86 -
   76.87 -#endif // __ASSEMBLER__
   76.88 -
   76.89 -#endif // KERNEL_ARCH_BEEHIVE_BEEKERNEL_H
    77.1 --- a/kernel/arch/beehive/bmp.h	Fri Jan 20 14:32:03 2012 -0800
    77.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.3 @@ -1,36 +0,0 @@
    77.4 -/**
    77.5 - * \file
    77.6 - * \brief Beehive message transport kernel component
    77.7 - */
    77.8 -
    77.9 -/*
   77.10 - * Copyright (c) 2010, ETH Zurich.
   77.11 - * All rights reserved.
   77.12 - *
   77.13 - * This file is distributed under the terms in the attached LICENSE file.
   77.14 - * If you do not find this file, copies can be found by writing to:
   77.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   77.16 - */
   77.17 -
   77.18 -#ifndef KERNEL_ARCH_BEEHIVE_BMP_H
   77.19 -#define KERNEL_ARCH_BEEHIVE_BMP_H
   77.20 -
   77.21 -#include <stdlib.h> // uint32_t
   77.22 -#include <barrelfish_kpi/legacy_idc_buffer.h> // struct idc_recv_msg
   77.23 -#include <barrelfish_kpi/syscalls.h> // struct sysret
   77.24 -#include <corearea.h> // struct corearea
   77.25 -
   77.26 -void bmp_init(void);
   77.27 -
   77.28 -void bmp_pump(void);
   77.29 -
   77.30 -// This returns when the messenger is empty and either a message
   77.31 -// arrived at some point, or a timer interrupt is pending.
   77.32 -void bmp_pump_until_timer(struct corearea *corearea);
   77.33 -
   77.34 -void bmp_send(int core, int assoc, int size, uint32_t *words);
   77.35 -
   77.36 -struct sysret bmp_table_set(struct capability *to, struct idc_recv_msg *msg);
   77.37 -struct sysret bmp_table_delete(struct capability *to, struct idc_recv_msg *msg);
   77.38 -
   77.39 -#endif // KERNEL_ARCH_BEEHIVE_BMP_H
    78.1 --- a/kernel/arch/beehive/boot.S	Fri Jan 20 14:32:03 2012 -0800
    78.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.3 @@ -1,470 +0,0 @@
    78.4 -/**
    78.5 - * \file
    78.6 - * \brief Bootstrap the kernel.
    78.7 - */
    78.8 -/*
    78.9 - * Copyright (c) 2009, 2010, ETH Zurich.
   78.10 - * All rights reserved.
   78.11 - *
   78.12 - * This file is distributed under the terms in the attached LICENSE file.
   78.13 - * If you do not find this file, copies can be found by writing to:
   78.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   78.15 - */
   78.16 -
   78.17 -#ifndef __ASSEMBLER__
   78.18 -#define __ASSEMBLER__   1
   78.19 -#endif
   78.20 -
   78.21 -#include <regconvention.h>
   78.22 -#include <barrelfish_kpi/syscalls.h>
   78.23 -#include <asmoffsets.h>
   78.24 -#include <beej7.h>
   78.25 -#include <simctrl.h>
   78.26 -#include "beekernel.h"
   78.27 -	
   78.28 -// ------------------------------------------------------------
   78.29 -
   78.30 -	.code
   78.31 -
   78.32 -	.globl main /* bsim requires that this be called main */
   78.33 -	.globl __code_ibefore
   78.34 -__code_ibefore:
   78.35 -main:	j	.+8		/* must be +8 for correct magic number */
   78.36 -btorg:	.word	0
   78.37 -btsize:	.word	0
   78.38 -bdorg:	.word	0
   78.39 -bdsize:	.word	0
   78.40 -bborg:	.word	0
   78.41 -bbsize:	.word	0
   78.42 -bcksum:	.word	0
   78.43 -
   78.44 -	.data
   78.45 -	.globl __data_ibefore
   78.46 -__data_ibefore:
   78.47 -	.code
   78.48 -	
   78.49 -after:	orn	r0, r0, r0
   78.50 -	or	r1, r0, r0
   78.51 -	jnz	badv1
   78.52 -	
   78.53 -vok:
   78.54 -	sub	r2, pc, 11	/* r2 points at cs:main */
   78.55 -	add_lsl	r3, r2, zero, 2	/* r3 points at ds:main */
   78.56 -	aqr_add	vb, r3, 4	/* read btorg */
   78.57 -	ld	r4, rq
   78.58 -	sub	r5, r4, r2
   78.59 -	jnz	badhdr
   78.60 -
   78.61 -	/* now we can assume we are running at the address we were
   78.62 -	 * linked for. XXX data and bss layout ??? */
   78.63 -	ld	t1, r3
   78.64 -	aqr_add	vb, r3, 20
   78.65 -	aqr_add	vb, r3, 24
   78.66 -	sub	r3, rq, r2	/* r3 has (word) bborg - btorg*/
   78.67 -	add	r3, rq, r3	/* r3 has (word) bborg + bbsize - btorg */
   78.68 -	add	r4, zero, zero	/* r4 is checksum */
   78.69 -	sub	r2, t1, 4	/* loop incs r2 first before load */
   78.70 -cklp:				/* r2 is data pointer, r3 is size in words */
   78.71 -	aqr_add	r2, r2, 4
   78.72 -	add	r4, rq, r4
   78.73 -	sub	r3, r3, 1
   78.74 -	jnz	cklp
   78.75 -	rol	r5, r4, 1
   78.76 -	xorn	vb, r4, r5
   78.77 -	jnz	badck
   78.78 -
   78.79 -ckok:	
   78.80 -	long_ld	sp, stack
   78.81 -	long_ld	a1, guardz
   78.82 -	lsr	a1, a1, 2
   78.83 -	ld	a2, 512 // 512 words of guard
   78.84 -	ld	a3, 0
   78.85 -	ld	a4, 0
   78.86 -	simctrl	BEE_SIMCTRL_ADDRCHECK
   78.87 -	/* Argument to bmain used cross-core is in s1 */
   78.88 -	ld	a1, s1
   78.89 -	long_call _bmain
   78.90 -	long_call _reboot
   78.91 -	j __end_simulation
   78.92 -
   78.93 -
   78.94 -badv1:	andn	t2, t2, t2
   78.95 -	add	r1, t2, "v"
   78.96 -	add	t2, t2, "1"
   78.97 -	j	dieloop
   78.98 -
   78.99 -badhdr:	simctrl	BEE_SIMCTRL_REGISTERS
  78.100 -	andn	t2, t2, t2
  78.101 -	add	r1, t2, "h"
  78.102 -	add	r2, t2, "d"
  78.103 -	j	dieloop
  78.104 -
  78.105 -badck:	simctrl	BEE_SIMCTRL_REGISTERS
  78.106 -	andn	t2, t2, t2
  78.107 -	add	r1, t2, "c"
  78.108 -	add	r2, t2, "k"
  78.109 -	j	dieloop
  78.110 -
  78.111 -	/* r1 with char 1, r2 with char 2 */
  78.112 -dieloop:andn	t2, t2, t2
  78.113 -T1:	aqr_add	t3, t2, 0x02
  78.114 -	add	t3, rq, t2
  78.115 -	and	t3, t3, 0x200
  78.116 -	sub	t3, t3, 0
  78.117 -	jz	T1
  78.118 -	aqw_add	t3, t2, 0x02
  78.119 -	add	wq, r1, 0x200 /* r1 + go*/
  78.120 -T2:	aqr_add	t3, t2, 0x02
  78.121 -	add	t3, rq, t2
  78.122 -	and	t3, t3, 0x200
  78.123 -	sub	t3, t3, 0
  78.124 -	jz	T2
  78.125 -	aqw_add	t3, t2, 0x02
  78.126 -	add	wq, r2, 0x200 /* r2 + go */
  78.127 -	simctrl	BEE_SIMCTRL_TERMINATE
  78.128 -	j	T1
  78.129 -
  78.130 -		
  78.131 -	.globl __end_simulation
  78.132 -__end_simulation:
  78.133 -	simctrl BEE_SIMCTRL_TERMINATE
  78.134 -	j __end_simulation
  78.135 -
  78.136 -/* Performing system calls.  At the C level they all return a struct
  78.137 - * sysret which, by beehive calling convention means that the first
  78.138 - * *result* register is used to *pass* the address where the return
  78.139 - * value should be written.  At the assembler level we use t1 to
  78.140 - * contain the system call number.  There are several other
  78.141 - * errors here including that we trust the user r1 for pointer of
  78.142 - * location to write the struct sysret return value into */
  78.143 -
  78.144 -#if SYSCALL_INVOKE != 0
  78.145 -#error "This code assumes invoke is zero"
  78.146 -#endif
  78.147 -#if SYS_ERR_OK != 0
  78.148 -#error "This code assumes SYS_ERR_OK is zero"
  78.149 -#endif
  78.150 -
  78.151 -	.globl _systrap
  78.152 -_systrap:
  78.153 -	/* check for system call number in range */
  78.154 -	sub	vb, t1, SYSCALL_COUNT
  78.155 -	jc	systrapbad
  78.156 -systrap2:
  78.157 -	/* switch to kernel stack and store old link and sp */
  78.158 -	ld	wq, link
  78.159 -	ld	wq, sp
  78.160 -	long_ld	sp, stack
  78.161 -	aqw_sub	sp, sp, 4
  78.162 -	aqw_sub	sp, sp, 4
  78.163 -
  78.164 -	lsl	t1, t1, 2
  78.165 -	jz	systrapinvoke
  78.166 -
  78.167 -	/* table dispatch */
  78.168 -	long_ld link, _syscalls
  78.169 -	aqr_add	vb, link, t1
  78.170 -systrap3:
  78.171 -	call	rq
  78.172 -	/* atomically, are there any pending timer interrupts?  we
  78.173 -	 * want it to look like the intererupt happened right at the
  78.174 -	 * return from the system call */
  78.175 -	ld	wq, zero	// wq non empty prevents interrupts
  78.176 -	j7	BEE_J7_COREAREA
  78.177 -	aqr_add	t1, link, OFFSETOF_COREAREA_KERNEL_PENDING
  78.178 -	ld	t2, rq
  78.179 -	jnz	systrap4
  78.180 -	/* no interrupt pending, return */
  78.181 -	aqr_ld	void, sp
  78.182 -	aqr_add	link, sp, 4
  78.183 -	ld	sp, rq
  78.184 -	aqw_ld	void, link	// release wq non empty, write into k stack
  78.185 -	j	rq		// next is j so no interrupt in gap
  78.186 -
  78.187 -systrapinvoke:
  78.188 -	/* This code saves the callee-save registers into the
  78.189 -	 * user dispatcher state just in case this invoke
  78.190 -	 * happens to be IDC. */
  78.191 -	// Set return code to zero
  78.192 -	ld	r1, zero
  78.193 -	call	syssavecontext
  78.194 -	aqr_long_ld link, _syscalls	// assumes invoke is 0
  78.195 -	j	systrap3
  78.196 -
  78.197 -systrap4:
  78.198 -	/* kernel pending non zero, wq still has dummy in it */
  78.199 -	/* we no longer need to keep the wq non empty. An additional
  78.200 -	 * timer interrupt here will only increment pending which will
  78.201 -	 * either be noticed when we call handle_timer, or will be
  78.202 -	 * noticed when the dispatcher resumes something, or idles */
  78.203 -	aqw_sub	void, sp, 4	// safe dump of wq non empty token
  78.204 -	call	syssavecontext
  78.205 -	sub	a1, t3, 31*4	// arg is move t3 back to start
  78.206 -	ld	a2, HANDLE_TIMER_HOW_SYSCALL
  78.207 -	add	sp, sp, 8
  78.208 -	long_call _handle_timer
  78.209 -	/* Shouldnt come back, but if it does, ok to fall through */
  78.210 -
  78.211 -syssavep1bad:
  78.212 -	simctrl	BEE_SIMCTRL_REGISTERS
  78.213 -	j7	BEE_J7_BREAKPOINT
  78.214 -	j	syssavep1bad
  78.215 -
  78.216 -syssavecontext:
  78.217 -	/* This subroutine saves the callee-save registers and return
  78.218 -	 * value into the user dispatcher state.  It assumes that the
  78.219 -	 * users stack pointer and return address are on the current
  78.220 -	 * stack. It propagates disp->disabled to dcb->disabled.
  78.221 -	 * The address of the save_area pc slot is returned in t3. */
  78.222 -	ld	t2, link
  78.223 -	// Check that dcb_current->disp == p1
  78.224 -	aqr_long_ld link, _dcb_current
  78.225 -	ld	link, rq
  78.226 -	aqr_add	vb, link, OFFSETOF_DCB_DISP
  78.227 -	sub	vb, rq, p1
  78.228 -	jnz	syssavep1bad
  78.229 -	// t3 = dcb_current->disabled = disp->disabled
  78.230 -	aqr_add	vb, p1, OFFSETOF_DISP_DISABLED
  78.231 -	aqw_add	vb, link, OFFSETOF_DCB_DISABLED
  78.232 -	ld	t3, rq
  78.233 -	ld	wq, t3
  78.234 -	// Selected save area t3 = (t3 ? disabled_save_area : enabled_save_area)
  78.235 -	jz	.+3
  78.236 -	add	t3, p1, OFFSETOF_DISP_DISABLED_AREA
  78.237 -	j	.+2
  78.238 -	add	t3, p1, OFFSETOF_DISP_ENABLED_AREA
  78.239 -
  78.240 -	// Save callee-save and return value etc. Note save r1 and r2
  78.241 -	aqw_ld	vb, t3
  78.242 -	aqw_add	t3, t3, 4
  78.243 -	aqw_add	t3, t3, 4
  78.244 -	ld	wq, zero
  78.245 -	ld	wq, r1
  78.246 -	ld	wq, r2
  78.247 -
  78.248 -	add	t3, t3, 6*4	// r2 to r8
  78.249 -	ld	t1, 15		// r9--r23
  78.250 -	aqw_add	t3, t3, 4	// first to r9==s1
  78.251 -	sub	t1, t1, 1
  78.252 -	jnz	.-2
  78.253 -	ld	wq, s1
  78.254 -	ld	wq, s2
  78.255 -	ld	wq, s3
  78.256 -	ld	wq, s4
  78.257 -	ld	wq, s5
  78.258 -	ld	wq, s6
  78.259 -	ld	wq, s7
  78.260 -	ld	wq, s8
  78.261 -	ld	wq, s9
  78.262 -	ld	wq, s10
  78.263 -	ld	wq, s11
  78.264 -	ld	wq, s12
  78.265 -	ld	wq, s13
  78.266 -	ld	wq, s14
  78.267 -	ld	wq, fp
  78.268 -
  78.269 -	aqr_ld	void, sp	// read stacked sp
  78.270 -	aqr_add	void, sp, 4	// read stacked link
  78.271 -	aqw_add	t3, t3, 4*4	// from r23 to r27==p1
  78.272 -	aqw_add	t3, t3, 4	// p28==sp
  78.273 -	aqw_add	t3, t3, 3*4	// from r28 to r31
  78.274 -	ld	wq, p1		// have to save this since it will be loaded
  78.275 -	ld	wq, rq
  78.276 -	ld	wq, rq
  78.277 -	j	t2	
  78.278 -
  78.279 -systrapbad:
  78.280 -	/* here is t1 is an out of range system call number */
  78.281 -	simctrl BEE_SIMCTRL_REGISTERS
  78.282 -	ld	a1, t1
  78.283 -	ld	t1, SYSCALL_COUNT
  78.284 -	j	systrap2
  78.285 -
  78.286 -/* Performing timer interrupts.  The assembler in slave.S has taken
  78.287 - * stop from the master core and if the core was not running in the
  78.288 - * kernel then it enters us here.  We have to do most of the saving
  78.289 - * and copy over a few registers that were saved in the corearea.
  78.290 - */
  78.291 -
  78.292 -	.globl	_interrupt
  78.293 -_interrupt:
  78.294 -	// Check that dcb_current->disp == p1
  78.295 -	long_ld link, _dcb_current
  78.296 -	aqr_ld	void, link
  78.297 -	ld	link, rq
  78.298 -	aqr_add	void, link, OFFSETOF_DCB_DISP
  78.299 -	sub	void, rq, p1
  78.300 -	jnz	interruptbad
  78.301 -	// t3 = dcb_current->disabled = disp->disabled
  78.302 -	aqr_add	void, p1, OFFSETOF_DISP_DISABLED
  78.303 -	aqw_add	void, link, OFFSETOF_DCB_DISABLED
  78.304 -	ld	t3, rq
  78.305 -	ld	wq, t3
  78.306 -	// Selected save area t3 = (t3 ? disabled_save_area : enabled_save_area)
  78.307 -	jz	inten
  78.308 -intdi:	add	t3, p1, OFFSETOF_DISP_DISABLED_AREA
  78.309 -	j	intsave
  78.310 -inten:	add	t3, p1, OFFSETOF_DISP_ENABLED_AREA
  78.311 -intsave:
  78.312 -	// Load t1, t2, t3, link, pc into rq
  78.313 -	j7	BEE_J7_COREAREA
  78.314 -	aqr_add	void, link, 24 * 4
  78.315 -	aqr_add	void, link, 25 * 4
  78.316 -	aqr_add	void, link, 26 * 4
  78.317 -	aqr_add	void, link, 30 * 4
  78.318 -	aqr_add	void, link, 31 * 4
  78.319 -	ld	wq, $1
  78.320 -	ld	wq, $2
  78.321 -	ld	wq, $3
  78.322 -	ld	wq, $4
  78.323 -	ld	wq, $5
  78.324 -	ld	wq, $6
  78.325 -	ld	wq, $7
  78.326 -	ld	wq, $8
  78.327 -	ld	wq, $9
  78.328 -	ld	wq, $10
  78.329 -	ld	wq, $11
  78.330 -	ld	wq, $12
  78.331 -	ld	wq, $13
  78.332 -	ld	wq, $14
  78.333 -	ld	wq, $15
  78.334 -	ld	wq, $16
  78.335 -	ld	wq, $17
  78.336 -	ld	wq, $18
  78.337 -	ld	wq, $19
  78.338 -	ld	wq, $20
  78.339 -	ld	wq, $21
  78.340 -	ld	wq, $22
  78.341 -	ld	wq, $23
  78.342 -	ld	wq, rq // t1 = 24
  78.343 -	ld	wq, rq // t2 = 25
  78.344 -	ld	wq, rq // t3 = 26
  78.345 -	ld	wq, $27
  78.346 -	ld	wq, $28
  78.347 -	add	wq, zero, $29    //r29 (via a port) is rq. Use the b port
  78.348 -	ld	wq, rq // link = 30
  78.349 -	ld	wq, rq // link = 31
  78.350 -
  78.351 -	ld	t1, t3
  78.352 -	ld	t2, 31
  78.353 -	// t1 points to base, t3 to current (first is r1), t2 count
  78.354 -ints1:	aqw_add	t3, t3, 4
  78.355 -	sub	t2, t2, 1
  78.356 -	jnz	ints1
  78.357 -	// Still need to move count and the rq words
  78.358 -	//simctrl	BEE_SIMCTRL_TRACEON
  78.359 -	aqr_add	void, link, 0
  78.360 -	aqw_add	void, t1, 0
  78.361 -	add	link, link, 32 * 4 - 4
  78.362 -	ld	t2, rq
  78.363 -	ld	wq, t2
  78.364 -ints2:	sub	t2, t2, 1
  78.365 -	jm	ints3
  78.366 -	aqr_add	link, link, 4
  78.367 -	aqw_add	t3, t3, 4
  78.368 -	ld	wq, rq
  78.369 -	j	ints2
  78.370 -ints3:	// rq copied
  78.371 -	/* Upcall to C need stack */
  78.372 -	//simctrl	BEE_SIMCTRL_TRACEOFF
  78.373 -	ld	a1, t1
  78.374 -	ld	a2, HANDLE_TIMER_HOW_SYNC
  78.375 -	long_ld	sp, stack
  78.376 -	ld	fp, 0
  78.377 -	long_call _handle_timer
  78.378 -	/* Shouldnt come back, but if it does, ok to fall through */
  78.379 -
  78.380 -interruptbad:
  78.381 -	simctrl BEE_SIMCTRL_REGISTERS
  78.382 -	j7	BEE_J7_BREAKPOINT
  78.383 -	j	interruptbad
  78.384 -
  78.385 -/* Extra misc things
  78.386 - */
  78.387 -
  78.388 -// Look at corearea->kernel_pending with wq non empty
  78.389 -	.globl _halt_unless_timer_pending
  78.390 -_halt_unless_timer_pending:
  78.391 -	ld	wq, link		// save it also defers interrupts
  78.392 -	j7	BEE_J7_COREAREA
  78.393 -	aqr_add	void, link, OFFSETOF_COREAREA_KERNEL_PENDING
  78.394 -	ld	void, rq
  78.395 -	jnz	nohalt
  78.396 -	simctrl	BEE_SIMCTRL_HALT
  78.397 -nohalt:	aqw_sub	void, sp, 4
  78.398 -	aqr_sub	void, sp, 4
  78.399 -	j	rq
  78.400 -
  78.401 -
  78.402 -	.globl _mmu_add_entry
  78.403 -_mmu_add_entry:
  78.404 -	simctrl BEE_SIMCTRL_ADDRCHECK
  78.405 -	j	link
  78.406 -
  78.407 -	.globl	_lli_test
  78.408 -_lli_test:
  78.409 -	ld	t1, link
  78.410 -	aqr_ld	void, sp
  78.411 -	j7	BEE_J7_TEST_RQ_EMPTY
  78.412 -	ld	void, link
  78.413 -	jz	. - 2
  78.414 -	x_lli	0xE8000000
  78.415 -	ld	void, void
  78.416 -	ld	void, void
  78.417 -	j7	BEE_J7_TEST_RQ_EMPTY
  78.418 -	ld	r1, link
  78.419 -	jz	t1
  78.420 -	ld	void, rq
  78.421 -	j	t1
  78.422 -
  78.423 -	.globl _skip_test
  78.424 -_skip_test:
  78.425 -	ld	a2, 0x003
  78.426 -	ld	a3, 0x00C
  78.427 -	ld	a4, 0x030
  78.428 -	ld	a5, 0x0C0
  78.429 -	ld	a6, 0x300
  78.430 -	ld	r1, 0
  78.431 -st1:	
  78.432 -	xor	a2, a2, 0x003
  78.433 -	xor	a3, a3, 0x00C
  78.434 -	xor	a4, a4, 0x030
  78.435 -	xor	a5, a5, 0x0C0
  78.436 -	xor	a6, a6, 0x300
  78.437 -
  78.438 -	xor	a2, a2, 0x001
  78.439 -	xor	a3, a3, 0x004
  78.440 -	xor	a4, a4, 0x010
  78.441 -	xor	a5, a5, 0x040
  78.442 -	xor	a6, a6, 0x100
  78.443 -
  78.444 -	xor	a2, a2, 0x002
  78.445 -	xor	a3, a3, 0x008
  78.446 -	xor	a4, a4, 0x020
  78.447 -	xor	a5, a5, 0x080
  78.448 -	xor	a6, a6, 0x200
  78.449 -	
  78.450 -	xor	r1, r1, 0x3FF
  78.451 -	xor	r1, r1, a2
  78.452 -	xor	r1, r1, a3
  78.453 -	xor	r1, r1, a4
  78.454 -	xor	r1, r1, a5
  78.455 -	xor	r1, r1, a6
  78.456 -	jnz	st2
  78.457 -
  78.458 -	sub	a1, a1, 1
  78.459 -	jnz	st1
  78.460 -	j	link
  78.461 -
  78.462 -	j7	BEE_J7_BREAKPOINT
  78.463 -
  78.464 -st2:	simctrl BEE_SIMCTRL_REGISTERS
  78.465 -	j	link
  78.466 -
  78.467 -	.bss
  78.468 -guardz:
  78.469 -	.blkw 512 // 2kB
  78.470 -	.blkw 768 // 3kB
  78.471 -	.globl	stack		// also used in context.S
  78.472 -stack:	// is_copy needs 1320 bytes all on its own!
  78.473 -	
    79.1 --- a/kernel/arch/beehive/context.S	Fri Jan 20 14:32:03 2012 -0800
    79.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.3 @@ -1,150 +0,0 @@
    79.4 -/**
    79.5 - * \file
    79.6 - * \brief Provide kernel context switch code
    79.7 - */
    79.8 -/*
    79.9 - * Copyright (c) 2010 ETH Zurich.
   79.10 - * All rights reserved.
   79.11 - *
   79.12 - * This file is distributed under the terms in the attached LICENSE file.
   79.13 - * If you do not find this file, copies can be found by writing to:
   79.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   79.15 - */
   79.16 -
   79.17 -#ifndef __ASSEMBLER__
   79.18 -#define __ASSEMBLER__   1
   79.19 -#endif
   79.20 -
   79.21 -#include <regconvention.h>
   79.22 -#include <beej7.h>
   79.23 -#include <asmoffsets.h>
   79.24 -#include "beekernel.h"
   79.25 -
   79.26 -// ------------------------------------------------------------
   79.27 -
   79.28 -	.code
   79.29 -
   79.30 -	.globl __resume
   79.31 -	/* Argument a1 is union registers_beehive *regs */
   79.32 -__resume:
   79.33 -	/* We need to check if a software interrupt is pending. If so
   79.34 -	 * we will pretend that this is the context we just saved.
   79.35 -	 * If a hardware interrupt happens during this routine we
   79.36 -	 * need to ensure it happens after the return to user mode.
   79.37 -	 * This is tricky since we are resuming a full state of
   79.38 -	 * all registers here, we use a trick where the address to
   79.39 -	 * empty the wq token comes from the rq and not from register.
   79.40 -	 */
   79.41 -	add	wq, a1, 31*4	// wq non empty with address to zap
   79.42 -
   79.43 -	/* look at pending flag, non zero take interrupt */
   79.44 -	j7	BEE_J7_COREAREA
   79.45 -	aqr_add	void, link, OFFSETOF_COREAREA_KERNEL_PENDING
   79.46 -	ld	void, rq
   79.47 -	jnz	resintr
   79.48 -
   79.49 -	/* we are going to resume this context and poison it to
   79.50 -	 * prevent reuse (catch bugs) by setting pc to zero */
   79.51 -	ld	wq, zero	// wq additional non empty
   79.52 -	aqw_sub	void, sp, 4	// write zap address to stack
   79.53 -	
   79.54 -	aqr_ld	link, a1	// fetch count
   79.55 -	ld	t1, 30		// fetch 30 more
   79.56 -res1:	aqr_add	link, link, 4
   79.57 -	sub	t1, t1, 1
   79.58 -	jnz	res1
   79.59 -	aqr_sub	void, sp, 4	// fetch zap address from stack
   79.60 -	aqr_add	link, link, 4	// fetch pc
   79.61 -	
   79.62 -	// Now load them
   79.63 -	ld	$28, rq		// entry 0 is RQ count
   79.64 -	ld	$1, rq
   79.65 -	ld	$2, rq
   79.66 -	ld	$3, rq
   79.67 -	ld	$4, rq
   79.68 -	ld	$5, rq
   79.69 -	ld	$6, rq
   79.70 -	ld	$7, rq
   79.71 -	ld	$8, rq
   79.72 -	ld	$9, rq
   79.73 -	ld	$10, rq
   79.74 -	ld	$11, rq
   79.75 -	ld	$12, rq
   79.76 -	ld	$13, rq
   79.77 -	ld	$14, rq
   79.78 -	ld	$15, rq
   79.79 -	ld	$16, rq
   79.80 -	ld	$17, rq
   79.81 -	ld	$18, rq
   79.82 -	ld	$19, rq
   79.83 -	ld	$20, rq
   79.84 -	ld	$21, rq
   79.85 -	ld	$22, rq
   79.86 -	ld	$23, rq
   79.87 -	ld	$24, rq
   79.88 -	ld	$25, rq
   79.89 -	ld	$26, rq
   79.90 -	ld	$27, rq
   79.91 -	/* rq now has r28, r29, link, zapaddr, pc.  r28=rqcount */
   79.92 -res2:	sub	$28, $28, 1
   79.93 -	jm	res3
   79.94 -	aqr_add	link, link, 4
   79.95 -	j	res2
   79.96 -res3:
   79.97 -	ld	$28, rq
   79.98 -	ld	$29, rq
   79.99 -	ld	link, rq
  79.100 -	aqw_ld	void, rq	// zap context and release empty wq
  79.101 -	j	rq
  79.102 -
  79.103 -resintr:
  79.104 -	/* wq still has dummy in it.  a1 still has the address of
  79.105 -	 * the context, which is what we need for calling _handle_timer.
  79.106 -	 * Just need to empty out wq and pass how argument. */
  79.107 -	long_ld	sp, stack
  79.108 -	aqw_sub	void, sp, 4
  79.109 -	ld	fp, 0
  79.110 -	ld	a2, HANDLE_TIMER_HOW_RESUME
  79.111 -	long_call _handle_timer
  79.112 -	/* should not return */
  79.113 -	j7	BEE_J7_BREAKPOINT
  79.114 -
  79.115 -// ------------------------------------------------------------
  79.116 -
  79.117 -	.globl	__execute
  79.118 -	/* Argument a1 is entry address */
  79.119 -	/* Argument a2 is dispatcher pointer */
  79.120 -__execute:
  79.121 -	/* We need to check if a software interrupt is pending.  If so
  79.122 -	 * we will abort this execute.  We know that if we are executing
  79.123 -	 * it is because we are making a scheduler activation on an
  79.124 -	 * enabled domain and have set it to disabled in the dispatcher
  79.125 -	 * (so the scheduler activation handler is resumed until such
  79.126 -	 * time as it has decided to re-enable activations) so all
  79.127 -	 * we need to do is undo the scheduler activation mark in the
  79.128 -	 * dispatcher. */
  79.129 -	ld	wq, zero		// wq non empty
  79.130 -
  79.131 -	j7	BEE_J7_COREAREA
  79.132 -	aqr_add	void, link, OFFSETOF_COREAREA_KERNEL_PENDING
  79.133 -	ld	void, rq
  79.134 -	jnz	exeintr
  79.135 -
  79.136 -	/* we are going to make the jump */
  79.137 -	ld	p1, a2
  79.138 -	aqw_sub	void, sp, 4		// drop dummy to stack
  79.139 -	call	a1
  79.140 -	/* should not return */
  79.141 -	j7	BEE_J7_BREAKPOINT
  79.142 -
  79.143 -exeintr:
  79.144 -	/* wq still has a zero in it.  Write that to disp->disabled
  79.145 -	 * and call into _handle_timer */
  79.146 -	aqw_add	void, a2, OFFSETOF_DISP_DISABLED
  79.147 -	ld	a1, zero
  79.148 -	ld	a2, HANDLE_TIMER_HOW_EXECUTE
  79.149 -	long_call _handle_timer
  79.150 -	/* should not return */
  79.151 -	j7	BEE_J7_BREAKPOINT
  79.152 -
  79.153 -/* End */
    80.1 --- a/kernel/arch/beehive/core1.S	Fri Jan 20 14:32:03 2012 -0800
    80.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.3 @@ -1,114 +0,0 @@
    80.4 -/**
    80.5 - * \file
    80.6 - * \brief Bootstrap the kernel.
    80.7 - */
    80.8 -/*
    80.9 - * Copyright (c) 2009, 2010, ETH Zurich.
   80.10 - * All rights reserved.
   80.11 - *
   80.12 - * This file is distributed under the terms in the attached LICENSE file.
   80.13 - * If you do not find this file, copies can be found by writing to:
   80.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   80.15 - */
   80.16 -
   80.17 -#ifndef __ASSEMBLER__
   80.18 -#define __ASSEMBLER__   1
   80.19 -#endif
   80.20 -
   80.21 -#include <regconvention.h>
   80.22 -#include <asmoffsets.h>
   80.23 -
   80.24 -stack = 0x4000
   80.25 -
   80.26 -// ------------------------------------------------------------
   80.27 -
   80.28 -	.code
   80.29 -
   80.30 -	.globl main /* bsim requires that this be called main */
   80.31 -	.globl __code_ibefore
   80.32 -__code_ibefore:
   80.33 -main:	j	.+8		/* must be +8 for correct magic number */
   80.34 -btorg:	.word	0
   80.35 -btsize:	.word	0
   80.36 -bdorg:	.word	0
   80.37 -bdsize:	.word	0
   80.38 -bborg:	.word	0
   80.39 -bbsize:	.word	0
   80.40 -bcksum:	.word	0
   80.41 -after:	orn	r0, r0, r0
   80.42 -	or	r1, r0, r0
   80.43 -	jnz	badv1
   80.44 -	
   80.45 -vok:
   80.46 -	sub	r2, pc, 11	/* r2 points at cs:main */
   80.47 -	add_lsl	r3, r2, zero, 2	/* r3 points at ds:main */
   80.48 -	aqr_add	vb, r3, 4	/* read btorg */
   80.49 -	ld	r4, rq
   80.50 -	sub	r5, r4, r2
   80.51 -	jnz	badhdr
   80.52 -
   80.53 -	/* now we can assume we are running at the address we were
   80.54 -	 * linked for. XXX data and bss layout ??? */
   80.55 -	ld	t1, r3
   80.56 -	aqr_add	vb, r3, 20
   80.57 -	aqr_add	vb, r3, 24
   80.58 -	sub	r3, rq, r2	/* r3 has (word) bborg - btorg*/
   80.59 -	add	r3, rq, r3	/* r3 has (word) bborg + bbsize - btorg */
   80.60 -	add	r4, zero, zero	/* r4 is checksum */
   80.61 -	sub	r2, t1, 4	/* loop incs r2 first before load */
   80.62 -cklp:				/* r2 is data pointer, r3 is size in words */
   80.63 -	aqr_add	r2, r2, 4
   80.64 -	add	r4, rq, r4
   80.65 -	sub	r3, r3, 1
   80.66 -	jnz	cklp
   80.67 -	rol	r5, r4, 1
   80.68 -	xorn	vb, r4, r5
   80.69 -	jnz	badck
   80.70 -
   80.71 -ckok:	
   80.72 -	long_ld	sp, stack
   80.73 -	long_call _bmain
   80.74 -	j __end_simulation
   80.75 -
   80.76 -
   80.77 -badv1:	andn	t2, t2, t2
   80.78 -	add	r1, t2, "v"
   80.79 -	add	t2, t2, "1"
   80.80 -	j	dieloop
   80.81 -
   80.82 -badhdr:	simctrl	4
   80.83 -	andn	t2, t2, t2
   80.84 -	add	r1, t2, "h"
   80.85 -	add	r2, t2, "d"
   80.86 -	j	dieloop
   80.87 -
   80.88 -badck:	simctrl	4
   80.89 -	andn	t2, t2, t2
   80.90 -	add	r1, t2, "c"
   80.91 -	add	r2, t2, "k"
   80.92 -	j	dieloop
   80.93 -
   80.94 -	/* r1 with char 1, r2 with char 2 */
   80.95 -dieloop:andn	t2, t2, t2
   80.96 -T1:	aqr_add	t3, t2, 0x02
   80.97 -	add	t3, rq, t2
   80.98 -	and	t3, t3, 0x200
   80.99 -	sub	t3, t3, 0
  80.100 -	jz	T1
  80.101 -	aqw_add	t3, t2, 0x02
  80.102 -	add	wq, r1, 0x200 /* r1 + go*/
  80.103 -T2:	aqr_add	t3, t2, 0x02
  80.104 -	add	t3, rq, t2
  80.105 -	and	t3, t3, 0x200
  80.106 -	sub	t3, t3, 0
  80.107 -	jz	T2
  80.108 -	aqw_add	t3, t2, 0x02
  80.109 -	add	wq, r2, 0x200 /* r2 + go */
  80.110 -	simctrl	1
  80.111 -	j	T1
  80.112 -
  80.113 -		
  80.114 -	.globl __end_simulation
  80.115 -__end_simulation:
  80.116 -	simctrl 1
  80.117 -	j __end_simulation
    81.1 --- a/kernel/arch/beehive/dcache.S	Fri Jan 20 14:32:03 2012 -0800
    81.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.3 @@ -1,50 +0,0 @@
    81.4 -/*
    81.5 - * Copyright (c) 2010, ETH Zurich.
    81.6 - * All rights reserved.
    81.7 - *
    81.8 - * This file is distributed under the terms in the attached LICENSE file.
    81.9 - * If you do not find this file, copies can be found by writing to:
   81.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   81.11 - */
   81.12 -
   81.13 -#include <regconvention.h>
   81.14 -
   81.15 -#if 0 /* inline in dcache.h */
   81.16 -	.code
   81.17 -	.globl _bee_dcache_flush_all
   81.18 -_bee_dcache_flush_all:
   81.19 -	ld	t1,link
   81.20 -	aqw_long_ld vb,0x8001fc03 ROL 2
   81.21 -	j	t1
   81.22 -#endif
   81.23 -
   81.24 -	.globl _bee_dcache_empty_all
   81.25 -_bee_dcache_empty_all:
   81.26 -	ld	t1,link
   81.27 -	/* must avoid context switch between flush and invalidate */
   81.28 -	ld	wq, zero
   81.29 -	aqw_long_ld vb,0x8001fc03 ROL 2
   81.30 -	aqw_long_ld vb,0x8003fc03 ROL 2
   81.31 -	aqw_sub	vb, sp, 4
   81.32 -	j	t1
   81.33 -
   81.34 -#ifndef IN_KERNEL
   81.35 -	.globl _bee_dcache_flush_lines
   81.36 -_bee_dcache_flush_lines:
   81.37 -	lsl	a2, a2, 7
   81.38 -	add_lsl	a1, a2, a1, 5
   81.39 -	aqw_add a1, a1, 0x0E
   81.40 -	j	link
   81.41 -
   81.42 -	.globl _bee_dcache_empty_lines
   81.43 -_bee_dcache_empty_lines:
   81.44 -	lsl	a2, a2, 7
   81.45 -	add_lsl	a1, a2, a1, 5
   81.46 -	/* must avoid context switch between flush and invalidate */
   81.47 -	ld	wq, zero
   81.48 -	aqw_add a1, a1, 0x0E
   81.49 -	lsl	t1, 1, 19 /* invalidate ends up in AQ[17] */
   81.50 -	aqw_add	t1, a1, t1
   81.51 -	aqw_sub	vb, sp, 4
   81.52 -	j	link
   81.53 -#endif
    82.1 --- a/kernel/arch/beehive/exec.c	Fri Jan 20 14:32:03 2012 -0800
    82.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.3 @@ -1,188 +0,0 @@
    82.4 -/**
    82.5 - * \file
    82.6 - * \brief x86-64 execution and miscellany
    82.7 - */
    82.8 -
    82.9 -/*
   82.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
   82.11 - * All rights reserved.
   82.12 - *
   82.13 - * This file is distributed under the terms in the attached LICENSE file.
   82.14 - * If you do not find this file, copies can be found by writing to:
   82.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   82.16 - */
   82.17 -
   82.18 -#include <kernel.h>
   82.19 -#include <gdb_stub.h>
   82.20 -#include <exec.h>
   82.21 -#include <stdio.h> // printf
   82.22 -#include <dispatch.h>
   82.23 -#include <barrelfish_kpi/registers_arch.h> // NUM_REGS
   82.24 -#include <trace/trace.h>
   82.25 -#include <simctrl.h>
   82.26 -#include <corearea.h>
   82.27 -#include <trace/trace.h>
   82.28 -
   82.29 -#include "beekernel.h"
   82.30 -#include "bmp.h"
   82.31 -
   82.32 -/**
   82.33 - * \brief Triggers a debugger breakpoint.
   82.34 - */
   82.35 -void breakpoint(void)
   82.36 -{
   82.37 -    gdb_stub_entry(5/*???*/, "breakpoint"); 
   82.38 -}
   82.39 -
   82.40 -void halt(void)
   82.41 -{
   82.42 -    panic("halt: called");
   82.43 -}
   82.44 -
   82.45 -void reboot(void)
   82.46 -{
   82.47 -    panic("reboot: called");
   82.48 -}
   82.49 -
   82.50 -/*
   82.51 - * On beehive we have SAS, so just check that this is null
   82.52 - */
   82.53 -extern void paging_context_switch(void* ptbase);
   82.54 -void paging_context_switch(void* ptbase)
   82.55 -{
   82.56 -    assert(ptbase == (void*)0xBAD23200);
   82.57 -}
   82.58 -
   82.59 -
   82.60 -extern void __attribute__ ((noreturn)) _resume(union registers_beehive *regs);
   82.61 -
   82.62 -extern void __attribute__ ((noreturn)) _execute(uint32_t entry, struct dispatcher_shared_generic *disp);
   82.63 -
   82.64 -
   82.65 -// XXX See kernel/arch/include/misc.h code for arch_set_thread_register
   82.66 -uintptr_t x86_fs_compatability_register;
   82.67 -
   82.68 -/**
   82.69 - * \brief Go to user-space at entry point 'entry'.
   82.70 - *
   82.71 - * This function goes to user-space and starts executing the program at
   82.72 - * its entry point at virtual address 'entry'.
   82.73 - *
   82.74 - * \param entry Entry point address of program to execute.
   82.75 - */
   82.76 -
   82.77 -void __attribute__ ((noreturn)) execute(lvaddr_t entry)
   82.78 -{
   82.79 -    if (entry == 0)
   82.80 -	panic("execute: jumping at 0!\n\n");
   82.81 -
   82.82 -    struct dispatcher_shared_generic *disp = (void*)x86_fs_compatability_register;
   82.83 -    if (disp == NULL)
   82.84 -	panic("execute: disp == NULL");
   82.85 -
   82.86 -    _execute(entry, disp);
   82.87 -}
   82.88 -
   82.89 -/**
   82.90 - * \brief Resume the given user-space snapshot.
   82.91 - *
   82.92 - * This function resumes user-space execution by restoring the CPU
   82.93 - * registers with the ones given in the array, pointed to by 'regs'.
   82.94 - */
   82.95 -void __attribute__ ((noreturn)) resume(arch_registers_state_t *state)
   82.96 -{
   82.97 -    if (((uintptr_t)state & (sizeof(uintptr_t) -1)) != 0)
   82.98 -	panic("execute: state=%p\n", state);
   82.99 -
  82.100 -    if (state->named.count > 64)
  82.101 -	panic("resume: invalid rq count (%u) indicated\n", state->named.count);
  82.102 -    if (state->named.pc == 0)
  82.103 -	panic("resume: jumping at 0!\n\n");
  82.104 -    if (state->named.p1 == 0) {
  82.105 -	if (x86_fs_compatability_register == 0)
  82.106 -	    panic("resume: no p1\n");
  82.107 -	else {
  82.108 -	    printf("fixing up missing thread register from x86 segment register\n");
  82.109 -	    state->named.p1 = x86_fs_compatability_register;
  82.110 -	}
  82.111 -    }
  82.112 -    _resume(state);
  82.113 -}
  82.114 -
  82.115 -/**
  82.116 - * \brief Halt processor until an interrupt arrives
  82.117 - *
  82.118 - * For use in the idle loop when nothing is runnable.
  82.119 - */
  82.120 -void __attribute__ ((noreturn)) wait_for_interrupt(void)
  82.121 -{
  82.122 -#ifdef TRACE_CSWITCH
  82.123 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_CSWITCH, 0);
  82.124 -#endif
  82.125 -    //int core = arch_get_core_id();
  82.126 -    //printf("Core %d yields\n", core);
  82.127 -    struct corearea *corearea = my_corearea();
  82.128 -    for(;;) {
  82.129 -	bmp_pump_until_timer(corearea);
  82.130 -	if (corearea->kernel_pending) {
  82.131 -	    printf("wfi: pending %u\n", corearea->kernel_pending);
  82.132 -	    /* XXX RACE */
  82.133 -	    kernel_now += corearea->kernel_pending;
  82.134 -	    corearea->kernel_pending = 0;
  82.135 -	    /* XXX END RACE */
  82.136 -	}
  82.137 -	struct dcb *next = schedule();
  82.138 -	if (next != NULL) {
  82.139 -	    //printf("Core %d dispatches %p\n", core, next);
  82.140 -	    dispatch(next);
  82.141 -	} else {
  82.142 -	    printf("Core %d still had nothing to do!\n", arch_get_core_id());
  82.143 -	}
  82.144 -    }
  82.145 -}
  82.146 -
  82.147 -
  82.148 -void __attribute__((noreturn)) handle_timer(
  82.149 -    union registers_beehive *saved, int how);
  82.150 -
  82.151 -/* If the how indicates EXECUTE then the saved pointer is NULL */
  82.152 -
  82.153 -void __attribute__((noreturn)) handle_timer(
  82.154 -    union registers_beehive *saved, int how)
  82.155 -{
  82.156 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_TIMER, kernel_now);
  82.157 -
  82.158 -    struct corearea *corearea = my_corearea();
  82.159 -    struct dcb *dcb = dcb_current;
  82.160 -
  82.161 -    assert(dcb != NULL);
  82.162 -
  82.163 -    struct dispatcher_shared_beehive *disp;
  82.164 -
  82.165 -    disp = get_dispatcher_shared_beehive(dcb_current->disp);
  82.166 -    assert(dcb->disabled == disp->d.disabled);
  82.167 -    if (how == HANDLE_TIMER_HOW_EXECUTE) {
  82.168 -	assert(saved == NULL);
  82.169 -	printf("handle_timer: core %u \"%.*s\" (%p,%p) at activation\n",
  82.170 -	       arch_get_core_id(),
  82.171 -	       DISP_NAME_LEN, disp->d.name, dcb, disp);
  82.172 -    } else {
  82.173 -	assert(saved == (dcb->disabled ? &disp->disabled_save_area : &disp->enabled_save_area));
  82.174 -	printf("handle_timer: core %u \"%.*s\" (%p,%p) at %#x %s how %u\n",
  82.175 -	       arch_get_core_id(),
  82.176 -	       DISP_NAME_LEN, disp->d.name, dcb, disp, saved->named.pc,
  82.177 -	       (dcb->disabled ? "disabled" : "enabled"), how);
  82.178 -    }
  82.179 -
  82.180 -    if (corearea->kernel_pending > (how == HANDLE_TIMER_HOW_SYNC ? 0 : 1))
  82.181 -	printf("handle_timer: core %u *** pending = %u\n",
  82.182 -	       arch_get_core_id(), corearea->kernel_pending);
  82.183 -
  82.184 -    /* XXX RACE */
  82.185 -    kernel_now += corearea->kernel_pending + (how == HANDLE_TIMER_HOW_SYNC ? 1 : 0);
  82.186 -    corearea->kernel_pending = 0;
  82.187 -    /* XXX END RACE */
  82.188 -
  82.189 -    dispatch(schedule());
  82.190 -    panic("dispatch() returned");
  82.191 -}
    83.1 --- a/kernel/arch/beehive/findbits.S	Fri Jan 20 14:32:03 2012 -0800
    83.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.3 @@ -1,116 +0,0 @@
    83.4 -/*
    83.5 - * Copyright (c) 2010 ETH Zurich.
    83.6 - * All rights reserved.
    83.7 - *
    83.8 - * This file is distributed under the terms in the attached LICENSE file.
    83.9 - * If you do not find this file, copies can be found by writing to:
   83.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   83.11 - */
   83.12 -
   83.13 -#ifndef __ASSEMBLER__
   83.14 -#define __ASSEMBLER__   1
   83.15 -#endif
   83.16 -
   83.17 -#include <regconvention.h>
   83.18 -
   83.19 -// ------------------------------------------------------------
   83.20 -
   83.21 -	.code
   83.22 -
   83.23 -	.globl	_find_least_clear32
   83.24 -	.globl	_find_least_set32
   83.25 -_find_least_clear32:
   83.26 -	xorn	a1, a1, zero
   83.27 -_find_least_set32:
   83.28 -	ld	r1, 0
   83.29 -	ld	void, a1
   83.30 -flsjoin:jz	minusone
   83.31 -	lsl	void, a1, 16
   83.32 -	jnz	.+3
   83.33 -	lsr	a1, a1, 16
   83.34 -	add	r1, r1, 16
   83.35 -	and	void, a1, 0xff
   83.36 -	jnz	.+3
   83.37 -	lsr	a1, a1, 8
   83.38 -	add	r1, r1, 8
   83.39 -	and	void, a1, 0x0f
   83.40 -	jnz	.+3
   83.41 -	lsr	a1, a1, 4
   83.42 -	add	r1, r1, 4
   83.43 -	and	void, a1, 0x03
   83.44 -	jnz	.+3
   83.45 -	lsr	a1, a1, 2
   83.46 -	add	r1, r1, 2
   83.47 -	and	void, a1, 0x01
   83.48 -	jnz	link
   83.49 -	add	r1, r1, 1
   83.50 -	j	link
   83.51 -minusone:
   83.52 -	xorn	r1, zero, zero
   83.53 -	j	link
   83.54 -
   83.55 -	.globl	_find_least_clear64
   83.56 -	.globl	_find_least_set64
   83.57 -_find_least_clear64:
   83.58 -	xorn	a1, a1, zero
   83.59 -	xorn	a2, a2, zero
   83.60 -_find_least_set64:
   83.61 -	ld	void, a1
   83.62 -	jnz	_find_least_set32
   83.63 -	ld	r1, 32
   83.64 -	ld	a1, a2
   83.65 -	j	flsjoin
   83.66 -		
   83.67 -
   83.68 -	.globl	_find_highest_clear32
   83.69 -	.globl	_find_highest_set32
   83.70 -_find_highest_clear32:
   83.71 -	xorn	a1, a1, zero
   83.72 -_find_highest_set32:
   83.73 -	ld	r1, 31
   83.74 -	ld	void, a1
   83.75 -fhsjoin:jz	minusone
   83.76 -	lsr	void, a1, 16
   83.77 -	jnz	.+3
   83.78 -	sub	r1, r1, 16
   83.79 -	lsl	a1, a1, 16
   83.80 -	lsr	void, a1, 24
   83.81 -	jnz	.+3
   83.82 -	sub	r1, r1, 8
   83.83 -	lsl	a1, a1, 8
   83.84 -	lsr	void, a1, 28
   83.85 -	jnz	.+3
   83.86 -	sub	r1, r1, 4
   83.87 -	lsl	a1, a1, 4
   83.88 -	lsr	void, a1, 30
   83.89 -	jnz	.+3
   83.90 -	sub	r1, r1, 2
   83.91 -	lsl	a1, a1, 2
   83.92 -	lsr	a1, a1, 31
   83.93 -	jnz	link
   83.94 -	sub	r1, r1, 1
   83.95 -	j	link
   83.96 -
   83.97 -
   83.98 -	.globl	_find_highest_clear64
   83.99 -	.globl	_find_highest_set64
  83.100 -_find_highest_clear64:
  83.101 -	xorn	a1, a1, zero
  83.102 -	xorn	a2, a2, zero
  83.103 -_find_highest_set64:
  83.104 -	ld	void, a2
  83.105 -	jz	_find_highest_set32
  83.106 -	ld	a1, a2
  83.107 -	ld	r1, 63
  83.108 -	j	fhsjoin
  83.109 -
  83.110 -
  83.111 -	.globl	_population_count
  83.112 -_population_count:
  83.113 -	ld	r1, 0
  83.114 -	ld	void, a1
  83.115 -	jz	link
  83.116 -	add	r1, r1, 1
  83.117 -	sub	t1, a1, 1
  83.118 -	and	a1, a1, t1
  83.119 -	j	.-4
    84.1 --- a/kernel/arch/beehive/gdb_arch.c	Fri Jan 20 14:32:03 2012 -0800
    84.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.3 @@ -1,216 +0,0 @@
    84.4 -/** \file
    84.5 - * \brief x86-specific parts of in-kernel GDB stub.
    84.6 - *
    84.7 - * This file implements x86 architecture support for the kernel-side GDB stubs.
    84.8 - */
    84.9 -
   84.10 -/*
   84.11 - * Copyright (c) 2007, 2008, ETH Zurich.
   84.12 - * All rights reserved.
   84.13 - *
   84.14 - * This file is distributed under the terms in the attached LICENSE file.
   84.15 - * If you do not find this file, copies can be found by writing to:
   84.16 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   84.17 - */
   84.18 -
   84.19 -#include <kernel.h>
   84.20 -#include <stdio.h>
   84.21 -#include <paging_kernel_arch.h>
   84.22 -#include <gdb_stub.h>
   84.23 -
   84.24 -#ifndef ARCH_NUMREGS
   84.25 -#define ARCH_NUMREGS NUM_REGS
   84.26 -#endif
   84.27 -
   84.28 -/** \brief GDB register save area / frame.
   84.29 - *
   84.30 - * Stores pointer to current save frame used by GDB. Used to read/modify
   84.31 - * register contents, and reloaded when program execution resumes. */
   84.32 -union registers_beehive *gdb_arch_registers;
   84.33 -
   84.34 -
   84.35 -#if 0
   84.36 -/** \brief Separate stack area for the stub to run on */
   84.37 -static uintptr_t gdb_stack[KERNEL_STACK_SIZE/sizeof(uintptr_t)];
   84.38 -/** \brief Pointer to top of GDB stack area. */
   84.39 -uintptr_t * SNT gdb_stack_top = &gdb_stack[KERNEL_STACK_SIZE/sizeof(uintptr_t)];
   84.40 -#endif
   84.41 -
   84.42 -#if 0
   84.43 -/** \brief Converts exception vector to signal number.
   84.44 - *
   84.45 - * This function takes an x86 exception vector and attempts to
   84.46 - * translate this number into a Unix-compatible signal value.
   84.47 - */
   84.48 -static int exception_to_signal(int vector)
   84.49 -{
   84.50 -    switch (vector) {
   84.51 -        case 0:     return 8;   // divide by zero
   84.52 -        case 1:     return 5;   // debug exception
   84.53 -        case 3:     return 5;   // breakpoint
   84.54 -        case 4:     return 16;  // into instruction (overflow)
   84.55 -        case 5:     return 16;  // bound instruction
   84.56 -        case 6:     return 4;   // Invalid opcode
   84.57 -        case 7:     return 8;   // coprocessor not available
   84.58 -        case 8:     return 7;   // double fault
   84.59 -        case 9:     return 11;  // coprocessor segment overrun
   84.60 -        case 10:    return 11;  // Invalid TSS
   84.61 -        case 11:    return 11;  // Segment not present
   84.62 -        case 12:    return 11;  // stack exception
   84.63 -        case 13:    return 11;  // general protection
   84.64 -        case 14:    return 11;  // page fault
   84.65 -        case 16:    return 7;   // coprocessor error
   84.66 -        default:    return 7;   // "software generated"
   84.67 -    }
   84.68 -}
   84.69 -#endif
   84.70 -
   84.71 -#if 0
   84.72 -/** \brief Entry point for an exception; we are now on our own stack.
   84.73 - *
   84.74 - * This function sets up the GDB-format register save frame, constructs the
   84.75 - * initial message to the remote GDB and calls into the generic debugger entry
   84.76 - * point.
   84.77 - */
   84.78 -void gdb_handle_exception_onstack(int vector, uintptr_t * NONNULL
   84.79 -        COUNT(NUM_REGS) save_area) __attribute__((noreturn));
   84.80 -void gdb_handle_exception_onstack(int vector, uintptr_t * NONNULL
   84.81 -        COUNT(NUM_REGS) save_area)
   84.82 -{
   84.83 -}
   84.84 -#endif
   84.85 -
   84.86 -/** \brief Get the value of a single register in the frame.
   84.87 - * \param regnum register number (as defined by the #gdb_register_nums enum)
   84.88 - * \param value pointer to location in which to return current value
   84.89 - * \return Zero on success, nonzero on failure (invalid regnum).
   84.90 - */
   84.91 -int gdb_arch_get_register(int regnum, uintptr_t *value)
   84.92 -{
   84.93 -    if (regnum < 0 || regnum >= (sizeof(union registers_beehive) / sizeof(uint32_t))) {
   84.94 -        return -1;
   84.95 -    }
   84.96 -
   84.97 -    *value = gdb_arch_registers->regs[regnum];
   84.98 -    return 0;
   84.99 -}
  84.100 -
  84.101 -/** \brief Set the value of a single register in the frame.
  84.102 - * \param regnum register number (as defined by the #gdb_register_nums enum)
  84.103 - * \param value new value
  84.104 - * \return Zero on success, nonzero on failure (invalid regnum).
  84.105 - */
  84.106 -int gdb_arch_set_register(int regnum, uintptr_t value)
  84.107 -{
  84.108 -    if (regnum < 0 || regnum >= (sizeof(union registers_beehive) / sizeof(uint32_t))) {
  84.109 -        return -1;
  84.110 -    }
  84.111 -
  84.112 -    gdb_arch_registers->regs[regnum] = value;
  84.113 -    return 0;
  84.114 -}
  84.115 -
  84.116 -/** \brief Resume execution.
  84.117 - *
  84.118 - * Resumes execution with the CPU state stored in the #gdb_arch_registers frame.
  84.119 - */
  84.120 -void gdb_resume(void) __attribute__((noreturn));
  84.121 -
  84.122 -void gdb_resume(void)
  84.123 -{
  84.124 -    panic("gdb_resume: called");
  84.125 -}
  84.126 -
  84.127 -/** \brief Resume program execution.
  84.128 - * \param addr Address to resume at, or 0 to continue at last address.
  84.129 - */
  84.130 -void gdb_arch_continue(lvaddr_t addr)
  84.131 -{
  84.132 -    if (addr != 0) {
  84.133 -	gdb_arch_registers->named.pc = addr;
  84.134 -    }
  84.135 -
  84.136 -    gdb_resume(); /* doesn't return */
  84.137 -}
  84.138 -
  84.139 -/** \brief Single-step program execution.
  84.140 - * \param addr Address to resume at, or 0 to continue at last address.
  84.141 - */
  84.142 -void gdb_arch_single_step(lvaddr_t addr)
  84.143 -{
  84.144 -    if (addr != 0) {
  84.145 -	gdb_arch_registers->named.pc = addr;
  84.146 -    }
  84.147 -    panic("cant implement");
  84.148 -
  84.149 -    /* set the trace bit for single-step */
  84.150 -    //gdb_arch_registers[EFLAGS_REG] |= 0x100; // XXX
  84.151 -
  84.152 -    gdb_resume(); /* doesn't return */
  84.153 -}
  84.154 -
  84.155 -/** \brief Ensures that the page containing addr is mapped.
  84.156 - * \return Zero on success, negative on failure.
  84.157 - */
  84.158 -static int ensure_mapping(lvaddr_t addr)
  84.159 -{
  84.160 -#if FALSE
  84.161 -    static paddr_t lastaddr;
  84.162 -
  84.163 -    /* check if address is in kernel image */
  84.164 -    if (addr >= KERNEL_OFFSET && addr < (vaddr_t)&_end_kernel) {
  84.165 -        return 0;
  84.166 -    }
  84.167 -
  84.168 -    /* if address is outside "physical" memory region, fail the access */
  84.169 -    if (addr < MEMORY_OFFSET || addr >= KERNEL_OFFSET) {
  84.170 -        return -1;
  84.171 -    }
  84.172 -
  84.173 -    /* we now know we have a valid "physical memory" region address */
  84.174 -    paddr_t paddr = mem_to_phys(addr);
  84.175 -    paddr -= paddr & MEM_PAGE_MASK; // page-align
  84.176 -
  84.177 -    /* quick and dirty optimisation: if this address is on the same page as
  84.178 -     * the last time we were called, return immediately */
  84.179 -    if (lastaddr == paddr && lastaddr != 0) {
  84.180 -        return 0;
  84.181 -    }
  84.182 -
  84.183 -    int r = paging_map_memory(paddr, MEM_PAGE_SIZE);
  84.184 -    if (r < 0) {
  84.185 -        return r;
  84.186 -    }
  84.187 -
  84.188 -    lastaddr = paddr;
  84.189 -#endif /* FALSE */
  84.190 -    return 0;
  84.191 -}
  84.192 -
  84.193 -/** \brief Writes a byte to an arbitrary address in kernel memory.
  84.194 - * \return Zero on success, nonzero on error (invalid address)
  84.195 - */
  84.196 -int gdb_arch_write_byte(uint8_t *addr, uint8_t val)
  84.197 -{
  84.198 -    int r = ensure_mapping((lvaddr_t)addr);
  84.199 -    if (r < 0) {
  84.200 -        return r;
  84.201 -    }
  84.202 -
  84.203 -    *addr = val;
  84.204 -    return 0;
  84.205 -}
  84.206 -
  84.207 -/** \brief Reads a byte from an arbitrary address in kernel memory.
  84.208 - * \return Zero on success, nonzero on error (invalid address)
  84.209 - */
  84.210 -int gdb_arch_read_byte(uint8_t *addr, uint8_t *val)
  84.211 -{
  84.212 -    int r = ensure_mapping((lvaddr_t)addr);
  84.213 -    if (r < 0) {
  84.214 -        return r;
  84.215 -    }
  84.216 -
  84.217 -    *val = *addr;
  84.218 -    return 0;
  84.219 -}
    85.1 --- a/kernel/arch/beehive/hyper.c	Fri Jan 20 14:32:03 2012 -0800
    85.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.3 @@ -1,668 +0,0 @@
    85.4 -/*
    85.5 - * Copyright (c) 2009, 2010, ETH Zurich.
    85.6 - * All rights reserved.
    85.7 - *
    85.8 - * This file is distributed under the terms in the attached LICENSE file.
    85.9 - * If you do not find this file, copies can be found by writing to:
   85.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   85.11 - */
   85.12 -
   85.13 -/* 
   85.14 - * Core 1 runs a small 'hypervisor' which acts as a timer device, 
   85.15 - * serial device and interrupt controller. 
   85.16 - *
   85.17 - * It interacts with other cores via DEBUG messages.  
   85.18 - *
   85.19 - */
   85.20 -
   85.21 -#include <stdarg.h>
   85.22 -#include <kernel.h>
   85.23 -#include <hyper.h>
   85.24 -#include <serial.h>
   85.25 -#include <bexec.h>
   85.26 -#include <simctrl.h>
   85.27 -#include <corearea.h>
   85.28 -#include <dcache.h>
   85.29 -#include <stopcode.h>
   85.30 -
   85.31 -
   85.32 -#if 0
   85.33 -#define HYPERDBG(x) serial_console_putchar(x)
   85.34 -#else
   85.35 -#define HYPERDBG(x) (void)sizeof(x)
   85.36 -#endif
   85.37 -
   85.38 -#define ROUNDUP(x,y) (((x)+(y)-1) & ~((y)-1))
   85.39 -#define BASE_PAGE_SIZE 0x1000
   85.40 -
   85.41 -
   85.42 -static void halt(void) __attribute__((noreturn));
   85.43 -static void serial_dec_word(uint32_t word);
   85.44 -static void serial_hex_word(uint32_t word);
   85.45 -
   85.46 -void bmain(uint32_t a, uint32_t b, uint32_t c, 
   85.47 -	   uint32_t d, uint32_t e, uint32_t f)
   85.48 -    __attribute__((noreturn));
   85.49 -
   85.50 -#define HYPERFAIL(format, ...) hyperfail(__LINE__, format, ## __VA_ARGS__)
   85.51 -
   85.52 -/*
   85.53 - * Stop the system if running in the simulator
   85.54 - */
   85.55 -static void halt(void)
   85.56 -{
   85.57 -    for(;;)
   85.58 -	BEE_SIMCTRL(BEE_SIMCTRL_TERMINATE);
   85.59 -}
   85.60 -
   85.61 -/*
   85.62 - * Do a register dump if running in the simulator
   85.63 - */
   85.64 -static inline void dumpregs(void)
   85.65 -{
   85.66 -    BEE_SIMCTRL(BEE_SIMCTRL_REGISTERS);
   85.67 -}
   85.68 -
   85.69 -/*
   85.70 - * Read the ID register to get the core number 
   85.71 - */
   85.72 -static inline uint8_t arch_get_core_id(void)
   85.73 -{
   85.74 -    volatile unsigned int *ptr = (void*)0x02;
   85.75 -    unsigned int val = *ptr;
   85.76 - 
   85.77 -    return (val >> 10) & 0xf;
   85.78 -}
   85.79 -
   85.80 -static inline uint8_t arch_get_max_core_id(void)
   85.81 -{
   85.82 -    volatile unsigned int *ptr = (void*)0x02;
   85.83 -    unsigned int val = *ptr;
   85.84 -    return (val >> 14) & 0xf;
   85.85 -}
   85.86 -
   85.87 -
   85.88 -static inline unsigned int cyclecounter(void)
   85.89 -{
   85.90 -    return *(volatile unsigned int *)(0x22);
   85.91 -}
   85.92 -
   85.93 -
   85.94 -/*
   85.95 - * Hardware messages are up to 63 32-bit words
   85.96 - */
   85.97 -typedef unsigned int msg_t[63];
   85.98 -
   85.99 -/*
  85.100 - * Send a message to core number "dest", using "len" words at "buf".
  85.101 - *
  85.102 - * Note that message lengths are measured in words, not bytes.
  85.103 - */
  85.104 -void message_send(unsigned int dest, unsigned int type,
  85.105 -		  msg_t *buf, unsigned int len);
  85.106 -
  85.107 -/*
  85.108 - * If there's a message available to receive, place its details and
  85.109 - * contents in (srce, type, buf) and return its length.
  85.110 - * Otherwise return 0.
  85.111 - */
  85.112 -unsigned int message_recv(unsigned int *srce, unsigned int *type,
  85.113 -			  msg_t * buf);
  85.114 -
  85.115 -
  85.116 -extern int lockunit_read(int n);
  85.117 -extern void lockunit_write(int n);
  85.118 -
  85.119 -
  85.120 -int hyperfail(int line, const char *fmt, ...) __attribute__ ((format(printf, 2, 3)))
  85.121 -    __attribute__((noreturn));
  85.122 -
  85.123 -int vprintf(const char *fmt, va_list ap)
  85.124 -{
  85.125 -    int percent = 0;
  85.126 -    int ch;
  85.127 -    while ((ch = *fmt++) != 0) {
  85.128 -	if (percent) {
  85.129 -	    if (ch == 'x' || ch == 'X' || ch == 'p')
  85.130 -		serial_hex_word(va_arg(ap, unsigned));
  85.131 -	    else if (ch == '%')
  85.132 -		serial_console_putchar('%');
  85.133 -	    else if (ch == 'c')
  85.134 -		serial_console_putchar(va_arg(ap, int));
  85.135 -	    else
  85.136 -		serial_dec_word(va_arg(ap, unsigned));
  85.137 -	    percent = 0;
  85.138 -	}
  85.139 -	else if (ch == '%')
  85.140 -	    percent = 1;
  85.141 -	else if (ch == '\n') {
  85.142 -	    serial_console_putchar('\r');
  85.143 -	    serial_console_putchar(ch);
  85.144 -	}
  85.145 -	else
  85.146 -	    serial_console_putchar(ch);
  85.147 -    }
  85.148 -    va_end(ap);
  85.149 -    return 0;
  85.150 -}
  85.151 -
  85.152 -int printf(const char *fmt, ...)
  85.153 -{
  85.154 -    int result;
  85.155 -    va_list ap;
  85.156 -    va_start(ap, fmt);
  85.157 -    result = vprintf(fmt, ap);
  85.158 -    va_end(ap);
  85.159 -    return result;
  85.160 -}
  85.161 -
  85.162 -int hyperfail(int line, const char *fmt, ...)
  85.163 -{
  85.164 -    va_list ap;
  85.165 -    printf("\nhypervisor failure at line %d\n", line);
  85.166 -    va_start(ap, fmt);
  85.167 -    vprintf(fmt, ap);
  85.168 -    va_end(ap);
  85.169 -    printf("\n");
  85.170 -    halt();
  85.171 -}
  85.172 -
  85.173 -/// Different handler for cap operations performed by the monitor
  85.174 -static errval_t arch_spawn_core(coreid_t core_id, genvaddr_t entry)
  85.175 -{
  85.176 -    // Setup registers in save area
  85.177 -    struct corearea *savearea = COREAREA_FOR_CORE(core_id);
  85.178 -
  85.179 -    for (unsigned i = 1; i < 32; i++) {
  85.180 -        savearea->regs[i] = 0xBAD000 | i;
  85.181 -    }
  85.182 -    // Count
  85.183 -    savearea->regs[0]  = 0;
  85.184 -
  85.185 -    // Arg Registers
  85.186 -    savearea->regs[3]  = 0xA1;
  85.187 -    savearea->regs[4]  = 0xA2;
  85.188 -    savearea->regs[5]  = 0xA3; 
  85.189 -    savearea->regs[6]  = 0xA4;
  85.190 -    savearea->regs[7]  = 0xA5;
  85.191 -    savearea->regs[8]  = 0xA6;
  85.192 -
  85.193 -    // SavedLink
  85.194 -    savearea->regs[30] = 0xBAD;
  85.195 - 
  85.196 -    // SavedPC
  85.197 -    savearea->regs[31] = entry;
  85.198 -
  85.199 -    // Mark kernel covering whole memory so timer interrupts are deferred
  85.200 -    savearea->kernel_begins = 0;
  85.201 -    savearea->kernel_ends = 0x7fffffff;
  85.202 -
  85.203 -    //bee_dcache_flush_all();
  85.204 -    bee_dcache_empty_all();
  85.205 -   //bee_dcache_flush_rgn(savearea, 512);
  85.206 -
  85.207 -    // Send a START message
  85.208 -    HYPERDBG('>');
  85.209 -    message_send(core_id, 0, NULL, 0);
  85.210 -
  85.211 -    return SYS_ERR_OK;
  85.212 -}
  85.213 -
  85.214 -static void serial_hex_nibble(uint32_t nibble);
  85.215 -static void serial_hex_nibble(uint32_t nibble)
  85.216 -{
  85.217 -    nibble &= 0xf;
  85.218 -    if (nibble > 9) 
  85.219 -	nibble += '@' - '0';
  85.220 -    serial_console_putchar(nibble + '0');
  85.221 -}
  85.222 -	
  85.223 -static void serial_hex_word(uint32_t word)
  85.224 -{
  85.225 -    serial_console_putchar('0');
  85.226 -    serial_console_putchar('x');
  85.227 -    serial_hex_nibble((word>>28));
  85.228 -    serial_hex_nibble((word>>24));
  85.229 -    serial_hex_nibble((word>>20));
  85.230 -    serial_hex_nibble((word>>16));
  85.231 -    serial_hex_nibble((word>>12));
  85.232 -    serial_hex_nibble((word>>8));
  85.233 -    serial_hex_nibble((word>>4));
  85.234 -    serial_hex_nibble((word));
  85.235 -}
  85.236 -
  85.237 -static void serial_dec_word(uint32_t word)
  85.238 -{
  85.239 -    if (word > 9) {
  85.240 -	uint32_t tens = word / 10;
  85.241 -	word = word - (10 * tens);
  85.242 -	serial_dec_word(tens);
  85.243 -    }
  85.244 -    serial_console_putchar('0'+word);
  85.245 -}
  85.246 -
  85.247 -/* Reads a single character from the default serial port.
  85.248 - * Returns -1 if there isnt one without delaying
  85.249 - */
  85.250 -static int serial_poll_getchar(void)
  85.251 -{
  85.252 -    // The RS232 is in IO position 0, register 0 XXX Should have a
  85.253 -    // MACRO in an arch header file to build these type of constants
  85.254 -    volatile int *const rs232 = (int *)0x02;
  85.255 -
  85.256 -    int reg = *rs232;
  85.257 -    if ((reg & 0x100) == 0)
  85.258 -	return -1;
  85.259 -    // Indicate that we noticed it
  85.260 -    *rs232 = 0x100;
  85.261 -    return (reg & 0xff);
  85.262 -}
  85.263 -
  85.264 -
  85.265 -
  85.266 -static inline int arch_is_simulator(void)
  85.267 -{
  85.268 -    volatile unsigned int *ptr = (void*)0x02;
  85.269 -    unsigned int val = *ptr;
  85.270 -
  85.271 -    printf("identity=%x\n", val);
  85.272 -
  85.273 -    val >>= 18;
  85.274 -    val &= 0x7f;
  85.275 -    return val == 2 ? 1 : 0;
  85.276 -}
  85.277 -
  85.278 -/**
  85.279 - * \brief Expect a break message from all cores and panic if not
  85.280 - *
  85.281 - */
  85.282 -static inline void expect_breaks(uint32_t pc, unsigned wait);
  85.283 -static inline void expect_breaks(uint32_t pc, unsigned wait)
  85.284 -{
  85.285 -    int expectbreak[16];
  85.286 -    for (unsigned i = 0; i < 16; i++)
  85.287 -	expectbreak[i] = 0;
  85.288 -    int ncores = arch_get_max_core_id();
  85.289 -    for(unsigned i=2; i<ncores; i++)
  85.290 -	expectbreak[i] = 1;
  85.291 -    
  85.292 -    msg_t msg; 
  85.293 -    unsigned int srce = 0;
  85.294 -    unsigned int type = 0;
  85.295 -    unsigned int len;
  85.296 -    if (wait != 0)
  85.297 -	wait = ncores - 2;
  85.298 -    while ((len = message_recv(&srce, &type, &msg)) != 0 || (wait != 0)) {
  85.299 -	serial_console_putchar('0'+len);
  85.300 -	serial_console_putchar('A'+wait);
  85.301 -	if (len == 1 && type == 1 && expectbreak[srce] == 1 && msg[0] == pc) {
  85.302 -	    expectbreak[srce] = 0;
  85.303 -	    if (wait > 0)
  85.304 -		wait--;
  85.305 -	}
  85.306 -	else if (len != 0)
  85.307 -	    HYPERFAIL("not break len=%d srce=%d type=%d", len, srce, type);
  85.308 -    }
  85.309 -    for(unsigned i=2; i<ncores; i++)
  85.310 -	if (expectbreak[i] != 0)
  85.311 -	    HYPERFAIL("no expected break core %d", i);
  85.312 -} // expect_breaks
  85.313 -
  85.314 -
  85.315 -#define STEP(_s) \
  85.316 -    serial_console_putchar('0'+(_s))
  85.317 -
  85.318 -void change_slaves(void);
  85.319 -void change_slaves(void)
  85.320 -{
  85.321 -    const uint32_t jplus8 = 0xf800220c;
  85.322 -    const uint32_t jlink = 0xf000030c;
  85.323 -    const uint32_t nop = 0x000000c5;
  85.324 -    uint32_t *const iflushDataAddr = (uint32_t *)0x7ffff000;
  85.325 -    
  85.326 -    printf("change_slaves: ");
  85.327 -    STEP(0);
  85.328 -    // Step 0: new slaves dont build cache flush table so just
  85.329 -    // in case our new slave is already installed in hardware
  85.330 -    // we must build the cache flush table before we poke them
  85.331 -    for(int i=0; i<1024-8; i+=8)
  85.332 -	iflushDataAddr[i] = jplus8;
  85.333 -    iflushDataAddr[1024-8] = jlink;
  85.334 -    
  85.335 -    iflushDataAddr[1024-7] = nop;
  85.336 -    iflushDataAddr[1024-6] = nop;
  85.337 -    iflushDataAddr[1024-5] = jlink;
  85.338 -    bee_dcache_flush_all();
  85.339 -
  85.340 -    STEP(1);
  85.341 -    // Step 1: set the resume context for all cores to execute
  85.342 -    // the iflush code and then return to the return (loops)
  85.343 -    unsigned ncores = arch_get_max_core_id();
  85.344 -    for(unsigned i=2; i < ncores; i++) {
  85.345 -	struct corearea *corearea = COREAREA_FOR_CORE(i);
  85.346 -	corearea->regs[0] = 0;
  85.347 -	corearea->regs[30] = ((uint32_t)(iflushDataAddr+1024-7)) >> 2;
  85.348 -	corearea->regs[31] = ((uint32_t)iflushDataAddr) >> 2;
  85.349 -    }
  85.350 -    bee_dcache_flush_all();
  85.351 -
  85.352 -    STEP(2);
  85.353 -    // Step 2: cause the old slaves to start running the
  85.354 -    // cache flush and then loop
  85.355 -    for(unsigned i=2; i<ncores; i++) {
  85.356 -	message_send(i, 0, NULL, 0);
  85.357 -    }
  85.358 -
  85.359 -    STEP(3);
  85.360 -    // Step 3: wait long enough that they must have finished iflush
  85.361 -    // and are now looping.  They have to notice the start; load
  85.362 -    // context execute the iflush, finish loading the context and then
  85.363 -    // execute the iflush all over again (the second one we expect to
  85.364 -    // be mostly cached).  This should be shorter than the time it takes
  85.365 -    // us to read the same memory three times (with *empty* in between)
  85.366 -    for(unsigned i=0; i<3; i++) {
  85.367 -	bee_dcache_empty_all();
  85.368 -	for (unsigned j=0; j<1024; j++)
  85.369 -	    ((volatile uint32_t *)iflushDataAddr)[j];
  85.370 -    }
  85.371 -    
  85.372 -    STEP(4);
  85.373 -    // Step 4: copy the new slave into place
  85.374 -    // and zero all the core areas. except tell the new slave that we
  85.375 -    // expect it to stop.
  85.376 -    extern void slaveStart(void);
  85.377 -    extern void slaveAfter(void);
  85.378 -    uint32_t *from = (uint32_t*)(((uint32_t)slaveStart) << 2);
  85.379 -    uint32_t *to = (uint32_t*)0;
  85.380 -    uint32_t count = slaveAfter - slaveStart;
  85.381 -    while(count--)
  85.382 -	*to++ = *from++;
  85.383 -
  85.384 -    for(int i=2; i<ncores; i++) {
  85.385 -	struct corearea *corearea = COREAREA_FOR_CORE(i);
  85.386 -	for(unsigned j=0; j<sizeof(*corearea)/sizeof(uint32_t); j++)
  85.387 -	    ((uint32_t*)corearea)[j] = 0;
  85.388 -	corearea->master_stops = 1;
  85.389 -    }
  85.390 -    bee_dcache_flush_all();
  85.391 -
  85.392 -    STEP(5);
  85.393 -    // Step 5: send the cores a stop
  85.394 -    // TODO: XXX use the signal word to explain to them...
  85.395 -    for (unsigned i=2; i<ncores; i++) {
  85.396 -	message_send(i, 1, NULL, 0);
  85.397 -    }
  85.398 -
  85.399 -    // Step 6: Wait for them to sync
  85.400 -    STEP(6);
  85.401 -    expect_breaks(STOPCODE_STOP, 1);
  85.402 -    printf("done\n");
  85.403 -} // change_slaves
  85.404 -
  85.405 -
  85.406 -static inline void backtrace(uintptr_t fp)
  85.407 -{
  85.408 -    int i=0;
  85.409 -    printf("Backtrace follows:\n");
  85.410 -    printf("   ---Frame-- -Address-\n");
  85.411 -    while ((fp != 0) && ((fp & (sizeof(fp)-1)) == 0)) {
  85.412 -	printf("%d %x %x\n", i, fp, ((uintptr_t *)fp)[1]);
  85.413 -	fp = *(uintptr_t *)fp;
  85.414 -	i++;
  85.415 -    }
  85.416 -    printf("%d %x\n", i, fp);
  85.417 -}
  85.418 -
  85.419 -#define CORESTATE_STOPPED        1
  85.420 -#define CORESTATE_STOP_SENT      2
  85.421 -#define CORESTATE_RUN_SENT       4
  85.422 -#define CORESTATE_SEND_STOP      8
  85.423 -#define CORESTATE_SEND_KILL      16
  85.424 -#define CORESTATE_EXPECT_BREAKPOINT 32
  85.425 -
  85.426 -int two = 2; // Strange but true; needed to avoid a compiler bug
  85.427 -
  85.428 -void bmain(uint32_t a, uint32_t b, uint32_t c, uint32_t d, uint32_t e, uint32_t f)
  85.429 -{
  85.430 -    uint8_t core;
  85.431 -
  85.432 -    int corestate[16];
  85.433 -    int expectstoptype[16];
  85.434 -
  85.435 -    HYPERDBG('*');
  85.436 -
  85.437 -    core = arch_get_core_id();
  85.438 -
  85.439 -    if (core != 1) {
  85.440 -	HYPERFAIL("core=%d", core);
  85.441 -    }
  85.442 -
  85.443 -    int simulator = arch_is_simulator();
  85.444 -
  85.445 -    extern void _data_iafter(void);
  85.446 -    uintptr_t codelast = (uintptr_t)&_data_iafter;
  85.447 -
  85.448 -    bexec_t *bexec = (bexec_t*)ROUNDUP(codelast<<2, BASE_PAGE_SIZE);
  85.449 -
  85.450 -
  85.451 -    if ((uintptr_t)bexec  != 0x2000<<2) {
  85.452 -	HYPERFAIL("bexec=%p", bexec);
  85.453 -    }
  85.454 -    if (bexec->bmagic != BEXEC_BMAGIC) {
  85.455 -	HYPERFAIL("bmagic=%x", bexec->bmagic);
  85.456 -    }
  85.457 -
  85.458 -#if 0
  85.459 -    // Print the debug stub code for checking
  85.460 -    if (!simulator) {
  85.461 -	printf("Debug stub:\n");
  85.462 -	for (int i = 0; i < 0x300; i+=4) {
  85.463 -	    serial_hex_word(*(unsigned *)i);
  85.464 -	    serial_console_putchar('\r');
  85.465 -	    serial_console_putchar('\n');
  85.466 -	}
  85.467 -    }
  85.468 -#endif
  85.469 -
  85.470 -    for (int i = 0; i < 16; i++)
  85.471 -	corestate[i] = expectstoptype[i] = 0;
  85.472 -
  85.473 -    if (simulator) {
  85.474 -	// The other cores should have run the slave code which should
  85.475 -	// give initial power-on breakpoint.
  85.476 -	expect_breaks(0, 0);
  85.477 -    }
  85.478 -
  85.479 -    change_slaves();
  85.480 -
  85.481 -    // Start first real kernel on core 2 (XXX hardwired address for now!)
  85.482 -    arch_spawn_core(2, 0x2000);
  85.483 -
  85.484 -    unsigned int alarmdelta = (simulator ? 20*1000*1000 : 100*1000*1000);
  85.485 -    unsigned int alarm = cyclecounter() + alarmdelta;
  85.486 -    unsigned ncores = arch_get_max_core_id();
  85.487 -
  85.488 -    corestate[2] = CORESTATE_RUN_SENT;
  85.489 -    for(unsigned i=3; i<ncores; i++)
  85.490 -	corestate[i] = CORESTATE_STOPPED;
  85.491 -
  85.492 -    printf("hyper: alarm=%d\n", alarm);
  85.493 -
  85.494 -    // Handle messages forever
  85.495 -    while (1) {
  85.496 -        msg_t msg; 
  85.497 -        unsigned int srce = 0;
  85.498 -        unsigned int type = 0;
  85.499 -        unsigned int len;
  85.500 -
  85.501 -	do {
  85.502 -	    int ch = serial_poll_getchar();
  85.503 -	    if (ch != -1) {
  85.504 -		printf("hyper: ch=%c\n", ch);
  85.505 -	    }
  85.506 -	    if (ch == 'K' || ch == 'k' || ch == 'S' || ch =='s') { // Stop or Kill
  85.507 -		// Send breaks to all cores
  85.508 -		for (unsigned i=2; i<ncores; i++) {
  85.509 -		    struct corearea *corearea = COREAREA_FOR_CORE(i);
  85.510 -		    corearea->master_stops++;
  85.511 -		}
  85.512 -		bee_dcache_flush_all();
  85.513 -		for (unsigned i=2; i<ncores; i++) {
  85.514 -		    message_send(i, ch == 'K' ? 2 : 1, NULL, 0);
  85.515 -		}
  85.516 -	    }
  85.517 -	    unsigned int cycles = cyclecounter();
  85.518 -	    if (((int)(cycles - alarm)) > 0) {
  85.519 -		// Send timer to all cores
  85.520 -              //		printf("hyper: timer at %d\n", cycles);
  85.521 -		for (unsigned i=2; i<ncores; i++) {
  85.522 -		    struct corearea *corearea = COREAREA_FOR_CORE(i);
  85.523 -		    if (corestate[i] == CORESTATE_RUN_SENT) {
  85.524 -			corearea->master_ticks++;
  85.525 -			corestate[i] = CORESTATE_SEND_STOP;
  85.526 -			expectstoptype[i] = STOPCODE_TIMER;
  85.527 -		    } else if (corestate[i] == CORESTATE_STOP_SENT) {
  85.528 -			corearea->master_stops++;
  85.529 -			printf("hyper: %d not responding!\n", i);
  85.530 -			corestate[i] = CORESTATE_SEND_KILL;
  85.531 -			expectstoptype[i] = STOPCODE_STOP;
  85.532 -		    } else if ((corestate[i] & CORESTATE_EXPECT_BREAKPOINT) != 0) {
  85.533 -		    } else if (corestate[i] != CORESTATE_STOPPED)
  85.534 -			HYPERFAIL("corestate[%d]=%d", i, corestate[i]);
  85.535 -		}
  85.536 -		bee_dcache_flush_all(); // after decisions before sends
  85.537 -		for (unsigned i=2; i<ncores; i++) {
  85.538 -		    if (corestate[i] == CORESTATE_SEND_STOP) {
  85.539 -			message_send(i, 1, NULL, 0);
  85.540 -			corestate[i] = CORESTATE_STOP_SENT;
  85.541 -		    } else if (corestate[i] == CORESTATE_SEND_KILL) {
  85.542 -			message_send(i, 2, NULL, 0);
  85.543 -			corestate[i] = CORESTATE_STOP_SENT;
  85.544 -		    }
  85.545 -		}
  85.546 -		alarm = cyclecounter() + alarmdelta;
  85.547 -                //		printf("hyper: alarm=%d\n", alarm);
  85.548 -	    }
  85.549 -	    //BEE_SIMCTRL(BEE_SIMCTRL_HALT);
  85.550 -	    len = message_recv(&srce, &type, &msg);
  85.551 -	} while(len == 0);
  85.552 -
  85.553 -	HYPERDBG('<');
  85.554 -	HYPERDBG('0'+srce);
  85.555 -	HYPERDBG('T');
  85.556 -	HYPERDBG('0'+type);
  85.557 -	HYPERDBG('L');
  85.558 -	HYPERDBG('0'+len);
  85.559 -	
  85.560 -	if (type == HYPER_MSG_TYPE) {
  85.561 -	    uint32_t opcode = msg[0];
  85.562 -                
  85.563 -	    switch(opcode) {
  85.564 -	    case HYPER_START_CORE:
  85.565 -		HYPERDBG('S');
  85.566 -		HYPERDBG('0'+msg[1]);
  85.567 -		HYPERDBG('>');
  85.568 -		if (corestate[msg[1]] != CORESTATE_STOPPED)
  85.569 -		    HYPERFAIL("start core %d state %d", msg[1], corestate[msg[1]]);
  85.570 -		message_send(msg[1], 0, NULL, 0);
  85.571 -		corestate[msg[1]] = CORESTATE_RUN_SENT;
  85.572 -		break;
  85.573 -
  85.574 -	    case HYPER_SERIAL_OUT:
  85.575 -		if (1) {
  85.576 -#if 0
  85.577 -		    const char *hex = "0123456789ABCDEF";
  85.578 -		    serial_console_putchar(hex[srce]);
  85.579 -		    serial_console_putchar(':');
  85.580 -#endif
  85.581 -		    int outlen = msg[1];
  85.582 -		    char *buf = (char*)&msg[2];
  85.583 -		    // Synchronous output for now...
  85.584 -		    while (outlen) {
  85.585 -			serial_console_putchar(*buf++);
  85.586 -			outlen--;
  85.587 -		    }
  85.588 -		}
  85.589 -		// // XXX Core will breakpoint next ... 
  85.590 -		// // restart once serial output is complete
  85.591 -		//corestate[srce] |= CORESTATE_EXPECT_BREAKPOINT;
  85.592 -		//expectstoptype[srce] = STOPCODE_BREAK;
  85.593 -		// clear lock so core knows it can resume (or
  85.594 -		// send next printf if printf if async)
  85.595 -		lockunit_write(srce);
  85.596 -		break;
  85.597 -	    default:
  85.598 -		HYPERDBG('?');
  85.599 -		break;
  85.600 -	    }
  85.601 -	} else if (type == 1 && len == 1) {
  85.602 -	    // STOPACK TYPE:1 LEN:1 MSG[0]:STOPCODE
  85.603 -	    uint32_t stopcode = msg[0];
  85.604 -	    if (corestate[srce] == CORESTATE_STOP_SENT
  85.605 -		&& stopcode == STOPCODE_TIMER
  85.606 -		&& expectstoptype[srce] == STOPCODE_TIMER) {
  85.607 -		// just get it running again asap
  85.608 -              //		printf("hyper: timer ack %d\n", srce);
  85.609 -		message_send(srce, 0, NULL, 0);
  85.610 -		corestate[srce] = CORESTATE_RUN_SENT;
  85.611 -	    }
  85.612 -	    else if (stopcode == STOPCODE_BREAK
  85.613 -		     && ((corestate[srce] & CORESTATE_EXPECT_BREAKPOINT) != 0)
  85.614 -		     && expectstoptype[srce] == STOPCODE_BREAK) {
  85.615 -		/* Restart the core: dont need to skip over breakpoint
  85.616 -		 * as that is now done in the slave */
  85.617 -		//bee_dcache_empty_all();
  85.618 -		//struct corearea *corearea = COREAREA_FOR_CORE(srce);
  85.619 -		//corearea->regs[31]++;
  85.620 -		//bee_dcache_empty_all();
  85.621 -		message_send(srce, 0, NULL, 0);
  85.622 -		corestate[srce] &= ~CORESTATE_EXPECT_BREAKPOINT;
  85.623 -	    }
  85.624 -	    else {
  85.625 -		printf("hyper: Unexpected stop %d on core %d state %d expect %d\n",
  85.626 -		       stopcode, srce, corestate[srce], expectstoptype[srce]);
  85.627 -
  85.628 -		// XXX should really be invalidate of savearea
  85.629 -		bee_dcache_empty_all();
  85.630 -
  85.631 -		// Dump registers in save area
  85.632 -		struct corearea *savearea = COREAREA_FOR_CORE(srce);
  85.633 -
  85.634 -		for (unsigned i = 0; i < 32; i++) {
  85.635 -		    if ((i & 3) == 0) {
  85.636 -			if (i < 10) serial_console_putchar(' ');
  85.637 -			serial_dec_word(i);
  85.638 -		    }
  85.639 -		    serial_console_putchar(' ');
  85.640 -		    serial_hex_word(savearea->regs[i]);
  85.641 -		    if ((i & 3) == 3)
  85.642 -			printf("\n");
  85.643 -		}
  85.644 -		backtrace(savearea->regs[23]);
  85.645 -
  85.646 -		for (unsigned p = savearea->regs[31] - 8;
  85.647 -		     p < savearea->regs[31] + 8;
  85.648 -		     p++) {
  85.649 -		    printf("word %x = %x\n", p, *((unsigned *)(p << 2)));
  85.650 -		}
  85.651 -
  85.652 -		corestate[srce] = CORESTATE_STOPPED;
  85.653 -
  85.654 -		int allstopped = 1;
  85.655 -		for(unsigned i=two; i<ncores; i++) {
  85.656 -		    if (corestate[i] != CORESTATE_STOPPED) {
  85.657 -			allstopped = 0;
  85.658 -			break;
  85.659 -		    }
  85.660 -		}
  85.661 -		if (allstopped)
  85.662 -		    HYPERFAIL("all stopped");
  85.663 -	    }
  85.664 -	} else {
  85.665 -	    printf("hyper: Unexpected type %x len %d: ", type, len);
  85.666 -	    for (unsigned i=0; i<len; i++) {
  85.667 -		printf("%x\n", msg[i]);
  85.668 -	    }
  85.669 -	}
  85.670 -    } // while(1)
  85.671 -}
    86.1 --- a/kernel/arch/beehive/init.c	Fri Jan 20 14:32:03 2012 -0800
    86.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.3 @@ -1,289 +0,0 @@
    86.4 -/*
    86.5 - * Copyright (c) 2009, 2010, ETH Zurich.
    86.6 - * All rights reserved.
    86.7 - *
    86.8 - * This file is distributed under the terms in the attached LICENSE file.
    86.9 - * If you do not find this file, copies can be found by writing to:
   86.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   86.11 - */
   86.12 -
   86.13 -#include <kernel.h>
   86.14 -#include <serial.h>
   86.15 -#include <stdio.h>
   86.16 -#include <string.h> // for memmove
   86.17 -#include <barrelfish_kpi/init.h>
   86.18 -#include <barrelfish_kpi/paging_arch.h> // for BASE_PAGE_SIZE
   86.19 -#include <target/beehive/barrelfish_kpi/coredata_target.h>
   86.20 -#include <corearea.h>
   86.21 -#include <simctrl.h>
   86.22 -#include <dcache.h>
   86.23 -#include "beekernel.h"
   86.24 -#include "bmp.h"
   86.25 -
   86.26 -// <This section should be in a arch header file>
   86.27 -
   86.28 -#define MAX_IMAGES 32
   86.29 -bexec_t *MovedImages[MAX_IMAGES];
   86.30 -int MovedImageCount;
   86.31 -
   86.32 -#define ROUNDUP(x,y) (((x)+(y)-1) & ~((y)-1))
   86.33 -
   86.34 -extern void mmu_add_entry(uint32_t start, uint32_t length, int read, int write);
   86.35 -
   86.36 -// </This section should be in a arch header file>
   86.37 -
   86.38 -extern void ringt0(uint32_t *ptr, int count);
   86.39 -extern void ringt1(uint32_t *ptr, int count);
   86.40 -extern void ringt2(uint32_t *ptr, int count);
   86.41 -extern void ringt3(uint32_t *ptr, int count);
   86.42 -extern void ringt4(uint32_t *ptr, int count);
   86.43 -
   86.44 -uint32_t array[6*10];
   86.45 -
   86.46 -// On most systems this is called _end, but on beehive it is a
   86.47 -// word/code address, and must be shifted for data accesses.
   86.48 -// care that some of these are Linker absolute and dont relocate
   86.49 -// properly to other than the first image.
   86.50 -extern void _code_ibefore(void);
   86.51 -extern void _code_iafter(void);
   86.52 -extern void _data_ibefore(void);
   86.53 -extern void _data_iafter(void);
   86.54 -
   86.55 -int bmain(struct beehive_core_data *bcd);
   86.56 -
   86.57 -static void MoveImages(void**const pinitaddr, pstringtable_t *const ppstrings);
   86.58 -
   86.59 -// findbits.S
   86.60 -
   86.61 -extern int find_least_clear32(uint32_t value);
   86.62 -//extern int find_least_set32(uint32_t value);
   86.63 -extern int find_least_clear64(uint64_t value);
   86.64 -extern int find_least_set64(uint64_t value);
   86.65 -extern int find_highest_clear32(uint32_t value);
   86.66 -//extern int find_highest_set32(uint32_t value);
   86.67 -extern int find_highest_clear64(uint64_t value);
   86.68 -extern int find_highest_set64(uint64_t value);
   86.69 -extern int population_count(uint32_t value);
   86.70 -
   86.71 -// startup.c
   86.72 -
   86.73 -extern void kernel_bsp_startup(void* initaddr, pstringtable_t strings);
   86.74 -extern void kernel_app_startup(struct beehive_core_data *bcd);
   86.75 -extern void kernel_alloc_init(lpaddr_t base, lpaddr_t limit);
   86.76 -
   86.77 -// Tell startup.c where it can start allocating memory
   86.78 -
   86.79 -/**
   86.80 - * \brief Test if this is the bootstrap processor
   86.81 - *
   86.82 - */
   86.83 -inline bool arch_core_is_bsp(void)
   86.84 -{
   86.85 -    int core = arch_get_core_id();
   86.86 -    return core == 1 || core == 2;
   86.87 -}
   86.88 -
   86.89 -/*
   86.90 - * the bcd pointer is only valid if we are not the boot core
   86.91 - */
   86.92 -int bmain(struct beehive_core_data *bcd)
   86.93 -{
   86.94 -    uint8_t core;
   86.95 -
   86.96 -    core = arch_get_core_id();
   86.97 -    if (core > 1) {
   86.98 -	BEE_SIMCTRL(BEE_SIMCTRL_REGISTERS);
   86.99 -    }
  86.100 -
  86.101 -    // do not remove/change this printf: needed by regression harness
  86.102 -    printf("Barrelfish CPU driver starting on Beehive core %u\n", core);
  86.103 -
  86.104 -    mmu_add_entry((uint32_t)_code_ibefore,
  86.105 -		  (((uint32_t)_data_ibefore) >> 2) - (uint32_t)_code_ibefore,
  86.106 -		  1, 0);
  86.107 -
  86.108 -    // Write system call vector into this core's core area
  86.109 -    struct corearea *corearea = my_corearea();
  86.110 -
  86.111 -    extern void systrap(void); // assembler function
  86.112 -    corearea->syscall = (uint32_t)systrap;
  86.113 -    printf("Set system call entry at %p to %#x\n",
  86.114 -	   &corearea->syscall, corearea->syscall);
  86.115 -
  86.116 -    extern void interrupt(void); // assembler function
  86.117 -    corearea->kernel_ticker = (uint32_t)interrupt;
  86.118 -    printf("Set kernel ticker entry at %p to %#x\n",
  86.119 -	   &corearea->kernel_ticker, corearea->kernel_ticker);
  86.120 -
  86.121 -    corearea->kernel_begins = (uint32_t)_code_ibefore;
  86.122 -    corearea->kernel_ends = (uint32_t)(_data_ibefore) >> 2; // because of linker
  86.123 -    printf("Set kernel begins %#x and ends %#x\n",
  86.124 -	   corearea->kernel_begins, corearea->kernel_ends);
  86.125 -
  86.126 -    // Tests
  86.127 -
  86.128 -    extern int lli_test(void);
  86.129 -    int lli_result = lli_test();
  86.130 -    if (lli_result == 1)
  86.131 -	printf("lli_test(): passed ok\n");
  86.132 -    else
  86.133 -	printf("\n**** lli_test(): failed with code %#x\n\n", lli_result);
  86.134 -
  86.135 -    extern unsigned skip_test(unsigned t); // ~20 cycles per iteration
  86.136 -    unsigned skip_result = skip_test(arch_is_simulator() ? 100000 : 10000000);
  86.137 -    if (skip_result != 0)
  86.138 -	panic("skip_test: %#x\n", skip_result);
  86.139 -
  86.140 -
  86.141 -    // TODO: Might need to move bmp init to before first printf for real HW
  86.142 -    bmp_init();
  86.143 -    if (arch_core_is_bsp()) {
  86.144 -#if 0
  86.145 -	// XXX HACK
  86.146 -	if (core == 2) {
  86.147 -	    ringt1(array, 10);
  86.148 -	    for(int i=0; i<60; i+=6) {
  86.149 -		printf("%8u %8u %8u %8u %8u %8u\n",
  86.150 -		       array[i], array[i+1], array[i+2],
  86.151 -		       array[i+3], array[i+4], array[i+5]);
  86.152 -	    }
  86.153 -	}
  86.154 -#endif
  86.155 -        //kernel_startup_early();
  86.156 -        void *initaddr;
  86.157 -        pstringtable_t strings;
  86.158 -        MoveImages(&initaddr, &strings);
  86.159 -        bee_dcache_flush_all();
  86.160 -	if (!strings)
  86.161 -	    panic("no string table found");
  86.162 -        kernel_bsp_startup(initaddr, strings);
  86.163 -    } else {
  86.164 -        printf("core_data at %p\n", bcd);
  86.165 -        printf("cpu_module at %p\n", bcd->cpu_module);
  86.166 -        printf("monitor_module at %p\n", bcd->monitor_module);
  86.167 -        kernel_alloc_init(bcd->memory_base, bcd->memory_limit);
  86.168 -        kernel_app_startup(bcd);
  86.169 -    }
  86.170 -
  86.171 -    return 0; // "error: return type of main is not int"
  86.172 -} // bmain
  86.173 -
  86.174 -
  86.175 -static unsigned int ImageSum(const unsigned int *ptr, size_t count)
  86.176 -{
  86.177 -    unsigned int val = 0;
  86.178 -    do
  86.179 -	val += *(ptr++);
  86.180 -    while(--count > 0);
  86.181 -    return val ^ ~((val << 1) | (val >> 31));
  86.182 -}
  86.183 -
  86.184 -
  86.185 -static void MoveImages(void**const pinitaddr, pstringtable_t *const ppstrings)
  86.186 -{
  86.187 -    // current last position in word addresses
  86.188 -    //    uintptr_t codelast = (uintptr_t)0x1000; 
  86.189 -    uintptr_t codelast = (uintptr_t)&_data_iafter;
  86.190 -    bexec_t *bexec = (void*)(codelast << 2);
  86.191 -    pstringtable_t strings = NULL;
  86.192 -    pstringtable_t strings2 = NULL;
  86.193 -    printf("_data_iafter = %p\n", &_data_iafter);
  86.194 -    printf("bexec = %p\n", bexec);
  86.195 -
  86.196 -    MovedImageCount = 0;
  86.197 -    while (MovedImageCount < MAX_IMAGES) {
  86.198 -	if ((bexec->bmagic == BEXEC_BMAGIC)
  86.199 -	    && (bexec->btorg >= codelast) && (bexec->btsize > 8)
  86.200 -	    && (bexec->bdorg >= bexec->btorg + bexec->btsize)
  86.201 -	    && (bexec->bborg >= bexec->bdorg + bexec->bdsize)
  86.202 -	    && (ImageSum((void*)bexec, bexec->btsize + bexec->bdsize) == 0)) {
  86.203 -	    // Found an image
  86.204 -	    printf("Found image %d at %p [%#x %#x %#x %#x %#x %#x %#x]\n", 
  86.205 -                   MovedImageCount, bexec, bexec->bmagic,
  86.206 -		   bexec->btorg, bexec->btsize, bexec->bdorg, bexec->bdsize,
  86.207 -		   bexec->bborg, bexec->bbsize);
  86.208 -	    MovedImages[MovedImageCount++] = bexec;
  86.209 -	    codelast = ROUNDUP(bexec->bborg + bexec->bbsize, (BASE_PAGE_SIZE >> 2));
  86.210 -	    bexec = (void*)(((uintptr_t)bexec) + ((bexec->btsize + bexec->bdsize) << 2));
  86.211 -            // Check that we're not exceeding MAX_IMAGES
  86.212 -            if (MovedImageCount == MAX_IMAGES) {
  86.213 -              panic("reached MAX_IMAGES before end of input");
  86.214 -            }
  86.215 -	} else if (bexec->bmagic == BEXEC_ARGSMAGIC) {
  86.216 -	    strings = (pstringtable_t)bexec;
  86.217 - 	    strings2 = (pstringtable_t)(codelast << 2);
  86.218 -	    printf("Found strings area at %p size %u move to %p\n",
  86.219 -		   strings, strings->slength, strings2);
  86.220 -	    codelast += (ROUNDUP(strings->slength, BASE_PAGE_SIZE)) >> 2;
  86.221 -	    break; // string table is last
  86.222 -	} else {
  86.223 -	    printf ("No image at %p [%#x %#x %#x %#x %#x %#x %#x]\n", 
  86.224 -                   bexec, bexec->bmagic,
  86.225 -		   bexec->btorg, bexec->btsize, bexec->bdorg, bexec->bdsize,
  86.226 -		   bexec->bborg, bexec->bbsize);
  86.227 -	    break;
  86.228 -	}
  86.229 -    }
  86.230 -    printf("Found %d images total\n", MovedImageCount);
  86.231 -
  86.232 -    printf("codelast=%#x\n", codelast);
  86.233 -
  86.234 -    if (strings != NULL) {
  86.235 -	memmove(strings2, strings, strings->slength);
  86.236 -    }
  86.237 -
  86.238 -    // Now they are found, move each one into place and zap its bss
  86.239 -    for (int i=MovedImageCount-1; i>=0; i--) {
  86.240 -	bexec = MovedImages[i];
  86.241 -	// Remember to move backwards down memory
  86.242 -	void *src = bexec;
  86.243 -	void *dst = (void*)(bexec->btorg << 2);
  86.244 -	size_t len = (bexec->bdorg + bexec->bdsize - bexec->btorg) << 2;
  86.245 -
  86.246 -	// Must memset before memmove since bexec->... can be different
  86.247 -	// after the memmove!
  86.248 -        size_t zlen = ((bexec->bborg+bexec->bbsize)
  86.249 -                       - (bexec->bdorg+bexec->bdsize));
  86.250 -        void *edata = (void*)((bexec->bdorg + bexec->bdsize)<<2);
  86.251 -        memset(edata, 0, zlen << 2);
  86.252 -
  86.253 -        if (((uintptr_t)src^(uintptr_t)dst) & (sizeof(uintptr_t)-1)) {
  86.254 -            printf("warning: slow unaligned memmove\n");
  86.255 -        }
  86.256 -	memmove(dst, src, len);
  86.257 -	MovedImages[i] = dst;
  86.258 -        bexec = dst;
  86.259 -#if 0
  86.260 -        printf("Checksum is now %#x\n", 
  86.261 -               ImageSum((void*)bexec, bexec->btsize + bexec->bdsize));
  86.262 -        printf("Checksum (w/BSS) is now %#x\n", 
  86.263 -               ImageSum((void*)bexec, bexec->btsize + bexec->bdsize + bexec->bbsize));
  86.264 -#endif
  86.265 -
  86.266 -	// And protect it
  86.267 -        printf("Write-protect TEXT %#x->%#x\n", bexec->btorg, bexec->btorg+bexec->btsize);
  86.268 -	mmu_add_entry(bexec->btorg, bexec->btsize, 1, 0);	
  86.269 -        if (i < 1) continue;
  86.270 -        continue;
  86.271 -        printf("Write-protect DATA %#x->%#x\n", bexec->bdorg, bexec->bdorg+bexec->bdsize);
  86.272 -        mmu_add_entry(bexec->bdorg, bexec->bdsize, 1, 0);
  86.273 -
  86.274 -        printf("Write-protect BSS %#x->%#x\n", bexec->bborg, bexec->bborg+bexec->bbsize);
  86.275 -        mmu_add_entry(bexec->bborg, bexec->bbsize, 1, 0);
  86.276 -
  86.277 -    }
  86.278 -
  86.279 -    printf("All images moved\n");
  86.280 -
  86.281 -    // First free address
  86.282 -    uintptr_t location = codelast << 2;
  86.283 -
  86.284 -    // Roundup to a sane granularuity 
  86.285 -    printf("location = %#x\n", location);
  86.286 -    location = ROUNDUP(location, BASE_PAGE_SIZE);
  86.287 -    kernel_alloc_init(location, location + BASE_PAGE_SIZE*1024);
  86.288 -   
  86.289 -    // Results
  86.290 -    *pinitaddr = (MovedImageCount > 0 ? MovedImages[0] : NULL);
  86.291 -    *ppstrings = strings2;
  86.292 -} // MoveImages
    87.1 --- a/kernel/arch/beehive/kputchar.c	Fri Jan 20 14:32:03 2012 -0800
    87.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.3 @@ -1,102 +0,0 @@
    87.4 -/**
    87.5 - * \file
    87.6 - * \brief The world's simplest serial driver.
    87.7 - *
    87.8 - */
    87.9 -
   87.10 -/*
   87.11 - * Copyright (c) 2010, ETH Zurich.
   87.12 - * All rights reserved.
   87.13 - *
   87.14 - * This file is distributed under the terms in the attached LICENSE file.
   87.15 - * If you do not find this file, copies can be found by writing to:
   87.16 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   87.17 - */
   87.18 -
   87.19 -#include <serial.h>
   87.20 -#include <hyper.h>
   87.21 -#include <kputchar.h>
   87.22 -#include <beej7.h>
   87.23 -#include "beekernel.h"
   87.24 -
   87.25 -static uint32_t msg[63];
   87.26 -static char *kputbuf = 0;
   87.27 -
   87.28 -#define KPBUFSZ (61*4)
   87.29 -static int kcount = 0;
   87.30 -
   87.31 -extern int message_recv(int *srce, int *type, uint32_t * buf);
   87.32 -extern void message_send(int dest, int type, uint32_t *buf, int len);
   87.33 -
   87.34 -extern int lockunit_read(int n);
   87.35 -extern void lockunit_write(int n);
   87.36 -
   87.37 -
   87.38 -static  void breakpoint(void) 
   87.39 -{
   87.40 -    // Sanity check that breakpoint code doesn't trash registers!
   87.41 -    //__asm volatile ("simctrl 4");
   87.42 -    __asm volatile ("j7	6");
   87.43 -    // __asm volatile ("simctrl 4");
   87.44 -}
   87.45 -
   87.46 -static inline int running(void)
   87.47 -{
   87.48 -    int result;
   87.49 -    __asm("j7 5; ld %[result], link"
   87.50 -	  : [result]"=r" (result) :: "link", "cc");
   87.51 -    return result;
   87.52 -}
   87.53 -
   87.54 -
   87.55 -static void kflush(void)
   87.56 -{
   87.57 -    if (kcount > 0) {
   87.58 -        msg[0] = HYPER_SERIAL_OUT;
   87.59 -        msg[1] = kcount;
   87.60 -        int words = 2 + ((kcount+3)>>2);
   87.61 -
   87.62 -	// Wait while any previous message is unfinished
   87.63 -	// indicated by us still having the lock/semaphore
   87.64 -	int mycore = arch_get_core_id();
   87.65 -	int lockval;
   87.66 -	do {
   87.67 -	    lockval = lockunit_read(mycore);
   87.68 -	    if (lockval != 1 && lockval != 2)
   87.69 -		breakpoint();
   87.70 -	} while(lockval == 2);
   87.71 -
   87.72 -        message_send(1, HYPER_MSG_TYPE, msg, words);
   87.73 -        //breakpoint();
   87.74 -
   87.75 -        kcount = 0;
   87.76 -    }
   87.77 -}
   87.78 -
   87.79 -void kprintf_begin(void)
   87.80 -{
   87.81 -    if (!running())
   87.82 -	breakpoint();
   87.83 -    kcount = 0;
   87.84 -    kputbuf = (char*)&msg[2];
   87.85 -}
   87.86 -
   87.87 -int kputchar(int c)
   87.88 -{
   87.89 -    if (c == '\n') {
   87.90 -	if (kcount == KPBUFSZ)
   87.91 -	    kflush();
   87.92 -	kputbuf[kcount++] = '\r';
   87.93 -    }
   87.94 -    if (kcount == KPBUFSZ)
   87.95 -	kflush();
   87.96 -    kputbuf[kcount++] = c;
   87.97 -    return c;
   87.98 -}
   87.99 -
  87.100 -void kprintf_end(void)
  87.101 -{
  87.102 -    kflush();
  87.103 -}
  87.104 -
  87.105 -// End
    88.1 --- a/kernel/arch/beehive/microbenchmarks.c	Fri Jan 20 14:32:03 2012 -0800
    88.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.3 @@ -1,21 +0,0 @@
    88.4 -/**
    88.5 - * \file
    88.6 - * \brief Architecture-specific microbenchmarks.
    88.7 - */
    88.8 -
    88.9 -/*
   88.10 - * Copyright (c) 2009, ETH Zurich
   88.11 - * All rights reserved.
   88.12 - *
   88.13 - * This file is distributed under the terms in the attached LICENSE file.
   88.14 - * If you do not find this file, copies can be found by writing to:
   88.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   88.16 - */
   88.17 -
   88.18 -#include <kernel.h>
   88.19 -#include <microbenchmarks.h>
   88.20 -
   88.21 -struct microbench arch_benchmarks[] = {
   88.22 -};
   88.23 -
   88.24 -size_t arch_benchmarks_size = sizeof(arch_benchmarks) / sizeof(struct microbench);
    89.1 --- a/kernel/arch/beehive/misc.c	Fri Jan 20 14:32:03 2012 -0800
    89.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.3 @@ -1,139 +0,0 @@
    89.4 -/** \file
    89.5 - * \brief Miscellaneous kernel support code.
    89.6 - *
    89.7 - * This file contains miscellaneous architecture-independent kernel support
    89.8 - * code that doesn't belong anywhere else.
    89.9 - */
   89.10 -
   89.11 -/*
   89.12 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
   89.13 - * All rights reserved.
   89.14 - *
   89.15 - * This file is distributed under the terms in the attached LICENSE file.
   89.16 - * If you do not find this file, copies can be found by writing to:
   89.17 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   89.18 - */
   89.19 -
   89.20 -#include <kernel.h>
   89.21 -#include <stdarg.h>
   89.22 -#include <stdio.h>
   89.23 -#include <exec.h>
   89.24 -#include <misc.h>
   89.25 -
   89.26 -#define DEFAULT_LOGLEVEL        LOG_DEBUG
   89.27 -#define DEFAULT_SUBSYSTEM_MASK  (~0L)
   89.28 -
   89.29 -/**
   89.30 - * Global kernel loglevel.
   89.31 - */
   89.32 -int kernel_loglevel = DEFAULT_LOGLEVEL;
   89.33 -
   89.34 -/**
   89.35 - * Default kernel subsystem message mask. Determines messages of what subsystems
   89.36 - * get output.
   89.37 - */
   89.38 -int kernel_log_subsystem_mask = DEFAULT_SUBSYSTEM_MASK;
   89.39 -
   89.40 -/**
   89.41 - * 'true' if kernel should handle and context switch on timer ticks.
   89.42 - * Pass the ticks parameter on the kernel command line if you
   89.43 - * want to change this.
   89.44 - */
   89.45 -bool kernel_ticks_enabled = true;
   89.46 -
   89.47 -/**
   89.48 - * The current time since kernel start in timeslices.
   89.49 - */
   89.50 -size_t kernel_now = 0;
   89.51 -
   89.52 -
   89.53 -__attribute__((noinline)) void debug_print_backtrace(void)
   89.54 -{
   89.55 -    uintptr_t fp = (uintptr_t)__builtin_frame_address(0);
   89.56 -    int i=0;
   89.57 -    printf("Backtrace follows:\n");
   89.58 -    printf("   ---Frame-- -Address-\n");
   89.59 -    while ((fp != 0) && ((fp & (sizeof(fp)-1)) == 0)) {
   89.60 -	printf("%.2i 0x%.8x 0x%.8x\n", i, fp, ((uintptr_t *)fp)[1]);
   89.61 -	fp = *(uintptr_t *)fp;
   89.62 -	i++;
   89.63 -    }
   89.64 -    printf("%.2i 0x%.8x\n", i, fp);
   89.65 -}
   89.66 -
   89.67 -
   89.68 -
   89.69 -/**
   89.70 - * \brief Print a message and halt the kernel.
   89.71 - *
   89.72 - * Something irrecoverably bad happened. Print a panic message, then halt.
   89.73 - */
   89.74 -void panic(const char *msg, ...)
   89.75 -{
   89.76 -    va_list ap;
   89.77 -    static char buf[256];
   89.78 -
   89.79 -    va_start(ap, msg);
   89.80 -    vsnprintf(buf, sizeof(buf), msg, ap);
   89.81 -    va_end(ap);
   89.82 -
   89.83 -    printf("kernel PANIC! (core %d) %.*s\n", my_core_id, (int)sizeof(buf), buf);
   89.84 -
   89.85 -    debug_print_backtrace();
   89.86 -
   89.87 -    extern void _end_simulation(void);
   89.88 -    _end_simulation();
   89.89 -
   89.90 -    // We don't have GDB support - so don't breakpoint
   89.91 -    //breakpoint();
   89.92 -    
   89.93 -    // Halt calls panic! :-)
   89.94 -    halt();
   89.95 -}
   89.96 -
   89.97 -/**
   89.98 - * \brief Log a kernel message.
   89.99 - *
  89.100 - * Logs printf()-style message 'msg', having loglevel 'level' to the default
  89.101 - * kernel console(s). Additional arguments are like printf(). Whether the
  89.102 - * message is put out depends on the current kernel log level.
  89.103 - *
  89.104 - * \param level Loglevel of message.
  89.105 - * \param msg   The message (printf() format string)
  89.106 - */
  89.107 -void printk(int level, const char *msg, ...)
  89.108 -{
  89.109 -    if(kernel_loglevel > level) {
  89.110 -        va_list ap;
  89.111 -        static char buf[256];
  89.112 -
  89.113 -        va_start(ap, msg);
  89.114 -        vsnprintf(buf, sizeof(buf), msg, ap);
  89.115 -        va_end(ap);
  89.116 -
  89.117 -        printf("kernel %.*s", (int)sizeof(buf), buf);
  89.118 -    }
  89.119 -}
  89.120 -
  89.121 -/**
  89.122 - * Helper function used in the implementation of assert()
  89.123 - */
  89.124 -void __assert(const char *exp, const char *file, const char *func, int line)
  89.125 -{
  89.126 -    panic("kernel assertion \"%s\" failed at %s:%d", exp, file, line);
  89.127 -}
  89.128 -#if 0
  89.129 -void
  89.130 -wait_cycles(uint64_t duration)
  89.131 -{
  89.132 -    uint64_t stoptime;
  89.133 -    stoptime = arch_get_cycle_count() + duration;
  89.134 -    printk(LOG_NOTE, "Waiting %lu cycles...\n", duration);
  89.135 -    while (arch_get_cycle_count() < stoptime);
  89.136 -}
  89.137 -#endif
  89.138 -
  89.139 -/**
  89.140 - * Kernel trace buffer
  89.141 - */
  89.142 -lvaddr_t kernel_trace_buf = 0;
    90.1 --- a/kernel/arch/beehive/page_mappings_arch.c	Fri Jan 20 14:32:03 2012 -0800
    90.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.3 @@ -1,25 +0,0 @@
    90.4 -/**
    90.5 - * \file
    90.6 - * \brief
    90.7 - */
    90.8 -
    90.9 -/*
   90.10 - * Copyright (c) 2010, ETH Zurich.
   90.11 - * All rights reserved.
   90.12 - *
   90.13 - * This file is distributed under the terms in the attached LICENSE file.
   90.14 - * If you do not find this file, copies can be found by writing to:
   90.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   90.16 - */
   90.17 -
   90.18 -#include <kernel.h>
   90.19 -#include <capabilities.h>
   90.20 -
   90.21 -/// Create page mappings
   90.22 -errval_t caps_copy_to_vnode(struct cte *dest_vnode_cte, cslot_t dest_slot,
   90.23 -                            struct cte *src_cte, uintptr_t param1,
   90.24 -                            uintptr_t param2)
   90.25 -{
   90.26 -    panic("NYI");
   90.27 -    return SYS_ERR_OK;
   90.28 -}
    91.1 --- a/kernel/arch/beehive/ringbmp.c	Fri Jan 20 14:32:03 2012 -0800
    91.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.3 @@ -1,327 +0,0 @@
    91.4 -/**
    91.5 - * \file
    91.6 - * \brief Beehive message transport kernel component
    91.7 - */
    91.8 -
    91.9 -/*
   91.10 - * Copyright (c) 2010, ETH Zurich.
   91.11 - * All rights reserved.
   91.12 - *
   91.13 - * This file is distributed under the terms in the attached LICENSE file.
   91.14 - * If you do not find this file, copies can be found by writing to:
   91.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   91.16 - */
   91.17 -
   91.18 -#include <kernel.h>
   91.19 -#include <hyper.h>
   91.20 -#include <stdlib.h>
   91.21 -#include <stdio.h>
   91.22 -#include <assert.h>
   91.23 -#include <capabilities.h> // cte
   91.24 -#include <dispatch.h> // dcb_current
   91.25 -#include <barrelfish_kpi/lmp.h> // LM_RECV_HEADER_LENGTH
   91.26 -
   91.27 -#include <trace/trace.h>
   91.28 -
   91.29 -#include "bmp.h"
   91.30 -
   91.31 -/*
   91.32 - * Understanding this kernel component transport: this is a connection
   91.33 - * oriented word transport with credit based flow control between
   91.34 - * cores.
   91.35 - *
   91.36 - * Message format: messages have a header word with two fields; one
   91.37 - * contains the credit being sent, the other the channel number.
   91.38 - *
   91.39 - * Receive: the channel number identifies a state record (if invalid
   91.40 - * the data is discarded) which describes the area of memory for
   91.41 - * receipt of the words (base and size) which is used as a circular
   91.42 - * buffer.  A Next index and a Limit index control the use of the
   91.43 - * circular buffer.  How the Next and Limit indices are communicated
   91.44 - * to the user mode process is TBD.
   91.45 - *
   91.46 - * Credits: there are two arrays of credits, one for transmission and
   91.47 - * one for outgoing.  When a message arrives the incoming credit count
   91.48 - * is added to the transmission credit for the remote core.  The size
   91.49 - * of the message, including the hardware header word, is added to the
   91.50 - * outgoing credit count for the remote core.
   91.51 - *
   91.52 - * Processing: when polling (e.g. from the idle loop) messages are
   91.53 - * read and delivered until the incoming fifo is empty.  Then any
   91.54 - * outgoing credit values greater than 2 are sent to the respective
   91.55 - * cores.  Values <= 2 are not sent to avoid ACKing ACKs.
   91.56 - *
   91.57 - * Transmit: a message of n words (including headers) can be sent if
   91.58 - * the amount of credit available is greater than or equal to n + 2.
   91.59 - * The extra 2 is required to ensure that an ACK can be sent at a
   91.60 - * later date without having to wait for one.
   91.61 - *
   91.62 - * MTU: The hardware supports 64 words, i.e. 62 plus our header plus
   91.63 - * HW header, but this is also the flow control limit.  Since we might
   91.64 - * have sent an ACK already which is not acked a common value of
   91.65 - * credit is 62.  Since we have to keep enough credit to be able to
   91.66 - * send an ACK subsequently the maximum sized message is 60 words,
   91.67 - * i.e. 58 words of payload.
   91.68 - */
   91.69 -
   91.70 -#define MAX_PAYLOAD 58
   91.71 -
   91.72 -#define BEEHIVE_RING_TYPE_BMP 2
   91.73 -
   91.74 -#define NUM_ASSOCS 32
   91.75 -
   91.76 -#define BEEHIVE_CORES 16
   91.77 -
   91.78 -static int out_credits[BEEHIVE_CORES];
   91.79 -static int tx_credits[BEEHIVE_CORES];
   91.80 -
   91.81 -static struct cte bmp_dispatch[NUM_ASSOCS];
   91.82 -
   91.83 -void bmp_init(void)
   91.84 -{
   91.85 -    for(int i=0; i<BEEHIVE_CORES; i++) {
   91.86 -	out_credits[i] = 0;
   91.87 -	tx_credits[i] = 64;
   91.88 -    }
   91.89 -}
   91.90 -
   91.91 -
   91.92 -/**
   91.93 - * \brief Deliver a BMP message to a dispatcher.
   91.94 - *
   91.95 - * \param ep     Endpoint capability to send to
   91.96 - * \param len    Number of words to be transferred
   91.97 - * \param msg    Message to be sent
   91.98 - *
   91.99 - * \return Error code
  91.100 - */
  91.101 -errval_t bmp_deliver(struct capability *ep, size_t len,
  91.102 -                     uintptr_t *msg);
  91.103 -
  91.104 -static inline void bmpack(int core, int credit);
  91.105 -static inline void bmptx(int core, int credit, int assoc, int size, uint32_t *ptr);
  91.106 -
  91.107 -extern int message_recv(int *srce, int *type, uint32_t * buf);
  91.108 -extern void message_send(int dest, int type, uint32_t *buf, int len);
  91.109 -extern void message_send_with_header(int dest, int type, uint32_t *buf, int len, uint32_t header);
  91.110 -
  91.111 -extern void halt_unless_timer_pending(void);
  91.112 -
  91.113 -
  91.114 -// Returns 0 if message queue was empty, 1 otherwise
  91.115 -static inline int bmp_process_one(void)
  91.116 -{
  91.117 -    static uint32_t buf[64];
  91.118 -    int core;
  91.119 -    int type;
  91.120 -    int len;
  91.121 -
  91.122 -    for(;;) {
  91.123 -	len = message_recv(&core, &type, buf);
  91.124 -	if (len == 0)
  91.125 -	    return 0;
  91.126 -
  91.127 -        if (core == 1) {
  91.128 -	    printf("bmpread1: message from hypervisor!\n");
  91.129 -	    continue;
  91.130 -        }
  91.131 -	trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_RX, len);
  91.132 -	//debug(SUBSYS_BMP, "bmpread1: len=%d, core=%d, type=%d\n", len, core, type);
  91.133 -
  91.134 -	// Even if it is invalid message it counts for credit
  91.135 -	out_credits[core] += len + 1; // +1 for HW header word
  91.136 -	
  91.137 -	if (type != BEEHIVE_RING_TYPE_BMP) {
  91.138 -	    printf("bmpread1: bad type %d\n", type);
  91.139 -	    continue;
  91.140 -	}
  91.141 -
  91.142 -	uint32_t header = buf[0];
  91.143 -	//debug(SUBSYS_BMP, "bmpread1: incoming credits: %u\n", header >> 16);
  91.144 -	tx_credits[core] += (header >> 16);
  91.145 -	// If no length then just an ack, no assoc
  91.146 -	if (len == 1)
  91.147 -	    continue;
  91.148 -
  91.149 -	header &= 0xffff;
  91.150 -	if (header > NUM_ASSOCS) {
  91.151 -	    printf("bmpread1: bad assoc %d\n", header);
  91.152 -	    continue;
  91.153 -	}
  91.154 -
  91.155 -	struct capability *cap = &bmp_dispatch[header].cap;
  91.156 -	if (cap->type == ObjType_Null) {
  91.157 -	    printf("bmpread1: unused assoc %d\n", header);
  91.158 -	    continue;
  91.159 -	}
  91.160 -	assert(cap->type == ObjType_EndPoint);
  91.161 -	// XXX Check incoming core?
  91.162 -
  91.163 -	//debug(SUBSYS_BMP, "Delivering BMP message assoc %u len %u\n", header, len);
  91.164 -	trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_PRE_DELIVER, (uintptr_t)cap);
  91.165 -	errval_t err = bmp_deliver(cap, len -1, &buf[1]);
  91.166 -	trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_POST_DELIVER, (uintptr_t)cap);
  91.167 -	if (err_is_fail(err))
  91.168 -	    printf("bmpread1: bmp_deliver: error %u\n", err);
  91.169 -	return 1;
  91.170 -    }
  91.171 -} // bmpread1
  91.172 -
  91.173 -static inline void bmpack(int core, int credit)
  91.174 -{
  91.175 -    uint32_t header = credit << 16;
  91.176 -    message_send_with_header(core, BEEHIVE_RING_TYPE_BMP, NULL, 0, header);
  91.177 -}
  91.178 -
  91.179 -static inline void bmptx(int core, int credit, int assoc, int size, uint32_t *ptr)
  91.180 -{
  91.181 -    uint32_t header = (credit << 16) | assoc;
  91.182 -    message_send_with_header(core, BEEHIVE_RING_TYPE_BMP, ptr, size, header);
  91.183 -}
  91.184 -
  91.185 -
  91.186 -static inline void bmp_send_out_credits(void)
  91.187 -{
  91.188 -    for(int i=0; i<BEEHIVE_CORES; i++) {
  91.189 -	assert(out_credits[i] >= 0 && out_credits[i] <= 64);
  91.190 -	if (out_credits[i] > 2 && tx_credits[i] >= 2) {
  91.191 -	    bmpack(i, out_credits[i]);
  91.192 -	    out_credits[i] = 0;
  91.193 -	    tx_credits[i] -= 2;
  91.194 -	}
  91.195 -    }
  91.196 -}
  91.197 -
  91.198 -void bmp_pump(void)
  91.199 -{
  91.200 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_PUMP, 1);
  91.201 -    while (bmp_process_one() != 0);
  91.202 -    bmp_send_out_credits();
  91.203 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_PUMP, 0);
  91.204 -}
  91.205 -
  91.206 -// This returns when the messenger is empty and either a message
  91.207 -// arrived at some point, or a timer interrupt is pending.
  91.208 -void bmp_pump_until_timer(struct corearea *corearea)
  91.209 -{
  91.210 -    int something;
  91.211 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_PUMP, 2);
  91.212 -    do {
  91.213 -	halt_unless_timer_pending();
  91.214 -	something = bmp_process_one();
  91.215 -	if (something) {
  91.216 -	    while (bmp_process_one() != 0);
  91.217 -	    bmp_send_out_credits();
  91.218 -	}
  91.219 -    } while(something == 0 && corearea->kernel_pending == 0);
  91.220 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_PUMP, 0);
  91.221 -}
  91.222 -
  91.223 -void bmp_send(int core, int assoc, int size, uint32_t *words)
  91.224 -{
  91.225 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_SEND, size);
  91.226 -
  91.227 -    assert(core > 1 && core < BEEHIVE_CORES);
  91.228 -    assert(assoc >= 0 && assoc < NUM_ASSOCS);
  91.229 -    assert(size > 0 && size <= MAX_PAYLOAD);
  91.230 -    assert(words != 0);
  91.231 -
  91.232 -    //debug(SUBSYS_BMP, "bmp_send: core=%u assoc=%u size=%u tx_credits=%u\n",
  91.233 -    //  core, assoc, size, tx_credits[core]);
  91.234 -
  91.235 -    if (tx_credits[core] >= size + 2 + 2)
  91.236 -	goto sendit;
  91.237 -
  91.238 -    for(;;) {
  91.239 -	int idle = bmp_process_one();
  91.240 -	if (tx_credits[core] >= size + 2 + 2)
  91.241 -	    goto sendit;
  91.242 -	if (idle)
  91.243 -	    bmp_send_out_credits();
  91.244 -    }
  91.245 -
  91.246 -  sendit:
  91.247 -    trace_event(TRACE_SUBSYS_KERNEL, TRACE_EVENT_BMP_SEND, 0);
  91.248 -    //debug(SUBSYS_BMP, "bmp_send: sendit\n");
  91.249 -    // Have enough to send it already
  91.250 -    bmptx(core, out_credits[core], assoc, size, words);
  91.251 -    tx_credits[core] -= size + 2;
  91.252 -    out_credits[core] = 0;
  91.253 -    
  91.254 -    bmp_pump();
  91.255 -}
  91.256 -
  91.257 -/* --------------------------------------------------------------------- */
  91.258 -/* And now for the capability code which manages the ability to send and
  91.259 - * receive on bmp associations
  91.260 - */
  91.261 -
  91.262 -errval_t bmp_deliver(struct capability *ep, size_t len,
  91.263 -                     uintptr_t *msg)
  91.264 -{
  91.265 -    assert(ep != NULL);
  91.266 -    assert(ep->type == ObjType_EndPoint);
  91.267 -    assert(msg != NULL);
  91.268 -    assert(len > 0 && len <= MAX_PAYLOAD);
  91.269 -
  91.270 -    return lmp_deliver_payload(ep, NULL, msg, len, false);
  91.271 -}
  91.272 -
  91.273 -
  91.274 -struct sysret bmp_table_set(struct capability *to, struct idc_recv_msg *msg)
  91.275 -{
  91.276 -    errval_t err;
  91.277 -    unsigned int associd;
  91.278 -    caddr_t cptr;
  91.279 -    struct cte *recv;
  91.280 -
  91.281 -    associd = idc_msg_decode_word_or_zero(msg);
  91.282 -    cptr    = (caddr_t)idc_msg_decode_word_or_zero(msg);
  91.283 -
  91.284 -    err = caps_lookup_slot(&dcb_current->cspace.cap, cptr,
  91.285 -                           CPTR_BITS, &recv, CAPRIGHTS_WRITE);
  91.286 -    if (err_is_fail(err)) {
  91.287 -        return SYSRET(err_push(err, SYS_ERR_BMP_LOOKUP));
  91.288 -    }
  91.289 -
  91.290 -    assert(to->type == ObjType_BMPTable);
  91.291 -    assert(recv != NULL);
  91.292 -
  91.293 -    // Return w/error if cap is not an endpoint
  91.294 -    if(recv->cap.type != ObjType_EndPoint) {
  91.295 -        return SYSRET(SYS_ERR_BMP_NOT_ENDPOINT);
  91.296 -    }
  91.297 -
  91.298 -    // Return w/error if no listener on endpoint
  91.299 -    if(recv->cap.u.endpoint.listener == NULL) {
  91.300 -        return SYSRET(SYS_ERR_BMP_NO_LISTENER);
  91.301 -    }
  91.302 -
  91.303 -    if(associd >= NUM_ASSOCS) {
  91.304 -	return SYSRET(SYS_ERR_BMP_INVALID);
  91.305 -    }
  91.306 -
  91.307 -    // check that we don't overwrite someone else's handler
  91.308 -    if (bmp_dispatch[associd].cap.type != ObjType_Null) {
  91.309 -	printf("kernel: installing new handler for BMP associd %u\n", associd);
  91.310 -	// XXX TODO: Then what?
  91.311 -    }
  91.312 -    err = caps_copy_to_cte(&bmp_dispatch[associd], recv, false, 0, 0);
  91.313 -    return SYSRET(err);
  91.314 -}
  91.315 -
  91.316 -struct sysret bmp_table_delete(struct capability *to, struct idc_recv_msg *msg)
  91.317 -{
  91.318 -    assert(to->type == ObjType_IRQTable);
  91.319 -
  91.320 -    unsigned int associd = idc_msg_decode_word_or_zero(msg);
  91.321 -
  91.322 -    if (associd >= NUM_ASSOCS) {
  91.323 -	return SYSRET(SYS_ERR_BMP_INVALID);
  91.324 -    }
  91.325 -
  91.326 -    bmp_dispatch[associd].cap.type = ObjType_Null;
  91.327 -    return SYSRET(SYS_ERR_OK);
  91.328 -}
  91.329 -
  91.330 -/* End */
    92.1 --- a/kernel/arch/beehive/ringtest.S	Fri Jan 20 14:32:03 2012 -0800
    92.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.3 @@ -1,494 +0,0 @@
    92.4 -/**
    92.5 - * \file
    92.6 - * \brief Bootstrap the kernel.
    92.7 - */
    92.8 -/*
    92.9 - * Copyright (c) 2009 ETH Zurich.
   92.10 - * All rights reserved.
   92.11 - *
   92.12 - * This file is distributed under the terms in the attached LICENSE file.
   92.13 - * If you do not find this file, copies can be found by writing to:
   92.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   92.15 - */
   92.16 -
   92.17 -#include <regconvention.h>
   92.18 -
   92.19 -	
   92.20 -// Exports:
   92.21 -	.globl	_message_send
   92.22 -	.globl	_message_send_with_header
   92.23 -	.globl	_message_recv
   92.24 -
   92.25 -// Constants:
   92.26 -	msgControl = 18
   92.27 -	lockControl = 22
   92.28 -
   92.29 -////////////////////////////////////////////////////////////////////////////
   92.30 -//                                                                        //
   92.31 -// void message_send(int dest, int type, msg_t *buf, int len)             //
   92.32 -//                                                                        //
   92.33 -// Send a message to core number "dest", using "len" words at "buf".      //
   92.34 -//                                                                        //
   92.35 -// Arguments are in r3-r6                                                 //
   92.36 -//                                                                        //
   92.37 -// The implementation has no uses of LINK, including long_* ops, so we    //
   92.38 -// don't need to preserve LINK on the stack.                              //
   92.39 -//                                                                        //
   92.40 -////////////////////////////////////////////////////////////////////////////
   92.41 -	//.type	_message_send, @function
   92.42 -_message_send:
   92.43 -					// ... first place data on wq
   92.44 -	ld	r7,r6			// r7 (loop variable) = msg length
   92.45 -x0:
   92.46 -	sub	r5,r5,4			// we will preincrement
   92.47 -x1:
   92.48 -	sub	r7,r7,1
   92.49 -	jm	x2			// bail if done copying
   92.50 -	aqr_add	r5,r5,4			// preincremnet and fetch word
   92.51 -	ld	wq,rq			// copy word onto wq
   92.52 -	j	x1
   92.53 -x2:					// ... now assemble the address
   92.54 -	lsl	r4,r4,6			// r4 = type << 6
   92.55 -	add_lsl	r4,r4,r6,4		// r4 = (r4 + len) << 4
   92.56 -	add_lsl r4,r4,r3,5		// r4 = (r4 + dest) << 5
   92.57 -	aqw_add	r4,r4,msgControl	// initiate the write
   92.58 -	j	link
   92.59 -	.size	_message_send,.-_message_send
   92.60 -
   92.61 -////////////////////////////////////////////////////////////////////////////
   92.62 -//                                                                        //
   92.63 -// void message_send_with_header(int dest, int type, msg_t *buf, int len, //
   92.64 -//                               unsigned hdr)                            //
   92.65 -//                                                                        //
   92.66 -// Varaint in which we prepend message with word "hdr".                   //
   92.67 -// Tweak a few things and then jump into _message_send.                   //
   92.68 -// Arguments are in r3-r7                                                 //
   92.69 -//                                                                        //
   92.70 -////////////////////////////////////////////////////////////////////////////
   92.71 -_message_send_with_header:
   92.72 -	ld	wq, r7			// place header word on wq
   92.73 -	ld	r7, r6			// loop variable additional words
   92.74 -	add	r6, r6, 1		// length includes hdr
   92.75 -	j	x0
   92.76 -	
   92.77 -////////////////////////////////////////////////////////////////////////////
   92.78 -//                                                                        //
   92.79 -// int message_recv(int *srce, int *type, msg_t * buf)                    //
   92.80 -//                                                                        //
   92.81 -// Receive a message into "buf" and return its word length, or 0.         //
   92.82 -//                                                                        //
   92.83 -// Arguments are in r3-r5, result goes in r1                              //
   92.84 -//                                                                        //
   92.85 -////////////////////////////////////////////////////////////////////////////
   92.86 -	.type	_message_recv, @function
   92.87 -_message_recv:
   92.88 -	aqw_sub	sp,sp,4
   92.89 -	ld	wq,link
   92.90 -	aqr_ld	vb,msgControl		// read the device
   92.91 -	ld	r1,rq			// r1 = status
   92.92 -	jz	x4			// if status == 0 then return 0
   92.93 -	ld	r6,r1			// r6 = status
   92.94 -	and	r1,r6,63		// r1 = msg length
   92.95 -	aqw_ld	vb,r4			// &type
   92.96 -	lsr	r6,r6,6
   92.97 -	and	wq,r6,15
   92.98 -	aqw_ld	vb,r3			// &srce
   92.99 -	lsr	r6,r6,4
  92.100 -	and	wq,r6,15
  92.101 -	ld	r7,r1			// r7 (loop variable) = msg length
  92.102 -x3:
  92.103 -	sub	r7,r7,1
  92.104 -	jm	x4			// exit loop if done copying
  92.105 -	aqw_ld	vb,r5
  92.106 -	ld	wq,rq			// copy word onto wq
  92.107 -	add	r5,r5,4			// next word address
  92.108 -	j	x3
  92.109 -x4:
  92.110 -	aqr_add	sp,sp,0
  92.111 -	add	sp,sp,4
  92.112 -	j	rq
  92.113 -	.size	_message_recv,.-_message_recv
  92.114 -
  92.115 -
  92.116 -	.globl _lockunit_read
  92.117 -_lockunit_read:
  92.118 -	lsl	r3, r3, 5
  92.119 -	aqr_add	r3, r3, lockControl
  92.120 -	ld	r1, rq
  92.121 -	j	link
  92.122 -
  92.123 -	.globl _lockunit_write
  92.124 -_lockunit_write:
  92.125 -	lsl	r3, r3, 5
  92.126 -	aqw_add	r3, r3, lockControl
  92.127 -	j	link
  92.128 -
  92.129 -
  92.130 -// ------------------------------------------------------------
  92.131 -#if 0
  92.132 -	.code
  92.133 -	/* Read the cycle counter register several times */
  92.134 -	.globl ringt0
  92.135 -ringt0:	
  92.136 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.137 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.138 -	ld	r0, r0
  92.139 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.140 -	ld	r0, r0
  92.141 -	ld	r0, r0
  92.142 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.143 -	ld	r0, r0
  92.144 -	ld	r0, r0
  92.145 -	ld	r0, r0
  92.146 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.147 -	ld	r0, r0
  92.148 -	ld	r0, r0
  92.149 -	ld	r0, r0
  92.150 -	ld	r0, r0
  92.151 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.152 -	ld	r0, r0
  92.153 -	ld	r0, r0
  92.154 -	ld	r0, r0
  92.155 -	ld	r0, r0
  92.156 -	ld	r0, r0
  92.157 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.158 -
  92.159 -	ld	r1, rq
  92.160 -	sub	r2, rq, r1
  92.161 -	sub	r3, rq, r1
  92.162 -	sub	r4, rq, r1
  92.163 -	sub	r5, rq, r1
  92.164 -	sub	r6, rq, r1
  92.165 -	sub	r7, rq, r1
  92.166 -		
  92.167 -	j	link
  92.168 -
  92.169 -/* ================================================== */
  92.170 -
  92.171 -	.globl _ringt0
  92.172 -_ringt0:
  92.173 -	ld	t2, ringt0
  92.174 -	j	doperf
  92.175 -
  92.176 -	.globl _ringt1
  92.177 -_ringt1:
  92.178 -	ld	t2, ringt1
  92.179 -	j	doperf
  92.180 -
  92.181 -	.globl _ringt2
  92.182 -_ringt2:
  92.183 -	ld	t2, ringt2
  92.184 -	j	doperf
  92.185 -
  92.186 -	.globl _ringt3
  92.187 -_ringt3:
  92.188 -	ld	t2, ringt3
  92.189 -	j	doperf
  92.190 -
  92.191 -	.globl _ringt4
  92.192 -_ringt4:
  92.193 -	ld	t2, ringt4
  92.194 -	j	doperf
  92.195 -
  92.196 -	
  92.197 -	/* doperf: t2 is function to call, a1 is ptr, a2 is count */
  92.198 -doperf:
  92.199 -	aqw_sub	sp, sp, 4
  92.200 -	ld	wq, link
  92.201 -	aqw_sub	sp, sp, 4
  92.202 -	ld	wq, s1
  92.203 -	aqw_sub	sp, sp, 4
  92.204 -	ld	wq, s2
  92.205 -	aqw_sub	sp, sp, 4
  92.206 -	ld	wq, s3
  92.207 -
  92.208 -	ld	s3, t2
  92.209 -	sub	s1, a1, 4
  92.210 -	ld	s2, a2
  92.211 -	jz	dp0B
  92.212 -dp0A:	
  92.213 -	aqw_long_ld vb, 0x8001fc03 ROL 2 /* flush whole cache */
  92.214 -	add_lsl	r1, s2, 0x40, 8
  92.215 -dp0A1:	sub	r1, r1, 1
  92.216 -	jnz	dp0A1
  92.217 -	call	s3
  92.218 -	aqw_add	s1, s1, 4
  92.219 -	ld	wq, r2
  92.220 -	aqw_add	s1, s1, 4
  92.221 -	sub	wq, r3, r2
  92.222 -	aqw_add	s1, s1, 4
  92.223 -	sub	wq, r4, r3
  92.224 -	aqw_add	s1, s1, 4
  92.225 -	sub	wq, r5, r4
  92.226 -	aqw_add	s1, s1, 4
  92.227 -	sub	wq, r6, r5
  92.228 -	aqw_add	s1, s1, 4
  92.229 -	sub	wq, r7, r6
  92.230 -	sub	s2, s2, 1
  92.231 -	jnz	dp0A
  92.232 -dp0B:
  92.233 -	aqr_add	sp, sp, 0
  92.234 -	aqr_add	sp, sp, 4
  92.235 -	aqr_add sp, sp, 4
  92.236 -	aqr_add sp, sp, 4
  92.237 -	add	sp, sp, 4
  92.238 -	ld	s3, rq
  92.239 -	ld	s2, rq
  92.240 -	ld	s1, rq
  92.241 -	simctrl	3
  92.242 -	j	rq
  92.243 -	
  92.244 -/* ================================================== */
  92.245 -	
  92.246 -	.globl ringt1
  92.247 -ringt1:
  92.248 -	ld	t3, link
  92.249 -
  92.250 -	// t1 gets message send address, type=1 length=4 dest=2, io=4
  92.251 -	long_ld	t1, (0x80000000 + (1 LSL 13) + (4 LSL 7) + (2 LSL 3) + 4) ROL 2
  92.252 -
  92.253 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.254 -	ld	wq, t1
  92.255 -	ld	wq, t1
  92.256 -	ld	wq, t1
  92.257 -	ld	wq, t1
  92.258 -	aqw_ld	vb, t1
  92.259 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.260 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.261 -
  92.262 -	ld	r1, rq
  92.263 -	sub	r2, rq, r1
  92.264 -	sub	r3, rq, r1
  92.265 -
  92.266 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.267 -rt1p1:	sub	r4, rq, r1
  92.268 -	aqr_ld	vb, t1
  92.269 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.270 -	ld	t2, rq
  92.271 -	lsl	vb, t2, 18
  92.272 -	jz	rt1p1
  92.273 -	ld	vb, rq		/* discard one word */
  92.274 -	ld	vb, rq		/* discard one word */
  92.275 -	ld	vb, rq		/* discard one word */
  92.276 -	ld	vb, rq		/* discard one word */
  92.277 -	sub	r5, rq, r1
  92.278 -	ld	r6, r5
  92.279 -	ld	r7, r5
  92.280 -	j	t3
  92.281 -
  92.282 -/* ================================================== */
  92.283 -
  92.284 -	.globl ringt2
  92.285 -ringt2:
  92.286 -	ld	t3, link
  92.287 -
  92.288 -	// t1 gets message send address, type=1 length=3 dest=1, io=4
  92.289 -	long_ld	t1, (0x80000000 + (1 LSL 13) + (3 LSL 7) + (1 LSL 3) + 4) ROL 2
  92.290 -
  92.291 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.292 -	ld	wq, t1
  92.293 -	ld	wq, t1
  92.294 -	ld	wq, t1
  92.295 -	aqw_ld	vb, t1
  92.296 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.297 -	ld	wq, t1
  92.298 -	ld	wq, t1
  92.299 -	ld	wq, t1
  92.300 -	aqw_ld	vb, t1
  92.301 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.302 -
  92.303 -	ld	r1, rq
  92.304 -	sub	r2, rq, r1
  92.305 -	sub	r3, rq, r1
  92.306 -
  92.307 -	ld	r0, r0
  92.308 -	ld	r0, r0
  92.309 -	ld	r0, r0
  92.310 -	
  92.311 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.312 -rt2p1:	sub	r4, rq, r1
  92.313 -	aqr_ld	vb, t1
  92.314 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.315 -	ld	t2, rq
  92.316 -	lsl	vb, t2, 18
  92.317 -	jz	rt2p1
  92.318 -	ld	vb, rq		/* discard one word */
  92.319 -	ld	vb, rq		/* discard one word */
  92.320 -	ld	vb, rq		/* discard one word */
  92.321 -	sub	r5, rq, r1
  92.322 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.323 -rt2p2:	sub	r6, rq, r1
  92.324 -	aqr_ld	vb, t1
  92.325 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.326 -	ld	t2, rq
  92.327 -	lsl	vb, t2, 18
  92.328 -	jz	rt2p2
  92.329 -	ld	vb, rq		/* discard one word */
  92.330 -	ld	vb, rq		/* discard one word */
  92.331 -	ld	vb, rq		/* discard one word */
  92.332 -	sub	r7, rq, r1
  92.333 -
  92.334 -	j	t3
  92.335 -
  92.336 -/* ================================================== */
  92.337 -
  92.338 -	.globl ringt3
  92.339 -ringt3:
  92.340 -	ld	t3, link
  92.341 -
  92.342 -	// t1 gets message send address, type=1 length=4 dest=1, io=4
  92.343 -	long_ld	t1, (0x80000000 + (1 LSL 13) + (4 LSL 7) + (1 LSL 3) + 4) ROL 2
  92.344 -
  92.345 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.346 -	ld	wq, t1
  92.347 -	ld	wq, t1
  92.348 -	ld	wq, t1
  92.349 -	ld	wq, t1
  92.350 -	aqw_ld	vb, t1
  92.351 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.352 -	ld	wq, t1
  92.353 -	ld	wq, t1
  92.354 -	ld	wq, t1
  92.355 -	ld	wq, t1
  92.356 -	aqw_ld	vb, t1
  92.357 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.358 -
  92.359 -	ld	r1, rq
  92.360 -	sub	r2, rq, r1
  92.361 -	sub	r3, rq, r1
  92.362 -
  92.363 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.364 -rt3p1:	sub	r4, rq, r1
  92.365 -	aqr_ld	vb, t1
  92.366 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.367 -	ld	t2, rq
  92.368 -	lsl	vb, t2, 18
  92.369 -	jz	rt3p1
  92.370 -	ld	vb, rq		/* discard one word */
  92.371 -	ld	vb, rq		/* discard one word */
  92.372 -	ld	vb, rq		/* discard one word */
  92.373 -	ld	vb, rq		/* discard one word */
  92.374 -	sub	r5, rq, r1
  92.375 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.376 -rt3p2:	sub	r6, rq, r1
  92.377 -	aqr_ld	vb, t1
  92.378 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.379 -	ld	t2, rq
  92.380 -	lsl	vb, t2, 18
  92.381 -	jz	rt3p2
  92.382 -	ld	vb, rq		/* discard one word */
  92.383 -	ld	vb, rq		/* discard one word */
  92.384 -	ld	vb, rq		/* discard one word */
  92.385 -	ld	vb, rq		/* discard one word */
  92.386 -	sub	r7, rq, r1
  92.387 -
  92.388 -	j	t3
  92.389 -
  92.390 -/* ================================================== */
  92.391 -
  92.392 -	.globl ringt4
  92.393 -xringt4:
  92.394 -	ld	t3, link
  92.395 -
  92.396 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.397 -	aqr_ld	vb, (0x80000010 + 5) ROL 2
  92.398 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.399 -	//aqr_ld	vb, (0x80000010 + 5) ROL 2
  92.400 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.401 -
  92.402 -	ld	r1, rq
  92.403 -	ld	t1, rq
  92.404 -	sub	r2, rq, r1
  92.405 -	//ld	t2, rq
  92.406 -	sub	r3, rq, r1
  92.407 -
  92.408 -	add	r4, t1, r3
  92.409 -	add	r5, t2, r4
  92.410 -	j	t3
  92.411 -	
  92.412 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.413 -	aqw_ld	vb, (0x80000000 + 5) ROL 2
  92.414 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.415 -	aqw_ld	vb, (0x80000000 + 5) ROL 2
  92.416 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.417 -	
  92.418 -	sub	r4, rq, r1
  92.419 -	sub	r5, rq, r1
  92.420 -	sub	r6, rq, r1
  92.421 -
  92.422 -	add	r7, r6, t1
  92.423 -	add	r7, r7, t2
  92.424 -	j	t3
  92.425 -
  92.426 -yringt4:
  92.427 -	ld	t3, link
  92.428 -	aqw_ld	vb, (0x80000010 + 5) ROL 2
  92.429 -	j	foo1
  92.430 -foo3:	
  92.431 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.432 -	ld	r1, rq
  92.433 -	aqr_ld	vb, (0x80000010 + 5) ROL 2
  92.434 -	ld	t1, rq
  92.435 -	j	foo1a
  92.436 -foo1:	j	foo2
  92.437 -foo1a:	
  92.438 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.439 -	sub	r2, rq, r1
  92.440 -	j	foo2a
  92.441 -foo2:	j	foo3
  92.442 -foo2a:	
  92.443 -	add	r3, r2, t1
  92.444 -	j	t3
  92.445 -
  92.446 -ringt4:
  92.447 -	ld	t3, link
  92.448 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.449 -	aqw_ld	vb, (0x80000010 + 5) ROL 2
  92.450 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.451 -	aqr_ld	vb, (0x80000010 + 5) ROL 2
  92.452 -	aqr_ld	vb, (0x80000000 + (1 LSL 3)) ROL 2
  92.453 -	j	bar1
  92.454 -	ld	r0, r0
  92.455 -	ld	r0, r0
  92.456 -	ld	r0, r0
  92.457 -	ld	r0, r0
  92.458 -	ld	r0, r0
  92.459 -	ld	r0, r0
  92.460 -	ld	r0, r0
  92.461 -	ld	r0, r0
  92.462 -bar1:	j	bar2
  92.463 -	ld	r0, r0
  92.464 -	ld	r0, r0
  92.465 -	ld	r0, r0
  92.466 -	ld	r0, r0
  92.467 -	ld	r0, r0
  92.468 -	ld	r0, r0
  92.469 -	ld	r0, r0
  92.470 -	ld	r0, r0
  92.471 -bar2:	j	bar3
  92.472 -	ld	r0, r0
  92.473 -	ld	r0, r0
  92.474 -	ld	r0, r0
  92.475 -	ld	r0, r0
  92.476 -	ld	r0, r0
  92.477 -	ld	r0, r0
  92.478 -	ld	r0, r0
  92.479 -	ld	r0, r0
  92.480 -bar3:	j	bar4
  92.481 -	ld	r0, r0
  92.482 -	ld	r0, r0
  92.483 -	ld	r0, r0
  92.484 -	ld	r0, r0
  92.485 -	ld	r0, r0
  92.486 -	ld	r0, r0
  92.487 -	ld	r0, r0
  92.488 -	ld	r0, r0
  92.489 -bar4:
  92.490 -	ld	r1, rq
  92.491 -	sub	r2, rq, r1
  92.492 -	ld	t1, rq
  92.493 -	sub	r3, rq, r1
  92.494 -
  92.495 -	add	r4, t1, r3
  92.496 -	j	t3
  92.497 -#endif
    93.1 --- a/kernel/arch/beehive/serial.c	Fri Jan 20 14:32:03 2012 -0800
    93.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.3 @@ -1,54 +0,0 @@
    93.4 -/**
    93.5 - * \file
    93.6 - * \brief The world's simplest serial driver.
    93.7 - *
    93.8 - */
    93.9 -
   93.10 -/*
   93.11 - * Copyright (c) 2009, ETH Zurich.
   93.12 - * All rights reserved.
   93.13 - *
   93.14 - * This file is distributed under the terms in the attached LICENSE file.
   93.15 - * If you do not find this file, copies can be found by writing to:
   93.16 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   93.17 - */
   93.18 -
   93.19 -#include <serial.h>
   93.20 -
   93.21 -/** \brief Prints a single character to the default serial port. */
   93.22 -void serial_console_putchar(char c)
   93.23 -{
   93.24 -    // The RS232 is in IO position 0, register 0 XXX Should have a
   93.25 -    // MACRO in an arch header file to build these type of constants
   93.26 -    volatile int *const rs232 = (int *)0x02;
   93.27 -
   93.28 -    int reg;
   93.29 -    while (((reg = *rs232) & 0x200) == 0);
   93.30 -    *rs232 = (int)0x200 | c;
   93.31 -}
   93.32 -
   93.33 -
   93.34 -/** \brief Reads a single character from the default serial port.
   93.35 - * This function spins waiting for a character to arrive.
   93.36 - */
   93.37 -char serial_console_getchar(void)
   93.38 -{
   93.39 -    // The RS232 is in IO position 0, register 0 XXX Should have a
   93.40 -    // MACRO in an arch header file to build these type of constants
   93.41 -    volatile int *const rs232 = (int *)0x02;
   93.42 -
   93.43 -    int reg;
   93.44 -    while (((reg = *rs232) & 0x100) == 0);
   93.45 -    *rs232 = 0x100;
   93.46 -    return (char)(reg & 0xff);
   93.47 -}
   93.48 -
   93.49 -void serial_debug_putchar(char c)
   93.50 -{
   93.51 -    serial_console_putchar(c);
   93.52 -}
   93.53 -
   93.54 -char serial_debug_getchar(void)
   93.55 -{
   93.56 -    return serial_console_getchar();
   93.57 -}
    94.1 --- a/kernel/arch/beehive/slave.S	Fri Jan 20 14:32:03 2012 -0800
    94.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.3 @@ -1,379 +0,0 @@
    94.4 -/*
    94.5 - * Copyright (c) 2010, ETH Zurich.
    94.6 - * All rights reserved.
    94.7 - *
    94.8 - * This file is distributed under the terms in the attached LICENSE file.
    94.9 - * If you do not find this file, copies can be found by writing to:
   94.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   94.11 - */
   94.12 -
   94.13 -#include <simctrl.h>
   94.14 -#include <beej7.h>
   94.15 -#include <asmoffsets.h>
   94.16 -#include <regconvention.h>
   94.17 -#include <stopcode.h>
   94.18 -
   94.19 -.code
   94.20 -// ------------------------------------------------------------
   94.21 -// The slave stop/start code.
   94.22 -//
   94.23 -// When the system is reset, the program starts at location 0.
   94.24 -// ------------------------------------------------------------
   94.25 -
   94.26 -//.globl main
   94.27 -.globl _slaveStart
   94.28 -.globl _slaveAfter
   94.29 -
   94.30 -
   94.31 -invalByteAddress = 0x7ffff000 //used when building the table
   94.32 -JPLUS8 = 0xf800220c
   94.33 -JLINK = 0xf000030c
   94.34 -
   94.35 -// inv=0 cnt=127 line=0 dev=3
   94.36 -FLUSHALL = (0 LSL 19) + (127 LSL 12) + (0 LSL 5) + (3 LSL 2) + 2
   94.37 -
   94.38 -// inv=0 cnt=0 line=? dev=3
   94.39 -FLUSHONE = (0 LSL 19) + (0 LSL 12) + (3 LSL 2) + 2
   94.40 -
   94.41 -// inv=1 cnt=127 line=0 dev=3
   94.42 -INVALALL = (1 LSL 19) + (127 LSL 12) + (0 LSL 5) + (3 LSL 2) + 2
   94.43 -
   94.44 -// inv=1 cnt=0 line=? dev=3
   94.45 -INVALONE = (1 LSL 19) + (0 LSL 12) + (3 LSL 2) + 2
   94.46 -
   94.47 -// inv=1<<19
   94.48 -INVALSHIFT = 19
   94.49 -
   94.50 -// dev = 3
   94.51 -CACHEACCESS = (3 LSL 2) + 2
   94.52 -
   94.53 -// line mask
   94.54 -LINEMASK = (127 LSL 5)
   94.55 -
   94.56 -// type=1 len=1 dst=1 dev=4
   94.57 -STOPACKMSG = (1 LSL 15) + (1 LSL 9) + (1 LSL 5) + (4 LSL 2) + 2
   94.58 -
   94.59 -
   94.60 -
   94.61 -main:
   94.62 -_slaveStart:
   94.63 -/* The instruction at address 0 must be a nop because it might or
   94.64 - * might not be nullified depending on the pipeline state at the time
   94.65 - * the debug unit triggers.
   94.66 - */
   94.67 -	ld	zero, 0
   94.68 -
   94.69 -/* We want to save the minimum registers to check if we are running
   94.70 - * or took a wild branch to zero.  If the latter then we want link
   94.71 - * to be preserved since it is useful to help us find where we came
   94.72 - * from.
   94.73 - */
   94.74 -	ld	wq, link
   94.75 -	j7	BEE_J7_TEST_RUNNING
   94.76 -	ld	void, link
   94.77 -	jnz	wildjump
   94.78 -
   94.79 -/* If this is power-up condition savedPc will be 0.  We dont need to
   94.80 - * save lots of stuff but might want to do other initialisation.
   94.81 - */
   94.82 -	j7	BEE_J7_SAVEDPC
   94.83 -	ld	void, link
   94.84 -	jz	powerup
   94.85 -
   94.86 -/* Next we want to check for stop interrupts.  Timer interrupts might
   94.87 - * also be pending but that is true after a restart anyway so we
   94.88 - * punt timer+stop to dealing with timer after a restart.  A breakpoint
   94.89 - * might also happen simultaneously but the savedPC will be pointing
   94.90 - * at the breakpoint so we will just break again after the restart.
   94.91 - */
   94.92 -	ld	wq, t1
   94.93 -	ld	wq, t2
   94.94 -	ld	wq, t3
   94.95 -	add	wq, link, 1		// savedPc. Instruction already executed
   94.96 -	j7	BEE_J7_COREAREA
   94.97 -	aqw_add	void, link, 30 * 4	// original link (==savedLink)
   94.98 -	aqw_add	void, link, 24 * 4	// t1
   94.99 -	aqw_add	void, link, 25 * 4	// t2
  94.100 -	aqw_add	void, link, 26 * 4	// t3
  94.101 -	aqw_add	t2, link, 31 * 4	// savedPc, also set t2 for rq2wq
  94.102 -
  94.103 -	ld	t3, zero
  94.104 -	j	rq2wq
  94.105 -
  94.106 -	/* TODO: XXX: nasty code can arrange more than 64 words in RQ! */
  94.107 -rq2wql:	ld	wq, rq
  94.108 -	aqw_add	t2, t2, 4
  94.109 -	add	t3, t3, 1
  94.110 -rq2wq:	j7	BEE_J7_TEST_RQ_EMPTY
  94.111 -	ld	void, link
  94.112 -	jnz	rq2wql
  94.113 -
  94.114 -	j7	BEE_J7_COREAREA
  94.115 -	ld	wq, t3
  94.116 -	aqw_ld	void, link		// overwrite count
  94.117 -
  94.118 -	/* We would like to invalidate one line if a particular
  94.119 -	 * address is cached there, but we cant do that - the
  94.120 -	 * invalidate invalidates the specified line always so we must
  94.121 -	 * always flush first (why does invalidate-only even exist?) */
  94.122 -	
  94.123 -	add	t1, link, OFFSETOF_COREAREA_MASTER + CACHEACCESS
  94.124 -	aqw_and	t2, t1, LINEMASK + CACHEACCESS // flush that line
  94.125 -	lsl	t3, 1, INVALSHIFT
  94.126 -	aqw_add	void, t2, t3		// invalidate that line
  94.127 -	
  94.128 -	aqr_add	void, link, OFFSETOF_COREAREA_MASTER_STOPS
  94.129 -	aqr_add	void, link, OFFSETOF_COREAREA_SLAVE_STOPS
  94.130 -	ld	t1, rq
  94.131 -	sub	void, rq, t1
  94.132 -	jnz	stop
  94.133 -
  94.134 -/* Not a stop, is it a timer interrupt? */
  94.135 -
  94.136 -	aqr_add	void, link, OFFSETOF_COREAREA_MASTER_TICKS
  94.137 -	aqr_add	void, link, OFFSETOF_COREAREA_SLAVE_TICKS
  94.138 -	ld	t1, rq
  94.139 -	sub	void, rq, t1
  94.140 -	jz	break
  94.141 -
  94.142 -/* Mark to ourselves that we have noticed this one */
  94.143 -	aqw_add	void, link, OFFSETOF_COREAREA_SLAVE_TICKS
  94.144 -	ld	wq, t1
  94.145 -
  94.146 -/* It is a timer interrupt.  We cannot make ourselves running, and the
  94.147 - * master cant send us a running until it knows we have stopped
  94.148 - * (otherwise we cant tell the difference from a wild branch to
  94.149 - * zero).  So we need to get off a timerAck to the master as soon
  94.150 - * as possible so we dont stall too long waiting to be made
  94.151 - * running. */
  94.152 -
  94.153 -	ld	wq, STOPCODE_TIMER
  94.154 -	aqw_long_ld void, STOPACKMSG
  94.155 -
  94.156 -/* If we are running in the kernel we want to mark for a deferred
  94.157 - * interrupt otherwise we want to take the interrupt now. We compare
  94.158 - * the savedPc against kernel boundaries.
  94.159 - */
  94.160 -	j7	BEE_J7_SAVEDPC
  94.161 -	ld	t2, link
  94.162 -	j7	BEE_J7_COREAREA
  94.163 -	aqr_add	void, link, OFFSETOF_COREAREA_KERNEL_BEGINS
  94.164 -	aqr_add	void, link, OFFSETOF_COREAREA_KERNEL_ENDS
  94.165 -	//simctrl	BEE_SIMCTRL_BREAK_SIM
  94.166 -	// Beehive is 6502 carry (not 8080 carry) which I find
  94.167 -	// hard to get my head round.  A subtraction carries
  94.168 -	// if the addition of the negation carries, which is
  94.169 -	// if the subtraction has no carry.
  94.170 -	ld	t3, rq
  94.171 -	sub	void, rq, t2	// (end - t2 > 0 => carry) => (end > t2 => carry)
  94.172 -	jnc	take		// hence nc if t2 > end
  94.173 -	sub	void, t3, t2	// (start - t2 > 0 => carry) => (start > t2 => carry)
  94.174 -	jnc	defer		// hence nc if t2 < start
  94.175 -
  94.176 -/* Take the interrupt now (as soon as we are running). */
  94.177 -take:	aqr_add	void, link, OFFSETOF_COREAREA_KERNEL_TICKER
  94.178 -	simctrl	BEE_SIMCTRL_HALT
  94.179 -	j7	BEE_J7_TEST_RUNNING
  94.180 -	ld	void, link
  94.181 -	jz	. - 2
  94.182 -	j	rq
  94.183 -
  94.184 -defer:	aqr_add	void, link, OFFSETOF_COREAREA_KERNEL_PENDING
  94.185 -	aqw_add	void, link, OFFSETOF_COREAREA_KERNEL_PENDING
  94.186 -	add	wq, rq, 1
  94.187 -
  94.188 -/* Now load up the saved registers and rq and back to where we came
  94.189 - * from (assumes link is saved area) */
  94.190 -iret:	aqr_add	void, link, 0		// read count
  94.191 -	aqr_add	void, link, 24 * 4	// t1
  94.192 -	aqr_add	void, link, 25 * 4	// t2
  94.193 -	aqr_add	void, link, 26 * 4	// t3
  94.194 -
  94.195 -	add	t1, rq, 2		// +2 for link and pc adjacent
  94.196 -	add	link, link, 30 * 4 - 4	// &link -4
  94.197 -iretrq:	aqr_add	link, link, 4
  94.198 -	sub	t1, t1, 1
  94.199 -	jnz	iretrq
  94.200 -
  94.201 -	ld	t1, rq
  94.202 -	ld	t2, rq
  94.203 -	ld	t3, rq
  94.204 -
  94.205 -	simctrl	BEE_SIMCTRL_HALT
  94.206 -	j7	BEE_J7_TEST_RUNNING
  94.207 -	ld	void, link
  94.208 -	jz	. - 2
  94.209 -
  94.210 -	ld	link, rq
  94.211 -	j	rq
  94.212 -
  94.213 -wildjump:
  94.214 -	j7	BEE_J7_COREAREA
  94.215 -	aqw_add	void, link, 30 * 4	// link is in wq
  94.216 -	aqr_add	void, link, 30 * 4	// read it back
  94.217 -	ld	link, rq
  94.218 -wjloop:	j7	BEE_J7_BREAKPOINT
  94.219 -	j	wjloop
  94.220 -	
  94.221 -/* At power-up we must create the icache flush code table because we cant rely
  94.222 - * on the master having code to do it, or it finishing it before we
  94.223 - * need to use it.  Also we clear our own core area */
  94.224 -powerup:
  94.225 -	j7	BEE_J7_COREAREA
  94.226 -	aqw_add	void, link, 30 * 4
  94.227 -	ld	t2, 128
  94.228 -	sub	link, link, 4
  94.229 -zarea:	aqw_add	link, link, 4
  94.230 -	ld	wq, 0
  94.231 -	sub	t2, t2, 1
  94.232 -	jnz	zarea
  94.233 -
  94.234 -	/* build the table of instructions at invalIcache.  127 of "j . + 8"
  94.235 -	 * followed by a j link */
  94.236 -	
  94.237 -	long_ld	t1, invalByteAddress - 32
  94.238 -	ld	t2, 127
  94.239 -itable:	aqw_add	t1, t1, 32
  94.240 -	long_ld	wq, JPLUS8
  94.241 -	sub	t2, t2, 1
  94.242 -	jnz	itable
  94.243 -	aqw_add	t1, t1, 32
  94.244 -	long_ld	wq, JLINK
  94.245 -
  94.246 -	/* Note that "stopped" flushes the cache before executing the
  94.247 -	 * icache flush */
  94.248 -
  94.249 -	ld	t1, STOPCODE_POWERUP
  94.250 -	j	stopped	
  94.251 -
  94.252 -/* We were sent a stop, so acknowledge that and come to a full stop */
  94.253 -		
  94.254 -stop:
  94.255 -	ld	wq, t1
  94.256 -	aqw_add	void, link, OFFSETOF_COREAREA_SLAVE_STOPS
  94.257 -
  94.258 -	ld	t1, STOPCODE_STOP
  94.259 -	j	fullstop
  94.260 -
  94.261 -/* A breakpoint was executed.  Tell master and come to a full stop */
  94.262 -
  94.263 -break:
  94.264 -	ld	t1, STOPCODE_BREAK
  94.265 -
  94.266 -/* This code saves all the registers out and flushes the whole
  94.267 - * cache so the master can examine everything, and then informs the
  94.268 - * master. link=corearea already t1=argument */
  94.269 -fullstop:
  94.270 -	ld	wq, $1
  94.271 -	ld	wq, $2
  94.272 -	ld	wq, $3
  94.273 -	ld	wq, $4
  94.274 -	ld	wq, $5
  94.275 -	ld	wq, $6
  94.276 -	ld	wq, $7
  94.277 -	ld	wq, $8
  94.278 -	ld	wq, $9
  94.279 -	ld	wq, $10
  94.280 -	ld	wq, $11
  94.281 -	ld	wq, $12
  94.282 -	ld	wq, $13
  94.283 -	ld	wq, $14
  94.284 -	ld	wq, $15
  94.285 -	ld	wq, $16
  94.286 -	ld	wq, $17
  94.287 -	ld	wq, $18
  94.288 -	ld	wq, $19
  94.289 -	ld	wq, $20
  94.290 -	ld	wq, $21
  94.291 -	ld	wq, $22
  94.292 -	ld	wq, $23
  94.293 -	// we already did t1=24 t2=25 and t3=26
  94.294 -	ld	wq, $27
  94.295 -	ld	wq, $28
  94.296 -	add	wq, zero, $29    //r29 (via a port) is rq. Use the b port
  94.297 -
  94.298 -	ld	t2, 23
  94.299 -save23:	aqw_add	link, link, 4
  94.300 -	sub	t2, t2, 1
  94.301 -	jnz	save23
  94.302 -	aqw_add	link, link, 4 * 4	 // skip t1, t2, t3
  94.303 -	aqw_add	link, link, 4
  94.304 -	aqw_add	link, link, 4
  94.305 -
  94.306 -stopped:
  94.307 -	aqw_long_ld void,FLUSHALL
  94.308 -	aqw_long_ld void,INVALALL
  94.309 -
  94.310 -	/* Report that we are stopped */
  94.311 -	ld	wq, t1
  94.312 -	aqw_long_ld void, STOPACKMSG
  94.313 -
  94.314 -	/* We have to invalidate the icache at some point.  We might
  94.315 -	 * as well do it while the master is thinking about us */
  94.316 -
  94.317 -	long_call invalByteAddress ROR 2
  94.318 -
  94.319 -	/* Wait to be restarted */
  94.320 -	simctrl	BEE_SIMCTRL_HALT
  94.321 -	j7	BEE_J7_TEST_RUNNING
  94.322 -	ld	void, link
  94.323 -	jz	. - 3
  94.324 -
  94.325 -fullstart:
  94.326 -	j7	BEE_J7_COREAREA
  94.327 -	ld	$28, 31
  94.328 -	aqr_ld	link, link
  94.329 -fs1:	aqr_add	link, link, 4
  94.330 -	sub	$28, $28, 1
  94.331 -	jnz	fs1
  94.332 -
  94.333 -	ld	$28, rq		//put RQ count into r28
  94.334 -	ld	$1, rq		//load registers 1-27, r29
  94.335 -	ld	$2, rq
  94.336 -	ld	$3, rq
  94.337 -	ld	$4, rq
  94.338 -	ld	$5, rq
  94.339 -	ld	$6, rq
  94.340 -	ld	$7, rq
  94.341 -	ld	$8, rq
  94.342 -	ld	$9, rq
  94.343 -	ld	$10, rq
  94.344 -	ld	$11, rq
  94.345 -	ld	$12, rq
  94.346 -	ld	$13, rq
  94.347 -	ld	$14, rq
  94.348 -	ld	$15, rq
  94.349 -	ld	$16, rq
  94.350 -	ld	$17, rq
  94.351 -	ld	$18, rq
  94.352 -	ld	$19, rq
  94.353 -	ld	$20, rq
  94.354 -	ld	$21, rq
  94.355 -	ld	$22, rq
  94.356 -	ld	$23, rq
  94.357 -	ld	$24, rq
  94.358 -	ld	$25, rq
  94.359 -	ld	$26, rq
  94.360 -	ld	$27, rq
  94.361 -
  94.362 -	/* rq now has r28, r29, savedLink, savedPC
  94.363 -	 * $28 contains the number of RQ entries to restore.
  94.364 -	 * We use it because r29 isn't a good place to stand
  94.365 -	 * continue reading until $28 < 0.
  94.366 -	 */
  94.367 -
  94.368 -loadRQ:
  94.369 -	sub	$28, $28, 1	//all RQ entries read?
  94.370 -	jm	rqDone
  94.371 -	aqr_add	link, link, 4
  94.372 -	j	loadRQ
  94.373 -rqDone:
  94.374 -	/* rq now contains r28, r29, savedLink, savedPC, and the RQ entries. */
  94.375 -
  94.376 -	ld	$28, rq		//load r28
  94.377 -	ld	$29, rq		//load r29
  94.378 -	ld	link, rq	//load link
  94.379 -	simctrl	BEE_SIMCTRL_TRACEOFF
  94.380 -	j	rq		//transfer to user code.
  94.381 -
  94.382 -_slaveAfter:
    95.1 --- a/kernel/arch/beehive/slavecode.mem	Fri Jan 20 14:32:03 2012 -0800
    95.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.3 @@ -1,123 +0,0 @@
    95.4 -@0000
    95.5 -0000000c5
    95.6 -00fc00305
    95.7 -017c00305
    95.8 -01fc00305
    95.9 -027c00305
   95.10 -02fc00305
   95.11 -037c00305
   95.12 -03fc00305
   95.13 -047c00305
   95.14 -04fc00305
   95.15 -057c00305
   95.16 -05fc00305
   95.17 -067c00305
   95.18 -06fc00305
   95.19 -077c00305
   95.20 -07fc00305
   95.21 -087c00305
   95.22 -08fc00305
   95.23 -097c00305
   95.24 -09fc00305
   95.25 -0a7c00305
   95.26 -0afc00305
   95.27 -0b7c00305
   95.28 -0bfc00305
   95.29 -0c7c00305
   95.30 -0cfc00305
   95.31 -0d7c00305
   95.32 -0dfc00305
   95.33 -0e7c00305
   95.34 -007c07405
   95.35 -004000e0f
   95.36 -0f7c00305
   95.37 -004000a0f
   95.38 -0f7c00305
   95.39 -000407e05
   95.40 -00400060f
   95.41 -0f7801206
   95.42 -008400645
   95.43 -0f8000a4e
   95.44 -0f0c00305
   95.45 -00400120f
   95.46 -0f0000305
   95.47 -0f800160a
   95.48 -0efc00305
   95.49 -018c01206
   95.50 -008400605
   95.51 -0f8001a4c
   95.52 -00fc00305
   95.53 -00400060f
   95.54 -0f7800306
   95.55 -07fffefe3
   95.56 -0f1000305
   95.57 -00041fe05
   95.58 -0f8002203
   95.59 -0f7c03305
   95.60 -021008206
   95.61 -008400645
   95.62 -0f800124e
   95.63 -0f0000303
   95.64 -0f7c03305
   95.65 -021008206
   95.66 -00007f003
   95.67 -0f0003b06
   95.68 -0000ff003
   95.69 -0f0003b06
   95.70 -00400160f
   95.71 -0f0000305
   95.72 -0f8000a0a
   95.73 -000100105
   95.74 -004000a0f
   95.75 -0f7c00305
   95.76 -000008233
   95.77 -0f0000b06
   95.78 -00400160f
   95.79 -0f0000305
   95.80 -0f8000e0e
   95.81 -0f8000e4c
   95.82 -000040105
   95.83 -00400060f
   95.84 -0f7801245
   95.85 -000408205
   95.86 -0f7801207
   95.87 -008400645
   95.88 -0f8000a4e
   95.89 -0ef000305
   95.90 -0e8400305
   95.91 -0e8800305
   95.92 -0e8c00305
   95.93 -0e9000305
   95.94 -0e9400305
   95.95 -0e9800305
   95.96 -0e9c00305
   95.97 -0ea000305
   95.98 -0ea400305
   95.99 -0ea800305
  95.100 -0eac00305
  95.101 -0eb000305
  95.102 -0eb400305
  95.103 -0eb800305
  95.104 -0ebc00305
  95.105 -0ec000305
  95.106 -0ec400305
  95.107 -0ec800305
  95.108 -0ecc00305
  95.109 -0ed000305
  95.110 -0ed400305
  95.111 -0ed800305
  95.112 -0edc00305
  95.113 -0ee000305
  95.114 -0ee400305
  95.115 -0ee800305
  95.116 -0eec00305
  95.117 -0e7000645
  95.118 -0f8000e09
  95.119 -0f7801207
  95.120 -0f8000e4c
  95.121 -01ffffc03
  95.122 -0f0000308
  95.123 -0ef000305
  95.124 -0ef400305
  95.125 -0ef800305
  95.126 -0e800030c
    96.1 --- a/kernel/arch/beehive/startup_arch.c	Fri Jan 20 14:32:03 2012 -0800
    96.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.3 @@ -1,445 +0,0 @@
    96.4 -/**
    96.5 - * \file
    96.6 - * \brief Architecture-dependent kernel bootup code.
    96.7 - */
    96.8 -
    96.9 -/*
   96.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
   96.11 - * All rights reserved.
   96.12 - *
   96.13 - * This file is distributed under the terms in the attached LICENSE file.
   96.14 - * If you do not find this file, copies can be found by writing to:
   96.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   96.16 - */
   96.17 -
   96.18 -#include <kernel.h>
   96.19 -#include <stdio.h>
   96.20 -#include <stdlib.h>
   96.21 -#include <string.h> // for strcpy
   96.22 -#include <barrelfish_kpi/init.h>
   96.23 -#include <capabilities.h> // not to be confused with the next one
   96.24 -#include <barrelfish_kpi/capabilities.h> // before capbits.h
   96.25 -#include <barrelfish_kpi/capbits.h> // in build directory
   96.26 -#include <dispatch.h>
   96.27 -#include <startup.h>
   96.28 -#include <barrelfish_kpi/paging_arch.h> // for BASE_PAGE_SIZE
   96.29 -#include <target/beehive/barrelfish_kpi/coredata_target.h>
   96.30 -#include "beekernel.h"
   96.31 -
   96.32 -/// Quick way to find the base address of a cnode capability
   96.33 -#define CNODE(cte)     (cte)->cap.u.cnode.cnode
   96.34 -
   96.35 -// findbits.S
   96.36 -
   96.37 -extern int find_least_clear32(uint32_t value);
   96.38 -//extern int find_least_set32(uint32_t value);
   96.39 -extern int find_least_clear64(uint64_t value);
   96.40 -extern int find_least_set64(uint64_t value);
   96.41 -extern int find_highest_clear32(uint32_t value);
   96.42 -//extern int find_highest_set32(uint32_t value);
   96.43 -extern int find_highest_clear64(uint64_t value);
   96.44 -extern int find_highest_set64(uint64_t value);
   96.45 -extern int population_count(uint32_t value);
   96.46 -
   96.47 -
   96.48 -void kernel_bsp_startup(void* initaddr, pstringtable_t strings);
   96.49 -void kernel_app_startup(struct beehive_core_data *bcd);
   96.50 -void kernel_alloc_init(lpaddr_t base, lpaddr_t limit);
   96.51 -
   96.52 -static struct spawn_state spawn_state;
   96.53 -
   96.54 -// Kernel static data
   96.55 -#define MAX_IMAGES 16
   96.56 -bexec_t *MovedImages[MAX_IMAGES];
   96.57 -int MovedImageCount;
   96.58 -
   96.59 -
   96.60 -
   96.61 -/**
   96.62 - * The address from where alloc_phys will start allocating memory
   96.63 - */
   96.64 -static lpaddr_t init_alloc_addr;
   96.65 -static lpaddr_t init_alloc_limit;
   96.66 -static int alloc_phys_pages = 0;
   96.67 -
   96.68 -/**
   96.69 - * \brief Initialise linear physical memory allocator.
   96.70 - *
   96.71 - * This function initialises the allocator 
   96.72 - *
   96.73 - * \param base  Start of allocation region
   96.74 - * \param limit End of allocation region
   96.75 - *
   96.76 - */
   96.77 -void kernel_alloc_init(lpaddr_t base, lpaddr_t limit)
   96.78 -{
   96.79 -    init_alloc_addr = base;
   96.80 -    init_alloc_limit = limit;
   96.81 -}
   96.82 -
   96.83 -/**
   96.84 - * \brief Linear physical memory allocator.
   96.85 - *
   96.86 - * This function allocates a linear region of addresses of size 'size' from
   96.87 - * physical memory. XXX Performs no checking on whether it is safe to do so
   96.88 - *
   96.89 - * \param size  Number of bytes to allocate.
   96.90 - *
   96.91 - * \return Base physical address of memory region.
   96.92 - */
   96.93 -static inline lpaddr_t alloc_phys(size_t size)
   96.94 -{
   96.95 -    // round to base page size
   96.96 -    size_t npages = (size + BASE_PAGE_SIZE - 1) / BASE_PAGE_SIZE;
   96.97 -
   96.98 -    assert(init_alloc_addr != 0);
   96.99 -    lpaddr_t addr = init_alloc_addr;
  96.100 -
  96.101 -    init_alloc_addr += npages * BASE_PAGE_SIZE;
  96.102 -    alloc_phys_pages += npages;
  96.103 -
  96.104 -    if(init_alloc_addr > init_alloc_limit) {
  96.105 -        printf("Out of memory: %d pages allocated\n", alloc_phys_pages);
  96.106 -    }
  96.107 -    assert(init_alloc_addr <= init_alloc_limit);
  96.108 -
  96.109 -    //printf("alloc_phys(%x) => %x\n", size, addr);
  96.110 -
  96.111 -    return addr;
  96.112 -}
  96.113 -
  96.114 -// On most systems this is called _end, but on beehive it is a
  96.115 -// word/code address, and must be shifted for data accesses.
  96.116 -extern void _code_ibefore(void);
  96.117 -extern void _code_iafter(void);
  96.118 -extern void _data_iafter(void);
  96.119 -
  96.120 -#define ROUNDUP(x,y) (((x)+(y)-1) & ~((y)-1))
  96.121 -
  96.122 -// </This section should be in a arch header file>
  96.123 -
  96.124 -
  96.125 -#define AddRegionStr(_base, _size, _type, _string) \
  96.126 -    do { \
  96.127 -        uintptr_t base = (_base); \
  96.128 -        size_t size = (_size); \
  96.129 -        __typeof__((_type)) type = (_type); \
  96.130 -	assert((base) == location); \
  96.131 -        assert((size) > 0); \
  96.132 -	assert(bootinfo->regions_length < MAX_MEM_REGIONS); \
  96.133 -	bootinfo->regions[bootinfo->regions_length] = (struct mem_region){ .mr_base = (base), .mr_type = (type), .mr_bits = find_highest_set32(size) + (population_count(size) > 1 ? 1 : 0), .mrmod_size = (size), .mrmod_data = (_string) }; \
  96.134 -	bootinfo->regions_length++; \
  96.135 -	location = (base) + (size); \
  96.136 -        printf("Region 0x%08X size %zu to 0x%08X type %d\n", (base), (size), (location), (type)); \
  96.137 -    } while(0)
  96.138 -
  96.139 -#define AddRegion(_base, _size, _type) AddRegionStr(_base, _size, _type, 0)
  96.140 -
  96.141 -static void create_regions_from_moved_images(struct bootinfo *const bootinfo, pstringtable_t strings)
  96.142 -{
  96.143 -    assert(bootinfo != NULL);
  96.144 -    assert(strings != NULL);
  96.145 -    printf("strings->soffset[0] = %d\n", strings->soffset[0]);
  96.146 -    printf("strings[0] = \"%s\"\n", 
  96.147 -	   (char*)strings + strings->soffset[0]);
  96.148 -    assert(strings->soffset[0] < strings->slength);
  96.149 -
  96.150 -    uintptr_t location = 0;
  96.151 -
  96.152 -    // First: create the module information from the MovedImages
  96.153 -    // Kernel at 0x2000
  96.154 -    assert((((uintptr_t)&_code_ibefore)<< 2) == 0x8000); // if not check this code
  96.155 -
  96.156 -    AddRegion(0, 0x1000, RegionType_PlatformData); // 4kB magic code at 0
  96.157 -    AddRegion(0x1000, 0x3000, RegionType_PlatformData); // 12kB reserved
  96.158 -    AddRegion(0x4000, 0x2000, RegionType_PlatformData); // 16*512B debug areas
  96.159 -    AddRegion(0x6000, 0x2000, RegionType_PlatformData); // 8k hypervisor
  96.160 -    AddRegionStr(0x8000,
  96.161 -	      ROUNDUP(
  96.162 -		  ((((uintptr_t)&_data_iafter)<<2)-0x8000), BASE_PAGE_SIZE),
  96.163 -	      RegionType_Module, strings->soffset[0]); // Kernel
  96.164 -
  96.165 -    for(int i=0; i<MovedImageCount; i++) {
  96.166 -	bexec_t *bexec = MovedImages[i];
  96.167 -	if (location != (bexec->btorg << 2))
  96.168 -	    panic("Bsplice logic failure in boot image");
  96.169 -        printf("strings->soffset[%d] = %d\n", i+1, strings->soffset[i+1]);
  96.170 -        printf("strings[%d] = \"%s\"\n", 
  96.171 -               i+1, (char*)strings + strings->soffset[i+1]);
  96.172 -	assert(strings->soffset[i+1] < strings->slength);
  96.173 -	AddRegionStr((bexec->btorg << 2), 
  96.174 -		     ROUNDUP(
  96.175 -			 ((bexec->bborg + bexec->bbsize - bexec->btorg) << 2), BASE_PAGE_SIZE),
  96.176 -		     RegionType_Module,
  96.177 -		     strings->soffset[i+1]);
  96.178 -    }
  96.179 -
  96.180 -    // Need to check whether this is the simulator or the real HW
  96.181 -
  96.182 -    // Again we add a Consumed region just to fill the gap - 
  96.183 -    // it should be ignored by init.
  96.184 -#if 0
  96.185 -    AddRegion(location, ((size_t)2 << 30) - 4096 -location, RegionType_Consumed);
  96.186 -    AddRegion(((size_t)2<<30) - 4096, 4096, RegionType_PlatformData); // I cache flush
  96.187 -#endif
  96.188 -}
  96.189 -
  96.190 -
  96.191 -
  96.192 -/// Setup the module cnode, which contains frame caps to all boot loaded modules
  96.193 -static void create_module_caps(struct bootinfo * bootinfo, pstringtable_t strings)
  96.194 -{
  96.195 -    errval_t err;
  96.196 -    int first_slot = 0;
  96.197 -
  96.198 -    /* Walk over the memoty regions creating frame caps */
  96.199 -    for(int i=0; i<bootinfo->regions_length; i++) {
  96.200 -	struct mem_region *region = &bootinfo->regions[i];
  96.201 -	if (region->mr_type != RegionType_Module)
  96.202 -	    continue;
  96.203 -
  96.204 -        first_slot = spawn_state.modulecn_slot;
  96.205 -
  96.206 -#if 0
  96.207 -	printf("create_module_caps: for %" PRIxGENPADDR " to +%#x = %" PRIxGENPADDR " from slot %d\n",
  96.208 -	       region->mr_base, region->mrmod_size, 
  96.209 -               region->mr_base + region->mrmod_size, first_slot);
  96.210 -#endif
  96.211 -
  96.212 -	// Create a single cap per module
  96.213 -	size_t remain = region->mrmod_size;
  96.214 -	lpaddr_t base_addr = region->mr_base;
  96.215 -
  96.216 -	while (remain > 0) {
  96.217 -	    assert((base_addr & BASE_PAGE_MASK) == 0);
  96.218 -	    assert((remain & BASE_PAGE_MASK) == 0);
  96.219 -
  96.220 -	    uint8_t block_size = bitaddralign(remain, base_addr);
  96.221 -
  96.222 -            assert(spawn_state.modulecn_slot
  96.223 -                   < (1UL << spawn_state.modulecn->cap.u.cnode.bits));
  96.224 -            // create as DevFrame cap to avoid zeroing memory contents
  96.225 -            err = caps_create_new(ObjType_DevFrame, base_addr, block_size,
  96.226 -                        block_size,
  96.227 -                        caps_locate_slot(spawn_state.modulecn->cap.u.cnode.cnode,
  96.228 -                                         spawn_state.modulecn_slot++));
  96.229 -            assert(err_is_ok(err));
  96.230 -
  96.231 -	    // Advance by that chunk
  96.232 -	    base_addr += (1UL << block_size);
  96.233 -	    remain -= (1UL << block_size);
  96.234 -	}
  96.235 -
  96.236 -#if 0	    
  96.237 -        for (lpaddr_t pa = region->mr_base; 
  96.238 -             pa < region->mr_base + region->mrmod_size;
  96.239 -             pa += BASE_PAGE_SIZE) {
  96.240 -
  96.241 -            assert((pa & BASE_PAGE_MASK) == 0);
  96.242 -            assert(modulecn_slot < (1UL << modulecn->cap.u.cnode.bits));
  96.243 -            // create as DevFrame cap to avoid zeroing memory contents
  96.244 -            err = caps_create_new(ObjType_DevFrame, pa, BASE_PAGE_BITS,
  96.245 -                        BASE_PAGE_BITS,
  96.246 -                        caps_locate_slot(modulecn->cap.u.cnode.cnode,
  96.247 -                                         modulecn_slot++));
  96.248 -            assert(err_is_ok(err));
  96.249 -        }
  96.250 -#endif // 0
  96.251 -
  96.252 -        // Replace mr_base with the modulecn slot number for the caps
  96.253 -        region->mrmod_slot = first_slot;
  96.254 -    }
  96.255 -}
  96.256 -
  96.257 -
  96.258 -/// Create physical address range or RAM caps to unused physical memory
  96.259 -static void create_phys_caps(struct bootinfo *bootinfo)
  96.260 -{
  96.261 -    /* XXX PBAR - now we need to create caps for all usable physical
  96.262 -       memory so that init can hand these to mem_serv.  
  96.263 -
  96.264 -       This will probably involve walking the boot images just like
  96.265 -       MoveImages() did and record the current state of the address
  96.266 -       space into the mem_regions datatructure (which in turn is
  96.267 -       passed to init in the bootinfo so it can initilize the
  96.268 -       mem_serv).  
  96.269 -
  96.270 -       MoveImages currently fiddles with the memregions - but this is
  96.271 -       most likely best done here since we also need to deal with any
  96.272 -       reserved physical addresses such as the 'context save areas'
  96.273 -       for each core and any datastrcutres residing at 'well-known'
  96.274 -       addresses (i.e. not allocated using alloc_phys()).  Not 100%
  96.275 -       sure how we record the memory which alloc_phys has handed out
  96.276 -       ... perhaps look at current value of init_alloc_addr */
  96.277 -
  96.278 -    // XXX GUESS.  Create a cap from where init_alloc_addr got to
  96.279 -    // until the end of RAM.
  96.280 -    errval_t err;
  96.281 -    err = create_caps_to_cnode(init_alloc_addr,
  96.282 -			       ((size_t)(0x80000000U - 4096) - init_alloc_addr),
  96.283 -			       RegionType_Empty, &spawn_state, bootinfo);
  96.284 -    assert(err_is_ok(err));
  96.285 -    // init_alloc_addr is not valid any more since we created caps for
  96.286 -    // memory after that.
  96.287 -    init_alloc_addr = 0;
  96.288 -}
  96.289 -
  96.290 -static struct dcb *bee_spawn_module(struct bootinfo *bootinfo,
  96.291 -                                pstringtable_t strings,
  96.292 -                                bexec_t *module, 
  96.293 -                                const char *name,
  96.294 -                                int argc, const char** argv)
  96.295 -{
  96.296 -    errval_t err;
  96.297 -
  96.298 -    printf("bee_spawn_module\n");
  96.299 -
  96.300 -    lvaddr_t paramaddr;
  96.301 -    struct dcb *init_dcb = spawn_module(&spawn_state, name, argc, argv,
  96.302 -                                        (lpaddr_t)bootinfo, 0, alloc_phys,
  96.303 -                                        &paramaddr);
  96.304 -
  96.305 -    // Create BMP table in task cnode
  96.306 -    err = caps_create_new(ObjType_BMPTable, 0, 0, 0,
  96.307 -			  caps_locate_slot(CNODE(spawn_state.taskcn),
  96.308 -                          TASKCN_SLOT_BMP_TABLE));
  96.309 -    assert(err_is_ok(err));
  96.310 -
  96.311 -    /* Set fields in DCB */
  96.312 -    // Set Vspace (undefined concept since 1:1 SAS)
  96.313 -    init_dcb->vspace = 0xBAD23200;
  96.314 -
  96.315 -    // create cap for strings area in first slot of modulecn
  96.316 -    if (strings != NULL) {
  96.317 -	assert(spawn_state.modulecn_slot == 0);
  96.318 -	assert(strings->slength < BASE_PAGE_SIZE);
  96.319 -        // create as DevFrame cap to avoid zeroing memory contents
  96.320 -	err = caps_create_new(ObjType_DevFrame, (uintptr_t)strings,
  96.321 -			      BASE_PAGE_BITS, BASE_PAGE_BITS,
  96.322 -			      caps_locate_slot(spawn_state.modulecn->cap.u.cnode.cnode,
  96.323 -					       spawn_state.modulecn_slot++));
  96.324 -	assert(err_is_ok(err));
  96.325 -    }
  96.326 -
  96.327 -    /* Initialize dispatcher */
  96.328 -    struct dispatcher_shared_generic *init_disp =
  96.329 -        get_dispatcher_shared_generic(init_dcb->disp);
  96.330 -    struct dispatcher_shared_beehive *init_disp_beehive =
  96.331 -        get_dispatcher_shared_beehive(init_dcb->disp);
  96.332 -    init_disp->disabled = true;
  96.333 -    strncpy(init_disp->name, argv[0], DISP_NAME_LEN);
  96.334 -
  96.335 -    /* Set up args in appropriate regs */
  96.336 -    registers_set_param(&init_disp_beehive->enabled_save_area, paramaddr);
  96.337 -
  96.338 -    /* tell init the vspace addr of its dispatcher (1:1 V:P) */
  96.339 -    init_disp->udisp = (lvaddr_t)init_dcb->disp;
  96.340 -
  96.341 -    init_disp_beehive->disabled_save_area.named.pc = module->btorg;
  96.342 -    init_disp_beehive->disabled_save_area.named.p1 = init_dcb->disp;
  96.343 -
  96.344 -    return init_dcb;
  96.345 -}
  96.346 -
  96.347 -/**
  96.348 - * Name of multiboot module containing program for init domains.
  96.349 - */
  96.350 -#define BSP_INIT_MODULE_NAME     "/beehive/sbin/init"
  96.351 -#define BSP_MONITOR_MODULE_NAME  "/beehive/sbin/monitor"
  96.352 -
  96.353 -static bexec_t *find_module(char *name, pstringtable_t strings) 
  96.354 -{
  96.355 -    bexec_t *module = NULL;
  96.356 -
  96.357 -    printf("name=%s\n", name);
  96.358 -    for (int i=0; i<MovedImageCount; i++) {
  96.359 -	char *str = (char*)strings + strings->soffset[i+1]; // +1 since kernel not moved
  96.360 -	printf("str=%s\n", str);
  96.361 -	if (strcmp(name, str))
  96.362 -	    continue;
  96.363 -	module = MovedImages[i];
  96.364 -	break;
  96.365 -    }
  96.366 -    return module;
  96.367 -}
  96.368 -
  96.369 -void kernel_app_startup(struct beehive_core_data *bcd)
  96.370 -{
  96.371 -    my_core_id = arch_get_core_id();
  96.372 -
  96.373 -    bexec_t *monitor = bcd->monitor_module;
  96.374 -    if (monitor == NULL) {
  96.375 -        panic("Could not find monitor module!");
  96.376 -    }
  96.377 -
  96.378 -    // Setup args for monitor here
  96.379 -    // First arg is coreid of monitor which booted us
  96.380 -    // Second is the address of a page used for URPC (XXX replace with BMP?)
  96.381 -    char corearg[8];
  96.382 -    snprintf(corearg, sizeof(corearg), "%d", bcd->src_core_id);
  96.383 -
  96.384 -    char chanarg[16];
  96.385 -    snprintf(chanarg, sizeof(chanarg), "chanid=%d", bcd->chanid);
  96.386 -
  96.387 -    const char *argv[3] = { "monitor", corearg, chanarg };
  96.388 -
  96.389 -    struct dcb *mon_dcb = bee_spawn_module(bcd->bootinfo, 
  96.390 -                                       bcd->strings,
  96.391 -                                       bcd->monitor_module, 
  96.392 -                                       BSP_MONITOR_MODULE_NAME,
  96.393 -                                       3, argv);
  96.394 -
  96.395 -    printf("alloc_phys_pages=%d\n", alloc_phys_pages);
  96.396 -
  96.397 -    make_runnable(mon_dcb);
  96.398 -    
  96.399 -    printf("Going to dispatch monitor...\n");
  96.400 -    dispatch(mon_dcb);
  96.401 -    
  96.402 -    panic("MONITOR RETURNED!\n");
  96.403 -}
  96.404 -
  96.405 -void kernel_bsp_startup(void* initaddr, pstringtable_t strings)
  96.406 -{
  96.407 -    my_core_id = arch_get_core_id();
  96.408 -
  96.409 -    bexec_t *init = find_module(BSP_INIT_MODULE_NAME, strings);
  96.410 -    if (init == NULL) {
  96.411 -        panic("Could not find init module!");
  96.412 -    }
  96.413 -    /* Fill bootinfo struct to tell init where everything is */
  96.414 -    // TODO XXX Need to integrate this with MoveImages
  96.415 -    struct bootinfo *bootinfo = (void*)alloc_phys(BOOTINFO_SIZE);
  96.416 -    memset(bootinfo, 0, BOOTINFO_SIZE);
  96.417 -    printf("BOOTINFO at %p\n", bootinfo);
  96.418 -    bootinfo->regions_length = 0;
  96.419 -
  96.420 -    /* Fill in modules from MovedImage data */
  96.421 -    printf("create_regions_from_moved_images...\n");
  96.422 -    create_regions_from_moved_images(bootinfo, strings);
  96.423 -
  96.424 -    char bootinfoarg[16];
  96.425 -    snprintf(bootinfoarg, sizeof(bootinfoarg), "%d", (lvaddr_t)bootinfo);
  96.426 -
  96.427 -    const char *argv[2] = { "init", bootinfoarg };
  96.428 -    struct dcb *init_dcb = bee_spawn_module(bootinfo, strings, 
  96.429 -                                        init, BSP_INIT_MODULE_NAME,
  96.430 -                                        2, argv);
  96.431 -
  96.432 -    /* Create caps for init to use */
  96.433 -    printf("create_module_caps...\n");
  96.434 -    create_module_caps(bootinfo, strings);
  96.435 -
  96.436 -    printf("create_phys_caps...\n");
  96.437 -    create_phys_caps(bootinfo);
  96.438 -
  96.439 -    printf("alloc_phys_pages=%d\n", alloc_phys_pages);
  96.440 -
  96.441 -    make_runnable(init_dcb);
  96.442 -    
  96.443 -    printf("Going to dispatch init...\n");
  96.444 -    dispatch(init_dcb);
  96.445 -    
  96.446 -    panic("INIT RETURNED!\n");
  96.447 -
  96.448 -}
    97.1 --- a/kernel/arch/beehive/syscall.c	Fri Jan 20 14:32:03 2012 -0800
    97.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.3 @@ -1,807 +0,0 @@
    97.4 -/**
    97.5 - * \file
    97.6 - * \brief System calls implementation.
    97.7 - */
    97.8 -
    97.9 -/*
   97.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
   97.11 - * All rights reserved.
   97.12 - *
   97.13 - * This file is distributed under the terms in the attached LICENSE file.
   97.14 - * If you do not find this file, copies can be found by writing to:
   97.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
   97.16 - */
   97.17 -
   97.18 -#include <kernel.h>
   97.19 -#include <hyper.h>
   97.20 -#include <stdio.h>
   97.21 -#include <errno.h>
   97.22 -#include <barrelfish_kpi/syscalls.h> // for struct sysret
   97.23 -#include <barrelfish_kpi/paging_arch.h>
   97.24 -#include <dispatch.h> // for dcb_current
   97.25 -#include <syscall.h> // kernel generic syscalls
   97.26 -#include <mdb.h> // for remove_mapping
   97.27 -#include <barrelfish_kpi/legacy_idc_buffer.h>
   97.28 -#include <barrelfish_kpi/lmp.h>
   97.29 -#include <target/beehive/barrelfish_kpi/dispatcher_shared_target.h>
   97.30 -#include <target/beehive/barrelfish_kpi/coredata_target.h>
   97.31 -#include <corearea.h>
   97.32 -#include <dcache.h>
   97.33 -#include <trace/trace.h> // needed for trace_snapshot
   97.34 -#include "beekernel.h"
   97.35 -#include "bmp.h"
   97.36 -
   97.37 -#define MIN(a,b)        ((a) < (b) ? (a) : (b))
   97.38 -
   97.39 -
   97.40 -static struct sysret handle_invocation(struct capability *to,
   97.41 -                                       struct idc_send_msg *msg);
   97.42 -
   97.43 -
   97.44 -
   97.45 -static struct sysret handle_dispatcher_setup(struct capability *to,
   97.46 -                                             struct idc_recv_msg *msg)
   97.47 -{
   97.48 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
   97.49 -    int depth    = idc_msg_decode_word_or_zero(msg);
   97.50 -    caddr_t vptr = idc_msg_decode_word_or_zero(msg); // CPTR_NULL
   97.51 -    caddr_t dptr = idc_msg_decode_word_or_zero(msg);
   97.52 -    bool run = idc_msg_decode_word_or_zero(msg);
   97.53 -    caddr_t odptr = idc_msg_decode_word_or_zero(msg);
   97.54 -
   97.55 -    // The generic code checks that vspace is initialized
   97.56 -    struct dcb *dcb = to->u.dispatcher.dcb;
   97.57 -    dcb->vspace = 0xBAD23200;
   97.58 -
   97.59 -    return sys_dispatcher_setup(to, cptr, depth, vptr, dptr, run, odptr);
   97.60 -}
   97.61 -
   97.62 -static struct sysret handle_dispatcher_properties(struct capability *to,
   97.63 -                                                  struct idc_recv_msg *msg)
   97.64 -{
   97.65 -    enum task_type type = idc_msg_decode_word_or_zero(msg);
   97.66 -    unsigned long deadline = idc_msg_decode_word_or_zero(msg);
   97.67 -    unsigned long wcet = idc_msg_decode_word_or_zero(msg);
   97.68 -    unsigned long period = idc_msg_decode_word_or_zero(msg);
   97.69 -    unsigned long release = idc_msg_decode_word_or_zero(msg);
   97.70 -    unsigned short weight = idc_msg_decode_word_or_zero(msg);
   97.71 -
   97.72 -    return sys_dispatcher_properties(to, type, deadline, wcet, period,
   97.73 -                                     release, weight);
   97.74 -}
   97.75 -
   97.76 -
   97.77 -static struct sysret handle_dispatcher_perfmon(struct capability *to,
   97.78 -                                               struct idc_recv_msg *msg)
   97.79 -{
   97.80 -    return SYSRET(SYS_ERR_ILLEGAL_SYSCALL);
   97.81 -}
   97.82 -
   97.83 -static struct sysret handle_retype_common(struct capability *root,
   97.84 -                                          struct idc_recv_msg *msg,
   97.85 -                                          bool from_monitor)
   97.86 -{
   97.87 -    caddr_t source_cptr     = idc_msg_decode_word_or_zero(msg);
   97.88 -    enum objtype type       = idc_msg_decode_word_or_zero(msg);
   97.89 -    uint8_t objbits         = idc_msg_decode_word_or_zero(msg);
   97.90 -    caddr_t dest_cnode_cptr = idc_msg_decode_word_or_zero(msg);
   97.91 -    caddr_t dest_slot       = idc_msg_decode_word_or_zero(msg);
   97.92 -    uint8_t dest_vbits      = idc_msg_decode_word_or_zero(msg);
   97.93 -
   97.94 -    return sys_retype(root, source_cptr, type, objbits, dest_cnode_cptr,
   97.95 -                      dest_slot, dest_vbits, from_monitor);
   97.96 -}
   97.97 -
   97.98 -static struct sysret handle_retype(struct capability *root,
   97.99 -                                   struct idc_recv_msg *msg)
  97.100 -{
  97.101 -    return handle_retype_common(root, msg, false);
  97.102 -}
  97.103 -
  97.104 -/**
  97.105 - * Common code for copying and minting except the mint flag and param passing
  97.106 - */
  97.107 -static struct sysret copy_or_mint(struct capability *root,
  97.108 -                                  struct idc_recv_msg *msg, bool mint)
  97.109 -{
  97.110 -    /* Retrive arguments */
  97.111 -    caddr_t  destcn_cptr   = idc_msg_decode_word_or_zero(msg);
  97.112 -    cslot_t dest_slot     = idc_msg_decode_word_or_zero(msg);
  97.113 -    caddr_t  source_cptr   = idc_msg_decode_word_or_zero(msg);
  97.114 -    int      destcn_vbits  = idc_msg_decode_word_or_zero(msg);
  97.115 -    int      source_vbits  = idc_msg_decode_word_or_zero(msg);
  97.116 -    uintptr_t param1, param2;
  97.117 -    // params only sent if mint operation
  97.118 -    if (mint) {
  97.119 -        param1 = idc_msg_decode_word_or_zero(msg);
  97.120 -        param2 = idc_msg_decode_word_or_zero(msg);
  97.121 -    } else {
  97.122 -        param1 = param2 = 0;
  97.123 -    }
  97.124 -
  97.125 -    return sys_copy_or_mint(root, destcn_cptr, dest_slot, source_cptr,
  97.126 -                            destcn_vbits, source_vbits, param1, param2, mint);
  97.127 -}
  97.128 -
  97.129 -static struct sysret handle_mint(struct capability *root,
  97.130 -                                 struct idc_recv_msg *msg)
  97.131 -{
  97.132 -    return copy_or_mint(root, msg, true);
  97.133 -}
  97.134 -
  97.135 -static struct sysret handle_copy(struct capability *root,
  97.136 -                                 struct idc_recv_msg *msg)
  97.137 -{
  97.138 -    return copy_or_mint(root, msg, false);
  97.139 -}
  97.140 -
  97.141 -static struct sysret handle_delete_common(struct capability *root,
  97.142 -                                          struct idc_recv_msg *msg,
  97.143 -                                          bool from_monitor)
  97.144 -{
  97.145 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
  97.146 -    int bits     = idc_msg_decode_word_or_zero(msg);
  97.147 -    return sys_delete(root, cptr, bits, from_monitor);
  97.148 -}
  97.149 -
  97.150 -static struct sysret handle_delete(struct capability *root,
  97.151 -                                   struct idc_recv_msg *msg)
  97.152 -{
  97.153 -    return  handle_delete_common(root, msg, false);
  97.154 -}
  97.155 -
  97.156 -static struct sysret handle_revoke_common(struct capability *root,
  97.157 -                                          struct idc_recv_msg *msg,
  97.158 -                                          bool from_monitor)
  97.159 -{
  97.160 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
  97.161 -    int bits     = idc_msg_decode_word_or_zero(msg);
  97.162 -    return sys_revoke(root, cptr, bits, from_monitor);
  97.163 -}
  97.164 -
  97.165 -static struct sysret handle_revoke(struct capability *root,
  97.166 -                                   struct idc_recv_msg *msg)
  97.167 -{
  97.168 -    return  handle_revoke_common(root, msg, false);
  97.169 -}
  97.170 -
  97.171 -static struct sysret monitor_handle_retype(struct capability *kernel_cap,
  97.172 -                                           struct idc_recv_msg *msg)
  97.173 -{
  97.174 -    errval_t err;
  97.175 -
  97.176 -    caddr_t root_caddr = idc_msg_decode_word_or_zero(msg);
  97.177 -    caddr_t root_vbits = idc_msg_decode_word_or_zero(msg);
  97.178 -
  97.179 -    struct capability *root;
  97.180 -    err = caps_lookup_cap(&dcb_current->cspace.cap, root_caddr, root_vbits,
  97.181 -                          &root, CAPRIGHTS_READ);
  97.182 -    if (err_is_fail(err)) {
  97.183 -        return SYSRET(err_push(err, SYS_ERR_ROOT_CAP_LOOKUP));
  97.184 -    }
  97.185 -
  97.186 -    return handle_retype_common(root, msg, true);
  97.187 -}
  97.188 -
  97.189 -/// Different handler for cap operations performed by the monitor
  97.190 -static struct sysret monitor_handle_delete(struct capability *kernel_cap,
  97.191 -                                           struct idc_recv_msg *msg)
  97.192 -{
  97.193 -    errval_t err;
  97.194 -
  97.195 -    caddr_t root_caddr = idc_msg_decode_word_or_zero(msg);
  97.196 -    caddr_t root_vbits = idc_msg_decode_word_or_zero(msg);
  97.197 -
  97.198 -    struct capability *root;
  97.199 -    err = caps_lookup_cap(&dcb_current->cspace.cap, root_caddr, root_vbits,
  97.200 -                          &root, CAPRIGHTS_READ);
  97.201 -    if (err_is_fail(err)) {
  97.202 -        return SYSRET(err_push(err, SYS_ERR_ROOT_CAP_LOOKUP));
  97.203 -    }
  97.204 -
  97.205 -    return handle_delete_common(root, msg, true);
  97.206 -}
  97.207 -
  97.208 -/// Different handler for cap operations performed by the monitor
  97.209 -static struct sysret monitor_handle_revoke(struct capability *kernel_cap,
  97.210 -                                           struct idc_recv_msg *msg)
  97.211 -{
  97.212 -    errval_t err;
  97.213 -
  97.214 -    caddr_t root_caddr = idc_msg_decode_word_or_zero(msg);
  97.215 -    caddr_t root_vbits = idc_msg_decode_word_or_zero(msg);
  97.216 -
  97.217 -    struct capability *root;
  97.218 -    err = caps_lookup_cap(&dcb_current->cspace.cap, root_caddr, root_vbits,
  97.219 -                          &root, CAPRIGHTS_READ);
  97.220 -    if (err_is_fail(err)) {
  97.221 -        return SYSRET(err_push(err, SYS_ERR_ROOT_CAP_LOOKUP));
  97.222 -    }
  97.223 -
  97.224 -    return handle_revoke_common(root, msg, true);
  97.225 -}
  97.226 -
  97.227 -static struct sysret monitor_handle_register(struct capability *kernel_cap,
  97.228 -                                             struct idc_recv_msg *msg)
  97.229 -{
  97.230 -    caddr_t ep_caddr = idc_msg_decode_word_or_zero(msg);
  97.231 -    return sys_monitor_register(ep_caddr);
  97.232 -}
  97.233 -
  97.234 -//
  97.235 -// Inter-core messaging
  97.236 -//
  97.237 -typedef unsigned int msg_t[63];
  97.238 -
  97.239 -// Send a message to core number "dest", using "len" words at "buf".
  97.240 -//
  97.241 -// Note that message lengths are measured in words, not bytes.
  97.242 -void message_send(unsigned int dest, unsigned int type,
  97.243 -                  msg_t *buf, unsigned int len);
  97.244 -
  97.245 -// If there's a message available to receive, place its details and
  97.246 -// contents in (srce, type, buf) and return its length.
  97.247 -// Otherwise return 0.
  97.248 -unsigned int message_recv(unsigned int *srce, unsigned int *type,
  97.249 -                          msg_t * buf);
  97.250 -
  97.251 -/// Different handler for cap operations performed by the monitor
  97.252 -static struct sysret
  97.253 -sys_monitor_spawn_core(coreid_t core_id, enum cpu_type cpu_type,
  97.254 -                       genvaddr_t core_data)
  97.255 -{
  97.256 -    struct beehive_core_data *bcd =
  97.257 -        (struct beehive_core_data*)(lvaddr_t)core_data;
  97.258 -    if (core_id < 2 || core_id >= arch_get_max_core_id())
  97.259 -	panic("core_id out of range");
  97.260 -    printf("spawning core %d data=%p cpu=%p monitor=%p\n",
  97.261 -	   core_id, bcd, bcd->cpu_module, bcd->monitor_module);
  97.262 -
  97.263 -    uint32_t entry = bcd->cpu_module->btorg;
  97.264 -
  97.265 -    // Setup registers in save area
  97.266 -    struct corearea *savearea = COREAREA_FOR_CORE(core_id);
  97.267 -    for (int i = 1; i < 32; i++) {
  97.268 -        savearea->regs[i] = 0xBAD000 | i;
  97.269 -    }
  97.270 -    // Count
  97.271 -    savearea->regs[0] = 0;
  97.272 -    
  97.273 -    /* Pass argument through to target _bmain via s1 */
  97.274 -    savearea->regs[9] = core_data;
  97.275 -    savearea->regs[31] = entry;
  97.276 -
  97.277 -    // Mark kernel covering whole memory so timer interrupts are deferred
  97.278 -    savearea->kernel_begins = 0;
  97.279 -    savearea->kernel_ends = 0x7fffffff;
  97.280 -
  97.281 -    //bee_dcache_flush_rgn(savearea, 512);
  97.282 -    bee_dcache_flush_all(); // paranoid!
  97.283 -
  97.284 -    if (arch_get_core_id() != 1) {
  97.285 -        msg_t msg;
  97.286 -        msg[0] = HYPER_START_CORE;
  97.287 -        msg[1] = core_id;
  97.288 -        message_send(1, HYPER_MSG_TYPE, &msg, 2);
  97.289 -    } else {
  97.290 -        // Send a START message
  97.291 -        message_send(core_id, 0, NULL, 0);
  97.292 -    }
  97.293 -
  97.294 -    return SYSRET(SYS_ERR_OK);
  97.295 -}
  97.296 -
  97.297 -/**
  97.298 - * \brief Spawn a new core and create a kernel cap for it.
  97.299 - */
  97.300 -static struct sysret monitor_spawn_core(struct capability *kernel_cap,
  97.301 -                                        struct idc_recv_msg *msg)
  97.302 -{
  97.303 -    coreid_t core_id       = idc_msg_decode_word_or_zero(msg);
  97.304 -    enum cpu_type cpu_type = idc_msg_decode_word_or_zero(msg);
  97.305 -    genvaddr_t entry       = idc_msg_decode_word_or_zero(msg);
  97.306 -
  97.307 -    return sys_monitor_spawn_core(core_id, cpu_type, entry);
  97.308 -}
  97.309 -
  97.310 -static struct sysret monitor_get_core_id(struct capability *kernel_cap,
  97.311 -                                         struct idc_recv_msg *msg)
  97.312 -{
  97.313 -    return (struct sysret){.error = SYS_ERR_OK, .value = arch_get_core_id()};
  97.314 -}
  97.315 -
  97.316 -
  97.317 -static struct sysret monitor_identify_cap_common(struct capability *kernel_cap,
  97.318 -                                                 struct capability *root,
  97.319 -                                                 struct idc_recv_msg *msg)
  97.320 -{
  97.321 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
  97.322 -    uint8_t bits = idc_msg_decode_word_or_zero(msg);
  97.323 -    struct capability *retbuf = (void *)idc_msg_decode_word_or_zero(msg);
  97.324 -
  97.325 -    return sys_monitor_identify_cap(root, cptr, bits, retbuf);
  97.326 -}
  97.327 -
  97.328 -static struct sysret monitor_identify_cap(struct capability *kernel_cap,
  97.329 -                                          struct idc_recv_msg *msg)
  97.330 -{
  97.331 -    return monitor_identify_cap_common(kernel_cap, &dcb_current->cspace.cap, msg);
  97.332 -}
  97.333 -
  97.334 -static struct sysret monitor_identify_domains_cap(struct capability *kernel_cap,
  97.335 -                                                  struct idc_recv_msg *msg)
  97.336 -{
  97.337 -    errval_t err;
  97.338 -
  97.339 -    caddr_t root_caddr = idc_msg_decode_word_or_zero(msg);
  97.340 -    caddr_t root_vbits = idc_msg_decode_word_or_zero(msg);
  97.341 -
  97.342 -    struct capability *root;
  97.343 -    err = caps_lookup_cap(&dcb_current->cspace.cap, root_caddr, root_vbits,
  97.344 -                          &root, CAPRIGHTS_READ);
  97.345 -
  97.346 -    if (err_is_fail(err)) {
  97.347 -        return SYSRET(err_push(err, SYS_ERR_ROOT_CAP_LOOKUP));
  97.348 -    }
  97.349 -    return monitor_identify_cap_common(kernel_cap, root, msg);
  97.350 -}
  97.351 -
  97.352 -static struct sysret monitor_remote_cap(struct capability *kernel_cap,
  97.353 -                                        struct idc_recv_msg *msg)
  97.354 -{
  97.355 -    struct capability *root = &dcb_current->cspace.cap;
  97.356 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
  97.357 -    int bits = idc_msg_decode_word_or_zero(msg);
  97.358 -    bool remote = (bool)idc_msg_decode_word_or_zero(msg);
  97.359 -    bool * has_desc = (bool *)idc_msg_decode_word_or_zero(msg);
  97.360 -
  97.361 -    struct cte *cte;
  97.362 -    errval_t err = caps_lookup_slot(root, cptr, bits, &cte, CAPRIGHTS_WRITE);
  97.363 -    if (err_is_fail(err)) {
  97.364 -        return SYSRET(err_push(err, SYS_ERR_IDENTIFY_LOOKUP));
  97.365 -    }
  97.366 -
  97.367 -    set_cap_remote(cte, remote);
  97.368 -    *has_desc = has_descendants(cte);
  97.369 -
  97.370 -    return SYSRET(SYS_ERR_OK);
  97.371 -}
  97.372 -
  97.373 -
  97.374 -static struct sysret monitor_create_cap(struct capability *kernel_cap,
  97.375 -                                        struct idc_recv_msg *msg)
  97.376 -{
  97.377 -    /* Get the raw metadata of the capability to create */
  97.378 -    /* XXX: trusting user pointer! */
  97.379 -    struct capability *src = (struct capability*)idc_msg_decode_word_or_zero(msg);
  97.380 -
  97.381 -    /* Certain types cannot be created here */
  97.382 -    if ((src->type == ObjType_Null) || (src->type == ObjType_EndPoint)
  97.383 -        || (src->type == ObjType_Dispatcher) || (src->type == ObjType_Kernel)
  97.384 -        || (src->type == ObjType_IRQTable)) {
  97.385 -        return SYSRET(SYS_ERR_ILLEGAL_DEST_TYPE);
  97.386 -    }
  97.387 -
  97.388 -    /* Create the cap in the destination */
  97.389 -    caddr_t cnode_cptr = idc_msg_decode_word_or_zero(msg);
  97.390 -    int cnode_vbits    = idc_msg_decode_word_or_zero(msg);
  97.391 -    size_t slot        = idc_msg_decode_word_or_zero(msg);
  97.392 -    return SYSRET(caps_create_from_existing(&dcb_current->cspace.cap,
  97.393 -                                            cnode_cptr, cnode_vbits,
  97.394 -                                            slot, src));
  97.395 -}
  97.396 -
  97.397 -static struct sysret monitor_nullify_cap(struct capability *kernel_cap,
  97.398 -                                         struct idc_recv_msg *msg)
  97.399 -{
  97.400 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
  97.401 -    uint8_t bits = idc_msg_decode_word_or_zero(msg);
  97.402 -
  97.403 -    return sys_monitor_nullify_cap(cptr, bits);
  97.404 -}
  97.405 -
  97.406 -static struct sysret monitor_iden_cnode_get_cap(struct capability *kern_cap,
  97.407 -                                                struct idc_recv_msg *msg)
  97.408 -{
  97.409 -    errval_t err;
  97.410 -
  97.411 -    /* Get the raw metadata of the cnode */
  97.412 -    uintptr_t raw[sizeof(struct capability) / sizeof(uintptr_t)];
  97.413 -    for(int i = 0; i < sizeof(struct capability) / sizeof(uintptr_t); i++) {
  97.414 -        raw[i] = idc_msg_decode_word_or_zero(msg);
  97.415 -    }
  97.416 -
  97.417 -    struct capability *cnode = (struct capability*)raw;
  97.418 -    assert(cnode->type == ObjType_CNode);
  97.419 -
  97.420 -    struct capability *cnode_copy;
  97.421 -    err = mdb_get_copy(cnode, &cnode_copy);
  97.422 -    if (err_is_fail(err)) {
  97.423 -        return SYSRET(err);
  97.424 -    }
  97.425 -
  97.426 -    caddr_t slot = idc_msg_decode_word_or_zero(msg);
  97.427 -    struct cte* cte = caps_locate_slot(cnode_copy->u.cnode.cnode, slot);
  97.428 -
  97.429 -    // XXX: Write cap data directly back to user-space
  97.430 -    // FIXME: this should involve a pointer/range check for reliability,
  97.431 -    // but because the monitor is inherently trusted it's not a security hole
  97.432 -    struct capability *retbuf = (void *)idc_msg_decode_word_or_zero(msg);
  97.433 -    *retbuf = cte->cap;
  97.434 -
  97.435 -    return SYSRET(SYS_ERR_OK);
  97.436 -}
  97.437 -
  97.438 -static struct sysret handle_frame_identify(struct capability *to,
  97.439 -                                           struct idc_recv_msg *msg)
  97.440 -{
  97.441 -    // Return with physical base address of frame
  97.442 -    // XXX: pack size into bottom bits of base address
  97.443 -    assert(to->type == ObjType_Frame || to->type == ObjType_DevFrame);
  97.444 -    assert((to->u.frame.base & BASE_PAGE_MASK) == 0);
  97.445 -    return (struct sysret) {
  97.446 -        .error = SYS_ERR_OK,
  97.447 -        .value = to->u.frame.base | to->u.frame.bits,
  97.448 -    };
  97.449 -}
  97.450 -
  97.451 -
  97.452 -static struct sysret monitor_handle_domain_id(struct capability *monitor_cap,
  97.453 -                                              struct idc_recv_msg *msg)
  97.454 -{
  97.455 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
  97.456 -    domainid_t domain_id = idc_msg_decode_word_or_zero(msg);
  97.457 -
  97.458 -    return sys_monitor_domain_id(cptr, domain_id);
  97.459 -}
  97.460 -
  97.461 -/**
  97.462 - * \brief Set up tracing in the kernel
  97.463 - */
  97.464 -static struct sysret handle_trace_setup(struct capability *cap,
  97.465 -                                        struct idc_recv_msg *msg)
  97.466 -{
  97.467 -    struct capability *frame;
  97.468 -    errval_t err;
  97.469 -
  97.470 -    /* lookup passed cap */
  97.471 -    caddr_t cptr = idc_msg_decode_word_or_zero(msg);
  97.472 -    err = caps_lookup_cap(&dcb_current->cspace.cap, cptr, CPTR_BITS, &frame,
  97.473 -                          CAPRIGHTS_READ_WRITE);
  97.474 -    if (err_is_fail(err)) {
  97.475 -        return SYSRET(err);
  97.476 -    }
  97.477 -
  97.478 -    //panic("kernel_trace_buf\n");
  97.479 -    kernel_trace_buf = /*phys_to_mem*/(frame->u.frame.base);
  97.480 -    //printf("kernel.%u: handle_trace_setup at %lx\n", apic_id, kernel_trace_buf);
  97.481 -    return SYSRET(SYS_ERR_OK);
  97.482 -}
  97.483 -
  97.484 -static struct sysret irq_table_set(struct capability *to, struct idc_recv_msg *msg)
  97.485 -{
  97.486 -    return SYSRET(SYS_ERR_ILLEGAL_SYSCALL);
  97.487 -}
  97.488 -
  97.489 -static struct sysret irq_table_delete(struct capability *to, struct idc_recv_msg *msg)
  97.490 -{
  97.491 -    return SYSRET(SYS_ERR_ILLEGAL_SYSCALL);
  97.492 -}
  97.493 -
  97.494 -static struct sysret handle_io(struct capability *to, struct idc_recv_msg *msg)
  97.495 -{
  97.496 -    return SYSRET(SYS_ERR_IO_PORT_INVALID);
  97.497 -}
  97.498 -
  97.499 -
  97.500 -
  97.501 -
  97.502 -typedef struct sysret (*invocation_handler_t)(struct capability *to,
  97.503 -                                              struct idc_recv_msg *msg);
  97.504 -
  97.505 -static invocation_handler_t invocations[ObjType_Num][CAP_MAX_CMD] = {
  97.506 -    [ObjType_Dispatcher] = {
  97.507 -        [DispatcherCmd_Setup] = handle_dispatcher_setup,
  97.508 -        [DispatcherCmd_Properties] = handle_dispatcher_properties,
  97.509 -        [DispatcherCmd_PerfMon] = handle_dispatcher_perfmon,
  97.510 -    },
  97.511 -    [ObjType_Frame] = {
  97.512 -        [FrameCmd_Identify] = handle_frame_identify
  97.513 -    },
  97.514 -    [ObjType_DevFrame] = {
  97.515 -        [FrameCmd_Identify] = handle_frame_identify
  97.516 -    },
  97.517 -    [ObjType_CNode] = {
  97.518 -        [CNodeCmd_Copy]   = handle_copy,
  97.519 -        [CNodeCmd_Mint]   = handle_mint,
  97.520 -        [CNodeCmd_Retype] = handle_retype,
  97.521 -        [CNodeCmd_Delete] = handle_delete,
  97.522 -        [CNodeCmd_Revoke] = handle_revoke,
  97.523 -    },
  97.524 -    [ObjType_Kernel] = {
  97.525 -        [KernelCmd_Spawn_core]   = monitor_spawn_core,
  97.526 -        [KernelCmd_Get_core_id]  = monitor_get_core_id,
  97.527 -        [KernelCmd_Identify_cap] = monitor_identify_cap,
  97.528 -        [KernelCmd_Identify_domains_cap] = monitor_identify_domains_cap,
  97.529 -        [KernelCmd_Remote_cap]   = monitor_remote_cap,
  97.530 -        [KernelCmd_Iden_cnode_get_cap] = monitor_iden_cnode_get_cap,
  97.531 -        [KernelCmd_Create_cap]   = monitor_create_cap,
  97.532 -        [KernelCmd_Nullify_cap]  = monitor_nullify_cap,
  97.533 -        [KernelCmd_Setup_trace]  = handle_trace_setup,
  97.534 -        [KernelCmd_Register]     = monitor_handle_register,
  97.535 -        [KernelCmd_Domain_Id]    = monitor_handle_domain_id,
  97.536 -        [MonitorCmd_Retype]      = monitor_handle_retype,
  97.537 -        [MonitorCmd_Delete]      = monitor_handle_delete,
  97.538 -        [MonitorCmd_Revoke]      = monitor_handle_revoke
  97.539 -    },
  97.540 -    [ObjType_IRQTable] = {
  97.541 -        [IRQTableCmd_Set] = irq_table_set,
  97.542 -        [IRQTableCmd_Delete] = irq_table_delete
  97.543 -    },
  97.544 -    [ObjType_BMPTable] = {
  97.545 -        [BMPTableCmd_Set] = bmp_table_set,
  97.546 -        [BMPTableCmd_Delete] = bmp_table_delete
  97.547 -    },
  97.548 -    [ObjType_IO] = {
  97.549 -        [IOCmd_Outb] = handle_io,
  97.550 -        [IOCmd_Outw] = handle_io,
  97.551 -        [IOCmd_Outd] = handle_io,
  97.552 -        [IOCmd_Inb] = handle_io,
  97.553 -        [IOCmd_Inw] = handle_io,
  97.554 -        [IOCmd_Ind] = handle_io
  97.555 -    }
  97.556 -};
  97.557 -
  97.558 -static struct sysret handle_invocation(struct capability *to,
  97.559 -                                       struct idc_send_msg *msg)
  97.560 -{
  97.561 -    assert(to->type < ObjType_Num);
  97.562 -
  97.563 -    // Endpoint cap, do IDC
  97.564 -    if (to->type == ObjType_EndPoint) {
  97.565 -        struct dcb *listener = to->u.endpoint.listener;
  97.566 -        assert(listener != NULL);
  97.567 -
  97.568 -        if (listener->disp == 0) {
  97.569 -            return SYSRET(SYS_ERR_LMP_NO_TARGET);
  97.570 -        }
  97.571 -
  97.572 -        // does the sender want to yield their timeslice on success?
  97.573 -        bool sync = msg->u.x.header.x.flags.sync;
  97.574 -        // does the sender want to yield to the target if undeliverable?
  97.575 -        bool yield = msg->u.x.header.x.flags.yield;
  97.576 -
  97.577 -        /* limit length of message from buggy/malicious sender */
  97.578 -        size_t len = MIN(msg->u.x.header.x.length, LMP_MSG_LENGTH);
  97.579 -
  97.580 -        // try to deliver message
  97.581 -        errval_t err = lmp_deliver(to, dcb_current, msg->u.x.words, len,
  97.582 -                                   msg->u.x.header.x.send_cptr,
  97.583 -                                   msg->u.x.header.x.send_bits);
  97.584 -
  97.585 -        /* Switch to reciever upon successful delivery with sync flag,
  97.586 -         * or (some cases of) unsuccessful delivery with yield flag */
  97.587 -        enum err_code err_code = err_no(err);
  97.588 -        if ((sync && err_is_ok(err)) ||
  97.589 -            (yield && (err_code == SYS_ERR_LMP_BUF_OVERFLOW
  97.590 -                       || err_code == SYS_ERR_LMP_CAPTRANSFER_DST_CNODE_LOOKUP
  97.591 -                       || err_code == SYS_ERR_LMP_CAPTRANSFER_DST_CNODE_INVALID
  97.592 -                       || err_code == SYS_ERR_LMP_CAPTRANSFER_DST_SLOT_OCCUPIED))
  97.593 -                ) {
  97.594 -            if (err_is_fail(err)) {
  97.595 -                struct dispatcher_shared_generic *current_disp =
  97.596 -                    get_dispatcher_shared_generic(dcb_current->disp);
  97.597 -                struct dispatcher_shared_generic *listener_disp =
  97.598 -                    get_dispatcher_shared_generic(listener->disp);
  97.599 -                debug(SUBSYS_DISPATCH, "IDC failed; %.*s yields to %.*s: %u\n",
  97.600 -                      DISP_NAME_LEN, current_disp->name,
  97.601 -                      DISP_NAME_LEN, listener_disp->name, err_code);
  97.602 -            }
  97.603 -            union registers_beehive *save_area;
  97.604 -            dispatcher_handle_t handle = dcb_current->disp;
  97.605 -            struct dispatcher_shared_beehive *disp =
  97.606 -                get_dispatcher_shared_beehive(handle);
  97.607 -            //printf("dcb_current->disabled = %d\n", dcb_current->disabled);
  97.608 -            if (dcb_current->disabled) {
  97.609 -                save_area = &disp->disabled_save_area;
  97.610 -            } else {
  97.611 -                save_area = &disp->enabled_save_area;
  97.612 -            }
  97.613 -            // The syscall_invoke in syscall_arch.h returns errval_t
  97.614 -            save_area->named.return1 = err; // SET RETURN VALUE
  97.615 -
  97.616 -            dispatch(to->u.endpoint.listener);
  97.617 -            panic("dispatch returned");
  97.618 -        }
  97.619 -
  97.620 -        return SYSRET(err);
  97.621 -    }
  97.622 -    else if (to->type == ObjType_BMPEndPoint) {
  97.623 -
  97.624 -        // TODO: XXX should this by done through the dispach table?
  97.625 -        // the dispatch code below looks bizzare and bad performance
  97.626 -
  97.627 -        int core      = to->u.bmpendpoint.coreid;
  97.628 -        int assoc     = to->u.bmpendpoint.chanid;
  97.629 -        int len       = msg->u.x.words[0];
  97.630 -        uint32_t *ptr = (uintptr_t*)msg->u.x.words[1];
  97.631 -        bmp_send(core, assoc, len, ptr);
  97.632 -        return SYSRET(0);
  97.633 -    }
  97.634 -
  97.635 -
  97.636 -    // not endpoint cap, call kernel handler through dispatch table
  97.637 -
  97.638 -    // construct receive message
  97.639 -    struct idc_recv_msg rcvmsg = {
  97.640 -        .pos = 0,
  97.641 -        .msg.header.raw = 0,
  97.642 -    };
  97.643 -    rcvmsg.msg.header.x.length = MIN(msg->u.x.header.x.length, IDC_MSG_LENGTH);
  97.644 -
  97.645 -    /* XXX: copy payload */
  97.646 -    for (int i = 0; i < rcvmsg.msg.header.x.length; i++) {
  97.647 -        rcvmsg.msg.words[i] = msg->u.x.words[i];
  97.648 -    }
  97.649 -
  97.650 -    uintptr_t cmd = idc_msg_decode_word_or_zero(&rcvmsg);
  97.651 -    if (cmd >= CAP_MAX_CMD) {
  97.652 -        return SYSRET(SYS_ERR_ILLEGAL_INVOCATION);
  97.653 -    }
  97.654 -
  97.655 -    invocation_handler_t invocation = invocations[to->type][cmd];
  97.656 -    if(invocation == NULL) {
  97.657 -        return SYSRET(SYS_ERR_ILLEGAL_INVOCATION);
  97.658 -    }
  97.659 -
  97.660 -    // Call the invocation
  97.661 -    struct sysret sysret = invocation(to, &rcvmsg);
  97.662 -
  97.663 -    // If dcb_current got removed, dispatch someone else
  97.664 -    if (dcb_current == NULL) {
  97.665 -        assert(err_is_ok(sysret.error));
  97.666 -        dispatch(schedule());
  97.667 -    }
  97.668 -
  97.669 -    return sysret;
  97.670 -} // handle_invocation
  97.671 -
  97.672 -
  97.673 -/*
  97.674 - * The assembler trap handler assumes that these functions have a
  97.675 - * maximum of 6 words of arguments.  Any more than this requries
  97.676 - * modification in the assember.
  97.677 - */
  97.678 -errval_t sys_invoke(uintptr_t *const pvalue,
  97.679 -                    uint8_t validbits, caddr_t cptr,
  97.680 -                    struct idc_send_msg *msg);
  97.681 -errval_t sys_beehive_yield(caddr_t target);
  97.682 -errval_t sys_lrpc(void);
  97.683 -errval_t sys_reboot(void);
  97.684 -errval_t sys_nop(void);
  97.685 -errval_t beehive_sys_print(const char *str, size_t length);
  97.686 -errval_t sys_rundown(void);
  97.687 -errval_t sys_illegal(unsigned int num);
  97.688 -
  97.689 -
  97.690 -/* Check that the table below is going to be correct */
  97.691 -STATIC_ASSERT(SYSCALL_INVOKE == 0, "0");
  97.692 -STATIC_ASSERT(SYSCALL_YIELD == 1, "1");
  97.693 -STATIC_ASSERT(SYSCALL_LRPC == 2, "2");
  97.694 -STATIC_ASSERT(SYSCALL_DEBUG == 3, "3");
  97.695 -STATIC_ASSERT(SYSCALL_REBOOT == 4, "4");
  97.696 -STATIC_ASSERT(SYSCALL_NOP == 5, "5");
  97.697 -STATIC_ASSERT(SYSCALL_PRINT == 6, "6");
  97.698 -STATIC_ASSERT(SYSCALL_BEEHIVE_TRACE_RUNDOWN == 7, "7");
  97.699 -
  97.700 -const void* syscalls[] = {
  97.701 -    sys_invoke,
  97.702 -    sys_beehive_yield,
  97.703 -    sys_lrpc,
  97.704 -    sys_illegal,
  97.705 -    sys_reboot,
  97.706 -    sys_nop,
  97.707 -    sys_print,
  97.708 -    sys_rundown,
  97.709 -    sys_illegal,
  97.710 -    sys_illegal
  97.711 -};
  97.712 -
  97.713 -// The sys_illegal must be at index SYSCALL_COUNT
  97.714 -STATIC_ASSERT_SIZEOF(syscalls, (sizeof(void*) * (SYSCALL_COUNT+1)));
  97.715 -
  97.716 -
  97.717 -
  97.718 -// XXX TODO: Should be typedef for these, not uint8_t
  97.719 -errval_t sys_invoke(uintptr_t *const pvalue,
  97.720 -                    uint8_t validbits, caddr_t cptr, struct idc_send_msg *msg)
  97.721 -{
  97.722 -    //printf("sys_invoke: called %u 0x%" PRIxCADDR "\n", validbits, cptr);
  97.723 -
  97.724 -    struct capability *to = NULL;
  97.725 -    errval_t err = caps_lookup_cap(&dcb_current->cspace.cap,
  97.726 -                                   cptr, validbits,
  97.727 -                                   &to, CAPRIGHTS_READ);
  97.728 -    if (err_is_fail(err)) {
  97.729 -        printf("sys_invoke: caps_lookup_cap: error %#x\n", err);
  97.730 -        //debug_print_backtrace();
  97.731 -        return err;
  97.732 -    }
  97.733 -
  97.734 -    assert(to != NULL);
  97.735 -
  97.736 -    // done in asm: dcb_current->disabled = disp_is_disabled_ip(dcb_current->disp, 0);
  97.737 -
  97.738 -    struct sysret retval = handle_invocation(to, msg);
  97.739 -    if (err_is_fail(retval.error) &&
  97.740 -        retval.error != SYS_ERR_RETRY_THROUGH_MONITOR) {
  97.741 -        printf("sys_invoke: handle_invocation: error %#x\n", retval.error);
  97.742 -        debug_print_backtrace();
  97.743 -    }
  97.744 -    //printf("sys_invoke: return %#x,%#x\n", retval.error, retval.value);
  97.745 -    *pvalue = retval.value;
  97.746 -    return retval.error;
  97.747 -}
  97.748 -
  97.749 -
  97.750 -errval_t sys_lrpc(void)
  97.751 -{
  97.752 -    panic("sys_lrpc: called\n");
  97.753 -}
  97.754 -
  97.755 -errval_t sys_beehive_yield(caddr_t target)
  97.756 -{
  97.757 -    return sys_yield(target).error;
  97.758 -}
  97.759 -
  97.760 -errval_t sys_reboot(void)
  97.761 -{
  97.762 -    panic("sys_reboot: called");
  97.763 -}
  97.764 -
  97.765 -
  97.766 -errval_t sys_nop(void)
  97.767 -{
  97.768 -    bmp_pump();
  97.769 -    return SYS_ERR_OK;
  97.770 -}
  97.771 -
  97.772 -/**
  97.773 - * Put rundown of current state in the trace buffer
  97.774 - * This would typically be called at the start of tracing
  97.775 - */
  97.776 -void trace_snapshot(void)
  97.777 -{
  97.778 -    // DCBS
  97.779 -    struct dcb *dcb = dcbs_list;
  97.780 -    struct trace_event ev;
  97.781 -    errval_t err;
  97.782 -
  97.783 -    while (dcb != NULL) {
  97.784 -        struct dispatcher_shared_generic *disp =
  97.785 -            get_dispatcher_shared_generic(dcb->disp);
  97.786 -        //printf("%d DCB: %p %.*s\n", my_core_id, dcb, DISP_NAME_LEN, disp->name);
  97.787 -	// Top bit of timestamp is flag to indicate dcb rundown events
  97.788 -        ev.timestamp = (1ULL << 63) | (uintptr_t)dcb;
  97.789 -	assert(sizeof(ev.u.raw) <= sizeof(disp->name));
  97.790 -        memcpy(&ev.u.raw, disp->name, sizeof(ev.u.raw));
  97.791 -        err = trace_write_event(&ev);
  97.792 -        dcb = dcb->next_all;
  97.793 -    }
  97.794 -
  97.795 -    // TO DO: currently running domain
  97.796 -}
  97.797 -
  97.798 -errval_t sys_rundown(void)
  97.799 -{
  97.800 -    trace_snapshot();
  97.801 -    return SYS_ERR_OK;
  97.802 -}
  97.803 -
  97.804 -
  97.805 -errval_t sys_illegal(unsigned int num)
  97.806 -{
  97.807 -    printf("sys_illegal: %u\n", num);
  97.808 -    return SYS_ERR_ILLEGAL_SYSCALL;
  97.809 -}
  97.810 -
    98.1 --- a/kernel/arch/x86/ipi_notify.c	Fri Jan 20 14:32:03 2012 -0800
    98.2 +++ b/kernel/arch/x86/ipi_notify.c	Mon Jan 23 11:04:15 2012 -0800
    98.3 @@ -121,7 +121,6 @@
    98.4      // Make sure the next slot is empty
    98.5      if (fifo[slot] != 0) {
    98.6          panic("FULL");
    98.7 -        return SYSRET(SYS_ERR_BMP_TX_BUSY);
    98.8      }
    98.9  
   98.10      // Update notify fifo
    99.1 --- a/kernel/capabilities.c	Fri Jan 20 14:32:03 2012 -0800
    99.2 +++ b/kernel/capabilities.c	Mon Jan 23 11:04:15 2012 -0800
    99.3 @@ -73,7 +73,7 @@
    99.4  
    99.5  // If you create more capability types you need to deal with them
    99.6  // in the table below.
    99.7 -STATIC_ASSERT(ObjType_Num == 27, "Knowledge of all cap types");
    99.8 +STATIC_ASSERT(ObjType_Num == 25, "Knowledge of all cap types");
    99.9  
   99.10  static size_t caps_numobjs(enum objtype type, uint8_t bits, uint8_t objbits)
   99.11  {
   99.12 @@ -124,8 +124,6 @@
   99.13      case ObjType_IRQTable:
   99.14      case ObjType_IO:
   99.15      case ObjType_EndPoint:
   99.16 -    case ObjType_BMPEndPoint:
   99.17 -    case ObjType_BMPTable:
   99.18      case ObjType_Domain:
   99.19      case ObjType_Notify_RCK:
   99.20      case ObjType_Notify_IPI:
   99.21 @@ -160,18 +158,13 @@
   99.22   */
   99.23  // If you create more capability types you need to deal with them
   99.24  // in the table below.
   99.25 -STATIC_ASSERT(ObjType_Num == 27, "Knowledge of all cap types");
   99.26 +STATIC_ASSERT(ObjType_Num == 25, "Knowledge of all cap types");
   99.27  
   99.28  static errval_t caps_create(enum objtype type, lpaddr_t lpaddr, uint8_t bits,
   99.29                              uint8_t objbits, size_t numobjs,
   99.30                              struct cte *dest_caps)
   99.31  {
   99.32      errval_t err;
   99.33 -#if 0
   99.34 -#ifdef __BEEHIVE__
   99.35 -    extern void debug_print_cap(struct capability *cap);
   99.36 -#endif
   99.37 -#endif
   99.38  
   99.39      /* Parameter checking */
   99.40      assert(dest_caps != NULL);
   99.41 @@ -245,11 +238,6 @@
   99.42              if (err_is_fail(err)) {
   99.43                  return err;
   99.44              }
   99.45 -#if 0
   99.46 -#ifdef __BEEHIVE__
   99.47 -            debug_print_cap(&dest_caps[i].cap);
   99.48 -#endif
   99.49 -#endif
   99.50          }
   99.51          return SYS_ERR_OK;
   99.52      case ObjType_DevFrame:
   99.53 @@ -544,8 +532,6 @@
   99.54      case ObjType_Kernel:
   99.55      case ObjType_IRQTable:
   99.56      case ObjType_EndPoint:
   99.57 -    case ObjType_BMPTable:
   99.58 -    case ObjType_BMPEndPoint:
   99.59      case ObjType_Domain:
   99.60      case ObjType_Notify_RCK:
   99.61      case ObjType_Notify_IPI:
   100.1 --- a/kernel/dispatch.c	Fri Jan 20 14:32:03 2012 -0800
   100.2 +++ b/kernel/dispatch.c	Mon Jan 23 11:04:15 2012 -0800
   100.3 @@ -65,9 +65,8 @@
   100.4  static inline void context_switch(struct dcb *dcb)
   100.5  {
   100.6      assert(dcb != NULL);
   100.7 -#ifndef __BEEHIVE__ // XXX Single Address Space
   100.8      assert(dcb->vspace != 0);
   100.9 -#endif
  100.10 +
  100.11      // VM guests do not have a user space dispatcher
  100.12      if (!dcb->is_vm_guest) {
  100.13          assert(dcb->disp != 0);
   101.1 --- a/kernel/include/arch/beehive/arch_gdb_stub.h	Fri Jan 20 14:32:03 2012 -0800
   101.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.3 @@ -1,23 +0,0 @@
   101.4 -/**
   101.5 - * \file
   101.6 - * \brief Header for Beehive-specific GDB stub code.
   101.7 - */
   101.8 -
   101.9 -/*
  101.10 - * Copyright (c) 2007, 2008, ETH Zurich.
  101.11 - * All rights reserved.
  101.12 - *
  101.13 - * This file is distributed under the terms in the attached LICENSE file.
  101.14 - * If you do not find this file, copies can be found by writing to:
  101.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  101.16 - */
  101.17 -
  101.18 -#include <barrelfish_kpi/registers_arch.h>
  101.19 -
  101.20 -extern union registers_beehive *gdb_arch_registers;
  101.21 -
  101.22 -/** Address of saved registers as void * */
  101.23 -#define GDB_ARCH_REGADDR    ((void*)gdb_arch_registers)
  101.24 -
  101.25 -/** Number of bytes saved in GDB frame */
  101.26 -#define GDB_ARCH_REGBYTES   (sizeof(union registers_beehive))
   102.1 --- a/kernel/include/arch/beehive/conio.h	Fri Jan 20 14:32:03 2012 -0800
   102.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   102.3 @@ -1,17 +0,0 @@
   102.4 -/*
   102.5 - * Copyright (c) 2007, ETH Zurich.
   102.6 - * All rights reserved.
   102.7 - *
   102.8 - * This file is distributed under the terms in the attached LICENSE file.
   102.9 - * If you do not find this file, copies can be found by writing to:
  102.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Z++rich. Attn: Systems Group.
  102.11 - */
  102.12 -
  102.13 -#ifndef __CONIO_H
  102.14 -#define __CONIO_H
  102.15 -
  102.16 -#define conio_cls() (void)0
  102.17 -#define conio_putchar(c) (void)c
  102.18 -#define conio_relocate_vidmem(a) (void)a
  102.19 -
  102.20 -#endif //__CONIO_H
   103.1 --- a/kernel/include/arch/beehive/hyper.h	Fri Jan 20 14:32:03 2012 -0800
   103.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.3 @@ -1,22 +0,0 @@
   103.4 -/** \file
   103.5 - *  \brief Beehive 'hypervisor' protocol
   103.6 - */
   103.7 -
   103.8 -/*
   103.9 - * Copyright (c) 2010, ETH Zurich.
  103.10 - * All rights reserved.
  103.11 - *
  103.12 - * This file is distributed under the terms in the attached LICENSE file.
  103.13 - * If you do not find this file, copies can be found by writing to:
  103.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  103.15 - */
  103.16 -
  103.17 -#ifndef __HYPER_H
  103.18 -#define __HYPER_H
  103.19 -
  103.20 -#define HYPER_MSG_TYPE    6 // XXX Arbitrary!
  103.21 -
  103.22 -#define HYPER_START_CORE  0xBEE00001
  103.23 -#define HYPER_SERIAL_OUT  0xBEE00002
  103.24 -
  103.25 -#endif
   104.1 --- a/kernel/include/arch/beehive/irq.h	Fri Jan 20 14:32:03 2012 -0800
   104.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.3 @@ -1,18 +0,0 @@
   104.4 -/*
   104.5 - * Copyright (c) 2010, ETH Zurich.
   104.6 - * All rights reserved.
   104.7 - *
   104.8 - * This file is distributed under the terms in the attached LICENSE file.
   104.9 - * If you do not find this file, copies can be found by writing to:
  104.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  104.11 - */
  104.12 -
  104.13 -#ifndef KERNEL_ARCH_BEEHIVE_IRQ_H
  104.14 -#define KERNEL_ARCH_BEEHIVE_IRQ_H
  104.15 -
  104.16 -struct capability;
  104.17 -struct idc_recv_msg;
  104.18 -struct sysret irq_table_set(struct capability *to, struct idc_recv_msg *msg);
  104.19 -struct sysret irq_table_delete(struct capability *to, struct idc_recv_msg *msg);
  104.20 -
  104.21 -#endif // KERNEL_ARCH_BEEHIVE_IRQ_H
   105.1 --- a/kernel/include/arch/beehive/kputchar.h	Fri Jan 20 14:32:03 2012 -0800
   105.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.3 @@ -1,22 +0,0 @@
   105.4 -/**
   105.5 - * \file
   105.6 - * \brief A struct for all shared data between the kernels
   105.7 - */
   105.8 -
   105.9 -/*
  105.10 - * Copyright (c) 2008, 2010 ETH Zurich.
  105.11 - * All rights reserved.
  105.12 - *
  105.13 - * This file is distributed under the terms in the attached LICENSE file.
  105.14 - * If you do not find this file, copies can be found by writing to:
  105.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  105.16 - */
  105.17 -
  105.18 -#ifndef KERNEL_ARCH_BEEHIVE_KPUTCHAR_H
  105.19 -#define KERNEL_ARCH_BEEHIVE_KPUTCHAR_H
  105.20 -
  105.21 -extern void kprintf_begin(void);
  105.22 -extern void kprintf_end(void);
  105.23 -extern int kputchar(int c);
  105.24 -
  105.25 -#endif // KERNEL_ARCH_BEEHIVE_KPUTCHAR_H
   106.1 --- a/kernel/include/arch/beehive/misc.h	Fri Jan 20 14:32:03 2012 -0800
   106.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.3 @@ -1,46 +0,0 @@
   106.4 -/* [2009-07-30 ohodson] TODO: implement! */
   106.5 -
   106.6 -/**
   106.7 - * \file
   106.8 - * \brief Miscellaneous architecture-specific functions
   106.9 - */
  106.10 -
  106.11 -/*
  106.12 - * Copyright (c) 2008, 2009, 2010 ETH Zurich
  106.13 - * All rights reserved.
  106.14 - *
  106.15 - * This file is distributed under the terms in the attached LICENSE file.
  106.16 - * If you do not find this file, copies can be found by writing to:
  106.17 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  106.18 - */
  106.19 -
  106.20 -#ifndef ARCH_MISC_H
  106.21 -#define ARCH_MISC_H
  106.22 -
  106.23 -/**
  106.24 - * \brief Set thread-local-storage register.
  106.25 - */
  106.26 -
  106.27 -/* 
  106.28 - * The name of the function is somewhat misleading. we need an unused
  106.29 - * user register that always stores the pointer to the current
  106.30 - * dispatcher. most ABIs define a register for thread-local storage,
  106.31 - * and we have been abusing that on x64 for the dispatcher pointer
  106.32 - * --arch_set_thread_ register sets this pointer.  Obviously this
  106.33 - * needs to change to support thread-local storage using a standard
  106.34 - * ABI, so we will have to figure out how to get to the dispatcher
  106.35 - * from something like a thread-local variable.  The reason that this
  106.36 - * is in the switch path and not in resume/execute is that on x86_64
  106.37 - * loading the thread register (fs) is stupidly expensive, so we avoid
  106.38 - * doing it unless we switch contexts -- presumably that could be a
  106.39 - * local optimisation in the x86_64 dispatch paths rather than the
  106.40 - * generic context_switch path/
  106.41 - */
  106.42 -
  106.43 -static inline void arch_set_thread_register(uintptr_t val)
  106.44 -{
  106.45 -    extern uintptr_t x86_fs_compatability_register;
  106.46 -    x86_fs_compatability_register = val;
  106.47 -}
  106.48 -
  106.49 -#endif /* ARCH_MISC_H */
   107.1 --- a/kernel/include/arch/beehive/offsets.h	Fri Jan 20 14:32:03 2012 -0800
   107.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.3 @@ -1,81 +0,0 @@
   107.4 -/**
   107.5 - * \file
   107.6 - * \brief Beehive address space sizes and offsets
   107.7 - *
   107.8 - * The Beehive has no translation logic, and an address space layout
   107.9 - * which is different on the instruction side and the data side.
  107.10 - * Barrelfish memory management system currently doesnt deal with this
  107.11 - * so instead we just pretend we have a simple 32-bit address space.
  107.12 - *
  107.13 - */
  107.14 -
  107.15 -/*
  107.16 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich
  107.17 - * All rights reserved.
  107.18 - *
  107.19 - * This file is distributed under the terms in the attached LICENSE file.
  107.20 - * If you do not find this file, copies can be found by writing to:
  107.21 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  107.22 - */
  107.23 -
  107.24 -#ifndef OFFSETS_H
  107.25 -#define OFFSETS_H
  107.26 -
  107.27 -#ifndef __ASSEMBLER__
  107.28 -
  107.29 -/*
  107.30 - * This must be defined for kernel/capabilities.c.  Maximum physical
  107.31 - * address space mappable by the kernel.  We pretend 2GB since its not
  107.32 - * clear whether it deals correctly with 4GB.
  107.33 - */
  107.34 -
  107.35 -#define PADDR_SPACE_LIMIT ((lpaddr_t)1 << 31)
  107.36 -
  107.37 -
  107.38 -/**
  107.39 - * Takes absolute physical address addr and returns corresponding
  107.40 - * kernel-space address.
  107.41 - *
  107.42 - * \param addr  Absolute physical address
  107.43 - *
  107.44 - * \return Corresponding kernel-space address.
  107.45 - */
  107.46 -static inline lvaddr_t local_phys_to_mem(lpaddr_t addr)
  107.47 -{
  107.48 -  return (lvaddr_t)addr;
  107.49 -}
  107.50 -
  107.51 -/**
  107.52 - * Takes kernel-space address addr and returns corresponding physical
  107.53 - * address.
  107.54 - *
  107.55 - * \param addr  Kernel-space address
  107.56 - *
  107.57 - * \return Corresponding physical address.
  107.58 - */
  107.59 -static inline lpaddr_t mem_to_local_phys(lvaddr_t addr)
  107.60 -{
  107.61 -  return (lpaddr_t)addr;
  107.62 -}
  107.63 -
  107.64 -/*
  107.65 - * TODO XXX This is platform specific concept not architecture
  107.66 - * specific
  107.67 - */
  107.68 -static inline lpaddr_t gen_phys_to_local_phys(genpaddr_t addr)
  107.69 -{
  107.70 -    return (lpaddr_t)addr;
  107.71 -}
  107.72 -
  107.73 -/*
  107.74 - * TODO XXX This is platform specific concept not architecture
  107.75 - * specific
  107.76 - */
  107.77 -static inline genpaddr_t local_phys_to_gen_phys(lpaddr_t addr)
  107.78 -{
  107.79 -    return (genpaddr_t)addr;
  107.80 -}
  107.81 -
  107.82 -#endif  // __ASSEMBLER__
  107.83 -
  107.84 -#endif  // OFFSETS_H
   108.1 --- a/kernel/include/arch/beehive/paging_kernel_arch.h	Fri Jan 20 14:32:03 2012 -0800
   108.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   108.3 @@ -1,39 +0,0 @@
   108.4 -/**
   108.5 - * \file
   108.6 - * \brief ARM kernel page-table structures.
   108.7 - */
   108.8 -
   108.9 -/*
  108.10 - * Copyright (c) 2007, 2008, 2009, ETH Zurich.
  108.11 - * All rights reserved.
  108.12 - *
  108.13 - * This file is distributed under the terms in the attached LICENSE file.
  108.14 - * If you do not find this file, copies can be found by writing to:
  108.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  108.16 - */
  108.17 -
  108.18 -#ifndef KERNEL_ARCH_BEEHIVE_PAGING_H
  108.19 -#define KERNEL_ARCH_BEEHIVE_PAGING_H
  108.20 -
  108.21 -// XXX: Not sure if these includes are required
  108.22 -#include <capabilities.h>
  108.23 -#include <barrelfish_kpi/cpu.h>
  108.24 -#include <barrelfish_kpi/paging_arch.h>
  108.25 -
  108.26 -/**
  108.27 - * Setup bootstrap page table with direct and relocated mappings for kernel.
  108.28 - *
  108.29 - * This function does not enable paging.
  108.30 - *
  108.31 - * @param initial_base
  108.32 - * @param initial_size
  108.33 - */
  108.34 -void paging_map_kernel(uintptr_t initial_base, size_t initial_size);
  108.35 -
  108.36 -lvaddr_t paging_map_device(lpaddr_t base, size_t size);
  108.37 -
  108.38 -void paging_enable_mmu(void);
  108.39 -
  108.40 -void paging_context_switch(lpaddr_t ptbase);
  108.41 -
  108.42 -#endif // KERNEL_ARCH_BEEHIVE_PAGING_H
   109.1 --- a/kernel/include/dispatch.h	Fri Jan 20 14:32:03 2012 -0800
   109.2 +++ b/kernel/include/dispatch.h	Mon Jan 23 11:04:15 2012 -0800
   109.3 @@ -38,11 +38,7 @@
   109.4   */
   109.5  struct dcb {
   109.6      dispatcher_handle_t disp;           ///< User-mode dispatcher frame pointer
   109.7 -#ifdef __BEEHIVE__
   109.8 -    unsigned int	disabled;	///< Was dispatcher disabled when last saved?
   109.9 -#else
  109.10      bool                disabled;       ///< Was dispatcher disabled when last saved?
  109.11 -#endif
  109.12      struct cte          cspace;         ///< Cap slot for CSpace
  109.13      lpaddr_t            vspace;         ///< Address of VSpace root
  109.14      struct cte          disp_cte;
   110.1 --- a/kernel/include/kernel.h	Fri Jan 20 14:32:03 2012 -0800
   110.2 +++ b/kernel/include/kernel.h	Mon Jan 23 11:04:15 2012 -0800
   110.3 @@ -69,18 +69,6 @@
   110.4   * \return Highest exponent (bits) for the blocksize to use next
   110.5   */
   110.6  
   110.7 -#if defined(__BEEHIVE__)
   110.8 -extern int find_least_set32(uint32_t value);
   110.9 -extern int find_highest_set32(uint32_t value);
  110.10 -
  110.11 -static inline int bitaddralign(size_t size, size_t base)
  110.12 -{
  110.13 -    int lo = find_least_set32(base);
  110.14 -    int hi = find_highest_set32(size);
  110.15 -    int res = min(lo, hi);
  110.16 -    return res;
  110.17 -}
  110.18 -#else // !beehive
  110.19  /// Computes the floor of log_2 of the given number
  110.20  static inline uint8_t log2flr(uintptr_t num)
  110.21  {
  110.22 @@ -103,7 +91,6 @@
  110.23      }
  110.24      return((1UL << exponent) > n ? log2flr(n) : exponent);
  110.25  }
  110.26 -#endif
  110.27  
  110.28  /**
  110.29   * Kernel subsystems.
   111.1 --- a/lib/barrelfish/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   111.2 +++ b/lib/barrelfish/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   111.3 @@ -50,9 +50,6 @@
   111.4                                   "vspace/arch/x86_64/layout.c",
   111.5                                   "vspace/memobj_pinned.c", "vspace/pinned.c", "vspace/memobj_anon.c",
   111.6                                   "arch/x86/perfmon.c", "arch/x86/tls.c"]
   111.7 -      archfam_srcs "beehive" = [ "arch/beehive/debug.c", "arch/beehive/dispatch.c",
   111.8 -                              "arch/beehive/pmap_arch.c", "arch/beehive/bmp_chan.c",
   111.9 -                              "vspace/arch/beehive/layout.c"]
  111.10        archfam_srcs "arm"     = [ "arch/arm/debug.c", "arch/arm/dispatch.c", 
  111.11                                   "arch/arm/pmap_arch.c", "arch/arm/sys_debug.c",
  111.12                                   "arch/arm/syscalls.c", "vspace/memobj_pinned.c" ,
  111.13 @@ -64,14 +61,10 @@
  111.14        arch_srcs "scc" = [ "arch/x86/ipi_notify.c" ]
  111.15        arch_srcs "x86_32" = [ "arch/x86/ipi_notify.c" ]
  111.16        arch_srcs "x86_64" = [ "arch/x86/ipi_notify.c" ]
  111.17 -      arch_srcs "beehive" = [ "arch/beehive/dcachergn.c" ]
  111.18        arch_srcs _     = []
  111.19  
  111.20        arch_assembly "x86_32"  = [ "arch/x86_32/entry.S" ]
  111.21        arch_assembly "x86_64"  = [ "arch/x86_64/entry.S" ]
  111.22 -      arch_assembly "beehive" = [ "arch/beehive/cswitch.S" , "arch/beehive/entry.S",
  111.23 -                                  "arch/beehive/dcache.S",
  111.24 -                                  "arch/beehive/syscalls.S", "arch/beehive/findbits.S" ]
  111.25        arch_assembly "arm"     = [ "arch/arm/entry.S", "arch/arm/syscall.S" ]
  111.26        arch_assembly _         = []
  111.27  
   112.1 --- a/lib/barrelfish/arch/beehive/bmp_chan.c	Fri Jan 20 14:32:03 2012 -0800
   112.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   112.3 @@ -1,368 +0,0 @@
   112.4 -/**
   112.5 - * \file
   112.6 - * \brief Bidirectional Beehive messaging channel implementation
   112.7 - */
   112.8 -
   112.9 -/*
  112.10 - * Copyright (c) 2009, 2010, ETH Zurich.
  112.11 - * All rights reserved.
  112.12 - *
  112.13 - * This file is distributed under the terms in the attached LICENSE file.
  112.14 - * If you do not find this file, copies can be found by writing to:
  112.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  112.16 - */
  112.17 -
  112.18 -#include <string.h>
  112.19 -#include <barrelfish/barrelfish.h>
  112.20 -#include <barrelfish/bmp_chan.h>
  112.21 -#include <barrelfish/dispatcher_arch.h>
  112.22 -#include <barrelfish/idc_export.h>
  112.23 -#include "waitset_chan.h"
  112.24 -#include <if/monitor_defs.h>
  112.25 -
  112.26 -#ifndef CONFIG_INTERCONNECT_DRIVER_BMP
  112.27 -#error "This file shouldn't be compiled without CONFIG_INTERCONNECT_DRIVER_BMP"
  112.28 -#endif
  112.29 -
  112.30 -/**
  112.31 - * \brief Initialise a new Beehive channel
  112.32 - *
  112.33 - * Most code should be using one of bmp_chan_bind() or bmp_chan_accept().
  112.34 - *
  112.35 - * \param c Storage for channel state
  112.36 - */
  112.37 -void bmp_chan_init(struct bmp_chan *c)
  112.38 -{
  112.39 -    assert(c != NULL);
  112.40 -
  112.41 -    c->inep = NULL;
  112.42 -    waitset_chanstate_init(&c->send_waitset, CHANTYPE_BMP_OUT);
  112.43 -    memset(&c->cap_handlers, 0, sizeof(c->cap_handlers));
  112.44 -    c->connstate = BMP_DISCONNECTED;
  112.45 -    c->iref = 0;
  112.46 -    c->monitor_binding = get_monitor_binding(); // default
  112.47 -}
  112.48 -
  112.49 -/// Destroy the local state associated with a given channel
  112.50 -void bmp_chan_destroy(struct bmp_chan *c)
  112.51 -{
  112.52 -    USER_PANIC("NYI");
  112.53 -}
  112.54 -
  112.55 -/// Handler for bind reply messages from the Monitor
  112.56 -static void bind_bmp_reply_handler(struct monitor_binding *b, uintptr_t mon_id,
  112.57 -                                   uintptr_t conn_id, struct capref bee_ep,
  112.58 -                                   size_t remote_ep_len, errval_t success)
  112.59 -{
  112.60 -    struct bmp_chan *c = (void *)conn_id;
  112.61 -
  112.62 -    assert(c->connstate == BMP_BIND_WAIT);
  112.63 -
  112.64 -    if (err_is_ok(success)) { /* bind succeeded */
  112.65 -        c->connstate = BMP_CONNECTED;
  112.66 -        c->monitor_id = mon_id;
  112.67 -        c->outepcap = bee_ep;
  112.68 -        c->outeplen = remote_ep_len;
  112.69 -    } else { /* bind failed */
  112.70 -        c->connstate = BMP_DISCONNECTED;
  112.71 -        /* TODO: delete endpoint, destroy local_cap */
  112.72 -    }
  112.73 -
  112.74 -    /* either way, tell the user what happened */
  112.75 -    assert(c->bind_continuation.handler != NULL);
  112.76 -    c->bind_continuation.handler(c->bind_continuation.st, success, c);
  112.77 -}
  112.78 -
  112.79 -struct bind_bmp_reply_state {
  112.80 -    struct monitor_binding *b;
  112.81 -    struct bmp_chan *c;
  112.82 -    uintptr_t monitor_id;
  112.83 -    errval_t bind_success;
  112.84 -    struct event_queue_node qnode;
  112.85 -};
  112.86 -
  112.87 -static void send_bind_reply(void *arg)
  112.88 -{
  112.89 -    struct bind_bmp_reply_state *st = arg;
  112.90 -    struct monitor_binding *b = st->b;
  112.91 -    struct bmp_chan *c = st->c;
  112.92 -    errval_t err;
  112.93 -
  112.94 -    // send back a bind success/failure message to the monitor
  112.95 -    err =
  112.96 -        st->b->tx_vtbl.bind_bmp_reply_monitor(b, NOP_CONT, st->monitor_id,
  112.97 -                                              (uintptr_t)c,
  112.98 -                                              c ? c->inepcap : NULL_CAP,
  112.99 -                                              st->bind_success);
 112.100 -    if (err_is_ok(err)) {
 112.101 -        event_mutex_unlock(&b->mutex);
 112.102 -        free(st);
 112.103 -    } else if (err_no(err) == FLOUNDER_ERR_TX_BUSY) {
 112.104 -        err = st->b->register_send(b, b->waitset, MKCONT(send_bind_reply,st));
 112.105 -        assert(err_is_ok(err)); // shouldn't fail, as we have the mutex
 112.106 -    } else {
 112.107 -        event_mutex_unlock(&b->mutex);
 112.108 -        DEBUG_ERR(err, "failed sending back reply to BMP bind request;"
 112.109 -                       " request dropped!");
 112.110 -        if (c != NULL) {
 112.111 -            bmp_chan_destroy(c);
 112.112 -            // FIXME: how do we tell the binding about this!?
 112.113 -        }
 112.114 -        free(st);
 112.115 -    }
 112.116 -}
 112.117 -
 112.118 -/// Handler for BMP bind request messages from the Monitor
 112.119 -static void bind_bmp_service_request_handler(struct monitor_binding *b,
 112.120 -                                             uintptr_t service_id,
 112.121 -                                             uintptr_t mon_id,
 112.122 -                                             struct capref bee_ep,
 112.123 -                                             size_t remote_ep_len)
 112.124 -{
 112.125 -    struct idc_export *e = (void *)service_id;
 112.126 -    errval_t err;
 112.127 -
 112.128 -    // call the binding's connect handler
 112.129 -    if (e->bmp_connect_callback != NULL) {
 112.130 -        err = e->bmp_connect_callback(e->connect_cb_st, b, mon_id, bee_ep,
 112.131 -                                      remote_ep_len);
 112.132 -    } else {
 112.133 -        err = LIB_ERR_NO_BMP_BIND_HANDLER;
 112.134 -    }
 112.135 -
 112.136 -    if (err_is_fail(err)) {
 112.137 -        bmp_chan_send_bind_reply(b, NULL, err, mon_id);
 112.138 -    } else {
 112.139 -        // binding is responsible for sending reply
 112.140 -    }
 112.141 -}
 112.142 -
 112.143 -void bmp_chan_send_bind_reply(struct monitor_binding *mb,
 112.144 -                              struct bmp_chan *c, errval_t err,
 112.145 -                              uintptr_t monitor_id)
 112.146 -{
 112.147 -    struct bind_bmp_reply_state *st = malloc(sizeof(struct bind_bmp_reply_state));
 112.148 -    assert(st != NULL);
 112.149 -
 112.150 -    if (err_is_ok(err)) {
 112.151 -        assert(c != NULL);
 112.152 -    } else {
 112.153 -        assert(c == NULL);
 112.154 -    }
 112.155 -
 112.156 -    st->b = mb;
 112.157 -    st->c = c;
 112.158 -    st->bind_success = err;
 112.159 -    st->monitor_id = monitor_id;
 112.160 -
 112.161 -    // wait for the ability to use the monitor binding
 112.162 -    event_mutex_enqueue_lock(&mb->mutex, &st->qnode, MKCONT(send_bind_reply, st));
 112.163 -}
 112.164 -
 112.165 -static void send_bind_cont(void *arg)
 112.166 -{
 112.167 -    struct bmp_chan *c = arg;
 112.168 -    struct monitor_binding *b = c->monitor_binding;
 112.169 -    errval_t err;
 112.170 -
 112.171 -    /* Send bind request to the monitor */
 112.172 -    assert(c->monitor_binding == b);
 112.173 -    assert(b->tx_vtbl.bind_bmp_client_request);
 112.174 -    err = b->tx_vtbl.bind_bmp_client_request(b, NOP_CONT, c->iref,
 112.175 -                                             (uintptr_t)c, c->inepcap);
 112.176 -    if (err_is_ok(err)) { // request sent ok
 112.177 -        event_mutex_unlock(&b->mutex);
 112.178 -    } else if (err_no(err) == FLOUNDER_ERR_TX_BUSY) {
 112.179 -        // register to retry
 112.180 -        err = b->register_send(b, b->waitset, MKCONT(send_bind_cont, c));
 112.181 -        assert(err_is_ok(err)); // we hold the monitor binding mutex
 112.182 -    } else { // permanent failure sending message
 112.183 -        event_mutex_unlock(&b->mutex);
 112.184 -        c->bind_continuation.handler(c->bind_continuation.st,
 112.185 -                                     err_push(err, LIB_ERR_BIND_BMP_REQ), NULL);
 112.186 -    }
 112.187 -}
 112.188 -
 112.189 -/**
 112.190 - * \brief Initialise a new BMP channel and initiate a binding
 112.191 - *
 112.192 - * \param c  Storage for channel state
 112.193 - * \param cont Continuation for bind completion/failure
 112.194 - * \param qnode Storage for an event queue node (used for queuing bind request)
 112.195 - * \param iref IREF to which to bind
 112.196 - * \param monitor_binding Monitor binding to use
 112.197 - * \param ep_buflen Length of local endpoint buffer to allocate, in words
 112.198 - */
 112.199 -errval_t bmp_chan_bind(struct bmp_chan *c, struct bmp_bind_continuation cont,
 112.200 -                       struct event_queue_node *qnode,  iref_t iref,
 112.201 -                       struct monitor_binding *monitor_binding,
 112.202 -                       size_t ep_buflen)
 112.203 -{
 112.204 -    errval_t err;
 112.205 -
 112.206 -    // initialise channel state
 112.207 -    bmp_chan_init(c);
 112.208 -
 112.209 -    // store bind args
 112.210 -    c->bind_continuation = cont;
 112.211 -    c->monitor_binding = monitor_binding;
 112.212 -    c->iref = iref;
 112.213 -
 112.214 -    // allocate a local endpoint
 112.215 -    err = endpoint_create(ep_buflen, &c->inepcap, &c->inep);
 112.216 -    if (err_is_fail(err)) {
 112.217 -        return err_push(err, LIB_ERR_ENDPOINT_CREATE);
 112.218 -    }
 112.219 -
 112.220 -    // wait for the ability to use the monitor binding
 112.221 -    c->connstate = BMP_BIND_WAIT;
 112.222 -    event_mutex_enqueue_lock(&monitor_binding->mutex, qnode,
 112.223 -                             MKCONT(send_bind_cont, c));
 112.224 -
 112.225 -    return SYS_ERR_OK;
 112.226 -}
 112.227 -
 112.228 -/**
 112.229 - * \brief Initialise a new BMP channel to accept an incoming binding request
 112.230 - *
 112.231 - * \param c  Storage for channel state
 112.232 - * \param mon_id Monitor's connection ID for this channel
 112.233 - * \param remote_ep Capability to remote endpoint
 112.234 - * \param remot_ep_len Length of local endpoint buffer to allocate, in words
 112.235 - * \param local_ep_len Length of local endpoint buffer to allocate, in words
 112.236 - */
 112.237 -errval_t bmp_chan_accept(struct bmp_chan *c, uintptr_t mon_id,
 112.238 -                         struct capref remote_ep, size_t remote_ep_len,
 112.239 -                         size_t local_ep_len)
 112.240 -{
 112.241 -    errval_t err;
 112.242 -
 112.243 -    bmp_chan_init(c);
 112.244 -    c->monitor_id = mon_id;
 112.245 -    c->outepcap = remote_ep;
 112.246 -    c->outeplen = remote_ep_len;
 112.247 -
 112.248 -    // allocate a local endpoint
 112.249 -    err = endpoint_create(local_ep_len, &c->inepcap, &c->inep);
 112.250 -    if (err_is_fail(err)) {
 112.251 -        return err_push(err, LIB_ERR_ENDPOINT_CREATE);
 112.252 -    }
 112.253 -
 112.254 -    /* mark connected */
 112.255 -    c->connstate = BMP_CONNECTED;
 112.256 -    return SYS_ERR_OK;
 112.257 -}
 112.258 -
 112.259 -/**
 112.260 - * \brief Register an event handler to be notified when messages can be sent
 112.261 - *
 112.262 - * In the future, call the closure on the given waitset when it is likely that
 112.263 - * a message can be sent on the channel. A channel may only be registered
 112.264 - * with a single send event handler on a single waitset at any one time.
 112.265 - *
 112.266 - * \param c BMP channel
 112.267 - * \param ws Waitset
 112.268 - * \param closure Event handler
 112.269 - */
 112.270 -errval_t bmp_chan_register_send(struct bmp_chan *c, struct waitset *ws,
 112.271 -                                 struct event_closure closure)
 112.272 -{
 112.273 -    assert(c != NULL);
 112.274 -    assert(ws != NULL);
 112.275 -
 112.276 -    errval_t err = waitset_chan_register(ws, &c->send_waitset, closure);
 112.277 -    if (err_is_fail(err)) {
 112.278 -        return err;
 112.279 -    }
 112.280 -
 112.281 -    // enqueue in list of channels with a registered event to retry sending
 112.282 -    assert(c->next == NULL && c->prev == NULL);
 112.283 -    dispatcher_handle_t handle = disp_disable();
 112.284 -    struct dispatcher_generic *dp = get_dispatcher_generic(handle);
 112.285 -    if (dp->bmp_send_events_list == NULL) {
 112.286 -        dp->bmp_send_events_list = c;
 112.287 -        c->next = c->prev = c;
 112.288 -    } else {
 112.289 -        c->prev = dp->bmp_send_events_list->prev;
 112.290 -        c->next = dp->bmp_send_events_list;
 112.291 -        c->prev->next = c;
 112.292 -        c->next->prev = c;
 112.293 -    }
 112.294 -    disp_enable(handle);
 112.295 -
 112.296 -    return err;
 112.297 -}
 112.298 -
 112.299 -/**
 112.300 - * \brief Cancel an event registration made with bmp_chan_register_send()
 112.301 - *
 112.302 - * \param lc BMP channel
 112.303 - */
 112.304 -errval_t bmp_chan_deregister_send(struct bmp_chan *c)
 112.305 -{
 112.306 -    assert(c != NULL);
 112.307 -    errval_t err = waitset_chan_deregister(&c->send_waitset);
 112.308 -    if (err_is_fail(err)) {
 112.309 -        return err;
 112.310 -    }
 112.311 -
 112.312 -    // dequeue from list of channels with send events
 112.313 -    assert(c->next != NULL && c->prev != NULL);
 112.314 -    dispatcher_handle_t handle = disp_disable();
 112.315 -    struct dispatcher_generic *dp = get_dispatcher_generic(handle);
 112.316 -    if (c->next == c->prev) {
 112.317 -        assert_disabled(dp->bmp_send_events_list == c);
 112.318 -        dp->bmp_send_events_list = NULL;
 112.319 -    } else {
 112.320 -        c->prev->next = c->next;
 112.321 -        c->next->prev = c->prev;
 112.322 -        if (dp->bmp_send_events_list == c) {
 112.323 -            dp->bmp_send_events_list = c->next;
 112.324 -        }
 112.325 -    }
 112.326 -#ifndef NDEBUG
 112.327 -    c->prev = c->next = NULL;
 112.328 -#endif
 112.329 -
 112.330 -    disp_enable(handle);
 112.331 -    return err;
 112.332 -}
 112.333 -
 112.334 -/**
 112.335 - * \brief Trigger send events for all BMP channels that are registered
 112.336 - *
 112.337 - * We don't have a good way to determine when we are likely to be able
 112.338 - * to send on an BMP channel, so this function just trigger all such
 112.339 - * pending events every time the dispatcher is rescheduled.
 112.340 - *
 112.341 - * Must be called while disabled and from dispatcher logic.
 112.342 - */
 112.343 -void bmp_channels_retry_send_disabled(dispatcher_handle_t handle)
 112.344 -{
 112.345 -    struct dispatcher_generic *dp = get_dispatcher_generic(handle);
 112.346 -    struct bmp_chan *c, *first = dp->bmp_send_events_list, *next;
 112.347 -    errval_t err;
 112.348 -
 112.349 -    for (c = first; c != NULL; c = next) {
 112.350 -        next = c->next;
 112.351 -        assert(next != NULL);
 112.352 -        err = waitset_chan_trigger_disabled(&c->send_waitset, handle);
 112.353 -        assert_disabled(err_is_ok(err)); // shouldn't fail
 112.354 -#ifndef NDEBUG
 112.355 -        c->next = c->prev = NULL;
 112.356 -#endif
 112.357 -        if (next == first) {
 112.358 -            break; // wrapped
 112.359 -        }
 112.360 -    }
 112.361 -
 112.362 -    dp->bmp_send_events_list = NULL;
 112.363 -}
 112.364 -
 112.365 -/// Initialise the Beehive channel driver
 112.366 -void bmp_init(void)
 112.367 -{
 112.368 -    struct monitor_binding *mcb = get_monitor_binding();
 112.369 -    mcb->rx_vtbl.bind_bmp_reply_client = bind_bmp_reply_handler;
 112.370 -    mcb->rx_vtbl.bind_bmp_service_request = bind_bmp_service_request_handler;
 112.371 -}
   113.1 --- a/lib/barrelfish/arch/beehive/cswitch.S	Fri Jan 20 14:32:03 2012 -0800
   113.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   113.3 @@ -1,165 +0,0 @@
   113.4 -/*
   113.5 - * \file
   113.6 - * \brief Provide user context switch code
   113.7 - */
   113.8 -/*
   113.9 - * Copyright (c) 2010 ETH Zurich.
  113.10 - * All rights reserved.
  113.11 - *
  113.12 - * This file is distributed under the terms in the attached LICENSE file.
  113.13 - * If you do not find this file, copies can be found by writing to:
  113.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  113.15 - */
  113.16 -
  113.17 -#ifndef __ASSEMBLER__
  113.18 -#define __ASSEMBLER__   1
  113.19 -#endif
  113.20 -
  113.21 -#include <regconvention.h>
  113.22 -
  113.23 -// ------------------------------------------------------------
  113.24 -
  113.25 -	.code
  113.26 -
  113.27 -/*
  113.28 - * __disp_resume is called only from C disp_resume.  The first argument
  113.29 - * is the context to resume, the second is the address to write to zero
  113.30 - * atomically with the resume.  We can do this on Beehive because
  113.31 - * interrupts are not delivered if the next instruction is a jump.
  113.32 - */
  113.33 -	.globl __disp_resume
  113.34 -__disp_resume:
  113.35 -	ld	$28, 31
  113.36 -	ld	$29, a2
  113.37 -	aqr_ld	link, a1	// entry 0 is RQ count
  113.38 -dr1:	aqr_add	link, link, 4
  113.39 -	sub	$28, $28, 1
  113.40 -	jnz	dr1
  113.41 -	/* debug hack - kill this context by setting pc to zero */
  113.42 -	aqw_ld	void, link
  113.43 -	ld	wq, 0
  113.44 -	// Now load them
  113.45 -	ld	$28, rq		// entry 0 is RQ count
  113.46 -	ld	$1, rq
  113.47 -	ld	$2, rq
  113.48 -	ld	$3, rq
  113.49 -	ld	$4, rq
  113.50 -	ld	$5, rq
  113.51 -	ld	$6, rq
  113.52 -	ld	$7, rq
  113.53 -	ld	$8, rq
  113.54 -	ld	$9, rq
  113.55 -	ld	$10, rq
  113.56 -	ld	$11, rq
  113.57 -	ld	$12, rq
  113.58 -	ld	$13, rq
  113.59 -	ld	$14, rq
  113.60 -	ld	$15, rq
  113.61 -	ld	$16, rq
  113.62 -	ld	$17, rq
  113.63 -	ld	$18, rq
  113.64 -	ld	$19, rq
  113.65 -	ld	$20, rq
  113.66 -	ld	$21, rq
  113.67 -	ld	$22, rq
  113.68 -	ld	$23, rq
  113.69 -	ld	$24, rq
  113.70 -	ld	$25, rq
  113.71 -	ld	$26, rq
  113.72 -	ld	$27, rq
  113.73 -
  113.74 -	/* rq now has r28, r29, link, pc
  113.75 -	 * r28 has rqcount, r29 has addres to zap */
  113.76 -dr2:	sub	$28, $28, 1
  113.77 -	jm	dr3
  113.78 -	aqr_add	link, link, 4
  113.79 -	j	dr2
  113.80 -dr3:
  113.81 -	aqw_add	void, zero, $29	// address to zap
  113.82 -	ld	$28, rq
  113.83 -	ld	$29, rq
  113.84 -	ld	link, rq
  113.85 -	ld	wq, zero	// write 0 to disabled flag
  113.86 -	j	rq
  113.87 -
  113.88 -/*
  113.89 - * __disp_switch is called only from C disp_switch.  It has extremely
  113.90 - * unusual semantics compared to the assembler functions required for
  113.91 - * most operating systems as it combines a variant of setjmp with a resume
  113.92 - */
  113.93 -	.globl __disp_switch
  113.94 -__disp_switch:
  113.95 -	aqw_ld	a2, a2
  113.96 -	ld	wq, zero	// RQ count = 0
  113.97 -	aqw_add	a2, a2, 36	// r9 is first callee save
  113.98 -	ld	t1, 14		// 14 callee save regs plus fp
  113.99 -	aqw_add	a2, a2, 4
 113.100 -	sub	t1, t1, 1
 113.101 -	jnz	.-2
 113.102 -	ld	wq, s1
 113.103 -	ld	wq, s2
 113.104 -	ld	wq, s3
 113.105 -	ld	wq, s4
 113.106 -	ld	wq, s5
 113.107 -	ld	wq, s6
 113.108 -	ld	wq, s7
 113.109 -	ld	wq, s8
 113.110 -	ld	wq, s9
 113.111 -	ld	wq, s10
 113.112 -	ld	wq, s11
 113.113 -	ld	wq, s12
 113.114 -	ld	wq, s13
 113.115 -	ld	wq, s14
 113.116 -	ld	wq, fp
 113.117 -	aqw_add	a2, a2, 16	// skip save for t1, t2, t3
 113.118 -	ld	wq, p1
 113.119 -	aqw_add	a2, a2, 4
 113.120 -	ld	wq, sp
 113.121 -	aqw_add	a2, a2, 12	// skip save for vb and link
 113.122 -	ld	wq, link
 113.123 -
 113.124 -	ld	a2, a3
 113.125 -	long_j	_disp_resume	// NB this is the C version
 113.126 -
 113.127 -/*
 113.128 - * __disp_save is called only from C disp_save.  Saves only voluntary
 113.129 - * state, but in a format suitable for resuming with __disp_resume.
 113.130 - * It works like setjmp/longjump in that it returns a 0 when first called
 113.131 - * and sets the return register in the save area to non-zero.
 113.132 - */
 113.133 -
 113.134 -	.globl __disp_save
 113.135 -__disp_save:
 113.136 -	aqw_ld	a1, a1
 113.137 -	ld	wq, zero	// RQ count = 0
 113.138 -	aqw_add	a1, a1, 4
 113.139 -	orn	wq, zero, zero	// r1 in save area is ~0
 113.140 -	aqw_add	a1, a1, 32	// r9 is first callee save
 113.141 -	ld	t1, 14		// 14 callee save regs plus fp
 113.142 -	aqw_add	a1, a1, 4
 113.143 -	sub	t1, t1, 1
 113.144 -	jnz	.-2
 113.145 -	ld	wq, s1
 113.146 -	ld	wq, s2
 113.147 -	ld	wq, s3
 113.148 -	ld	wq, s4
 113.149 -	ld	wq, s5
 113.150 -	ld	wq, s6
 113.151 -	ld	wq, s7
 113.152 -	ld	wq, s8
 113.153 -	ld	wq, s9
 113.154 -	ld	wq, s10
 113.155 -	ld	wq, s11
 113.156 -	ld	wq, s12
 113.157 -	ld	wq, s13
 113.158 -	ld	wq, s14
 113.159 -	ld	wq, fp
 113.160 -	aqw_add	a1, a1, 16	// skip save for t1, t2, t3
 113.161 -	ld	wq, p1
 113.162 -	aqw_add	a1, a1, 4
 113.163 -	ld	wq, sp
 113.164 -	aqw_add	a1, a1, 12	// skip save for vb and link
 113.165 -	ld	wq, link
 113.166 -
 113.167 -	ld	r1, zero
 113.168 -	j	link
   114.1 --- a/lib/barrelfish/arch/beehive/dcache.S	Fri Jan 20 14:32:03 2012 -0800
   114.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   114.3 @@ -1,50 +0,0 @@
   114.4 -/*
   114.5 - * Copyright (c) 2010, ETH Zurich.
   114.6 - * All rights reserved.
   114.7 - *
   114.8 - * This file is distributed under the terms in the attached LICENSE file.
   114.9 - * If you do not find this file, copies can be found by writing to:
  114.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  114.11 - */
  114.12 -
  114.13 -#include <regconvention.h>
  114.14 -
  114.15 -#if 0 /* inline in dcache.h */
  114.16 -	.code
  114.17 -	.globl _bee_dcache_flush_all
  114.18 -_bee_dcache_flush_all:
  114.19 -	ld	t1,link
  114.20 -	aqw_long_ld vb,0x8001fc03 ROL 2
  114.21 -	j	t1
  114.22 -#endif
  114.23 -
  114.24 -	.globl _bee_dcache_empty_all
  114.25 -_bee_dcache_empty_all:
  114.26 -	ld	t1,link
  114.27 -	/* must avoid context switch between flush and invalidate */
  114.28 -	ld	wq, zero
  114.29 -	aqw_long_ld vb,0x8001fc03 ROL 2
  114.30 -	aqw_long_ld vb,0x8003fc03 ROL 2
  114.31 -	aqw_sub	vb, sp, 4
  114.32 -	j	t1
  114.33 -
  114.34 -#ifndef IN_KERNEL
  114.35 -	.globl _bee_dcache_flush_lines
  114.36 -_bee_dcache_flush_lines:
  114.37 -	lsl	a2, a2, 7
  114.38 -	add_lsl	a1, a2, a1, 5
  114.39 -	aqw_add a1, a1, 0x0E
  114.40 -	j	link
  114.41 -
  114.42 -	.globl _bee_dcache_empty_lines
  114.43 -_bee_dcache_empty_lines:
  114.44 -	lsl	a2, a2, 7
  114.45 -	add_lsl	a1, a2, a1, 5
  114.46 -	/* must avoid context switch between flush and invalidate */
  114.47 -	ld	wq, zero
  114.48 -	aqw_add a1, a1, 0x0E
  114.49 -	lsl	t1, 1, 19 /* invalidate ends up in AQ[17] */
  114.50 -	aqw_add	t1, a1, t1
  114.51 -	aqw_sub	vb, sp, 4
  114.52 -	j	link
  114.53 -#endif
   115.1 --- a/lib/barrelfish/arch/beehive/dcachergn.c	Fri Jan 20 14:32:03 2012 -0800
   115.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   115.3 @@ -1,122 +0,0 @@
   115.4 -/*
   115.5 - * Copyright (c) 2010, ETH Zurich.
   115.6 - * All rights reserved.
   115.7 - *
   115.8 - * This file is distributed under the terms in the attached LICENSE file.
   115.9 - * If you do not find this file, copies can be found by writing to:
  115.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  115.11 - */
  115.12 -
  115.13 -#include <stdlib.h>
  115.14 -#include <dcache.h>
  115.15 -
  115.16 -extern void bee_dcache_flush_lines(size_t line, size_t countless1);
  115.17 -extern void bee_dcache_empty_lines(size_t line, size_t countless1);
  115.18 -
  115.19 -void bee_dcache_flush_rgn (void * addr, size_t n);
  115.20 -void bee_dcache_empty_rgn (void * addr, size_t n);
  115.21 -
  115.22 -void bee_dcache_flush_rgn (void * addr, size_t n)
  115.23 -{
  115.24 -    if (n == 0) return;
  115.25 -
  115.26 -    unsigned int start = (unsigned int)addr;
  115.27 -    unsigned int after = start + n;
  115.28 -
  115.29 -    unsigned int firstline = start >> 5;
  115.30 -    unsigned int lastline = (after - 1) >> 5;
  115.31 -
  115.32 -    unsigned int countlessone = lastline - firstline;
  115.33 -
  115.34 -    if (countlessone >= 127) {
  115.35 -	/*
  115.36 -	 * This command will affect the entire cache,
  115.37 -	 * so just perform the whole cache version.
  115.38 -	 */
  115.39 -	
  115.40 -	bee_dcache_flush_all();
  115.41 -	return;
  115.42 -    }
  115.43 -
  115.44 -    unsigned int firstalias = firstline & 127;
  115.45 -
  115.46 -    /*
  115.47 -     * According to Chuck, a dcache command in which
  115.48 -     * first + count wraps around the cache is illegal.
  115.49 -     * So for such a case, we have to break it up into
  115.50 -     * two dcache commands.
  115.51 -     */
  115.52 -    
  115.53 -    if (firstalias + countlessone > 127) {
  115.54 -	/*
  115.55 -	 * At this point we must have ( firstalias > 0 )
  115.56 -	 * because we know that ( countlessone < 127 )
  115.57 -	 */
  115.58 -	
  115.59 -	unsigned int countlessonexx = 127 - firstalias;
  115.60 -	bee_dcache_flush_lines(firstalias,countlessonexx);
  115.61 -	
  115.62 -	/*
  115.63 -	 * Note that ( countlessone > 127 - firstalias )
  115.64 -	 * therefore ( countlessone > countlessonexx )
  115.65 -	 */
  115.66 -	
  115.67 -	firstalias = 0;
  115.68 -	countlessone -= countlessonexx + 1;
  115.69 -    }
  115.70 -
  115.71 -    bee_dcache_flush_lines(firstalias,countlessone);
  115.72 -}   
  115.73 -
  115.74 -
  115.75 -void bee_dcache_empty_rgn (void * addr, size_t n)
  115.76 -{
  115.77 -    if (n == 0) return;
  115.78 -
  115.79 -    unsigned int start = (unsigned int)addr;
  115.80 -    unsigned int after = start + n;
  115.81 -
  115.82 -    unsigned int firstline = start >> 5;
  115.83 -    unsigned int lastline = (after - 1) >> 5;
  115.84 -
  115.85 -    unsigned int countlessone = lastline - firstline;
  115.86 -
  115.87 -    if (countlessone >= 127) {
  115.88 -	/*
  115.89 -	 * This command will affect the entire cache,
  115.90 -	 * so just perform the whole cache version.
  115.91 -	 */
  115.92 -	
  115.93 -	bee_dcache_empty_all();
  115.94 -	return;
  115.95 -    }
  115.96 -
  115.97 -    unsigned int firstalias = firstline & 127;
  115.98 -
  115.99 -    /*
 115.100 -     * According to Chuck, a dcache command in which
 115.101 -     * first + count wraps around the cache is illegal.
 115.102 -     * So for such a case, we have to break it up into
 115.103 -     * two dcache commands.
 115.104 -     */
 115.105 -    
 115.106 -    if (firstalias + countlessone > 127) {
 115.107 -	/*
 115.108 -	 * At this point we must have ( firstalias > 0 )
 115.109 -	 * because we know that ( countlessone < 127 )
 115.110 -	 */
 115.111 -	
 115.112 -	unsigned int countlessonexx = 127 - firstalias;
 115.113 -	bee_dcache_empty_lines(firstalias,countlessonexx);
 115.114 -	
 115.115 -	/*
 115.116 -	 * Note that ( countlessone > 127 - firstalias )
 115.117 -	 * therefore ( countlessone > countlessonexx )
 115.118 -	 */
 115.119 -	
 115.120 -	firstalias = 0;
 115.121 -	countlessone -= countlessonexx + 1;
 115.122 -    }
 115.123 -
 115.124 -    bee_dcache_empty_lines(firstalias,countlessone);
 115.125 -}   
   116.1 --- a/lib/barrelfish/arch/beehive/debug.c	Fri Jan 20 14:32:03 2012 -0800
   116.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   116.3 @@ -1,78 +0,0 @@
   116.4 -/**
   116.5 - * \file
   116.6 - * \brief Arch specific debugging functions
   116.7 - */
   116.8 -
   116.9 -/*
  116.10 - * Copyright (c) 2010, ETH Zurich.
  116.11 - * All rights reserved.
  116.12 - *
  116.13 - * This file is distributed under the terms in the attached LICENSE file.
  116.14 - * If you do not find this file, copies can be found by writing to:
  116.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  116.16 - */
  116.17 -
  116.18 -#include <stdio.h>
  116.19 -#include <barrelfish/barrelfish.h>
  116.20 -#include <barrelfish/caddr.h>
  116.21 -#include <barrelfish/debug.h>
  116.22 -#include <barrelfish/dispatch.h>
  116.23 -#include <if/monitor_defs.h>
  116.24 -#include <stdarg.h>
  116.25 -#include <stdlib.h>
  116.26 -#include <string.h>
  116.27 -#include <inttypes.h>
  116.28 -
  116.29 -#define NR_OF_DISPLAYED_RET_ADDRS   10
  116.30 -
  116.31 -/**
  116.32 - * \brief Dump out various memory regions and a partial backtrace.
  116.33 - *
  116.34 - * Mainly for debugging traps and faults in the dispatcher handlers.
  116.35 - */
  116.36 -void debug_dump(arch_registers_state_t *archregs)
  116.37 -{
  116.38 -    /* NYI */
  116.39 -}
  116.40 -
  116.41 -static void debug_call_chain_rbp(uintptr_t bp)
  116.42 -{
  116.43 -    uintptr_t ret_addr;
  116.44 -    uintptr_t user_rbp = bp;
  116.45 -
  116.46 -    for (int it = 0; it < NR_OF_DISPLAYED_RET_ADDRS; it++) {
  116.47 -        if (user_rbp < BASE_PAGE_SIZE || (user_rbp % sizeof(uintptr_t)) != 0) {
  116.48 -            break;
  116.49 -        }
  116.50 -	ret_addr = ((uintptr_t *)user_rbp)[1];
  116.51 -	debug_printf("return address = 0x%" PRIxPTR " frame address = 0x%" PRIxPTR "\n",
  116.52 -		     ret_addr, user_rbp);
  116.53 -	user_rbp = ((uintptr_t *)user_rbp)[0];
  116.54 -    }
  116.55 -}
  116.56 -
  116.57 -void debug_call_chain(arch_registers_state_t *archregs)
  116.58 -{
  116.59 -    // TODO: use regs argument
  116.60 -    register uintptr_t fp;
  116.61 -    fp = (uintptr_t)__builtin_frame_address(0);
  116.62 -    debug_printf("current fp = 0x%" PRIxPTR "\n", fp);
  116.63 -    debug_call_chain_rbp(fp);
  116.64 -}
  116.65 -
  116.66 -/**
  116.67 - * \brief Print out the registers in a dispatcher save area, for trap handlers.
  116.68 - */
  116.69 -void debug_print_save_area(arch_registers_state_t *state)
  116.70 -{
  116.71 -    /* NYI */
  116.72 -}
  116.73 -
  116.74 -void debug_return_addresses(void)
  116.75 -{
  116.76 -    debug_printf("return address = %p\n", __builtin_return_address(0));
  116.77 -    debug_printf("return address = %p\n", __builtin_return_address(1));
  116.78 -    debug_printf("return address = %p\n", __builtin_return_address(2));
  116.79 -    debug_printf("return address = %p\n", __builtin_return_address(3));
  116.80 -    debug_printf("return address = %p\n", __builtin_return_address(4));
  116.81 -}
   117.1 --- a/lib/barrelfish/arch/beehive/dispatch.c	Fri Jan 20 14:32:03 2012 -0800
   117.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   117.3 @@ -1,169 +0,0 @@
   117.4 -/**
   117.5 - * \file
   117.6 - * \brief Dispatcher architecture-specific implementation.
   117.7 - */
   117.8 -
   117.9 -/*
  117.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich
  117.11 - * All rights reserved.
  117.12 - *
  117.13 - * This file is distributed under the terms in the attached LICENSE file.
  117.14 - * If you do not find this file, copies can be found by writing to:
  117.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  117.16 - */
  117.17 -
  117.18 -#include <barrelfish/barrelfish.h>
  117.19 -#include <barrelfish/dispatch.h>
  117.20 -#include <barrelfish/dispatcher_arch.h>
  117.21 -#include <barrelfish/curdispatcher_arch.h>
  117.22 -#include <barrelfish/syscalls.h>
  117.23 -#include <threads.h>
  117.24 -
  117.25 -/* entry points defined in assembler code */
  117.26 -extern void run_entry(void);
  117.27 -extern void pagefault_entry(void);
  117.28 -extern void disabled_pagefault_entry(void);
  117.29 -extern void trap_entry(void);
  117.30 -
  117.31 -/* helper functions defined in assembler code */
  117.32 -extern void _disp_resume(union registers_beehive *regs,
  117.33 -			 uint32_t *disabledptr) __attribute__((noreturn));
  117.34 -
  117.35 -// The assembler uses DISP_DISABLED from asmoffsets.c
  117.36 -// so make sure asmoffsets.c is also using dispatcher_shared_generic
  117.37 -extern void _disp_switch(struct dispatcher_shared_generic *disp, 
  117.38 -			 union registers_beehive *from_regs,
  117.39 -			 union registers_beehive *to_regs);
  117.40 -
  117.41 -extern int _disp_save(union registers_beehive *regs) __attribute__((returns_twice));
  117.42 -
  117.43 -#if 0
  117.44 -void __attribute__ ((visibility ("hidden"))) disp_resume_end(void);
  117.45 -#endif
  117.46 -
  117.47 -/**
  117.48 - * \brief Architecture-specific dispatcher initialisation
  117.49 - */
  117.50 -void disp_arch_init(dispatcher_handle_t handle)
  117.51 -{
  117.52 -    struct dispatcher_shared_beehive *disp =
  117.53 -        get_dispatcher_shared_beehive(handle);
  117.54 -
  117.55 -    disp->d.dispatcher_run = (lvaddr_t)run_entry;
  117.56 -    disp->d.dispatcher_pagefault = (lvaddr_t)pagefault_entry;
  117.57 -    disp->d.dispatcher_pagefault_disabled = (lvaddr_t)disabled_pagefault_entry;
  117.58 -    disp->d.dispatcher_trap = (lvaddr_t)trap_entry;
  117.59 -
  117.60 -#if 0
  117.61 -    disp->crit_pc_low = (lvaddr_t)disp_resume;
  117.62 -    disp->crit_pc_high = (lvaddr_t)disp_resume_end;
  117.63 -#endif
  117.64 -}
  117.65 -
  117.66 -/**
  117.67 - * \brief Resume execution of a given register state
  117.68 - *
  117.69 - * This function resumes the execution of the given register state on the
  117.70 - * current dispatcher. It may only be called while the dispatcher is disabled.
  117.71 - *
  117.72 - * \param disp Current dispatcher pointer
  117.73 - * \param regs Register state snapshot
  117.74 - */
  117.75 -void disp_resume(dispatcher_handle_t handle, arch_registers_state_t *archregs)
  117.76 -{
  117.77 -    struct dispatcher_shared_generic *disp =
  117.78 -        get_dispatcher_shared_generic(handle);
  117.79 -
  117.80 -    assert_disabled(disp != NULL);
  117.81 -    assert_disabled(archregs != NULL);
  117.82 -
  117.83 -    assert_disabled(curdispatcher() == handle);
  117.84 -    assert_disabled(disp->disabled);
  117.85 -    assert_disabled(disp->haswork);
  117.86 -
  117.87 -    /* sanity check user state */
  117.88 -    assert_disabled(archregs->named.count <= 64);
  117.89 -    assert_disabled(archregs->named.p1 != 0);
  117.90 -    assert_disabled(archregs->named.stack != 0);
  117.91 -    assert_disabled(archregs->named.pc != 0);
  117.92 -
  117.93 -#ifdef CONFIG_DEBUG_DEADLOCKS
  117.94 -    ((struct disp_priv *)disp)->yieldcount = 0;
  117.95 -#endif
  117.96 -    
  117.97 -    // The assembler does the rest, including atomically
  117.98 -    // clearing the disable flag with restoring the context.
  117.99 -    _disp_resume(archregs, &disp->disabled);
 117.100 -}
 117.101 -
 117.102 -
 117.103 -/**
 117.104 - * \brief Switch execution between two register states
 117.105 - *
 117.106 - * This function saves as much as necessary of the current register state
 117.107 - * (which, when resumed will return to the caller), and switches execution
 117.108 - * by resuming the given register state.  It may only be called while the
 117.109 - * dispatcher is disabled.
 117.110 - *
 117.111 - * \param disp Current dispatcher pointer
 117.112 - * \param from_regs Location to save current register state
 117.113 - * \param to_regs Location from which to resume new register state
 117.114 - */
 117.115 -void disp_switch(dispatcher_handle_t handle, arch_registers_state_t *from_state,
 117.116 -                 arch_registers_state_t *to_state)
 117.117 -{
 117.118 -    assert_disabled(curdispatcher() == handle);
 117.119 -    struct dispatcher_shared_generic *disp =
 117.120 -        get_dispatcher_shared_generic(handle);
 117.121 -    assert_disabled(disp->disabled);
 117.122 -    assert_disabled(disp->haswork);
 117.123 -
 117.124 -    //struct disp_priv *disp_priv = (struct disp_priv *)disp;
 117.125 -    assert_disabled(to_state != NULL);
 117.126 -
 117.127 -    // The assembler does all the rest
 117.128 -    _disp_switch(disp, from_state, to_state);
 117.129 -}
 117.130 -
 117.131 -
 117.132 -/**
 117.133 - * \brief Save the current register state and optionally yield the CPU
 117.134 - *
 117.135 - * This function saves as much as necessary of the current register state
 117.136 - * (which, when resumed will return to the caller), and then either
 117.137 - * re-enters the thread scheduler or yields the CPU.
 117.138 - * It may only be called while the dispatcher is disabled.
 117.139 - *
 117.140 - * \param disp Current dispatcher pointer
 117.141 - * \param regs Location to save current register state
 117.142 - * \param yield If true, yield CPU to kernel; otherwise re-run thread scheduler
 117.143 - * \param yield_to Endpoint capability for dispatcher to which we want to yield
 117.144 - */
 117.145 -void disp_save(dispatcher_handle_t handle, arch_registers_state_t *state,
 117.146 -               bool yield, caddr_t yield_to)
 117.147 -{
 117.148 -    assert_disabled(curdispatcher() == handle);
 117.149 -    struct dispatcher_shared_generic *disp =
 117.150 -        get_dispatcher_shared_generic(handle);
 117.151 -    assert_disabled(disp->disabled);
 117.152 -
 117.153 -    // Save resume IP, stack and control registers
 117.154 -    // See disp_switch above for details
 117.155 -
 117.156 -    if (_disp_save(state) != 0) {
 117.157 -	return;
 117.158 -    }
 117.159 -
 117.160 -    if (yield) {
 117.161 -        sys_yield(yield_to);
 117.162 -        // may fail if target doesn't exist; if so, just fall through
 117.163 -    }
 117.164 -    // this code won't run if the yield succeeded
 117.165 -
 117.166 -    // enter thread scheduler again
 117.167 -    // this doesn't return, and will call disp_yield if there's nothing to do
 117.168 -    thread_run_disabled(handle);
 117.169 -#if 0
 117.170 -    __asm volatile ("save_resume:");
 117.171 -#endif
 117.172 -}
   118.1 --- a/lib/barrelfish/arch/beehive/entry.S	Fri Jan 20 14:32:03 2012 -0800
   118.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   118.3 @@ -1,69 +0,0 @@
   118.4 -/**
   118.5 - * \file
   118.6 - * \brief Dispatcher entry points.
   118.7 - */
   118.8 -
   118.9 -/*
  118.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
  118.11 - * All rights reserved.
  118.12 - *
  118.13 - * This file is distributed under the terms in the attached LICENSE file.
  118.14 - * If you do not find this file, copies can be found by writing to:
  118.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  118.16 - */
  118.17 -
  118.18 -#ifndef __ASSEMBLER__
  118.19 -#define __ASSEMBLER__
  118.20 -#endif /* __ASSEMBLER__ */
  118.21 -
  118.22 -#include <barrelfish/dispatch.h>
  118.23 -#include <regconvention.h>
  118.24 -#include <asmoffsets.h>
  118.25 -
  118.26 -#ifndef OFFSETOF_DISP_PRIV_STACK_LIMIT
  118.27 -#error "No OFFSETOF_DISP_PRIV_STACK_LIMIT"
  118.28 -#endif
  118.29 -#ifndef OFFSETOF_DISP_PRIV_TRAP_STACK_LIMIT
  118.30 -#error "No OFFSETOF_DISP_PRIV_TRAP_STACK_LIMIT"
  118.31 -#endif
  118.32 -
  118.33 -//
  118.34 -// void run_entry(struct disp_priv* p)
  118.35 -//
  118.36 -	.globl _run_entry
  118.37 -_run_entry:
  118.38 -	x_lli	OFFSETOF_DISP_PRIV_STACK_LIMIT
  118.39 -	add	sp, link, p1
  118.40 -	ld	a1, p1
  118.41 -	long_call _disp_run
  118.42 -	j	.
  118.43 -
  118.44 -//
  118.45 -// void pagefault_entry(disp ptr, vaddr_t fault_addr, uintptr_t error, vaddr_t pc)
  118.46 -//
  118.47 -	.globl _pagefault_entry
  118.48 -_pagefault_entry:
  118.49 -	x_lli	OFFSETOF_DISP_PRIV_STACK_LIMIT
  118.50 -	add	sp, link, p1
  118.51 -	long_call _disp_pagefault
  118.52 -	j	.
  118.53 -
  118.54 -//
  118.55 -// void disabled_pagefault_entry(disp ptr, vaddr_t fault_addr, uintptr_t error, vaddr_t pc)
  118.56 -//
  118.57 -	.globl _disabled_pagefault_entry
  118.58 -_disabled_pagefault_entry:
  118.59 -	x_lli	OFFSETOF_DISP_PRIV_TRAP_STACK_LIMIT
  118.60 -	add	sp, link, p1
  118.61 -	long_call _disp_pagefault_disabled
  118.62 -	j	.
  118.63 -
  118.64 -//
  118.65 -// void trap_entry(disp ptr, uintptr_t irq, uintptr_t error, vaddr_t pc)
  118.66 -//
  118.67 -	.globl _trap_entry
  118.68 -_trap_entry:
  118.69 -	x_lli	OFFSETOF_DISP_PRIV_TRAP_STACK_LIMIT
  118.70 -	add	sp, link, p1
  118.71 -	long_call _disp_trap
  118.72 -	j	.
   119.1 --- a/lib/barrelfish/arch/beehive/findbits.S	Fri Jan 20 14:32:03 2012 -0800
   119.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   119.3 @@ -1,116 +0,0 @@
   119.4 -/*
   119.5 - * Copyright (c) 2010 ETH Zurich.
   119.6 - * All rights reserved.
   119.7 - *
   119.8 - * This file is distributed under the terms in the attached LICENSE file.
   119.9 - * If you do not find this file, copies can be found by writing to:
  119.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  119.11 - */
  119.12 -
  119.13 -#ifndef __ASSEMBLER__
  119.14 -#define __ASSEMBLER__   1
  119.15 -#endif
  119.16 -
  119.17 -#include <regconvention.h>
  119.18 -
  119.19 -// ------------------------------------------------------------
  119.20 -
  119.21 -	.code
  119.22 -
  119.23 -	.globl	_find_least_clear32
  119.24 -	.globl	_find_least_set32
  119.25 -_find_least_clear32:
  119.26 -	xorn	a1, a1, zero
  119.27 -_find_least_set32:
  119.28 -	ld	r1, 0
  119.29 -	ld	void, a1
  119.30 -flsjoin:jz	minusone
  119.31 -	lsl	void, a1, 16
  119.32 -	jnz	.+3
  119.33 -	lsr	a1, a1, 16
  119.34 -	add	r1, r1, 16
  119.35 -	and	void, a1, 0xff
  119.36 -	jnz	.+3
  119.37 -	lsr	a1, a1, 8
  119.38 -	add	r1, r1, 8
  119.39 -	and	void, a1, 0x0f
  119.40 -	jnz	.+3
  119.41 -	lsr	a1, a1, 4
  119.42 -	add	r1, r1, 4
  119.43 -	and	void, a1, 0x03
  119.44 -	jnz	.+3
  119.45 -	lsr	a1, a1, 2
  119.46 -	add	r1, r1, 2
  119.47 -	and	void, a1, 0x01
  119.48 -	jnz	link
  119.49 -	add	r1, r1, 1
  119.50 -	j	link
  119.51 -minusone:
  119.52 -	xorn	r1, zero, zero
  119.53 -	j	link
  119.54 -
  119.55 -	.globl	_find_least_clear64
  119.56 -	.globl	_find_least_set64
  119.57 -_find_least_clear64:
  119.58 -	xorn	a1, a1, zero
  119.59 -	xorn	a2, a2, zero
  119.60 -_find_least_set64:
  119.61 -	ld	void, a1
  119.62 -	jnz	_find_least_set32
  119.63 -	ld	r1, 32
  119.64 -	ld	a1, a2
  119.65 -	j	flsjoin
  119.66 -		
  119.67 -
  119.68 -	.globl	_find_highest_clear32
  119.69 -	.globl	_find_highest_set32
  119.70 -_find_highest_clear32:
  119.71 -	xorn	a1, a1, zero
  119.72 -_find_highest_set32:
  119.73 -	ld	r1, 31
  119.74 -	ld	void, a1
  119.75 -fhsjoin:jz	minusone
  119.76 -	lsr	void, a1, 16
  119.77 -	jnz	.+3
  119.78 -	sub	r1, r1, 16
  119.79 -	lsl	a1, a1, 16
  119.80 -	lsr	void, a1, 24
  119.81 -	jnz	.+3
  119.82 -	sub	r1, r1, 8
  119.83 -	lsl	a1, a1, 8
  119.84 -	lsr	void, a1, 28
  119.85 -	jnz	.+3
  119.86 -	sub	r1, r1, 4
  119.87 -	lsl	a1, a1, 4
  119.88 -	lsr	void, a1, 30
  119.89 -	jnz	.+3
  119.90 -	sub	r1, r1, 2
  119.91 -	lsl	a1, a1, 2
  119.92 -	lsr	a1, a1, 31
  119.93 -	jnz	link
  119.94 -	sub	r1, r1, 1
  119.95 -	j	link
  119.96 -
  119.97 -
  119.98 -	.globl	_find_highest_clear64
  119.99 -	.globl	_find_highest_set64
 119.100 -_find_highest_clear64:
 119.101 -	xorn	a1, a1, zero
 119.102 -	xorn	a2, a2, zero
 119.103 -_find_highest_set64:
 119.104 -	ld	void, a2
 119.105 -	jz	_find_highest_set32
 119.106 -	ld	a1, a2
 119.107 -	ld	r1, 63
 119.108 -	j	fhsjoin
 119.109 -
 119.110 -
 119.111 -	.globl	_population_count
 119.112 -_population_count:
 119.113 -	ld	r1, 0
 119.114 -	ld	void, a1
 119.115 -	jz	link
 119.116 -	add	r1, r1, 1
 119.117 -	sub	t1, a1, 1
 119.118 -	and	a1, a1, t1
 119.119 -	j	.-4
   120.1 --- a/lib/barrelfish/arch/beehive/pmap_arch.c	Fri Jan 20 14:32:03 2012 -0800
   120.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   120.3 @@ -1,204 +0,0 @@
   120.4 -/**
   120.5 - * \file
   120.6 - * \brief pmap management
   120.7 - * \buf Not implemented
   120.8 - */
   120.9 -
  120.10 -/*
  120.11 - * Copyright (c) 2010, ETH Zurich.
  120.12 - * All rights reserved.
  120.13 - *
  120.14 - * This file is distributed under the terms in the attached LICENSE file.
  120.15 - * If you do not find this file, copies can be found by writing to:
  120.16 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  120.17 - */
  120.18 -
  120.19 -#include <barrelfish/barrelfish.h>
  120.20 -#include <barrelfish/caddr.h>
  120.21 -#include <stdio.h>
  120.22 -#include <inttypes.h>
  120.23 -#include <dcache.h>
  120.24 -
  120.25 -#define PMAP_DEBUG if (0) debug_printf
  120.26 - 
  120.27 -/**
  120.28 - * \brief Create page mappings
  120.29 - *
  120.30 - * \param pmap     The pmap object
  120.31 - * \param vaddr    The virtual address to create the mapping for
  120.32 - * \param frame    The frame cap to map in
  120.33 - * \param offset   Offset into the frame cap
  120.34 - * \param size     Size of the mapping
  120.35 - * \param flags    Flags for the mapping
  120.36 - * \param retoff   If non-NULL, filled in with adjusted offset of mapped region
  120.37 - * \param retsize  If non-NULL, filled in with adjusted size of mapped region
  120.38 - */
  120.39 -static errval_t map(struct pmap *pmap, genvaddr_t vaddr, struct capref frame,
  120.40 -                    size_t offset, size_t size, vregion_flags_t flags,
  120.41 -                    size_t *retoff, size_t *retsize)
  120.42 -{
  120.43 -    PMAP_DEBUG("pmap_beehive.c map: vaddr=%" PRIxGENVADDR
  120.44 -               " offset=%zu size=%zu flags=%" PRIuVREGIONFLAGS "\n",
  120.45 -               vaddr, offset, size, flags);
  120.46 -
  120.47 -    errval_t err;
  120.48 -    struct frame_identity id;
  120.49 -    err = invoke_frame_identify(frame, &id);
  120.50 -    if (err_is_fail(err))
  120.51 -	return err;
  120.52 -
  120.53 -    PMAP_DEBUG("pmap_beehive.c map: id.base=%" PRIxGENPADDR
  120.54 -               " id.bits=%u (0x%zx)\n", 
  120.55 -               id.base, id.bits, ((size_t)1) << id.bits);
  120.56 -    
  120.57 -    if (offset != 0 || size != (1<<id.bits) || id.base != vaddr) {
  120.58 -        PMAP_DEBUG("BAD map() call: offset %x size %x base %"
  120.59 -                   PRIxGENPADDR" vaddr %"PRIxGENVADDR"\n",
  120.60 -                   offset, size, id.base, vaddr);
  120.61 -	return LIB_ERR_NOT_IMPLEMENTED;
  120.62 -    }
  120.63 -
  120.64 -    if (retoff != NULL) *retoff = offset;
  120.65 -    if (retsize != NULL) *retsize = size;
  120.66 -    return SYS_ERR_OK;
  120.67 -}
  120.68 -
  120.69 -
  120.70 -/**
  120.71 - * \brief Remove page mappings
  120.72 - *
  120.73 - * \param pmap     The pmap object
  120.74 - * \param vaddr    The start of the virtual addres to remove
  120.75 - * \param size     The size of virtual address to remove
  120.76 - * \param retsize  If non-NULL, filled in with the actual size removed
  120.77 - */
  120.78 -static errval_t unmap(struct pmap *pmap, genvaddr_t vaddr, size_t size,
  120.79 -                      size_t *retsize)
  120.80 -{
  120.81 -    // XXX: This will flush the entire cache to memory
  120.82 -    bee_dcache_flush_all();
  120.83 -
  120.84 -    if (retsize) {
  120.85 -        *retsize = size;
  120.86 -    }
  120.87 -    return SYS_ERR_OK;
  120.88 -}
  120.89 -
  120.90 -/**
  120.91 - * \brief Determine a suitable address for a given memory object
  120.92 - *
  120.93 - * \param pmap    The pmap object
  120.94 - * \param memobj  The memory object to determine the address for
  120.95 - * \param alignment Minimum alignment
  120.96 - * \param vaddr   Pointer to return the determined address
  120.97 - *
  120.98 - * Relies on vspace.c code maintaining an ordered list of vregions
  120.99 - */
 120.100 -static errval_t determine_addr(struct pmap *pmap, struct memobj *memobj,
 120.101 -                               size_t alignment, genvaddr_t *vaddr)
 120.102 -{
 120.103 -    struct frame_identity id = {0, 0};
 120.104 -    errval_t err;
 120.105 -
 120.106 -    assert(memobj->type == ONE_FRAME ||
 120.107 -           memobj->type == ONE_FRAME_ONE_MAP);
 120.108 -
 120.109 -    assert(alignment == 0); // XXX: unsupported
 120.110 -
 120.111 -    if (memobj->type == ONE_FRAME) {
 120.112 -        struct memobj_one_frame *mof;
 120.113 -        mof = (struct memobj_one_frame*)memobj;
 120.114 -        err = invoke_frame_identify(mof->frame, &id);
 120.115 -    } else {
 120.116 -        struct memobj_one_frame_one_map *mofom;
 120.117 -        mofom = (struct memobj_one_frame_one_map*)memobj;
 120.118 -        err = invoke_frame_identify(mofom->frame, &id);
 120.119 -    } 
 120.120 -    if (err_is_fail(err)) {
 120.121 -        return err;
 120.122 -    }
 120.123 -
 120.124 -    *vaddr = id.base;
 120.125 -
 120.126 -    return SYS_ERR_OK;
 120.127 -}
 120.128 -
 120.129 -/**
 120.130 - * \brief Modify page mapping
 120.131 - *
 120.132 - * \param pmap     The pmap object
 120.133 - * \param vaddr    The virtual address to unmap
 120.134 - * \param flags    New flags for the mapping
 120.135 - * \param retsize  If non-NULL, filled in with the actual size modified
 120.136 - */
 120.137 -static errval_t modify_flags(struct pmap *pmap, genvaddr_t vaddr, size_t size,
 120.138 -                             vregion_flags_t flags, size_t *retsize)
 120.139 -{
 120.140 -    USER_PANIC("NYI");
 120.141 -    return LIB_ERR_NOT_IMPLEMENTED;
 120.142 -}
 120.143 -
 120.144 -/**
 120.145 - * \brief Query existing page mapping
 120.146 - *
 120.147 - * \param pmap     The pmap object
 120.148 - * \param vaddr    The virtual address to query
 120.149 - * \param retvaddr Returns the base virtual address of the mapping
 120.150 - * \param retsize  Returns the actual size of the mapping
 120.151 - * \param retcap   Returns the cap mapped at this address
 120.152 - * \param retoffset Returns the offset within the cap that is mapped
 120.153 - * \param retflags Returns the flags for this mapping
 120.154 - *
 120.155 - * All of the ret parameters are optional.
 120.156 - */
 120.157 -static errval_t lookup(struct pmap *pmap, genvaddr_t vaddr,
 120.158 -                       genvaddr_t *retvaddr, size_t *retsize,
 120.159 -                       struct capref *retcap, genvaddr_t *retoffset,
 120.160 -                       vregion_flags_t *retflags)
 120.161 -{
 120.162 -    USER_PANIC("NYI");
 120.163 -    return 0;
 120.164 -}
 120.165 -
 120.166 -
 120.167 -static errval_t serialise(struct pmap *pmap, void *buf, size_t buflen)
 120.168 -{
 120.169 -    // Unimplemented: ignored
 120.170 -    return SYS_ERR_OK;
 120.171 -}
 120.172 -
 120.173 -static errval_t deserialise(struct pmap *pmap, void *buf, size_t buflen)
 120.174 -{
 120.175 -    // Unimplemented: noop for beehive
 120.176 -    return SYS_ERR_OK;
 120.177 -}
 120.178 -
 120.179 -static struct pmap_funcs pmap_funcs = {
 120.180 -    .determine_addr = determine_addr,
 120.181 -    .map = map,
 120.182 -    .unmap = unmap,
 120.183 -    .modify_flags = modify_flags,
 120.184 -    .lookup = lookup,
 120.185 -    .serialise = serialise,
 120.186 -    .deserialise = deserialise,
 120.187 -};
 120.188 -
 120.189 -/**
 120.190 - * \brief Initialize the pmap object
 120.191 - */
 120.192 -errval_t pmap_init(struct pmap *pmap, struct vspace *vspace,
 120.193 -                   struct capref vnode, struct slot_allocator *opt_slot_alloc)
 120.194 -{
 120.195 -    /* Generic portion */
 120.196 -    pmap->f = pmap_funcs;
 120.197 -    pmap->vspace = vspace;
 120.198 -
 120.199 -    /* Will need some architecture specific code here */
 120.200 -
 120.201 -    return SYS_ERR_OK;
 120.202 -}
 120.203 -
 120.204 -errval_t pmap_current_init(bool init_domain)
 120.205 -{
 120.206 -    return SYS_ERR_OK;
 120.207 -}
   121.1 --- a/lib/barrelfish/arch/beehive/syscalls.S	Fri Jan 20 14:32:03 2012 -0800
   121.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   121.3 @@ -1,87 +0,0 @@
   121.4 -/**
   121.5 - * \file
   121.6 - * \brief Dispatcher entry points.
   121.7 - */
   121.8 -
   121.9 -/*
  121.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
  121.11 - * All rights reserved.
  121.12 - *
  121.13 - * This file is distributed under the terms in the attached LICENSE file.
  121.14 - * If you do not find this file, copies can be found by writing to:
  121.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  121.16 - */
  121.17 -
  121.18 -#ifndef __ASSEMBLER__
  121.19 -#define __ASSEMBLER__
  121.20 -#endif /* __ASSEMBLER__ */
  121.21 -
  121.22 -#include <regconvention.h>
  121.23 -#include <beej7.h>
  121.24 -#include <barrelfish_kpi/syscalls.h>
  121.25 -#include <asmoffsets.h>
  121.26 -
  121.27 -/*
  121.28 - * extern errval_t sys_yield(caddr_t target);
  121.29 - */
  121.30 -	.globl _sys_yield
  121.31 -_sys_yield:
  121.32 -	ld	t2, link
  121.33 -	j7	BEE_J7_COREAREA
  121.34 -	aqr_add	vb, link, OFFSETOF_COREAREA_SYSCALL
  121.35 -	ld	link, t2	
  121.36 -	ld	t1, SYSCALL_YIELD
  121.37 -	j	rq
  121.38 -
  121.39 -/*
  121.40 - * extern errval_t sys_nop(void);
  121.41 - */
  121.42 -	.globl _sys_nop
  121.43 -_sys_nop:
  121.44 -	ld	t2, link
  121.45 -	j7	BEE_J7_COREAREA
  121.46 -	aqr_add	vb, link, OFFSETOF_COREAREA_SYSCALL
  121.47 -	ld	link, t2	
  121.48 -	ld	t1, SYSCALL_NOP
  121.49 -	j	rq
  121.50 -
  121.51 -/*
  121.52 - * extern errval_t sys_print(const char *string, size_t length);
  121.53 - */
  121.54 -	.globl _sys_print
  121.55 -_sys_print:
  121.56 -	ld	t2, link
  121.57 -	j7	BEE_J7_COREAREA
  121.58 -	aqr_add	vb, link, OFFSETOF_COREAREA_SYSCALL
  121.59 -	ld	link, t2	
  121.60 -	ld	t1, SYSCALL_PRINT
  121.61 -	j	rq
  121.62 -
  121.63 -/*
  121.64 - * extern errval_t sys_invoke(uintptr_t *const pvalue,
  121.65 - *	uint8_t invokebits,
  121.66 - *	caddr_t invokecptr,
  121.67 - *	struct idc_send_msg *const msg);
  121.68 - */
  121.69 -	.globl _sys_invoke
  121.70 -_sys_invoke:
  121.71 -	ld	t2, link
  121.72 -	j7	BEE_J7_COREAREA
  121.73 -	aqr_add	vb, link, OFFSETOF_COREAREA_SYSCALL
  121.74 -	ld	link, t2	
  121.75 -	ld	t1, SYSCALL_INVOKE
  121.76 -	j	rq
  121.77 -
  121.78 -/*
  121.79 - * extern errval_r sys_rundown(void);
  121.80 - */
  121.81 -	.globl _sys_rundown
  121.82 -_sys_rundown:
  121.83 -	ld	t2, link
  121.84 -	j7	BEE_J7_COREAREA
  121.85 -	aqr_add	vb, link, OFFSETOF_COREAREA_SYSCALL
  121.86 -	ld	link, t2	
  121.87 -	ld	t1, SYSCALL_BEEHIVE_TRACE_RUNDOWN
  121.88 -	j	rq
  121.89 -
  121.90 -/* End */
   122.1 --- a/lib/barrelfish/arch/beehive/syscalls.c	Fri Jan 20 14:32:03 2012 -0800
   122.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   122.3 @@ -1,54 +0,0 @@
   122.4 -/**
   122.5 - * \file
   122.6 - * \brief User-side system call implementation
   122.7 - */
   122.8 -
   122.9 -/*
  122.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich
  122.11 - * All rights reserved.
  122.12 - *
  122.13 - * This file is distributed under the terms in the attached LICENSE file.
  122.14 - * If you do not find this file, copies can be found by writing to:
  122.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  122.16 - */
  122.17 -
  122.18 -#include <barrelfish/barrelfish.h>
  122.19 -#include <barrelfish/caddr.h>
  122.20 -#include <barrelfish/dispatch.h>
  122.21 -#include <barrelfish/syscall_arch.h>
  122.22 -
  122.23 -/* For documentation on system calls see include/barrelfish/syscalls.h
  122.24 - */
  122.25 -
  122.26 -#error "you should have compiled syscall.S instead"
  122.27 -
  122.28 -errval_t sys_yield(caddr_t target)
  122.29 -{
  122.30 -    // This is painful, perhaps we should just write it all in assembler
  122.31 -    struct sysret retval;
  122.32 -    __asm volatile("ld r1,%0\n\t"
  122.33 -		   "ld r3,%1\n\t"
  122.34 -		   "ld t1," __XSTRING(SYSCALL_YIELD) "\n\t"
  122.35 -		   "long_call 0x1009"
  122.36 -		   : /* no outputs */
  122.37 -		   : "r" (&retval), "r" (target)
  122.38 -		   : /* clobbers */ "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "t1", "t2", "t3", "vb", "link", "cc");
  122.39 -    return retval.error;
  122.40 -    // return syscall(SYSCALL_YIELD, target).error;
  122.41 -}
  122.42 -
  122.43 -errval_t sys_print(const char *string, size_t length)
  122.44 -{
  122.45 -    // This is painful, perhaps we should just write it all in assembler
  122.46 -    struct sysret retval;
  122.47 -    __asm volatile("ld r1,%0\n\t"
  122.48 -		   "ld r3,%1\n\t"
  122.49 -		   "ld r4,%2\n\t"
  122.50 -		   "ld t1," __XSTRING(SYSCALL_PRINT) "\n\t"
  122.51 -		   "long_call 0x1009"
  122.52 -		   : /* no outputs */
  122.53 -		   : "r" (&retval), "r" (string), "r" (length)
  122.54 -		   : /* clobbers */ "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "t1", "t2", "t3", "vb", "link", "cc");
  122.55 -    return retval.error;
  122.56 -    // return syscall(SYSCALL_PRINT, (uintptr_t)string, length).error;
  122.57 -}
   123.1 --- a/lib/barrelfish/capabilities.c	Fri Jan 20 14:32:03 2012 -0800
   123.2 +++ b/lib/barrelfish/capabilities.c	Mon Jan 23 11:04:15 2012 -0800
   123.3 @@ -84,12 +84,6 @@
   123.4      .slot  = TASKCN_SLOT_IRQ
   123.5  };
   123.6  
   123.7 -/// Capability for BMP table
   123.8 -struct capref cap_bmptable = {
   123.9 -    .cnode = TASK_CNODE_INIT,
  123.10 -    .slot  = TASKCN_SLOT_BMP_TABLE
  123.11 -};
  123.12 -
  123.13  /// Capability for legacy IO
  123.14  struct capref cap_io = {
  123.15      .cnode = TASK_CNODE_INIT,
   124.1 --- a/lib/barrelfish/deferred.c	Fri Jan 20 14:32:03 2012 -0800
   124.2 +++ b/lib/barrelfish/deferred.c	Mon Jan 23 11:04:15 2012 -0800
   124.3 @@ -23,15 +23,8 @@
   124.4  
   124.5  #include "waitset_chan.h"
   124.6  
   124.7 -// this macro hides two kludges:
   124.8 -//  1. the kernel currently reports time in ms rather than us
   124.9 -//  2. Beehive is apparently incapable of multiplying a 64-bit value by 1000
  124.10 -//  (internal compiler error: in simplify_const_unary_operation, at simplify-rtx.c:1108)
  124.11 -#ifdef __BEEHIVE__
  124.12 -#define SYSTIME_MULTIPLIER 1
  124.13 -#else
  124.14 +// kludge: the kernel currently reports time in ms rather than us
  124.15  #define SYSTIME_MULTIPLIER 1000
  124.16 -#endif
  124.17  
  124.18  static void update_wakeup_disabled(dispatcher_handle_t dh)
  124.19  {
   125.1 --- a/lib/barrelfish/dispatch.c	Fri Jan 20 14:32:03 2012 -0800
   125.2 +++ b/lib/barrelfish/dispatch.c	Mon Jan 23 11:04:15 2012 -0800
   125.3 @@ -30,10 +30,6 @@
   125.4  # include <barrelfish/lmp_chan.h>
   125.5  #endif
   125.6  
   125.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   125.8 -# include <barrelfish/bmp_chan.h>
   125.9 -#endif
  125.10 -
  125.11  #ifdef FPU_LAZY_CONTEXT_SWITCH
  125.12  #  include <arch/fpu.h>
  125.13  #endif
  125.14 @@ -100,11 +96,6 @@
  125.15      lmp_channels_retry_send_disabled(handle);
  125.16  #endif // CONFIG_INTERCONNECT_DRIVER_LMP
  125.17  
  125.18 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
  125.19 -    // Trigger any send events for BMP channels
  125.20 -    bmp_channels_retry_send_disabled(handle);
  125.21 -#endif // CONFIG_INTERCONNECT_DRIVER_BMP
  125.22 -
  125.23      // Run, saving state of previous thread if required
  125.24      thread_run_disabled(handle);
  125.25  
   126.1 --- a/lib/barrelfish/domain.c	Fri Jan 20 14:32:03 2012 -0800
   126.2 +++ b/lib/barrelfish/domain.c	Mon Jan 23 11:04:15 2012 -0800
   126.3 @@ -1035,7 +1035,6 @@
   126.4      return &disp->core_state.vspace_state.vspace;
   126.5  }
   126.6  
   126.7 -#ifndef __BEEHIVE__ // XXX: Implement arch specific domain.c
   126.8  /**
   126.9   * \brief Returns a pointer to the current pinned state on the dispatcher priv
  126.10   */
  126.11 @@ -1045,7 +1044,6 @@
  126.12      struct dispatcher_generic* disp = get_dispatcher_generic(handle);
  126.13      return &disp->core_state.pinned_state;
  126.14  }
  126.15 -#endif
  126.16  
  126.17  /**
  126.18   * \brief Returns a pointer to the current pmap on the dispatcher priv
   127.1 --- a/lib/barrelfish/flounder_support.c	Fri Jan 20 14:32:03 2012 -0800
   127.2 +++ b/lib/barrelfish/flounder_support.c	Mon Jan 23 11:04:15 2012 -0800
   127.3 @@ -128,7 +128,7 @@
   127.4      }
   127.5  }
   127.6  
   127.7 -#if defined(CONFIG_INTERCONNECT_DRIVER_UMP) || defined(CONFIG_INTERCONNECT_DRIVER_BMP)
   127.8 +#if defined(CONFIG_INTERCONNECT_DRIVER_UMP)
   127.9  static void flounder_stub_cap_state_init(struct flounder_cap_state *s, void *binding)
  127.10  {
  127.11      s->tx_cap_ack = false;
  127.12 @@ -138,7 +138,7 @@
  127.13      s->rx_capnum = 0;
  127.14      s->binding = binding;
  127.15  }
  127.16 -#endif // UMP || BMP
  127.17 +#endif // UMP
  127.18  
  127.19  static uintptr_t getword(const uint8_t *buf, size_t *pos, size_t len)
  127.20  {
  127.21 @@ -474,139 +474,3 @@
  127.22  }
  127.23  
  127.24  #endif // CONFIG_INTERCONNECT_DRIVER_UMP
  127.25 -
  127.26 -
  127.27 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
  127.28 -
  127.29 -#include <flounder/flounder_support_bmp.h>
  127.30 -
  127.31 -void flounder_stub_bmp_state_init(struct flounder_bmp_state *s, void *binding)
  127.32 -{
  127.33 -    s->sent_id = 0;
  127.34 -    s->seq_id = 0;
  127.35 -    s->ack_id = 0;
  127.36 -    s->last_ack = 0;
  127.37 -    flounder_stub_cap_state_init(&s->capst, binding);
  127.38 -}
  127.39 -
  127.40 -errval_t flounder_stub_bmp_send_buf(struct flounder_bmp_state *s,
  127.41 -                                    int msgnum, const void *bufp,
  127.42 -                                    size_t len, size_t *pos)
  127.43 -{
  127.44 -    const uint8_t *buf = bufp;
  127.45 -    uintptr_t msg[BMP_MSG_LENGTH];
  127.46 -    errval_t err;
  127.47 -
  127.48 -    do {
  127.49 -        // store initial position for retry
  127.50 -        size_t restartpos = *pos;
  127.51 -
  127.52 -        // get header
  127.53 -        msg[0] = flounder_stub_bmp_mkheader(s, msgnum);
  127.54 -
  127.55 -        int msgpos;
  127.56 -        // is this the start of the string?
  127.57 -        if (*pos == 0) {
  127.58 -            // if so, send the length in the next word
  127.59 -            msg[1] = len;
  127.60 -            msgpos = 2;
  127.61 -        } else {
  127.62 -            // otherwise use it for payload
  127.63 -            msgpos = 1;
  127.64 -        }
  127.65 -
  127.66 -        // fill message payload
  127.67 -        for (; msgpos < BMP_MSG_LENGTH && *pos < len; msgpos++) {
  127.68 -            msg[msgpos] = getword(buf, pos, len);
  127.69 -        }
  127.70 -
  127.71 -        // can we send this message?
  127.72 -        if (!flounder_stub_bmp_can_send(s, msgpos)) {
  127.73 -            *pos = restartpos;
  127.74 -            return FLOUNDER_ERR_BUF_SEND_MORE;
  127.75 -        }
  127.76 -
  127.77 -        // try to send
  127.78 -        err = flounder_stub_bmp_send(s, msg, msgpos);
  127.79 -        if (err_is_fail(err)) {
  127.80 -            *pos = restartpos;
  127.81 -            return err;
  127.82 -        }
  127.83 -    } while (*pos < len);
  127.84 -
  127.85 -    // we're done. zero out our state for the next send
  127.86 -    assert(*pos == len);
  127.87 -    *pos = 0;
  127.88 -
  127.89 -    return SYS_ERR_OK;
  127.90 -}
  127.91 -
  127.92 -errval_t flounder_stub_bmp_recv_buf(struct bmp_recv_msg *msg,
  127.93 -                                    void **bufp, size_t *len, size_t *pos)
  127.94 -{
  127.95 -    int msgpos;
  127.96 -
  127.97 -    if (msg->buf.msglen < 1) {
  127.98 -        return FLOUNDER_ERR_RX_INVALID_LENGTH;
  127.99 -    }
 127.100 -
 127.101 -    // is this the first fragment?
 127.102 -    // if so, unmarshall the length and allocate a buffer
 127.103 -    if (*pos == 0) {
 127.104 -        *len = msg->words[1];
 127.105 -        if (*len == 0) {
 127.106 -            *bufp = NULL;
 127.107 -        } else {
 127.108 -            *bufp = malloc(*len);
 127.109 -            if (*bufp == NULL) {
 127.110 -                return LIB_ERR_MALLOC_FAIL;
 127.111 -            }
 127.112 -        }
 127.113 -
 127.114 -        // skip header
 127.115 -        msgpos = 2;
 127.116 -    } else {
 127.117 -        msgpos = 1;
 127.118 -    }
 127.119 -
 127.120 -    uint8_t *buf = *bufp;
 127.121 -
 127.122 -    // copy remainder of fragment to buffer
 127.123 -    for (; msgpos < msg->buf.msglen && *pos < *len; msgpos++) {
 127.124 -        putword(msg->words[msgpos], buf, pos, *len);
 127.125 -    }
 127.126 -
 127.127 -    // are we done?
 127.128 -    if (*pos < *len) {
 127.129 -        return FLOUNDER_ERR_BUF_RECV_MORE;
 127.130 -    } else {
 127.131 -        // reset state for next buffer
 127.132 -        *pos = 0;
 127.133 -        return SYS_ERR_OK;
 127.134 -    }
 127.135 -}
 127.136 -
 127.137 -errval_t flounder_stub_bmp_send_string(struct flounder_bmp_state *s,
 127.138 -                                       int msgnum, const char *str,
 127.139 -                                       size_t *pos, size_t *len)
 127.140 -{
 127.141 -    // compute length, if this is the first call
 127.142 -    if (*pos == 0) {
 127.143 -        if (str == NULL) {
 127.144 -            *len = 0;
 127.145 -        } else {
 127.146 -            // send the '\0', making it easy to reuse the buffer code
 127.147 -            *len = strlen(str) + 1;
 127.148 -        }
 127.149 -    }
 127.150 -
 127.151 -    return flounder_stub_bmp_send_buf(s, msgnum, str, *len, pos);
 127.152 -}
 127.153 -
 127.154 -errval_t flounder_stub_bmp_recv_string(struct bmp_recv_msg *msg,
 127.155 -                                       char **strp, size_t *pos, size_t *len)
 127.156 -{
 127.157 -    return flounder_stub_bmp_recv_buf(msg, (void **)strp, len, pos);
 127.158 -}
 127.159 -
 127.160 -#endif // CONFIG_INTERCONNECT_DRIVER_BMP
   128.1 --- a/lib/barrelfish/idc.c	Fri Jan 20 14:32:03 2012 -0800
   128.2 +++ b/lib/barrelfish/idc.c	Mon Jan 23 11:04:15 2012 -0800
   128.3 @@ -25,9 +25,6 @@
   128.4  #ifdef CONFIG_INTERCONNECT_DRIVER_UMP
   128.5      ump_init();
   128.6  #endif
   128.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   128.8 -    bmp_init();
   128.9 -#endif
  128.10  #if defined(CONFIG_FLOUNDER_BACKEND_UMP_IPI)
  128.11      ipi_init();
  128.12  #endif
   129.1 --- a/lib/barrelfish/include/arch/beehive/arch/registers.h	Fri Jan 20 14:32:03 2012 -0800
   129.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   129.3 @@ -1,45 +0,0 @@
   129.4 -/**
   129.5 - * \file
   129.6 - * \brief architecture-specific registers code
   129.7 - */
   129.8 -
   129.9 -/*
  129.10 - * Copyright (c) 2010, ETH Zurich.
  129.11 - * All rights reserved.
  129.12 - *
  129.13 - * This file is distributed under the terms in the attached LICENSE file.
  129.14 - * If you do not find this file, copies can be found by writing to:
  129.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  129.16 - */
  129.17 -
  129.18 -#ifndef ARCH_BEEHIVE_BARRELFISH_REGISTERS_H
  129.19 -#define ARCH_BEEHIVE_BARRELFISH_REGISTERS_H
  129.20 -
  129.21 -#include <barrelfish/curdispatcher_arch.h> // XXX For curdispatcher()
  129.22 -#include <threads.h>
  129.23 -
  129.24 -static inline void
  129.25 -registers_set_initial(arch_registers_state_t *regs, struct thread *thread,
  129.26 -                      lvaddr_t entry, lvaddr_t stack, uint32_t arg1,
  129.27 -                      uint32_t arg2, uint32_t arg3, uint32_t arg4)
  129.28 -{
  129.29 -    regs->named.count = 0;
  129.30 -    regs->named.arg1 = arg1;
  129.31 -    regs->named.arg2 = arg2;
  129.32 -    regs->named.arg3 = arg3;
  129.33 -    regs->named.arg4 = arg4;
  129.34 -    regs->named.stack = stack;
  129.35 -    regs->named.frame = 0;
  129.36 -    regs->named.p1 = (uintptr_t)curdispatcher(); // XXX API bug means this must be run same-core
  129.37 -    regs->named.pc = entry;
  129.38 -}
  129.39 -
  129.40 -static inline bool
  129.41 -registers_is_stack_invalid(struct dispatcher_generic *disp_gen,
  129.42 -                             arch_registers_state_t *archregs)
  129.43 -{
  129.44 -  return archregs->named.stack > (lvaddr_t)disp_gen->current->stack ||
  129.45 -    archregs->named.stack <= (lvaddr_t)disp_gen->current->stack_top;
  129.46 -}
  129.47 -
  129.48 -#endif // ARCH_BEEHIVE_BARRELFISH_REGISTERS_H
   130.1 --- a/lib/barrelfish/include/arch/beehive/arch/syscall.h	Fri Jan 20 14:32:03 2012 -0800
   130.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   130.3 @@ -1,24 +0,0 @@
   130.4 -/**
   130.5 - * \file
   130.6 - * \brief User-side system call implementation
   130.7 - */
   130.8 -
   130.9 -/*
  130.10 - * Copyright (c) 2007, 2008, 2009, ETH Zurich.
  130.11 - * All rights reserved.
  130.12 - *
  130.13 - * This file is distributed under the terms in the attached LICENSE file.
  130.14 - * If you do not find this file, copies can be found by writing to:
  130.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  130.16 - */
  130.17 -#ifndef LIBBARRELFISH_ARCH_SYSCALL_H
  130.18 -#define LIBBARRELFISH_ARCH_SYSCALL_H
  130.19 -
  130.20 -// Implemented in assembler
  130.21 -extern struct sysret syscall1(uintptr_t a);
  130.22 -extern struct sysret syscall2(uintptr_t a, uintptr_t b);
  130.23 -extern struct sysret syscall3(uintptr_t a, uintptr_t b, uintptr_t c);
  130.24 -extern struct sysret syscall4(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d);
  130.25 -extern struct sysret syscall5(uintptr_t a, uintptr_t b, uintptr_t c, uintptr_t d, uintptr_t e);
  130.26 -
  130.27 -#endif
   131.1 --- a/lib/barrelfish/include/arch/beehive/arch/threads.h	Fri Jan 20 14:32:03 2012 -0800
   131.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   131.3 @@ -1,35 +0,0 @@
   131.4 -/**
   131.5 - * \file
   131.6 - * \brief Threads architecture-specific code
   131.7 - */
   131.8 -
   131.9 -/*
  131.10 - * Copyright (c) 2009, ETH Zurich
  131.11 - * All rights reserved.
  131.12 - *
  131.13 - * This file is distributed under the terms in the attached LICENSE file.
  131.14 - * If you do not find this file, copies can be found by writing to:
  131.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  131.16 - */
  131.17 -
  131.18 -#ifndef LIBBARRELFISH_ARCH_THREADS_H
  131.19 -#define LIBBARRELFISH_ARCH_THREADS_H
  131.20 -
  131.21 -#if 0
  131.22 -/**
  131.23 - * Returns true iff the thread with the given save area has successfully
  131.24 - * performed a syscall. Used for the thread_invoke_cap_and_exit() hack.
  131.25 - */
  131.26 -static inline bool thread_check_syscall_succeeded(uintptr_t *save_area)
  131.27 -{
  131.28 -    assert(!"thread_check_syscall_succeeded: called");
  131.29 -    abort();
  131.30 -#if 0
  131.31 -    return ((save_area[PC_REG] == (vaddr_t)barrelfish_cap_invoke_post_syscall_instr
  131.32 -             || save_area[PC_REG] == (vaddr_t)barrelfish_lrpc_post_syscall_instr)
  131.33 -            && save_area[RAX_REG] == 0);
  131.34 -#endif
  131.35 -}
  131.36 -#endif
  131.37 -
  131.38 -#endif // LIBBARRELFISH_ARCH_THREADS_H
   132.1 --- a/lib/barrelfish/include/threads.h	Fri Jan 20 14:32:03 2012 -0800
   132.2 +++ b/lib/barrelfish/include/threads.h	Mon Jan 23 11:04:15 2012 -0800
   132.3 @@ -86,9 +86,6 @@
   132.4  #ifdef CONFIG_INTERCONNECT_DRIVER_LMP
   132.5              || disp->lmp_send_events_list != NULL
   132.6  #endif
   132.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   132.8 -            || disp->bmp_send_events_list != NULL
   132.9 -#endif
  132.10              ;
  132.11  }
  132.12  
   133.1 --- a/lib/barrelfish/init.c	Fri Jan 20 14:32:03 2012 -0800
   133.2 +++ b/lib/barrelfish/init.c	Mon Jan 23 11:04:15 2012 -0800
   133.3 @@ -31,15 +31,7 @@
   133.4  #include "init.h"
   133.5  
   133.6  /// Are we the init domain (and thus need to take some special paths)?
   133.7 -#ifdef __BEEHIVE__
   133.8 -// We dont have ELF to mess with entry points, so we rely on
   133.9 -// initialisation domains to initialise this global symbol; if they dont
  133.10 -// it will end up in as a common symbol in the bss and hence zero.
  133.11 -bool __barrelfish_initialisation_domain;
  133.12 -#define init_domain __barrelfish_initialisation_domain
  133.13 -#else
  133.14  static bool init_domain;
  133.15 -#endif
  133.16  
  133.17  extern size_t (*_libc_terminal_read_func)(char *, size_t);
  133.18  extern size_t (*_libc_terminal_write_func)(const char *, size_t);
  133.19 @@ -119,24 +111,13 @@
  133.20          return SYS_ERR_OK;
  133.21      }
  133.22  
  133.23 -#ifdef __BEEHIVE__ // whatever SAS is called
  133.24 -    struct frame_identity id = { .base = 0, .bits = 0 };
  133.25 -    err = invoke_frame_identify(cap, &id);
  133.26 -    if (err_is_fail(err)) {
  133.27 -	DEBUG_ERR(err, "frame_identify failed");
  133.28 -	return err;
  133.29 -    }
  133.30 -    // TODO: XXX Here be many bugs; should do some kind of mapping?
  133.31 -    trace_buffer_master = id.base;
  133.32 -#else
  133.33      err = vspace_map_one_frame((void**)&trace_buffer_master, TRACE_BUF_SIZE,
  133.34                                 cap, NULL, NULL);
  133.35      if (err_is_fail(err)) {
  133.36          DEBUG_ERR(err, "vspace_map_one_frame failed");
  133.37          return err;
  133.38      }
  133.39 -#endif
  133.40 -    assert(err_is_ok(err));
  133.41 +
  133.42      trace_buffer_va = trace_buffer_master +
  133.43          (disp_get_core_id() * TRACE_PERCORE_BUF_SIZE);
  133.44  
  133.45 @@ -307,14 +288,6 @@
  133.46   * setup. We can't call anything that needs to be enabled (ie. cap invocations)
  133.47   * or uses threads. This is called from crt0.
  133.48   */
  133.49 -#ifdef __BEEHIVE__
  133.50 -void barrelfish_init_disabled(dispatcher_handle_t handle);
  133.51 -void barrelfish_init_disabled(dispatcher_handle_t handle)
  133.52 -{
  133.53 -    disp_init_disabled(handle);
  133.54 -    thread_init_disabled(handle, init_domain);
  133.55 -}
  133.56 -#else
  133.57  void barrelfish_init_disabled(dispatcher_handle_t handle, bool init_dom_arg);
  133.58  void barrelfish_init_disabled(dispatcher_handle_t handle, bool init_dom_arg)
  133.59  {
  133.60 @@ -322,4 +295,3 @@
  133.61      disp_init_disabled(handle);
  133.62      thread_init_disabled(handle, init_dom_arg);
  133.63  }
  133.64 -#endif
   134.1 --- a/lib/barrelfish/morecore.c	Fri Jan 20 14:32:03 2012 -0800
   134.2 +++ b/lib/barrelfish/morecore.c	Mon Jan 23 11:04:15 2012 -0800
   134.3 @@ -20,10 +20,8 @@
   134.4  /// Amount of virtual space for malloc
   134.5  #ifdef __x86_64__
   134.6  #       define HEAP_REGION (2UL * 1024 * 1024 * 1024) /* 2GB */
   134.7 -#elif defined(__i386__) || defined(__arm__) || defined(__BEEHIVE__)
   134.8 +#else
   134.9  #       define HEAP_REGION (512UL * 1024 * 1024) /* 512MB */
  134.10 -#else
  134.11 -#       error "HEAP_REGION needs to be defined for this system."
  134.12  #endif
  134.13  
  134.14  typedef void *(*morecore_alloc_func_t)(size_t bytes, size_t *retbytes);
   135.1 --- a/lib/barrelfish/spawn_client.c	Fri Jan 20 14:32:03 2012 -0800
   135.2 +++ b/lib/barrelfish/spawn_client.c	Mon Jan 23 11:04:15 2012 -0800
   135.3 @@ -43,11 +43,10 @@
   135.4  /* XXX: utility function that doesn't really belong here */
   135.5  const char *cpu_type_to_archstr(enum cpu_type cpu_type)
   135.6  {
   135.7 -    STATIC_ASSERT(CPU_TYPE_NUM == 5, "knowledge of all CPU types here");
   135.8 +    STATIC_ASSERT(CPU_TYPE_NUM == 4, "knowledge of all CPU types here");
   135.9      switch(cpu_type) {
  135.10      case CPU_X86_64:    return "x86_64";
  135.11      case CPU_X86_32:    return "x86_32";
  135.12 -    case CPU_BEEHIVE:   return "beehive";
  135.13      case CPU_SCC:       return "scc";
  135.14      case CPU_ARM:       return "arm";
  135.15      default:            USER_PANIC("cpu_type_to_pathstr: %d unknown", cpu_type);
   136.1 --- a/lib/barrelfish/vspace/arch/beehive/layout.c	Fri Jan 20 14:32:03 2012 -0800
   136.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   136.3 @@ -1,29 +0,0 @@
   136.4 -/**
   136.5 - * \file
   136.6 - * \brief
   136.7 - */
   136.8 -
   136.9 -/*
  136.10 - * Copyright (c) 2010, ETH Zurich.
  136.11 - * All rights reserved.
  136.12 - *
  136.13 - * This file is distributed under the terms in the attached LICENSE file.
  136.14 - * If you do not find this file, copies can be found by writing to:
  136.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  136.16 - */
  136.17 -
  136.18 -#include <barrelfish/barrelfish.h>
  136.19 -#include "../../vspace_internal.h"
  136.20 -
  136.21 -/**
  136.22 - * \brief Initialize the x86_32 layout
  136.23 - */
  136.24 -errval_t vspace_layout_init(struct vspace_layout *l)
  136.25 -{
  136.26 -    l->offset = 0;
  136.27 -    l->granularity = BASE_PAGE_SIZE;
  136.28 -    // XXX: Copied size from kernel/offsets.h.
  136.29 -    //Layout is not used in the tree yet so does not matter yet.
  136.30 -    l->size = (genvaddr_t)1 << 31;
  136.31 -    return SYS_ERR_OK;
  136.32 -}
   137.1 --- a/lib/barrelfish/vspace/memobj_anon.c	Fri Jan 20 14:32:03 2012 -0800
   137.2 +++ b/lib/barrelfish/vspace/memobj_anon.c	Mon Jan 23 11:04:15 2012 -0800
   137.3 @@ -372,10 +372,6 @@
   137.4  {
   137.5      struct memobj *memobj = &anon->m;
   137.6  
   137.7 -#ifdef NOTRANS
   137.8 -    assert(!"Cannot be used for MMUs with no translation ability");
   137.9 -#endif
  137.10 -
  137.11      /* Generic portion */
  137.12      memobj->f.map_region   = map_region;
  137.13      memobj->f.unmap_region = unmap_region;
   138.1 --- a/lib/barrelfish/vspace/memobj_pinned.c	Fri Jan 20 14:32:03 2012 -0800
   138.2 +++ b/lib/barrelfish/vspace/memobj_pinned.c	Mon Jan 23 11:04:15 2012 -0800
   138.3 @@ -175,10 +175,6 @@
   138.4  {
   138.5      struct memobj *memobj = &pinned->m;
   138.6  
   138.7 -#ifdef NOTRANS
   138.8 -    assert(!"Cannot be used for MMUs with no translation ability");
   138.9 -#endif
  138.10 -
  138.11      /* Generic portion */
  138.12      memobj->f.map_region   = map_region;
  138.13      memobj->f.unmap_region = unmap_region;
   139.1 --- a/lib/barrelfish/vspace/mmu_aware.c	Fri Jan 20 14:32:03 2012 -0800
   139.2 +++ b/lib/barrelfish/vspace/mmu_aware.c	Mon Jan 23 11:04:15 2012 -0800
   139.3 @@ -27,7 +27,7 @@
   139.4   *
   139.5   * \param state   The struct to initialize
   139.6   * \param init    The buffer to use to initialize the struct
   139.7 - * \param size    The size of anon memobj to create (Not needed for NOTRANS MMU)
   139.8 + * \param size    The size of anon memobj to create
   139.9   *
  139.10   * Initializes the struct according to the type of MMU
  139.11   */
  139.12 @@ -36,12 +36,6 @@
  139.13      state->size = size;
  139.14      state->consumed = 0;
  139.15  
  139.16 -#ifdef NOTRANS
  139.17 -    state->head = &state->init_list;
  139.18 -    state->head->next = NULL;
  139.19 -    state->memobj = (struct memobj*)&state->init_memobj;
  139.20 -
  139.21 -#else
  139.22      errval_t err;
  139.23  
  139.24      size = ROUND_UP(size, BASE_PAGE_SIZE);
  139.25 @@ -58,7 +52,6 @@
  139.26      }
  139.27      state->offset = state->mapoffset = 0;
  139.28  
  139.29 -#endif
  139.30      return SYS_ERR_OK;
  139.31  }
  139.32  
  139.33 @@ -82,52 +75,6 @@
  139.34  {
  139.35      errval_t err;
  139.36  
  139.37 -#ifdef NOTRANS
  139.38 -    // Create frame of appropriate size
  139.39 -    size_t blocksize = sizeof(struct memobj_one_frame_one_map) +
  139.40 -        sizeof(struct vspace_mmu_vregion_list);
  139.41 -    size_t size = req_size + blocksize;
  139.42 -
  139.43 -    err = frame_create(frame, size, &size);
  139.44 -    if (err_is_fail(err)) {
  139.45 -        return err_push(err, LIB_ERR_FRAME_CREATE);
  139.46 -    }
  139.47 -
  139.48 -    if (state->consumed + size - blocksize > state->size) {
  139.49 -        err = cap_delete(frame);
  139.50 -        if (err_is_fail(err)) {
  139.51 -            debug_err(__FILE__, __func__, __LINE__, err,
  139.52 -                      "cap_delete failed");
  139.53 -        }
  139.54 -        return LIB_ERR_VSPACE_MMU_AWARE_NO_SPACE;
  139.55 -    }
  139.56 -
  139.57 -    // Map it in
  139.58 -    err = vspace_map_one_frame_one_map((struct memobj_one_frame_one_map*)state->memobj,
  139.59 -                                       &state->head->vregion, size, frame);
  139.60 -    if (err_is_fail(err)) {
  139.61 -        return err_push(err, LIB_ERR_VSPACE_MAP);
  139.62 -    }
  139.63 -
  139.64 -    // Reserve memory for next memobj and vregion
  139.65 -    struct memobj *memobj = (void*)(lvaddr_t)vregion_get_base_addr(&state->head->vregion);
  139.66 -    struct vspace_mmu_vregion_list *walk =
  139.67 -        (void*)(lvaddr_t)(vregion_get_base_addr(&state->head->vregion) +
  139.68 -                          sizeof(struct memobj_one_frame_one_map));
  139.69 -
  139.70 -    // Buffer to return
  139.71 -    *retbuf = (void*)(lvaddr_t)(vregion_get_base_addr(&state->head->vregion) +
  139.72 -                                sizeof(struct memobj_one_frame_one_map) +
  139.73 -                                sizeof(struct vspace_mmu_vregion_list));
  139.74 -    *retsize = size - blocksize;
  139.75 -    state->consumed += *retsize;
  139.76 -
  139.77 -    // Reserve space for next growth
  139.78 -    state->memobj  = memobj;
  139.79 -    walk->next = state->head;
  139.80 -    state->head = walk;
  139.81 -
  139.82 -#else
  139.83      // Calculate how much still to map in
  139.84      size_t origsize = req_size;
  139.85      assert(state->mapoffset >= state->offset);
  139.86 @@ -181,18 +128,12 @@
  139.87      state->offset = state->mapoffset;
  139.88      state->consumed += req_size;
  139.89  
  139.90 -#endif
  139.91      return SYS_ERR_OK;
  139.92  }
  139.93  
  139.94  errval_t vspace_mmu_aware_unmap(struct vspace_mmu_aware *state,
  139.95                                  lvaddr_t base, size_t bytes)
  139.96  {
  139.97 -#ifdef NOTRANS
  139.98 -    // Not implemented on Beehive
  139.99 -    return LIB_ERR_NOT_IMPLEMENTED;
 139.100 -
 139.101 -#else
 139.102      errval_t err;
 139.103      struct capref frame;
 139.104      genvaddr_t gvaddr = vregion_get_base_addr(&state->vregion) + state->offset;
 139.105 @@ -241,5 +182,4 @@
 139.106      }
 139.107  
 139.108      return SYS_ERR_OK;
 139.109 -#endif
 139.110  }
   140.1 --- a/lib/barrelfish/vspace/utils.c	Fri Jan 20 14:32:03 2012 -0800
   140.2 +++ b/lib/barrelfish/vspace/utils.c	Mon Jan 23 11:04:15 2012 -0800
   140.3 @@ -47,7 +47,6 @@
   140.4      return SYS_ERR_OK;
   140.5  }
   140.6  
   140.7 -#ifndef NOTRANS
   140.8  /// Map with an alignment constraint
   140.9  errval_t vspace_map_anon_aligned(void **retaddr, struct memobj **ret_memobj,
  140.10                                   struct vregion **ret_vregion, size_t size,
  140.11 @@ -177,7 +176,6 @@
  140.12      }
  140.13      return err1;
  140.14  }
  140.15 -#endif
  140.16  
  140.17  /**
  140.18   * \brief Wrapper for creating and mapping a memory object of type one frame
   141.1 --- a/lib/barrelfish/vspace/vspace.c	Fri Jan 20 14:32:03 2012 -0800
   141.2 +++ b/lib/barrelfish/vspace/vspace.c	Mon Jan 23 11:04:15 2012 -0800
   141.3 @@ -58,13 +58,11 @@
   141.4          return err_push(err, LIB_ERR_PMAP_CURRENT_INIT);
   141.5      }
   141.6  
   141.7 -#ifndef NOTRANS // Pinned memory only supported for MMUs with translation
   141.8      // Initialize pinned memory
   141.9      err = vspace_pinned_init();
  141.10      if (err_is_fail(err)) {
  141.11          return err_push(err, LIB_ERR_VSPACE_PINNED_INIT);
  141.12      }
  141.13 -#endif
  141.14  
  141.15      return SYS_ERR_OK;
  141.16  }
   142.1 --- a/lib/bench/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   142.2 +++ b/lib/bench/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   142.3 @@ -15,7 +15,6 @@
   142.4  
   142.5       arch_srcs "x86_32"  = [ "arch/x86/bench_arch.c" ]
   142.6       arch_srcs "x86_64"  = [ "arch/x86/bench_arch.c" ]
   142.7 -     arch_srcs "beehive" = [ "arch/beehive/bench_arch.c" ]
   142.8       arch_srcs "arm"     = [ "arch/arm/bench_arch.c" ]
   142.9       arch_srcs _         = []
  142.10    in
   143.1 --- a/lib/bench/arch/beehive/bench_arch.c	Fri Jan 20 14:32:03 2012 -0800
   143.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   143.3 @@ -1,22 +0,0 @@
   143.4 -/**
   143.5 - * \file
   143.6 - * \brief Bench library initialization.
   143.7 - */
   143.8 -
   143.9 -/*
  143.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
  143.11 - * All rights reserved.
  143.12 - *
  143.13 - * This file is distributed under the terms in the attached LICENSE file.
  143.14 - * If you do not find this file, copies can be found by writing to:
  143.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  143.16 - */
  143.17 -
  143.18 -#include <barrelfish/barrelfish.h>
  143.19 -#include <bench/bench.h>
  143.20 -#include <bench/bench_arch.h>
  143.21 -
  143.22 -void bench_arch_init(void)
  143.23 -{
  143.24 -    /* nop */
  143.25 -}
   144.1 --- a/lib/c/src/arch-beehive/jmp.S	Fri Jan 20 14:32:03 2012 -0800
   144.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   144.3 @@ -1,117 +0,0 @@
   144.4 -/*
   144.5 - * Copyright (c) 2009, ETH Zurich.
   144.6 - * All rights reserved.
   144.7 - *
   144.8 - * This file is distributed under the terms in the attached LICENSE file.
   144.9 - * If you do not find this file, copies can be found by writing to:
  144.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  144.11 - */
  144.12 -
  144.13 -#include <regconvention.h>
  144.14 -
  144.15 -	.globl	_setjmp
  144.16 -	.globl	_longjmp
  144.17 -
  144.18 -/* These are currently organised so that a stop cleanly cannot
  144.19 - * stop in the middle of save/restore, by keeping the queues
  144.20 - * nonempty.
  144.21 - */
  144.22 -
  144.23 -_setjmp:
  144.24 -	// 17 addresses
  144.25 -	aqw_add	a1, a1, 0
  144.26 -	
  144.27 -	aqw_add a1, a1, 4
  144.28 -	aqw_add a1, a1, 4
  144.29 -	aqw_add a1, a1, 4
  144.30 -	aqw_add a1, a1, 4
  144.31 -	
  144.32 -	aqw_add a1, a1, 4
  144.33 -	aqw_add a1, a1, 4
  144.34 -	aqw_add a1, a1, 4
  144.35 -	aqw_add a1, a1, 4
  144.36 -	
  144.37 -	aqw_add a1, a1, 4
  144.38 -	aqw_add a1, a1, 4
  144.39 -	aqw_add a1, a1, 4
  144.40 -	aqw_add a1, a1, 4
  144.41 -	
  144.42 -	aqw_add a1, a1, 4
  144.43 -	aqw_add a1, a1, 4
  144.44 -	aqw_add a1, a1, 4
  144.45 -	aqw_add a1, a1, 4
  144.46 -	// 17 stores
  144.47 -	ld	wq, s1
  144.48 -	ld	wq, s2
  144.49 -	ld	wq, s3
  144.50 -	ld	wq, s4
  144.51 -	
  144.52 -	ld	wq, s5
  144.53 -	ld	wq, s6
  144.54 -	ld	wq, s7
  144.55 -	ld	wq, s8
  144.56 -	
  144.57 -	ld	wq, s9
  144.58 -	ld	wq, s10
  144.59 -	ld	wq, s11
  144.60 -	ld	wq, s12
  144.61 -	
  144.62 -	ld	wq, s13
  144.63 -	ld	wq, s14
  144.64 -	ld	wq, fp
  144.65 -	ld	wq, sp
  144.66 -	
  144.67 -	ld	wq, link
  144.68 -	ld	r1, 0
  144.69 -	j	link
  144.70 -
  144.71 -lj0:	ld	a2, 1
  144.72 -_longjmp:
  144.73 -	// return value
  144.74 -	ld	r1, a2
  144.75 -	jz	lj0
  144.76 -
  144.77 -	// 17 addresses
  144.78 -	aqr_add	a1, a1, 0
  144.79 -	
  144.80 -	aqr_add a1, a1, 4
  144.81 -	aqr_add a1, a1, 4
  144.82 -	aqr_add a1, a1, 4
  144.83 -	aqr_add a1, a1, 4
  144.84 -
  144.85 -	aqr_add a1, a1, 4
  144.86 -	aqr_add a1, a1, 4
  144.87 -	aqr_add a1, a1, 4
  144.88 -	aqr_add a1, a1, 4
  144.89 -	
  144.90 -	aqr_add a1, a1, 4
  144.91 -	aqr_add a1, a1, 4
  144.92 -	aqr_add a1, a1, 4
  144.93 -	aqr_add a1, a1, 4
  144.94 -	
  144.95 -	aqr_add a1, a1, 4
  144.96 -	aqr_add a1, a1, 4
  144.97 -	aqr_add a1, a1, 4
  144.98 -	aqr_add a1, a1, 4
  144.99 -	// 17 loads
 144.100 -	ld	s1, rq
 144.101 -	ld	s2, rq
 144.102 -	ld	s3, rq
 144.103 -	ld	s4, rq
 144.104 -	
 144.105 -	ld	s5, rq
 144.106 -	ld	s6, rq
 144.107 -	ld	s7, rq
 144.108 -	ld	s8, rq
 144.109 -	
 144.110 -	ld	s9, rq
 144.111 -	ld	s10, rq
 144.112 -	ld	s11, rq
 144.113 -	ld	s12, rq
 144.114 -	
 144.115 -	ld	s13, rq
 144.116 -	ld	s14, rq
 144.117 -	ld	fp, rq
 144.118 -	ld	sp, rq
 144.119 -
 144.120 -	j	rq
   145.1 --- a/lib/c/src/gdtoa/beehive/arith.h	Fri Jan 20 14:32:03 2012 -0800
   145.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   145.3 @@ -1,17 +0,0 @@
   145.4 -/*
   145.5 - * MD header for contrib/gdtoa
   145.6 - *
   145.7 - * $FreeBSD$
   145.8 - */
   145.9 -
  145.10 -/*
  145.11 - * NOTE: The definitions in this file must be correct or strtod(3) and
  145.12 - * floating point formats in printf(3) will break!  The file can be
  145.13 - * generated by running contrib/gdtoa/arithchk.c on the target
  145.14 - * architecture.  See contrib/gdtoa/gdtoaimp.h for details.
  145.15 - */
  145.16 -
  145.17 -// XXX These are guesses
  145.18 -#define IEEE_8087
  145.19 -// #define Arith_Kind_ASL 1
  145.20 -// #define Sudden_Underflow
   146.1 --- a/lib/c/src/gdtoa/beehive/gd_qnan.h	Fri Jan 20 14:32:03 2012 -0800
   146.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   146.3 @@ -1,24 +0,0 @@
   146.4 -/*
   146.5 - * MD header for contrib/gdtoa
   146.6 - *
   146.7 - * This file can be generated by compiling and running contrib/gdtoa/qnan.c
   146.8 - * on the target architecture after arith.h has been generated.
   146.9 - *
  146.10 - * XXX I don't have ARM hardware, so I just guessed.  --das
  146.11 - *
  146.12 - * $FreeBSD$
  146.13 - */
  146.14 -
  146.15 -#define f_QNAN 0x7fc00000
  146.16 -#define d_QNAN0 0x0
  146.17 -#define d_QNAN1 0x7ff80000
  146.18 -#define ld_QNAN0 0x0
  146.19 -#define ld_QNAN1 0xc0000000
  146.20 -#define ld_QNAN2 0x7fff
  146.21 -#define ld_QNAN3 0x0
  146.22 -#define ldus_QNAN0 0x0
  146.23 -#define ldus_QNAN1 0x0
  146.24 -#define ldus_QNAN2 0x0
  146.25 -#define ldus_QNAN3 0xc000
  146.26 -#define ldus_QNAN4 0x7fff
  146.27 -
   147.1 --- a/lib/c/src/sys-barrelfish/sys_morecore.c	Fri Jan 20 14:32:03 2012 -0800
   147.2 +++ b/lib/c/src/sys-barrelfish/sys_morecore.c	Mon Jan 23 11:04:15 2012 -0800
   147.3 @@ -67,8 +67,8 @@
   147.4   */
   147.5  void lesscore(void)
   147.6  {
   147.7 -#if defined(NOTRANS) || defined(__arm__)
   147.8 -    // Not implemented without translation hardware
   147.9 +#if defined(__arm__)
  147.10 +    // Not implemented
  147.11  
  147.12  #else
  147.13      struct morecore_state *state = get_morecore_state();
   148.1 --- a/lib/crt/arch/beehive/crt0.S	Fri Jan 20 14:32:03 2012 -0800
   148.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   148.3 @@ -1,84 +0,0 @@
   148.4 -/*
   148.5 - * Copyright (c) 2009, ETH Zurich.
   148.6 - * All rights reserved.
   148.7 - *
   148.8 - * This file is distributed under the terms in the attached LICENSE file.
   148.9 - * If you do not find this file, copies can be found by writing to:
  148.10 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  148.11 - */
  148.12 -
  148.13 -#include <regconvention.h>
  148.14 -#include <simctrl.h>
  148.15 -#include <beej7.h>
  148.16 -
  148.17 -// ------------------------------------------------------------
  148.18 -// Program start.  Initialize and jump to main.
  148.19 -// ------------------------------------------------------------
  148.20 -    .code
  148.21 -
  148.22 -	.globl main /* bsim requires that this be called main */
  148.23 -main:	j	after
  148.24 -btorg:	.word	0
  148.25 -btsize:	.word	0
  148.26 -bdorg:	.word	0
  148.27 -bdsize:	.word	0
  148.28 -bborg:	.word	0
  148.29 -bbsize:	.word	0
  148.30 -bcksum:	.word	0
  148.31 -
  148.32 -after:
  148.33 -	/* check header and checksum without touching arg regs */
  148.34 -	sub	t1, pc, 8	/* t1 points at cs:main */
  148.35 -	sub_lsl	t2, t1, zero, 2	/* t2 points at ds:main */
  148.36 -	aqr_add vb, t2, 4	/* read btorg */
  148.37 -	sub	vb, rq, t1	/* compare &main with *btorg */
  148.38 -	jnz	badhdr
  148.39 -
  148.40 -	aqr_add	vb, t2, 20	/* read bborg */
  148.41 -	lsl	vb, rq, 2
  148.42 -	aqr_ld	vb, vb
  148.43 -	ld	vb, rq
  148.44 -	jnz	badsum
  148.45 -
  148.46 -	aqr_add	vb, t2, 20	/* read bborg */
  148.47 -	aqr_add	vb, t2, 24	/* read bbsize */
  148.48 -	sub	t3, rq, t1	/* t3 has (word) bborg - btorg */
  148.49 -	add	t3, rq, t3	/* t3 has (word) bborg + bbsize - btorg */
  148.50 -
  148.51 -	ld	t1, 0
  148.52 -	sub	t2, t2, 4	/* loop incs r2 first before load */
  148.53 -cklp:				/* t2 has data pointer, r3 is size in words */
  148.54 -	aqr_add	t2, t2, 4
  148.55 -	add	t1, rq, t1
  148.56 -	sub	t3, t3, 1
  148.57 -	jnz	cklp
  148.58 -	rol	t3, t1, 1
  148.59 -	xorn	vb, t1, t3
  148.60 -	jnz	badsum
  148.61 -
  148.62 -	long_ld	sp,stack         // initialize sp
  148.63 -	
  148.64 -	/* _barrelfish_init_disabled expects first arg is disp pointer
  148.65 -	 * which is actually stored in the thread register at this point
  148.66 -	 */
  148.67 -	ld	a1, p1
  148.68 -	long_call	_barrelfish_init_disabled
  148.69 -	simctrl BEE_SIMCTRL_REGISTERS
  148.70 -    
  148.71 -// XXX	.globl     _exit
  148.72 -_exit:
  148.73 -	j7	BEE_J7_BREAKPOINT
  148.74 -	j	_exit
  148.75 -
  148.76 -badsum:
  148.77 -	simctrl BEE_SIMCTRL_REGISTERS
  148.78 -	j7	BEE_J7_BREAKPOINT
  148.79 -	j	badsum
  148.80 -badhdr:
  148.81 -	simctrl BEE_SIMCTRL_REGISTERS
  148.82 -	j7	BEE_J7_BREAKPOINT
  148.83 -	j	badhdr
  148.84 -
  148.85 -    .bss
  148.86 -    .blkw 512
  148.87 -stack:
   149.1 --- a/lib/crt/crtbegin.c	Fri Jan 20 14:32:03 2012 -0800
   149.2 +++ b/lib/crt/crtbegin.c	Mon Jan 23 11:04:15 2012 -0800
   149.3 @@ -24,14 +24,12 @@
   149.4  __attribute__ ((unused, section(".ctors"), aligned(sizeof(CDtor))))
   149.5      = { (CDtor)(-1) };
   149.6  
   149.7 -#ifndef __BEEHIVE__
   149.8  /**
   149.9   * Symbols provided by linker that point to the first and after the
  149.10   * last entry of the .init_array section, respectively.
  149.11   */
  149.12  extern CDtor __init_array_start __attribute__ ((visibility ("hidden")));
  149.13  extern CDtor __init_array_end __attribute__ ((visibility ("hidden")));
  149.14 -#endif
  149.15  
  149.16  int _main(int argc, char *argv[]);
  149.17  int main(int argc, char *argv[]);
  149.18 @@ -60,7 +58,6 @@
  149.19      }
  149.20  }
  149.21  
  149.22 -#ifndef __BEEHIVE__
  149.23  /**
  149.24   * \brief Call global (static) constructors, listed in .init_array
  149.25   *
  149.26 @@ -75,13 +72,10 @@
  149.27          (*ctor)();
  149.28      }
  149.29  }
  149.30 -#endif
  149.31  
  149.32  int _main(int argc, char *argv[])
  149.33  {
  149.34      call_global_ctors();
  149.35 -#ifndef __BEEHIVE__
  149.36      call_init_array();
  149.37 -#endif
  149.38      return main(argc, argv);
  149.39  }
   150.1 --- a/lib/msun/beehive/fenv.c	Fri Jan 20 14:32:03 2012 -0800
   150.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   150.3 @@ -1,35 +0,0 @@
   150.4 -/*-
   150.5 - * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
   150.6 - * All rights reserved.
   150.7 - *
   150.8 - * Redistribution and use in source and binary forms, with or without
   150.9 - * modification, are permitted provided that the following conditions
  150.10 - * are met:
  150.11 - * 1. Redistributions of source code must retain the above copyright
  150.12 - *    notice, this list of conditions and the following disclaimer.
  150.13 - * 2. Redistributions in binary form must reproduce the above copyright
  150.14 - *    notice, this list of conditions and the following disclaimer in the
  150.15 - *    documentation and/or other materials provided with the distribution.
  150.16 - *
  150.17 - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  150.18 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  150.19 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  150.20 - * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  150.21 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  150.22 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  150.23 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  150.24 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  150.25 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  150.26 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  150.27 - * SUCH DAMAGE.
  150.28 - *
  150.29 - * $FreeBSD: src/lib/msun/mips/fenv.c,v 1.1 2008/04/26 12:20:29 imp Exp $
  150.30 - */
  150.31 -
  150.32 -#include <fenv.h>
  150.33 -
  150.34 -/*
  150.35 - * Hopefully the system ID byte is immutable, so it's valid to use
  150.36 - * this as a default environment.
  150.37 - */
  150.38 -const fenv_t __fe_dfl_env = 0;
   151.1 --- a/lib/spawndomain/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   151.2 +++ b/lib/spawndomain/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   151.3 @@ -15,7 +15,6 @@
   151.4  
   151.5       arch_srcs "x86_32"  = [ "arch/x86/spawn_arch.c" ]
   151.6       arch_srcs "x86_64"  = [ "arch/x86/spawn_arch.c" ]
   151.7 -     arch_srcs "beehive" = [ "arch/beehive/spawn_arch.c" ]
   151.8       arch_srcs "arm"     = [ "arch/arm/spawn_arch.c" ]
   151.9       arch_srcs _         = []
  151.10  
   152.1 --- a/lib/spawndomain/arch/beehive/spawn_arch.c	Fri Jan 20 14:32:03 2012 -0800
   152.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   152.3 @@ -1,77 +0,0 @@
   152.4 -/**
   152.5 - * \file
   152.6 - * \brief functionality to spawn domains
   152.7 - */
   152.8 -
   152.9 -/*
  152.10 - * Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
  152.11 - * All rights reserved.
  152.12 - *
  152.13 - * This file is distributed under the terms in the attached LICENSE file.
  152.14 - * If you do not find this file, copies can be found by writing to:
  152.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  152.16 - */
  152.17 -
  152.18 -#include <string.h>
  152.19 -#include <stdio.h>
  152.20 -#include <inttypes.h>
  152.21 -#include <barrelfish/barrelfish.h>
  152.22 -#include <spawndomain/spawndomain.h>
  152.23 -#include <barrelfish/dispatcher_arch.h>
  152.24 -#include <bexec.h>
  152.25 -#include "spawn.h"
  152.26 -#include "../../arch.h"
  152.27 -
  152.28 -#if 0
  152.29 -static unsigned int ImageSum(const unsigned int *ptr, size_t count)
  152.30 -{
  152.31 -    unsigned int val = 0;
  152.32 -    do
  152.33 -        val += *(ptr++);
  152.34 -    while(--count > 0);
  152.35 -    return val ^ ~((val << 1) | (val >> 31));
  152.36 -}
  152.37 -#endif
  152.38 -
  152.39 -errval_t spawn_arch_load(struct spawninfo *si,
  152.40 -                         lvaddr_t binary, size_t binary_size,
  152.41 -                         genvaddr_t *entry, void **arch_load_info)
  152.42 -{
  152.43 -    // XXX: is this a real bexec image, or a reference to one elsewhere?
  152.44 -    if (binary_size == sizeof(struct bimgref_file)) {
  152.45 -        // XXX: cheat the cap system and grab the binary straight out of memory
  152.46 -        struct bimgref_file *bimgref = (void *)binary;
  152.47 -        assert(bimgref->magic == BIMGREF_MAGIC);
  152.48 -        struct mem_region *region = bimgref->region;
  152.49 -        binary = region->mr_base;
  152.50 -        debug_printf("spawn_arch_load: fixing up fake binary to %"PRIxLVADDR"\n",
  152.51 -                     binary);
  152.52 -    }
  152.53 -
  152.54 -    // Look at the bexec header and pull out the entry point.
  152.55 -    // Don't need to relocate the binary - but we may want to record
  152.56 -    // that the module is in use to prevent two domains sharing the
  152.57 -    // same data segment!
  152.58 -    bexec_t *bexec = (bexec_t *)binary;
  152.59 -    assert(bexec->bmagic == BEXEC_BMAGIC);
  152.60 -    assert(bexec->btorg != 0);
  152.61 -
  152.62 -    *entry = bexec->btorg;
  152.63 -
  152.64 -    // XXX All executables currently checksum themselves
  152.65 -    //    unsigned int checksum = ImageSum((void*)bexec, bexec->btsize + bexec->bdsize);
  152.66 -    //assert(checksum == 0);
  152.67 -
  152.68 -    // TLS is NYI
  152.69 -    si->tls_init_base = 0;
  152.70 -    si->tls_init_len = si->tls_total_len = 0;
  152.71 -
  152.72 -    return SYS_ERR_OK;
  152.73 -}
  152.74 -
  152.75 -void spawn_arch_set_registers(void *arch_load_info,
  152.76 -                              dispatcher_handle_t handle,
  152.77 -                              arch_registers_state_t *enabled_area,
  152.78 -                              arch_registers_state_t *disabled_area)
  152.79 -{
  152.80 -}
   153.1 --- a/lib/spawndomain/multiboot.c	Fri Jan 20 14:32:03 2012 -0800
   153.2 +++ b/lib/spawndomain/multiboot.c	Mon Jan 23 11:04:15 2012 -0800
   153.3 @@ -51,33 +51,6 @@
   153.4      return optstring;
   153.5  }
   153.6  
   153.7 -#if defined(__BEEHIVE__)
   153.8 -extern int find_least_set32(uint32_t value);
   153.9 -extern int find_highest_set32(uint32_t value);
  153.10 -
  153.11 -/**
  153.12 - * \brief Align block at base_addr with size n to power of two
  153.13 - * alignable at its size
  153.14 - *
  153.15 - * Compute the highest exponent x of n so that 2^x < n _and_
  153.16 - * the base_addr is aligned at its size.
  153.17 - * For example: n = 20, base_addr = 4 => size can be 1, 2 or 4.
  153.18 - * Biggest possible block is 4 => x = 2
  153.19 - *
  153.20 - * \param n         Size of the block to split in bytes
  153.21 - * \param base_addr Base address of the block to split
  153.22 - *
  153.23 - * \return Highest exponent (bits) for the blocksize to use next
  153.24 - */
  153.25 -static int bitaddralign(size_t size, size_t base)
  153.26 -{
  153.27 -    int lo = find_least_set32(base);
  153.28 -    int hi = find_highest_set32(size);
  153.29 -    int res = min(lo, hi);
  153.30 -    return res;
  153.31 -}
  153.32 -#endif
  153.33 -
  153.34  /// Map in the frame caps for a module into our vspace, return their location
  153.35  errval_t spawn_map_module(struct mem_region *module, size_t *retsize,
  153.36                            lvaddr_t *retaddr, genpaddr_t *retpaddr)
  153.37 @@ -93,41 +66,6 @@
  153.38      struct memobj *memobj;
  153.39      struct vregion *vregion;
  153.40   
  153.41 -#ifdef NOTRANS
  153.42 -    struct capref frame = {
  153.43 -        .cnode = cnode_module,
  153.44 -        .slot  = module->mrmod_slot,
  153.45 -    };
  153.46 -
  153.47 -    lpaddr_t base_addr = module->mr_base;
  153.48 -    while (size > 0) {
  153.49 -	assert((base_addr & BASE_PAGE_MASK) == 0);
  153.50 -	assert((size & BASE_PAGE_MASK) == 0);
  153.51 -	
  153.52 -	uint8_t block_size = bitaddralign(size, base_addr);
  153.53 -
  153.54 -	err = vspace_map_one_frame(&base, (1UL << block_size), frame, &memobj, &vregion);
  153.55 -	if (err_is_fail(err)) {
  153.56 -	    printf("vspace_map_one_frame failed!\n");
  153.57 -	    return err_push(err, LIB_ERR_VSPACE_MAP);
  153.58 -	}
  153.59 -	
  153.60 -	frame.slot ++;
  153.61 -	size -= (1UL << block_size);
  153.62 -	base_addr += (1UL << block_size);
  153.63 -    }
  153.64 -    
  153.65 -    if (retsize != NULL) {
  153.66 -        *retsize = module->mrmod_size;
  153.67 -    }
  153.68 -
  153.69 -    if (retaddr != NULL) {
  153.70 -	*retaddr = (lpaddr_t)module->mr_base;
  153.71 -    }
  153.72 -
  153.73 -    return SYS_ERR_OK;
  153.74 -
  153.75 -#else
  153.76      err = vspace_map_anon_attr(&base, &memobj, &vregion, size, &size,
  153.77                                 VREGION_FLAGS_READ);
  153.78      if (err_is_fail(err)) {
  153.79 @@ -174,7 +112,6 @@
  153.80      }
  153.81  
  153.82      return SYS_ERR_OK;
  153.83 -#endif
  153.84  }
  153.85  
  153.86  
   154.1 --- a/lib/spawndomain/spawn.c	Fri Jan 20 14:32:03 2012 -0800
   154.2 +++ b/lib/spawndomain/spawn.c	Mon Jan 23 11:04:15 2012 -0800
   154.3 @@ -22,10 +22,7 @@
   154.4  #include <trace/trace.h>
   154.5  #include "spawn.h"
   154.6  #include "arch.h"
   154.7 -
   154.8 -#ifndef __BEEHIVE__
   154.9  #include <elf/elf.h>
  154.10 -#endif
  154.11  
  154.12  extern char **environ;
  154.13  
  154.14 @@ -200,12 +197,6 @@
  154.15  #endif
  154.16          break;
  154.17  
  154.18 -    case CPU_BEEHIVE:
  154.19 -        /* vtree is meaningless for beehive */
  154.20 -        si->vtree = NULL_CAP;
  154.21 -        err = SYS_ERR_OK;
  154.22 -        break;
  154.23 -
  154.24      case CPU_ARM:
  154.25          err = vnode_create(si->vtree, ObjType_VNode_ARM_l1);
  154.26          break;
  154.27 @@ -258,15 +249,6 @@
  154.28   */
  154.29  static errval_t spawn_determine_cputype(struct spawninfo *si, lvaddr_t binary)
  154.30  {
  154.31 -#ifdef __BEEHIVE__
  154.32 -    si->cpu_type = CPU_BEEHIVE;
  154.33 -
  154.34 -    // XXX There used to be magic code here to pass the
  154.35 -    // bootinfo pointer through, but that is now believed
  154.36 -    // to have been obsoleted by the generic mechanism.
  154.37 -    // If not, here is where to put it back in.
  154.38 -
  154.39 -#else
  154.40      struct Elf64_Ehdr *head = (struct Elf64_Ehdr *)binary;
  154.41  
  154.42      switch(head->e_machine) {
  154.43 @@ -286,7 +268,7 @@
  154.44          assert(!"Unsupported architecture type");
  154.45          return SPAWN_ERR_UNKNOWN_TARGET_ARCH;
  154.46      }
  154.47 -#endif
  154.48 +
  154.49      return SYS_ERR_OK;
  154.50  }
  154.51  
   155.1 --- a/lib/spawndomain/spawn_vspace.c	Fri Jan 20 14:32:03 2012 -0800
   155.2 +++ b/lib/spawndomain/spawn_vspace.c	Mon Jan 23 11:04:15 2012 -0800
   155.3 @@ -175,7 +175,6 @@
   155.4      return err;
   155.5  }
   155.6  
   155.7 -#ifndef NOTRANS
   155.8  /**
   155.9   * \brief Return memobj and vregion for anonymous type mapping
  155.10   */
  155.11 @@ -222,4 +221,3 @@
  155.12      }
  155.13      return err;
  155.14  }
  155.15 -#endif
   156.1 --- a/lib/thc/thc.c	Fri Jan 20 14:32:03 2012 -0800
   156.2 +++ b/lib/thc/thc.c	Mon Jan 23 11:04:15 2012 -0800
   156.3 @@ -1349,36 +1349,6 @@
   156.4           " call *%eax                       \n\t" // Call callee (it pops args)
   156.5           " pop %esp                         \n\t" // Restore old ESP
   156.6           " ret \n\t");
   156.7 -#elif (defined(__BEEHIVE__))
   156.8 -
   156.9 -
  156.10 -/* static void thc_on_alt_stack_0(void *stack,     // r3
  156.11 -                                  void *fn,        // r4
  156.12 -                                  void *args)  */  // r5
  156.13 -
  156.14 -__asm__ ("      .code                       \n\t"
  156.15 -         "      .alignw 1                   \n\t"
  156.16 -         "      .globl  _thc_on_alt_stack_0 \n\t"
  156.17 -         "_thc_on_alt_stack_0:              \n\t"
  156.18 -         // Store info about old stack into new stack
  156.19 -         " sub     r3, r3, 8                \n\t"   // 2 words on new stack
  156.20 -         " aqw_add  vb, r3, 0               \n\t"
  156.21 -         " ld      wq, sp                   \n\t"   // Store our SP on new stack
  156.22 -         " aqw_add  vb, r3, 4               \n\t"
  156.23 -         " ld      wq, link                 \n\t"   // Store our link reg
  156.24 -         " ld      sp, r3                   \n\t"   // Initialize new SP
  156.25 -         // Make call
  156.26 -         " ld      r3, r5                   \n\t"   // Outgoing args for call
  156.27 -         " call    r4                       \n\t"   // Call fn(args)
  156.28 -         // Return to old stack
  156.29 -         " aqr_add vb, sp, 4                \n\t"
  156.30 -         " ld      link, rq                 \n\t"   // Restore link
  156.31 -         " aqr_add  vb, sp, 0               \n\t"
  156.32 -         " ld      sp, rq                   \n\t"   // Restore SP
  156.33 -         " j       link                     \n\t"
  156.34 -         "      .size _thc_on_alt_stack_0, .-_thc_on_alt_stack_0 \n\t");
  156.35 -
  156.36 -  
  156.37  #else
  156.38  void thc_on_alt_stack_0(void *stack,   
  156.39                          void *fn,   
  156.40 @@ -1634,110 +1604,6 @@
  156.41  	 );
  156.42  
  156.43  
  156.44 -#elif defined(__BEEHIVE__)
  156.45 -/*
  156.46 -            static void thc_awe_execute_0(awe_t *awe)    // r3
  156.47 -*/
  156.48 -
  156.49 -__asm__ ("      .code                      \n\t"
  156.50 -         "      .alignw 1                  \n\t"
  156.51 -         "      .globl  _thc_awe_execute_0 \n\t"
  156.52 -         "_thc_awe_execute_0:              \n\t"
  156.53 -         " aqr_add vb, r3, 4               \n\t" // Frame pointer
  156.54 -         " ld      fp, rq                  \n\t"
  156.55 -         " aqr_add vb, r3, 8               \n\t" // Stack pointer
  156.56 -         " ld      sp, rq                  \n\r"
  156.57 -         " aqr_add vb, r3, 0               \n\t" // IP
  156.58 -         " ld      r3, rq                  \n\t"
  156.59 -         " j       r3                      \n\t"
  156.60 -         "      .size _thc_awe_execute_0, .-_thc_awe_execute_0 \n\t");
  156.61 -
  156.62 -/*
  156.63 -           void _thc_schedulecont(awe_t *awe)   // r3
  156.64 -*/
  156.65 -
  156.66 -__asm__("	.code                            \n\t"
  156.67 -        "       .alignw 1                        \n\t"
  156.68 -        "       .globl __thc_schedulecont            \n\t"
  156.69 -        "       .type __thc_schedulecont, @function  \n\t"
  156.70 -        "__thc_schedulecont:                         \n\t"
  156.71 -        " aqw_add vb, r3, 0                      \n\t" // Our return address
  156.72 -        " ld      wq, link                       \n\t"
  156.73 -        " aqw_add vb, r3, 4                      \n\t" // Frame pointer
  156.74 -        " ld      wq, fp                         \n\t"
  156.75 -        " aqw_add vb, r3, 8                      \n\t" // Stack pointer
  156.76 -        " ld      wq, sp                         \n\t"
  156.77 -        " aqw_add vb, r3, 12                     \n\t" // PTS
  156.78 -        " ld      wq, zero                       \n\t" 
  156.79 -        " aqw_add vb, r3, 16                     \n\t" // Current FB
  156.80 -        " ld      wq, zero                       \n\t" 
  156.81 -        " aqw_add vb, r3, 20                     \n\t" // Prev
  156.82 -        " ld      wq, zero                       \n\t" 
  156.83 -        " aqw_add vb, r3, 24                     \n\t" // Next
  156.84 -        " ld      wq, zero                       \n\t"
  156.85 -        // AWE now initialized call into C for the rest.  NB:
  156.86 -        // r3 is still in place as the outgoing argument to
  156.87 -        // the C function.        
  156.88 -        " aqw_sub sp, sp, 4                      \n\t"
  156.89 -        " ld      wq, link                       \n\t"
  156.90 -        " long_call __thc_schedulecont_c         \n\t"
  156.91 -        " ld      r1, zero                       \n\t" // Return value
  156.92 -        " aqr_add sp, sp, 0                      \n\t"
  156.93 -        " add     sp, sp, 4                      \n\t"
  156.94 -        " j       rq                             \n\t"
  156.95 -        "       .size __thc_schedulecont, .-__thc_schedulecont   \n\t");
  156.96 -
  156.97 -
  156.98 -/*
  156.99 -           void _thc_callcont(awe_t *awe,   // r3
 156.100 -                   THCContFn_t fn,          // r4
 156.101 -                   void *args) {            // r5
 156.102 -*/
 156.103 -
 156.104 -__asm__("	.code                            \n\t"
 156.105 -        "       .alignw 1                        \n\t"
 156.106 -        "       .globl __thc_callcont            \n\t"
 156.107 -        "       .type __thc_callcont, @function  \n\t"
 156.108 -        "__thc_callcont:                         \n\t"
 156.109 -        " aqw_add vb, r3, 12                     \n\t" // PTS
 156.110 -        " ld      wq, zero                       \n\t" 
 156.111 -        " aqw_add vb, r3, 16                     \n\t" // Current FB
 156.112 -        " ld      wq, zero                       \n\t" 
 156.113 -        " aqw_add vb, r3, 20                     \n\t" // Prev
 156.114 -        " ld      wq, zero                       \n\t" 
 156.115 -        " aqw_add vb, r3, 24                     \n\t" // Next
 156.116 -        " ld      wq, zero                       \n\t"
 156.117 -        " aqw_add vb, r3, 0                      \n\t" // Our return address
 156.118 -        " ld      wq, link                       \n\t"
 156.119 -        " aqw_add vb, r3, 4                      \n\t" // Frame pointer
 156.120 -        " ld      wq, fp                         \n\t"
 156.121 -        " aqw_add vb, r3, 8                      \n\t" // Stack pointer
 156.122 -        " ld      wq, sp                         \n\t"
 156.123 -        // AWE now initialized call into C for the rest.  NB:
 156.124 -        // r3, r4, r5 are still in place as the outgoing arguments to
 156.125 -        // the C function.        
 156.126 -        " aqw_sub sp, sp, 4                      \n\t"
 156.127 -        " ld      wq, link                       \n\t"
 156.128 -        " long_call __thc_callcont_c             \n\t"
 156.129 -	" simctrl 1                              \n\t"
 156.130 -        "       .size __thc_callcont, .-__thc_callcont   \n\t");
 156.131 -
 156.132 -/*
 156.133 -            static void _thc_lazy_awe_marker()   
 156.134 -*/
 156.135 -
 156.136 -__asm__ ("      .text \n\t"
 156.137 -         "      .align  16            \n\t"
 156.138 -         "      .globl  __thc_lazy_awe \n\t"
 156.139 -         "      .globl  __thc_lazy_awe_marker \n\t"
 156.140 -	 " __thc_lazy_awe:            \n\t" /* This is for debugging so we get */
 156.141 -         " xor zero, zero, zero      \n\t" /* a sensible call stack           */
 156.142 -	 " __thc_lazy_awe_marker:    \n\t"
 156.143 -	 " simctrl 1                 \n\t" /* should never be called */
 156.144 -	 );
 156.145 -
 156.146 -
 156.147 -
 156.148  #else
 156.149  void thc_awe_execute_0(awe_t *awe) {
 156.150    assert(0 && "_thc_awe_execute_0 not implemented for this architecture");
   157.1 --- a/lib/thc/thcsync.c	Fri Jan 20 14:32:03 2012 -0800
   157.2 +++ b/lib/thc/thcsync.c	Mon Jan 23 11:04:15 2012 -0800
   157.3 @@ -519,10 +519,6 @@
   157.4  #ifdef _MSC_VER
   157.5      C_ASSERT(sizeof(LONGLONG) == sizeof(seq->n));
   157.6      return InterlockedIncrement64(reinterpret_cast<volatile LONGLONG*>(&seq->n)) - 1;
   157.7 -#elif defined(__BEEHIVE__)
   157.8 -  uint64_t result = seq->n;
   157.9 -  seq->n ++;
  157.10 -  return result;
  157.11  #else
  157.12    uint64_t result;
  157.13    do {
   158.1 --- a/tools/asmoffsets/asmoffsets.c	Fri Jan 20 14:32:03 2012 -0800
   158.2 +++ b/tools/asmoffsets/asmoffsets.c	Mon Jan 23 11:04:15 2012 -0800
   158.3 @@ -70,10 +70,6 @@
   158.4  
   158.5  #include <barrelfish/dispatcher_arch.h>
   158.6  
   158.7 -#ifdef __BEEHIVE__
   158.8 -#include <corearea.h>
   158.9 -#endif
  158.10 -
  158.11  /* wrap everything inside a dummy function, to keep the compiler happy */
  158.12  #ifdef __ICC
  158.13  int main(void)
  158.14 @@ -135,11 +131,6 @@
  158.15      DECL(DISP_X86_32_TRAP_AREA, struct dispatcher_shared_x86_32, trap_save_area);
  158.16  #endif
  158.17  
  158.18 -#if defined(__BEEHIVE__)
  158.19 -    DECL(DISP_ENABLED_AREA, struct dispatcher_shared_beehive, enabled_save_area);
  158.20 -    DECL(DISP_DISABLED_AREA, struct dispatcher_shared_beehive, disabled_save_area);
  158.21 -#endif // __BEEHIVE__
  158.22 -
  158.23  #if defined(__arm__)
  158.24      DECL(DISP_CRIT_PC_LOW, struct dispatcher_shared_arm, crit_pc_low);
  158.25      DECL(DISP_CRIT_PC_HIGH, struct dispatcher_shared_arm, crit_pc_high);
  158.26 @@ -181,8 +172,6 @@
  158.27      ASSERT(sizeof(struct dispatcher_x86_64) <= (1 << DISPATCHER_FRAME_BITS));
  158.28  #elif defined __i386__
  158.29      ASSERT(sizeof(struct dispatcher_x86_32) <= (1 << DISPATCHER_FRAME_BITS));
  158.30 -#elif defined __BEEHIVE__
  158.31 -    ASSERT(sizeof(struct dispatcher_beehive) <= (1 << DISPATCHER_FRAME_BITS));
  158.32  #elif defined __arm__
  158.33      ASSERT(sizeof(struct dispatcher_arm) <= (1 << DISPATCHER_FRAME_BITS));
  158.34  #else
  158.35 @@ -198,25 +187,6 @@
  158.36  
  158.37      EMIT(SIZEOF_STRUCT_SYSRET, sizeof(struct sysret));
  158.38  
  158.39 -#ifdef __BEEHIVE__
  158.40 -    DECL(COREAREA_RQ_AREA, struct corearea, rqarea);
  158.41 -
  158.42 -    DECL(COREAREA_MASTER, struct corearea, master_stops);
  158.43 -    DECL(COREAREA_MASTER_STOPS, struct corearea, master_stops);
  158.44 -    DECL(COREAREA_MASTER_TICKS, struct corearea, master_ticks);
  158.45 -
  158.46 -    DECL(COREAREA_SLAVE, struct corearea, slave_stops);
  158.47 -    DECL(COREAREA_SLAVE_STOPS, struct corearea, slave_stops);
  158.48 -    DECL(COREAREA_SLAVE_TICKS, struct corearea, slave_ticks);
  158.49 -
  158.50 -    DECL(COREAREA_KERNEL_BEGINS, struct corearea, kernel_begins);
  158.51 -    DECL(COREAREA_KERNEL_ENDS, struct corearea, kernel_ends);
  158.52 -    DECL(COREAREA_KERNEL_TICKER, struct corearea, kernel_ticker);
  158.53 -    DECL(COREAREA_KERNEL_PENDING, struct corearea, kernel_pending);
  158.54 -
  158.55 -    DECL(COREAREA_SYSCALL, struct corearea, syscall);
  158.56 -#endif // BEEHIVE
  158.57 -
  158.58      /* footer */
  158.59      __asm("\n#endif /* ASMOFFSETS_H */\n");
  158.60  }
   159.1 --- a/tools/flounder/Arch.hs	Fri Jan 20 14:32:03 2012 -0800
   159.2 +++ b/tools/flounder/Arch.hs	Mon Jan 23 11:04:15 2012 -0800
   159.3 @@ -60,17 +60,7 @@
   159.4      lrpc_words = 0
   159.5  }
   159.6  
   159.7 -beehive = Arch {
   159.8 -    archname = "beehive",
   159.9 -    wordsize = 32,
  159.10 -    ptrsize = 32,
  159.11 -    sizesize = 32,
  159.12 -    enum_type = Int32,
  159.13 -    lmp_words = 9,
  159.14 -    lrpc_words = 0
  159.15 -}
  159.16 -
  159.17 -all_archs = [x86_64, x86_32, arm, beehive]
  159.18 +all_archs = [x86_64, x86_32, arm]
  159.19  
  159.20  -- for option parsing: find the matching arch info
  159.21  parse_arch :: String -> Maybe Arch
   160.1 --- a/tools/flounder/BMP.hs	Fri Jan 20 14:32:03 2012 -0800
   160.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   160.3 @@ -1,1059 +0,0 @@
   160.4 -{- 
   160.5 -   BMP.hs: Flounder stub generator for Beehive message passing.
   160.6 -
   160.7 -  Part of Flounder: a message passing IDL for Barrelfish
   160.8 -   
   160.9 -  Copyright (c) 2007-2010, ETH Zurich.
  160.10 -  All rights reserved.
  160.11 -  
  160.12 -  This file is distributed under the terms in the attached LICENSE file.
  160.13 -  If you do not find this file, copies can be found by writing to:
  160.14 -  ETH Zurich D-INFK, Universit\"atstr. 6, CH-8092 Zurich. Attn: Systems Group.
  160.15 --}  
  160.16 -
  160.17 -module BMP where
  160.18 -
  160.19 -import Data.Bits
  160.20 -import Maybe
  160.21 -
  160.22 -import qualified CAbsSyntax as C
  160.23 -import qualified Backend
  160.24 -import Arch
  160.25 -import BackendCommon
  160.26 -import Syntax
  160.27 -import MsgFragments
  160.28 -
  160.29 -drvname = "bmp"
  160.30 -arch = fromJust $ parse_arch "beehive"
  160.31 -frag_len_words = 58 - 1 -- determined by kernel transport, with a 1-word header
  160.32 -
  160.33 -------------------------------------------------------------------------
  160.34 --- Language mapping: C identifier names
  160.35 -------------------------------------------------------------------------
  160.36 -
  160.37 --- Name of the binding struct
  160.38 -bind_type :: String -> String
  160.39 -bind_type ifn = ifscope ifn "bmp_binding"
  160.40 -
  160.41 --- Name of the local variable used for the BMP-specific binding type
  160.42 -my_bindvar_name :: String
  160.43 -my_bindvar_name = "b"
  160.44 -my_bindvar = C.Variable my_bindvar_name
  160.45 -
  160.46 --- Name of the bind function
  160.47 -bind_fn_name n = ifscope n "bmp_bind"
  160.48 -
  160.49 --- Name of the bind continuation function
  160.50 -bind_cont_fn_name n = ifscope n "bmp_bind_continuation"
  160.51 -
  160.52 --- Name of the continuation for new monitor bindings
  160.53 -new_monitor_cont_fn_name n = ifscope n "bmp_new_monitor_binding_continuation"
  160.54 -
  160.55 --- Name of the init function
  160.56 -init_fn_name n = ifscope n "bmp_init"
  160.57 -
  160.58 --- Name of the destroy function
  160.59 -destroy_fn_name n = ifscope n "bmp_destroy"
  160.60 -
  160.61 --- Name of the transmit function
  160.62 -tx_fn_name ifn mn = idscope ifn mn "bmp_send"
  160.63 -
  160.64 --- Name of the transmit handler
  160.65 -tx_handler_name ifn = ifscope ifn "bmp_send_handler"
  160.66 -
  160.67 --- Name of the cap transmit handler
  160.68 -tx_cap_handler_name ifn = ifscope ifn "bmp_cap_send_handler"
  160.69 -
  160.70 --- Name of the transmit vtable
  160.71 -tx_vtbl_name ifn = ifscope ifn "bmp_tx_vtbl"
  160.72 -
  160.73 --- Name of the receive handler
  160.74 -rx_handler_name ifn = ifscope ifn "bmp_rx_handler"
  160.75 -
  160.76 --- Name of the cap send/recv handlers
  160.77 -cap_rx_handler_name ifn = ifscope ifn "bmp_cap_rx_handler"
  160.78 -cap_tx_reply_handler_name ifn = ifscope ifn "bmp_cap_tx_reply_handler"
  160.79 -
  160.80 --- Names of the control functions
  160.81 -change_waitset_fn_name ifn = ifscope ifn "bmp_change_waitset"
  160.82 -control_fn_name = generic_control_fn_name drvname
  160.83 -
  160.84 --- Name of the continuation that runs when we get the monitor mutex
  160.85 -monitor_mutex_cont_name ifn = ifscope ifn "bmp_monitor_mutex_cont"
  160.86 -
  160.87 -------------------------------------------------------------------------
  160.88 --- Language mapping: Create the header file for this interconnect driver
  160.89 -------------------------------------------------------------------------
  160.90 -
  160.91 -header :: String -> String -> Interface -> String
  160.92 -header infile outfile intf = 
  160.93 -    unlines $ C.pp_unit $ header_file intf (header_body infile intf)
  160.94 -    where
  160.95 -        header_file :: Interface -> [C.Unit] -> C.Unit
  160.96 -        header_file interface@(Interface name _ _) body = 
  160.97 -            let sym = "__" ++ name ++ "_BMP_H"
  160.98 -            in C.IfNDef sym ([ C.Define sym [] "1"] ++ body) []
  160.99 -
 160.100 -header_body :: String -> Interface -> [C.Unit]
 160.101 -header_body infile interface@(Interface name descr decls) = [
 160.102 -    intf_preamble infile name descr,
 160.103 -    C.Blank,
 160.104 -    C.MultiComment [ "BMP interconnect driver" ],
 160.105 -    C.Blank,
 160.106 -    C.Include C.Standard "barrelfish/bmp_chan.h",
 160.107 -    C.Include C.Standard "flounder/flounder_support_bmp.h",
 160.108 -    C.Blank,
 160.109 -    bmp_binding_struct name,
 160.110 -    C.Blank,
 160.111 -    init_function_proto name,
 160.112 -    destroy_function_proto name,
 160.113 -    bind_function_proto name,
 160.114 -    connect_handler_proto name,
 160.115 -    rx_handler_proto name,
 160.116 -    C.Blank
 160.117 -    ]
 160.118 -
 160.119 -bmp_binding_struct :: String -> C.Unit
 160.120 -bmp_binding_struct ifn = C.StructDecl (bind_type ifn) fields
 160.121 -  where
 160.122 -    fields = [
 160.123 -        C.Param (C.Struct $ intf_bind_type ifn) "b",
 160.124 -        C.Param (C.Struct "flounder_bmp_state") "bmp_state",
 160.125 -        C.ParamBlank,
 160.126 -        -- these are needed for the new monitor continuation to know the bind parameters
 160.127 -        C.ParamComment "bind params for the new monitor continuation",
 160.128 -        C.Param (C.TypeName "iref_t") "iref",
 160.129 -        C.Param (C.TypeName "size_t") "ep_buflen"
 160.130 -        ]
 160.131 -
 160.132 -init_function_proto :: String -> C.Unit
 160.133 -init_function_proto n = 
 160.134 -    C.GVarDecl C.Extern C.NonConst 
 160.135 -         (C.Function C.NoScope C.Void params) name Nothing
 160.136 -    where 
 160.137 -      name = init_fn_name n
 160.138 -      params = [C.Param (C.Ptr $ C.Struct (bind_type n)) "b",
 160.139 -                C.Param (C.Ptr $ C.Struct "waitset") "waitset"]
 160.140 -
 160.141 -destroy_function_proto :: String -> C.Unit
 160.142 -destroy_function_proto n = 
 160.143 -    C.GVarDecl C.Extern C.NonConst 
 160.144 -         (C.Function C.NoScope C.Void params) name Nothing
 160.145 -    where 
 160.146 -      name = destroy_fn_name n
 160.147 -      params = [C.Param (C.Ptr $ C.Struct (bind_type n)) "b"]
 160.148 -
 160.149 -bind_function_proto :: String -> C.Unit
 160.150 -bind_function_proto n = 
 160.151 -    C.GVarDecl C.Extern C.NonConst 
 160.152 -         (C.Function C.NoScope (C.TypeName "errval_t") params) name Nothing
 160.153 -    where 
 160.154 -      name = bind_fn_name n
 160.155 -      params = bind_params n
 160.156 -
 160.157 -bind_params n = [ C.Param (C.Ptr $ C.Struct (bind_type n)) "b",
 160.158 -                 C.Param (C.TypeName "iref_t") "iref",
 160.159 -                 C.Param (C.Ptr $ C.TypeName $ intf_bind_cont_type n) intf_cont_var,
 160.160 -                 C.Param (C.Ptr $ C.TypeName "void") "st",
 160.161 -                 C.Param (C.Ptr $ C.Struct "waitset") "waitset",
 160.162 -                 C.Param (C.TypeName "idc_bind_flags_t") "flags",
 160.163 -                 C.Param (C.TypeName "size_t") "ep_buflen" ]
 160.164 -
 160.165 -rx_handler_proto ifn = C.GVarDecl C.Extern C.NonConst
 160.166 -    (C.Function C.NoScope C.Void [C.Param (C.Ptr C.Void) "arg"])
 160.167 -    (rx_handler_name ifn) Nothing
 160.168 -
 160.169 -connect_handler_proto :: String -> C.Unit
 160.170 -connect_handler_proto ifn = C.GVarDecl C.Extern C.NonConst
 160.171 -    (C.Function C.NoScope (C.TypeName "errval_t") connect_handler_params)
 160.172 -    (drv_connect_handler_name drvname ifn) Nothing
 160.173 -
 160.174 -connect_handler_params :: [C.Param]
 160.175 -connect_handler_params
 160.176 -    = [C.Param (C.Ptr $ C.Void) "st",
 160.177 -       C.Param (C.Ptr $ C.Struct "monitor_binding") "monitor_binding",
 160.178 -       C.Param (C.TypeName "uintptr_t") "monitor_id",
 160.179 -       C.Param (C.Struct "capref") "bee_ep",
 160.180 -       C.Param (C.TypeName "size_t") "bee_ep_len"]
 160.181 -
 160.182 -
 160.183 -------------------------------------------------------------------------
 160.184 --- Language mapping: Create the stub (implementation) for this interconnect driver
 160.185 -------------------------------------------------------------------------
 160.186 -
 160.187 -stub :: String -> String -> Interface -> String
 160.188 -stub infile outfile intf =  unlines $ C.pp_unit $ stub_body infile intf
 160.189 -
 160.190 -stub_body :: String -> Interface -> C.Unit
 160.191 -stub_body infile intf@(Interface ifn descr decls) = C.UnitList [
 160.192 -    intf_preamble infile ifn descr,
 160.193 -    C.Blank,
 160.194 -    C.MultiComment [ "Generated Stub for BMP" ],
 160.195 -    C.Blank,
 160.196 -
 160.197 -    C.Include C.Standard "string.h",
 160.198 -    C.Include C.Standard "barrelfish/barrelfish.h",
 160.199 -    C.Include C.Standard "barrelfish/monitor_client.h",
 160.200 -    C.Include C.Standard "flounder/flounder_support.h",
 160.201 -    C.Include C.Standard "flounder/flounder_support_bmp.h",
 160.202 -    C.Include C.Standard ("if/" ++ ifn ++ "_defs.h"),
 160.203 -    C.Blank,
 160.204 -
 160.205 -    C.MultiComment [ "Send handler function" ],
 160.206 -    tx_handler ifn msg_specs,
 160.207 -    C.Blank,
 160.208 -
 160.209 -    C.MultiComment [ "Capability sender function" ],
 160.210 -    tx_cap_handler ifn msg_specs,
 160.211 -    C.Blank,
 160.212 -    
 160.213 -    C.MultiComment [ "Receive handler" ],
 160.214 -    rx_handler ifn types messages msg_specs,
 160.215 -    C.Blank,
 160.216 -
 160.217 -    C.MultiComment [ "Cap send/receive handlers" ],
 160.218 -    cap_rx_handler ifn types messages msg_specs,
 160.219 -    cap_tx_reply_handler ifn,
 160.220 -    C.Blank,
 160.221 -
 160.222 -    C.UnitList $ if has_caps then
 160.223 -        [C.MultiComment [ "Monitor mutex acquire continuation" ],
 160.224 -        monitor_mutex_cont ifn,
 160.225 -        C.Blank]
 160.226 -    else [],
 160.227 -
 160.228 -    C.MultiComment [ "Message sender functions" ],
 160.229 -    C.UnitList [ tx_fn ifn types msg spec | (msg, spec) <- zip messages msg_specs ],
 160.230 -    C.Blank,
 160.231 -
 160.232 -    C.MultiComment [ "Send vtable" ],
 160.233 -    tx_vtbl ifn messages,
 160.234 -
 160.235 -    C.MultiComment [ "Control functions" ],
 160.236 -    can_send_fn_def drvname ifn,
 160.237 -    register_send_fn_def drvname ifn,
 160.238 -    default_error_handler_fn_def drvname ifn,
 160.239 -    change_waitset_fn_def ifn,
 160.240 -    generic_control_fn_def drvname ifn,
 160.241 -    C.Blank,
 160.242 -
 160.243 -    C.MultiComment [ "Functions to initialise/destroy the binding state" ],
 160.244 -    init_fn ifn,
 160.245 -    destroy_fn ifn,
 160.246 -    C.Blank,
 160.247 -
 160.248 -    C.MultiComment [ "Bind function" ],
 160.249 -    bind_cont_fn ifn,
 160.250 -    new_monitor_cont_fn ifn,
 160.251 -    bind_fn ifn,
 160.252 -    C.Blank,
 160.253 -
 160.254 -    C.MultiComment [ "Connect callback for export" ],
 160.255 -    connect_handler_fn ifn
 160.256 -    ]
 160.257 -    where
 160.258 -        (types, messagedecls) = Backend.partitionTypesMessages decls
 160.259 -        messages = rpcs_to_msgs messagedecls
 160.260 -        msg_specs = [build_msg_spec arch frag_len_words False types m | m <- messages]
 160.261 -        has_caps = [1 | MsgSpec _ _ caps <- msg_specs, caps /= []] /= []
 160.262 -
 160.263 -init_fn :: String -> C.Unit
 160.264 -init_fn ifn = C.FunctionDef C.NoScope C.Void (init_fn_name ifn) params [
 160.265 -    C.StmtList common_init,
 160.266 -    C.Ex $ C.Call "bmp_chan_init" [C.AddressOf $ statevar `C.FieldOf` "chan"],
 160.267 -    C.Ex $ C.Call "flounder_stub_bmp_state_init" [C.AddressOf statevar, my_bindvar],
 160.268 -    C.Ex $ C.Assignment (common_field "change_waitset") (C.Variable $ change_waitset_fn_name ifn),
 160.269 -    C.Ex $ C.Assignment (common_field "control") (C.Variable $ control_fn_name ifn) ]
 160.270 -    where
 160.271 -      statevar = C.DerefField my_bindvar "bmp_state"
 160.272 -      params = [C.Param (C.Ptr $ C.Struct (bind_type ifn)) my_bindvar_name,
 160.273 -                C.Param (C.Ptr $ C.Struct "waitset") "waitset"]
 160.274 -      common_field f = my_bindvar `C.DerefField` "b" `C.FieldOf` f
 160.275 -      common_init = binding_struct_init drvname ifn
 160.276 -        (C.DerefField my_bindvar "b")
 160.277 -        (C.Variable "waitset")
 160.278 -        (C.Variable $ tx_vtbl_name ifn)
 160.279 -
 160.280 -destroy_fn :: String -> C.Unit
 160.281 -destroy_fn ifn = C.FunctionDef C.NoScope C.Void (destroy_fn_name ifn) params [
 160.282 -    C.StmtList common_destroy,
 160.283 -    C.Ex $ C.Call "bmp_chan_destroy" [C.AddressOf $ statevar `C.FieldOf` "chan"]]
 160.284 -    where
 160.285 -      statevar = C.DerefField my_bindvar "bmp_state"
 160.286 -      params = [C.Param (C.Ptr $ C.Struct (bind_type ifn)) my_bindvar_name]
 160.287 -      common_destroy = binding_struct_destroy ifn (C.DerefField my_bindvar "b")
 160.288 -
 160.289 -bind_fn :: String -> C.Unit
 160.290 -bind_fn ifn =
 160.291 -    C.FunctionDef C.NoScope (C.TypeName "errval_t") (bind_fn_name ifn) params [
 160.292 -        localvar (C.TypeName "errval_t") "err" Nothing,
 160.293 -        C.Ex $ C.Call (init_fn_name ifn) [my_bindvar, C.Variable "waitset"],
 160.294 -        C.Ex $ C.Assignment (intf_bind_field "st") (C.Variable "st"),
 160.295 -        C.Ex $ C.Assignment (intf_bind_field "bind_cont") (C.Variable intf_cont_var),
 160.296 -        C.Ex $ C.Assignment (my_bindvar `C.DerefField` "iref") (C.Variable "iref"),
 160.297 -        C.Ex $ C.Assignment (my_bindvar `C.DerefField` "ep_buflen") (C.Variable "ep_buflen"),
 160.298 -        C.SBlank,
 160.299 -        C.SComment "do we need a new monitor binding?",
 160.300 -        C.If (C.Binary C.BitwiseAnd (C.Variable "flags") (C.Variable "IDC_BIND_FLAG_RPC_CAP_TRANSFER"))
 160.301 -            [C.Ex $ C.Assignment errvar $ C.Call "monitor_client_new_binding"
 160.302 -                [C.Variable (new_monitor_cont_fn_name ifn),
 160.303 -                 my_bindvar, C.Variable "waitset",
 160.304 -                 C.Variable "DEFAULT_LMP_BUF_WORDS"],
 160.305 -             C.If (C.Call "err_is_fail" [errvar])
 160.306 -                [C.Ex $ C.Assignment errvar $
 160.307 -                    C.Call "err_push" [errvar, C.Variable "LIB_ERR_MONITOR_CLIENT_BIND"]] []
 160.308 -            ]
 160.309 -            -- no new monitor binding, just bind
 160.310 -            [C.Ex $ C.Assignment errvar $ C.Call "bmp_chan_bind"
 160.311 -                [C.AddressOf $ my_bindvar `C.DerefField` "bmp_state" `C.FieldOf` "chan",
 160.312 -                 C.StructConstant "bmp_bind_continuation"
 160.313 -                    [("handler", C.Variable (bind_cont_fn_name ifn)),
 160.314 -                     ("st", my_bindvar)],
 160.315 -                 C.AddressOf $ intf_bind_field "event_qnode",
 160.316 -                 C.Variable "iref",
 160.317 -                 C.Call "get_monitor_binding" [],
 160.318 -                 C.Variable "ep_buflen"]],
 160.319 -        C.If (C.Call "err_is_fail" [errvar])
 160.320 -            [C.Ex $ C.Call (destroy_fn_name ifn) [my_bindvar]] [],
 160.321 -        C.Return errvar
 160.322 -    ]
 160.323 -    where 
 160.324 -      params = bind_params ifn
 160.325 -      intf_bind_field = C.FieldOf (C.DerefField my_bindvar "b")
 160.326 -
 160.327 -
 160.328 -new_monitor_cont_fn :: String -> C.Unit
 160.329 -new_monitor_cont_fn ifn =
 160.330 -    C.FunctionDef C.Static C.Void (new_monitor_cont_fn_name ifn) params [
 160.331 -        localvar (C.Ptr $ C.Struct $ intf_bind_type ifn)
 160.332 -                intf_bind_var (Just $ C.Variable "st"),
 160.333 -        localvar (C.Ptr $ C.Struct $ bind_type ifn)
 160.334 -                my_bindvar_name (Just $ C.Variable "st"),
 160.335 -        C.SBlank,
 160.336 -
 160.337 -        C.If (C.Call "err_is_fail" [errvar])
 160.338 -            [C.Ex $ C.Assignment errvar $
 160.339 -                C.Call "err_push" [errvar, C.Variable "LIB_ERR_MONITOR_CLIENT_BIND"],
 160.340 -             C.Goto "out"] [],
 160.341 -        C.SBlank,
 160.342 -
 160.343 -        C.Ex $ C.Assignment (chanvar `C.FieldOf` "monitor_binding") (C.Variable "monitor_binding"),
 160.344 -        C.SComment "start the bind on the new monitor binding",
 160.345 -        C.Ex $ C.Assignment errvar $ C.Call "bmp_chan_bind"
 160.346 -           [C.AddressOf $ chanvar,
 160.347 -            C.StructConstant "bmp_bind_continuation"
 160.348 -               [("handler", C.Variable (bind_cont_fn_name ifn)),
 160.349 -                ("st", my_bindvar)],
 160.350 -            C.AddressOf $ bindvar `C.DerefField` "event_qnode",
 160.351 -            my_bindvar `C.DerefField` "iref",
 160.352 -            C.Variable "monitor_binding",
 160.353 -            my_bindvar `C.DerefField` "ep_buflen"],
 160.354 -        C.SBlank,
 160.355 -
 160.356 -        C.Label "out",
 160.357 -        C.If (C.Call "err_is_fail" [errvar])
 160.358 -            [C.Ex $ C.CallInd (bindvar `C.DerefField` "bind_cont")
 160.359 -                [bindvar `C.DerefField` "st", errvar, bindvar],
 160.360 -            C.Ex $ C.Call (destroy_fn_name ifn) [my_bindvar]] []
 160.361 -    ]
 160.362 -    where
 160.363 -        params = [C.Param (C.Ptr C.Void) "st",
 160.364 -                  C.Param (C.TypeName "errval_t") "err",
 160.365 -                  C.Param (C.Ptr $ C.Struct "monitor_binding") "monitor_binding"]
 160.366 -        chanvar = my_bindvar `C.DerefField` "bmp_state" `C.FieldOf` "chan"
 160.367 -
 160.368 -
 160.369 -bind_cont_fn :: String -> C.Unit
 160.370 -bind_cont_fn ifn =
 160.371 -    C.FunctionDef C.Static C.Void (bind_cont_fn_name ifn) params [
 160.372 -        localvar (C.Ptr $ C.Struct $ intf_bind_type ifn)
 160.373 -            intf_bind_var (Just $ C.Variable "st"),
 160.374 -        localvar (C.Ptr $ C.Struct $ bind_type ifn)
 160.375 -            my_bindvar_name (Just $ C.Variable "st"),
 160.376 -        C.SBlank,
 160.377 -
 160.378 -        C.If (C.Call "err_is_ok" [errvar])
 160.379 -            [C.StmtList $ setup_cap_handlers ifn,
 160.380 -             C.StmtList $ register_recv ifn]
 160.381 -            [C.Ex $ C.Call (destroy_fn_name ifn) [my_bindvar]],
 160.382 -        C.SBlank,
 160.383 -
 160.384 -        C.Ex $ C.CallInd (intf_var `C.FieldOf` "bind_cont")
 160.385 -            [intf_var `C.FieldOf` "st", errvar, C.AddressOf intf_var]]
 160.386 -    where
 160.387 -      params = [C.Param (C.Ptr C.Void) "st",
 160.388 -                C.Param (C.TypeName "errval_t") "err",
 160.389 -                C.Param (C.Ptr $ C.Struct "bmp_chan") "chan"]
 160.390 -      intf_var = C.DerefField my_bindvar "b"
 160.391 -      errvar = C.Variable "err"
 160.392 -      chanaddr = C.Variable "chan"
 160.393 -
 160.394 -connect_handler_fn :: String -> C.Unit
 160.395 -connect_handler_fn ifn = C.FunctionDef C.NoScope (C.TypeName "errval_t")
 160.396 -    (drv_connect_handler_name "bmp" ifn) connect_handler_params [
 160.397 -    localvar (C.Ptr $ C.Struct $ export_type ifn) "e" $ Just $ C.Variable "st",
 160.398 -    localvar (C.TypeName "errval_t") "err" Nothing,
 160.399 -    C.SBlank,
 160.400 -    C.SComment "allocate storage for binding",
 160.401 -    localvar (C.Ptr $ C.Struct $ bind_type ifn) my_bindvar_name
 160.402 -        $ Just $ C.Call "malloc" [C.SizeOfT $ C.Struct $ bind_type ifn],
 160.403 -    C.If (C.Binary C.Equals my_bindvar (C.Variable "NULL"))
 160.404 -        [C.Return $ C.Variable "LIB_ERR_MALLOC_FAIL"] [],
 160.405 -    C.SBlank,
 160.406 -    
 160.407 -    localvar (C.Ptr $ C.Struct $ intf_bind_type ifn)
 160.408 -         intf_bind_var (Just $ C.AddressOf $ my_bindvar `C.DerefField` "b"),
 160.409 -    C.Ex $ C.Call (init_fn_name ifn) [my_bindvar,
 160.410 -                                          exportvar `C.DerefField` "waitset"],
 160.411 -    C.SBlank,
 160.412 -
 160.413 -    C.SComment "run user's connect handler",
 160.414 -    C.Ex $ C.Assignment errvar $ C.CallInd (C.DerefField exportvar "connect_cb")
 160.415 -                       [C.DerefField exportvar "st", bindvar],
 160.416 -    C.If (C.Call "err_is_fail" [errvar])
 160.417 -        [C.SComment "connection refused",
 160.418 -         C.Ex $ C.Call (destroy_fn_name ifn) [my_bindvar],
 160.419 -         C.Return $ errvar] [],
 160.420 -    C.SBlank,
 160.421 -
 160.422 -    C.SComment "accept the connection and setup the channel",
 160.423 -    C.SComment "FIXME: user policy needed to decide on the size of the message buffer?",
 160.424 -    C.Ex $ C.Assignment errvar $ C.Call "bmp_chan_accept"
 160.425 -                                [chanaddr,
 160.426 -                                 C.Variable "monitor_id", C.Variable "bee_ep",
 160.427 -                                 C.Variable "bee_ep_len", C.Variable "bee_ep_len"],
 160.428 -    C.If (C.Call "err_is_fail" [errvar])
 160.429 -        [C.Ex $ C.Assignment errvar $ C.Call "err_push"
 160.430 -                    [errvar, C.Variable "LIB_ERR_BMP_CHAN_ACCEPT"],
 160.431 -         report_user_err errvar,
 160.432 -         C.Return $ errvar] [],
 160.433 -    C.SBlank,
 160.434 -
 160.435 -    C.StmtList $ register_recv ifn,
 160.436 -    C.StmtList $ setup_cap_handlers ifn,
 160.437 -    C.SBlank,
 160.438 -
 160.439 -    C.SComment "send back bind reply",
 160.440 -    C.Ex $ C.Call "bmp_chan_send_bind_reply"
 160.441 -         [C.Variable "monitor_binding", chanaddr, C.Variable "SYS_ERR_OK",
 160.442 -          C.Variable "monitor_id"],
 160.443 -    C.Return $ C.Variable "SYS_ERR_OK"]
 160.444 -    where
 160.445 -        exportvar = C.Variable "e"
 160.446 -        chanaddr = C.AddressOf $ chanvar
 160.447 -        chanvar = C.DerefField my_bindvar "bmp_state" `C.FieldOf` "chan"
 160.448 -
 160.449 -change_waitset_fn_def :: String -> C.Unit
 160.450 -change_waitset_fn_def ifn = 
 160.451 -    C.FunctionDef C.Static (C.TypeName "errval_t") (change_waitset_fn_name ifn) params [
 160.452 -        localvar (C.Ptr $ C.Struct $ bind_type ifn)
 160.453 -            my_bindvar_name (Just $ C.Cast (C.Ptr C.Void) bindvar),
 160.454 -        localvar (C.TypeName "errval_t") "err" Nothing,
 160.455 -        C.SBlank,
 160.456 -
 160.457 -        C.SComment "change waitset on private monitor binding if we have one",
 160.458 -        C.If (C.Binary C.NotEquals (chanvar `C.FieldOf` "monitor_binding") (C.Call "get_monitor_binding" []))
 160.459 -            [C.Ex $ C.Assignment errvar $
 160.460 -                C.Call "flounder_support_change_monitor_waitset"
 160.461 -                    [chanvar `C.FieldOf` "monitor_binding", C.Variable "ws"],
 160.462 -             C.If (C.Call "err_is_fail" [errvar])
 160.463 -                [C.Return $
 160.464 -                    C.Call "err_push" [errvar, C.Variable "FLOUNDER_ERR_CHANGE_MONITOR_WAITSET"]]
 160.465 -                []
 160.466 -            ] [],
 160.467 -        C.SBlank,
 160.468 -
 160.469 -        C.SComment "change waitset on binding",
 160.470 -        C.Ex $ C.Assignment
 160.471 -            (bindvar `C.DerefField` "waitset")
 160.472 -            (C.Variable "ws"),
 160.473 -        C.SBlank,
 160.474 -
 160.475 -        C.SComment "re-register for receive (if previously registered)",
 160.476 -        C.Ex $ C.Assignment errvar $ C.Call "bmp_chan_deregister_recv" [chanaddr],
 160.477 -        C.If (C.Binary C.And
 160.478 -                (C.Call "err_is_fail" [errvar])
 160.479 -                (C.Binary C.NotEquals (C.Call "err_no" [errvar])
 160.480 -                                    (C.Variable "LIB_ERR_CHAN_NOT_REGISTERED")))
 160.481 -            [C.Return $
 160.482 -               C.Call "err_push" [errvar, C.Variable "LIB_ERR_CHAN_DEREGISTER_RECV"]]
 160.483 -            [],
 160.484 -        C.If (C.Call "err_is_ok" [errvar]) [
 160.485 -            C.Ex $ C.Assignment errvar $ C.Call "bmp_chan_register_recv"
 160.486 -                [chanaddr, C.Variable "ws",
 160.487 -                 C.StructConstant "event_closure"
 160.488 -                    [("handler", C.Variable $ rx_handler_name ifn),
 160.489 -                     ("arg", bindvar)]],
 160.490 -            C.If (C.Call "err_is_fail" [errvar])
 160.491 -                [C.Return $
 160.492 -                    C.Call "err_push" [errvar, C.Variable "LIB_ERR_CHAN_REGISTER_RECV"]]
 160.493 -                []
 160.494 -            ] [],
 160.495 -        C.Return $ C.Variable "SYS_ERR_OK"
 160.496 -    ]
 160.497 -    where
 160.498 -        chanvar = my_bindvar `C.DerefField` "bmp_state" `C.FieldOf` "chan"
 160.499 -        chanaddr = C.AddressOf $ chanvar
 160.500 -        params = [C.Param (C.Ptr $ C.Struct $ intf_bind_type ifn) intf_bind_var,
 160.501 -                  C.Param (C.Ptr $ C.Struct "waitset") "ws"]
 160.502 -
 160.503 -
 160.504 -handler_preamble :: String -> C.Stmt
 160.505 -handler_preamble ifn = C.StmtList
 160.506 -    [C.SComment "Get the binding state from our argument pointer",
 160.507 -     localvar (C.Ptr $ C.Struct $ intf_bind_type ifn)
 160.508 -         intf_bind_var (Just $ C.Variable "arg"),
 160.509 -     localvar (C.Ptr $ C.Struct $ bind_type ifn)
 160.510 -         my_bindvar_name (Just $ C.Variable "arg"),
 160.511 -     localvar (C.TypeName "errval_t") "err" Nothing,
 160.512 -     C.Ex $ C.Assignment errvar (C.Variable "SYS_ERR_OK"),
 160.513 -     C.SBlank]
 160.514 -
 160.515 -tx_cap_handler :: String -> [MsgSpec] -> C.Unit
 160.516 -tx_cap_handler ifn msgspecs = 
 160.517 -    C.FunctionDef C.Static C.Void (tx_cap_handler_name ifn) [C.Param (C.Ptr C.Void) "arg"] [
 160.518 -        handler_preamble ifn,
 160.519 -
 160.520 -        C.Ex $ C.Call "assert" [capst `C.FieldOf` "rx_cap_ack"],
 160.521 -        C.Ex $ C.Call "assert" [capst `C.FieldOf` "monitor_mutex_held"],
 160.522 -        C.SBlank,
 160.523 -
 160.524 -        C.SComment "Switch on current outgoing message",
 160.525 -        C.Switch (C.DerefField bindvar "tx_msgnum") cases
 160.526 -            [C.Ex $ C.Call "assert"
 160.527 -                    [C.Unary C.Not $ C.StringConstant "invalid message number"],
 160.528 -             report_user_err (C.Variable "FLOUNDER_ERR_INVALID_STATE")]
 160.529 -    ]
 160.530 -    where
 160.531 -        bmpst = C.DerefField my_bindvar "bmp_state"
 160.532 -        capst = bmpst `C.FieldOf` "capst"
 160.533 -        cases = [C.Case (C.Variable $ msg_enum_elem_name ifn mn)
 160.534 -                        (tx_cap_handler_case ifn mn (length frags) caps)
 160.535 -                 | MsgSpec mn frags caps <- msgspecs, caps /= []]
 160.536 -
 160.537 -tx_cap_handler_case :: String -> String -> Int -> [CapFieldTransfer] -> [C.Stmt]
 160.538 -tx_cap_handler_case ifn mn nfrags caps = [
 160.539 -    C.SComment "Switch on current outgoing cap",
 160.540 -    C.Switch (capst `C.FieldOf` "tx_capnum") cases
 160.541 -            [C.Ex $ C.Call "assert"
 160.542 -                    [C.Unary C.Not $ C.StringConstant "invalid cap number"],
 160.543 -             report_user_err (C.Variable "FLOUNDER_ERR_INVALID_STATE")],
 160.544 -    C.Break]
 160.545 -    where
 160.546 -        give_away_val :: CapTransferMode -> C.Expr
 160.547 -        give_away_val Copied = C.Variable "false"
 160.548 -        give_away_val GiveAway = C.Variable "true"
 160.549 -
 160.550 -        bmpst = C.DerefField my_bindvar "bmp_state"
 160.551 -        capst = bmpst `C.FieldOf` "capst"
 160.552 -        chan = bmpst `C.FieldOf` "chan"
 160.553 -        cases = [C.Case (C.NumConstant $ toInteger i) $ subcase cap i
 160.554 -                 | (cap, i) <- zip caps [0..]] ++ 
 160.555 -                [C.Case (C.NumConstant $ toInteger $ length caps) last_case]
 160.556 -
 160.557 -        last_case = [
 160.558 -            -- release our lock on the monitor binding
 160.559 -            C.Ex $ C.Call "flounder_support_monitor_mutex_unlock"
 160.560 -                    [chan `C.FieldOf` "monitor_binding"],
 160.561 -
 160.562 -            -- if we've sent the last cap, and we've sent all the other fragments, we're done
 160.563 -            C.If (C.Binary C.Equals tx_msgfrag_field
 160.564 -                                (C.NumConstant $ toInteger nfrags))
 160.565 -                    finished_send [],
 160.566 -            C.Break]
 160.567 -        tx_msgfrag_field = C.DerefField bindvar "tx_msg_fragment"
 160.568 -
 160.569 -        subcase :: CapFieldTransfer -> Int -> [C.Stmt]
 160.570 -        subcase (CapFieldTransfer tm cap) ncap = [
 160.571 -            C.Ex $ C.Assignment errvar $ C.Call "flounder_stub_send_cap"
 160.572 -                [C.AddressOf $ capst, chan `C.FieldOf` "monitor_binding",
 160.573 -                 chan `C.FieldOf` "monitor_id", argfield_expr TX mn cap,
 160.574 -                 give_away_val tm, C.Variable $ tx_cap_handler_name ifn],
 160.575 -            C.If (C.Call "err_is_fail" [errvar])
 160.576 -                [report_user_tx_err errvar, C.Break] [],
 160.577 -            C.Break]
 160.578 -
 160.579 -tx_handler :: String -> [MsgSpec] -> C.Unit
 160.580 -tx_handler ifn msgs =
 160.581 -    C.FunctionDef C.Static C.Void (tx_handler_name ifn) [C.Param (C.Ptr C.Void) "arg"] [
 160.582 -        handler_preamble ifn,
 160.583 -
 160.584 -        C.SComment "do we need to (and can we) send a cap ack?",
 160.585 -        C.If (C.Binary C.And
 160.586 -                    (capst `C.FieldOf` "tx_cap_ack")
 160.587 -                    (C.Call "flounder_stub_bmp_can_send" [C.AddressOf bmpst,
 160.588 -                                                          C.NumConstant 1]))
 160.589 -            [C.Ex $ C.Assignment errvar $
 160.590 -                    C.Call "flounder_stub_bmp_send_cap_ack" [C.AddressOf bmpst],
 160.591 -             C.If (C.Call "err_is_ok" [errvar])
 160.592 -                [C.Ex $ C.Assignment (capst `C.FieldOf` "tx_cap_ack") (C.Variable "false")]
 160.593 -                [C.Goto "out"]] [],
 160.594 -        C.SBlank,
 160.595 -
 160.596 -        C.SComment "Switch on current outgoing message number",
 160.597 -        C.Switch (C.DerefField bindvar "tx_msgnum") msgcases
 160.598 -            [C.Ex $ C.Call "assert" [C.Unary C.Not $ C.StringConstant "invalid msgnum"],
 160.599 -                report_user_err (C.Variable "FLOUNDER_ERR_INVALID_STATE")],
 160.600 -        C.SBlank,
 160.601 -
 160.602 -        C.SComment "send a forced ack if the incoming channel is still full",
 160.603 -        C.If (C.Binary C.And (C.Call "err_is_ok" [errvar])
 160.604 -                                (C.Call "flounder_stub_bmp_needs_ack" [C.AddressOf $ bmpst]))
 160.605 -            [C.Ex $ C.Assignment errvar $ C.Call "flounder_stub_bmp_send_ack" [C.AddressOf $ bmpst]] [],
 160.606 -        C.SBlank,
 160.607 -
 160.608 -        C.Label "out",
 160.609 -        C.If (C.Call "err_is_fail" [errvar])
 160.610 -            [C.If (C.Binary C.Equals (C.Call "err_no" [errvar]) (C.Variable "SYS_ERR_BMP_TX_BUSY"))
 160.611 -                -- transient error: re-register to send
 160.612 -                [C.Ex $ C.Assignment errvar
 160.613 -                        (C.Call "bmp_chan_register_send" [
 160.614 -                            C.AddressOf $ bmpst `C.FieldOf` "chan",
 160.615 -                            C.DerefField bindvar "waitset",
 160.616 -                            C.StructConstant "event_closure" [
 160.617 -                                ("handler", C.Variable $ tx_handler_name ifn),
 160.618 -                                ("arg", C.Variable "arg")]]),
 160.619 -                 C.Ex $ C.Call "assert" [C.Call "err_is_ok" [errvar]]]
 160.620 -                [C.If (C.Binary C.Equals (C.Call "err_no" [errvar]) (C.Variable "FLOUNDER_ERR_BUF_SEND_MORE"))
 160.621 -                    -- transient error: flow control, need to wait for rx before we can send more
 160.622 -                    [C.SComment "do nothing; waiting to receive an ack"]
 160.623 -                    -- permanent errors
 160.624 -                    [C.SComment "Report error to user",
 160.625 -                     report_user_tx_err errvar]]] []
 160.626 -    ]
 160.627 -    where
 160.628 -        inc_fragnum = C.Ex $ C.PostInc $ C.DerefField bindvar "tx_msg_fragment"
 160.629 -        tx_msgnum_field = C.DerefField bindvar "tx_msgnum"
 160.630 -        bmpst = C.DerefField my_bindvar "bmp_state"
 160.631 -        capst = bmpst `C.FieldOf` "capst"
 160.632 -
 160.633 -        msgcases = (C.Case (C.NumConstant 0) [C.Break]):
 160.634 -                   [C.Case (C.Variable $ msg_enum_elem_name ifn mn)
 160.635 -                    $ gen_msgcase mn msgfrags caps
 160.636 -                    | MsgSpec mn msgfrags caps <- msgs]
 160.637 -    
 160.638 -        gen_msgcase mn msgfrags caps = [
 160.639 -            C.SComment "Switch on current outgoing message fragment",
 160.640 -            C.Switch (C.DerefField bindvar "tx_msg_fragment") fragcases
 160.641 -                [C.Ex $ C.Call "assert" [C.Unary C.Not $ C.StringConstant "invalid fragment"],
 160.642 -                    report_user_err (C.Variable "FLOUNDER_ERR_INVALID_STATE")],
 160.643 -            C.Break]
 160.644 -
 160.645 -            where
 160.646 -            fragcases = [C.Case (C.NumConstant $ toInteger i)
 160.647 -                         $ (tx_handler_case ifn mn frag) ++ gen_epilog i
 160.648 -                         | (frag, i) <- zip msgfrags [0..]]
 160.649 -                     ++ [C.Case (C.NumConstant $ toInteger $ length msgfrags)
 160.650 -                         $ last_frag]
 160.651 -
 160.652 -            last_frag = [
 160.653 -                C.SComment "we've sent all the fragments, we must just be waiting for caps",
 160.654 -                C.Ex $ C.Call "assert"
 160.655 -                    [C.Binary C.LessThanEq (capst `C.FieldOf` "tx_capnum")
 160.656 -                            (C.NumConstant $ toInteger $ length caps)],
 160.657 -                C.Break]
 160.658 -
 160.659 -            -- generate the code that runs after the send succeeds
 160.660 -            gen_epilog i =
 160.661 -                [C.If (C.Call "err_is_fail" [errvar]) [C.Break] [], inc_fragnum] ++
 160.662 -                if (i + 1 == length msgfrags) then
 160.663 -                    -- if the last fragment succeeds, and we've sent all the caps, we're done
 160.664 -                    -- otherwise we'll need to wait to finish sending the caps
 160.665 -                    ((if caps /= [] then
 160.666 -                        [C.If (C.Binary C.Equals (capst `C.FieldOf` "tx_capnum")
 160.667 -                            (C.NumConstant $ toInteger $ length caps + 1))
 160.668 -                            finished_send []]
 160.669 -                     else finished_send)
 160.670 -                     ++ [C.ReturnVoid])
 160.671 -                else -- more fragments to go
 160.672 -                    [C.SComment "fall through to next fragment"]
 160.673 -
 160.674 -
 160.675 -tx_handler_case :: String -> String -> MsgFragment -> [C.Stmt]
 160.676 -tx_handler_case ifn mn (MsgFragment words) = [
 160.677 -    C.SComment "check if we can send another message",
 160.678 -    C.If (C.Unary C.Not $ C.Call "flounder_stub_bmp_can_send"
 160.679 -                                [stateaddr, C.NumConstant $ toInteger msglen])
 160.680 -        [C.Break] [],
 160.681 -    C.SBlank,
 160.682 -
 160.683 -    C.SComment "send the next fragment",
 160.684 -    localvar (C.Array (toInteger msglen) (C.TypeName "uintptr_t")) "msg"
 160.685 -        (Just $ C.ArrayConstant $ header:payload),
 160.686 -     C.Ex $ C.Assignment errvar $ C.Call "flounder_stub_bmp_send"
 160.687 -        [stateaddr, C.Variable "msg", C.NumConstant $ toInteger msglen]
 160.688 -    ] where
 160.689 -        msglen = length words + 1 -- for header
 160.690 -        header = C.Call "flounder_stub_bmp_mkheader" [stateaddr, msgnum_arg]
 160.691 -        payload = map (fragment_word_to_expr arch ifn mn) words
 160.692 -        msgnum_arg = C.Variable $ msg_enum_elem_name ifn mn
 160.693 -        statevar = C.DerefField my_bindvar "bmp_state"
 160.694 -        stateaddr = C.AddressOf statevar
 160.695 -        chanaddr = C.AddressOf $ C.FieldOf statevar "chan"
 160.696 -
 160.697 -tx_handler_case ifn mn (OverflowFragment (StringFragment af)) =
 160.698 -    [C.Ex $ C.Assignment errvar (C.Call "flounder_stub_bmp_send_string" args)]
 160.699 -    where
 160.700 -        args = [chan_arg, msgnum_arg, string_arg, pos_arg, len_arg]
 160.701 -        chan_arg = C.AddressOf $ C.DerefField my_bindvar "bmp_state"
 160.702 -        msgnum_arg = C.Variable $ msg_enum_elem_name ifn mn
 160.703 -        string_arg = argfield_expr TX mn af
 160.704 -        pos_arg = C.AddressOf $ C.DerefField bindvar "tx_str_pos"
 160.705 -        len_arg = C.AddressOf $ C.DerefField bindvar "tx_str_len"
 160.706 -
 160.707 -tx_handler_case ifn mn (OverflowFragment (BufferFragment _ afn afl)) =
 160.708 -    [C.Ex $ C.Assignment errvar (C.Call "flounder_stub_bmp_send_buf" args)]
 160.709 -    where
 160.710 -        args = [chan_arg, msgnum_arg, buf_arg, len_arg, pos_arg]
 160.711 -        chan_arg = C.AddressOf $ C.DerefField my_bindvar "bmp_state"
 160.712 -        msgnum_arg = C.Variable $ msg_enum_elem_name ifn mn
 160.713 -        buf_arg = argfield_expr TX mn afn
 160.714 -        len_arg = argfield_expr TX mn afl
 160.715 -        pos_arg = C.AddressOf $ C.DerefField bindvar "tx_str_pos"
 160.716 -
 160.717 -
 160.718 -tx_fn :: String -> [TypeDef] -> MessageDef -> MsgSpec -> C.Unit
 160.719 -tx_fn ifn typedefs msg@(Message _ n args _) (MsgSpec _ _ caps) =
 160.720 -    C.FunctionDef C.Static (C.TypeName "errval_t") (tx_fn_name ifn n) params body
 160.721 -    where
 160.722 -        params = [binding_param ifn, cont_param] ++ (
 160.723 -                    concat [ msg_argdecl TX ifn a | a <- args ])
 160.724 -        cont_param = C.Param (C.Struct "event_closure") intf_cont_var
 160.725 -        body = [
 160.726 -            C.SComment "check that we can accept an outgoing message",
 160.727 -            C.If (C.Binary C.NotEquals tx_msgnum_field (C.NumConstant 0))
 160.728 -                [C.Return $ C.Variable "FLOUNDER_ERR_TX_BUSY"] [],
 160.729 -            C.SBlank,
 160.730 -            C.SComment "register send continuation",
 160.731 -            C.StmtList $ register_txcont (C.Variable intf_cont_var),
 160.732 -            C.SBlank,
 160.733 -            C.SComment "store message number and arguments",
 160.734 -            C.Ex $ C.Assignment tx_msgnum_field (C.Variable $ msg_enum_elem_name ifn n),
 160.735 -            C.Ex $ C.Assignment tx_msgfrag_field (C.NumConstant 0),
 160.736 -            C.StmtList [ tx_arg_assignment ifn typedefs n a | a <- args ],
 160.737 -            C.StmtList $ start_send drvname ifn n args,
 160.738 -            C.SBlank,
 160.739 -            -- if this message has caps, we need to acquire the monitor binding mutex
 160.740 -            C.StmtList $ if caps /= [] then
 160.741 -                [C.SComment "init cap send state",
 160.742 -                 C.Ex $ C.Assignment (capst `C.FieldOf` "tx_capnum") (C.NumConstant 0),
 160.743 -                 C.Ex $ C.Assignment (capst `C.FieldOf` "rx_cap_ack") (C.Variable "false"),
 160.744 -                 C.Ex $ C.Assignment (capst `C.FieldOf` "monitor_mutex_held") (C.Variable "false"),
 160.745 -                 C.SBlank,
 160.746 -
 160.747 -                 C.SComment "wait to acquire the monitor binding mutex",
 160.748 -                 C.Ex $ C.Call "flounder_support_monitor_mutex_enqueue"
 160.749 -                    [bmpst `C.FieldOf` "chan" `C.FieldOf` "monitor_binding",
 160.750 -                     C.AddressOf $ bindvar `C.DerefField` "event_qnode",
 160.751 -                     C.StructConstant "event_closure" [
 160.752 -                        ("handler", C.Variable $ monitor_mutex_cont_name ifn),
 160.753 -                        ("arg", bindvar)]],
 160.754 -                 C.SBlank]
 160.755 -                else [],
 160.756 -            C.SComment "try to send!",
 160.757 -            C.Ex $ C.Call (tx_handler_name ifn) [bindvar],
 160.758 -            C.SBlank,
 160.759 -            C.Return $ C.Variable "SYS_ERR_OK"
 160.760 -            ]
 160.761 -        bmpvar = C.Cast (C.Ptr $ C.Struct $ bind_type ifn) bindvar
 160.762 -        bmpst = C.DerefField bmpvar "bmp_state"
 160.763 -        capst = bmpst `C.FieldOf` "capst"
 160.764 -        tx_msgnum_field = C.DerefField bindvar "tx_msgnum"
 160.765 -        tx_msgfrag_field = C.DerefField bindvar "tx_msg_fragment"
 160.766 -
 160.767 -tx_vtbl :: String -> [MessageDef] -> C.Unit
 160.768 -tx_vtbl ifn ml =
 160.769 -    C.StructDef C.Static (intf_vtbl_type ifn TX) (tx_vtbl_name ifn) fields
 160.770 -    where
 160.771 -        fields = [let mn = msg_name m in (mn, tx_fn_name ifn mn) | m <- ml]
 160.772 -
 160.773 -monitor_mutex_cont :: String -> C.Unit
 160.774 -monitor_mutex_cont ifn =
 160.775 -    C.FunctionDef C.Static C.Void (monitor_mutex_cont_name ifn) [C.Param (C.Ptr C.Void) "arg"] [
 160.776 -        localvar (C.Ptr $ C.Struct $ bind_type ifn) my_bindvar_name (Just $ C.Variable "arg"),
 160.777 -        C.Ex $ C.Call "assert" [C.Unary C.Not (capst `C.FieldOf` "monitor_mutex_held")],
 160.778 -        C.Ex $ C.Assignment (capst `C.FieldOf` "monitor_mutex_held") (C.Variable "true"),
 160.779 -        C.If (capst `C.FieldOf` "rx_cap_ack")
 160.780 -            [C.Ex $ C.Call (tx_cap_handler_name ifn) [my_bindvar]] []
 160.781 -    ]
 160.782 -    where
 160.783 -        statevar = C.DerefField my_bindvar "bmp_state"
 160.784 -        capst = statevar `C.FieldOf` "capst"
 160.785 -
 160.786 -rx_handler :: String -> [TypeDef] -> [MessageDef] -> [MsgSpec] -> C.Unit
 160.787 -rx_handler ifn typedefs msgdefs msgs =
 160.788 -    C.FunctionDef C.NoScope C.Void (rx_handler_name ifn) [C.Param (C.Ptr C.Void) "arg"] [
 160.789 -        handler_preamble ifn,
 160.790 -
 160.791 -        -- local variables
 160.792 -        localvar (C.Struct "bmp_recv_msg") "msg" (Just $ C.Variable "BMP_RECV_MSG_INIT"),
 160.793 -        localvar (C.TypeName "int") "msgnum" Nothing,
 160.794 -        C.SBlank,
 160.795 -
 160.796 -        C.While (C.Variable "true") loopbody,
 160.797 -        C.SBlank,
 160.798 -
 160.799 -        C.Label "out",
 160.800 -        C.StmtList $ register_recv ifn,
 160.801 -        C.SBlank,
 160.802 -
 160.803 -        -- XXX: hack around the AST to get an attribute on this label, which may not be used
 160.804 -        C.Label "out_no_reregister",
 160.805 -        C.Ex $ C.Variable "__attribute__((unused))",
 160.806 -
 160.807 -        C.SComment "run our send process, if we need to",
 160.808 -        C.If (C.Binary C.Or
 160.809 -                    (C.Binary C.Or
 160.810 -                        (capst `C.FieldOf` "tx_cap_ack")
 160.811 -                        (C.Binary C.NotEquals
 160.812 -                            (bindvar `C.DerefField` "tx_msgnum")
 160.813 -                            (C.NumConstant 0)))
 160.814 -                    (C.Call "flounder_stub_bmp_needs_ack" [stateaddr]))
 160.815 -            [C.Ex $ C.Call (tx_handler_name ifn) [my_bindvar]] []
 160.816 -    ] where
 160.817 -        loopbody = [
 160.818 -            C.SComment "try to retrieve a message from the channel",
 160.819 -            C.Ex $ C.Assignment errvar
 160.820 -                    $ C.Call "bmp_chan_recv" [chanaddr,
 160.821 -                                C.AddressOf $ C.Variable "msg"],
 160.822 -
 160.823 -            C.SComment "check if we succeeded",
 160.824 -            C.If (C.Call "err_is_fail" [errvar])
 160.825 -                -- if err_is_fail, check err_no
 160.826 -                [C.If (C.Binary C.Equals (C.Call "err_no" [errvar]) (C.Variable "LIB_ERR_NO_LMP_MSG"))
 160.827 -                    [C.SComment "no message",
 160.828 -                     C.Break]
 160.829 -                    [C.SComment "real error",
 160.830 -                     report_user_err $ C.Call "err_push" [errvar, C.Variable "LIB_ERR_BMP_CHAN_RECV"],
 160.831 -                     C.ReturnVoid]
 160.832 -                ] [],
 160.833 -            C.SBlank,
 160.834 -
 160.835 -            C.SComment "check message length",
 160.836 -            C.If (C.Binary C.Equals msglen (C.NumConstant 0)) [
 160.837 -                report_user_err $ C.Variable "FLOUNDER_ERR_RX_EMPTY_MSG",
 160.838 -                C.Break] [],
 160.839 -            C.SBlank,
 160.840 -
 160.841 -            C.SComment "process control word",
 160.842 -            C.Ex $ C.Assignment (C.Variable "msgnum")
 160.843 -                 $ C.Call "flounder_stub_bmp_process_header"
 160.844 -                    [stateaddr, C.SubscriptOf msgwords $ C.NumConstant 0, msglen],
 160.845 -            C.SBlank,
 160.846 -
 160.847 -            C.SComment "is this a dummy message (ACK)?",
 160.848 -            C.If (C.Binary C.Equals (C.Variable "msgnum") (C.Variable "FL_BMP_ACK"))
 160.849 -                [C.Continue] [],
 160.850 -            C.SBlank,
 160.851 -
 160.852 -            C.SComment "is this a cap ack for a pending tx message",
 160.853 -            C.If (C.Binary C.Equals (C.Variable "msgnum") (C.Variable "FL_BMP_CAP_ACK"))
 160.854 -                [C.Ex $ C.Call "assert" [C.Unary C.Not (capst `C.FieldOf` "rx_cap_ack")],
 160.855 -                 C.Ex $ C.Assignment (capst `C.FieldOf` "rx_cap_ack") (C.Variable "true"),
 160.856 -                 C.If (capst `C.FieldOf` "monitor_mutex_held")
 160.857 -                    [C.Ex $ C.Call (tx_cap_handler_name ifn) [my_bindvar]] [],
 160.858 -                 C.Continue]
 160.859 -                [],
 160.860 -            C.SBlank,
 160.861 -
 160.862 -            C.SComment "is this the start of a new message?",
 160.863 -            C.If (C.Binary C.Equals rx_msgnum_field (C.NumConstant 0)) [
 160.864 -                C.Ex $ C.Assignment rx_msgnum_field (C.Variable "msgnum"),
 160.865 -                C.Ex $ C.Assignment rx_msgfrag_field (C.NumConstant 0)
 160.866 -            ] [],
 160.867 -            C.SBlank,
 160.868 -
 160.869 -            C.SComment "switch on message number and fragment number",
 160.870 -            C.Switch rx_msgnum_field msgnum_cases bad_msgnum]
 160.871 -
 160.872 -        statevar = C.DerefField my_bindvar "bmp_state"
 160.873 -        capst = statevar `C.FieldOf` "capst"
 160.874 -        stateaddr = C.AddressOf statevar
 160.875 -        chanaddr = C.AddressOf $ statevar `C.FieldOf` "chan"
 160.876 -        msglen = C.Variable "msg" `C.FieldOf` "buf" `C.FieldOf` "msglen"
 160.877 -        msgwords = C.Variable "msg" `C.FieldOf` "words"
 160.878 -        rx_msgnum_field = C.DerefField bindvar "rx_msgnum"
 160.879 -        rx_msgfrag_field = C.DerefField bindvar "rx_msg_fragment"
 160.880 -
 160.881 -        msgnum_cases = [C.Case (C.Variable $ msg_enum_elem_name ifn mn) (msgnum_case msgdef msg)
 160.882 -                            | (msgdef, msg@(MsgSpec mn _ _)) <- zip msgdefs msgs]
 160.883 -
 160.884 -        msgnum_case msgdef@(Message _ _ msgargs _) (MsgSpec mn frags caps) = [
 160.885 -            C.Switch rx_msgfrag_field
 160.886 -                [C.Case (C.NumConstant $ toInteger i) $
 160.887 -                 (if i == 0 then
 160.888 -                    -- first fragment of a message
 160.889 -                    start_recv drvname ifn typedefs mn msgargs ++ 
 160.890 -                    (if caps /= [] then [
 160.891 -                        -- + with caps received
 160.892 -                        C.Ex $ C.Assignment
 160.893 -                            (capst `C.FieldOf` "tx_cap_ack") (C.Variable "true"),
 160.894 -                        C.Ex $ C.Assignment
 160.895 -                            (capst `C.FieldOf` "rx_capnum") (C.NumConstant 0)
 160.896 -                        ] else []) 
 160.897 -                       else []) ++
 160.898 -                    (msgfrag_case msgdef frag caps (i == length frags - 1))
 160.899 -                 | (frag, i) <- zip frags [0..] ]
 160.900 -                bad_msgfrag,
 160.901 -            C.Break]
 160.902 -
 160.903 -        bad_msgnum = [report_user_err $ C.Variable "FLOUNDER_ERR_RX_INVALID_MSGNUM",
 160.904 -                      C.Goto "out"]
 160.905 -
 160.906 -        bad_msgfrag = [report_user_err $ C.Variable "FLOUNDER_ERR_INVALID_STATE",
 160.907 -                      C.Goto "out"]
 160.908 -
 160.909 -        msgfrag_case :: MessageDef -> MsgFragment -> [CapFieldTransfer] -> Bool -> [C.Stmt]
 160.910 -        msgfrag_case msg@(Message _ mn _ _) (MsgFragment wl) caps isLast = [
 160.911 -            C.StmtList $ concat [store_arg_frags arch ifn mn msgwords word 0 afl
 160.912 -                                 | (afl, word) <- zip wl [1..]],
 160.913 -            C.SBlank,
 160.914 -            C.StmtList $ msgfrag_case_prolog msg caps isLast,
 160.915 -            C.Break]
 160.916 -
 160.917 -        msgfrag_case msg@(Message _ mn _ _) (OverflowFragment ofrag) caps isLast = [
 160.918 -            C.Ex $ C.Assignment errvar (C.Call func args),
 160.919 -            C.If (C.Call "err_is_ok" [errvar])
 160.920 -                (msgfrag_case_prolog msg caps isLast)
 160.921 -                -- error from receive code, check if it's permanent
 160.922 -                [C.If (C.Binary C.NotEquals
 160.923 -                        (C.Call "err_no" [errvar])
 160.924 -                        (C.Variable "FLOUNDER_ERR_BUF_RECV_MORE"))
 160.925 -                    [report_user_err errvar] -- real error
 160.926 -                    [] -- will receive more next time
 160.927 -                ],
 160.928 -            C.Break]
 160.929 -            where
 160.930 -                msg_arg = C.AddressOf $ C.Variable "msg"
 160.931 -                pos_arg = C.AddressOf $ C.DerefField bindvar "rx_str_pos"
 160.932 -                (func, args) = case ofrag of
 160.933 -                    (BufferFragment _ afn afl) -> ("flounder_stub_bmp_recv_buf",
 160.934 -                                                   [msg_arg, buf_arg, len_arg, pos_arg])
 160.935 -                      where 
 160.936 -                        buf_arg = C.Cast (C.Ptr $ C.Ptr C.Void)
 160.937 -                                        $ C.AddressOf $ argfield_expr RX mn afn
 160.938 -                        len_arg = C.AddressOf $ argfield_expr RX mn afl
 160.939 -                    (StringFragment af) -> ("flounder_stub_bmp_recv_string",
 160.940 -                                            [msg_arg, string_arg, pos_arg, len_arg])
 160.941 -                      where
 160.942 -                        string_arg = C.AddressOf $ argfield_expr RX mn af
 160.943 -                        len_arg = C.AddressOf $ C.DerefField bindvar "rx_str_len"
 160.944 -
 160.945 -        msgfrag_case_prolog :: MessageDef -> [CapFieldTransfer] -> Bool -> [C.Stmt]
 160.946 -        -- intermediate fragment
 160.947 -        msgfrag_case_prolog _ _ False = [rx_fragment_increment]
 160.948 -
 160.949 -        -- last fragment: call handler and zero message number
 160.950 -        -- if we're expecting any caps, only do so if we've received them all
 160.951 -        msgfrag_case_prolog (Message _ mn msgargs _) caps True
 160.952 -            | caps == [] = finished_recv drvname ifn typedefs mn msgargs
 160.953 -            | otherwise = [
 160.954 -                rx_fragment_increment,
 160.955 -                C.If (C.Binary C.Equals
 160.956 -                                    (capst `C.FieldOf` "rx_capnum")
 160.957 -                                    (C.NumConstant $ toInteger $ length caps))
 160.958 -                    (finished_recv drvname ifn typedefs mn msgargs)
 160.959 -                    [C.SComment "don't process anything else until we're done",
 160.960 -                     C.Goto "out_no_reregister"]]
 160.961 -
 160.962 -        rx_fragment_increment
 160.963 -            = C.Ex $ C.PostInc $ C.DerefField bindvar "rx_msg_fragment"
 160.964 -
 160.965 -cap_tx_reply_handler :: String -> C.Unit
 160.966 -cap_tx_reply_handler ifn
 160.967 -    = C.FunctionDef C.Static C.Void (cap_tx_reply_handler_name ifn)
 160.968 -        [C.Param (C.Ptr C.Void) "st",
 160.969 -         C.Param (C.TypeName "uint32_t") "capid",
 160.970 -         C.Param (C.TypeName "errval_t") "err"]
 160.971 -        [
 160.972 -        localvar (C.Ptr $ C.Struct $ intf_bind_type ifn) intf_bind_var (Just $ C.Variable "st"),
 160.973 -        C.If (C.Call "err_is_fail" [errvar])
 160.974 -            [C.Ex $ C.Call "DEBUG_ERR" [errvar,
 160.975 -                        C.StringConstant "monitor refused to accept cap for BMP send"],
 160.976 -             report_user_tx_err $
 160.977 -                    C.Call "err_push" [errvar, C.Variable "LIB_ERR_MONITOR_CAP_SEND"]] []
 160.978 -        ]
 160.979 -
 160.980 -cap_rx_handler :: String -> [TypeDef] -> [MessageDef] -> [MsgSpec] -> C.Unit
 160.981 -cap_rx_handler ifn typedefs msgdefs msgspecs
 160.982 -    = C.FunctionDef C.Static C.Void (cap_rx_handler_name ifn)
 160.983 -        [C.Param (C.Ptr C.Void) "arg",
 160.984 -         C.Param (C.Struct "capref") "cap",
 160.985 -         C.Param (C.TypeName "uint32_t") "capid"]
 160.986 -        [
 160.987 -        handler_preamble ifn,
 160.988 -
 160.989 -        C.Ex $ C.Call "assert" [C.Binary C.Equals
 160.990 -                                       (C.Variable "capid")
 160.991 -                                       (capst `C.FieldOf` "rx_capnum")],
 160.992 -        C.SBlank,
 160.993 -
 160.994 -        C.SComment "Switch on current incoming message",
 160.995 -        C.Switch (C.DerefField bindvar "rx_msgnum") cases
 160.996 -            [C.Ex $ C.Call "assert"
 160.997 -                    [C.Unary C.Not $ C.StringConstant "invalid message number"],
 160.998 -             report_user_err (C.Variable "FLOUNDER_ERR_INVALID_STATE")]
 160.999 -    ]
160.1000 -    where
160.1001 -        bmpst = C.DerefField my_bindvar "bmp_state"
160.1002 -        capst = bmpst `C.FieldOf` "capst"
160.1003 -        cases = [C.Case (C.Variable $ msg_enum_elem_name ifn mn)
160.1004 -                        (cap_rx_handler_case ifn typedefs mn msgdef (length frags) caps)
160.1005 -                 | (MsgSpec mn frags caps, msgdef) <- zip msgspecs msgdefs, caps /= []]
160.1006 -
160.1007 -cap_rx_handler_case :: String -> [TypeDef] -> String -> MessageDef -> Int -> [CapFieldTransfer] -> [C.Stmt]
160.1008 -cap_rx_handler_case ifn typedefs mn (Message _ _ msgargs _) nfrags caps = [
160.1009 -    C.SComment "Switch on current incoming cap",
160.1010 -    C.Switch (C.PostInc $ capst `C.FieldOf` "rx_capnum") cases
160.1011 -            [C.Ex $ C.Call "assert"
160.1012 -                    [C.Unary C.Not $ C.StringConstant "invalid cap number"],
160.1013 -             report_user_err (C.Variable "FLOUNDER_ERR_INVALID_STATE")],
160.1014 -    C.Break]
160.1015 -    where
160.1016 -        bmpst = C.DerefField my_bindvar "bmp_state"
160.1017 -        capst = bmpst `C.FieldOf` "capst"
160.1018 -        cases = [C.Case (C.NumConstant $ toInteger i) $ subcase cap i
160.1019 -                 | (cap, i) <- zip caps [0..]]
160.1020 -
160.1021 -        subcase :: CapFieldTransfer -> Int -> [C.Stmt]
160.1022 -        subcase (CapFieldTransfer _ cap) ncap = [
160.1023 -            C.Ex $ C.Assignment (argfield_expr RX mn cap) (C.Variable "cap"),
160.1024 -            if is_last then
160.1025 -                -- if this was the last cap, and we've received all the other fragments, we're done
160.1026 -                C.If (C.Binary C.Equals rx_msgfrag_field (C.NumConstant $ toInteger nfrags))
160.1027 -                    [
160.1028 -                        C.StmtList $ finished_recv drvname ifn typedefs mn msgargs,
160.1029 -                        C.StmtList $ register_recv ifn
160.1030 -                    ] []
160.1031 -                else C.StmtList [],
160.1032 -            C.Break]
160.1033 -            where
160.1034 -                rx_msgfrag_field = C.DerefField bindvar "rx_msg_fragment"
160.1035 -                is_last = (ncap + 1 == length caps)
160.1036 -
160.1037 --- generate the code to register for receive notification
160.1038 -register_recv :: String -> [C.Stmt]
160.1039 -register_recv ifn = [
160.1040 -    C.SComment "register for receive notification",
160.1041 -    C.Ex $ C.Assignment errvar $ C.Call "bmp_chan_register_recv"
160.1042 -        [C.AddressOf $ my_bindvar `C.DerefField` "bmp_state" `C.FieldOf` "chan",
160.1043 -         bindvar `C.DerefField` "waitset",
160.1044 -         C.StructConstant "event_closure"
160.1045 -            [("handler", C.Variable $ rx_handler_name ifn),
160.1046 -             ("arg", my_bindvar)]],
160.1047 -    C.If (C.Call "err_is_fail" [errvar])
160.1048 -        [report_user_err $ C.Call "err_push" [errvar, C.Variable "LIB_ERR_CHAN_REGISTER_RECV"]]
160.1049 -        [] ]
160.1050 -
160.1051 --- generate the code to set cap rx/tx handlers
160.1052 -setup_cap_handlers :: String -> [C.Stmt]
160.1053 -setup_cap_handlers ifn = [
160.1054 -    C.SComment "setup cap handlers",
160.1055 -    C.Ex $ C.Assignment (C.FieldOf handlers "st") my_bindvar,
160.1056 -    C.Ex $ C.Assignment (C.FieldOf handlers "cap_receive_handler")
160.1057 -                        (C.Variable $ cap_rx_handler_name ifn),
160.1058 -    C.Ex $ C.Assignment (C.FieldOf handlers "cap_send_reply_handler")
160.1059 -                        (C.Variable $ cap_tx_reply_handler_name ifn) ]
160.1060 -    where
160.1061 -        chanvar = my_bindvar `C.DerefField` "bmp_state" `C.FieldOf` "chan"
160.1062 -        handlers = chanvar `C.FieldOf` "cap_handlers"
   161.1 --- a/tools/flounder/GCBackend.hs	Fri Jan 20 14:32:03 2012 -0800
   161.2 +++ b/tools/flounder/GCBackend.hs	Mon Jan 23 11:04:15 2012 -0800
   161.3 @@ -22,7 +22,6 @@
   161.4  import LMP (lmp_bind_type, lmp_bind_fn_name)
   161.5  import qualified UMP (bind_type, bind_fn_name)
   161.6  import qualified UMP_IPI (bind_type, bind_fn_name)
   161.7 -import qualified BMP (bind_type, bind_fn_name)
   161.8  import qualified Multihop (m_bind_type, m_bind_fn_name)
   161.9  
  161.10  -- name of the bind continuation function
  161.11 @@ -245,7 +244,6 @@
  161.12                      [lmp_bind_backend, 
  161.13                       ump_ipi_bind_backend, 
  161.14                       ump_bind_backend, 
  161.15 -                     bmp_bind_backend, 
  161.16                       multihop_bind_backend]
  161.17                                                       
  161.18  -- backends in different order (prefer multihop over ump, etc.)
  161.19 @@ -254,8 +252,7 @@
  161.20                      [lmp_bind_backend, 
  161.21                       multihop_bind_backend, 
  161.22                       ump_ipi_bind_backend, 
  161.23 -                     ump_bind_backend, 
  161.24 -                     bmp_bind_backend]
  161.25 +                     ump_bind_backend]
  161.26  
  161.27  bindst = C.Variable "b"
  161.28  binding = bindst `C.DerefField` "binding"
  161.29 @@ -317,22 +314,6 @@
  161.30      cleanup_bind = [ C.Ex $ C.Call "free" [binding] ]
  161.31      }
  161.32    
  161.33 -bmp_bind_backend ifn cont = 
  161.34 -  BindBackend {
  161.35 -    flounder_backend = "bmp",
  161.36 -    start_bind = [
  161.37 -        C.Ex $ C.Assignment binding $
  161.38 -            C.Call "malloc" [C.SizeOfT $ C.Struct $ BMP.bind_type ifn],
  161.39 -        C.Ex $ C.Call "assert" [C.Binary C.NotEquals binding (C.Variable "NULL")],
  161.40 -        C.Ex $ C.Assignment errvar $
  161.41 -            C.Call (BMP.bind_fn_name ifn) [binding, iref, cont, C.Variable "b", waitset,
  161.42 -                                           flags, C.Variable "DEFAULT_BMP_BUF_WORDS"]
  161.43 -    ],
  161.44 -    test_cb_success = C.Call "err_is_ok" [errvar],
  161.45 -    test_cb_try_next = C.Variable "true",
  161.46 -    cleanup_bind = [ C.Ex $ C.Call "free" [binding] ]
  161.47 -    }
  161.48 -  
  161.49  multihop_bind_backend ifn cont = 
  161.50    BindBackend {
  161.51      flounder_backend = "multihop",
   162.1 --- a/tools/flounder/GHBackend.hs	Fri Jan 20 14:32:03 2012 -0800
   162.2 +++ b/tools/flounder/GHBackend.hs	Mon Jan 23 11:04:15 2012 -0800
   162.3 @@ -390,7 +390,7 @@
   162.4  -- Include the right files for different backends
   162.5  --
   162.6  
   162.7 -flounder_backends = [ "lmp", "ump", "ump_ipi", "bmp", "multihop" ]
   162.8 +flounder_backends = [ "lmp", "ump", "ump_ipi", "multihop" ]
   162.9  
  162.10  backend_includes :: String -> [ C.Unit ] 
  162.11  backend_includes n = 
   163.1 --- a/tools/flounder/Main.lhs	Fri Jan 20 14:32:03 2012 -0800
   163.2 +++ b/tools/flounder/Main.lhs	Mon Jan 23 11:04:15 2012 -0800
   163.3 @@ -34,7 +34,6 @@
   163.4  > import qualified LMP
   163.5  > import qualified UMP
   163.6  > import qualified UMP_IPI
   163.7 -> import qualified BMP
   163.8  > import qualified Multihop
   163.9  > import qualified Loopback
  163.10  > import qualified RPCClient
  163.11 @@ -51,8 +50,6 @@
  163.12  >            | UMP_Stub
  163.13  >            | UMP_IPI_Header
  163.14  >            | UMP_IPI_Stub
  163.15 ->            | BMP_Header
  163.16 ->            | BMP_Stub
  163.17  >  	     | Multihop_Stub
  163.18  >            | Multihop_Header
  163.19  >            | Loopback_Header
  163.20 @@ -93,8 +90,6 @@
  163.21  >     | isNothing arch = error "no architecture specified for UMP_IPI stubs"
  163.22  >     | otherwise = UMP_IPI.stub (fromJust arch)
  163.23  >     where arch = optArch opts
  163.24 -> generator _ BMP_Header = BMP.header
  163.25 -> generator _ BMP_Stub = BMP.stub
  163.26  > generator _ Multihop_Header = Multihop.header
  163.27  > generator opts Multihop_Stub
  163.28  >     | isNothing arch = error "no architecture specified for Multihop stubs"
  163.29 @@ -137,8 +132,6 @@
  163.30  >             Option [] ["ump-stub"] (NoArg $ addTarget UMP_Stub)     "Create a stub file for UMP",
  163.31  >             Option [] ["ump_ipi-header"] (NoArg $ addTarget UMP_IPI_Header) "Create a header file for UMP_IPI",
  163.32  >             Option [] ["ump_ipi-stub"] (NoArg $ addTarget UMP_IPI_Stub)     "Create a stub file for UMP_IPI",
  163.33 ->             Option [] ["bmp-header"] (NoArg $ addTarget BMP_Header) "Create a header file for BMP",
  163.34 ->             Option [] ["bmp-stub"] (NoArg $ addTarget BMP_Stub)     "Create a stub file for BMP",
  163.35  >             Option [] ["multihop-header"] (NoArg $ addTarget Multihop_Header) "Create a header file for Multihop",
  163.36  >             Option [] ["multihop-stub"] (NoArg $ addTarget Multihop_Stub)     "Create a stub file for Multihop",
  163.37  >             Option [] ["loopback-header"] (NoArg $ addTarget Loopback_Header) "Create a header file for loopback",
   164.1 --- a/tools/harness/barrelfish.py	Fri Jan 20 14:32:03 2012 -0800
   164.2 +++ b/tools/harness/barrelfish.py	Mon Jan 23 11:04:15 2012 -0800
   164.3 @@ -115,26 +115,6 @@
   164.4          m.add_module("%s/sbin/pci" % a, ["boot"])
   164.5  	m.add_module("%s/sbin/routing_setup" %a, ["boot"])
   164.6  
   164.7 -    # beehive-specific stuff
   164.8 -    elif a == "beehive":
   164.9 -        m.set_hypervisor("beehive/sbin/hyper")
  164.10 -
  164.11 -        kernargs = machine.get_kernel_args()
  164.12 -        if kernargs is None:
  164.13 -            kernargs = []
  164.14 -
  164.15 -        # add cpu, monitor and spawnd for each core
  164.16 -        m.del_module("%s/sbin/cpu" % a)
  164.17 -        extracores = machine.get_coreids()[1:]
  164.18 -        for c in extracores:
  164.19 -            m.add_module("%s/sbin/cpu|%d" % (a, c), kernargs+["nospawn"])
  164.20 -            m.add_module("%s/sbin/monitor|%d" % (a, c), ["nospawn"])
  164.21 -            m.add_module("%s/sbin/spawnd|%d" % (a, c), ["nospawn"])
  164.22 -
  164.23 -        # tell BSP spawnd what to boot
  164.24 -        m.add_module_arg("spawnd",
  164.25 -                         "bootbees=" + ','.join(map(str,extracores)))
  164.26 -
  164.27      # ARM-specific stuff
  164.28      elif a == "arm":
  164.29          m.add_module_arg("spawnd", "bootarm")
   165.1 --- a/tools/harness/machines/__init__.py	Fri Jan 20 14:32:03 2012 -0800
   165.2 +++ b/tools/harness/machines/__init__.py	Mon Jan 23 11:04:15 2012 -0800
   165.3 @@ -95,7 +95,7 @@
   165.4      all_machines.append(machine)
   165.5      return machine
   165.6  
   165.7 -# Assume that QEMU/Bsim works everywhere if invoked
   165.8 -import qemu, bsim
   165.9 +# Assume that QEMU works everywhere if invoked
  165.10 +import qemu
  165.11  
  165.12  # Other site-specific modules will be loaded by the siteconfig module
   166.1 --- a/tools/harness/machines/bsim.py	Fri Jan 20 14:32:03 2012 -0800
   166.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   166.3 @@ -1,115 +0,0 @@
   166.4 -##########################################################################
   166.5 -# Copyright (c) 2009, ETH Zurich.
   166.6 -# All rights reserved.
   166.7 -#
   166.8 -# This file is distributed under the terms in the attached LICENSE file.
   166.9 -# If you do not find this file, copies can be found by writing to:
  166.10 -# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  166.11 -##########################################################################
  166.12 -
  166.13 -import os, signal, tempfile, subprocess, shutil
  166.14 -import debug, machines
  166.15 -from machines import Machine
  166.16 -
  166.17 -SLAVECODE_PATH = "kernel/arch/beehive/slavecode.mem" # relative to source tree
  166.18 -BSIM_CMD = 'Bsimimg'
  166.19 -BSIM_ARGS= '-noaddrcheck -ibase=1000 -datarota=2'.split()
  166.20 -BSIM_IMG = 'spliced.img' # in "tftp" dir
  166.21 -BSPLICE_CMD = 'Bsplice'
  166.22 -BSIM_NCORES = 2
  166.23 -
  166.24 -@machines.add_machine
  166.25 -class BSim(Machine):
  166.26 -    '''Beehive simulator'''
  166.27 -    name = 'bsim'
  166.28 -
  166.29 -    def __init__(self, options):
  166.30 -        super(BSim, self).__init__(options)
  166.31 -        self.child = None
  166.32 -        self.tftp_dir = None
  166.33 -        self.options = options
  166.34 -
  166.35 -    def get_bootarch(self):
  166.36 -        return "beehive"
  166.37 -
  166.38 -    def get_ncores(self):
  166.39 -        return BSIM_NCORES
  166.40 -
  166.41 -    def get_coreids(self):
  166.42 -        return range(2, 2 + self.get_ncores())
  166.43 -
  166.44 -    def get_tickrate(self):
  166.45 -        return None
  166.46 -
  166.47 -    def get_boot_timeout(self):
  166.48 -        # time limit for running a sim test
  166.49 -        # FIXME: ideally this should somehow be expressed in CPU time / cycles
  166.50 -        return 6 * 60
  166.51 -
  166.52 -    def get_tftp_dir(self):
  166.53 -        if self.tftp_dir is None:
  166.54 -            debug.verbose('creating temporary directory for Bsim TFTP files')
  166.55 -            self.tftp_dir = tempfile.mkdtemp(prefix='harness_sim_')
  166.56 -            debug.verbose('Bsim TFTP directory is %s' % self.tftp_dir)
  166.57 -        return self.tftp_dir
  166.58 -
  166.59 -    def _write_menu_lst(self, data, path):
  166.60 -        debug.verbose('writing %s' % path)
  166.61 -        debug.debug(data)
  166.62 -        f = open(path, 'w')
  166.63 -        f.write(data)
  166.64 -        f.close()
  166.65 -
  166.66 -    def _run_bsplice(self):
  166.67 -        tftp_dir = self.get_tftp_dir()
  166.68 -        outpath = os.path.join(tftp_dir, BSIM_IMG)
  166.69 -        inpath = os.path.join(tftp_dir, 'menu.lst')
  166.70 -        debug.checkcmd([BSPLICE_CMD, '-o', outpath, '-i', inpath])
  166.71 -
  166.72 -    def set_bootmodules(self, modules):
  166.73 -        path = os.path.join(self.get_tftp_dir(), 'menu.lst')
  166.74 -        # XXX: Bsplice unsurprisingly doesn't like 'modulenounzip'
  166.75 -        menudata = modules.get_menu_data('/').replace("modulenounzip", "module")
  166.76 -        self._write_menu_lst(menudata, path)
  166.77 -        self._run_bsplice()
  166.78 -
  166.79 -    def lock(self):
  166.80 -        pass
  166.81 -
  166.82 -    def unlock(self):
  166.83 -        pass
  166.84 -
  166.85 -    def setup(self):
  166.86 -        pass
  166.87 -
  166.88 -    def _get_cmdline(self):
  166.89 -        tftp_dir = self.get_tftp_dir()
  166.90 -        return ([BSIM_CMD,
  166.91 -                 "-slave=" + os.path.join(self.options.sourcedir, SLAVECODE_PATH),
  166.92 -                 "-ncores=%d" % (self.get_ncores() + 1)] # +1 for hypervisor
  166.93 -                + BSIM_ARGS + [os.path.join(tftp_dir, BSIM_IMG)])
  166.94 -
  166.95 -    def _kill_child(self):
  166.96 -        # terminate child if running
  166.97 -        if self.child:
  166.98 -            os.kill(self.child.pid, signal.SIGTERM)
  166.99 -            self.child.wait()
 166.100 -            self.child = None
 166.101 -
 166.102 -    def reboot(self):
 166.103 -        self._kill_child()
 166.104 -        cmd = self._get_cmdline()
 166.105 -        debug.verbose('starting "%s"' % ' '.join(cmd))
 166.106 -        devnull = open(os.devnull, 'r')
 166.107 -        self.child = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=devnull)
 166.108 -        devnull.close()
 166.109 -
 166.110 -    def shutdown(self):
 166.111 -        self._kill_child()
 166.112 -        # try to cleanup tftp tree if needed
 166.113 -        if self.tftp_dir and os.path.isdir(self.tftp_dir):
 166.114 -            shutil.rmtree(self.tftp_dir, ignore_errors=True)
 166.115 -        self.tftp_dir = None
 166.116 -
 166.117 -    def get_output(self):
 166.118 -        return self.child.stdout
   167.1 --- a/usr/bench/bmp_bench/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   167.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   167.3 @@ -1,19 +0,0 @@
   167.4 ---------------------------------------------------------------------------
   167.5 --- Copyright (c) 2007-2010, ETH Zurich.
   167.6 --- All rights reserved.
   167.7 ---
   167.8 --- This file is distributed under the terms in the attached LICENSE file.
   167.9 --- If you do not find this file, copies can be found by writing to:
  167.10 --- ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  167.11 ---
  167.12 --- Hakefile for bmp_bench
  167.13 --- 
  167.14 ---------------------------------------------------------------------------
  167.15 -
  167.16 -[
  167.17 -build application { target = "bmp_bench",
  167.18 -                  cFiles = [ "bmpbench.c", "bb_test.c", "bb_pingpong.c" ],
  167.19 -                  flounderBindings = [ "test", "ping_pong" ],
  167.20 -                  addLibraries = [ "trace" ]
  167.21 -                 }
  167.22 -]
   168.1 --- a/usr/bench/bmp_bench/bb_pingpong.c	Fri Jan 20 14:32:03 2012 -0800
   168.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   168.3 @@ -1,269 +0,0 @@
   168.4 -/** \file
   168.5 - *  \brief IDC system test code
   168.6 - */
   168.7 -
   168.8 -/*
   168.9 - * Copyright (c) 2010, ETH Zurich.
  168.10 - * All rights reserved.
  168.11 - *
  168.12 - * This file is distributed under the terms in the attached LICENSE file.
  168.13 - * If you do not find this file, copies can be found by writing to:
  168.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  168.15 - */
  168.16 -
  168.17 -#define _USE_XOPEN /* for strdup() */
  168.18 -#include <string.h>
  168.19 -#include <stdio.h>
  168.20 -#include <inttypes.h>
  168.21 -#include <barrelfish/barrelfish.h>
  168.22 -#include <barrelfish/nameservice_client.h>
  168.23 -#include <barrelfish/debug.h>
  168.24 -#include <bench/bench.h>
  168.25 -#include <if/ping_pong_defs.h>
  168.26 -
  168.27 -#include <trace/trace.h>
  168.28 -#ifdef __BEEHIVE__
  168.29 -#include <simctrl.h>
  168.30 -#else
  168.31 -#define BEE_SIMCTRL(x) (void)0
  168.32 -#endif
  168.33 -#include "bmpbench.h"
  168.34 -
  168.35 -static const char *my_service_name = "bmpbench-pingpong";
  168.36 -
  168.37 -/* ------------------------ COMMON MESSAGE HANDLERS ------------------------ */
  168.38 -
  168.39 -static void send_cont(void *);
  168.40 -
  168.41 -static void rx_ping(struct ping_pong_binding *b, uint64_t val)
  168.42 -{
  168.43 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_RXPING, val); 
  168.44 -  //printf("rx_ping %" PRIu64 "\n", val);
  168.45 -    b->tx_vtbl.pong(b, NOP_CONT, val);
  168.46 -}
  168.47 -
  168.48 -static void rx_pong(struct ping_pong_binding *b, uint64_t val)
  168.49 -{
  168.50 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_RXPONG, val);
  168.51 -  //printf("rx_pong %" PRIu64 "\n", val);
  168.52 -    send_cont(b);
  168.53 -}
  168.54 -
  168.55 -static void rx_slow_op(struct ping_pong_binding *b, uint64_t val)
  168.56 -{
  168.57 -    BEE_SIMCTRL(BEE_SIMCTRL_CACHE_STAT);
  168.58 -    if (val >= 100) {
  168.59 -	printf("rx_slow_op: %" PRIu64 "\n", val);
  168.60 -    }
  168.61 -    else {
  168.62 -	val = icachetest_run((int)val);
  168.63 -    }
  168.64 -    b->tx_vtbl.slow_reply(b, NOP_CONT, val);
  168.65 -}
  168.66 -
  168.67 -static void rx_slow_reply(struct ping_pong_binding *b, uint64_t val)
  168.68 -{
  168.69 -    printf("rx_slow_reply %" PRIu64 "\n", val);
  168.70 -    printf("rx_slow_reply locally %zu\n", icachetest_run(20));
  168.71 -}
  168.72 -
  168.73 -static void rx_stop(struct ping_pong_binding *b)
  168.74 -{
  168.75 -    printf("rx_stop:\n");
  168.76 -}
  168.77 -
  168.78 -static void rx_testrpc_call(struct ping_pong_binding *b, uint64_t testin)
  168.79 -{
  168.80 -    printf("rx_testrpc_call: %" PRIu64 "\n", testin);
  168.81 -    b->tx_vtbl.testrpc_response(b, NOP_CONT, testin);
  168.82 -}
  168.83 -
  168.84 -static void rx_testrpc_response(struct ping_pong_binding *b, uint64_t testout)
  168.85 -{
  168.86 -    printf("rx_testrpc_response: %" PRIu64 "\n", testout);
  168.87 -}
  168.88 -
  168.89 -static void rx_outoforder_call(struct ping_pong_binding *b,
  168.90 -			       uint64_t seq_in, uint64_t testin)
  168.91 -{
  168.92 -    printf("rx_outoforder_call: %" PRIu64 " %" PRIu64 "\n", seq_in, testin);
  168.93 -    b->tx_vtbl.outoforder_response(b, NOP_CONT, seq_in, testin);
  168.94 -}
  168.95 -
  168.96 -static void rx_outoforder_response(struct ping_pong_binding *b,
  168.97 -				   uint64_t seq_out, uint64_t testout)
  168.98 -{
  168.99 -    printf("rx_outoforder_response: %" PRIu64 " %" PRIu64 "\n", seq_out, testout);
 168.100 -}
 168.101 -
 168.102 -static struct ping_pong_rx_vtbl rx_vtbl = {
 168.103 -    .ping = rx_ping,
 168.104 -    .pong = rx_pong,
 168.105 -    .slow_op = rx_slow_op,
 168.106 -    .slow_reply = rx_slow_reply,
 168.107 -    .stop = rx_stop,
 168.108 -    .testrpc_call = rx_testrpc_call,
 168.109 -    .testrpc_response = rx_testrpc_response,
 168.110 -    .outoforder_call = rx_outoforder_call,
 168.111 -    .outoforder_response = rx_outoforder_response
 168.112 -};
 168.113 -
 168.114 -
 168.115 -/* ------------------------------ CLIENT ------------------------------ */
 168.116 -
 168.117 -#define REPEAT_BASIC 100
 168.118 -
 168.119 -struct client_state {
 168.120 -    int nextmsg;
 168.121 -};
 168.122 -
 168.123 -cycles_t times[REPEAT_BASIC+1];
 168.124 -
 168.125 -// send the next message in our sequence
 168.126 -static void send_cont(void *arg)
 168.127 -{
 168.128 -    struct ping_pong_binding *b = arg;
 168.129 -    struct client_state *myst = b->st;
 168.130 -    errval_t err;
 168.131 -
 168.132 -    //printf("client sending msg %d\n", myst->nextmsg);
 168.133 -
 168.134 -    times[myst->nextmsg] = bench_tsc();
 168.135 -    if (myst->nextmsg < REPEAT_BASIC) {
 168.136 -	BEE_SIMCTRL(BEE_SIMCTRL_CACHE_DELTA);
 168.137 -	err = b->tx_vtbl.ping(b, NOP_CONT, myst->nextmsg);
 168.138 -    }
 168.139 -    else if (myst->nextmsg == REPEAT_BASIC) {
 168.140 -	err = b->tx_vtbl.slow_op(b, MKCONT(send_cont, b), 20);
 168.141 -    }
 168.142 -    else {
 168.143 -	BEE_SIMCTRL(BEE_SIMCTRL_CACHE_STAT);
 168.144 -	cycles_t cy = icachetest_run(20);
 168.145 -	printf("cy=%zu\n", cy);
 168.146 -	BEE_SIMCTRL(BEE_SIMCTRL_CACHE_STAT);
 168.147 -	printf("client all done\n");
 168.148 -	err = trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0); 
 168.149 -	if (err_is_fail(err)) {
 168.150 -	    DEBUG_ERR(err, "trace_event off");
 168.151 -	    return;
 168.152 -	}
 168.153 -
 168.154 -	void *dump = malloc(1000000);
 168.155 -	size_t dumpsize = trace_dump(dump, 1000000);
 168.156 -	printf("trace_dump: resulted in %zu bytes\n", dumpsize);
 168.157 -	sys_print(dump, dumpsize);
 168.158 -	printf("Cycles times for %u ping operations\n", REPEAT_BASIC);
 168.159 -	for(int i=0; i<REPEAT_BASIC; i++)
 168.160 -	    printf("%u\n", times[i+1] - times[i]);
 168.161 -	printf("Done.\n");
 168.162 -	return;
 168.163 -    }
 168.164 -
 168.165 -    if (err_is_ok(err)) {
 168.166 -        myst->nextmsg++;
 168.167 -    } else {
 168.168 -        DEBUG_ERR(err, "error sending message %d", myst->nextmsg);
 168.169 -        abort();
 168.170 -    }
 168.171 -}
 168.172 -
 168.173 -static void bind_cb(void *st, errval_t err, struct ping_pong_binding *b)
 168.174 -{
 168.175 -    if (err_is_fail(err)) {
 168.176 -        DEBUG_ERR(err, "bind failed");
 168.177 -        abort();
 168.178 -    }
 168.179 -
 168.180 -    printf("client bound!\n");
 168.181 -
 168.182 -    // copy my message receive handler vtable to the binding
 168.183 -    b->rx_vtbl = rx_vtbl;
 168.184 -
 168.185 -    // construct local per-binding state
 168.186 -    struct client_state *myst = malloc(sizeof(struct client_state));
 168.187 -    assert(myst != NULL);
 168.188 -    myst->nextmsg = 0;
 168.189 -    b->st = myst;
 168.190 -
 168.191 -    // start sending stuff to the service
 168.192 -    err = trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 1);
 168.193 -    if (err_is_fail(err)) {
 168.194 -	DEBUG_ERR(err, "trace_event on");
 168.195 -	return;
 168.196 -    }
 168.197 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.198 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.199 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.200 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.201 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.202 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.203 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.204 -    trace_event(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0xbee);
 168.205 -
 168.206 -    send_cont(b);
 168.207 -}
 168.208 -
 168.209 -void bb_pingpong_start_client(void)
 168.210 -{
 168.211 -    iref_t iref;
 168.212 -    errval_t err;
 168.213 -
 168.214 -    printf("client looking up '%s' in name service...\n", my_service_name);
 168.215 -    err = nameservice_blocking_lookup(my_service_name, &iref);
 168.216 -    if (err_is_fail(err)) {
 168.217 -        DEBUG_ERR(err, "nameservice_blocking_lookup failed");
 168.218 -        abort();
 168.219 -    }
 168.220 -
 168.221 -    printf("client binding to %u...\n", iref);
 168.222 -    err = ping_pong_bind(iref, bind_cb, NULL /* state pointer for bind_cb */,
 168.223 -                    get_default_waitset(), IDC_BIND_FLAGS_DEFAULT);
 168.224 -    if (err_is_fail(err)) {
 168.225 -        DEBUG_ERR(err, "bind failed");
 168.226 -        abort();
 168.227 -    }
 168.228 -}
 168.229 -
 168.230 -/* ------------------------------ SERVER ------------------------------ */
 168.231 -
 168.232 -static void export_cb(void *st, errval_t err, iref_t iref)
 168.233 -{
 168.234 -    if (err_is_fail(err)) {
 168.235 -        DEBUG_ERR(err, "export failed");
 168.236 -        abort();
 168.237 -    }
 168.238 -
 168.239 -    printf("service exported at iref %u\n", iref);
 168.240 -
 168.241 -    // register this iref with the name service
 168.242 -    err = nameservice_register(my_service_name, iref);
 168.243 -    if (err_is_fail(err)) {
 168.244 -        DEBUG_ERR(err, "nameservice_register failed");
 168.245 -        abort();
 168.246 -    }
 168.247 -}
 168.248 -
 168.249 -static errval_t connect_cb(void *st, struct ping_pong_binding *b)
 168.250 -{
 168.251 -    printf("service got a connection!\n");
 168.252 -
 168.253 -    // copy my message receive handler vtable to the binding
 168.254 -    b->rx_vtbl = rx_vtbl;
 168.255 -
 168.256 -    // accept the connection (we could return an error to refuse it)
 168.257 -    return SYS_ERR_OK;
 168.258 -}
 168.259 -
 168.260 -void bb_pingpong_start_server(void)
 168.261 -{
 168.262 -    errval_t err;
 168.263 -
 168.264 -    err = ping_pong_export(NULL /* state pointer for connect/export callbacks */,
 168.265 -                      export_cb, connect_cb, get_default_waitset(),
 168.266 -                      IDC_EXPORT_FLAGS_DEFAULT);
 168.267 -    if (err_is_fail(err)) {
 168.268 -        DEBUG_ERR(err, "export failed");
 168.269 -        abort();
 168.270 -    }
 168.271 -}
 168.272 -
   169.1 --- a/usr/bench/bmp_bench/bb_test.c	Fri Jan 20 14:32:03 2012 -0800
   169.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   169.3 @@ -1,162 +0,0 @@
   169.4 -/** \file
   169.5 - *  \brief IDC system test code
   169.6 - */
   169.7 -
   169.8 -/*
   169.9 - * Copyright (c) 2010, ETH Zurich.
  169.10 - * All rights reserved.
  169.11 - *
  169.12 - * This file is distributed under the terms in the attached LICENSE file.
  169.13 - * If you do not find this file, copies can be found by writing to:
  169.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  169.15 - */
  169.16 -
  169.17 -#define _USE_XOPEN /* for strdup() */
  169.18 -#include <string.h>
  169.19 -#include <stdio.h>
  169.20 -#include <inttypes.h>
  169.21 -#include <barrelfish/barrelfish.h>
  169.22 -#include <barrelfish/nameservice_client.h>
  169.23 -#include <barrelfish/debug.h>
  169.24 -#include <bench/bench.h>
  169.25 -#include <if/test_defs.h>
  169.26 -
  169.27 -#include "bmpbench.h"
  169.28 -
  169.29 -static const char *my_service_name = "bmpbench-test";
  169.30 -
  169.31 -/* ------------------------ COMMON MESSAGE HANDLERS ------------------------ */
  169.32 -
  169.33 -static void rx_basic(struct test_binding *b, uint32_t arg)
  169.34 -{
  169.35 -    //printf("rx_basic %u\n", arg);
  169.36 -}
  169.37 -
  169.38 -static struct test_rx_vtbl rx_vtbl = {
  169.39 -    .basic = rx_basic,
  169.40 -};
  169.41 -
  169.42 -/* ------------------------------ CLIENT ------------------------------ */
  169.43 -
  169.44 -#define REPEAT_BASIC 100
  169.45 -
  169.46 -struct client_state {
  169.47 -    int nextmsg;
  169.48 -};
  169.49 -
  169.50 -cycles_t times[REPEAT_BASIC+1];
  169.51 -
  169.52 -// send the next message in our sequence
  169.53 -static void send_cont(void *arg)
  169.54 -{
  169.55 -    struct test_binding *b = arg;
  169.56 -    struct client_state *myst = b->st;
  169.57 -    errval_t err;
  169.58 -
  169.59 -    //printf("client sending msg %d\n", myst->nextmsg);
  169.60 -
  169.61 -    times[myst->nextmsg] = bench_tsc();
  169.62 -    if (myst->nextmsg < REPEAT_BASIC) {
  169.63 -	err = b->tx_vtbl.basic(b, MKCONT(send_cont, b), myst->nextmsg);
  169.64 -    }
  169.65 -    else {
  169.66 -	printf("client all done\n");
  169.67 -	for(int i=0; i<REPEAT_BASIC; i++)
  169.68 -	    printf("%u\n", times[i+1] - times[i]);
  169.69 -	return;
  169.70 -    }
  169.71 -
  169.72 -    if (err_is_ok(err)) {
  169.73 -        myst->nextmsg++;
  169.74 -    } else {
  169.75 -        DEBUG_ERR(err, "error sending message %d", myst->nextmsg);
  169.76 -        abort();
  169.77 -    }
  169.78 -}
  169.79 -
  169.80 -static void bind_cb(void *st, errval_t err, struct test_binding *b)
  169.81 -{
  169.82 -    if (err_is_fail(err)) {
  169.83 -        DEBUG_ERR(err, "bind failed");
  169.84 -        abort();
  169.85 -    }
  169.86 -
  169.87 -    printf("client bound!\n");
  169.88 -
  169.89 -    // copy my message receive handler vtable to the binding
  169.90 -    b->rx_vtbl = rx_vtbl;
  169.91 -
  169.92 -    // construct local per-binding state
  169.93 -    struct client_state *myst = malloc(sizeof(struct client_state));
  169.94 -    assert(myst != NULL);
  169.95 -    myst->nextmsg = 0;
  169.96 -    b->st = myst;
  169.97 -
  169.98 -    // start sending stuff to the service
  169.99 -    send_cont(b);
 169.100 -}
 169.101 -
 169.102 -void bb_test_start_client(void)
 169.103 -{
 169.104 -    iref_t iref;
 169.105 -    errval_t err;
 169.106 -
 169.107 -    printf("client looking up '%s' in name service...\n", my_service_name);
 169.108 -    err = nameservice_blocking_lookup(my_service_name, &iref);
 169.109 -    if (err_is_fail(err)) {
 169.110 -        DEBUG_ERR(err, "nameservice_blocking_lookup failed");
 169.111 -        abort();
 169.112 -    }
 169.113 -
 169.114 -    printf("client binding to %u...\n", iref);
 169.115 -    err = test_bind(iref, bind_cb, NULL /* state pointer for bind_cb */,
 169.116 -                    get_default_waitset(), IDC_BIND_FLAGS_DEFAULT);
 169.117 -    if (err_is_fail(err)) {
 169.118 -        DEBUG_ERR(err, "bind failed");
 169.119 -        abort();
 169.120 -    }
 169.121 -}
 169.122 -
 169.123 -/* ------------------------------ SERVER ------------------------------ */
 169.124 -
 169.125 -static void export_cb(void *st, errval_t err, iref_t iref)
 169.126 -{
 169.127 -    if (err_is_fail(err)) {
 169.128 -        DEBUG_ERR(err, "export failed");
 169.129 -        abort();
 169.130 -    }
 169.131 -
 169.132 -    printf("service exported at iref %u\n", iref);
 169.133 -
 169.134 -    // register this iref with the name service
 169.135 -    err = nameservice_register(my_service_name, iref);
 169.136 -    if (err_is_fail(err)) {
 169.137 -        DEBUG_ERR(err, "nameservice_register failed");
 169.138 -        abort();
 169.139 -    }
 169.140 -}
 169.141 -
 169.142 -static errval_t connect_cb(void *st, struct test_binding *b)
 169.143 -{
 169.144 -    printf("service got a connection!\n");
 169.145 -
 169.146 -    // copy my message receive handler vtable to the binding
 169.147 -    b->rx_vtbl = rx_vtbl;
 169.148 -
 169.149 -    // accept the connection (we could return an error to refuse it)
 169.150 -    return SYS_ERR_OK;
 169.151 -}
 169.152 -
 169.153 -void bb_test_start_server(void)
 169.154 -{
 169.155 -    errval_t err;
 169.156 -
 169.157 -    err = test_export(NULL /* state pointer for connect/export callbacks */,
 169.158 -                      export_cb, connect_cb, get_default_waitset(),
 169.159 -                      IDC_EXPORT_FLAGS_DEFAULT);
 169.160 -    if (err_is_fail(err)) {
 169.161 -        DEBUG_ERR(err, "export failed");
 169.162 -        abort();
 169.163 -    }
 169.164 -}
 169.165 -
   170.1 --- a/usr/bench/bmp_bench/bmpbench.c	Fri Jan 20 14:32:03 2012 -0800
   170.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   170.3 @@ -1,107 +0,0 @@
   170.4 -/** \file
   170.5 - *  \brief IDC system test code
   170.6 - */
   170.7 -
   170.8 -/*
   170.9 - * Copyright (c) 2010, ETH Zurich.
  170.10 - * All rights reserved.
  170.11 - *
  170.12 - * This file is distributed under the terms in the attached LICENSE file.
  170.13 - * If you do not find this file, copies can be found by writing to:
  170.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  170.15 - */
  170.16 -
  170.17 -#define _USE_XOPEN /* for strdup() */
  170.18 -#include <string.h>
  170.19 -#include <stdio.h>
  170.20 -#include <inttypes.h>
  170.21 -#include <barrelfish/barrelfish.h>
  170.22 -#include <barrelfish/nameservice_client.h>
  170.23 -#include <barrelfish/debug.h>
  170.24 -#include <bench/bench.h>
  170.25 -#ifdef __BEEHIVE__
  170.26 -// Why is this depended in other cases??
  170.27 -#include <dcache.h>
  170.28 -#endif
  170.29 -#include <if/test_defs.h>
  170.30 -#include <if/ping_pong_defs.h>
  170.31 -
  170.32 -#include <trace/trace.h>
  170.33 -#include "bmpbench.h"
  170.34 -
  170.35 -/* ------------------------------ MAIN ------------------------------ */
  170.36 -
  170.37 -#ifndef __BEEHIVE__
  170.38 -STATIC_ASSERT(!"BEEHIVE assumptions here");
  170.39 -#endif
  170.40 -
  170.41 -static void *icacheaddr;
  170.42 -
  170.43 -cycles_t icachetest_run(int count)
  170.44 -{
  170.45 -    void (*x)(void) = (void(*)(void)) (((uint32_t)icacheaddr) >> 2);
  170.46 -    cycles_t t1 = bench_tsc();
  170.47 -    while(count--) {
  170.48 -	x();
  170.49 -    }
  170.50 -    cycles_t t2 = bench_tsc();
  170.51 -    return t2 - t1;
  170.52 -}
  170.53 -    
  170.54 -void icachetest_setup(void)
  170.55 -{
  170.56 -    const uint32_t jplus8 = 0xf800220c;
  170.57 -    const uint32_t jlink = 0xf000030c;
  170.58 -
  170.59 -    uint32_t *ptr = (uint32_t*)malloc(8192);
  170.60 -    for(int i=0; i<2040; i+=8)
  170.61 -	ptr[i] = jplus8;
  170.62 -    ptr[2040] = jlink;
  170.63 -
  170.64 -    bee_dcache_flush_all();
  170.65 -    icacheaddr = ptr;
  170.66 -}
  170.67 -
  170.68 -
  170.69 -int main(int argc, char *argv[])
  170.70 -{
  170.71 -    errval_t err;
  170.72 -
  170.73 -    icachetest_setup();
  170.74 -
  170.75 -    err = trace_control(
  170.76 -	TRACE_EVENT(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 1),
  170.77 -	TRACE_EVENT(TRACE_SUBSYS_BENCH, TRACE_EVENT_PCBENCH, 0),
  170.78 -	100 * 1000000ULL * 60);
  170.79 -    if (err_is_fail(err)) {
  170.80 -	DEBUG_ERR(err, "trace_control");
  170.81 -	return EXIT_FAILURE;
  170.82 -    }
  170.83 -
  170.84 -    // "boot" time start domains
  170.85 -    if (argc >= 2 && strcmp(argv[1], "boot") == 0) {
  170.86 -	argv[1] = argv[0];
  170.87 -	argv++;
  170.88 -	argc--;
  170.89 -    }
  170.90 -
  170.91 -    if (argc == 2 && strcmp(argv[1], "client") == 0) {
  170.92 -        bb_pingpong_start_client();
  170.93 -    } else if (argc == 2 && strcmp(argv[1], "server") == 0) {
  170.94 -        bb_pingpong_start_server();
  170.95 -    } else {
  170.96 -        printf("Usage: %s client|server\n", argv[0]);
  170.97 -        return EXIT_FAILURE;
  170.98 -    }
  170.99 -
 170.100 -    struct waitset *ws = get_default_waitset();
 170.101 -    while (1) {
 170.102 -        err = event_dispatch(ws);
 170.103 -        if (err_is_fail(err)) {
 170.104 -            DEBUG_ERR(err, "in event_dispatch");
 170.105 -            break;
 170.106 -        }
 170.107 -    }
 170.108 -
 170.109 -    return EXIT_FAILURE;
 170.110 -}
   171.1 --- a/usr/bench/bmp_bench/bmpbench.h	Fri Jan 20 14:32:03 2012 -0800
   171.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   171.3 @@ -1,23 +0,0 @@
   171.4 -/** \file
   171.5 - *  \brief IDC system test code
   171.6 - */
   171.7 -
   171.8 -/*
   171.9 - * Copyright (c) 2010, ETH Zurich.
  171.10 - * All rights reserved.
  171.11 - *
  171.12 - * This file is distributed under the terms in the attached LICENSE file.
  171.13 - * If you do not find this file, copies can be found by writing to:
  171.14 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  171.15 - */
  171.16 -
  171.17 -
  171.18 -
  171.19 -extern void bb_test_start_client(void);
  171.20 -extern void bb_test_start_server(void);
  171.21 -
  171.22 -extern void bb_pingpong_start_server(void);
  171.23 -extern void bb_pingpong_start_client(void);
  171.24 -
  171.25 -extern void icachetest_setup(void);
  171.26 -extern cycles_t icachetest_run(int count);
   172.1 --- a/usr/bench/flounder_stubs/empty.c	Fri Jan 20 14:32:03 2012 -0800
   172.2 +++ b/usr/bench/flounder_stubs/empty.c	Mon Jan 23 11:04:15 2012 -0800
   172.3 @@ -61,11 +61,6 @@
   172.4          timestamps[i+1].time0 = timestamps[i].time1;
   172.5          i++;
   172.6      }
   172.7 -#ifdef __BEEHIVE__
   172.8 -    if (i==20) __asm volatile ("simctrl 2");
   172.9 -    __asm volatile("simctrl 8");
  172.10 -    if (i==21) __asm volatile ("simctrl 3");
  172.11 -#endif
  172.12      err = binding->tx_vtbl.fsb_empty_request(binding, NOP_CONT);
  172.13      assert(err_is_ok(err));
  172.14  }
  172.15 @@ -74,40 +69,6 @@
  172.16  {
  172.17      binding = b;
  172.18      printf("Running flounder_stubs_empty between core %d and core %d\n", id, my_core_id);
  172.19 -
  172.20 -#ifdef __BEEHIVE__
  172.21 -    // XXX Hijack the bmp binding
  172.22 -    errval_t err;
  172.23 -
  172.24 -    
  172.25 -    struct bench_bmp_binding *bmp = (struct bench_bmp_binding *)b;
  172.26 -    struct flounder_bmp_state *s = &(bmp->bmp_state);
  172.27 -
  172.28 -    bmp_chan_deregister_recv(&s->chan);
  172.29 -
  172.30 -    while (true) {
  172.31 -        // try to retrieve a message from the channel
  172.32 -	struct bmp_recv_msg msg = BMP_RECV_MSG_INIT;
  172.33 -    retry:
  172.34 -        sys_print("R", 1);
  172.35 -        err = bmp_chan_recv(&s->chan, &msg);
  172.36 -        if (err_no(err) == LIB_ERR_NO_LMP_MSG) {
  172.37 -            //messages_wait_and_handle_next();
  172.38 -            thread_yield();
  172.39 -            goto retry;
  172.40 -        }
  172.41 -        if (err_is_fail(err)) {
  172.42 -            DEBUG_ERR(err, "bmp_chan_recv");
  172.43 -            // real error
  172.44 -        }
  172.45 -        sys_print("M", 1);
  172.46 -
  172.47 -        sys_print("S", 1);
  172.48 -        err = bmp_chan_send(&s->chan,(uintptr_t *) &msg, 1);
  172.49 -        assert(!err_is_fail(err));
  172.50 -    }
  172.51 -#endif
  172.52 -
  172.53      experiment();
  172.54  }
  172.55  
  172.56 @@ -121,9 +82,6 @@
  172.57      errval_t err;
  172.58      err = b->tx_vtbl.fsb_empty_reply(b, NOP_CONT);
  172.59      assert(err_is_ok(err));
  172.60 -#ifdef __BEEHIVE__
  172.61 -    __asm volatile("simctrl 8");
  172.62 -#endif
  172.63  }
  172.64  
  172.65  static struct bench_rx_vtbl rx_vtbl = {
  172.66 @@ -137,43 +95,10 @@
  172.67      // copy my message receive handler vtable to the binding
  172.68      b->rx_vtbl = rx_vtbl;
  172.69  
  172.70 -#ifdef __BEEHIVE__
  172.71 -    // XXX Hijack the binding for BMP tests
  172.72 -    struct bench_bmp_binding *bmp = (struct bench_bmp_binding *)b;
  172.73 -    struct flounder_bmp_state *s = &(bmp->bmp_state);
  172.74 -
  172.75 -    bmp_chan_deregister_recv(&s->chan);
  172.76 -#endif
  172.77 -
  172.78      // Send an init message
  172.79      errval_t err;
  172.80      err = b->tx_vtbl.fsb_init_msg(b, NOP_CONT, my_core_id);
  172.81      assert(err_is_ok(err));
  172.82 -
  172.83 -#ifdef __BEEHIVE__
  172.84 -    while(1) {
  172.85 -        sys_print("s",1);
  172.86 -	struct bmp_recv_msg sendmsg = BMP_RECV_MSG_INIT;
  172.87 -        err = bmp_chan_send(&s->chan, (uintptr_t *)&sendmsg, 1);
  172.88 -        assert(!err_is_fail(err));
  172.89 -    retry:
  172.90 -        sys_print("r",1);
  172.91 -	struct bmp_recv_msg msg = BMP_RECV_MSG_INIT;
  172.92 -        err = bmp_chan_recv(&s->chan, &msg);
  172.93 -        if (err_no(err) == LIB_ERR_NO_LMP_MSG) {
  172.94 -            //messages_wait_and_handle_next();
  172.95 -            thread_yield();
  172.96 -            goto retry;
  172.97 -        }
  172.98 -        if (err_is_fail(err)) {
  172.99 -            DEBUG_ERR(err, "bmp_chan_recv");
 172.100 -            // real error
 172.101 -        }
 172.102 -        sys_print("m", 1);
 172.103 -        // process control word
 172.104 -        flounder_stub_bmp_process_header(&(bmp->bmp_state), (msg.words)[0], (msg.buf).msglen);
 172.105 -    }
 172.106 -#endif
 172.107  }
 172.108  
 172.109  static void export_cb(void *st, errval_t err, iref_t iref)
 172.110 @@ -214,8 +139,6 @@
 172.111      printf("bench_init done\n");
 172.112  
 172.113      if (argc == 1) { /* server */
 172.114 -
 172.115 -#ifndef __BEEHIVE__
 172.116          /*
 172.117            1. spawn domain,
 172.118            2. setup a server,
 172.119 @@ -227,7 +150,7 @@
 172.120          err = spawn_program(1, my_name, xargv, NULL,
 172.121                              SPAWN_FLAGS_DEFAULT, NULL);
 172.122          assert(err_is_ok(err));
 172.123 -#endif
 172.124 +
 172.125          /* Setup a server */
 172.126          err = bench_export(NULL, export_cb, connect_cb, get_default_waitset(),
 172.127                             IDC_BIND_FLAGS_DEFAULT);
   173.1 --- a/usr/init/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   173.2 +++ b/usr/init/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   173.3 @@ -14,11 +14,6 @@
   173.4    		      cFiles = [ "mem_alloc.c", "spawn.c", "init.c" ],
   173.5                        addLinkFlags = [ "-e _start_init"],
   173.6  		      addLibraries = [ "spawndomain", "mm", "getopt", "trace", "elf" ],
   173.7 -                      architectures = [ arch | arch <- allArchitectures, arch /= "beehive" ] 
   173.8 -                    },
   173.9 -  build application { target = "init",
  173.10 -  		      cFiles = [ "mem_alloc.c", "spawn.c", "init.c" ],
  173.11 -		      addLibraries = [ "spawndomain", "mm", "getopt", "trace" ],
  173.12 -                      architectures = [ "beehive" ]
  173.13 +                      architectures = allArchitectures
  173.14                      }
  173.15  ]
   174.1 --- a/usr/init/init.c	Fri Jan 20 14:32:03 2012 -0800
   174.2 +++ b/usr/init/init.c	Mon Jan 23 11:04:15 2012 -0800
   174.3 @@ -30,9 +30,6 @@
   174.4  #elif defined(__i386__)
   174.5  #       define MONITOR_NAME  "x86_32/sbin/monitor"
   174.6  #       define MEM_SERV_NAME "x86_32/sbin/mem_serv"
   174.7 -#elif defined(__BEEHIVE__)
   174.8 -#       define MONITOR_NAME  "beehive/sbin/monitor"
   174.9 -#       define MEM_SERV_NAME "beehive/sbin/mem_serv"
  174.10  #elif defined(__arm__)
  174.11  #       define MONITOR_NAME  "arm/sbin/monitor"
  174.12  #       define MEM_SERV_NAME "arm/sbin/mem_serv"
  174.13 @@ -40,11 +37,6 @@
  174.14  #       error Unknown architecture
  174.15  #endif
  174.16  
  174.17 -#ifdef __BEEHIVE__
  174.18 -// Flag this as an initialisation domain for systems without ELF entry
  174.19 -bool __barrelfish_initialisation_domain = 1;
  174.20 -#endif
  174.21 -
  174.22  const char *multiboot_strings;
  174.23  
  174.24  struct bootinfo *bi;
   175.1 --- a/usr/init/spawn.c	Fri Jan 20 14:32:03 2012 -0800
   175.2 +++ b/usr/init/spawn.c	Mon Jan 23 11:04:15 2012 -0800
   175.3 @@ -119,17 +119,5 @@
   175.4  #endif
   175.5  #endif // CONFIG_INTERCONNECT_DRIVER_UMP
   175.6  
   175.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   175.8 -    /* Give monitor BMP table */
   175.9 -    dest.cnode = si->taskcn;
  175.10 -    dest.slot  = TASKCN_SLOT_BMP_TABLE;
  175.11 -    src.cnode = cnode_task;
  175.12 -    src.slot  = TASKCN_SLOT_BMP_TABLE;
  175.13 -    err = cap_copy(dest, src);
  175.14 -    if (err_is_fail(err)) {
  175.15 -        return err_push(err, INIT_ERR_COPY_BMP_CAP);
  175.16 -    }
  175.17 -#endif
  175.18 -
  175.19      return SYS_ERR_OK;
  175.20  }
   176.1 --- a/usr/init_null/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   176.2 +++ b/usr/init_null/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   176.3 @@ -14,11 +14,6 @@
   176.4    		      cFiles = [ "init_null.c" ],
   176.5                        addLinkFlags = [ "-e _start_init"],
   176.6  		      addLibraries = [ "mm", "getopt", "trace", "elf" ],
   176.7 -		      architectures = [ arch | arch <- allArchitectures, arch /= "beehive" ]
   176.8 -                    },
   176.9 -  build application { target = "init_null",
  176.10 -  		      cFiles = [ "init_null.c" ],
  176.11 -		      addLibraries = [ ],
  176.12 -		      architectures = [ "beehive" ]
  176.13 +		      architectures = allArchitectures
  176.14                      }
  176.15  ]
   177.1 --- a/usr/init_null/init_null.c	Fri Jan 20 14:32:03 2012 -0800
   177.2 +++ b/usr/init_null/init_null.c	Mon Jan 23 11:04:15 2012 -0800
   177.3 @@ -16,11 +16,6 @@
   177.4  #include <stdbool.h>
   177.5  #include <stdio.h>
   177.6  
   177.7 -#ifdef __BEEHIVE__
   177.8 -// Flag this as an initialisation domain for systems without ELF entry
   177.9 -bool __barrelfish_initialisation_domain = 1;
  177.10 -#endif
  177.11 -
  177.12  int main(void)
  177.13  {
  177.14      printf ("init_null: Hello World\n");
   178.1 --- a/usr/mem_serv/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   178.2 +++ b/usr/mem_serv/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   178.3 @@ -15,12 +15,6 @@
   178.4                        flounderDefs = [ "monitor", "mem" ],
   178.5                        addLibraries = [ "mm", "trace" ],
   178.6                        addLinkFlags = [ "-e _start_init"],
   178.7 -                      architectures = [ arch | arch <- allArchitectures, arch /= "beehive" ] 
   178.8 -                    },
   178.9 -  build application { target = "mem_serv",
  178.10 -  		      cFiles = [ "mem_serv.c" ],
  178.11 -                      flounderDefs = [ "monitor", "mem" ],
  178.12 -                      addLibraries = [ "mm", "trace" ],
  178.13 -                      architectures = [ "beehive" ] 
  178.14 +                      architectures = allArchitectures
  178.15                      }
  178.16  ]
   179.1 --- a/usr/mem_serv/mem_serv.c	Fri Jan 20 14:32:03 2012 -0800
   179.2 +++ b/usr/mem_serv/mem_serv.c	Mon Jan 23 11:04:15 2012 -0800
   179.3 @@ -27,11 +27,6 @@
   179.4  
   179.5  size_t mem_total = 0, mem_avail = 0;
   179.6  
   179.7 -#ifdef __BEEHIVE__
   179.8 -// Flag this as an initialisation domain for systems without ELF entry
   179.9 -bool __barrelfish_initialisation_domain = 1;
  179.10 -#endif
  179.11 -
  179.12  /* parameters for size of supported RAM and thus required storage */
  179.13  
  179.14  // XXX: Even though we could manage an arbitrary amount of RAM on any
  179.15 @@ -41,9 +36,6 @@
  179.16  #       define MAXSIZEBITS     38              ///< Max size of memory in allocator
  179.17  #elif defined(__i386__)
  179.18  #       define MAXSIZEBITS     32
  179.19 -#elif defined(__BEEHIVE__)
  179.20 -/* XXX This is better if < 32! - but there were no compile time warnings! */
  179.21 -#       define MAXSIZEBITS     31
  179.22  #elif defined(__arm__)
  179.23  /* XXX This is better if < 32! - but there were no compile time warnings! */
  179.24  #       define MAXSIZEBITS     31
   180.1 --- a/usr/mem_serv_dist/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   180.2 +++ b/usr/mem_serv_dist/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   180.3 @@ -29,7 +29,7 @@
   180.4                                                  ("spawn", ["rpcclient"]), 
   180.5                                                  ("monitor_blocking", ["rpcclient"])],
   180.6                        addLibraries = [ "mm", "trace", "skb", "dist", "thc" ],
   180.7 -		      architectures = [ "x86_64", "x86_32", "scc", "beehive" ]
   180.8 +		      architectures = [ "x86_64", "x86_32", "scc" ]
   180.9                      },
  180.10  
  180.11  -- fully thc
  180.12 @@ -41,7 +41,7 @@
  180.13                                                  ("spawn", ["rpcclient"]),
  180.14                                                  ("monitor_blocking", ["rpcclient"])],
  180.15                        addLibraries = [ "mm", "trace", "skb", "dist", "thc" ],
  180.16 -                      architectures = [ "x86_64", "x86_32", "scc", "beehive" ]
  180.17 +                      architectures = [ "x86_64", "x86_32", "scc" ]
  180.18                      },
  180.19    build application { target = "mem_bench",
  180.20    		      cFiles = [ "mem_bench.c", "memtest_trace.c" ],
   181.1 --- a/usr/mem_serv_dist/mem_serv.h	Fri Jan 20 14:32:03 2012 -0800
   181.2 +++ b/usr/mem_serv_dist/mem_serv.h	Mon Jan 23 11:04:15 2012 -0800
   181.3 @@ -46,9 +46,6 @@
   181.4  #       define MAXSIZEBITS     38    ///< Max size of memory in allocator
   181.5  #elif defined(__i386__)
   181.6  #       define MAXSIZEBITS     32
   181.7 -#elif defined(__BEEHIVE__)
   181.8 -/* XXX This is better if < 32! - but there were no compile time warnings! */
   181.9 -#       define MAXSIZEBITS     31
  181.10  #elif defined(__arm__)
  181.11  /* XXX This is better if < 32! - but there were no compile time warnings! */
  181.12  #       define MAXSIZEBITS     31
   182.1 --- a/usr/monitor/Hakefile	Fri Jan 20 14:32:03 2012 -0800
   182.2 +++ b/usr/monitor/Hakefile	Mon Jan 23 11:04:15 2012 -0800
   182.3 @@ -34,7 +34,6 @@
   182.4       arch_srcs "x86_32"  = [ "arch/x86/boot.c", "arch/x86/inter.c", "arch/x86/monitor_server.c", "arch/x86/notify_ipi.c" ]
   182.5       arch_srcs "x86_64"  = [ "arch/x86/boot.c", "arch/x86/inter.c", "arch/x86/monitor_server.c", "arch/x86/notify_ipi.c" ]
   182.6       arch_srcs "scc"     = [ "arch/scc/boot.c", "arch/scc/inter.c", "arch/x86/monitor_server.c", "arch/x86/notify_ipi.c" ]
   182.7 -     arch_srcs "beehive" = [ "arch/beehive/inter.c" , "arch/beehive/boot.c" , "arch/beehive/monitor_server.c", "arch/beehive/endpoint.c" ]
   182.8       arch_srcs "arm"     = [ "arch/arm/boot.c", "arch/arm/inter.c", "arch/arm/monitor_server.c" ]
   182.9       arch_srcs "xscale"  = [ "arch/arm/boot.c", "arch/arm/inter.c", "arch/arm/monitor_server.c" ]
  182.10       arch_srcs _         = []
  182.11 @@ -42,7 +41,6 @@
  182.12       idc_srcs = concat $ map getsrcs $ optInterconnectDrivers $ options arch
  182.13            where
  182.14              getsrcs "ump" = [ "ump_support.c" ]
  182.15 -            getsrcs "bmp" = [ "bmp_support.c" ]
  182.16              getsrcs "multihop" = [ "multihop_support.c" ]
  182.17              getsrcs _     = []
  182.18              
  182.19 @@ -60,13 +58,10 @@
  182.20                          flounderExtraBindings = [ ("monitor", ["loopback"]),
  182.21                                                    ("monitor_mem", ["rpcclient"]),
  182.22                                                    ("mem", ["rpcclient"]) ],
  182.23 -                        addLinkFlags = if arch == "beehive" then
  182.24 -				           []
  182.25 -				       else
  182.26 -					   [ "-e _start_init" ],
  182.27 +                        addLinkFlags = [ "-e _start_init" ],
  182.28                          addIncludes = [ "include" ./. a | a <- arch_dirs arch ],
  182.29 -                        addLibraries =
  182.30 - 			    ([ "spawndomain", "bench", "trace" ] ++ rcap_db_libs ++ idc_libraries
  182.31 -                             ++ if arch == "beehive" then [] else [ "elf" ])
  182.32 +                        addLibraries = (
  182.33 + 			    [ "spawndomain", "bench", "trace", "elf" ]
  182.34 +                            ++ rcap_db_libs ++ idc_libraries)
  182.35                        }
  182.36   ) | arch <- allArchitectures ]
   183.1 --- a/usr/monitor/arch/beehive/boot.c	Fri Jan 20 14:32:03 2012 -0800
   183.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   183.3 @@ -1,335 +0,0 @@
   183.4 -/**
   183.5 - * \file
   183.6 - * \brief Code for handling booting additional cores
   183.7 - */
   183.8 -
   183.9 -/*
  183.10 - * Copyright (c) 2010, ETH Zurich.
  183.11 - * All rights reserved.
  183.12 - *
  183.13 - * This file is distributed under the terms in the attached LICENSE file.
  183.14 - * If you do not find this file, copies can be found by writing to:
  183.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  183.16 - */
  183.17 -
  183.18 -#include "monitor.h"
  183.19 -#include <bexec.h>
  183.20 -#include <target/beehive/barrelfish_kpi/coredata_target.h>
  183.21 -#include <barrelfish/dispatch.h>
  183.22 -#include <simctrl.h>
  183.23 -
  183.24 -// XXX We can't relocate binaries on Beehive yet so need a 2nd copy of 
  183.25 -// everything!
  183.26 -#define MONITOR_NAME "beehive/sbin/monitor"
  183.27 -#define KERNEL_NAME "beehive/sbin/cpu"
  183.28 -
  183.29 -#define APP_CORE_DATA_PAGES 600
  183.30 -
  183.31 -static errval_t spawn_arch_load(lvaddr_t binary,
  183.32 -                        size_t binary_size, genvaddr_t *entry)
  183.33 -{
  183.34 -    // Look at the bexec header and pull out the entry point.
  183.35 -    // Don't need to relocate the binary - but we may want to record
  183.36 -    // that the module is in use to prevent two domains sharing the 
  183.37 -    // same data segment!
  183.38 -    bexec_t *bexec = (bexec_t *)binary;
  183.39 -    assert(bexec->bmagic == BEXEC_BMAGIC);
  183.40 -    assert(bexec->btorg != 0);
  183.41 -
  183.42 -    *entry = bexec->btorg;
  183.43 -
  183.44 -    return SYS_ERR_OK;
  183.45 -}
  183.46 -
  183.47 -/* FIXME: find a header file for these! */
  183.48 -extern errval_t beehive_create_cap(coreid_t coreid, int chanid,
  183.49 -                                   struct capref *retcap);
  183.50 -
  183.51 -extern errval_t beehive_chan_allocate(struct capref ep, int *chanid);
  183.52 -
  183.53 -extern void intermon_bmp_setup(struct intermon_bmp_binding *b, struct capref bmp_cap,
  183.54 -                        struct lmp_endpoint *inep, struct capref inepcap);
  183.55 -
  183.56 -
  183.57 -// set up the monitor's side of a BMP binding given all the necessary state
  183.58 -void intermon_bmp_setup(struct intermon_bmp_binding *b, struct capref bmp_cap,
  183.59 -                        struct lmp_endpoint *inep, struct capref inepcap)
  183.60 -{
  183.61 -
  183.62 -    // init our end of the binding and channel
  183.63 -    intermon_bmp_init(b, get_default_waitset());
  183.64 -
  183.65 -    // XXX: stuff state into private parts of the binding to complete init
  183.66 -    b->bmp_state.chan.outepcap = bmp_cap;
  183.67 -    b->bmp_state.chan.outeplen = DEFAULT_BMP_BUF_WORDS;
  183.68 -    b->bmp_state.chan.inep = inep;
  183.69 -    b->bmp_state.chan.inepcap = inepcap;
  183.70 -
  183.71 -    // XXX: run rx handler to cause it to register on waitset for recieve events
  183.72 -    intermon_bmp_rx_handler(b);
  183.73 -}
  183.74 -
  183.75 -errval_t spawn_xcore_monitor(coreid_t coreid, int nopid, enum cpu_type cpu_type,
  183.76 -                             const char *cmdline /* XXX: currently ignored */,
  183.77 -                             struct intermon_binding **ret_binding)
  183.78 -{
  183.79 -    errval_t err;
  183.80 -
  183.81 -    debug_printf("spawn_xcore_monitor %d\n", coreid);
  183.82 -
  183.83 -    // XXX BUILD A DATASTRUCTURE TO PASS TO THE NEW KERNEL
  183.84 -
  183.85 -    /* This will tell the new kernel where the monitor binary is and
  183.86 -       also pass it some initial memory for the kernel to use when
  183.87 -       creating the monitor process strutures. 
  183.88 -       
  183.89 -       We also allocate memory for use by the startup code of the new
  183.90 -       kernel, e.g. to create the monitor domain
  183.91 -    */
  183.92 -
  183.93 -    assert(sizeof(struct beehive_core_data) <= BASE_PAGE_SIZE);
  183.94 -    size_t cpu_memory = BASE_PAGE_SIZE * APP_CORE_DATA_PAGES;
  183.95 -    struct capref cpu_memory_cap;
  183.96 -    err = frame_alloc(&cpu_memory_cap, cpu_memory, &cpu_memory);
  183.97 -    if (err_is_fail(err)) {
  183.98 -        return err_push(err, LIB_ERR_FRAME_ALLOC);
  183.99 -    }
 183.100 -    void *cpu_buf_memory;
 183.101 -    err = vspace_map_one_frame(&cpu_buf_memory, cpu_memory, 
 183.102 -                               cpu_memory_cap, NULL, NULL);
 183.103 -    if(err_is_fail(err)) {
 183.104 -        return err_push(err, LIB_ERR_VSPACE_MAP);
 183.105 -    }
 183.106 -    struct beehive_core_data *core_data = 
 183.107 -        (struct beehive_core_data*)cpu_buf_memory;
 183.108 -
 183.109 -    debug_printf("BOOTINFO at %p\n", bi);
 183.110 -    core_data->bootinfo = bi;
 183.111 -    core_data->memory_base = (lvaddr_t)cpu_buf_memory + BASE_PAGE_SIZE;
 183.112 -    core_data->memory_limit = (lvaddr_t)cpu_buf_memory + cpu_memory;
 183.113 -
 183.114 -    // construct name of kernel module for target core
 183.115 -    char namebuf[32];
 183.116 -    size_t namelen;
 183.117 -    namelen = snprintf(namebuf, sizeof(namebuf), "%s|%u", KERNEL_NAME, coreid);
 183.118 -    assert(namelen < sizeof(namebuf));
 183.119 -
 183.120 -    /* Look up modules */
 183.121 -    struct mem_region *cpu_region = multiboot_find_module(bi, namebuf);
 183.122 -    if (cpu_region == NULL) {
 183.123 -        debug_printf("failed to find cpu driver module\n");
 183.124 -        return SPAWN_ERR_FIND_MODULE;
 183.125 -    }
 183.126 -
 183.127 -    size_t cpu_binary_size;
 183.128 -    lvaddr_t cpu_binary;
 183.129 -    genpaddr_t cpu_binary_phys;
 183.130 -
 183.131 -    err = spawn_map_module(cpu_region, &cpu_binary_size, &cpu_binary,
 183.132 -			   &cpu_binary_phys);
 183.133 -    if (err_is_fail(err)) {
 183.134 -	return err_push(err, SPAWN_ERR_MAP_MODULE);
 183.135 -    }
 183.136 -    debug_printf("CPU driver at %x\n", cpu_binary);
 183.137 -
 183.138 -    /* Load the image */
 183.139 -    genvaddr_t cpu_entry;
 183.140 -    err = spawn_arch_load(cpu_binary, cpu_binary_size, &cpu_entry);
 183.141 -    if (err_is_fail(err)) {
 183.142 -        return err_push(err, SPAWN_ERR_LOAD);
 183.143 -    }
 183.144 -
 183.145 -    // construct name of monitor module for target core
 183.146 -    namelen = snprintf(namebuf, sizeof(namebuf), "%s|%u", MONITOR_NAME, coreid);
 183.147 -    assert(namelen < sizeof(namebuf));
 183.148 -    struct mem_region *monitor_region = multiboot_find_module(bi, namebuf);
 183.149 -    if (monitor_region == NULL) {
 183.150 -        return SPAWN_ERR_FIND_MODULE;
 183.151 -    }
 183.152 -
 183.153 -    core_data->cpu_module = (bexec_t *)cpu_binary;
 183.154 -    core_data->module_start = cpu_binary;
 183.155 -    core_data->module_end   = cpu_binary + cpu_binary_size;
 183.156 -
 183.157 -    debug_printf("spawn_map_module..\n");
 183.158 -
 183.159 -    size_t monitor_binary_size;
 183.160 -    lvaddr_t monitor_binary;
 183.161 -    genpaddr_t monitor_binary_phys;
 183.162 -
 183.163 -    err = spawn_map_module(monitor_region, &monitor_binary_size, 
 183.164 -			   &monitor_binary, &monitor_binary_phys);
 183.165 -    if (err_is_fail(err)) {
 183.166 -	return err_push(err, SPAWN_ERR_MAP_MODULE);
 183.167 -    }
 183.168 -    debug_printf("monitor at %x\n", monitor_binary);
 183.169 -
 183.170 -    core_data->monitor_module = (bexec_t *)monitor_binary;
 183.171 -    core_data->module_start = monitor_binary;
 183.172 -    core_data->module_end   = monitor_binary + monitor_binary_size;
 183.173 -    core_data->src_core_id = my_core_id;
 183.174 -
 183.175 -
 183.176 -    /*
 183.177 -     * Create the binding between this monitor and the monitor on the
 183.178 -     * newly spawned core. The other half of this connection setup is 
 183.179 -     * performed in boot_arch_app_core() below.
 183.180 -     */
 183.181 -
 183.182 -    struct intermon_bmp_binding *bmp_binding = 
 183.183 -        malloc(sizeof(struct intermon_bmp_binding));
 183.184 -    assert(bmp_binding != NULL);
 183.185 -
 183.186 -    // Create a normal IDC endpoint cap for incoming messages
 183.187 -    struct capref ep;
 183.188 -    struct lmp_endpoint *iep;
 183.189 -    err = endpoint_create(DEFAULT_BMP_BUF_WORDS, &ep, &iep);
 183.190 -    if (err_is_fail(err)) {
 183.191 -        USER_PANIC_ERR(err, "endpoint_create failed");
 183.192 -    }
 183.193 -
 183.194 -    // XXX Need to allocate a kernel 'association' for incoming messages
 183.195 -    // And then set it up to deliver to the above endpoint
 183.196 -    int chanid;
 183.197 -    err = beehive_chan_allocate(ep, &chanid);
 183.198 -    if (err_is_fail(err)) {
 183.199 -        USER_PANIC_ERR(err, "beehive_chan_allocate failed");
 183.200 -    }
 183.201 -
 183.202 -    // Record useful info in the core_data
 183.203 -    core_data->chanid = chanid;
 183.204 -
 183.205 -    // Create a way to send beehive messages to new core
 183.206 -    // Need to cause the remote kernel to take these messages and 
 183.207 -    // deliver them to its monitor LMP endpoint.
 183.208 -    // Channel 0 on new core is always the monitor.
 183.209 -    struct capref beehive_cap;
 183.210 -    err = beehive_create_cap(coreid, 0, &beehive_cap);
 183.211 -    assert(err == SYS_ERR_OK);
 183.212 -
 183.213 -    /* Invoke kernel capability to boot new core */
 183.214 -    debug_printf("invoke kernel cap...\n");
 183.215 -    err = invoke_monitor_spawn_core(coreid, cpu_type,
 183.216 -                                    (forvaddr_t)(lvaddr_t)core_data);
 183.217 -    if (err_is_fail(err)) {
 183.218 -        return err_push(err, MON_ERR_SPAWN_CORE);
 183.219 -    }
 183.220 -
 183.221 -    {
 183.222 -        struct bmp_chan chan;
 183.223 -        struct bmp_recv_msg msg;
 183.224 -        uintptr_t sendmsg = 0xF00;
 183.225 -
 183.226 -        /* Create a raw BMP chan */
 183.227 -        bmp_chan_init(&chan);
 183.228 -        chan.outepcap = beehive_cap;
 183.229 -        chan.outeplen = DEFAULT_BMP_BUF_WORDS;
 183.230 -        chan.inep = iep;
 183.231 -        chan.inepcap = ep;
 183.232 -
 183.233 -        msg.buf.buflen= BMP_MSG_LENGTH;
 183.234 -
 183.235 -        debug_printf("waiting for msgs...\n");
 183.236 -        for (int i = 0 ; i < 1000; i++) {
 183.237 -        retry:
 183.238 -            err = bmp_chan_recv(&chan, &msg);
 183.239 -            if (err_no(err) == LIB_ERR_NO_LMP_MSG) {
 183.240 -                sys_nop();
 183.241 -                goto retry;
 183.242 -            }
 183.243 -            bmp_chan_send(&chan, &sendmsg, 1);
 183.244 -        }
 183.245 -    }
 183.246 -    // init our end of the binding and channel
 183.247 -    intermon_bmp_setup(bmp_binding, beehive_cap, iep, ep);
 183.248 -
 183.249 -    *ret_binding = &bmp_binding->b;
 183.250 -
 183.251 -    return SYS_ERR_OK;
 183.252 -}
 183.253 -
 183.254 -/**
 183.255 - * \brief Initialize monitor running on app cores
 183.256 - */
 183.257 -errval_t boot_arch_app_core(int argc, char *argv[],
 183.258 -                            coreid_t *ret_parent_coreid,
 183.259 -                            struct intermon_binding **ret_binding)
 183.260 -{
 183.261 -    errval_t err;
 183.262 -
 183.263 -    assert(argc == 3);
 183.264 -
 183.265 -    // First argument contains the bootinfo location
 183.266 -    //    bi = (struct bootinfo*)strtol(argv[1], NULL, 10);
 183.267 -
 183.268 -    // core_id of the core that booted this core
 183.269 -    coreid_t core_id = strtol(argv[1], NULL, 10);
 183.270 -    *ret_parent_coreid = core_id;
 183.271 -
 183.272 -    // other monitor's channel id
 183.273 -    assert(strncmp("chanid", argv[2], strlen("chanid")) == 0);
 183.274 -    int chanid = strtol(strchr(argv[2], '=') + 1, NULL, 10);
 183.275 -
 183.276 -    // Create our own beehive cap
 183.277 -    struct capref beehive_cap;
 183.278 -    err = beehive_create_cap(core_id, chanid, &beehive_cap);
 183.279 -    assert(err == SYS_ERR_OK);
 183.280 -
 183.281 -    struct capref ep;
 183.282 -    struct lmp_endpoint *iep;
 183.283 -    err = endpoint_create(DEFAULT_BMP_BUF_WORDS, &ep, &iep);
 183.284 -    assert(err_is_ok(err));
 183.285 -
 183.286 -    int mychanid;
 183.287 -    err = beehive_chan_allocate(ep, &mychanid);
 183.288 -    assert(err_is_ok(err));
 183.289 -    assert(0 == mychanid);
 183.290 -
 183.291 -
 183.292 -    {
 183.293 -        struct bmp_chan chan;
 183.294 -        struct bmp_recv_msg msg;
 183.295 -        uintptr_t sendmsg = 0xF00;
 183.296 -
 183.297 -        /* Create a raw BMP chan */
 183.298 -        bmp_chan_init(&chan);
 183.299 -        chan.outepcap = beehive_cap;
 183.300 -        chan.outeplen = DEFAULT_BMP_BUF_WORDS;
 183.301 -        chan.inep     = iep;
 183.302 -        chan.inepcap  = ep;
 183.303 -
 183.304 -        /* Init message buf */
 183.305 -        msg.buf.buflen = BMP_MSG_LENGTH;
 183.306 -        
 183.307 -        /* Measure round-trip time */
 183.308 -        cycles_t before = bench_tsc();
 183.309 -        for (int i = 0 ; i < 1000; i++) {
 183.310 -	    BEE_SIMCTRL(BEE_SIMCTRL_CACHE_DELTA);
 183.311 -	    if (i == 555)
 183.312 -		BEE_SIMCTRL(BEE_SIMCTRL_TRACEON);
 183.313 -            bmp_chan_send(&chan, &sendmsg, 1);
 183.314 -        retry:
 183.315 -            err = bmp_chan_recv(&chan, &msg);
 183.316 -            if (err_no(err) == LIB_ERR_NO_LMP_MSG) {
 183.317 -                sys_nop();  // PUMP the BMP
 183.318 -                goto retry;
 183.319 -            }
 183.320 -	    if (i == 555)
 183.321 -		BEE_SIMCTRL(BEE_SIMCTRL_TRACEOFF);
 183.322 -        }
 183.323 -        cycles_t after = bench_tsc();
 183.324 -        debug_printf("Before %u after %u elapsed %u RTT %u\n",
 183.325 -                     before, after, (after-before), (after-before)/1000);
 183.326 -    }
 183.327 -
 183.328 -    // setup our side of the binding
 183.329 -    struct intermon_bmp_binding *ibb;
 183.330 -    ibb = malloc(sizeof(struct intermon_bmp_binding));
 183.331 -    assert(ibb != NULL);
 183.332 -
 183.333 -    intermon_bmp_setup(ibb, beehive_cap, iep, ep);
 183.334 -
 183.335 -    *ret_binding = &ibb->b;
 183.336 -
 183.337 -    return SYS_ERR_OK;
 183.338 -}
   184.1 --- a/usr/monitor/arch/beehive/endpoint.c	Fri Jan 20 14:32:03 2012 -0800
   184.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   184.3 @@ -1,94 +0,0 @@
   184.4 -/**
   184.5 - * \file
   184.6 - * \brief Beehive messaging
   184.7 - */
   184.8 -
   184.9 -/*
  184.10 - * Copyright (c) 2007, 2008, 2010, ETH Zurich.
  184.11 - * All rights reserved.
  184.12 - *
  184.13 - * This file is distributed under the terms in the attached LICENSE file.
  184.14 - * If you do not find this file, copies can be found by writing to:
  184.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  184.16 - */
  184.17 -
  184.18 -#include "monitor.h"
  184.19 -
  184.20 -/**
  184.21 - * \brief Set the handler endpoint for a given BMP association
  184.22 - *
  184.23 - * \param associd BMP association number
  184.24 - * \param ep Endpoint to receive interrupts
  184.25 - */
  184.26 -static errval_t monitor_bmptable_set(unsigned int associd, struct capref ep)
  184.27 -{
  184.28 -    return invoke_monitor_bmptable_set(cap_bmptable, associd, ep);
  184.29 -}
  184.30 -#if 0 // unused
  184.31 -/**
  184.32 - * \brief Remove the handler endpoint for a given BMP association
  184.33 - *
  184.34 - * \param associd BMP association number
  184.35 - */
  184.36 -static errval_t monitor_bmptable_delete(unsigned int associd)
  184.37 -{
  184.38 -    /* XXX: delete endpoint! */
  184.39 -    return invoke_monitor_bmptable_delete(cap_bmptable, associd);
  184.40 -}
  184.41 -#endif
  184.42 -
  184.43 -
  184.44 -extern errval_t beehive_create_cap(coreid_t coreid, int chanid,
  184.45 -                                   struct capref *retcap);
  184.46 -
  184.47 -extern errval_t beehive_chan_allocate(struct capref ep, int *chanid);
  184.48 -
  184.49 -
  184.50 -static int glbl_chanid = 0;
  184.51 -
  184.52 -
  184.53 -errval_t beehive_chan_allocate(struct capref ep, int *chanid)
  184.54 -{
  184.55 -    *chanid = glbl_chanid;
  184.56 -    glbl_chanid++;
  184.57 -
  184.58 -    if(get_cap_addr(ep) != CPTR_NULL) {
  184.59 -        return monitor_bmptable_set(*chanid, ep);
  184.60 -    } else {
  184.61 -        return SYS_ERR_OK;
  184.62 -    }
  184.63 -}
  184.64 -
  184.65 -errval_t beehive_create_cap(coreid_t coreid, int chanid, 
  184.66 -                            struct capref *retcap)
  184.67 -{
  184.68 -    errval_t err;
  184.69 -
  184.70 -    printf("%d: creating beehive cap with chanid %d, coreid %d, caller %p\n",
  184.71 -           my_core_id, chanid, coreid, __builtin_return_address(0));
  184.72 -
  184.73 -    /* Construct the notification capability */
  184.74 -    struct capability beehive_cap = {
  184.75 -        .type = ObjType_BMPEndPoint,
  184.76 -        .rights = CAPRIGHTS_READ_WRITE, // XXX
  184.77 -        .u.bmpendpoint = {
  184.78 -            .coreid = coreid,
  184.79 -            .chanid = chanid
  184.80 -        }
  184.81 -    };
  184.82 -
  184.83 -    err = slot_alloc(retcap);
  184.84 -    if (err_is_fail(err)) {
  184.85 -        DEBUG_ERR(err, "Failed to allocate slot from channel_alloc");
  184.86 -        printf("Failed to allocate slot from channel_alloc\n");
  184.87 -        abort(); //XXX
  184.88 -    }
  184.89 -    err = monitor_cap_create(*retcap, &beehive_cap, 0);
  184.90 -    if (err_is_fail(err)) {
  184.91 -        DEBUG_ERR(err, "monitor_cap_create failed");
  184.92 -        printf("monitor_cap_create failed\n");
  184.93 -        abort(); //XXX
  184.94 -    }
  184.95 -
  184.96 -    return SYS_ERR_OK;
  184.97 -}
   185.1 --- a/usr/monitor/arch/beehive/inter.c	Fri Jan 20 14:32:03 2012 -0800
   185.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   185.3 @@ -1,294 +0,0 @@
   185.4 -/**
   185.5 - * \file
   185.6 - * \brief Arch-specific inter-monitor communication
   185.7 - */
   185.8 -
   185.9 -/*
  185.10 - * Copyright (c) 2009, 2010, ETH Zurich.
  185.11 - * All rights reserved.
  185.12 - *
  185.13 - * This file is distributed under the terms in the attached LICENSE file.
  185.14 - * If you do not find this file, copies can be found by writing to:
  185.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  185.16 - */
  185.17 -
  185.18 -#include <inttypes.h>
  185.19 -#include "monitor.h"
  185.20 -#include <trace/trace.h>
  185.21 -
  185.22 -/* FIXME: needs a header file! */
  185.23 -extern errval_t beehive_create_cap(coreid_t coreid, int chanid,
  185.24 -                                   struct capref *retcap);
  185.25 -
  185.26 -extern errval_t beehive_chan_allocate(struct capref ep, int *chanid);
  185.27 -
  185.28 -extern void intermon_bmp_setup(struct intermon_bmp_binding *b, struct capref bmp_cap,
  185.29 -                        struct lmp_endpoint *inep, struct capref inepcap);
  185.30 -
  185.31 -
  185.32 -/******* stack-ripped bind_monitor_request_bmp *******/
  185.33 -
  185.34 -static void bind_monitor_reply_bmp_handler(struct intermon_binding *b,
  185.35 -                                           struct intermon_msg_queue_elem *e);
  185.36 -
  185.37 -struct bind_monitor_reply_bmp_state {
  185.38 -    struct intermon_msg_queue_elem elem;
  185.39 -    struct intermon_bind_monitor_reply_bmp__args args;
  185.40 -};
  185.41 -
  185.42 -static void bind_monitor_reply_bmp_cont(struct intermon_binding *b,
  185.43 -                                        errval_t err, chanid_t chanid)
  185.44 -{
  185.45 -    errval_t err2;
  185.46 -
  185.47 -    err2 = b->tx_vtbl.bind_monitor_reply_bmp(b, NOP_CONT, err,
  185.48 -                                             chanid, my_core_id);
  185.49 -    if (err_is_fail(err2)) {
  185.50 -        if(err_no(err2) == FLOUNDER_ERR_TX_BUSY) {
  185.51 -            struct bind_monitor_reply_bmp_state *me =
  185.52 -                malloc(sizeof(struct bind_monitor_reply_bmp_state));
  185.53 -            assert(me != NULL);
  185.54 -            struct intermon_state *ist = b->st;
  185.55 -            assert(ist != NULL);
  185.56 -            me->args.err = err;
  185.57 -            me->args.chan_id = chanid;
  185.58 -            me->elem.cont = bind_monitor_reply_bmp_handler;
  185.59 -
  185.60 -            err = intermon_enqueue_send(b, &ist->queue,
  185.61 -                                        get_default_waitset(), &me->elem.queue);
  185.62 -            assert(err_is_ok(err));
  185.63 -            return;
  185.64 -        }
  185.65 -
  185.66 -        DEBUG_ERR(err2, "reply failed");
  185.67 -    }
  185.68 -}
  185.69 -
  185.70 -static void bind_monitor_reply_bmp_handler(struct intermon_binding *b,
  185.71 -                                           struct intermon_msg_queue_elem *e)
  185.72 -{
  185.73 -    struct bind_monitor_reply_bmp_state *st = (struct bind_monitor_reply_bmp_state *)e;
  185.74 -    bind_monitor_reply_bmp_cont(b, st->args.err, st->args.chan_id);
  185.75 -    free(e);
  185.76 -}
  185.77 -
  185.78 -/**
  185.79 - * \brief A monitor receives request to setup a connection
  185.80 - * with another newly booted monitor from a third monitor
  185.81 - */
  185.82 -static void bind_monitor_request_bmp(struct intermon_binding *b,
  185.83 -                                     coreid_t core_id, 
  185.84 -                                     chanid_t chan_id, 
  185.85 -                                     coreid_t from_core_id)
  185.86 -{
  185.87 -    errval_t err;
  185.88 -
  185.89 -    // Create our own beehive cap to the remote core
  185.90 -    struct capref beehive_cap;
  185.91 -    err = beehive_create_cap(core_id, chan_id, &beehive_cap);
  185.92 -    assert(err == SYS_ERR_OK);
  185.93 -
  185.94 -    struct capref ep;
  185.95 -    struct lmp_endpoint *iep;
  185.96 -    err = endpoint_create(DEFAULT_BMP_BUF_WORDS, &ep, &iep);
  185.97 -    assert(err_is_ok(err));
  185.98 -
  185.99 -    int mychanid;
 185.100 -    err = beehive_chan_allocate(ep, &mychanid);
 185.101 -    assert(err_is_ok(err));
 185.102 -
 185.103 -    // setup our side of the binding
 185.104 -    struct intermon_bmp_binding *ibb;
 185.105 -    ibb = malloc(sizeof(struct intermon_bmp_binding));
 185.106 -    assert(ibb != NULL);
 185.107 -
 185.108 -    intermon_bmp_setup(ibb, beehive_cap, iep, ep);
 185.109 -
 185.110 -    // connect it to our request handlers
 185.111 -    intermon_init(&ibb->b, core_id);
 185.112 -
 185.113 -    /* Send reply */
 185.114 -    assert(ibb != NULL);
 185.115 -    bind_monitor_reply_bmp_cont(&ibb->b, err, mychanid);
 185.116 -    return;
 185.117 -}
 185.118 -
 185.119 -/**
 185.120 - * \brief The monitor that proxied the request for one monitor to
 185.121 - * setup a connection with another monitor gets the reply
 185.122 - */
 185.123 -static void bind_monitor_reply_bmp(struct intermon_binding *binding,
 185.124 -                                   errval_t err, chanid_t chan_id,
 185.125 -                                   coreid_t core_id)
 185.126 -{
 185.127 -    struct intermon_bmp_binding *b = (struct intermon_bmp_binding *)binding;
 185.128 -
 185.129 -    // Create a way to send beehive messages to new core
 185.130 -    err = beehive_create_cap(core_id, chan_id, &b->bmp_state.chan.outepcap);
 185.131 -    assert(err == SYS_ERR_OK);
 185.132 -}
 185.133 -
 185.134 -/******* stack-ripped bind_monitor_proxy_bmp *******/
 185.135 -
 185.136 -static void bind_monitor_request_bmp_handler(struct intermon_binding *b,
 185.137 -                                           struct intermon_msg_queue_elem *e);
 185.138 -
 185.139 -struct bind_monitor_request_bmp_state {
 185.140 -    struct intermon_msg_queue_elem elem;
 185.141 -    struct intermon_bind_monitor_request_bmp__args args;
 185.142 -};
 185.143 -
 185.144 -static void bind_monitor_request_bmp_cont(struct intermon_binding *dst_binding,
 185.145 -                                          coreid_t src_core_id,
 185.146 -                                          chanid_t chan_id,
 185.147 -                                          coreid_t core_id)
 185.148 -{
 185.149 -    errval_t err;
 185.150 -
 185.151 -    err = dst_binding->tx_vtbl.
 185.152 -        bind_monitor_request_bmp(dst_binding, NOP_CONT, src_core_id, 
 185.153 -                                 chan_id, core_id);
 185.154 -    if (err_is_fail(err)) {
 185.155 -        if(err_no(err) == FLOUNDER_ERR_TX_BUSY) {
 185.156 -            struct bind_monitor_request_bmp_state *me =
 185.157 -                malloc(sizeof(struct bind_monitor_request_bmp_state));
 185.158 -            assert(me != NULL);
 185.159 -            struct intermon_state *ist = dst_binding->st;
 185.160 -            assert(ist != NULL);
 185.161 -            me->args.core_id = src_core_id;
 185.162 -            me->args.chan_id = chan_id;
 185.163 -            me->args.from_core_id = core_id;
 185.164 -            me->elem.cont = bind_monitor_request_bmp_handler;
 185.165 -
 185.166 -            err = intermon_enqueue_send(dst_binding, &ist->queue,
 185.167 -                                        get_default_waitset(), &me->elem.queue);
 185.168 -            assert(err_is_ok(err));
 185.169 -            return;
 185.170 -        }
 185.171 -
 185.172 -        DEBUG_ERR(err, "forwarding bind request failed");
 185.173 -    }
 185.174 -}
 185.175 -
 185.176 -static void bind_monitor_request_bmp_handler(struct intermon_binding *b,
 185.177 -                                             struct intermon_msg_queue_elem *e)
 185.178 -{
 185.179 -    struct bind_monitor_request_bmp_state *st = (struct bind_monitor_request_bmp_state *)e;
 185.180 -    bind_monitor_request_bmp_cont(b, st->args.core_id,
 185.181 -                                  st->args.chan_id, st->args.from_core_id);
 185.182 -    free(e);
 185.183 -}
 185.184 -
 185.185 -/**
 185.186 - * \brief A monitor asks this monitor to proxy
 185.187 - * its request to bind to another monitor
 185.188 - */
 185.189 -static void bind_monitor_proxy_bmp(struct intermon_binding *b,
 185.190 -                                   coreid_t dst_core_id,
 185.191 -                                   chanid_t chan_id,
 185.192 -                                   coreid_t core_id)
 185.193 -{
 185.194 -    seen_connections++;
 185.195 -    errval_t err;
 185.196 -
 185.197 -    /* Get source monitor's core id */
 185.198 -    coreid_t src_core_id = ((struct intermon_state *)b->st)->core_id;
 185.199 -
 185.200 -    /* Get destination monitor */
 185.201 -    struct intermon_binding *dst_binding = NULL;
 185.202 -    err = intermon_binding_get(dst_core_id, &dst_binding);
 185.203 -    if (err_is_fail(err)) {
 185.204 -        DEBUG_ERR(err, "intermon_binding_get failed");
 185.205 -    }
 185.206 -
 185.207 -    // Proxy the request
 185.208 -    bind_monitor_request_bmp_cont(dst_binding, src_core_id, 
 185.209 -                                  chan_id, core_id);
 185.210 -}
 185.211 -
 185.212 -/**
 185.213 - * \brief Notification of a newly booted monitor.
 185.214 - *  Setup our connection and request the sender to proxy
 185.215 - *  the bind request to the monitor
 185.216 - */
 185.217 -static void new_monitor_notify(struct intermon_binding *b,
 185.218 -                               coreid_t core_id)
 185.219 -{
 185.220 -    errval_t err;
 185.221 -
 185.222 -    /*
 185.223 -     * Create the binding between this monitor and the monitor on the
 185.224 -     * newly spawned core. The other half of this connection setup is 
 185.225 -     * performed in bind_monitor_request_bmp() above.
 185.226 -     */
 185.227 -
 185.228 -    struct intermon_bmp_binding *bmp_binding = 
 185.229 -        malloc(sizeof(struct intermon_bmp_binding));
 185.230 -    assert(bmp_binding != NULL);
 185.231 -
 185.232 -    // Create a normal IDC endpoint cap for incoming messages
 185.233 -    struct capref ep;
 185.234 -    struct lmp_endpoint *iep;
 185.235 -    err = endpoint_create(DEFAULT_BMP_BUF_WORDS, &ep, &iep);
 185.236 -    assert(err_is_ok(err));
 185.237 -
 185.238 -    // XXX Need to allocate a kernel 'association' for incoming messages
 185.239 -    // And then set it up to deliver to the above endpoint
 185.240 -    int chanid;
 185.241 -    err = beehive_chan_allocate(ep, &chanid);
 185.242 -    if (err_is_fail(err)) {
 185.243 -        DEBUG_ERR(err, "beehive_chan_allocate failed");
 185.244 -        abort();
 185.245 -    }
 185.246 -    assert(err_is_ok(err));
 185.247 -
 185.248 -    // init our end of the binding and channel
 185.249 -    // we won't know the bmp cap until we get the bind reply
 185.250 -    intermon_bmp_setup(bmp_binding, NULL_CAP, iep, ep);
 185.251 -
 185.252 -    err = intermon_init(&bmp_binding->b, core_id);
 185.253 -    assert(err_is_ok(err));
 185.254 -
 185.255 -    /* reply to the sending monitor to proxy request */
 185.256 -    err = b->tx_vtbl.bind_monitor_proxy_bmp(b, NOP_CONT, core_id,
 185.257 -                                            chanid, my_core_id);
 185.258 -    if (err_is_fail(err)) {
 185.259 -        DEBUG_ERR(err, "bind proxy request failed");
 185.260 -    }
 185.261 -}
 185.262 -
 185.263 -static void spawnd_image_request(struct intermon_binding *b)
 185.264 -{
 185.265 -    assert(bsp_monitor);
 185.266 -    errval_t err;
 185.267 -
 185.268 -    char namebuf[32];
 185.269 -    size_t namelen;
 185.270 -
 185.271 -    struct intermon_state *st = b->st;
 185.272 -
 185.273 -    namelen = snprintf(namebuf, sizeof(namebuf),
 185.274 -                        "beehive/sbin/spawnd|%u", st->core_id);
 185.275 -    assert(namelen < sizeof(namebuf));
 185.276 -
 185.277 -    struct mem_region *mod = multiboot_find_module(bi, namebuf);
 185.278 -    if (mod == NULL) {
 185.279 -        USER_PANIC("didn't find %s in multiboot image", namebuf);
 185.280 -    }
 185.281 -
 185.282 -    assert(mod->mr_type == RegionType_Module);
 185.283 -
 185.284 -    err = b->tx_vtbl.spawnd_image_reply(b, NOP_CONT, mod->mr_base, mod->mrmod_size);
 185.285 -    assert(err_is_ok(err));
 185.286 -}
 185.287 -
 185.288 -errval_t arch_intermon_init(struct intermon_binding *b)
 185.289 -{
 185.290 -    b->rx_vtbl.bind_monitor_request_bmp = bind_monitor_request_bmp;
 185.291 -    b->rx_vtbl.bind_monitor_reply_bmp = bind_monitor_reply_bmp;
 185.292 -    b->rx_vtbl.bind_monitor_proxy_bmp = bind_monitor_proxy_bmp;
 185.293 -    b->rx_vtbl.new_monitor_notify = new_monitor_notify;
 185.294 -    b->rx_vtbl.spawnd_image_request = spawnd_image_request;
 185.295 -
 185.296 -    return SYS_ERR_OK;
 185.297 -}
   186.1 --- a/usr/monitor/arch/beehive/monitor_server.c	Fri Jan 20 14:32:03 2012 -0800
   186.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   186.3 @@ -1,21 +0,0 @@
   186.4 -/**
   186.5 - * \file
   186.6 - * \brief Monitor's connection with the dispatchers on the same core
   186.7 - */
   186.8 -
   186.9 -/*
  186.10 - * Copyright (c) 2009, 2010, ETH Zurich.
  186.11 - * All rights reserved.
  186.12 - *
  186.13 - * This file is distributed under the terms in the attached LICENSE file.
  186.14 - * If you do not find this file, copies can be found by writing to:
  186.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  186.16 - */
  186.17 -
  186.18 -#include "monitor.h"
  186.19 -
  186.20 -errval_t monitor_server_arch_init(struct monitor_binding *b)
  186.21 -{
  186.22 -    // TODO: XXX The purpose of this function is unclear
  186.23 -    return SYS_ERR_OK;
  186.24 -}
   187.1 --- a/usr/monitor/bmp_support.c	Fri Jan 20 14:32:03 2012 -0800
   187.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   187.3 @@ -1,484 +0,0 @@
   187.4 -/**
   187.5 - * \file
   187.6 - * \brief BMP channel support
   187.7 - */
   187.8 -
   187.9 -/*
  187.10 - * Copyright (c) 2009, 2010, ETH Zurich.
  187.11 - * All rights reserved.
  187.12 - *
  187.13 - * This file is distributed under the terms in the attached LICENSE file.
  187.14 - * If you do not find this file, copies can be found by writing to:
  187.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  187.16 - */
  187.17 -
  187.18 -#include <inttypes.h>
  187.19 -#include "monitor.h"
  187.20 -
  187.21 -/* FIXME: why isn't there a header file for these prototypes? */
  187.22 -extern errval_t beehive_create_cap(coreid_t coreid, int chanid,
  187.23 -                                   struct capref *retcap);
  187.24 -extern errval_t beehive_chan_allocate(struct capref ep, int *chanid);
  187.25 -
  187.26 -/******* stack-ripped monitor_bind_bmp_client_request *******/
  187.27 -
  187.28 -static void monitor_bind_bmp_client_request_error(struct monitor_binding *b,
  187.29 -                                                  uintptr_t conn_id,
  187.30 -                                                  uintptr_t domain_id,
  187.31 -                                                  errval_t err)
  187.32 -{
  187.33 -    errval_t err2;
  187.34 -
  187.35 -    if (conn_id != 0) {
  187.36 -        err2 = remote_conn_free(conn_id);
  187.37 -        if (err_is_fail(err2)) {
  187.38 -            DEBUG_ERR(err2, "remote_conn_free failed");
  187.39 -        }
  187.40 -    }
  187.41 -
  187.42 -    err2 = b->tx_vtbl.bind_bmp_reply_client(b, NOP_CONT, 0, domain_id,
  187.43 -                                            NULL_CAP, 0, err);
  187.44 -    if (err_is_fail(err2)) {
  187.45 -        DEBUG_ERR(err2, "error reply failed");
  187.46 -    }
  187.47 -}
  187.48 -
  187.49 -static void bind_bmp_request_handler(struct intermon_binding *b,
  187.50 -                                     struct intermon_msg_queue_elem *e);
  187.51 -
  187.52 -struct bind_bmp_request_state {
  187.53 -    struct intermon_msg_queue_elem elem;
  187.54 -    struct intermon_bind_bmp_request__args args;
  187.55 -    struct monitor_binding *b;
  187.56 -    uintptr_t domain_id;
  187.57 -};
  187.58 -
  187.59 -static void bind_bmp_request_cont(struct intermon_binding *mon_binding,
  187.60 -                                  iref_t iref, uintptr_t conn_id,
  187.61 -                                  uint32_t chanid, uint32_t eplen,
  187.62 -                                  struct monitor_binding *b,
  187.63 -                                  uintptr_t domain_id)
  187.64 -{
  187.65 -    errval_t err;
  187.66 -
  187.67 -    /* Send the request to the monitor on the server's core */
  187.68 -    err = mon_binding->tx_vtbl.
  187.69 -        bind_bmp_request(mon_binding, NOP_CONT, iref, conn_id, chanid, eplen);
  187.70 -    if (err_is_fail(err)) {
  187.71 -        if(err_no(err) == FLOUNDER_ERR_TX_BUSY) {
  187.72 -            struct bind_bmp_request_state *me =
  187.73 -                malloc(sizeof(struct bind_bmp_request_state));
  187.74 -            struct intermon_state *ist = mon_binding->st;
  187.75 -            me->args.iref = iref;
  187.76 -            me->args.mon_id = conn_id;
  187.77 -            me->args.chanid = chanid;
  187.78 -            me->args.ep_len = eplen;
  187.79 -            me->b = b;
  187.80 -            me->domain_id = domain_id;
  187.81 -            me->elem.cont = bind_bmp_request_handler;
  187.82 -
  187.83 -            err = intermon_enqueue_send(mon_binding, &ist->queue,
  187.84 -                                        get_default_waitset(), &me->elem.queue);
  187.85 -            assert(err_is_ok(err));
  187.86 -            return;
  187.87 -        }
  187.88 -
  187.89 -        DEBUG_ERR(err, "failed forwarding BMP bind request");
  187.90 -        monitor_bind_bmp_client_request_error(b, conn_id, domain_id, err);
  187.91 -    }
  187.92 -}
  187.93 -
  187.94 -static void bind_bmp_request_handler(struct intermon_binding *b,
  187.95 -                                     struct intermon_msg_queue_elem *e)
  187.96 -{
  187.97 -    struct bind_bmp_request_state *st = (struct bind_bmp_request_state *)e;
  187.98 -    bind_bmp_request_cont(b, st->args.iref, st->args.mon_id, st->args.chanid,
  187.99 -                          st->args.ep_len, st->b, st->domain_id);
 187.100 -    free(e);
 187.101 -}
 187.102 -
 187.103 -static void monitor_bind_bmp_client_request(struct monitor_binding *b,
 187.104 -                                            iref_t iref, uintptr_t domain_id,
 187.105 -                                            struct capref lmp_ep)
 187.106 -{
 187.107 -    uint8_t core_id;
 187.108 -    uintptr_t conn_id = 0;
 187.109 -    errval_t err;
 187.110 -    struct remote_conn_state *conn = NULL;
 187.111 -
 187.112 -    // Get the core id
 187.113 -    err = iref_get_core_id(iref, &core_id);
 187.114 -    if (err_is_fail(err)) {
 187.115 -        cap_destroy(lmp_ep);
 187.116 -        monitor_bind_bmp_client_request_error(b, conn_id, domain_id, err);
 187.117 -        return;
 187.118 -    }
 187.119 -
 187.120 -    if (core_id == my_core_id) {
 187.121 -        cap_destroy(lmp_ep);
 187.122 -        err = MON_ERR_SAME_CORE;
 187.123 -        monitor_bind_bmp_client_request_error(b, conn_id, domain_id, err);
 187.124 -        return;
 187.125 -    }
 187.126 -
 187.127 -    // Identify endpoint cap
 187.128 -    struct capability capability;
 187.129 -    err = monitor_cap_identify(lmp_ep, &capability);
 187.130 -    if (err_is_fail(err)) {
 187.131 -        DEBUG_ERR(err, "monitor_cap_identify failed, ignored");
 187.132 -        return; // XXX
 187.133 -    }
 187.134 -    assert(capability.type == ObjType_EndPoint); // XXX: shouldn't assert
 187.135 -
 187.136 -    // Allocate Beehive endpoint locally
 187.137 -    int chanid;
 187.138 -    err = beehive_chan_allocate(lmp_ep, &chanid);
 187.139 -    assert(err_is_ok(err)); // XXX
 187.140 -
 187.141 -    /* destroy our copy of the endpoint, we don't need it any more */
 187.142 -    errval_t err2 = cap_destroy(lmp_ep);
 187.143 -    if (err_is_fail(err2)) {
 187.144 -        DEBUG_ERR(err, "cap_destroy failed");
 187.145 -    }
 187.146 -
 187.147 -    /* Forward request to the corresponding monitor */
 187.148 -    // Create local state
 187.149 -    err = remote_conn_alloc(&conn, &conn_id, REMOTE_CONN_BMP);
 187.150 -    if (err_is_fail(err)) {
 187.151 -        monitor_bind_bmp_client_request_error(b, conn_id, domain_id, err);
 187.152 -        return;
 187.153 -    }
 187.154 -
 187.155 -    // Track data
 187.156 -    conn->domain_id = domain_id;
 187.157 -    conn->domain_binding = b;
 187.158 -
 187.159 -    // Get connection to the monitor to forward request to
 187.160 -    struct intermon_binding *mon_binding;
 187.161 -    err = intermon_binding_get(core_id, &mon_binding);
 187.162 -    if (err_is_fail(err)) {
 187.163 -        monitor_bind_bmp_client_request_error(b, conn_id, domain_id, err);
 187.164 -        return;
 187.165 -    }
 187.166 -
 187.167 -    bind_bmp_request_cont(mon_binding, iref, conn_id, chanid,
 187.168 -                          capability.u.endpoint.epbuflen, b, domain_id);
 187.169 -}
 187.170 -
 187.171 -/******* stack-ripped monitor_bind_bmp_reply *******/
 187.172 -
 187.173 -static void bind_bmp_reply_handler(struct intermon_binding *b,
 187.174 -                                     struct intermon_msg_queue_elem *e);
 187.175 -
 187.176 -struct bind_bmp_reply_state {
 187.177 -    struct intermon_msg_queue_elem elem;
 187.178 -    struct intermon_bind_bmp_reply__args args;
 187.179 -    struct capability capability;
 187.180 -};
 187.181 -
 187.182 -static void bind_bmp_reply_cont(struct intermon_binding *mon_binding,
 187.183 -                                uintptr_t your_mon_id, uintptr_t my_mon_id,
 187.184 -                                uintptr_t msgerr, uint32_t chanid, uint32_t eplen)
 187.185 -{
 187.186 -    errval_t err;
 187.187 -
 187.188 -    err = mon_binding->tx_vtbl.
 187.189 -        bind_bmp_reply(mon_binding, NOP_CONT, your_mon_id, my_mon_id, msgerr,
 187.190 -                       chanid, eplen);
 187.191 -    if (err_is_fail(err)) {
 187.192 -        if(err_no(err) == FLOUNDER_ERR_TX_BUSY) {
 187.193 -            struct bind_bmp_reply_state *me =
 187.194 -                malloc(sizeof(struct bind_bmp_reply_state));
 187.195 -            struct intermon_state *ist = mon_binding->st;
 187.196 -            me->args.con_id = your_mon_id;
 187.197 -            me->args.mon_id = my_mon_id;
 187.198 -            me->args.err = msgerr;
 187.199 -            me->args.chanid = chanid;
 187.200 -            me->args.ep_len = eplen;
 187.201 -            me->elem.cont = bind_bmp_reply_handler;
 187.202 -
 187.203 -            err = intermon_enqueue_send(mon_binding, &ist->queue,
 187.204 -                                        get_default_waitset(), &me->elem.queue);
 187.205 -            assert(err_is_ok(err));
 187.206 -            return;
 187.207 -        }
 187.208 -
 187.209 -        DEBUG_ERR(err, "failed forwarding BMP bind reply");
 187.210 -        // cleanup
 187.211 -        if (err_is_ok(msgerr)) {
 187.212 -            err = remote_conn_free(my_mon_id);
 187.213 -            assert(err_is_ok(err));
 187.214 -        }
 187.215 -    }
 187.216 -}
 187.217 -
 187.218 -static void bind_bmp_reply_handler(struct intermon_binding *b,
 187.219 -                                   struct intermon_msg_queue_elem *e)
 187.220 -{
 187.221 -    struct bind_bmp_reply_state *st = (struct bind_bmp_reply_state *)e;
 187.222 -    bind_bmp_reply_cont(b, st->args.con_id, st->args.mon_id, st->args.err,
 187.223 -                        st->args.chanid, st->args.ep_len);
 187.224 -    free(e);
 187.225 -}
 187.226 -
 187.227 -static void monitor_bind_bmp_reply(struct monitor_binding *dom_binding,
 187.228 -                                   uintptr_t my_mon_id, uintptr_t domain_id,
 187.229 -                                   struct capref lmp_ep, errval_t msgerr)
 187.230 -{
 187.231 -    errval_t err;
 187.232 -
 187.233 -    struct remote_conn_state *conn = remote_conn_lookup(my_mon_id);
 187.234 -    if (conn == NULL) {
 187.235 -        DEBUG_ERR(0, "invalid mon_id in BMP bind reply");
 187.236 -        return;
 187.237 -    }
 187.238 -
 187.239 -    uintptr_t your_mon_id = conn->mon_id;
 187.240 -    struct intermon_binding *mon_binding = conn->mon_binding;
 187.241 -
 187.242 -    if (err_is_ok(msgerr)) {
 187.243 -        /* Connection accepted */
 187.244 -        conn->domain_id = domain_id;
 187.245 -        conn->domain_binding = dom_binding;
 187.246 -    } else {
 187.247 -//error:
 187.248 -        err = remote_conn_free(my_mon_id);
 187.249 -        assert(err_is_ok(err));
 187.250 -    }
 187.251 -
 187.252 -    // Identify endpoint cap
 187.253 -    struct capability capability;
 187.254 -    err = monitor_cap_identify(lmp_ep, &capability);
 187.255 -    if (err_is_fail(err)) {
 187.256 -        DEBUG_ERR(err, "monitor_cap_identify failed, ignored");
 187.257 -        return;
 187.258 -    }
 187.259 -    assert(capability.type == ObjType_EndPoint); // XXX: shouldn't assert
 187.260 -
 187.261 -    // Allocate Beehive endpoint locally
 187.262 -    int chanid;
 187.263 -    err = beehive_chan_allocate(lmp_ep, &chanid);
 187.264 -    assert(err_is_ok(err)); // XXX
 187.265 -
 187.266 -    /* destroy our copy of the endpoint, we don't need it any more */
 187.267 -    errval_t err2 = cap_destroy(lmp_ep);
 187.268 -    if (err_is_fail(err2)) {
 187.269 -        DEBUG_ERR(err, "cap_destroy failed");
 187.270 -    }
 187.271 -
 187.272 -    bind_bmp_reply_cont(mon_binding, your_mon_id, my_mon_id, msgerr, chanid,
 187.273 -                        capability.u.endpoint.epbuflen);
 187.274 -}
 187.275 -
 187.276 -/******* stack-ripped intermon_bind_bmp_request *******/
 187.277 -
 187.278 -static void bind_bmp_service_request_handler(struct monitor_binding *b,
 187.279 -                                             struct monitor_msg_queue_elem *e);
 187.280 -
 187.281 -struct bind_bmp_service_request_state {
 187.282 -    struct monitor_msg_queue_elem elem;
 187.283 -    struct monitor_bind_bmp_service_request__args args;
 187.284 -    struct intermon_binding *binding;
 187.285 -    uintptr_t your_mon_id;
 187.286 -};
 187.287 -
 187.288 -static void bind_bmp_service_request_cont(struct monitor_binding *domain_binding,
 187.289 -                                          uintptr_t service_id,
 187.290 -                                          con_id_t my_mon_id,
 187.291 -                                          struct capref bee_ep,
 187.292 -                                          uint32_t ep_len,
 187.293 -                                          struct intermon_binding *binding,
 187.294 -                                          con_id_t your_mon_id)
 187.295 -{
 187.296 -    errval_t err, err2;
 187.297 -
 187.298 -    /* Proxy the request */
 187.299 -    err = domain_binding->tx_vtbl.
 187.300 -        bind_bmp_service_request(domain_binding, NOP_CONT, service_id,
 187.301 -                                 my_mon_id, bee_ep, ep_len);
 187.302 -    if (err_is_fail(err)) {
 187.303 -        if(err_no(err) == FLOUNDER_ERR_TX_BUSY) {
 187.304 -            struct bind_bmp_service_request_state *me =
 187.305 -                malloc(sizeof(struct bind_bmp_service_request_state));
 187.306 -            struct monitor_state *ist = domain_binding->st;
 187.307 -            me->args.service_id = service_id;
 187.308 -            me->args.mon_id = my_mon_id;
 187.309 -            me->args.bee_ep = bee_ep;
 187.310 -            me->args.remote_ep_len = ep_len;
 187.311 -            me->binding = binding;
 187.312 -            me->your_mon_id = your_mon_id;
 187.313 -            me->elem.cont = bind_bmp_service_request_handler;
 187.314 -
 187.315 -            err = monitor_enqueue_send(domain_binding, &ist->queue,
 187.316 -                                       get_default_waitset(), &me->elem.queue);
 187.317 -            assert(err_is_ok(err));
 187.318 -            return;
 187.319 -        }
 187.320 -
 187.321 -        err2 = cap_destroy(bee_ep);
 187.322 -        if (err_is_fail(err2)) {
 187.323 -            DEBUG_ERR(err2, "cap_destroy failed");
 187.324 -        }
 187.325 -        err2 = remote_conn_free(my_mon_id);
 187.326 -        if (err_is_fail(err2)) {
 187.327 -            DEBUG_ERR(err2, "remote_conn_free failed");
 187.328 -        }
 187.329 -        err2 = binding->tx_vtbl.bind_bmp_reply(binding, NOP_CONT, your_mon_id, 0,
 187.330 -                                               err, 0, 0);
 187.331 -        if (err_is_fail(err2)) {
 187.332 -            DEBUG_ERR(err2, "Sending bind_bmp_reply failed");
 187.333 -        }
 187.334 -    }
 187.335 -}
 187.336 -
 187.337 -static void bind_bmp_service_request_handler(struct monitor_binding *b,
 187.338 -                                             struct monitor_msg_queue_elem *e)
 187.339 -{
 187.340 -    struct bind_bmp_service_request_state *st = (struct bind_bmp_service_request_state *)e;
 187.341 -    bind_bmp_service_request_cont(b, st->args.service_id, st->args.mon_id,
 187.342 -                                  st->args.bee_ep, st->args.remote_ep_len,
 187.343 -                                  st->binding, st->your_mon_id);
 187.344 -    free(e);
 187.345 -}
 187.346 -
 187.347 -static void intermon_bind_bmp_request(struct intermon_binding *binding,
 187.348 -                                      iref_t iref, con_id_t your_mon_id,
 187.349 -                                      uint32_t chanid, uint32_t eplen)
 187.350 -{
 187.351 -    errval_t err;
 187.352 -
 187.353 -    /* Get client's core_id from the binding */
 187.354 -    coreid_t core_id = ((struct intermon_state *)binding->st)->core_id;
 187.355 -
 187.356 -    // Construct the beehive ep cap
 187.357 -    struct capref bee_ep;
 187.358 -    err = beehive_create_cap(core_id, chanid, &bee_ep);
 187.359 -    assert(err_is_ok(err)); // XXX
 187.360 -
 187.361 -    /* Get the server's connection */
 187.362 -    struct monitor_binding *domain_binding = NULL;
 187.363 -    err = iref_get_binding(iref, &domain_binding);
 187.364 -    assert(err_is_ok(err));
 187.365 -
 187.366 -    /* Get the service id */
 187.367 -    uintptr_t service_id = 0;
 187.368 -    err = iref_get_service_id(iref, &service_id);
 187.369 -    assert(err_is_ok(err));
 187.370 -
 187.371 -    /* Create a new connection state */
 187.372 -    uintptr_t my_mon_id;
 187.373 -    struct remote_conn_state *con;
 187.374 -    err = remote_conn_alloc(&con, &my_mon_id, REMOTE_CONN_BMP);
 187.375 -    assert(err_is_ok(err));
 187.376 -
 187.377 -    // Set the monitor portion of it
 187.378 -    con->mon_id = your_mon_id;
 187.379 -    con->mon_binding = binding;
 187.380 -
 187.381 -    bind_bmp_service_request_cont(domain_binding, service_id, my_mon_id,
 187.382 -                                  bee_ep, eplen, binding, your_mon_id);
 187.383 -}
 187.384 -
 187.385 -/******* stack-ripped intermon_bind_bmp_reply *******/
 187.386 -
 187.387 -static void bind_bmp_reply_client_handler(struct monitor_binding *b,
 187.388 -                                          struct monitor_msg_queue_elem *e);
 187.389 -
 187.390 -struct bind_bmp_reply_client_state {
 187.391 -    struct monitor_msg_queue_elem elem;
 187.392 -    struct monitor_bind_bmp_reply_client__args args;
 187.393 -};
 187.394 -
 187.395 -static void bind_bmp_reply_client_cont(struct monitor_binding *domain_binding,
 187.396 -                                       uintptr_t my_mon_id, uintptr_t domain_id,
 187.397 -                                       struct capref bee_ep, uint32_t eplen,
 187.398 -                                       errval_t msgerr)
 187.399 -{
 187.400 -    errval_t err;
 187.401 -
 187.402 -    err = domain_binding->tx_vtbl.
 187.403 -        bind_bmp_reply_client(domain_binding, NOP_CONT, my_mon_id, domain_id,
 187.404 -                              bee_ep, eplen, msgerr);
 187.405 -    if (err_is_fail(err)) {
 187.406 -        if(err_no(err) == FLOUNDER_ERR_TX_BUSY) {
 187.407 -            struct bind_bmp_reply_client_state *me =
 187.408 -                malloc(sizeof(struct bind_bmp_reply_client_state));
 187.409 -            struct monitor_state *ist = domain_binding->st;
 187.410 -            me->args.mon_id = my_mon_id;
 187.411 -            me->args.conn_id = domain_id;
 187.412 -            me->args.bee_ep = bee_ep;
 187.413 -            me->args.remote_ep_len = eplen;
 187.414 -            me->args.err = msgerr;
 187.415 -            me->elem.cont = bind_bmp_reply_client_handler;
 187.416 -
 187.417 -            err = monitor_enqueue_send(domain_binding, &ist->queue,
 187.418 -                                       get_default_waitset(), &me->elem.queue);
 187.419 -            assert(err_is_ok(err));
 187.420 -            return;
 187.421 -        }
 187.422 -
 187.423 -        DEBUG_ERR(err, "BMP bind reply failed");
 187.424 -        // cleanup
 187.425 -        err = remote_conn_free(my_mon_id);
 187.426 -        assert(err_is_ok(err));
 187.427 -    }
 187.428 -}
 187.429 -
 187.430 -static void bind_bmp_reply_client_handler(struct monitor_binding *b,
 187.431 -                                             struct monitor_msg_queue_elem *e)
 187.432 -{
 187.433 -    struct bind_bmp_reply_client_state *st = (struct bind_bmp_reply_client_state *)e;
 187.434 -    bind_bmp_reply_client_cont(b, st->args.mon_id, st->args.conn_id,
 187.435 -                               st->args.bee_ep, st->args.remote_ep_len,
 187.436 -                               st->args.err);
 187.437 -    free(e);
 187.438 -}
 187.439 -
 187.440 -static void intermon_bind_bmp_reply(struct intermon_binding *binding, 
 187.441 -                                    con_id_t my_mon_id, con_id_t your_mon_id,
 187.442 -                                    errval_t msgerr, uint32_t chanid,
 187.443 -                                    uint32_t eplen)
 187.444 -{
 187.445 -    errval_t err;
 187.446 -    struct remote_conn_state *con = remote_conn_lookup(my_mon_id);
 187.447 -    if (con == NULL) {
 187.448 -        DEBUG_ERR(0, "unknown mon_id in BMP bind reply");
 187.449 -        return;
 187.450 -    }
 187.451 -
 187.452 -    uintptr_t domain_id = con->domain_id;
 187.453 -    struct monitor_binding *domain_binding = con->domain_binding;
 187.454 -    struct capref bee_ep = NULL_CAP;
 187.455 -
 187.456 -    if (err_is_ok(msgerr)) { /* bind succeeded */
 187.457 -        con->mon_id = your_mon_id;
 187.458 -        con->mon_binding = binding;
 187.459 -
 187.460 -        // Get core id of sender
 187.461 -        coreid_t core_id = ((struct intermon_state *)binding->st)->core_id;
 187.462 -
 187.463 -        // Construct the beehive ep cap
 187.464 -        err = beehive_create_cap(core_id, chanid, &bee_ep);
 187.465 -        assert(err_is_ok(err)); // XXX
 187.466 -    } else { /* bind refused */
 187.467 -        err = remote_conn_free(my_mon_id);
 187.468 -        assert(err_is_ok(err));
 187.469 -    }
 187.470 -
 187.471 -    bind_bmp_reply_client_cont(domain_binding, my_mon_id, domain_id, bee_ep,
 187.472 -                               eplen, msgerr);
 187.473 -}
 187.474 -
 187.475 -errval_t bmp_intermon_init(struct intermon_binding *ib)
 187.476 -{
 187.477 -    ib->rx_vtbl.bind_bmp_request = intermon_bind_bmp_request;
 187.478 -    ib->rx_vtbl.bind_bmp_reply = intermon_bind_bmp_reply;
 187.479 -    return SYS_ERR_OK;
 187.480 -}
 187.481 -
 187.482 -errval_t bmp_monitor_init(struct monitor_binding *mb)
 187.483 -{
 187.484 -    mb->rx_vtbl.bind_bmp_client_request = monitor_bind_bmp_client_request;
 187.485 -    mb->rx_vtbl.bind_bmp_reply_monitor = monitor_bind_bmp_reply;
 187.486 -    return SYS_ERR_OK;
 187.487 -}
   188.1 --- a/usr/monitor/connection.h	Fri Jan 20 14:32:03 2012 -0800
   188.2 +++ b/usr/monitor/connection.h	Mon Jan 23 11:04:15 2012 -0800
   188.3 @@ -55,14 +55,11 @@
   188.4      coreid_t core_id;                       // core id of other side of channel
   188.5      
   188.6      // type-specific data
   188.7 -    enum remote_conn_type { REMOTE_CONN_UMP, REMOTE_CONN_BMP } type;
   188.8 +    enum remote_conn_type { REMOTE_CONN_UMP } type;
   188.9      union {
  188.10          struct {
  188.11              struct capref frame; // shared frame
  188.12          } ump;
  188.13 -        struct {
  188.14 -            /* nothing needed? */
  188.15 -        } bmp;
  188.16      } x;
  188.17  };
  188.18  
   189.1 --- a/usr/monitor/include/arch/beehive/monitor_invocations.h	Fri Jan 20 14:32:03 2012 -0800
   189.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
   189.3 @@ -1,286 +0,0 @@
   189.4 -/**
   189.5 - * \file
   189.6 - * \brief Capability invocations specific to the monitors
   189.7 - */
   189.8 -
   189.9 -/*
  189.10 - * Copyright (c) 2007 - 2011, ETH Zurich.
  189.11 - * All rights reserved.
  189.12 - *
  189.13 - * This file is distributed under the terms in the attached LICENSE file.
  189.14 - * If you do not find this file, copies can be found by writing to:
  189.15 - * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
  189.16 - */
  189.17 -
  189.18 -#ifndef ARCH_BEEHICE_MONITOR_INVOCATIONS_H
  189.19 -#define ARCH_BEEHIVE_MONITOR_INVOCATIONS_H
  189.20 -
  189.21 -#include <barrelfish/syscall_arch.h> // for cap_invoke
  189.22 -#include <barrelfish/caddr.h>
  189.23 -
  189.24 -/**
  189.25 - * \brief Spawn a new core.
  189.26 - *
  189.27 - * \param cur_kern   Cap of the current kernel
  189.28 - * \param core_id    APIC ID of the core to try booting
  189.29 - * \param sp_mem     Cap to Ram type memory to relocate the new kernel
  189.30 - * \param dcb        Cap to the dcb of the user program to run on the new kernel
  189.31 - * \param root_vbits Number of valid bits in root_cptr
  189.32 - * \param root_cptr  Cap to the root of cspace of the new user program
  189.33 - * \param vtree      Cap to the vtree root of the new user program
  189.34 - * \param dispatcher Cap to the dispatcher of the new user program
  189.35 - * \param entry      Kernel entry point in physical memory
  189.36 - */
  189.37 -static inline errval_t
  189.38 -invoke_monitor_spawn_core(coreid_t core_id, enum cpu_type cpu_type,
  189.39 -                          forvaddr_t entry)
  189.40 -{
  189.41 -    struct idc_send_msg msg;
  189.42 -
  189.43 -    idc_msg_init(&msg);
  189.44 -    idc_msg_encode_word(&msg, KernelCmd_Spawn_core);
  189.45 -    idc_msg_encode_word(&msg, core_id);
  189.46 -    idc_msg_encode_word(&msg, cpu_type);
  189.47 -    idc_msg_encode_word(&msg, entry);
  189.48 -
  189.49 -    return cap_invoke(cap_kernel, &msg).error;
  189.50 -}
  189.51 -
  189.52 -static inline errval_t
  189.53 -invoke_monitor_identify_cap(caddr_t cap, int bits, struct capability *out)
  189.54 -{
  189.55 -    struct idc_send_msg msg;
  189.56 -
  189.57 -    idc_msg_init(&msg);
  189.58 -    idc_msg_encode_word(&msg, KernelCmd_Identify_cap);
  189.59 -    idc_msg_encode_word(&msg, cap);
  189.60 -    idc_msg_encode_word(&msg, bits);
  189.61 -    idc_msg_encode_word(&msg, (uintptr_t)out);
  189.62 -
  189.63 -    return cap_invoke(cap_kernel, &msg).error;
  189.64 -}
  189.65 -
  189.66 -static inline errval_t
  189.67 -invoke_monitor_nullify_cap(caddr_t cap, int bits)
  189.68 -{
  189.69 -    struct idc_send_msg msg;
  189.70 -
  189.71 -    idc_msg_init(&msg);
  189.72 -    idc_msg_encode_word(&msg, KernelCmd_Nullify_cap);
  189.73 -    idc_msg_encode_word(&msg, cap);
  189.74 -    idc_msg_encode_word(&msg, bits);
  189.75 -
  189.76 -    return cap_invoke(cap_kernel, &msg).error;
  189.77 -}
  189.78 -
  189.79 -static inline errval_t
  189.80 -invoke_monitor_create_cap(uint64_t *raw, caddr_t caddr, int bits, caddr_t slot)
  189.81 -{
  189.82 -    struct idc_send_msg msg;
  189.83 -
  189.84 -    idc_msg_init(&msg);
  189.85 -    idc_msg_encode_word(&msg, KernelCmd_Create_cap);
  189.86 -    idc_msg_encode_word(&msg, (uintptr_t)raw);
  189.87 -    idc_msg_encode_word(&msg, caddr);
  189.88 -    idc_msg_encode_word(&msg, bits);
  189.89 -    idc_msg_encode_word(&msg, slot);
  189.90 -
  189.91 -    return cap_invoke(cap_kernel, &msg).error;
  189.92 -}
  189.93 -
  189.94 -static inline errval_t
  189.95 -invoke_monitor_cap_remote(caddr_t cap, int bits, bool is_remote, 
  189.96 -                          bool * has_descendents)
  189.97 -{
  189.98 -    struct idc_send_msg msg;
  189.99 -
 189.100 -    idc_msg_init(&msg);
 189.101 -    idc_msg_encode_word(&msg, KernelCmd_Remote_cap);
 189.102 -    idc_msg_encode_word(&msg, cap);
 189.103 -    idc_msg_encode_word(&msg, bits);
 189.104 -    idc_msg_encode_word(&msg, is_remote);
 189.105 -    idc_msg_encode_word(&msg, (uintptr_t)has_descendents);
 189.106 -    
 189.107 -    return cap_invoke(cap_kernel, &msg).error;
 189.108 -}
 189.109 -
 189.110 -static inline errval_t
 189.111 -invoke_monitor_register(struct capref ep)
 189.112 -{
 189.113 -    struct idc_send_msg msg;
 189.114 -
 189.115 -    idc_msg_init(&msg);
 189.116 -    idc_msg_encode_word(&msg, KernelCmd_Register);
 189.117 -    idc_msg_encode_word(&msg, get_cap_addr(ep));
 189.118 -
 189.119 -    return cap_invoke(cap_kernel, &msg).error;
 189.120 -}
 189.121 -
 189.122 -static inline errval_t
 189.123 -invoke_monitor_identify_cnode_get_cap(uint64_t *cnode_raw, caddr_t slot,
 189.124 -                                      struct capability *out)
 189.125 -{
 189.126 -    USER_PANIC("NYI");
 189.127 -    assert(cnode_raw != NULL);
 189.128 -    assert(out != NULL);
 189.129 -    return LIB_ERR_NOT_IMPLEMENTED;
 189.130 -
 189.131 -#if 0
 189.132 -    struct idc_send_msg msg;
 189.133 -    idc_msg_init(&msg);
 189.134 -    idc_msg_encode_word(&msg, KernelCmd_Iden_cnode_get_cap);
 189.135 -    for (int i = 0; i < sizeof(struct capability) / sizeof(uint64_t); i++) {
 189.136 -        idc_msg_encode_word(&msg, cnode_raw[i]);
 189.137 -    }
 189.138 -    idc_msg_encode_word(&msg, slot);
 189.139 -    idc_msg_encode_word(&msg, (uintptr_t)out);
 189.140 -
 189.141 -    return cap_invoke(cap_kernel, &msg);
 189.142 -#endif
 189.143 -}
 189.144 -
 189.145 -/**
 189.146 - * \brief Set up tracing in the kernel
 189.147 - *
 189.148 - */
 189.149 -static inline errval_t
 189.150 -invoke_trace_setup(struct capref cap)
 189.151 -{
 189.152 -    struct idc_send_msg msg;
 189.153 -    idc_msg_init(&msg);
 189.154 -    idc_msg_encode_word(&msg, KernelCmd_Setup_trace);
 189.155 -    idc_msg_encode_word(&msg, get_cap_addr(cap));
 189.156 -    return cap_invoke(cap_kernel, &msg).error;
 189.157 -}
 189.158 -
 189.159 -static inline errval_t
 189.160 -invoke_domain_id(struct capref cap, uint64_t domain_id)
 189.161 -{
 189.162 -    USER_PANIC("NYI");
 189.163 -    return LIB_ERR_NOT_IMPLEMENTED;
 189.164 -#if 0
 189.165 -    struct idc_send_msg msg;
 189.166 -    idc_msg_init(&msg);
 189.167 -    idc_msg_encode_word(&msg, KernelCmd_Domain_Id);
 189.168 -    idc_msg_encode_word(&msg, get_cap_addr(cap));
 189.169 -    idc_msg_encode_word(&msg, domain_id);
 189.170 -    return cap_invoke(cap_kernel, &msg);
 189.171 -#endif
 189.172 -}
 189.173 -static inline errval_t 
 189.174 -invoke_monitor_identify_domains_cap(caddr_t root_cap, int root_bits,
 189.175 -                                    caddr_t cap, int bits,
 189.176 -                                    struct capability *out)
 189.177 -{
 189.178 -    struct idc_send_msg msg;
 189.179 -
 189.180 -    idc_msg_init(&msg);
 189.181 -    idc_msg_encode_word(&msg, KernelCmd_Identify_domains_cap);
 189.182 -    idc_msg_encode_word(&msg, root_cap);
 189.183 -    idc_msg_encode_word(&msg, root_bits);
 189.184 -    idc_msg_encode_word(&msg, cap);
 189.185 -    idc_msg_encode_word(&msg, bits);
 189.186 -    idc_msg_encode_word(&msg, (uintptr_t)out);
 189.187 -
 189.188 -    return cap_invoke(cap_kernel, &msg).error;
 189.189 -}
 189.190 -
 189.191 -static inline errval_t
 189.192 -invoke_monitor_remote_cap_retype(caddr_t rootcap_addr, uint8_t rootcap_vbits,
 189.193 -                                 caddr_t src, enum objtype newtype,
 189.194 -                                 int objbits, caddr_t to, caddr_t slot,
 189.195 -                                 int bits)
 189.196 -{
 189.197 -    struct idc_send_msg msg;
 189.198 -
 189.199 -    idc_msg_init(&msg);
 189.200 -    idc_msg_encode_word(&msg, MonitorCmd_Retype);
 189.201 -    idc_msg_encode_word(&msg, rootcap_addr);
 189.202 -    idc_msg_encode_word(&msg, rootcap_vbits);
 189.203 -    idc_msg_encode_word(&msg, src);
 189.204 -    idc_msg_encode_word(&msg, newtype);
 189.205 -    idc_msg_encode_word(&msg, objbits);
 189.206 -    idc_msg_encode_word(&msg, to);
 189.207 -    idc_msg_encode_word(&msg, slot);
 189.208 -    idc_msg_encode_word(&msg, bits);
 189.209 -
 189.210 -    return cap_invoke(cap_kernel, &msg).error;
 189.211 -}
 189.212 -
 189.213 -
 189.214 -
 189.215 -static inline errval_t
 189.216 -invoke_monitor_remote_cap_delete(caddr_t rootcap_addr, uint8_t rootcap_vbits,
 189.217 -                                 caddr_t src, int bits) 
 189.218 -{
 189.219 -    struct idc_send_msg msg;
 189.220 -    
 189.221 -    idc_msg_init(&msg);
 189.222 -    idc_msg_encode_word(&msg, MonitorCmd_Delete);
 189.223 -    idc_msg_encode_word(&msg, rootcap_addr);
 189.224 -    idc_msg_encode_word(&msg, rootcap_vbits);
 189.225 -    idc_msg_encode_word(&msg, src);
 189.226 -    idc_msg_encode_word(&msg, bits);
 189.227 -
 189.228 -    return cap_invoke(cap_kernel, &msg).error;
 189.229 -}
 189.230 -
 189.231 -static inline errval_t
 189.232 -invoke_monitor_remote_cap_revoke(caddr_t rootcap_addr, uint8_t rootcap_vbits,
 189.233 -                                 caddr_t src, int bits) 
 189.234 -{
 189.235 -    struct idc_send_msg msg;
 189.236 -
 189.237 -    idc_msg_init(&msg);
 189.238 -    idc_msg_encode_word(&msg, MonitorCmd_Revoke);
 189.239 -    idc_msg_encode_word(&msg, rootcap_addr);
 189.240 -    idc_msg_encode_word(&msg, rootcap_vbits);
 189.241 -    idc_msg_encode_word(&msg, src);
 189.242 -    idc_msg_encode_word(&msg, bits);
 189.243 -
 189.244 -    return cap_invoke(cap_kernel, &msg).error;
 189.245 -}
 189.246 -
 189.247 -static inline errval_t invoke_monitor_bmptable_set(
 189.248 -    struct capref bmpcap, unsigned int associd, struct capref ep)
 189.249 -{
 189.250 -    struct idc_send_msg msg;
 189.251 -
 189.252 -    idc_msg_init(&msg);
 189.253 -    idc_msg_encode_word(&msg, BMPTableCmd_Set);
 189.254 -    idc_msg_encode_word(&msg, associd);
 189.255 -    idc_msg_encode_word(&msg, get_cap_addr(ep));
 189.256 -	
 189.257 -    return cap_invoke(bmpcap, &msg).error;
 189.258 -}
 189.259 -
 189.260 -static inline errval_t invoke_monitor_bmptable_delete(
 189.261 -    struct capref bmpcap, unsigned int associd)
 189.262 -{
 189.263 -    struct idc_send_msg msg;
 189.264 -
 189.265 -    idc_msg_init(&msg);
 189.266 -    idc_msg_encode_word(&msg, BMPTableCmd_Delete);
 189.267 -    idc_msg_encode_word(&msg, associd);
 189.268 -    
 189.269 -    return cap_invoke(bmpcap, &msg).error;
 189.270 -}
 189.271 -
 189.272 -static inline errval_t invoke_monitor_sync_timer(uint64_t synctime)
 189.273 -{
 189.274 -    return ERR_NOTIMP;
 189.275 -}
 189.276 -
 189.277 -static inline errval_t
 189.278 -invoke_monitor_get_arch_id(uintptr_t *arch_id)
 189.279 -{
 189.280 -    // core id == arch id on Beehive
 189.281 -    coreid_t coreid;
 189.282 -    errval_t err = invoke_kernel_get_core_id(cap_kernel, &coreid);
 189.283 -    if(err_is_ok(err)) {
 189.284 -        *arch_id = coreid;
 189.285 -    }
 189.286 -    return err;
 189.287 -}
 189.288 -
 189.289 -#endif // ARCH_BEEHIVE_MONITOR_INVOCATIONS_H
   190.1 --- a/usr/monitor/inter.c	Fri Jan 20 14:32:03 2012 -0800
   190.2 +++ b/usr/monitor/inter.c	Mon Jan 23 11:04:15 2012 -0800
   190.3 @@ -720,14 +720,6 @@
   190.4      }
   190.5  #endif
   190.6  
   190.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   190.8 -    err = bmp_intermon_init(b);
   190.9 -    if (err_is_fail(err)) {
  190.10 -        USER_PANIC_ERR(err, "bmp_intermon_init failed");
  190.11 -        return err;
  190.12 -    }
  190.13 -#endif
  190.14 -
  190.15  #ifdef CONFIG_INTERCONNECT_DRIVER_MULTIHOP
  190.16      err = multihop_intermon_init(b);
  190.17      if (err_is_fail(err)) {
   191.1 --- a/usr/monitor/main.c	Fri Jan 20 14:32:03 2012 -0800
   191.2 +++ b/usr/monitor/main.c	Mon Jan 23 11:04:15 2012 -0800
   191.3 @@ -17,11 +17,6 @@
   191.4  #include <barrelfish/dispatch.h>
   191.5  #include <trace/trace.h>
   191.6  
   191.7 -#ifdef __BEEHIVE__
   191.8 -// Flag this as an initialisation domain for systems without ELF entry
   191.9 -bool __barrelfish_initialisation_domain = 1;
  191.10 -#endif
  191.11 -
  191.12  /* irefs for mem server and name service */
  191.13  iref_t mem_serv_iref = 0;
  191.14  iref_t name_serv_iref = 0;
   192.1 --- a/usr/monitor/monitor.h	Fri Jan 20 14:32:03 2012 -0800
   192.2 +++ b/usr/monitor/monitor.h	Mon Jan 23 11:04:15 2012 -0800
   192.3 @@ -200,10 +200,6 @@
   192.4  errval_t ump_intermon_init(struct intermon_binding *ib);
   192.5  errval_t ump_monitor_init(struct monitor_binding *mb);
   192.6  
   192.7 -/* bmp_support.c */
   192.8 -errval_t bmp_intermon_init(struct intermon_binding *ib);
   192.9 -errval_t bmp_monitor_init(struct monitor_binding *mb);
  192.10 -
  192.11  /* multihop_support.c */
  192.12  errval_t multihop_intermon_init(struct intermon_binding *ib);
  192.13  errval_t multihop_monitor_init(struct monitor_binding *mb);
   193.1 --- a/usr/monitor/monitor_server.c	Fri Jan 20 14:32:03 2012 -0800
   193.2 +++ b/usr/monitor/monitor_server.c	Mon Jan 23 11:04:15 2012 -0800
   193.3 @@ -1060,14 +1060,6 @@
   193.4      }
   193.5  #endif
   193.6  
   193.7 -#ifdef CONFIG_INTERCONNECT_DRIVER_BMP
   193.8 -    errval_t err;
   193.9 -    err = bmp_monitor_init(b);
  193.10 -    if (err_is_fail(err)) {
  193.11 -        USER_PANIC_ERR(err, "bmp_monitor_init failed");
  193.12 -    }
  193.13 -#endif
  193.14 -
  193.15  #ifdef CONFIG_INTERCONNECT_DRIVER_MULTIHOP
  193.16      errval_t err2;
  193.17      err2 = multihop_monitor_init(b);
   194.1 --- a/usr/monitor/rcap_db_common.c	Fri Jan 20 14:32:03 2012 -0800
   194.2 +++ b/usr/monitor/rcap_db_common.c	Mon Jan 23 11:04:15 2012 -0800
   194.3 @@ -21,10 +21,6 @@
   194.4  
   194.5  uint64_t hash_cap(struct capability * cap)
   194.6  {
   194.7 -#ifdef __BEEHIVE__
   194.8 -    // XXX Avoid compiler error
   194.9 -    return 0;
  194.10 -#else
  194.11      // Based upon MurmurHash
  194.12      uint64_t hash = 3 ^ (sizeof(struct capability) * HASH_M);
  194.13  
  194.14 @@ -60,5 +56,4 @@
  194.15      hash ^= hash >> HASH_R;
  194.16  
  194.17      return hash;
  194.18 -#endif // BEEHIVE
  194.19  }
   195.1 --- a/usr/monitor/spawn.c	Fri Jan 20 14:32:03 2012 -0800
   195.2 +++ b/usr/monitor/spawn.c	Mon Jan 23 11:04:15 2012 -0800
   195.3 @@ -332,16 +332,10 @@
   195.4      // map the image in
   195.5      // XXX: leak memobj/region
   195.6      void *image;
   195.7 -#ifdef __BEEHIVE__
   195.8 -    // FIXME: why does the map fail below for beehive? -AB
   195.9 -    // it thinks the cap I just magiced up doesn't exist
  195.10 -    image = (void *)(lvaddr_t)spawnd_image.base;
  195.11 -#else
  195.12      err = vspace_map_one_frame(&image, spawnd_image.bytes, frame, NULL, NULL);
  195.13      if (err_is_fail(err)) {
  195.14          return err_push(err, LIB_ERR_VSPACE_MAP);
  195.15      }
  195.16 -#endif
  195.17  
  195.18      // spawn!
  195.19      char *argv[] = { "spawnd", NULL };
   196.1 --- a/usr/ramfsd/main.c	Fri Jan 20 14:32:03 2012 -0800
   196.2 +++ b/usr/ramfsd/main.c	Mon Jan 23 11:04:15 2012 -0800
   196.3 @@ -25,10 +25,6 @@
   196.4  #include "ramfs.h"
   196.5  #include <cpiobin.h>
   196.6  
   196.7 -#ifdef __BEEHIVE__
   196.8 -#include <bexec.h>
   196.9 -#endif
  196.10 -
  196.11  #define BOOTSCRIPT_FILE_NAME "bootmodules"
  196.12  
  196.13  static errval_t write_directory(struct dirent *root, const char *path);
  196.14 @@ -342,20 +338,6 @@
  196.15  static errval_t getimage(struct mem_region *region, size_t *retlen,
  196.16                           lvaddr_t *retdata)
  196.17  {
  196.18 -#ifdef __BEEHIVE__
  196.19 -    // construct a dummy "image" for Beehive that is just a pointer to the module
  196.20 -    static struct bimgref_file imgheader = {
  196.21 -        .magic = BIMGREF_MAGIC,
  196.22 -        .region = NULL
  196.23 -    };
  196.24 -    imgheader.region = region;
  196.25 -
  196.26 -    // XXX: return pointer to static buffer
  196.27 -    // assuming caller will copy it into RAMFS before calling us next
  196.28 -    *retlen = sizeof(imgheader);
  196.29 -    *retdata = (lvaddr_t)&imgheader;
  196.30 -    return SYS_ERR_OK;
  196.31 -#else // not beehive
  196.32      // map in the real module (FIXME: leaking it afterwards)
  196.33      size_t len;
  196.34      errval_t err = spawn_map_module(region, &len, retdata, NULL);
  196.35 @@ -364,7 +346,6 @@
  196.36          *retlen = region->mrmod_size;
  196.37      }
  196.38      return err;
  196.39 -#endif // __BEEHIVE__
  196.40  }
  196.41  
  196.42  static void populate_multiboot(struct dirent *root, struct bootinfo *bi)
   197.1 --- a/usr/spawnd/bsp_bootup.c	Fri Jan 20 14:32:03 2012 -0800
   197.2 +++ b/usr/spawnd/bsp_bootup.c	Mon Jan 23 11:04:15 2012 -0800
   197.3 @@ -236,10 +236,7 @@
   197.4              p++;
   197.5          }
   197.6          for(int i = id_from; i <= id_to; i++) {
   197.7 -            if (CURRENT_CPU_TYPE == CPU_BEEHIVE) {
   197.8 -                coreid_mappings[i].arch_id = i;
   197.9 -                coreid_mappings[i].present = true;
  197.10 -            } else if (i != my_arch_id) {
  197.11 +            if (i != my_arch_id) {
  197.12                  assert(next <= MAX_COREID);
  197.13                  coreid_mappings[next].arch_id = i;
  197.14                  coreid_mappings[next].present = true;
  197.15 @@ -273,8 +270,6 @@
  197.16              cmdline_mappings = argv[i];
  197.17          } else if(!strncmp(argv[i],"bootscc=",strlen("bootscc="))) {
  197.18              cmdline_mappings = argv[i];
  197.19 -        } else if(!strncmp(argv[i],"bootbees=",strlen("bootbees="))) {
  197.20 -            cmdline_mappings = argv[i];
  197.21          } else if(!strcmp(argv[i],"bootarm")) {
  197.22              cmdline_mappings = argv[i];
  197.23          } else if (strncmp(argv[i], "coreid_offset=", sizeof("coreid_offset")) == 0) {