Patch for libcpu, introducing CPU models 'native' and 'virtual' and
implementing functions removed from score.
diff --git a/c/src/lib/libcpu/i386/Makefile.am b/c/src/lib/libcpu/i386/Makefile.am
index 0330ba3..93e83db 100644
--- a/c/src/lib/libcpu/i386/Makefile.am
+++ b/c/src/lib/libcpu/i386/Makefile.am
@@ -4,12 +4,51 @@ noinst_PROGRAMS =
include $(top_srcdir)/../../../automake/compile.am
+if VIRT_POK
+
+
+# TODO insert virt_pok cpu includes here
+include_libcpudir = $(includedir)/libcpu
+
+include_libcpu_HEADERS = cpu.h cpuModel.h
+include_libcpu_HEADERS += ../shared/include/cache.h
+include_libcpu_HEADERS += byteorder.h
+
+include_libcpu_HEADERS += virtual/include/rtems/score/interrupts.h
+include_libcpu_HEADERS += virtual/include/cpu-score-split.h
+
+noinst_PROGRAMS += cache.rel
+cache_rel_SOURCES = cache.c cache_.h ../shared/src/cache_aligned_malloc.c \
+ ../shared/src/cache_manager.c ../shared/include/cache.h
+cache_rel_CPPFLAGS = $(AM_CPPFLAGS)
+cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+noinst_PROGRAMS += score.rel
+score_rel_SOURCES = displayCpu.c cpuModel.S cpuModel.h idtr.S cpu.h
+score_rel_SOURCES += virtual/cpu-score-split.c
+score_rel_CPPFLAGS = $(AM_CPPFLAGS)
+score_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+noinst_PROGRAMS += page.rel
+page_rel_SOURCES = page.c cpu.h
+page_rel_CPPFLAGS = $(AM_CPPFLAGS)
+page_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+
+
+else # native
+
+
+
include_libcpudir = $(includedir)/libcpu
include_libcpu_HEADERS = cpu.h cpuModel.h
include_libcpu_HEADERS += ../shared/include/cache.h
include_libcpu_HEADERS += byteorder.h
+include_libcpu_HEADERS += native/include/rtems/score/interrupts.h
+include_libcpu_HEADERS += native/include/cpu-score-split.h
+
noinst_PROGRAMS += cache.rel
cache_rel_SOURCES = cache.c cache_.h ../shared/src/cache_aligned_malloc.c \
../shared/src/cache_manager.c ../shared/include/cache.h
@@ -18,6 +57,7 @@ cache_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
noinst_PROGRAMS += score.rel
score_rel_SOURCES = displayCpu.c cpuModel.S cpuModel.h idtr.S cpu.h
+score_rel_SOURCES += native/cpu-score-split.c
score_rel_CPPFLAGS = $(AM_CPPFLAGS)
score_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
@@ -26,5 +66,9 @@ page_rel_SOURCES = page.c cpu.h
page_rel_CPPFLAGS = $(AM_CPPFLAGS)
page_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
+
+
+endif
+
include $(srcdir)/preinstall.am
include $(top_srcdir)/../../../automake/local.am
diff --git a/c/src/lib/libcpu/i386/configure.ac b/c/src/lib/libcpu/i386/configure.ac
index 5bc68c1..25e49e0 100644
--- a/c/src/lib/libcpu/i386/configure.ac
+++ b/c/src/lib/libcpu/i386/configure.ac
@@ -2,6 +2,7 @@
AC_PREREQ([2.69])
AC_INIT([rtems-c-src-lib-libcpu-i386],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
+# TODO check ac_config_srcdir cpuModel.h -- replacement necessary?
AC_CONFIG_SRCDIR([cpuModel.h])
RTEMS_TOP([../../../../..],[../../..])
@@ -19,6 +20,9 @@ AM_PROG_CC_C_O
RTEMS_CANONICALIZE_TOOLS
RTEMS_PROG_CCAS
+AM_CONDITIONAL([VIRT_POK],[test x"$RTEMS_CPU_MODEL" = x"virt-pok"])
+
+
RTEMS_AMPOLISH3
# Explicitly list all Makefiles here
diff --git a/c/src/lib/libcpu/i386/cpu.h b/c/src/lib/libcpu/i386/cpu.h
index a14ed46..1b39194 100644
--- a/c/src/lib/libcpu/i386/cpu.h
+++ b/c/src/lib/libcpu/i386/cpu.h
@@ -26,7 +26,7 @@
/*
* Interrupt Level Macros
*/
-#include <rtems/score/interrupts.h>
+#include <libcpu/interrupts.h>
/*
* Segment Access Routines
diff --git a/c/src/lib/libcpu/i386/native/cpu-score-split.c b/c/src/lib/libcpu/i386/native/cpu-score-split.c
new file mode 100644
index 0000000..cdb95cb
--- /dev/null
+++ b/c/src/lib/libcpu/i386/native/cpu-score-split.c
@@ -0,0 +1,39 @@
+/**
+ * @file
+ *
+ * @brief Virtualization Sensitive Intel i386 Dependent Source
+ *
+ * Part of cpu.c that must be replaced with a virtualization acceptable way to
+ * idle. On i386 "hlt" is used, which is priviledged and causes a GPF.
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <rtems/score/cpu.h> // function definition
+
+
+
+/**
+ * @brief Idle thread executes idle operation
+ *
+ * If used in a virtualized environment, this executes a call to the
+ * virtualization layer.
+ */
+
+void *_CPU_Thread_Idle_body( uintptr_t ignored )
+{
+ while(1)
+ {
+ __asm__ volatile ("hlt");
+ }
+ return NULL;
+}
+
+
+#ifdef __cpluplus
+}
+#endif
diff --git a/c/src/lib/libcpu/i386/native/include/cpu-score-split.h b/c/src/lib/libcpu/i386/native/include/cpu-score-split.h
new file mode 100644
index 0000000..8f24349
--- /dev/null
+++ b/c/src/lib/libcpu/i386/native/include/cpu-score-split.h
@@ -0,0 +1,62 @@
+/**
+ * @file
+ *
+ * @brief Virtualized Sensitive Intel I386 CPU Dependent Source
+ *
+ * This include file contains information for the virtualized i386
+ * architecture.
+ */
+
+#ifndef _RTEMS_LIBCPU_CPU_H
+#define _RTEMS_LIBCPU_CPU_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/i386.h>
+
+
+
+#ifndef ASM
+/*
+ * ISR handler macros
+ *
+ * These macros perform the following functions:
+ * + set a particular level
+ */
+
+
+#define _CPU_ISR_Set_level( _new_level ) \
+ { \
+ if ( _new_level ) __asm__ volatile ( "cli" ); \
+ else __asm__ volatile ( "sti" ); \
+ }
+
+
+
+/*
+ * Fatal Error manager macros
+ *
+ * These macros perform the following functions:
+ * + disable interrupts and halt the CPU
+ */
+
+#define _CPU_Fatal_halt( _error ) \
+ { \
+ __asm__ volatile ( "cli ; \
+ movl %0,%%eax ; \
+ hlt" \
+ : "=r" ((_error)) : "0" ((_error)) \
+ ); \
+ }
+
+#endif /* ASM */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _RTEMS_LIBCPU_CPU_H */
diff --git a/c/src/lib/libcpu/i386/native/include/rtems/score/interrupts.h b/c/src/lib/libcpu/i386/native/include/rtems/score/interrupts.h
new file mode 100644
index 0000000..bed6330
--- /dev/null
+++ b/c/src/lib/libcpu/i386/native/include/rtems/score/interrupts.h
@@ -0,0 +1,81 @@
+/**
+ * @file
+ *
+ * @brief Intel I386 Interrupt Macros
+ *
+ * Formerly contained in and extracted from libcpu/i386/cpu.h
+ */
+
+/*
+ * COPYRIGHT (c) 1998 [email protected]
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * Applications must not include this file directly.
+ */
+
+#ifndef _RTEMS_SCORE_INTERRUPTS_H
+#define _RTEMS_SCORE_INTERRUPTS_H
+
+#ifndef ASM
+
+struct __rtems_raw_irq_connect_data__;
+
+typedef void (*rtems_raw_irq_hdl) (void);
+typedef void (*rtems_raw_irq_enable) (const struct __rtems_raw_irq_connect_data__*);
+typedef void (*rtems_raw_irq_disable) (const struct __rtems_raw_irq_connect_data__*);
+typedef int (*rtems_raw_irq_is_enabled) (const struct __rtems_raw_irq_connect_data__*);
+
+/**
+ * @name Interrupt Level Macros
+ *
+ */
+/**@{**/
+
+#define i386_disable_interrupts( _level ) \
+ { \
+ __asm__ volatile ( "pushf ; \
+ cli ; \
+ pop %0" \
+ : "=rm" ((_level)) \
+ ); \
+ }
+
+#define i386_enable_interrupts( _level ) \
+ { \
+ __asm__ volatile ( "push %0 ; \
+ popf" \
+ : : "rm" ((_level)) : "cc" \
+ ); \
+ }
+
+#define i386_flash_interrupts( _level ) \
+ { \
+ __asm__ volatile ( "push %0 ; \
+ popf ; \
+ cli" \
+ : : "rm" ((_level)) : "cc" \
+ ); \
+ }
+
+#define i386_get_interrupt_level( _level ) \
+ do { \
+ register uint32_t _eflags; \
+ \
+ __asm__ volatile ( "pushf ; \
+ pop %0" \
+ : "=rm" ((_eflags)) \
+ ); \
+ \
+ _level = (_eflags & EFLAGS_INTR_ENABLE) ? 0 : 1; \
+ } while (0)
+
+#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level )
+#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level )
+
+/** @} */
+
+#endif
+#endif
diff --git a/c/src/lib/libcpu/i386/preinstall.am b/c/src/lib/libcpu/i386/preinstall.am
index 6f4af52..c749294 100644
--- a/c/src/lib/libcpu/i386/preinstall.am
+++ b/c/src/lib/libcpu/i386/preinstall.am
@@ -13,6 +13,7 @@ all-am: $(PREINSTALL_FILES)
PREINSTALL_FILES =
CLEANFILES = $(PREINSTALL_FILES)
+if VIRT_POK
$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
@$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
@: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
@@ -34,3 +35,41 @@ $(PROJECT_INCLUDE)/libcpu/byteorder.h: byteorder.h $(PROJECT_INCLUDE)/libcpu/$(d
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/byteorder.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/byteorder.h
+$(PROJECT_INCLUDE)/libcpu/interrupts.h: virtual/include/rtems/score/interrupts.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/interrupts.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/interrupts.h
+
+$(PROJECT_INCLUDE)/libcpu/cpu-score-split.h: virtual/include/cpu-score-split.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cpu-score-split.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cpu-score-split.h
+
+else # native
+$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
+ @$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
+ @: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+
+$(PROJECT_INCLUDE)/libcpu/cpu.h: cpu.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cpu.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cpu.h
+
+$(PROJECT_INCLUDE)/libcpu/cpuModel.h: cpuModel.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cpuModel.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cpuModel.h
+
+$(PROJECT_INCLUDE)/libcpu/cache.h: ../shared/include/cache.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cache.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cache.h
+
+$(PROJECT_INCLUDE)/libcpu/byteorder.h: byteorder.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/byteorder.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/byteorder.h
+
+$(PROJECT_INCLUDE)/libcpu/interrupts.h: native/include/rtems/score/interrupts.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/interrupts.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/interrupts.h
+
+$(PROJECT_INCLUDE)/libcpu/cpu-score-split.h: native/include/cpu-score-split.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/cpu-score-split.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/cpu-score-split.h
+endif
diff --git a/c/src/lib/libcpu/i386/virtual/cpu-score-split.c b/c/src/lib/libcpu/i386/virtual/cpu-score-split.c
new file mode 100644
index 0000000..9848d6f
--- /dev/null
+++ b/c/src/lib/libcpu/i386/virtual/cpu-score-split.c
@@ -0,0 +1,39 @@
+/**
+ * @file
+ *
+ * @brief Virtualization Sensitive Intel i386 Dependent Source
+ *
+ * Part of cpu.c that must be replaced with a virtualization acceptable way to
+ * idle. On i386 "hlt" is used, which is priviledged and causes a GPF.
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <rtems/score/cpu.h> // function definition
+#include <virtLayerCPU.h>
+
+
+/**
+ * @brief Idle thread executes idle operation
+ *
+ * If used in a virtualized environment, this executes a call to the
+ * virtualization layer.
+ */
+
+void *_CPU_Thread_Idle_body( uintptr_t ignored )
+{
+ while(1)
+ {
+ virt_idleThread();
+ }
+ return NULL;
+}
+
+
+#ifdef __cpluplus
+}
+#endif
diff --git a/c/src/lib/libcpu/i386/virtual/include/cpu-score-split.h b/c/src/lib/libcpu/i386/virtual/include/cpu-score-split.h
new file mode 100644
index 0000000..605eaf3
--- /dev/null
+++ b/c/src/lib/libcpu/i386/virtual/include/cpu-score-split.h
@@ -0,0 +1,63 @@
+/**
+ * @file
+ *
+ * @brief Virtualized Sensitive Intel I386 CPU Dependent Source
+ *
+ * This include file contains information for the virtualized i386
+ * architecture.
+ *
+ * Author: Philipp Eppelt
+ * Date: 06/19/2013
+ */
+
+#ifndef _RTEMS_LIBCPU_CPU_H
+#define _RTEMS_LIBCPU_CPU_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/score/i386.h>
+#include <virtLayerCPU.h>
+
+
+
+#ifndef ASM
+/*
+ * ISR handler macros
+ *
+ * These macros perform the following functions:
+ * + set a particular level
+ */
+
+
+#define _CPU_ISR_Set_level( _new_level ) \
+ { \
+ if ( _new_level ) virt_closeInterrupts(); \
+ else virt_openInterrupts(); \
+ }
+
+
+
+/*
+ * Fatal Error manager macros
+ *
+ * These macros perform the following functions:
+ * + disable interrupts and halt the CPU
+ */
+
+#define _CPU_Fatal_halt( _error ) \
+ { \
+ virt_closeInterrupts(); \
+ virt_execStopError( _error ); \
+ }
+
+#endif /* ASM */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _RTEMS_LIBCPU_CPU_H */
diff --git a/c/src/lib/libcpu/i386/virtual/include/rtems/score/interrupts.h b/c/src/lib/libcpu/i386/virtual/include/rtems/score/interrupts.h
new file mode 100644
index 0000000..522306a
--- /dev/null
+++ b/c/src/lib/libcpu/i386/virtual/include/rtems/score/interrupts.h
@@ -0,0 +1,67 @@
+/**
+ * @file
+ *
+ * @brief Intel I386 Interrupt Macros
+ *
+ * Formerly contained in and extracted from libcpu/i386/cpu.h
+ */
+
+/*
+ * COPYRIGHT (c) 1998 [email protected]
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * Applications must not include this file directly.
+ */
+
+#ifndef _RTEMS_SCORE_INTERRUPTS_H
+#define _RTEMS_SCORE_INTERRUPTS_H
+
+#ifndef ASM
+
+struct __rtems_raw_irq_connect_data__;
+
+typedef void (*rtems_raw_irq_hdl) (void);
+typedef void (*rtems_raw_irq_enable) (const struct __rtems_raw_irq_connect_data__*);
+typedef void (*rtems_raw_irq_disable) (const struct __rtems_raw_irq_connect_data__*);
+typedef int (*rtems_raw_irq_is_enabled) (const struct __rtems_raw_irq_connect_data__*);
+
+#include <virtLayerCPU.h>
+
+
+/**
+ * @name Interrupt Level Macros
+ *
+ */
+/**@{**/
+
+#define i386_disable_interrupts( _level ) \
+ { \
+ virt_disableInterrupts( _level ); \
+ }
+
+#define i386_enable_interrupts( _level ) \
+ { \
+ virt_enableInterrupts( _level ); \
+ }
+
+#define i386_flash_interrupts( _level ) \
+ { \
+ virt_enableInterrupts(_level); \
+ virt_disableInterrupts(_level); \
+ }
+
+#define i386_get_interrupt_level( _level ) \
+ { \
+ virt_getInterruptLevel( _level ); \
+ }
+
+#define _CPU_ISR_Disable( _level ) i386_disable_interrupts( _level )
+#define _CPU_ISR_Enable( _level ) i386_enable_interrupts( _level )
+
+/** @} */
+
+#endif
+#endif
_______________________________________________
rtems-devel mailing list
[email protected]
http://www.rtems.org/mailman/listinfo/rtems-devel