Sfoglia il codice sorgente

RTX5: updated Memory module (8-byte alignment)

Robert Rostohar 9 anni fa
parent
commit
3ba848805b

+ 2 - 2
CMSIS/RTOS2/RTX/Config/RTX_Config.c

@@ -210,7 +210,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MEMPOOL_NUM              1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0
@@ -232,7 +232,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MSGQUEUE_NUM             1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0

+ 2 - 2
CMSIS/RTOS2/RTX/Examples/Simulation/RTX5_Blinky/RTE/CMSIS/RTX_Config.c

@@ -210,7 +210,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MEMPOOL_NUM              1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0
@@ -232,7 +232,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MSGQUEUE_NUM             1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0

+ 2 - 2
CMSIS/RTOS2/RTX/Examples/TrustZoneV8M/RTOS/CM33_ns/RTE/CMSIS/RTX_Config.c

@@ -210,7 +210,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MEMPOOL_NUM              1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0
@@ -232,7 +232,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MSGQUEUE_NUM             1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0

+ 2 - 2
CMSIS/RTOS2/RTX/Examples/TrustZoneV8M/RTOS/CM33_s/RTE/CMSIS/RTX_Config.c

@@ -210,7 +210,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MEMPOOL_NUM              1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0
@@ -232,7 +232,7 @@
 //     <i> Applies to objects with system provided memory for control blocks.
 #define OS_MSGQUEUE_NUM             1
  
-//     <o>Data Storage Memory size [bytes] <0-1073741824:4>
+//     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0

+ 4 - 4
CMSIS/RTOS2/RTX/Include/rtx_config.h

@@ -289,10 +289,10 @@ __attribute__((section(".data.os.mempool.mpi"))) =
 
 // Memory Pool for Memory Pool Data Storage
 #if (OS_MEMPOOL_DATA_SIZE != 0)
-#if ((OS_MEMPOOL_DATA_SIZE & 3) != 0)
+#if ((OS_MEMPOOL_DATA_SIZE & 7) != 0)
 #error "Invalid Data Memory size for Memory Pools!"
 #endif
-static uint32_t os_mp_data[OS_MEMPOOL_DATA_SIZE/4] \
+static uint64_t os_mp_data[OS_MEMPOOL_DATA_SIZE/8] \
 __attribute__((section(".bss.os.mempool.mem")));
 #endif
 
@@ -319,10 +319,10 @@ __attribute__((section(".data.os.msgqueue.mpi"))) =
 
 // Memory Pool for Message Queue Data Storage
 #if (OS_MSGQUEUE_DATA_SIZE != 0)
-#if ((OS_MSGQUEUE_DATA_SIZE & 3) != 0)
+#if ((OS_MSGQUEUE_DATA_SIZE & 7) != 0)
 #error "Invalid Data Memory size for Message Queues!"
 #endif
-static uint32_t os_mq_data[OS_MSGQUEUE_DATA_SIZE/4] \
+static uint64_t os_mq_data[OS_MSGQUEUE_DATA_SIZE/8] \
 __attribute__((section(".bss.os.msgqueue.mem")));
 #endif
 

+ 6 - 6
CMSIS/RTOS2/RTX/Source/rtx_memory.c

@@ -52,17 +52,17 @@ uint32_t os_MemoryInit (void *mem, uint32_t size) {
   mem_head_t  *head;
   mem_block_t *ptr;
 
-  if ((mem == NULL) || ((uint32_t)mem & 3U) || (size & 3U) ||
-      (size < (sizeof(mem_head_t) + sizeof(mem_block_t) + sizeof(mem_block_t *)))) {
+  if ((mem == NULL) || ((uint32_t)mem & 7U) || (size & 7U) ||
+      (size < (sizeof(mem_head_t) + 2*sizeof(mem_block_t)))) {
     return 0U;
   }
 
   head = (mem_head_t *)mem;
   head->size = size;
-  head->used = sizeof(mem_head_t) + sizeof(mem_block_t *);
+  head->used = sizeof(mem_head_t) + sizeof(mem_block_t);
 
   ptr = (mem_block_t *)((uint32_t)mem + sizeof(mem_head_t));
-  ptr->next = (mem_block_t *)((uint32_t)mem + size - sizeof(mem_block_t *));
+  ptr->next = (mem_block_t *)((uint32_t)mem + size - sizeof(mem_block_t));
   ptr->next->next = NULL;
   ptr->info = 0U;
 
@@ -84,8 +84,8 @@ void *os_MemoryAlloc (void *mem, uint32_t size, uint32_t type) {
 
   // Add header to size
   size += sizeof(mem_block_t);
-  // Make sure that block is 4-byte aligned
-  size = (size + 3U) & ~((uint32_t)3U);
+  // Make sure that block is 8-byte aligned
+  size = (size + 7U) & ~((uint32_t)7U);
 
   // Search for hole big enough
   p = (mem_block_t *)((uint32_t)mem + sizeof(mem_head_t));