Browse Source

Initial support for Leon3 platform.

Ioannis Koutras 13 years ago
parent
commit
e619ebe5ab

+ 14 - 0
DefineOptions.cmake

@@ -19,6 +19,7 @@ set(BLOCKS_ORGANIZATION "sll" "Blocks organized in singly linked lists")
 option(WITH_OWNERSHIP "Build with ownership information in blocks" OFF)
 
 option(P2012 "Build for P2012 runtime" OFF)
+option(LEON3 "Build for Leon3" OFF)
 option(LINUXTEST "Build a case for Linux" ON) 
 
 if (P2012)
@@ -34,6 +35,19 @@ if (P2012)
   set(BLOCKS_ORGANIZATION "sll")
 endif (P2012)
 
+if (LEON3)
+  set(HAVE_LOCKS OFF)
+  set(WITH_MEMORY_SPACE_AWARENESS ON)
+  set(WITH_STATIC_LIB ON)
+  set(NUM_HEAPS 1)
+  set(LINUXTEST OFF)
+  set(WITH_FIXED_LISTS OFF)
+  set(WITH_STATS OFF)
+  set(WITH_COALESCING "never")
+  set(WITH_SPLITTING "never")
+  set(BLOCKS_ORGANIZATION "sll")
+endif (LEON3)
+
 if (LINUXTEST)
   set(HAVE_LOCKS ON)
   set(WITH_EXAMPLES ON)

+ 2 - 0
dmm_config.h.in

@@ -1,6 +1,8 @@
 #ifndef DMM_CONFIG_H
 #define DMM_CONFIG_H
 
+#cmakedefine LEON3
+
 #cmakedefine HAVE_LOCKS
 #cmakedefine WITH_MEMORY_SPACE_AWARENESS
 

+ 1 - 1
examples/CMakeLists.txt

@@ -14,7 +14,7 @@ endif (HAVE_LOCKS)
 
 if (WITH_MEMORY_SPACE_AWARENESS)
   add_executable(test_for_memory_space_aware test_for_memory_space_aware.c)
-  target_link_libraries(test_for_memory_space_aware ${DMMLIB_SHARED_LIBRARY})
+  target_link_libraries(test_for_memory_space_aware ${DMMLIB_STATIC_LIBRARY})
 else (WITH_MEMORY_SPACE_AWARENESS)
   add_executable(test test.c)
   target_link_libraries(test ${DMMLIB_SHARED_LIBRARY})

+ 14 - 0
include/dmmlib/heap.h

@@ -27,14 +27,19 @@
 
 #include "dmm_config.h"
 
+#ifndef LEON3
 #include <stdint.h>
 #include <stddef.h> /* For size_t support */
 #include <stdbool.h>
+#else
+#include <sys/types.h>
+#endif
 
 #ifdef HAVE_LOCKS
 #include <pthread.h>
 #endif /* HAVE_LOCKS */
 
+#ifdef WITH_KNOBS
 /**
  * A structure for knobs states (currently 5)
  * 
@@ -42,6 +47,7 @@
  *
  * */
 typedef uint8_t knob_state_t;
