1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     fnd_DetailHeapHead.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 /* Please see man pages for details
17 
18 
19 */
20 
21 #ifndef NN_FND_DETAIL_FND_DETAIL_HEAP_HEAD_H_
22 #define NN_FND_DETAIL_FND_DETAIL_HEAP_HEAD_H_
23 
24 #ifdef __cplusplus
25 
26 namespace nn{ namespace fnd{ namespace detail {
27 
28     /*---------------------------------------------------------------------------*
29       Name:         NNSFndLink
30       Description:  Node structure for doubly linked list. Stores this structure as a member of the structure that you want linked to the list structure.
31 
32      *---------------------------------------------------------------------------
33 */
34     typedef struct
35     {
36         void*       prevObject;     // Pointer to the previous linked object.
37         void*       nextObject;     // Pointer to the next linked object.
38 
39     } NNSFndLink;
40 
41 
42     /*---------------------------------------------------------------------------*
43       Name:         NNSFndList
44       Description:  Doubly linked list structure.
45      *---------------------------------------------------------------------------
46 */
47     typedef struct
48     {
49         void*       headObject;     // Pointer to the object linked to the top of the list.
50         void*       tailObject;     // Pointer to the object linked to the end of the list.
51         u16         numObjects;     // Number of objects linked in the list.
52         u16         offset;         // Offset for NNSFndLink type structure member.
53 
54     } NNSFndList;
55 
56     // Header information for memory
57     struct NNSiFndExpHeapMBlockHead
58     {
59         u16                         signature;      // Signature
60         u16                         attribute;      // Attribute
61                                                     // [8:groupID]
62                                                     // [7:alignment]
63                                                     // [1:temporary flag]
64 
65         u32                         blockSize;      // Block size (data area only)
66 
67         NNSiFndExpHeapMBlockHead*   pMBHeadPrev;    // Previous block
68         NNSiFndExpHeapMBlockHead*   pMBHeadNext;    // Next block
69     };
70 
71     // Memory list
72     struct NNSiFndExpMBlockList
73     {
74         NNSiFndExpHeapMBlockHead*   head;   // Pointer to memory linked to the start of the list
75         NNSiFndExpHeapMBlockHead*   tail;   // Pointer to memory linked to the end of the list
76     };
77 
78     // Header information for expanded heap
79     struct NNSiFndExpHeapHead
80     {
81         NNSiFndExpMBlockList        mbFreeList;     // Free list
82         NNSiFndExpMBlockList        mbUsedList;     // Used list
83 
84         u16                         groupID;        // Current group ID (lower 8 bits only)
85         u16                         feature;        // Attribute
86         bool                        reuse;          // Configures whether to reuse gap regions that occur during alignment.
87         NN_PADDING3;
88     };
89 
90     struct ExpHeapImpl
91     {
ExpHeapImplExpHeapImpl92         ExpHeapImpl() : signature(0) {}
93 
94         u32             signature;
95 
96         NNSFndLink      link;
97         NNSFndList      childList;
98 
99         void*           heapStart;      // Heap start address
100         void*           heapEnd;        // Heap end (+1) address
101 
102         u32             attribute;      // Attribute
103                                         // [8:Option flag]
104         NNSiFndExpHeapHead nnsiFndExpHeapHead;
105     };
106 
107 }}} // namespace nn::fnd::detail
108 
109 #endif // __cplusplus
110 
111 /* NN_FND_DETAIL_FND_DETAIL_HEAP_HEAD_H_ */
112 #endif
113 
114