FOC/L4RE: Upstream revision 42

This commit is contained in:
Sebastian Sumpf
2013-01-14 12:18:53 +01:00
parent 808d228872
commit 34af60da11
364 changed files with 7500 additions and 5211 deletions

View File

@@ -42,6 +42,7 @@ _start:
beq run /* ... go to run */
/* Disable caches as we're moving code around */
mcr p15, 0, r3, c7, c5, 0 /* ICIALLU */
mrc p15, 0, r0, c1, c0
bic r0, #0x0004
bic r0, #0x1000
@@ -57,16 +58,16 @@ _start:
* overwrites */
mov r9, r5 /* r9: run address */
ldr r0, .LCstart_bin
ldr r1, 3f
str r1, [r0], #4
ldr r1, 32f
str r1, [r0], #4
ldr r1, 33f
str r1, [r0], #4
ldr r1, 34f
str r1, [r0], #4
ldr r1, 35f
str r1, [r0], #4
ldr r3, 3f
str r3, [r0], #4
ldr r3, 32f
str r3, [r0], #4
ldr r3, 33f
str r3, [r0], #4
ldr r3, 34f
str r3, [r0], #4
ldr r3, 35f
str r3, [r0], #4
ldr pc, .LCstart_bin
3: ldr r6, [r4], #4
@@ -90,11 +91,11 @@ move_behind:
.LCend_bin: .word _module_data_end
run:
mov r1, #0x1000
sub r1, r1, #1 /* r1 == 0xfff */
mov r3, #0x1000
sub r3, r3, #1 /* r3 == 0xfff */
mrc p15, 0, r0, c0, c0, 0 /* Main ID */
lsr r0, #4
and r0, r0, r1
and r0, r0, r3
/* Check for processors that understand CPU ID */
mov r9, #0xb00
@@ -154,7 +155,7 @@ do_cpuid:
ldr r6, [r5, #0x30]
cmp r6, #0
movne pc, r6
.word 0xe320f003 /* wfi */
.inst 0xe320f003 /* wfi */
ldr r0, [r4, #12]
str r0, [r4, #16]
b 1b

View File

@@ -10,6 +10,9 @@
# - BOOTSTRAP_UIMAGE_COMPRESSION: set to none, gzip, or bzip2
# - BOOTSTRAP_CMDLINE: compiled-in command line, only used if no cmdline
# given via multi-boot boot loader (e.g. on arm)
# - BOOTSTRAP_OUTPUT_DIR: Optional alternative output directory for all
# images (and generated files), preferable some
# tmpfs directory
DEFAULT_RELOC_arm := 0x01000000
DEFAULT_RELOC_x86 := 0x002d0000
@@ -54,11 +57,13 @@ ifeq ($(BUILD_ARCH),$(filter $(BUILD_ARCH),arm ppc32 sparc))
ENTRY := auto-build-entry
endif
od := $(if $(BOOTSTRAP_OUTPUT_DIR),$(if $(wildcard $(BOOTSTRAP_OUTPUT_DIR)),,$(shell mkdir $(BOOTSTRAP_OUTPUT_DIR))))
od := $(if $(BOOTSTRAP_OUTPUT_DIR),$(BOOTSTRAP_OUTPUT_DIR)/)
PRIVATE_INCDIR = $(SRC_DIR) $(SRC_DIR)/ARCH-$(ARCH)
TARGET := $(BOOTSTRAP_ELF_NAME)
TARGET_BIN = $(BOOTSTRAP_ELF_NAME)
TARGET := $(od)$(BOOTSTRAP_ELF_NAME)
TARGET_BIN = $(od)$(BOOTSTRAP_ELF_NAME)
MODE = lib
SUPPORT_CC_arm-sa1000 := platform/sa1000.cc
@@ -66,7 +71,7 @@ SUPPORT_CC_arm-pxa := platform/pxa.cc
SUPPORT_CC_arm-integrator := platform/integrator.cc
SUPPORT_CC_arm-rv := platform/rv.cc
SUPPORT_CC_arm-rv_pbx := platform/rv.cc
SUPPORT_CC_arm-rv_vexpress := platform/rv.cc
SUPPORT_CC_arm-rv_vexpress := platform/rv_vexpress.cc
SUPPORT_CC_arm-omap3evm := platform/omap.cc
SUPPORT_CC_arm-omap3_am33xx:= platform/omap.cc
SUPPORT_CC_arm-beagleboard := platform/omap.cc
@@ -75,6 +80,7 @@ SUPPORT_CC_arm-tegra2 := platform/tegra2.cc
SUPPORT_CC_arm-imx21 := platform/imx.cc
SUPPORT_CC_arm-imx35 := platform/imx.cc
SUPPORT_CC_arm-imx51 := platform/imx.cc
SUPPORT_CC_arm-imx6 := platform/imx.cc
SUPPORT_CC_arm-om := platform/om.cc
SUPPORT_CC_arm-kirkwood := platform/kirkwood.cc
DEFAULT_RELOC_arm-imx21 := 0x00200000 # because of blob
@@ -163,7 +169,8 @@ ENTRY_FN := $(shell echo "$(ENTRY)" | tr '[ ]' '[_]' )
ifneq ($(ENTRY),)
ifeq ($(filter clean cleanall,$(MAKECMDGOALS)),)
BUILD_MOD_CMD = ( SEARCHPATH="$(BOOTSTRAP_SEARCH_PATH):$(BOOTSTRAP_MODULE_PATH_BINLIB)" \
CROSS_COMPILE=$(SYSTEM_TARGET) \
CROSS_COMPILE=$(SYSTEM_TARGET) MAKE_INC_FILE=$(PWD)/mod.make.inc \
OUTPUT_DIR="$(BOOTSTRAP_OUTPUT_DIR)" \
OPT_ARCH=$(ARCH) OPT_COMPRESS=$(COMPRESS) L4DIR=$(L4DIR) \
$(SRC_DIR)/build.pl $(1) $(BOOTSTRAP_MODULES_LIST) "$(ENTRY)" || \
(echo "processing-of-module-list-failed"; exit 1))
@@ -173,7 +180,7 @@ endif
# we need to re-do if some things change
.redo-change-tracker: FORCE
$(VERBOSE)echo "$(ENTRY) '$(COMPRESS)' '$(BOOTSTRAP_CMDLINE)' '$(BOOTSTRAP_SEARCH_PATH):$(BOOTSTRAP_MODULE_PATH_BINLIB)' '$(RAM_SIZE_MB)' '$(PLATFORM_TYPE)' '$(LOADER_MBI)'" > $@.tmp
$(VERBOSE)echo "$(ENTRY) '$(COMPRESS)' '$(BOOTSTRAP_CMDLINE)' '$(BOOTSTRAP_SEARCH_PATH):$(BOOTSTRAP_MODULE_PATH_BINLIB)' '$(RAM_SIZE_MB)' '$(PLATFORM_TYPE)' '$(LOADER_MBI)' '$(od)'" > $@.tmp
$(if $(BUILD_MOD_CMD),$(VERBOSE)$(call BUILD_MOD_CMD,dump) >> $@.tmp)
$(VERBOSE)if test ! -r "$@" || ! cmp -s $@ $@.tmp; then \
mv $@.tmp $@; \
@@ -183,24 +190,24 @@ endif
ifneq ($(ENTRY),)
INSTALL_TARGET = $(BOOTSTRAP_ELF_NAME) bootstrap_$(ENTRY_FN) bootstrap_$(ENTRY_FN).elf
INSTALL_FILES = $(BOOTSTRAP_ELF_NAME) bootstrap_$(ENTRY_FN) bootstrap_$(ENTRY_FN).elf
ifeq ($(ARCH),amd64)
INSTALL_TARGET += bootstrap32.elf
INSTALL_FILES += bootstrap32.elf
BOOTSTRAP_LINK_SOURCE = bootstrap32.elf
else
BOOTSTRAP_LINK_SOURCE = $(BOOTSTRAP_ELF_NAME)
endif
bootstrap_$(ENTRY_FN): $(BOOTSTRAP_LINK_SOURCE)
$(od)bootstrap_$(ENTRY_FN): $(od)$(BOOTSTRAP_LINK_SOURCE)
$(VERBOSE)$(LN) -f $< $@
bootstrap_$(ENTRY_FN).elf: $(BOOTSTRAP_LINK_SOURCE)
$(od)bootstrap_$(ENTRY_FN).elf: $(od)$(BOOTSTRAP_LINK_SOURCE)
$(VERBOSE)$(LN) -f $< $@
bootstrap_$(ENTRY_FN).raw: bootstrap.raw
$(od)bootstrap_$(ENTRY_FN).raw: $(od)bootstrap.raw
$(VERBOSE)$(LN) -f $< $@
bootstrap_$(ENTRY_FN).uimage: bootstrap.uimage
$(od)bootstrap_$(ENTRY_FN).uimage: $(od)bootstrap.uimage
$(VERBOSE)$(LN) -f $< $@
ifeq ($(ARCH),$(filter $(ARCH),arm ppc32))
@@ -212,12 +219,12 @@ bootstrap_$(ENTRY_FN).uimage: bootstrap.uimage
exit 1; } ; $(if $(BOOTSTRAP_NO_STRIP),,$(STRIP) $@)
ifneq ($(BOOTSTRAP_DO_RAW_IMAGE)$(BOOTSTRAP_DO_UIMAGE),)
BOOTSTRAP_RAW := bootstrap.raw
INSTALL_TARGET += bootstrap.raw bootstrap_$(ENTRY_FN).raw
BOOTSTRAP_RAW := $(od)bootstrap.raw
INSTALL_FILES += bootstrap.raw bootstrap_$(ENTRY_FN).raw
ifneq ($(BOOTSTRAP_DO_UIMAGE),)
ifneq ($(shell command -v $(MKIMAGE)),)
BOOTSTRAP_UIMAGE := bootstrap.uimage
INSTALL_TARGET += bootstrap.uimage bootstrap_$(ENTRY_FN).uimage
BOOTSTRAP_UIMAGE := $(od)bootstrap.uimage
INSTALL_FILES += bootstrap.uimage bootstrap_$(ENTRY_FN).uimage
else
$(error mkimage($(MKIMAGE)) host tool missing, cannot build bootstrap.uimage)
endif
@@ -225,36 +232,29 @@ bootstrap_$(ENTRY_FN).uimage: bootstrap.uimage
endif
endif
all:: $(addprefix $(IMAGES_DIR)/,$(INSTALL_TARGET))
all:: $(addprefix $(IMAGES_DIR)/,$(INSTALL_FILES))
$(VERBOSE)echo " Image size(s) in bytes:"
$(VERBOSE)for f in $(filter bootstrap_$(ENTRY_FN).elf bootstrap.raw bootstrap.uimage, $(INSTALL_TARGET)); do \
find . -name $$f -printf " %30f: %s\n"; \
$(VERBOSE)for f in $(filter bootstrap_$(ENTRY_FN).elf bootstrap.raw bootstrap.uimage, $(INSTALL_FILES)); do \
find $(if $(od),$(od),.) -name $$f -printf " %30f: %s\n"; \
done
$(if $(LDFLAGS_bootstrap.elf),$(VERBOSE)echo " Start address: $(patsubst --defsym=__executable_start=%,%,$(LDFLAGS_bootstrap.elf))")
$(VERBOSE)echo " --> Build-Nr: $$(cat .build_nr)"
# install images into easy to reach directory in build dir
$(IMAGES_DIR)/%: % $(IMAGES_DIR)/Makefile
$(IMAGES_DIR)/%: $(od)%
$(VERBOSE)if [ "$(ENTRY)" != "auto-build-entry" ]; then \
echo " ==> Installing $< in image directory"; \
$(LN) -sf $(PWD)/$< $(dir $@); \
(cd $(dir $@) && $(LN) -sf $(if $(od),,$(PWD)/)$<); \
fi
$(IMAGES_DIR)/Makefile: $(SRC_DIR)/Make.rules
@echo " ==> Preparing image directory"
$(VERBOSE)install -d $(dir $@)
$(VERBOSE)$(ECHO) "# Automatically generated by bootstrap" > $@
$(VERBOSE)$(ECHO) "\$$(if \$$(MAKECMDGOALS),%,a):" >> $@
$(VERBOSE)$(ECHO) " \$$(MAKE) -C .. image \$$(if \$$(MAKECMDGOALS),E=\"\$$@\")" >> $@
else
INSTALL_TARGET = bootstrap
INSTALL_FILES = bootstrap
endif # ENTRY
ifneq ($(REALMODE_LOADING),0)
LOADER_MBI = 1
CPPFLAGS += -DREALMODE_LOADING -DSINGLE_SECTION
# don't install bootstrap_$(ENTRY_FN).elf
INSTALL_TARGET = bootstrap.load
INSTALL_FILES = bootstrap.load
endif
ifneq ($(LOADER_MBI),0)
@@ -277,7 +277,7 @@ endif
CXXFLAGS += -fno-rtti -fno-exceptions
CXXFLAGS += $(call checkcxx,-fno-threadsafe-statics)
ifneq ($(ENTRY),)
ifneq ($(BUILD_MOD_CMD),)
ifeq ($(filter clean cleanall,$(MAKECMDGOALS)),)
processing-of-module-list-failed:
@@ -287,13 +287,13 @@ processing-of-module-list-failed:
@exit 1
mod.make.inc: $(GENERAL_D_LOC) $(shell $(call BUILD_MOD_CMD,list))
@echo Building entry "$(ENTRY)".
@echo Building entry \""$(ENTRY)"\".
$(VERBOSE)$(call BUILD_MOD_CMD,build)
-include mod.make.inc
BOOTSTRAP_LD_dep += mod.make.inc
STARTUP_C_dep := mod.make.inc
OBJS_$(BOOTSTRAP_ELF_NAME) += $(MODULE_OBJECT_FILES)
OBJS_$(od)$(BOOTSTRAP_ELF_NAME) += $(MODULE_OBJECT_FILES)
endif
CPPFLAGS += -DIMAGE_MODE
@@ -383,7 +383,7 @@ clean::
$(VERBOSE)$(RM) .redo-change-tracker
cleanall::
$(VERBOSE)$(RM) bootstrap_* bootstrap.*
$(VERBOSE)$(RM) $(od)bootstrap_* $(od)bootstrap.*
ifeq ($(ARCH),amd64)
@@ -435,3 +435,5 @@ else
bootstrap: $(BOOTSTRAP_ELF_NAME)
$(VERBOSE)$(LN) -f $^ $@
endif
INSTALL_TARGET := $(if $(od),,$(INSTALL_FILES))

View File

@@ -20,19 +20,21 @@ use L4::ModList;
my $cross_compile_prefix = $ENV{CROSS_COMPILE} || '';
my $arch = $ENV{OPT_ARCH} || "x86";
my $module_path = $ENV{SEARCHPATH} || ".";
my $prog_objcopy = $ENV{OBJCOPY} || "${cross_compile_prefix}objcopy";
my $prog_cc = $ENV{CC} || "${cross_compile_prefix}gcc";
my $prog_ld = $ENV{LD} || "${cross_compile_prefix}ld";
my $prog_cp = $ENV{PROG_CP} || "cp";
my $prog_gzip = $ENV{PROG_GZIP} || "gzip";
my $compress = $ENV{OPT_COMPRESS} || 0;
my $strip = $ENV{OPT_STRIP} || 1;
my $module_path = $ENV{SEARCHPATH} || ".";
my $prog_objcopy = $ENV{OBJCOPY} || "${cross_compile_prefix}objcopy";
my $prog_cc = $ENV{CC} || "${cross_compile_prefix}gcc";
my $prog_ld = $ENV{LD} || "${cross_compile_prefix}ld";
my $prog_cp = $ENV{PROG_CP} || "cp";
my $prog_gzip = $ENV{PROG_GZIP} || "gzip";
my $compress = $ENV{OPT_COMPRESS} || 0;
my $strip = $ENV{OPT_STRIP} || 1;
my $output_dir = $ENV{OUTPUT_DIR} || '.';
my $make_inc_file = $ENV{MAKE_INC_FILE} || "mod.make.inc";
my $flags_cc = "";
$flags_cc = "-m32" if $arch eq 'x86';
$flags_cc = "-m64" if $arch eq 'amd64';
my $make_inc_file = $ENV{MAKE_INC_FILE} || "mod.make.inc";
my $modulesfile = $ARGV[1];
my $entryname = $ARGV[2];
@@ -70,7 +72,8 @@ sub build_obj($$$)
my $file = L4::ModList::search_file($_file, $module_path)
|| die "Cannot find file $_file! Used search path: $module_path";
printf STDERR "Merging image %s to %s\n", $file, $modname;
printf STDERR "Merging image %s to %s [%dkB]\n",
$file, $modname, ((-s $file) + 1023) / 1024;
# make sure that the file isn't already compressed
system("$prog_gzip -dc $file > $modname.ugz 2> /dev/null");
$file = "$modname.ugz" if !$?;
@@ -166,7 +169,7 @@ sub build_objects(@)
{
my %entry = @_;
my @mods = @{$entry{mods}};
my $objs = "mbi_modules.bin";
my $objs = "$output_dir/mbi_modules.bin";
unlink($make_inc_file);
@@ -180,7 +183,7 @@ sub build_objects(@)
for (my $i = 0; $i < @mods; $i++) {
build_obj($mods[$i]->{cmdline}, $mods[$i]->{modname},
$mods[$i]->{type} =~ /.+-nostrip$/);
$objs .= " $mods[$i]->{modname}.bin";
$objs .= " $output_dir/$mods[$i]->{modname}.bin";
}
my $make_inc_str = "MODULE_OBJECT_FILES += $objs\n";
@@ -213,6 +216,15 @@ if (!$ARGV[2]) {
exit 1;
}
if (defined $output_dir)
{
if (not -d $output_dir)
{
mkdir $output_dir || die "Cannot create '$output_dir': $!";
}
chdir $output_dir || die "Cannot change to directory '$output_dir': $!";
}
my %entry = L4::ModList::get_module_entry($modulesfile, $entryname);
if ($ARGV[0] eq 'build')

View File

@@ -36,6 +36,10 @@ class Platform_arm_imx : public Platform_single_region_ram
#elif defined(PLATFORM_TYPE_imx51)
static L4::Io_register_block_mmio r(0x73fbc000);
static L4::Uart_imx51 _uart;
#elif defined(PLATFORM_TYPE_imx6)
//static L4::Io_register_block_mmio r(0x02020000); // UART1
static L4::Io_register_block_mmio r(0x021e8000); // UART2
static L4::Uart_imx6 _uart;
#else
#error Which platform type?
#endif

View File

@@ -1,13 +1,13 @@
/*!
* \file support_rv.cc
* \file
* \brief Support for the rv platform
*
* \date 2008-01-02
* \date 2011
* \author Adam Lackorznynski <adam@os.inf.tu-dresden.de>
*
*/
/*
* (c) 2008-2009 Author(s)
* (c) 2008-2011 Author(s)
* economic rights: Technische Universität Dresden (Germany)
*
* This file is part of TUD:OS and distributed under the terms of the
@@ -20,6 +20,7 @@
#include <l4/drivers/uart_pl011.h>
namespace {
class Platform_arm_rv : public Platform_single_region_ram
{
bool probe() { return true; }
@@ -31,6 +32,7 @@ class Platform_arm_rv : public Platform_single_region_ram
set_stdio_uart(&_uart);
}
};
}
REGISTER_PLATFORM(Platform_arm_rv);

View File

@@ -0,0 +1,38 @@
/*!
* \file
* \brief Support for the rv platform
*
* \date 2011
* \author Adam Lackorznynski <adam@os.inf.tu-dresden.de>
*
*/
/*
* (c) 2008-2011 Author(s)
* economic rights: Technische Universität Dresden (Germany)
*
* This file is part of TUD:OS and distributed under the terms of the
* GNU General Public License 2.
* Please see the COPYING-GPL-2 file for details.
*/
#include "support.h"
#include <l4/drivers/uart_pl011.h>
namespace {
class Platform_arm_rv_vexpress : public Platform_single_region_ram
{
bool probe() { return true; }
void init()
{
static L4::Io_register_block_mmio r(0x10009000);
static L4::Uart_pl011 _uart;
_uart.startup(&r);
set_stdio_uart(&_uart);
}
};
}
REGISTER_PLATFORM(Platform_arm_rv_vexpress);

View File

@@ -438,6 +438,9 @@ move_module(l4util_mb_info_t *mbi, int i, Region *from, Region *to,
printf(" moving module %02d { %lx-%llx } -> { %llx-%llx } [%ld]\n",
i, start, from->end(), to->begin(), to->end(), size);
if (!ram.contains(*to))
panic("Panic: Would move outside of RAM");
if (overlap_check)
{
Region *overlap = regions.find(*to);
@@ -446,11 +449,10 @@ move_module(l4util_mb_info_t *mbi, int i, Region *from, Region *to,
printf("ERROR: module target [%llx-%llx) overlaps\n",
to->begin(), to->end());
overlap->vprint();
panic("can not move module");
regions.dump();
panic("cannot move module");
}
}
if (!ram.contains(*to))
panic("Panic: Would move outside of RAM");
memmove((void *)to->begin(), (void *)start, size);
unsigned long x = to->end() + 1;
memset((char *)x, 0, l4_round_page(x) - x);
@@ -481,7 +483,7 @@ unsigned long mbi_mod_size(l4util_mb_info_t *mbi, int i)
static void
move_modules(l4util_mb_info_t *mbi, unsigned long modaddr)
{
printf(" Moving modules behind %lx\n", modaddr);
printf(" Moving up to %d modules behind %lx\n", mbi->mods_count, modaddr);
Region *ramr = ram.find(Region(modaddr, modaddr));
Region module_area(modaddr, ramr->end(), "ram for modules");
@@ -502,7 +504,6 @@ move_modules(l4util_mb_info_t *mbi, unsigned long modaddr)
lastmoduleend = regions.find_free(s, sz, L4_PAGESHIFT) + sz;
}
for (unsigned i = 0; i < mbi->mods_count; ++i)
{
unsigned long start = mbi_mod_start(mbi, i);
@@ -519,14 +520,14 @@ move_modules(l4util_mb_info_t *mbi, unsigned long modaddr)
if (i < 3)
{
unsigned long start = mbi_mod_start(mbi, i);
if (start < lastmoduleend)
{
unsigned long end = mbi_mod_end(mbi, i);
Region to(lastmoduleend, lastmoduleend + (end - start) - 1);
move_module(mbi, i, this_module, &to, true);
lastmoduleend = l4_round_page(this_module->end());
if (module_area.contains(to))
{
move_module(mbi, i, this_module, &to, true);
lastmoduleend = l4_round_page(this_module->end());
}
}
continue;
}