189
|
1 |
// Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// kernel\eka\include\slab.h
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#ifndef __KERNEL_MODE__
|
|
19 |
|
|
20 |
class slab;
|
|
21 |
class slabhdr;
|
|
22 |
#define MAXSLABSIZE 56
|
|
23 |
#define PAGESHIFT 12
|
|
24 |
#define PAGESIZE (1<<PAGESHIFT)
|
|
25 |
#define SLABSHIFT 10
|
|
26 |
#define SLABSIZE (1 << SLABSHIFT)
|
|
27 |
#define CELLALIGN 8
|
|
28 |
|
|
29 |
|
|
30 |
const unsigned slabfull = 0;
|
|
31 |
const TInt slabsperpage = (int)(PAGESIZE/SLABSIZE);
|
|
32 |
#define HIBIT(bits) (((unsigned)bits & 0xc) ? 2 + ((unsigned)bits>>3) : ((unsigned) bits>>1))
|
|
33 |
|
|
34 |
#define LOWBIT(bits) (((unsigned) bits&3) ? 1 - ((unsigned)bits&1) : 3 - (((unsigned)bits>>2)&1))
|
|
35 |
|
|
36 |
#define ZEROBITS(header) (((unsigned)header & 0x70000000) ? 0 : 1)
|
|
37 |
|
|
38 |
class slabhdr
|
|
39 |
{
|
|
40 |
public:
|
|
41 |
unsigned iHeader;
|
|
42 |
// made up of
|
|
43 |
// bits | 31 | 30..28 | 27..18 | 17..12 | 11..8 | 7..0 |
|
|
44 |
// +----------+--------+--------+--------+---------+----------+
|
|
45 |
// field | floating | zero | used-4 | size | pagemap | free pos |
|
|
46 |
//
|
|
47 |
slab** iParent; // reference to iParent's pointer to this slab in tree
|
|
48 |
slab* iChild1; // 1st iChild in tree
|
|
49 |
slab* iChild2; // 2nd iChild in tree
|
|
50 |
};
|
|
51 |
|
|
52 |
const TInt KMaxSlabPayload = SLABSIZE - sizeof(slabhdr);
|
|
53 |
#define MAXUSEDM4BITS 0x0fc00000
|
|
54 |
#define FLOATING_BIT 0x80000000
|
|
55 |
|
|
56 |
inline unsigned HeaderFloating(unsigned h)
|
|
57 |
{return (h&0x80000000);}
|
|
58 |
const unsigned maxuse = (SLABSIZE - sizeof(slabhdr))>>2;
|
|
59 |
const unsigned firstpos = sizeof(slabhdr)>>2;
|
|
60 |
|
|
61 |
#ifdef _DEBUG
|
|
62 |
#define CHECKTREE(x) DoCheckSlabTree(x,EFalse)
|
|
63 |
#define CHECKSLAB(s,t,p) DoCheckSlab(s,t,p)
|
|
64 |
#define CHECKSLABBFR(s,p) {TUint32 b[4]; BuildPartialSlabBitmap(b,s,p);}
|
|
65 |
#else
|
|
66 |
#define CHECKTREE(x) (void)0
|
|
67 |
#define CHECKSLAB(s,t,p) (void)0
|
|
68 |
#define CHECKSLABBFR(s,p) (void)0
|
|
69 |
#endif
|
|
70 |
|
|
71 |
class slabset
|
|
72 |
{
|
|
73 |
public:
|
|
74 |
slab* iPartial;
|
|
75 |
};
|
|
76 |
|
|
77 |
class slab : public slabhdr
|
|
78 |
{
|
|
79 |
public:
|
|
80 |
void Init(unsigned clz);
|
|
81 |
//static slab* SlabFor( void* p);
|
|
82 |
static slab* SlabFor(const void* p) ;
|
|
83 |
unsigned char iPayload[SLABSIZE-sizeof(slabhdr)];
|
|
84 |
};
|
|
85 |
|
|
86 |
class page
|
|
87 |
{
|
|
88 |
public:
|
|
89 |
inline static page* PageFor(slab* s);
|
|
90 |
//slab iSlabs;
|
|
91 |
slab iSlabs[slabsperpage];
|
|
92 |
};
|
|
93 |
|
|
94 |
|
|
95 |
inline page* page::PageFor(slab* s)
|
|
96 |
{
|
|
97 |
return reinterpret_cast<page*>((unsigned(s))&~(PAGESIZE-1));
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
#endif // __KERNEL_MODE__
|