ARMv8: adding functions to access the cnthctl_el3 register
authorReto Achermann <reto.achermann@inf.ethz.ch>
Wed, 22 Feb 2017 15:24:44 +0000 (16:24 +0100)
committerReto Achermann <reto.achermann@inf.ethz.ch>
Wed, 22 Feb 2017 15:24:44 +0000 (16:24 +0100)
Signed-off-by: Reto Achermann <reto.achermann@inf.ethz.ch>

hake/symbolic_targets.mk
kernel/include/arch/armv8/sysreg.h

index d793940..2ecdb30 100644 (file)
@@ -1,5 +1,5 @@
 ##########################################################################
-# Copyright (c) 2009-2015 ETH Zurich.
+# Copyright (c) 2009-2014 ETH Zurich.
 # All rights reserved.
 #
 # This file is distributed under the terms in the attached LICENSE file.
 #
 ##########################################################################
 
+# Disable built-in implicit rules. GNU make adds environment's MAKEFLAGS too.
+MAKEFLAGS=r
+
+# Explicitly disable the flex and bison implicit rules
+%.c : %.y
+
+%.c : %.l
+
 # Set default architecture to the first specified by Hake in generated Makefile.
 ARCH ?= $(word 1, $(HAKE_ARCHS))
+ARM_GCC?=arm-linux-gnueabi-gcc
+ARM_OBJCOPY?=arm-linux-gnueabi-objcopy
+K1OM_OBJCOPY?=k1om-mpss-linux-objcopy
+
+# upload Xeon Phi images to nfs share (leave blank to cancel)
+BARRELFISH_NFS_DIR ?="emmentaler.ethz.ch:/mnt/local/nfs/barrelfish/xeon_phi"
+
+#################################################################################
+# Additional submodule targets
+#################################################################################
+$(info Additional submodules:)
+
+# Shoal submodule
+ifneq ("$(wildcard $(SRCDIR)/lib/shoal/Hakefile)","")
+    $(info + shoal:      [YES])
+    SUBMODULE_SHOAL=1
+    SHOAL= \
+       sbin/tests/shl_simple
+else
+    $(info + shoal:      [NO])
+       SUBMODULE_SHOAL=0
+       SHOAL=
+endif
+
+# Green Marl Submodule
+ifneq ("$(wildcard $(SRCDIR)/usr/green-marl/Hakefile)","")
+    $(info + green-marl: [YES])
+       SUBMODULE_GREEN_MARL=1
+else
+    $(info + green-marl: [NO])
+       SUBMODULE_GREEN_MARL=
+endif
+
+# green-marl depends on presence of shoal
+ifneq "$(and $(SUBMODULE_GREEN_MARL),$(SUBMODULE_SHOAL))" ""
+    $(info + green-marl: [ENABLED])
+       GREEN_MARL= \
+               sbin/gm_tc \
+               sbin/gm_pr
+else
+    $(info + green-marl: [DISABLED])
+       GREEN_MARL=
+endif
+
 
-# Generic help text: this is the default target.
-.PHONY: help
-help:: 
-       @echo "------------------------------------------------------------------"
-       @echo "This is the 'help' target for the Barrelfish Makefile.  This Makefile"
-       @echo "has been generated by hake in the top-level directory of your build tree."
-       @echo "See the Hake documentation for more information."
-       @echo ""
-       @echo "This Makefile contains build targets for the following architectures:"
-       @echo ""                
-       @echo "$(HAKE_ARCHS)"
-       @echo ""        
-       @echo "To change configuration options, edit the Config.hs file in the hake"
-       @echo "subdirectory of this directory and run 'make rehake'."
-       @echo ""
-       @echo "To change the set of symbolic make targets available (for example, to"
-       @echo "build a different set of modules or architectures for your boot image),"
-       @echo "edit the local copy of the symbolic_targets.mk in this directory."
-       @echo ""        
-       @echo "Useful make targets:"
-       @echo " - <file>:           any file which can be built in the Barrelfish tree" 
-       @echo " - 'help':           show this help text"
-       @echo " - 'help-platforms': show the platforms (file collections) which can be built"
-       @echo " - 'help-boot':      show the boot sequences which can be initiated"
-       @echo " - 'clean':          remove most generated files" 
-       @echo " - 'realclean':      remove all generated files (clears the build tree)"
-       @echo " - 'rehake':         attempt to re-run hake"
-       @echo ""
-
-# Print the list of defined platforms.  Most of these will be
-# generated by Hake; this is just the preamble:
-.PHONY: help-platforms
-help-platforms:: 
-       @echo "------------------------------------------------------------------"
-       @echo "Platforms supported by this Makefile.  Use 'make <platform name>':"
-       @echo " (these are the platforms available with your architecture choices)"
-       @echo ""
-
-# Print the list of defined boots.  Most of these will be
-# generated by Hake; this is just the preamble:
-.PHONY: help-boot
-help-boot:: 
-       @echo "------------------------------------------------------------------"
-       @echo "Boot instructions supported by this Makefile.  Use 'make <boot name>':"
-       @echo " (these are the targets available with your architecture choices)"
-       @echo ""
 
 # All binaries of the RCCE LU benchmark
 BIN_RCCE_LU= \
