300
|
1 |
// Copyright (c) 2010 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 |
// e32test\pccd\t_HalNandMedia.cpp
|
|
15 |
// Overview:
|
|
16 |
// Test class HalNandMedia APIs
|
|
17 |
// Platforms/Drives/Compatibility:
|
|
18 |
// All.
|
|
19 |
// Assumptions/Requirement/Pre-requisites:
|
|
20 |
// Failures and causes:
|
|
21 |
// Base Port information:
|
|
22 |
//
|
|
23 |
//
|
|
24 |
|
|
25 |
#define __E32TEST_EXTENSION__
|
|
26 |
|
|
27 |
#include <e32test.h>
|
|
28 |
#include <e32hal.h>
|
|
29 |
#include <u32hal.h>
|
|
30 |
#include <e32svr.h>
|
|
31 |
#include <hal.h>
|
|
32 |
|
|
33 |
GLDEF_D RTest test(_L("T_HalNandMedia - HAL NandMedia test"));
|
|
34 |
|
|
35 |
// Version Info const and enums
|
|
36 |
enum
|
|
37 |
{
|
|
38 |
EHalGroupNandMedia = 28
|
|
39 |
};
|
|
40 |
|
|
41 |
|
|
42 |
/**
|
|
43 |
The number of nand media attributes.
|
|
44 |
It is simply defined by its position in the enumeration.
|
|
45 |
*/
|
|
46 |
enum TNandMediaHalFunction
|
|
47 |
{
|
|
48 |
EEraseBlockSize=1, /// nand device block size
|
|
49 |
EIsEraseNeedBeforeWrite, /// erase command is mandatory before write
|
|
50 |
EAtomicWriteSize, /// minimal size of data what can be written
|
|
51 |
|
|
52 |
EGetVersionInfoItems=0x10, /// total amount of items in version info structure
|
|
53 |
EGetVersionInfo /// get version info structure array from media driver
|
|
54 |
};
|
|
55 |
|
|
56 |
|
|
57 |
/**
|
|
58 |
The nand media devices enumeration.
|
|
59 |
*/
|
|
60 |
enum
|
|
61 |
{
|
|
62 |
ENandMediaDevice1=1 /// nand device1
|
|
63 |
};
|
|
64 |
|
|
65 |
|
|
66 |
const TUint8 KMaxSectionNameLen = 12;
|
|
67 |
const TUint8 KMaxVersionInfoLen = 28;
|
|
68 |
|
|
69 |
struct TVersionInfoItem
|
|
70 |
{
|
|
71 |
TText8 iSectionName[KMaxSectionNameLen];
|
|
72 |
TUint32 iSectionMaxSize;
|
|
73 |
TUint32 iImageCompressedSize;
|
|
74 |
TUint32 iImageSize;
|
|
75 |
TText8 iVersion[KMaxVersionInfoLen];
|
|
76 |
};
|
|
77 |
|
|
78 |
// Image header
|
|
79 |
// It is added after BB5_Common_Header
|
|
80 |
struct TImageHeader
|
|
81 |
{
|
|
82 |
TUint32 iMagic;
|
|
83 |
TUint32 iImageCompressedSize;
|
|
84 |
TUint32 iImageSize;
|
|
85 |
TUint32 iLoadAddress;
|
|
86 |
TUint32 iReserved;
|
|
87 |
TText8 iVersion[KMaxVersionInfoLen];
|
|
88 |
};
|
|
89 |
|
|
90 |
void TestCallNandMediaHalHandler()
|
|
91 |
{
|
|
92 |
test.Next(_L("Retrieving Nand Media Hal Attributes"));
|
|
93 |
|
|
94 |
TText8 *buffer;
|
|
95 |
TUint32 infoItems;
|
|
96 |
TUint32 i, j;
|
|
97 |
TInt err=KErrNone;
|
|
98 |
TVersionInfoItem *vinfo;
|
|
99 |
TBuf<KMaxSectionNameLen> SectName;
|
|
100 |
TBuf<KMaxVersionInfoLen> VersInfo;
|
|
101 |
|
|
102 |
// get number of items
|
|
103 |
err=UserSvr::HalFunction(EHalGroupNandMedia, EGetVersionInfoItems, &infoItems, 0, ENandMediaDevice1);
|
|
104 |
if(err!=KErrNone)
|
|
105 |
{
|
|
106 |
_LIT( KNoOfVersionsErrMsg, "HalFunction failed with %d when getting item count\n\r" );
|
|
107 |
test.Printf( KNoOfVersionsErrMsg, err );
|
|
108 |
return;
|
|
109 |
}
|
|
110 |
|
|
111 |
_LIT( KNoOfVersionsMsg, "Number of version info items available: %d\n\r" );
|
|
112 |
test.Printf( KNoOfVersionsMsg, infoItems );
|
|
113 |
|
|
114 |
// allocate buffer for items and fill it
|
|
115 |
buffer=(TUint8*)User::Alloc(infoItems*sizeof(TVersionInfoItem));
|
|
116 |
test(buffer!=NULL);
|
|
117 |
err=UserSvr::HalFunction(EHalGroupNandMedia, EGetVersionInfo, buffer, 0, ENandMediaDevice1);
|
|
118 |
if(err!=KErrNone)
|
|
119 |
{
|
|
120 |
_LIT( KVersionInfoErrMsg, "HalFunction failed with %d when getting items\n\r" );
|
|
121 |
test.Printf( KVersionInfoErrMsg, err );
|
|
122 |
User::Free(buffer);
|
|
123 |
return;
|
|
124 |
}
|
|
125 |
vinfo=(TVersionInfoItem *)buffer;
|
|
126 |
|
|
127 |
for(i=0; i<infoItems; i++)
|
|
128 |
{
|
|
129 |
// prepare section name and version info
|
|
130 |
SectName.Zero();
|
|
131 |
VersInfo.Zero();
|
|
132 |
for(j=0; j<KMaxSectionNameLen; j++)
|
|
133 |
{
|
|
134 |
if(vinfo->iSectionName[j]=='\0')
|
|
135 |
{
|
|
136 |
break;
|
|
137 |
}
|
|
138 |
SectName.Append(TChar((TUint)vinfo->iSectionName[j]));
|
|
139 |
}
|
|
140 |
SectName.SetLength(j);
|
|
141 |
|
|
142 |
for(j=0; j<KMaxVersionInfoLen; j++)
|
|
143 |
{
|
|
144 |
if(vinfo->iVersion[j]=='\0')
|
|
145 |
{
|
|
146 |
break;
|
|
147 |
}
|
|
148 |
VersInfo.Append(TChar((TUint)vinfo->iVersion[j]));
|
|
149 |
}
|
|
150 |
VersInfo.SetLength(j);
|
|
151 |
|
|
152 |
// print items
|
|
153 |
_LIT( KVersionInfoMsg, "[%2d] (%11S) (%27S) \nMaxSize = 0x%08X \nSize = 0x%08X \nCompSize = 0x%08X\n\r" );
|
|
154 |
test.Printf( KVersionInfoMsg, i, &SectName, &VersInfo, vinfo->iSectionMaxSize, vinfo->iImageSize, vinfo->iImageCompressedSize );
|
|
155 |
vinfo++;
|
|
156 |
}
|
|
157 |
|
|
158 |
User::Free(buffer);
|
|
159 |
}
|
|
160 |
|
|
161 |
|
|
162 |
GLDEF_C TInt E32Main()
|
|
163 |
//
|
|
164 |
// Test Kern HAL API
|
|
165 |
//
|
|
166 |
{
|
|
167 |
test.Title();
|
|
168 |
|
|
169 |
test.Start(_L("Test class Kern HAL API functions"));
|
|
170 |
|
|
171 |
TestCallNandMediaHalHandler();
|
|
172 |
|
|
173 |
test.End();
|
|
174 |
test.Close();
|
|
175 |
return(KErrNone);
|
|
176 |
}
|