summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/include/rtems/rtems/partimpl.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-04 10:13:35 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-04-06 09:08:22 +0200
commit3570ec684f23dc57772856d1170d39252299a490 (patch)
tree9729d0ff751ec562e68a99dfb62e1f60de5e1f0c /cpukit/rtems/include/rtems/rtems/partimpl.h
parentscore: Use red-black tree for active global objects (diff)
downloadrtems-3570ec684f23dc57772856d1170d39252299a490.tar.bz2
rtems: Avoid Giant lock for partitions
Use an ISR lock to protect the partition state changes. Update #2555.
Diffstat (limited to '')
-rw-r--r--cpukit/rtems/include/rtems/rtems/partimpl.h73
1 files changed, 57 insertions, 16 deletions
diff --git a/cpukit/rtems/include/rtems/rtems/partimpl.h b/cpukit/rtems/include/rtems/rtems/partimpl.h
index 472e06f4be..0ce7622a7a 100644
--- a/cpukit/rtems/include/rtems/rtems/partimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/partimpl.h
@@ -50,7 +50,7 @@ RTEMS_INLINE_ROUTINE void *_Partition_Allocate_buffer (
Partition_Control *the_partition
)
{
- return _Chain_Get( &the_partition->Memory );
+ return _Chain_Get_unprotected( &the_partition->Memory );
}
/**
@@ -63,7 +63,7 @@ RTEMS_INLINE_ROUTINE void _Partition_Free_buffer (
Chain_Node *the_buffer
)
{
- _Chain_Append( &the_partition->Memory, the_buffer );
+ _Chain_Append_unprotected( &the_partition->Memory, the_buffer );
}
/**
@@ -136,6 +136,37 @@ RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Allocate ( void )
return (Partition_Control *) _Objects_Allocate( &_Partition_Information );
}
+RTEMS_INLINE_ROUTINE void _Partition_Initialize(
+ Partition_Control *the_partition,
+ void *starting_address,
+ uint32_t length,
+ uint32_t buffer_size,
+ rtems_attribute attribute_set
+)
+{
+ the_partition->starting_address = starting_address;
+ the_partition->length = length;
+ the_partition->buffer_size = buffer_size;
+ the_partition->attribute_set = attribute_set;
+ the_partition->number_of_used_blocks = 0;
+
+ _Chain_Initialize(
+ &the_partition->Memory,
+ starting_address,
+ length / buffer_size,
+ buffer_size
+ );
+
+ _ISR_lock_Initialize( &the_partition->Lock, "Partition" );
+}
+
+RTEMS_INLINE_ROUTINE void _Partition_Destroy(
+ Partition_Control *the_partition
+)
+{
+ _ISR_lock_Destroy( &the_partition->Lock );
+}
+
/**
* @brief Frees a partition control block to the
* inactive chain of free partition control blocks.
@@ -150,24 +181,34 @@ RTEMS_INLINE_ROUTINE void _Partition_Free (
_Objects_Free( &_Partition_Information, &the_partition->Object );
}
-/**
- * @brief Maps partition IDs to partition control blocks.
- *
- * This function maps partition IDs to partition control blocks.
- * If ID corresponds to a local partition, then it returns
- * the_partition control pointer which maps to ID and location
- * is set to OBJECTS_LOCAL. If the partition ID is global and
- * resides on a remote node, then location is set to OBJECTS_REMOTE,
- * and the_partition is undefined. Otherwise, location is set
- * to OBJECTS_ERROR and the_partition is undefined.
- */
RTEMS_INLINE_ROUTINE Partition_Control *_Partition_Get (
Objects_Id id,
- Objects_Locations *location
+ Objects_Locations *location,
+ ISR_lock_Context *lock_context
+)
+{
+ return (Partition_Control *) _Objects_Get_isr_disable(
+ &_Partition_Information,
+ id,
+ location,
+ lock_context
+ );
+}
+
+RTEMS_INLINE_ROUTINE void _Partition_Acquire_critical(
+ Partition_Control *the_partition,
+ ISR_lock_Context *lock_context
+)
+{
+ _ISR_lock_Acquire( &the_partition->Lock, lock_context );
+}
+
+RTEMS_INLINE_ROUTINE void _Partition_Release(
+ Partition_Control *the_partition,
+ ISR_lock_Context *lock_context
)
{
- return (Partition_Control *)
- _Objects_Get( &_Partition_Information, id, location );
+ _ISR_lock_Release_and_ISR_enable( &the_partition->Lock, lock_context );
}
/**@}*/