+#endif /* WITH_KNOBS */
 
 /** A structure to represent a maptable node. */
 typedef struct maptable_node_s {
@@ -95,7 +101,11 @@ typedef struct heap_s {
 	void *free_list_head; /**< The head of the free list. */
 	void *used_blocks_head; /**< The head of the used blocks list. */
 	void *rov_ptr; /**< Roving pointer. */
+#ifndef LEON3
 	uint64_t num_objects; /**< Number of objects in the heap. */
+#else
+	unsigned long num_objects; /**< Number of objects in the heap. */
+#endif /* LEON3 */
 #ifdef WITH_STATS
 	dmmstats_t dmm_stats; /**< Statistics of the heap. */
 #endif /* WITH_STATS */
@@ -110,7 +120,11 @@ typedef struct heap_s {
 /** The allocator structure of dmmlib. */
 typedef struct allocator_s {
 	heap_t heaps[NUM_HEAPS]; /**< The heaps that the allocator manages. */
+#ifndef LEON3
 	bool initialized; /**< Initialization flag of the allocator. */
+#else
+	char initialized; /**< Initialization flag of the allocator. */
+#endif /* LEON3 */
 	void *border_ptr; /**< Border pointer of the allocator. */
 #ifdef WITH_MEMORY_SPACE_AWARENESS
 	size_t remaining_size; /**< The size of the remaining free space which

+ 9 - 1
private-include/linked_lists/linked_lists.h

@@ -26,11 +26,19 @@
 #ifndef LINKED_LISTS_H
 #define LINKED_LISTS_H
 
-#include <stdint.h>
 #include "dmm_config.h"
+#ifndef LEON3
+#include <stdint.h>
+#else
+#include <sys/types.h>
+#endif
 
 /** The type of the pointer to a list node */
+#ifndef LEON3
 typedef uintptr_t list_node_ptr;
+#else
+typedef void* list_node_ptr;
+#endif /* LEON3 */
 
 /** The header structure of a linked list node */
 typedef struct list_node_header_s {

+ 4 - 0
src/custom_malloc.c

@@ -46,7 +46,11 @@ void * custom_ahmalloc(allocator_t* allocator, heap_t* heap, size_t size) {
     /* Go to the system allocator if none was given */
     if(allocator == NULL) {
         allocator = &systemallocator;
+#ifndef LEON3
         if(allocator->initialized != true) {
+#else
+        if(allocator->initialized != '1') {
+#endif /* LEON3 */
             initialize_allocator(allocator);
         }
     }

+ 4 - 0
src/initialize_allocator.c

@@ -86,7 +86,11 @@ void initialize_allocator(allocator_t *allocator) {
     allocator->border_ptr = starting_address;
     allocator->remaining_size = size;
 #endif /* WITH_MEMORY_SPACE_AWARENESS */
+#ifndef LEON3
     allocator->initialized = false;
+#else
+    allocator->initialized = '0';
+#endif /* LEON3 */
 
 #ifdef WITH_FIXED_LISTS
 

+ 8 - 0
src/sys_alloc.c

@@ -52,14 +52,22 @@ void *sys_alloc(allocator_t *allocator, heap_t *heap, size_t size) {
     /* Note: border_ptr has already a value in memory space aware allocators,
      * so in this case we have to check also the initialized value.
      */
+#ifndef LEON3
     if(allocator->border_ptr != NULL && allocator->initialized) {
+#else
+    if(allocator->border_ptr != NULL && allocator->initialized == '1') {
+#endif /* LEON3 */
 #endif /* WITH_MEMORY_SPACE_AWARENESS */
         previous_size = get_size(allocator->border_ptr);
         previous_size_availability = get_size_availability(allocator->border_ptr);
     } else {
         previous_size = 0;
         previous_size_availability = 1; /* Occupied and of 0 size */
+#ifndef LEON3
         allocator->initialized = true;
+#else
+        allocator->initialized = '1';
+#endif /* LEON3 */
     }
 
 #ifndef WITH_MEMORY_SPACE_AWARENESS

+ 26 - 0
toolchain-sparc-elf.cmake

@@ -0,0 +1,26 @@
+include(CMakeForceCompiler)
+
+SET(CMAKE_SYSTEM_NAME SPARC-ELF)
+
+# The environment variables should be already set
+# in order to do proper cross compiling
+CMAKE_FORCE_C_COMPILER(sparc-elf-gcc GNU)
+CMAKE_FORCE_CXX_COMPILER(sparc-elf-g++ GNU)
+
+set (CMAKE_C_FLAGS $ENV{CFLAGS}) 
+set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS $ENV{LDFLAGS})
+
+set (CMAKE_AR sparc-elf-ar)
+set (CMAKE_RANLIB sparc-elf-ranlib)
+
+SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> <LINK_FLAGS> cr <TARGET> <OBJECTS>")
+SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
+
+# search for programs in the build host directories
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+# for libraries and headers in the target directories
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
+
+set(CMAKE_BUILD_TYPE Release)
+