@@ -83,6 +89,9 @@ BIN_RCCE_BT= \
 
 # All test domains
 TESTS_COMMON= \
+       sbin/fputest \
+       sbin/fread_test \
+       sbin/fscanf_test \
        sbin/hellotest \
        sbin/idctest \
        sbin/memtest \
@@ -105,10 +114,6 @@ TESTS_x86_64= \
        sbin/bomp_test \
        sbin/bulk_shm \
        sbin/cryptotest \
-       sbin/fputest \
-       sbin/fread_test \
-       sbin/fscanf_test \
-       sbin/lrpc_fpu \
        sbin/mdbtest_addr_zero \
        sbin/mdbtest_range_query \
        sbin/mem_affinity \
@@ -142,6 +147,7 @@ TESTS_k1om= \
        sbin/tests/xeon_phi_test \
        sbin/tests/xphi_nameservice_test
 
+
 # All benchmark domains
 BENCH_COMMON= \
        sbin/channel_cost_bench \
@@ -205,11 +211,13 @@ BENCH_k1om=\
        sbin/benchmarks/xomp_spawn \
        sbin/benchmarks/xomp_work \
        sbin/benchmarks/xphi_ump_bench \
-       sbin/benchmarks/xphi_xump_bench 
+       sbin/benchmarks/xphi_xump_bench
+
 
 # Default list of modules to build/install for all enabled architectures
 MODULES_COMMON= \
        sbin/init \
+       sbin/chips \
        sbin/skb \
        sbin/spawnd \
        sbin/startd \
@@ -219,7 +227,6 @@ MODULES_COMMON= \
 
 # List of modules that are arch-independent and always built
 MODULES_GENERIC= \
-       eclipseclp_ramfs.cpio.gz \
        skb_ramfs.cpio.gz \
        sshd_ramfs.cpio.gz
 
@@ -237,10 +244,8 @@ MODULES_x86_64= \
        sbin/e1000n \
        sbin/NGD_mng \
        sbin/e10k \
-    sbin/sfn5122f \
        sbin/sfxge \
        sbin/e10k_queue \
-    sbin/sfn5122f_queue \
        sbin/rtl8029 \
        sbin/netd \
        sbin/echoserver \
@@ -254,14 +259,14 @@ MODULES_x86_64= \
        sbin/pci \
        sbin/acpi \
        sbin/kaluga \
-       sbin/serial_kernel \
+       sbin/serial \
        sbin/angler \
        sbin/sshd \
        sbin/lshw \
+       sbin/sif \
        sbin/slideshow \
        sbin/vbe \
        sbin/vmkitmon \
-       sbin/vnode_map_test \
        sbin/webserver \
        sbin/routing_setup \
        sbin/bcached \
@@ -275,16 +280,18 @@ MODULES_x86_64= \
        sbin/block_server_client \
        sbin/bs_user \
        sbin/bulk_shm \
-       sbin/corectrl \
-       sbin/megaraid \
-       lib/libmegaraid.a 
+       $(GREEN_MARL) \
+       $(SHOAL) \
+       sbin/corectrl
 
 MODULES_k1om= \
        sbin/weever \
        sbin/cpu \
        sbin/xeon_phi \
        sbin/corectrl \
-       xeon_phi_multiboot
+       xeon_phi_multiboot \
+       $(GREEN_MARL) \
+       $(SHOAL)
 
 # the following are broken in the newidc system
 MODULES_x86_64_broken= \
@@ -323,6 +330,37 @@ MODULES_x86_32=\
        sbin/sshd \
        sbin/corectrl
 
+# SCC-specific module to build by default
+MODULES_scc=\
+       sbin/cpu \
+       $(BIN_RCCE_BT) \
+       $(BIN_RCCE_LU) \
+       sbin/rcce_pingpong \
+       sbin/bench \
+       sbin/eMAC \
+       sbin/netd \
+       sbin/NGD_mng \
+       sbin/webserver \
+       sbin/ipirc_test \
+       sbin/thc_v_flounder_empty \
+       sbin/thcidctest \
+       sbin/thcminitest \
+       sbin/thctest \
+       sbin/mem_serv_dist \
+       sbin/net-test \
+       sbin/netthroughput \
+       sbin/udp_throughput
+
+# ARM-specific modules to build by default
+MODULES_armv5=\
+       sbin/cpu \
+       sbin/cpu.bin
+
+# XScale-specific modules to build by default
+MODULES_xscale=\
+       sbin/cpu_ixp2800 \
+       sbin/cpu_ixp2800.bin
+
 # ARMv7-specific modules to build by default
 # XXX: figure out armv7 default
 MODULES_armv7=\
