genode/ports-foc/patches/l4android_genode.patch
Stefan Kalkowski 760f37fc86 Fiasco.OC: enable SMP for L4Linux
This commit comprises the following changes to enable L4Linux to use several
CPUs:
* change default configuration for x86 and ARM
* add atomic cmpxchg operation to l4re library
* implement l4_sleep (per thread)
* enable setting affinity for VCPUs and IRQs
* move "per CPU" section within linker-script (x86 only)
* introduce SMP run-script for pandaboard
* deactivate direct scheduler (Fiasco.OC syscall) access by L4Linux
2012-09-14 12:30:29 +02:00

1044 lines
27 KiB
Diff

diff --git a/arch/l4/Kconfig b/arch/l4/Kconfig
index 995122e..ed181ff 100644
--- a/arch/l4/Kconfig
+++ b/arch/l4/Kconfig
@@ -394,6 +394,18 @@ endmenu # l4linux options
config L4_USE_L4SHMC
bool
+config SCREEN_GENODE
+ bool
+ select FB_CFB_FILLRECT
+ select FB_CFB_COPYAREA
+ select FB_CFB_IMAGEBLIT
+ default y
+
+config SERIAL_GENODE
+ bool
+ default y
+ select SERIAL_CORE
+ select SERIAL_CORE_CONSOLE
# some delimiter (for .config)
comment ""
diff --git a/arch/l4/Makefile b/arch/l4/Makefile
index 806ef23..e577a7e 100644
--- a/arch/l4/Makefile
+++ b/arch/l4/Makefile
@@ -170,6 +170,12 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
# prevent gcc from generating any FP code by mistake
KBUILD_CFLAGS += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
+#
+# Prevent the gcc from linking Linux memmove into compiler-generated
+# Genode stuff.
+#
+KBUILD_CFLAGS += -Dmemmove=lx_memmove
+
endif
ifeq ($(BASEARCH),arm)
@@ -252,6 +258,8 @@ endif
endif
+# Genode compiler is build without Linux defines.
+KBUILD_CFLAGS +=-D__linux__ -Dlinux
# -----------------------------------------------
@@ -274,14 +282,15 @@ L4LX_E_L-$(CONFIG_L4_PDSPBLK_DRV) += pers_dsp
L4LX_E_L-$(CONFIG_L4_TCG_STPM) += stpm-client
L4LX_E_L-$(CONFIG_L4_FERRET) += ferret
-L4INC = -I$(L4OBJ)/include/$(L4_MK_ARCH)/$(L4_MK_API) \
- -I$(L4OBJ)/include/$(L4_MK_ARCH) \
- -I$(L4OBJ)/include/$(L4_MK_API) \
- -I$(L4OBJ)/include
+#L4INC = -I$(L4OBJ)/include/$(L4_MK_ARCH)/$(L4_MK_API) \
+# -I$(L4OBJ)/include/$(L4_MK_ARCH) \
+# -I$(L4OBJ)/include/$(L4_MK_API) \
+# -I$(L4OBJ)/include
head-y := arch/l4/kernel/head.o arch/l4/kernel/init_task.o
-libs-y += arch/l4/lib/arch-$(BASEARCH)/ \
+libs-y += arch/l4/lib/arch-$(BASEARCH)/
+# \
arch/l4/l4lxlib/generic/ \
arch/l4/l4lxlib/$(BASEENV)/
@@ -299,7 +308,7 @@ endif
core-y += arch/l4/
--include $(L4OBJ)/l4defs.mk.inc
+#-include $(L4OBJ)/l4defs.mk.inc
L4_REQUIRED_MODS := libc_be_minimal_log_io \
libc_minimal libc_minimal_l4re \
@@ -315,15 +324,16 @@ $(info L4_REQUIRED_MODS: $(L4_REQUIRED_MODS))
$(error Aborting.)
endif
-libs-y += -Bstatic $(L4_LIBDIRS) -ll4sys -ll4sys-direct
+libs-y += $(GENODE_LIBS)
export L4INC L4_REQUIRED_MODS
-LDFLAGS_vmlinux = \
- --defsym __L4_KIP_ADDR__=$(L4_BID_KIP_ADDR) \
- --defsym __l4sys_invoke_direct=$(L4_BID_KIP_ADDR)+$(L4_BID_KIP_OFFS_SYS_INVOKE) \
- --defsym __l4sys_debugger_direct=$(L4_BID_KIP_ADDR)+$(L4_BID_KIP_OFFS_SYS_DEBUGGER)
+LDFLAGS_vmlinux = -nostdlib
+# --defsym __L4_KIP_ADDR__=$(L4_BID_KIP_ADDR) \
+ -nostdlib
+#--defsym __l4sys_invoke_direct=$(L4_BID_KIP_ADDR)+$(L4_BID_KIP_OFFS_SYS_INVOKE) \
+ --defsym __l4sys_debugger_direct=$(L4_BID_KIP_ADDR)+$(L4_BID_KIP_OFFS_SYS_DEBUGGER) \
-KBUILD_CPPFLAGS += -Iarch/l4/include/asm/l4-arch \
+KBUILD_CPPFLAGS += $(GENODE_INCLUDES) -Iarch/l4/include/asm/l4-arch \
-I$(src)/arch/$(LINSRCARCH)/include \
-Iarch/l4/include/asm/$(LINSRCARCH)-arch \
-Iarch/l4/include/asm/orig-arch \
@@ -342,6 +352,8 @@ ifneq ($(CONFIG_L4_ARCH_ARM),)
KBUILD_CPPFLAGS += -DTEXT_OFFSET=0x0100000
endif
+drivers-y += arch/l4/drivers/
+
all: lImage
boot := arch/l4/boot
@@ -350,11 +362,11 @@ lImage: check_for_l4defs $(if $(CONFIG_L4_SERVER),server) vmlinux
$(Q)$(MAKE) $(build)=$(boot) $@
check_for_l4defs:
- $(Q)if [ ! -e $(L4OBJ)/l4defs.mk.inc ]; then \
- echo "No $(L4OBJ)/l4defs.mk.inc available."; \
- echo "Did you run 'make' in $(L4OBJ) to a successful end?"; \
- exit 1; \
- fi
+# $(Q)if [ ! -e $(L4OBJ)/l4defs.mk.inc ]; then \
+# echo "No $(L4OBJ)/l4defs.mk.inc available."; \
+# echo "Did you run 'make' in $(L4OBJ) to a successful end?"; \
+# exit 1; \
+# fi
server:
$(Q)$(MAKE) $(build)=arch/l4/server
diff --git a/arch/l4/boot/Makefile b/arch/l4/boot/Makefile
index 391b037..afd4c2a 100644
--- a/arch/l4/boot/Makefile
+++ b/arch/l4/boot/Makefile
@@ -10,7 +10,7 @@ $(obj)/Image: vmlinux FORCE
$(call if_changed,objcopy)
@echo ' Kernel: $@ is ready'
-lImage: $(obj)/Image vmlinuz$(VMLINUZ_SUFFIX) l4linux$(VMLINUZ_SUFFIX)
+lImage: $(obj)/Image
vmlinuz$(VMLINUZ_SUFFIX): ldrImage FORCE
$(call if_changed,gzip)
@@ -21,8 +21,8 @@ l4linux$(VMLINUZ_SUFFIX): ldrImage FORCE
objects-y := ldr.o res.o image.o
-include $(L4OBJ)/l4defs.mk.inc
-
+#include $(L4OBJ)/l4defs.mk.inc
+KBUILD_CFLAGS_i386 = -m32
KBUILD_CFLAGS := $(filter-out -mregparm=3,$(KBUILD_CFLAGS)) \
$(L4INC) -I$(L4OBJ)/include/uclibc \
-Wall -fno-strict-aliasing -O2 -pipe \
diff --git a/arch/l4/include/asm/generic/l4lib.h b/arch/l4/include/asm/generic/l4lib.h
index a5711ea..db5d812 100644
--- a/arch/l4/include/asm/generic/l4lib.h
+++ b/arch/l4/include/asm/generic/l4lib.h
@@ -3,6 +3,7 @@
#include <linux/stringify.h>
+#if 0
#ifdef ARCH_arm
#define L4_EXTERNAL_FUNC(func) \
asm(".section \".data.l4externals.str\" \n" \
@@ -58,5 +59,8 @@
".previous \n" \
)
#endif
+#endif
+
+#define L4_EXTERNAL_FUNC(func) ;
#endif /* __INCLUDE__ASM_L4__GENERIC__L4LIB_H__ */
diff --git a/arch/l4/include/asm/l4lxapi/thread.h b/arch/l4/include/asm/l4lxapi/thread.h
index db02c8c..0f75ba9 100644
--- a/arch/l4/include/asm/l4lxapi/thread.h
+++ b/arch/l4/include/asm/l4lxapi/thread.h
@@ -15,6 +15,7 @@
* \ingroup l4lxapi
*/
+void l4lx_thread_alloc_irq(l4_cap_idx_t c);
/**
* \brief Initialize thread handling.
diff --git a/arch/l4/kernel/arch-arm/traps.c b/arch/l4/kernel/arch-arm/traps.c
index d6a3b4f..a44f5eb 100644
--- a/arch/l4/kernel/arch-arm/traps.c
+++ b/arch/l4/kernel/arch-arm/traps.c
@@ -66,6 +66,7 @@ void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long
dump_mem("", "Exception stack", frame + 4, frame + 4 + sizeof(struct pt_regs));
}
+#if 0
#ifndef CONFIG_ARM_UNWIND
/*
* Stack pointers should always be within the kernels view of
@@ -81,6 +82,7 @@ static int verify_stack(unsigned long sp)
return 0;
}
#endif
+#endif
/*
* Dump out the contents of some memory nicely...
@@ -170,6 +172,7 @@ static inline void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
#else
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
{
+#if 0
unsigned int fp, mode;
int ok = 1;
@@ -201,6 +204,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
if (ok)
c_backtrace(fp, mode);
+#endif
}
#endif
diff --git a/arch/l4/kernel/arch-arm/vmlinux.lds.S b/arch/l4/kernel/arch-arm/vmlinux.lds.S
index 169f257..4e25408 100644
--- a/arch/l4/kernel/arch-arm/vmlinux.lds.S
+++ b/arch/l4/kernel/arch-arm/vmlinux.lds.S
@@ -36,6 +36,12 @@ jiffies = jiffies_64;
jiffies = jiffies_64 + 4;
#endif
+PHDRS
+{
+ ro PT_LOAD;
+ rw PT_LOAD;
+}
+
SECTIONS
{
#ifdef CONFIG_XIP_KERNEL
@@ -46,6 +52,19 @@ SECTIONS
.init : { /* Init code and data */
_stext = .;
+ _prog_img_beg = .;
+
+ /*
+ * Leave space for parent capability parameters at start of data
+ * section. The protection domain creator is reponsible for storing
+ * sane values here.
+ */
+ _parent_cap = .;
+ _parent_cap_thread_id = .;
+ LONG(0xffffffff);
+ _parent_cap_local_name = .;
+ LONG(0xffffffff);
+
_sinittext = .;
HEAD_TEXT
INIT_TEXT
@@ -80,7 +99,7 @@ SECTIONS
INIT_DATA
ARM_EXIT_KEEP(EXIT_DATA)
#endif
- }
+ } : rw
PERCPU_SECTION(32)
@@ -126,6 +145,7 @@ SECTIONS
#ifdef CONFIG_MMU
*(.fixup)
#endif
+ *(.text.*) /* put all Genode .text entries in here */
*(.gnu.warning)
*(.rodata)
*(.rodata.*)
@@ -134,7 +154,8 @@ SECTIONS
. = ALIGN(4);
*(.got) /* Global offset table */
ARM_CPU_KEEP(PROC_INFO)
- }
+
+ } : rw
RO_DATA(PAGE_SIZE)
@@ -155,6 +176,42 @@ SECTIONS
}
#endif
+ /*
+ * When building L4Linux for Genode, the 'CONFIG_ARM_UNWIND' option is
+ * disabled to avoid conflicts between unwinding-related symbols provided
+ * by the Linux kernel and the C++ compiler's libsupc++. Hence, the linker
+ * script section above is not used. Instead, the '.ARM.exidx' entries are
+ * handled as follows (taken from the Genode linker script.
+ */
+ /* .ARM.exidx is sorted, so has to go in its own output section */
+ __exidx_start = .;
+ .ARM.exidx : {
+ *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+ }
+ __exidx_end = .;
+
+ .ARM.extab : {
+ *(.ARM.extab*)
+ } : rw
+
+ /* exception frames for C++ */
+ .eh_frame : {
+ __eh_frame_start__ = .;
+ KEEP (*(.eh_frame))
+ LONG(0)
+ } : rw
+
+ .init_array : {
+ __init_array_start = .;
+ _ctors_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+ _ctors_end = .;
+ _dtors_start = .;
+ _dtors_end = .;
+ }
+
_etext = .; /* End of text and rodata section */
#ifdef CONFIG_XIP_KERNEL
@@ -204,8 +261,10 @@ SECTIONS
DATA_DATA
CONSTRUCTORS
+ *(.data.*) /* put all Genode .data entries in here */
+
_edata = .;
- }
+ } : rw
_edata_loc = __data_loc + SIZEOF(.data);
#ifdef CONFIG_HAVE_TCM
@@ -267,10 +326,20 @@ SECTIONS
NOTES
- BSS_SECTION(0, 0, 0)
+ /* BSS */
+ . = ALIGN(PAGE_SIZE);
+ .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
+ __bss_start = .;
+ *(.bss..page_aligned)
+ *(.bss)
+ *(.bss.*) /* put all Genode .bss entries in here */
+ . = ALIGN(4);
+ __bss_stop = .;
+ }
/* L4: Align to full superpage */
. = ALIGN(1048576);
+ _prog_img_end = .;
_end = .;
/* L4: Add NOTES so that .note.gnu.build-id is caught, because we do
diff --git a/arch/l4/kernel/arch-x86/vmlinux.lds.S b/arch/l4/kernel/arch-x86/vmlinux.lds.S
index 42ee2bc..2e1e1db 100644
--- a/arch/l4/kernel/arch-x86/vmlinux.lds.S
+++ b/arch/l4/kernel/arch-x86/vmlinux.lds.S
@@ -33,7 +33,7 @@ OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
#ifdef CONFIG_X86_32
OUTPUT_ARCH(i386)
-ENTRY(phys_startup_32)
+ENTRY(_start)
jiffies = jiffies_64;
#else
OUTPUT_ARCH(i386:x86-64)
@@ -67,17 +67,10 @@ jiffies_64 = jiffies;
#endif
-PHDRS {
- text PT_LOAD FLAGS(5); /* R_E */
- data PT_LOAD FLAGS(6); /* RW_ */
-#ifdef CONFIG_X86_64
- user PT_LOAD FLAGS(5); /* R_E */
-#ifdef CONFIG_SMP
- percpu PT_LOAD FLAGS(6); /* RW_ */
-#endif
- init PT_LOAD FLAGS(7); /* RWE */
-#endif
- note PT_NOTE FLAGS(0); /* ___ */
+PHDRS
+{
+ ro PT_LOAD;
+ rw PT_LOAD;
}
SECTIONS
@@ -97,6 +90,29 @@ SECTIONS
/*_stext = .;*/
.text : AT(ADDR(.text) - LOAD_OFFSET) {
_text = .;
+ _prog_img_beg = .;
+
+ /*
+ * Leave space for parent capability parameters at start of data
+ * section. The protection domain creator is reponsible for storing
+ * sane values here.
+ */
+ _parent_cap = .;
+ _parent_cap_thread_id = .;
+ LONG(0xffffffff);
+ _parent_cap_local_name = .;
+ LONG(0xffffffff);
+
+ /*
+ * Platform-specific entry for Fiasco.OC.
+ *
+ * PIC-code compiled for Fiasco.OC, needs some PIC-compatible
+ * way to enter the kernel, the fixed address of the kernel
+ * entry code address needs to be found here.
+ */
+ __l4sys_invoke_indirect = .;
+ LONG(0xeacff000);
+
/* bootstrapping code */
HEAD_TEXT
#ifdef CONFIG_X86_32
@@ -112,19 +128,55 @@ SECTIONS
ENTRY_TEXT
IRQENTRY_TEXT
*(.fixup)
+ *(.text.*) /* put all Genode .text entries in here */
*(.gnu.warning)
+
+ . = ALIGN(0x08);
+
+ _ctors_start = .;
+ KEEP (*(.ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.init_array)) /* list of constructors specific for ARM eabi */
+ _ctors_end = .;
+ _dtors_start = .;
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ _dtors_end = .;
+
/* End of text section */
_etext = .;
- } :text = 0x9090
+ } : rw
- NOTES :text :note
+ NOTES :rw
- EXCEPTION_TABLE(16) :text = 0x9090
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
#if defined(CONFIG_DEBUG_RODATA)
/* .text should occupy whole number of pages */
. = ALIGN(PAGE_SIZE);
#endif
+
+ /*
+ * because in Genode we collect all data.* entries in the data section
+ * we have to put the per_cpu section before defining the data section
+ * otherwise it's symbols would end up in the data section too.
+ */
+#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
+ PERCPU_SECTION(INTERNODE_CACHE_BYTES)
+#endif
+
+ /*
+ * smp_locks might be freed after init
+ * start/end must be page aligned
+ */
+ . = ALIGN(PAGE_SIZE);
+ .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
+ __smp_locks = .;
+ *(.smp_locks)
+ . = ALIGN(PAGE_SIZE);
+ __smp_locks_end = .;
+ }
+
X64_ALIGN_DEBUG_RODATA_BEGIN
RO_DATA(PAGE_SIZE)
X64_ALIGN_DEBUG_RODATA_END
@@ -152,9 +204,33 @@ SECTIONS
/* rarely changed data like cpu maps */
READ_MOSTLY_DATA(INTERNODE_CACHE_BYTES)
+ *(.data.*) /* put all Genode .data entries in here */
+
+
/* End of data section */
_edata = .;
- } :data
+ } : rw
+
+ EXCEPTION_TABLE(16) : rw
+
+ /* exception frames for C++ */
+ .eh_frame : {
+ __eh_frame_start__ = .;
+ KEEP (*(.eh_frame))
+ LONG(0)
+ } : rw
+
+ .init_array : {
+ __init_array_start = .;
+ KEEP (*(SORT(.init_array.*)))
+ KEEP (*(.init_array))
+ __init_array_end = .;
+ }
+
+ .gcc_except_table : {
+ KEEP(*(.gcc_except_table))
+ KEEP(*(.gcc_except_table.*))
+ }
#ifdef CONFIG_X86_64
@@ -331,10 +407,6 @@ SECTIONS
EXIT_DATA
}
-#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
- PERCPU_SECTION(INTERNODE_CACHE_BYTES)
-#endif
-
. = ALIGN(PAGE_SIZE);
/* freed after init ends here */
@@ -342,18 +414,6 @@ SECTIONS
__init_end = .;
}
- /*
- * smp_locks might be freed after init
- * start/end must be page aligned
- */
- . = ALIGN(PAGE_SIZE);
- .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
- __smp_locks = .;
- *(.smp_locks)
- . = ALIGN(PAGE_SIZE);
- __smp_locks_end = .;
- }
-
#ifdef CONFIG_X86_64
.data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
NOSAVE_DATA
@@ -366,6 +426,7 @@ SECTIONS
__bss_start = .;
*(.bss..page_aligned)
*(.bss)
+ *(.bss.*) /* put all Genode .bss entries in here */
. = ALIGN(PAGE_SIZE);
__bss_stop = .;
}
@@ -378,6 +439,7 @@ SECTIONS
__brk_limit = .;
}
+ _prog_img_end = .;
_end = .;
STABS_DEBUG
diff --git a/arch/l4/kernel/arch-x86/x86_init.c b/arch/l4/kernel/arch-x86/x86_init.c
index f4dec4e..b14e161 100644
--- a/arch/l4/kernel/arch-x86/x86_init.c
+++ b/arch/l4/kernel/arch-x86/x86_init.c
@@ -38,7 +38,7 @@ void iommu_shutdown_noop(void) { }
struct x86_init_ops x86_init __initdata = {
.resources = {
- .probe_roms = probe_roms,
+ .probe_roms = x86_init_noop,
.reserve_resources = reserve_standard_io_resources,
.memory_setup = l4x_memory_setup,
},
diff --git a/arch/l4/kernel/dispatch.c b/arch/l4/kernel/dispatch.c
index 4ef10e4..83e2bc4 100644
--- a/arch/l4/kernel/dispatch.c
+++ b/arch/l4/kernel/dispatch.c
@@ -274,7 +274,7 @@ static int l4x_hybrid_return(struct thread_info *ti,
return 0;
if (l4_msgtag_is_page_fault(tag)) {
- l4x_printf("HYBRID PF!!\n");
+ LOG_printf("HYBRID PF!!\n");
/* No exception IPC, it's a page fault, but shouldn't happen */
goto out_fail;
}
@@ -694,7 +694,7 @@ wait_again:
enter_kdebug("non hybrid in idle?!");
} else {
if (unlikely(l4x_handle_async_event(label, utcb, tag)))
- l4x_printf("Async return with error\n");
+ LOG_printf("Async return with error\n");
}
}
}
diff --git a/arch/l4/kernel/head.S b/arch/l4/kernel/head.S
index 302d211..8a8e96c 100644
--- a/arch/l4/kernel/head.S
+++ b/arch/l4/kernel/head.S
@@ -53,6 +53,7 @@ ENTRY(swapper_pg_dir)
.previous
#endif
+#ifdef NOT_GENODE
#ifdef ARCH_arm
.section ".text"
.globl _start
@@ -82,6 +83,10 @@ __address_l4re_global_env:
__address_l4lx_kinfo:
.long l4lx_kinfo
.previous
+#endif
+#endif /* NOT_GENODE */
+
+#ifdef ARCH_arm
.section .data.head, "wa"
.p2align 12
ENTRY(swapper_pg_dir)
diff --git a/arch/l4/kernel/main.c b/arch/l4/kernel/main.c
index d71a2b9..59c512c 100644
--- a/arch/l4/kernel/main.c
+++ b/arch/l4/kernel/main.c
@@ -305,7 +305,7 @@ static void l4x_configuration_sanity_check(const char *cmdline)
}
#endif
-#ifndef CONFIG_L4_SERIAL
+#if 0 //ndef CONFIG_L4_SERIAL
if (strstr(cmdline, "console=ttyLv")) {
LOG_printf("Console output set to ttyLvx but driver not compiled in.\n");
enter_kdebug("L4 serial driver not enabled");
@@ -363,6 +363,26 @@ static void l4x_virt_to_phys_show(void)
}
}
+static spinlock_t migrate_lock;
+
+void l4x_irq_save(unsigned long flags) { local_irq_save(flags); }
+void l4x_irq_restore(unsigned long flags) { local_irq_restore(flags); }
+unsigned long l4x_hz(void) { return HZ; }
+int l4x_nr_irqs(void) { return NR_IRQS; }
+void l4x_migrate_lock(unsigned long flags) { spin_lock_irqsave(&migrate_lock, flags); }
+void l4x_migrate_unlock(unsigned long flags) { spin_unlock_irqrestore(&migrate_lock, fla
+
+unsigned l4x_target_cpu(const struct cpumask *dest)
+{
+ if (!cpumask_intersects(dest, cpu_online_mask))
+ return (unsigned) -1;
+ return cpumask_any_and(dest, cpu_online_mask);
+}
+
+void l4x_cpumask_copy(struct irq_data *data, const struct cpumask *dest) {
+ cpumask_copy(data->affinity, dest); }
+
+
unsigned long l4x_virt_to_phys(volatile void * address)
{
int i;
@@ -375,14 +395,14 @@ unsigned long l4x_virt_to_phys(volatile void * address)
+ l4x_phys_virt_addrs[i].phys;
}
- l4x_virt_to_phys_show();
+// l4x_virt_to_phys_show();
/* Whitelist: */
/* Debugging check: don't miss a translation, can give nasty
* DMA problems */
- l4x_printf("%s: Could not translate virt. address %p\n",
+ LOG_printf("%s: Could not translate virt. address %p\n",
__func__, address);
- WARN_ON(1);
+// WARN_ON(1);
return __pa(address);
}
@@ -414,7 +434,7 @@ void *l4x_phys_to_virt(unsigned long address)
/* Debugging check: don't miss a translation, can give nasty
* DMA problems */
- l4x_printf("%s: Could not translate phys. address 0x%lx\n",
+ LOG_printf("%s: Could not translate phys. address 0x%lx\n",
__func__, address);
WARN_ON(1);
@@ -532,7 +552,7 @@ int l4x_re_resolve_name(const char *name, l4_cap_idx_t *cap)
r = l4re_ns_query_srv(entry->cap, n + 1, *cap);
if (r) {
- l4x_printf("Failed to query name '%s': %s(%d)\n",
+ LOG_printf("Failed to query name '%s': %s(%d)\n",
name, l4sys_errtostr(r), r);
L4XV_U(f);
return -ENOENT;
@@ -713,6 +733,7 @@ static const int at_exit_nr_of_functions
= sizeof(at_exit_functions) / sizeof(at_exit_functions[0]);
static int __current_exititem;
+#if 0
static struct cxa_atexit_item *__next_atexit(void)
{
if (__current_exititem >= at_exit_nr_of_functions) {
@@ -721,20 +742,9 @@ static struct cxa_atexit_item *__next_atexit(void)
}
return &at_exit_functions[__current_exititem++];
}
+#endif
-int __cxa_atexit(void (*f)(void *), void *arg, void *dso_handle)
-{
- struct cxa_atexit_item *h = __next_atexit();
-
- if (!h)
- return -1;
-
- h->f = f;
- h->arg = arg;
- h->dso_handle = dso_handle;
-
- return 0;
-}
+extern int __cxa_atexit(void (*f)(void *), void *arg, void *dso_handle);
void __cxa_finalize(void *dso_handle)
{
@@ -790,9 +800,19 @@ static inline int l4x_is_writable_area(unsigned long a)
}
static int l4x_forward_pf(l4_umword_t addr, l4_umword_t pc, int extra_write)
{
+#if 0
l4_msgtag_t tag;
l4_umword_t err;
l4_utcb_t *u = l4_utcb();
+#endif
+
+ if (!extra_write)
+ l4_touch_ro((void*)l4_trunc_page(addr), L4_LOG2_PAGESIZE);
+ else
+ l4_touch_rw((void*)l4_trunc_page(addr), L4_LOG2_PAGESIZE);
+
+ // TODO: Reenable this part
+#if 0
do {
l4_msg_regs_t *mr = l4_utcb_mr_u(u);
@@ -815,6 +835,7 @@ static int l4x_forward_pf(l4_umword_t addr, l4_umword_t pc, int extra_write)
// unresolvable page fault, we're supposed to trigger an
// exception
return 0;
+#endif
return 1;
}
@@ -1054,7 +1075,7 @@ static void l4x_register_pointer_section(void *p_in_addr,
addr = (l4_addr_t)p_in_addr;
size = 1;
if (l4re_rm_find(&addr, &size, &off, &flags, &ds)) {
- LOG_printf("Cannot anything at %p?!", p_in_addr);
+ LOG_printf("Cannot anything at %p\n?!", p_in_addr);
l4re_rm_show_lists();
enter_kdebug("l4re_rm_find failed");
return;
@@ -1254,7 +1275,7 @@ void __init l4x_setup_memory(char *cmdl,
0, "Main memory");
/* Reserve some part of the virtual address space for vmalloc */
- l4x_vmalloc_memory_start = (unsigned long)l4x_main_memory_start;
+ l4x_vmalloc_memory_start = (unsigned long)l4x_main_memory_start + l4x_mainmem_size;
if (l4re_rm_reserve_area(&l4x_vmalloc_memory_start,
#ifdef CONFIG_X86_32
__VMALLOC_RESERVE,
@@ -1381,6 +1402,10 @@ unsigned long l4x_get_isa_dma_memory_end(void)
static void l4x_create_ugate(l4_cap_idx_t forthread, unsigned cpu)
{
+ LOG_printf("thread=%lx cpu=%x\n", forthread, cpu);
+ l4x_user_gate[cpu] = forthread;
+
+#if 0
l4_msgtag_t r;
l4x_user_gate[cpu] = l4x_cap_alloc();
@@ -1401,6 +1426,7 @@ static void l4x_create_ugate(l4_cap_idx_t forthread, unsigned cpu)
l4_debugger_set_object_name(l4x_user_gate[cpu], n);
#endif
}
+#endif
}
#ifdef CONFIG_HOTPLUG_CPU
@@ -1607,11 +1633,15 @@ void l4x_cpu_ipi_setup(unsigned cpu)
l4x_exit_l4linux();
}
+#if 0
t = l4_factory_create_irq(l4re_env()->factory, c);
if (l4_error(t)) {
LOG_printf("Failed to create IRQ\n");
l4x_exit_l4linux();
}
+#else
+ l4lx_thread_alloc_irq(c);
+#endif
#ifdef CONFIG_L4_DEBUG_REGISTER_NAMES
l4_debugger_set_object_name(c, s);
@@ -1890,11 +1920,11 @@ static inline void l4x_repnop_init(void) {}
static int l4x_cpu_virt_phys_map_init(const char *boot_command_line)
{
- l4_umword_t max_cpus = 1;
- l4_sched_cpu_set_t cs = l4_sched_cpu_set(0, 0, 0);
unsigned i;
#ifdef CONFIG_SMP
+ l4_umword_t max_cpus = 1;
+ l4_sched_cpu_set_t cs = l4_sched_cpu_set(0, 0, 0);
char overbooking = 0;
char *p;
@@ -1907,9 +1937,10 @@ static int l4x_cpu_virt_phys_map_init(const char *boot_command_line)
}
}
-
+#if 0
if (l4_error(l4_scheduler_info(l4re_env()->scheduler,
&max_cpus, &cs)) == L4_EOK) {
+#endif
if ((p = strstr(boot_command_line, "l4x_cpus_map="))) {
// l4x_cpus_map=0,1,2,3,4,...
// the list specifies the physical CPU for each
@@ -1958,12 +1989,16 @@ static int l4x_cpu_virt_phys_map_init(const char *boot_command_line)
l4x_nr_cpus = v;
}
+#if 0
}
+#endif
#ifndef CONFIG_L4_VCPU
l4x_tamed_set_mapping(0, l4x_cpu_physmap_get_id(0));
#endif
#else /* UP */
+
+#if 0
if (l4_error(l4_scheduler_info(l4re_env()->scheduler,
&max_cpus, &cs)) == L4_EOK) {
@@ -1973,6 +2008,8 @@ static int l4x_cpu_virt_phys_map_init(const char *boot_command_line)
l4x_cpu_physmap[0].phys_id = p;
}
#endif
+ l4x_cpu_physmap[0].phys_id = 0;
+#endif
LOG_printf("CPU mapping (l:p)[%d]: ", l4x_nr_cpus);
for (i = 0; i < l4x_nr_cpus; i++)
@@ -2018,6 +2055,7 @@ static long l4x_blink(int state)
printk("panic: going to sleep forever, bye\n");
L4XV_L(f);
LOG_printf("panic: going to sleep forever, bye\n");
+ enter_kdebug("PANIC");
l4_sleep_forever();
return 0;
}
@@ -2298,7 +2336,7 @@ static void l4x_scan_hw_resources(void)
}
}
-int __init_refok L4_CV main(int argc, char **argv)
+int __init_refok L4_CV linux_main(int argc, char **argv)
{
l4lx_thread_t main_id;
extern char _end[];
@@ -2410,10 +2448,13 @@ int __init_refok L4_CV main(int argc, char **argv)
l4x_start_thread_id = l4re_env()->main_thread;
+#if 0
l4_thread_control_start();
l4_thread_control_commit(l4x_start_thread_id);
l4x_start_thread_pager_id
= l4_utcb_mr()->mr[L4_THREAD_CONTROL_MR_IDX_PAGER];
+#endif
+ l4x_start_thread_pager_id = l4re_env()->rm;
#ifndef CONFIG_L4_VCPU
#ifdef CONFIG_L4_TAMED
@@ -3180,6 +3221,10 @@ static inline int l4x_handle_pagefault(unsigned long pfa, unsigned long ip,
/* Not resolvable: Ooops */
LOG_printf("Non-resolvable page fault at %lx, ip %lx.\n", pfa, ip);
// will trigger an oops in caller
+
+#ifdef CONFIG_L4_DEBUG_SEGFAULTS
+ enter_kdebug("PF");
+#endif
return 0;
}
@@ -3560,7 +3605,9 @@ module_init(l4x_power_mgmt_init);
void exit(int code)
{
__cxa_finalize(0);
+#if 0
l4x_external_exit(code);
+#endif
LOG_printf("Still alive, going zombie???\n");
l4_sleep_forever();
}
diff --git a/arch/l4/lib/pte.c b/arch/l4/lib/pte.c
index f59bf94..858f668 100644
--- a/arch/l4/lib/pte.c
+++ b/arch/l4/lib/pte.c
@@ -19,6 +19,9 @@
#include <l4/sys/task.h>
#include <l4/sys/kdebug.h>
#include <l4/re/consts.h>
+#include <l4/log/log.h>
+
+extern void l4lx_memory_map_physical_page(unsigned long address);
static void l4x_flush_page(struct mm_struct *mm,
unsigned long address,
@@ -78,7 +81,7 @@ static void l4x_flush_page(struct mm_struct *mm,
if (mm && !l4_is_invalid_cap(mm->context.task)) {
L4XV_V(f);
if (!mm->context.task)
- l4x_printf("%s: Ups, task == 0\n", __func__);
+ LOG_printf("%s: Ups, task == 0\n", __func__);
/* Direct flush in the child, use virtual address in the
* child address space */
L4XV_L(f);
@@ -94,10 +97,11 @@ static void l4x_flush_page(struct mm_struct *mm,
tag = l4_task_unmap(L4RE_THIS_TASK_CAP,
l4_fpage(address & PAGE_MASK, size, flush_rights),
L4_FP_OTHER_SPACES);
+ l4lx_memory_map_physical_page(address);
L4XV_U(f);
}
if (l4_error(tag))
- l4x_printf("l4_task_unmap error %ld\n", l4_error(tag));
+ LOG_printf("l4_task_unmap error %ld\n", l4_error(tag));
}
#ifdef ARCH_arm
diff --git a/drivers/tty/serial/l4ser.c b/drivers/tty/serial/l4ser.c
index 3efd8ea..faa72bd 100644
--- a/drivers/tty/serial/l4ser.c
+++ b/drivers/tty/serial/l4ser.c
@@ -22,10 +22,12 @@
#include <linux/serial.h>
#include <l4/sys/vcon.h>
+#include <l4/sys/kdebug.h>
#include <l4/sys/factory.h>
#include <l4/sys/icu.h>
#include <l4/re/c/namespace.h>
#include <l4/re/c/util/cap.h>
+#include <l4/log/log.h>
#include <asm/generic/setup.h>
#include <asm/generic/cap_alloc.h>
#include <asm/generic/util.h>
@@ -135,7 +137,10 @@ static void l4ser_tx_chars(struct uart_port *port)
if (port->x_char) {
L4XV_L(f);
+#if 0
l4_vcon_write(l4port->vcon_cap, &port->x_char, 1);
+#endif
+ LOG_printf("%c", port->x_char);
L4XV_U(f);
port->icount.tx++;
port->x_char = 0;
@@ -147,7 +152,14 @@ static void l4ser_tx_chars(struct uart_port *port)
if (c > L4_VCON_WRITE_SIZE)
c = L4_VCON_WRITE_SIZE;
L4XV_L(f);
+#if 0
l4_vcon_write(l4port->vcon_cap, &xmit->buf[xmit->tail], c);
+#endif
+ char *ptr = (char*)&xmit->buf[xmit->tail], old = ptr[c];
+ ptr[c] = 0;
+ LOG_printf("%s", ptr);
+ ptr[c] = old;
+
L4XV_U(f);
xmit->tail = (xmit->tail + c) & (UART_XMIT_SIZE - 1);
port->icount.tx += c;
@@ -267,7 +279,7 @@ static int __init l4ser_init_port(int num, const char *name)
if (l4ser_port[num].inited)
return 0;
l4ser_port[num].inited = 1;
-
+#if 0
if ((r = l4x_re_resolve_name(name, &l4ser_port[num].vcon_cap))) {
if (num == 0)
l4ser_port[num].vcon_cap = l4re_env()->log;
@@ -308,11 +320,13 @@ static int __init l4ser_init_port(int num, const char *name)
L4XV_U(f);
return -EIO;
}
-
+#endif
vcon_attr.i_flags = 0;
vcon_attr.o_flags = 0;
vcon_attr.l_flags = 0;
+#if 0
l4_vcon_set_attr(l4ser_port[num].vcon_cap, &vcon_attr);
+#endif
L4XV_U(f);
l4ser_port[num].port.uartclk = 3686400;
@@ -356,7 +370,14 @@ l4ser_console_write(struct console *co, const char *s, unsigned int count)
if (c > L4_VCON_WRITE_SIZE)
c = L4_VCON_WRITE_SIZE;
L4XV_L(f);
+#if 0
l4_vcon_write(l4ser_port[co->index].vcon_cap, s, c);
+#endif
+ char *ptr = (char*)s, old = ptr[c];
+ ptr[c] = 0;
+ LOG_printf("%s", ptr);
+ ptr[c] = old;
+
L4XV_U(f);
count -= c;
} while (count);
@@ -403,6 +424,7 @@ static int __init l4ser_serial_init(void)
int ret, i;
printk(KERN_INFO "L4 serial driver\n");
+ LOG_printf("L4 serial driver\n");
if (l4ser_init_port(0, PORT0_NAME))
return -ENODEV;