packet.hh (10565:23593fdaadcd) packet.hh (10566:c99c8d2a7c31)
1/*
2 * Copyright (c) 2012-2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 233 unchanged lines hidden (view full) ---

242 static const FlagsType MEM_INHIBIT = 0x00000008;
243 /// Are the 'addr' and 'size' fields valid?
244 static const FlagsType VALID_ADDR = 0x00000100;
245 static const FlagsType VALID_SIZE = 0x00000200;
246 /// Is the data pointer set to a value that shouldn't be freed
247 /// when the packet is destroyed?
248 static const FlagsType STATIC_DATA = 0x00001000;
249 /// The data pointer points to a value that should be freed when
1/*
2 * Copyright (c) 2012-2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 233 unchanged lines hidden (view full) ---

242 static const FlagsType MEM_INHIBIT = 0x00000008;
243 /// Are the 'addr' and 'size' fields valid?
244 static const FlagsType VALID_ADDR = 0x00000100;
245 static const FlagsType VALID_SIZE = 0x00000200;
246 /// Is the data pointer set to a value that shouldn't be freed
247 /// when the packet is destroyed?
248 static const FlagsType STATIC_DATA = 0x00001000;
249 /// The data pointer points to a value that should be freed when
250 /// the packet is destroyed.
250 /// the packet is destroyed. The pointer is assumed to be pointing
251 /// to an array, and delete [] is consequently called
251 static const FlagsType DYNAMIC_DATA = 0x00002000;
252 static const FlagsType DYNAMIC_DATA = 0x00002000;
252 /// the data pointer points to an array (thus delete []) needs to
253 /// be called on it rather than simply delete.
254 static const FlagsType ARRAY_DATA = 0x00004000;
255 /// suppress the error if this packet encounters a functional
256 /// access failure.
257 static const FlagsType SUPPRESS_FUNC_ERROR = 0x00008000;
258 // Signal prefetch squash through express snoop flag
259 static const FlagsType PREFETCH_SNOOP_SQUASH = 0x00010000;
260
261 Flags flags;
262

--- 545 unchanged lines hidden (view full) ---

808 /**
809 * Set the data pointer to the following value that should not be
810 * freed.
811 */
812 template <typename T>
813 void
814 dataStatic(T *p)
815 {
253 /// suppress the error if this packet encounters a functional
254 /// access failure.
255 static const FlagsType SUPPRESS_FUNC_ERROR = 0x00008000;
256 // Signal prefetch squash through express snoop flag
257 static const FlagsType PREFETCH_SNOOP_SQUASH = 0x00010000;
258
259 Flags flags;
260

--- 545 unchanged lines hidden (view full) ---

806 /**
807 * Set the data pointer to the following value that should not be
808 * freed.
809 */
810 template <typename T>
811 void
812 dataStatic(T *p)
813 {
816 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
814 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
817 data = (PacketDataPtr)p;
818 flags.set(STATIC_DATA);
819 }
820
821 /**
822 * Set the data pointer to the following value that should not be
823 * freed. This version of the function allows the pointer passed
824 * to us to be const. To avoid issues down the line we cast the
825 * constness away, the alternative would be to keep both a const
826 * and non-const data pointer and cleverly choose between
827 * them. Note that this is only allowed for static data.
828 */
829 template <typename T>
830 void
831 dataStaticConst(const T *p)
832 {
815 data = (PacketDataPtr)p;
816 flags.set(STATIC_DATA);
817 }
818
819 /**
820 * Set the data pointer to the following value that should not be
821 * freed. This version of the function allows the pointer passed
822 * to us to be const. To avoid issues down the line we cast the
823 * constness away, the alternative would be to keep both a const
824 * and non-const data pointer and cleverly choose between
825 * them. Note that this is only allowed for static data.
826 */
827 template <typename T>
828 void
829 dataStaticConst(const T *p)
830 {
833 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
831 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
834 data = const_cast<PacketDataPtr>(p);
835 flags.set(STATIC_DATA);
836 }
837
838 /**
839 * Set the data pointer to a value that should have delete []
840 * called on it.
841 */
842 template <typename T>
843 void
832 data = const_cast<PacketDataPtr>(p);
833 flags.set(STATIC_DATA);
834 }
835
836 /**
837 * Set the data pointer to a value that should have delete []
838 * called on it.
839 */
840 template <typename T>
841 void
844 dataDynamicArray(T *p)
845 {
846 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
847 data = (PacketDataPtr)p;
848 flags.set(DYNAMIC_DATA|ARRAY_DATA);
849 }
850
851 /**
852 * set the data pointer to a value that should have delete called
853 * on it.
854 */
855 template <typename T>
856 void
857 dataDynamic(T *p)
858 {
842 dataDynamic(T *p)
843 {
859 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
844 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
860 data = (PacketDataPtr)p;
861 flags.set(DYNAMIC_DATA);
862 }
863
864 /**
865 * get a pointer to the data ptr.
866 */
867 template <typename T>

--- 65 unchanged lines hidden (view full) ---

933
934 /**
935 * delete the data pointed to in the data pointer. Ok to call to
936 * matter how data was allocted.
937 */
938 void
939 deleteData()
940 {
845 data = (PacketDataPtr)p;
846 flags.set(DYNAMIC_DATA);
847 }
848
849 /**
850 * get a pointer to the data ptr.
851 */
852 template <typename T>

--- 65 unchanged lines hidden (view full) ---

918
919 /**
920 * delete the data pointed to in the data pointer. Ok to call to
921 * matter how data was allocted.
922 */
923 void
924 deleteData()
925 {
941 if (flags.isSet(ARRAY_DATA))
926 if (flags.isSet(DYNAMIC_DATA))
942 delete [] data;
927 delete [] data;
943 else if (flags.isSet(DYNAMIC_DATA))
944 delete data;
945
928
946 flags.clear(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA);
929 flags.clear(STATIC_DATA|DYNAMIC_DATA);
947 data = NULL;
948 }
949
950 /** Allocate memory for the packet. */
951 void
952 allocate()
953 {
954 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
930 data = NULL;
931 }
932
933 /** Allocate memory for the packet. */
934 void
935 allocate()
936 {
937 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
955 flags.set(DYNAMIC_DATA|ARRAY_DATA);
938 flags.set(DYNAMIC_DATA);
956 data = new uint8_t[getSize()];
957 }
958
959 /**
960 * Check a functional request against a memory value represented
961 * by a base/size pair and an associated data array. If the
962 * functional request is a read, it may be satisfied by the memory
963 * value. If the functional request is a write, it may update the

--- 50 unchanged lines hidden ---
939 data = new uint8_t[getSize()];
940 }
941
942 /**
943 * Check a functional request against a memory value represented
944 * by a base/size pair and an associated data array. If the
945 * functional request is a read, it may be satisfied by the memory
946 * value. If the functional request is a write, it may update the

--- 50 unchanged lines hidden ---