@@ -333,6 +371,11 @@ MODULES_armv7=\
        sbin/fish \
        sbin/corectrl
 
+# ARM11MP-specific modules to build by default
+MODULES_arm11mp=\
+       sbin/cpu \
+       sbin/cpu.bin
+
 # construct list of all modules to be built (arch-specific and common for each arch)
 MODULES=$(foreach a,$(HAKE_ARCHS),$(foreach m,$(MODULES_$(a)),$(a)/$(m)) \
                                   $(foreach m,$(MODULES_COMMON),$(a)/$(m))) \
@@ -342,29 +385,41 @@ MODULES=$(foreach a,$(HAKE_ARCHS),$(foreach m,$(MODULES_$(a)),$(a)/$(m)) \
                                   $(foreach m,$(BENCH_COMMON),$(a)/$(m))) \
         $(MODULES_GENERIC)
 
+all: $(MODULES) menu.lst
+       @echo "You've just run the default ("all") target for Barrelfish"
+       @echo "using Hake.  The following modules have been built:"
+       @echo $(MODULES)
+       @echo "If you want to change this target, edit the file called"
+       @echo "'symbolic_targets.mk' in your build directory."
+.PHONY: all
+
 # XXX: this should be overridden in some local settings file?
 INSTALL_PREFIX ?= /home/netos/tftpboot/$(USER)
 
-# upload Xeon Phi images to nfs share (leave blank to cancel)
-BARRELFISH_NFS_DIR ?="emmentaler.ethz.ch:/mnt/local/nfs/barrelfish/xeon_phi"
-
-# Only install a binary if it doesn't exist in INSTALL_PREFIX or the
-# modification timestamp differs.
-
+# Only install a binary if it doesn't exist in INSTALL_PREFIX or the modification timestamp differs
 install: $(MODULES)
        @echo ""; \
        echo "Installing modules..." ; \
        for m in ${MODULES}; do \
          if [ ! -f ${INSTALL_PREFIX}/$$m ] || \
              [ $$(stat -c%Y $$m) -ne $$(stat -c%Y ${INSTALL_PREFIX}/$$m) ]; then \
+              if [ "$$m" != "k1om/xeon_phi_multiboot" ]; then \
                 do_update=1; \
                 echo "  > Installing $$m" ; \
                 mkdir -p ${INSTALL_PREFIX}/$$(dirname $$m); \
                 install -p $$m ${INSTALL_PREFIX}/$$m; \
+              fi; \
          fi; \
        done; \
        if [ ! $$do_update ]; then \
                echo "  > All up to date" ; \
+       else \
+               if [ -f "k1om/xeon_phi_multiboot" ] && [ $(BARRELFISH_NFS_DIR)  ]; then \
+                       echo ""; \
+                       echo "Uploading to NFS share $(BARRELFISH_NFS_DIR) ..." ; \
+                       scp k1om/xeon_phi_multiboot $(BARRELFISH_NFS_DIR); \
+                       scp     k1om/sbin/weever $(BARRELFISH_NFS_DIR); \
+               fi; \
        fi; \
        echo ""; \
        echo "done." ; \
@@ -372,9 +427,128 @@ install: $(MODULES)
 .PHONY : install
 
 
+install_headers:
+       echo "Installing header files..." ; \
+       for a in ${HAKE_ARCHS}; do \
+         mkdir -p "$$a" ; \
+         cp -rv "${SRCDIR}/include" "$$a/" ; \
+       done; \
+       echo "done." ; \
 
 .PHONY : install_headers
 
