311 Kern::UnpinPhysicalMemory(pinObject); |
318 Kern::UnpinPhysicalMemory(pinObject); |
312 Kern::DestroyPhysicalPinObject(pinObject); |
319 Kern::DestroyPhysicalPinObject(pinObject); |
313 NKern::ThreadLeaveCS(); |
320 NKern::ThreadLeaveCS(); |
314 return r; |
321 return r; |
315 } |
322 } |
|
323 |
|
324 case RMemoryTestLdd::ECreateKernelMapObject: |
|
325 { |
|
326 NKern::ThreadEnterCS(); |
|
327 r=Kern::CreateKernelMapObject(iKernelMapping.iObject, (TUint)a1); |
|
328 NKern::ThreadLeaveCS(); |
|
329 return r; |
|
330 } |
|
331 |
|
332 case RMemoryTestLdd::EKernelMapMemory: |
|
333 return Kern::MapAndPinMemory( iKernelMapping.iObject, NULL, (TLinAddr)a1, (TUint)a2, 0, |
|
334 iKernelMapping.iLinAddr, iKernelMapping.iPhysPageList); |
|
335 |
|
336 case RMemoryTestLdd::EKernelMapMemoryRO: |
|
337 return Kern::MapAndPinMemory( iKernelMapping.iObject, NULL, (TLinAddr)a1, (TUint)a2, Kern::EKernelMap_ReadOnly, |
|
338 iKernelMapping.iLinAddr, iKernelMapping.iPhysPageList); |
|
339 |
|
340 case RMemoryTestLdd::EKernelMapMemoryInvalid: |
|
341 return Kern::MapAndPinMemory( iKernelMapping.iObject, NULL, (TLinAddr)a1, (TUint)a2, (TUint)~Kern::EKernelMap_ReadOnly, |
|
342 iKernelMapping.iLinAddr, iKernelMapping.iPhysPageList); |
|
343 |
|
344 case RMemoryTestLdd::EKernelMapCheckPageList: |
|
345 { |
|
346 #ifdef __WINS__ |
|
347 return KErrNotSupported; |
|
348 #else |
|
349 TUint i = 0; |
|
350 for (; i < (TUint)KUCPageCount; i++) |
|
351 { |
|
352 // Compare the user side address to physical addresses |
|
353 TPhysAddr addr = Epoc::LinearToPhysical((TLinAddr)a1 + i*iPageSize); |
|
354 if (addr == KPhysAddrInvalid) |
|
355 return KErrGeneral; |
|
356 if (addr != iKernelMapping.iPhysPageList[i]) |
|
357 return KErrNotFound; |
|
358 // Compare the kernel side address to physical addresses |
|
359 addr = Epoc::LinearToPhysical(iKernelMapping.iLinAddr + i*iPageSize); |
|
360 if (addr == KPhysAddrInvalid) |
|
361 return KErrGeneral; |
|
362 if (addr != iKernelMapping.iPhysPageList[i]) |
|
363 return KErrNotFound; |
|
364 } |
|
365 return KErrNone; |
|
366 #endif |
|
367 } |
|
368 |
|
369 case RMemoryTestLdd::EKernelMapSyncMemory: |
|
370 Cache::SyncMemoryBeforeDmaWrite(iKernelMapping.iLinAddr, KUCPageCount*iPageSize); |
|
371 return KErrNone; |
|
372 |
|
373 case RMemoryTestLdd::EKernelMapInvalidateMemory: |
|
374 { |
|
375 Cache::SyncMemoryBeforeDmaRead(iKernelMapping.iLinAddr, KUCPageCount*iPageSize); |
|
376 Cache::SyncMemoryAfterDmaRead(iKernelMapping.iLinAddr, KUCPageCount*iPageSize); |
|
377 return KErrNone; |
|
378 } |
|
379 |
|
380 case RMemoryTestLdd::EKernelMapMoveMemory: |
|
381 { |
|
382 #ifdef __WINS__ |
|
383 return KErrNotSupported; |
|
384 #else |
|
385 TPhysAddr newPage; |
|
386 NKern::ThreadEnterCS(); |
|
387 r = Epoc::MovePhysicalPage(iKernelMapping.iPhysPageList[(TUint)a1], newPage); |
|
388 NKern::ThreadLeaveCS(); |
|
389 return r; |
|
390 #endif |
|
391 } |
|
392 |
|
393 case RMemoryTestLdd::EKernelMapReadModifyMemory: |
|
394 { |
|
395 TUint8* p = (TUint8*)iKernelMapping.iLinAddr; |
|
396 // Verify the contents of the data when accessed via the kernel mapping. |
|
397 TUint i = 0; |
|
398 for (i = 0; i < KUCPageCount*iPageSize; i++) |
|
399 { |
|
400 if (*p++ != (TUint8)i) |
|
401 return KErrCorrupt; |
|
402 } |
|
403 // Modify the data via the kernel mapping. |
|
404 p = (TUint8*)iKernelMapping.iLinAddr; |
|
405 for (i = 0; i < KUCPageCount*iPageSize; i++) |
|
406 { |
|
407 *p++ = (TUint8)(i + 1); |
|
408 } |
|
409 return KErrNone; |
|
410 } |
|
411 |
|
412 case RMemoryTestLdd::EKernelUnmapMemory: |
|
413 Kern::UnmapAndUnpinMemory(iKernelMapping.iObject); |
|
414 return KErrNone; |
|
415 |
|
416 case RMemoryTestLdd::EDestroyKernelMapObject: |
|
417 { |
|
418 NKern::ThreadEnterCS(); |
|
419 Kern::DestroyKernelMapObject(iKernelMapping.iObject); |
|
420 NKern::ThreadLeaveCS(); |
|
421 return KErrNone; |
|
422 } |
|
423 |
316 default: |
424 default: |
317 return KErrNotSupported; |
425 return KErrNotSupported; |
318 } |
426 } |
319 } |
427 } |
320 |
428 |