+sim: simulate
+.PHONY : sim
+
+QEMU=unknown-arch-error
+GDB=unknown-arch-error
+CLEAN_HD=
+
+DISK=hd.img
+AHCI=-device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -drive id=disk,file=$(DISK),if=none
+
+MENU_LST=-kernel $(shell sed -rne 's,^kernel[ \t]*/([^ ]*).*,\1,p' menu.lst) \
+       -append '$(shell sed -rne 's,^kernel[ \t]*[^ ]*[ \t]*(.*),\1,p' menu.lst)' \
+       -initrd '$(shell sed -rne 's,^module(nounzip)?[ \t]*/(.*),\2,p' menu.lst | awk '{ if(NR == 1) printf($$0); else printf("," $$0) } END { printf("\n") }')'
+
+ifeq ($(filter $(x86_64),$(ARCH)),)
+    QEMU_CMD=qemu-system-x86_64 -smp 2 -m 1024 -net nic,model=e1000 -net user $(AHCI) -nographic $(MENU_LST)
+       GDB=x86_64-pc-linux-gdb
+       CLEAN_HD=qemu-img create $(DISK) 10M
+else ifeq ($(ARCH),x86_32)
+        QEMU_CMD=qemu-system-i386 -no-kvm -smp 2 -m 1024 -net nic,model=ne2k_pci -net user -fda $(SRCDIR)/tools/grub-qemu.img -tftp $(PWD) -nographic
+       GDB=gdb
+else ifeq ($(ARCH),scc)
+        QEMU_CMD=qemu-system-i386 -no-kvm -smp 2 -m 1024 -cpu pentium -net nic,model=ne2k_pci -net user -fda $(SRCDIR)/tools/grub-qemu.img -tftp $(PWD) -nographic
+       GDB=gdb
+else ifeq ($(ARCH),armv5)
+       ARM_QEMU_CMD=qemu-system-arm -M integratorcp -kernel armv5/sbin/cpu.bin -nographic -no-reboot -m 256 -initrd armv5/romfs.cpio
+       GDB=xterm -e arm-linux-gnueabi-gdb
+simulate: $(MODULES) armv5/romfs.cpio
+       $(ARM_QEMU_CMD)
+.PHONY: simulate
+
+armv5/tools/debug.arm.gdb: $(SRCDIR)/tools/debug.arm.gdb
+       cp $< $@
+
+debugsim: $(MODULES) armv5/romfs.cpio armv5/tools/debug.arm.gdb
+       $(SRCDIR)/tools/debug.sh "$(ARM_QEMU_CMD) -initrd armv5/romfs.cpio" "$(GDB)" "-s $(ARCH)/sbin/cpu -x armv5/tools/debug.arm.gdb $(GDB_ARGS)"
+.PHONY : debugsim
+else ifeq ($(ARCH),arm11mp)
+       QEMU_CMD=qemu-system-arm -cpu mpcore -M realview -kernel arm11mp/sbin/cpu.bin
+       GDB=arm-linux-gnueabi-gdb
+else ifeq ($(ARCH), k1om)
+       # what is the emulation option for the xeon phi ?
+       QEMU=unknown-arch-error
+       GDB=x86_64-k1om-barrelfish-gdb
+endif
+
+
+ifdef QEMU_CMD
+
+simulate: $(MODULES)
+       $(CLEAN_HD)
+       $(QEMU_CMD)
+.PHONY : simulate
+
+debugsim: $(MODULES)
+       $(CLEAN_HD)
+       $(SRCDIR)/tools/debug.sh "$(QEMU_CMD)" "$(GDB)" "-x $(SRCDIR)/tools/debug.gdb $(GDB_ARGS)" "file:/dev/stdout"
+.PHONY : debugsim
+
+endif
+
+
+
+$(ARCH)/menu.lst: $(SRCDIR)/hake/menu.lst.$(ARCH)
+       cp $< $@
+
+$(ARCH)/romfs.cpio: $(SRCDIR)/tools/arm-mkbootcpio.sh $(MODULES) $(ARCH)/menu.lst
+       $(SRCDIR)/tools/arm-mkbootcpio.sh $(ARCH)/menu.lst $@
+
+# Location of hardcoded size of romfs CPIO image
+arm_romfs_cpio = "$(ARCH)/include/romfs_size.h"
+
+# XXX: Horrid hack to hardcode size of romfs CPIO image into ARM kernel
+# This works in several recursive make steps:
+# 1. Create a dummy romfs_size.h header file
+# 2. Compile everything
+# 3. Create the romfs CPIO image
+# 4. Determine its size and write to romfs_size.h
+# 5. Re-compile kernel (but not the romfs) with correct size information
+# 6. Install romfs to installation location
+arm:
+       $(MAKE)
+       $(MAKE) $(ARCH)/romfs.cpio
+       echo "//Autogenerated size of romfs.cpio because the bootloader cannot calculate it" > $(arm_romfs_cpio)
+       echo "size_t romfs_cpio_archive_size = `ls -asl $(ARCH)/romfs.cpio | sed -e 's/ /\n/g' | head -6 | tail -1`;" >> $(arm_romfs_cpio)
+       $(MAKE)
+.PHONY: arm
+
+# Builds a dummy romfs_size.h
+$(ARCH)/include/romfs_size.h:
+       mkdir -p $(shell dirname $@)
+       echo "size_t romfs_cpio_archive_size = 0; //should not see this" > $@
+
+arminstall:
+       $(MAKE) arm
+       $(MAKE) install
+       install -p $(ARCH)/romfs.cpio ${INSTALL_PREFIX}/$(ARCH)/romfs.cpio
+.PHONY: arminstall
+
+# Copy the scc-specific menu.lst from the source directory to the build directory
+menu.lst.scc: $(SRCDIR)/hake/menu.lst.scc
+       cp $< $@
+
+scc: all tools/bin/dite menu.lst.scc
+       $(shell find scc/sbin -type f -print0 | xargs -0 strip -d)
+       tools/bin/dite -32 -o bigimage.dat menu.lst.scc
+       cp $(SRCDIR)/tools/scc/bootvector.dat .
+       bin2obj -m $(SRCDIR)/tools/scc/bigimage.map -o barrelfish0.obj
+       bin2obj -m $(SRCDIR)/tools/scc/bootvector.map -o barrelfish1.obj
+       @echo Taking the barrelfish.obj files to SCC host
+       scp barrelfish[01].obj user@tomme1.in.barrelfish.org:
+
 # Source indexing targets
 cscope.files:
        find $(abspath .) $(abspath $(SRCDIR)) -name '*.[ch]' -type f -print | sort | uniq > $@
@@ -389,18 +563,55 @@ TAGS: cscope.files
 
 # force rebuild of the Makefile
 rehake: ./hake/hake
-       ./hake/hake --source-dir $(SRCDIR) --install-dir . --ghc-libdir $$(ghc --print-libdir) \
-                   --output-filename Makefile
+       ./hake/hake --source-dir $(SRCDIR)
 .PHONY: rehake
 
 clean::
-       $(RM) -r tools docs $(HAKE_ARCHS) $(MODULES_GENERIC)
+       $(RM) -r tools $(HAKE_ARCHS)
 .PHONY: clean
 
 realclean:: clean
        $(RM) hake/*.o hake/*.hi hake/hake Hakefiles.hs cscope.*
 .PHONY: realclean
 
+# Documentation
+DOCS= \
+       ./docs/TN-000-Overview.pdf \
+       ./docs/TN-001-Glossary.pdf \
+       ./docs/TN-002-Mackerel.pdf \
+       ./docs/TN-003-Hake.pdf \
+       ./docs/TN-004-VirtualMemory.pdf \
+       ./docs/TN-005-SCC.pdf \
+       ./docs/TN-006-Routing.pdf \
+       ./docs/TN-008-Tracing.pdf \
+       ./docs/TN-009-Notifications.pdf \
+       ./docs/TN-010-Spec.pdf \
+       ./docs/TN-011-IDC.pdf \
+       ./docs/TN-012-Services.pdf \
+       ./docs/TN-013-CapabilityManagement.pdf \
+       ./docs/TN-014-bulk-transfer.pdf \
+       ./docs/TN-015-DiskDriverArchitecture.pdf \
+       ./docs/TN-016-Serial.pdf \
+       ./docs/TN-017-ARM.pdf \
+       ./docs/TN-018-PracticalGuide.pdf \
+       ./docs/TN-019-DeviceDriver.pdf
+
+docs doc: $(DOCS)
+.PHONY: docs doc
+
+clean::
+       $(RM) $(DOCS)
+.PHONY: clean
+
+doxygen: Doxyfile
+       doxygen $<
+.PHONY: doxygen
+
+# pretend to be CMake's CONFIGURE_FILE command
+# TODO: clean this up
+Doxyfile: $(SRCDIR)/doc/Doxyfile.cmake
+       sed -r 's#@CMAKE_SOURCE_DIR@#$(SRCDIR)#g' $< > $@
+
 # Scheduler simulator test cases
 RUNTIME = 1000
 TESTS = $(addsuffix .txt,$(basename $(wildcard $(SRCDIR)/tools/schedsim/*.cfg)))
@@ -415,33 +626,304 @@ schedsim-check: $(wildcard $(SRCDIR)/tools/schedsim/*.cfg)
 
 ######################################################################
 #
-# Documentation
+# Green Marl Targets
 #
 ######################################################################
 
-# pretend to be CMake's CONFIGURE_FILE command
-# TODO: clean this up
-Doxyfile: $(SRCDIR)/doc/Doxyfile.cmake
-       sed -r 's#@CMAKE_SOURCE_DIR@#$(SRCDIR)#g' $< > $@
+GM_APPS=$(SRCDIR)usr/green-marl/apps/src
 
-doxygen: Doxyfile
-       doxygen $<
-.PHONY: doxygen
+define \n
 
-################################################################################
+
+endef
+
+x86_64/usr/green-marl/%.cc k1om/usr/green-marl/%.cc : tools/bin/gm_comp $(GM_APPS)/%.gm
+       $(foreach a,$(HAKE_ARCHS), \
+               mkdir -p $(a)/usr/green-marl ${\n}\
+               mkdir -p $(a)/include/green-marl ${\n}\
+               tools/bin/gm_comp -o=$(a)/usr/green-marl -t=cpp_omp  $(GM_APPS)/$*.gm ${\n} \
+               mv $(a)/usr/green-marl/$*.h $(a)/include/green-marl ${\n} \
+       )
+
+tools/bin/gm_comp :
+       test -s ./tools/bin/gm_comp || { echo "Compiler does already exist"; exit 0; }
+       # this target generates the green-marl compiler in the tools/bin directory
+       make -C $(SRCDIR)/usr/green-marl compiler -j 8
+       mv $(SRCDIR)/usr/green-marl/bin/gm_comp ./tools/bin/
+       make -C $(SRCDIR)/usr/green-marl clean
+       $(foreach a,$(HAKE_ARCHS), \
+               rm -rf $(a)/usr/green-marl/* ${\n}\
+       )
+
+######################################################################
+#
+# Intel Xeon Phi Builds
 #
-# Backwards compatibility: remove soon
-# 
-################################################################################
+######################################################################
 
-all: 
-       @echo "Type 'make help' for information on available targets."
-.PHONY : all
+# we have to filter out the moduels that are generated below
+MODULES_k1om_filtered = $(filter-out xeon_phi_multiboot, \
+                                               $(filter-out sbin/weever,$(MODULES_k1om)))
 
-sim: simulate
-.PHONY : sim
+# Intel Xeon Phi-specific modules
+XEON_PHI_MODULES =\
+       $(foreach m,$(MODULES_COMMON),k1om/$(m)) \
+       $(foreach m,$(MODULES_k1om_filtered),k1om/$(m)) \
+       $(foreach m,$(BENCH_COMMON),k1om/$(m)) \
+       $(foreach m,$(TESTS_COMMON),k1om/$(m)) \
+       $(foreach m,$(BENCH_k1om),k1om/$(m)) \
+       $(foreach m,$(TESTS_k1om),k1om/$(m))
 
-simulate: 
-       @echo "The targets 'sim' and 'simulate' have removed."
-       @echo "Type 'make help-boot' for a list of simulation targets."
-.PHONY : simulate
+menu.lst.k1om: $(SRCDIR)/hake/menu.lst.k1om
+       cp $< $@
+
+k1om/tools/weever/mbi.c: tools/bin/weever_multiboot \
+                                                k1om/xeon_phi_multiboot \
+                                                k1om/tools/weever/.marker
+       tools/bin/weever_multiboot k1om/multiboot.menu.lst.k1om k1om/tools/weever/mbi.c
+
+k1om/sbin/weever: k1om/sbin/weever.bin tools/bin/weever_creator
+       tools/bin/weever_creator ./k1om/sbin/weever.bin > ./k1om/sbin/weever
+
+k1om/sbin/weever.bin: k1om/sbin/weever_elf
+       $(K1OM_OBJCOPY) -O binary -R .note -R .comment -S k1om/sbin/weever_elf ./k1om/sbin/weever.bin
+
+k1om/xeon_phi_multiboot: $(XEON_PHI_MODULES) menu.lst.k1om
+       $(SRCDIR)/tools/weever/multiboot/build_data_files.sh menu.lst.k1om k1om
+
+
+#######################################################################
+#
+# Pandaboard builds
+#
+#######################################################################
+
+PANDABOARD_MODULES=\
+       armv7/sbin/cpu_omap44xx \
+       armv7/sbin/init \
+       armv7/sbin/mem_serv \
+       armv7/sbin/monitor \
+       armv7/sbin/ramfsd \
+       armv7/sbin/spawnd \
+       armv7/sbin/startd \
+       armv7/sbin/skb \
+       armv7/sbin/memtest \
+       armv7/sbin/kaluga \
+       armv7/sbin/fish \
+       armv7/sbin/sdma \
+       armv7/sbin/sdmatest \
+       armv7/sbin/sdma_bench \
+       armv7/sbin/bulk_sdma \
+       armv7/sbin/usb_manager \
+       armv7/sbin/usb_keyboard \
+       armv7/sbin/serial \
+       armv7/sbin/angler \
+       armv7/sbin/corectrl \
+
+
+menu.lst.pandaboard: $(SRCDIR)/hake/menu.lst.pandaboard
+       cp $< $@
+
+pandaboard_image: $(PANDABOARD_MODULES) \
+               tools/bin/arm_molly \
+               menu.lst.pandaboard
+       # Translate each of the binary files we need
+       $(SRCDIR)/tools/arm_molly/build_data_files.sh menu.lst.pandaboard molly_panda
+       # Generate appropriate linker script
+       cpp -P -DBASE_ADDR=0x82001000 $(SRCDIR)/tools/arm_molly/molly_ld_script.in \
+               molly_panda/molly_ld_script
+       # Build a C file to link into a single image for the 2nd-stage
+       # bootloader
+       tools/bin/arm_molly menu.lst.pandaboard panda_mbi.c
+       # Compile the complete boot image into a single executable
+       $(ARM_GCC) -std=c99 -g -fPIC -pie -Wl,-N -fno-builtin \
+               -nostdlib -march=armv7-a -mapcs -fno-unwind-tables \
+               -Tmolly_panda/molly_ld_script \
+               -I$(SRCDIR)/include \
+               -I$(SRCDIR)/include/arch/arm \
+               -I./armv7/include \
+               -I$(SRCDIR)/include/oldc \
+               -I$(SRCDIR)/include/c \
+               -imacros $(SRCDIR)/include/deputy/nodeputy.h \
+               $(SRCDIR)/tools/arm_molly/molly_boot.S \
+               $(SRCDIR)/tools/arm_molly/molly_init.c \
+               $(SRCDIR)/tools/arm_molly/lib.c \
+               ./panda_mbi.c \
+               $(SRCDIR)/lib/elf/elf32.c \
+               ./molly_panda/* \
+               -o pandaboard_image
+       @echo "OK - pandaboard boot image is built."
+       @echo "If your boot environment is correctly set up, you can now:"
+       @echo "$ usbboot ./pandaboard_image"
+
+########################################################################
+#
+# GEM5 build
+#
+########################################################################
+
+menu.lst.arm_gem5: $(SRCDIR)/hake/menu.lst.arm_gem5
+       cp $< $@
+
+menu.lst.arm_gem5_mc: $(SRCDIR)/hake/menu.lst.arm_gem5_mc
+       cp $< $@
+
+GEM5_MODULES=\
+       armv7/sbin/cpu_arm_gem5 \
+       armv7/sbin/init \
+       armv7/sbin/mem_serv \
+       armv7/sbin/monitor \
+       armv7/sbin/ramfsd \
+       armv7/sbin/spawnd \
+       armv7/sbin/startd \
+       armv7/sbin/corectrl \
+       armv7/sbin/skb \
+       armv7/sbin/memtest
+
+
+arm_gem5_image: $(GEM5_MODULES) \
+               tools/bin/arm_molly \
+               menu.lst.arm_gem5_mc
+       # Translate each of the binary files we need
+       $(SRCDIR)/tools/arm_molly/build_data_files.sh menu.lst.arm_gem5_mc molly_gem5
+       # Generate appropriate linker script
+       cpp -P -DBASE_ADDR=0x00100000 $(SRCDIR)/tools/arm_molly/molly_ld_script.in \
+               molly_gem5/molly_ld_script
+       # Build a C file to link into a single image for the 2nd-stage
+       # bootloader
+       tools/bin/arm_molly menu.lst.arm_gem5_mc arm_mbi.c
+       # Compile the complete boot image into a single executable
+       $(ARM_GCC) -std=c99 -g -fPIC -pie -Wl,-N -fno-builtin \
+               -nostdlib -march=armv7-a -mapcs -fno-unwind-tables \
+               -Tmolly_gem5/molly_ld_script \
+               -I$(SRCDIR)/include \
+               -I$(SRCDIR)/include/arch/arm \
+               -I./armv7/include \
+               -I$(SRCDIR)/include/oldc \
+               -I$(SRCDIR)/include/c \
+               -imacros $(SRCDIR)/include/deputy/nodeputy.h \
+               $(SRCDIR)/tools/arm_molly/molly_boot.S \
+               $(SRCDIR)/tools/arm_molly/molly_init.c \
+               $(SRCDIR)/tools/arm_molly/lib.c \
+               ./arm_mbi.c \
+               $(SRCDIR)/lib/elf/elf32.c \
+               ./molly_gem5/* \
+               -o arm_gem5_image
+
+# ARM GEM5 Simulation Targets
+ARM_FLAGS=$(SRCDIR)/tools/arm_gem5/gem5script.py --caches --l2cache --n=2 --kernel=arm_gem5_image
+
+arm_gem5: arm_gem5_image $(SRCDIR)/tools/arm_gem5/gem5script.py
+       gem5.fast $(ARM_FLAGS)
+
+arm_gem5_detailed: arm_gem5_image $(SRCDIR)/tools/arm_gem5/gem5script.py
+       gem5.fast $(ARM_FLAGS) --cpu-type=arm_detailed
+
+.PHONY: arm_gem5 arm_gem5_detailed
+
+#######################################################################
+#
+# Pandaboard build for the armv7-M slave image (to be used in conjunction with a master image)
+# (basically a normal pandaboard_image, but compiled for the cortex-m3)
+#
+#######################################################################
+
+HETEROPANDA_SLAVE_MODULES=\
+       armv7-m/sbin/cpu_omap44xx \
+       armv7-m/sbin/init \
+       armv7-m/sbin/mem_serv \
+       armv7-m/sbin/monitor \
+       armv7-m/sbin/ramfsd \
+       armv7-m/sbin/spawnd \
+       armv7-m/sbin/startd \
+       armv7-m/sbin/skb \
+       armv7-m/sbin/memtest
+
+menu.lst.armv7-m: $(SRCDIR)/hake/menu.lst.armv7-m
+       cp $< $@
+
+heteropanda_slave: $(HETEROPANDA_SLAVE_MODULES) \
+               tools/bin/arm_molly \
+               menu.lst.armv7-m
+       # Translate each of the binary files we need
+       $(SRCDIR)/tools/arm_molly/build_data_files.sh menu.lst.armv7-m molly_panda_slave
+       # Generate appropriate linker script
+       cpp -P -DBASE_ADDR=0x0 $(SRCDIR)/tools/arm_molly/molly_ld_script.in \
+               molly_panda_slave/molly_ld_script
+       # Build a C file to link into a single image for the 2nd-stage
+       # bootloader
+       tools/bin/arm_molly menu.lst.armv7-m panda_mbi_slave.c
+       # Compile the complete boot image into a single executable
+       $(ARM_GCC) -std=c99 -g -fPIC -pie -Wl,-N -fno-builtin \
+               -nostdlib -march=armv7-m -mcpu=cortex-m3 -mthumb -mapcs -fno-unwind-tables \
+               -Tmolly_panda_slave/molly_ld_script \
+               -I$(SRCDIR)/include \
+               -I$(SRCDIR)/include/arch/arm \
+               -I./armv7-m/include \
+               -I$(SRCDIR)/include/oldc \
+               -I$(SRCDIR)/include/c \
+               -imacros $(SRCDIR)/include/deputy/nodeputy.h \
+               $(SRCDIR)/tools/arm_molly/molly_boot.S \
+               $(SRCDIR)/tools/arm_molly/molly_init.c \
+               $(SRCDIR)/tools/arm_molly/lib.c \
+               ./panda_mbi_slave.c \
+               $(SRCDIR)/lib/elf/elf32.c \
+               ./molly_panda_slave/* \
+               -o heteropanda_slave
+       @echo "OK - heteropanda slave image is built."
+       @echo "you can now use this image to link into a regular pandaboard image"
+
+
+
+
+#######################################################################
+#
+# Pandaboard build for the heteropanda_master:
+# basically a regular pandaboard_image, except that it contains
+# a heteropanda_slave image, and arm_molly is called with -DHETEROPANDA
+#
+#######################################################################
+
+menu.lst.heteropanda_master: $(SRCDIR)/hake/menu.lst.heteropanda_master
+       cp $< $@
+
+heteropanda_master_image: $(PANDABOARD_MODULES) \
+               tools/bin/arm_molly \
+               menu.lst.heteropanda_master \
+               heteropanda_slave \
+               $(SRCDIR)/tools/arm_molly/molly_ld_script.in
+       # Translate each of the binary files we need
+       $(SRCDIR)/tools/arm_molly/build_data_files.sh menu.lst.heteropanda_master molly_panda
+       # Generate appropriate linker script
+       cpp -P -DBASE_ADDR=0x82001000 $(SRCDIR)/tools/arm_molly/molly_ld_script.in \
+               molly_panda/molly_ld_script
+
+       # HETEROPANDA: convert slave image into a form we can insert in our image
+       $(ARM_OBJCOPY) -I binary -O elf32-littlearm -B arm --rename-section \
+           .data=.rodata_thumb,alloc,load,readonly,data,contents heteropanda_slave \
+           molly_panda/heteropanda_slave
+
+       # Build a C file to link into a single image for the 2nd-stage
+       # bootloader
+       tools/bin/arm_molly menu.lst.heteropanda_master panda_mbi.c
+       # Compile the complete boot image into a single executable
+       $(ARM_GCC) -std=c99 -g -fPIC -pie -Wl,-N -fno-builtin \
+               -nostdlib -march=armv7-a -mcpu=cortex-a9 -mapcs -fno-unwind-tables \
+               -Tmolly_panda/molly_ld_script \
+               -I$(SRCDIR)/include \
+               -I$(SRCDIR)/include/arch/arm \
+               -I./armv7/include \
+               -I$(SRCDIR)/include/oldc \
+               -I$(SRCDIR)/include/c \
+               -imacros $(SRCDIR)/include/deputy/nodeputy.h \
+               $(SRCDIR)/tools/arm_molly/molly_boot.S \
+               $(SRCDIR)/tools/arm_molly/molly_init.c \
+               $(SRCDIR)/tools/arm_molly/lib.c \
+               ./panda_mbi.c \
+               $(SRCDIR)/lib/elf/elf32.c \
+               ./molly_panda/* \
+               -DHETEROPANDA \
+               -o heteropanda_master_image
+       @echo "OK - heteropanda_master_image is built."
+       @echo "If your boot environment is correctly set up, you can now:"
+       @echo "$ usbboot ./heteropanda_master_image"
index d4c8467..2e98c93 100644 (file)
@@ -302,6 +302,18 @@ sysreg_read_par_el1(void) {
 }
 
 static inline uint32_t
+sysreg_read_cnthctl_el2(void) {
+    uint32_t cnthctl_el2;
+    __asm volatile("mrs %[cnthctl_el2], CNTHCTL_EL2" : [cnthctl_el2] "=r" (cnthctl_el2));
+    return cnthctl_el2;
+}
+
+static inline void
+sysreg_write_cnthctl_el2(uint32_t cnthctl_el2) {
+    __asm volatile("msr CNTHCTL_EL2, %[cnthctl_el2]" : : [cnthctl_el2] "r" (cnthctl_el2));
+}
+
+static inline uint32_t
 sysreg_read_cntkctl_el1(void) {
     uint32_t cntkctl_el1;
     __asm volatile("mrs %[cntkctl_el1], CNTKCTL_EL1" : [cntkctl_el1] "=r" (cntkctl_el1));