Lines Matching refs:device

86   ScopedNvramSpace(SafeScopedNvramDevice* device, uint32_t index, uint32_t size)  in ScopedNvramSpace()  argument
87 : ScopedNvramSpace(device, in ScopedNvramSpace()
95 ScopedNvramSpace(SafeScopedNvramDevice* device, in ScopedNvramSpace() argument
99 : ScopedNvramSpace(device, in ScopedNvramSpace()
105 ScopedNvramSpace(SafeScopedNvramDevice* device, in ScopedNvramSpace() argument
110 : device_(device), in ScopedNvramSpace()
137 bool CleanBurnSpaces(SafeScopedNvramDevice* device) { in CleanBurnSpaces() argument
147 if (device->GetSpaceList(&space_index_list) != NV_RESULT_SUCCESS) { in CleanBurnSpaces()
153 if (device->IsSpaceLocked(index, &write_lock, &read_lock) != in CleanBurnSpaces()
159 nvram_result_t result = device->DeleteSpace(index, kNoAuth); in CleanBurnSpaces()
161 result = device->DeleteSpace(index, kBurnSpaceAuth); in CleanBurnSpaces()
175 bool GetNextBurnSpace(SafeScopedNvramDevice* device, uint32_t* index) { in GetNextBurnSpace() argument
176 if (!CleanBurnSpaces(device)) { in GetNextBurnSpace()
180 if (device->GetSpaceList(&space_index_list) != NV_RESULT_SUCCESS) { in GetNextBurnSpace()
204 SafeScopedNvramDevice device; in TEST() local
206 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetTotalSizeInBytes(&total_size)); in TEST()
211 SafeScopedNvramDevice device; in TEST() local
213 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetAvailableSizeInBytes(&available_size)); in TEST()
215 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetTotalSizeInBytes(&total_size)); in TEST()
220 SafeScopedNvramDevice device; in TEST() local
222 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetMaxSpaceSizeInBytes(&max_space_size)); in TEST()
224 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetTotalSizeInBytes(&total_size)); in TEST()
230 SafeScopedNvramDevice device; in TEST() local
232 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetMaxSpaces(&num_spaces)); in TEST()
237 SafeScopedNvramDevice device; in TEST() local
239 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetMaxSpaces(&max_spaces)); in TEST()
241 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetSpaceList(&space_index_list)); in TEST()
246 ScopedNvramSpace space(&device, kTestIndex1, 32); in TEST()
248 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetSpaceList(&space_index_list2)); in TEST()
256 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetSpaceList(&space_index_list3)); in TEST()
263 SafeScopedNvramDevice device; in TEST() local
264 ScopedNvramSpace space(&device, kTestIndex1, 17); in TEST()
265 ScopedNvramSpace space2(&device, kTestIndex2, 32); in TEST()
267 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetSpaceSize(kTestIndex1, &size)); in TEST()
269 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetSpaceSize(kTestIndex2, &size)); in TEST()
272 device.GetSpaceSize(kTestIndexNeverExists, &size)); in TEST()
276 SafeScopedNvramDevice device; in TEST() local
277 ScopedNvramSpace space(&device, kTestIndex1, 32); in TEST()
282 device.GetSpaceControls(kTestIndex1, &control_list)); in TEST()
286 device.GetSpaceControls(kTestIndexNeverExists, &control_list)); in TEST()
290 SafeScopedNvramDevice device; in TEST() local
291 ScopedNvramSpace space(&device, kTestIndex1, 32); in TEST()
294 device.IsSpaceLocked(kTestIndex1, &write_lock, &read_lock)); in TEST()
297 ASSERT_EQ(NV_RESULT_SUCCESS, device.EnableReadLock(kTestIndex1, kNoAuth)); in TEST()
299 device.IsSpaceLocked(kTestIndex1, &write_lock, &read_lock)); in TEST()
304 device.IsSpaceLocked(kTestIndexNeverExists, &write_lock, &read_lock)); in TEST()
308 SafeScopedNvramDevice device; in TEST() local
309 ScopedNvramSpace space(&device, kTestIndex1, 1); in TEST()
313 SafeScopedNvramDevice device; in TEST() local
315 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetMaxSpaceSizeInBytes(&max_space_size)); in TEST()
317 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetAvailableSizeInBytes(&available_size)); in TEST()
318 ScopedNvramSpace space(&device, kTestIndex1, in TEST()
326 SafeScopedNvramDevice device; in TEST() local
327 ScopedNvramSpace space(&device, kTestIndex1, 32, kControlList); in TEST()
330 device.GetSpaceControls(kTestIndex1, &control_list)); in TEST()
337 SafeScopedNvramDevice device; in TEST() local
340 &device, kTestIndex1, 32, in TEST()
346 device.WriteSpace(kTestIndex1, data, bad_password)); in TEST()
347 EXPECT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(kTestIndex1, data, password)); in TEST()
351 SafeScopedNvramDevice device; in TEST() local
352 ScopedNvramSpace space(&device, kTestIndex1, 32); in TEST()
354 device.CreateSpace(kTestIndex1, 32, {}, kNoAuth)); in TEST()
358 SafeScopedNvramDevice device; in TEST() local
360 ScopedNvramSpace space(&device, kTestIndex1, 32); in TEST()
362 EXPECT_EQ(NV_RESULT_SUCCESS, device.GetSpaceSize(kTestIndex1, &size)); in TEST()
368 device.GetSpaceSize(kTestIndex1, &size)); in TEST()
372 SafeScopedNvramDevice device; in TEST() local
374 ASSERT_TRUE(GetNextBurnSpace(&device, &index)); in TEST()
377 device.CreateSpace(index, 32, {NV_CONTROL_BOOT_WRITE_LOCK}, kNoAuth)); in TEST()
380 device.IsSpaceLocked(index, &write_lock, &read_lock)); in TEST()
384 ASSERT_EQ(NV_RESULT_SUCCESS, device.DeleteSpace(index, kNoAuth)); in TEST()
387 device.CreateSpace(index, 32, {NV_CONTROL_BOOT_WRITE_LOCK}, kNoAuth)); in TEST()
388 EXPECT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test", kNoAuth)); in TEST()
389 EXPECT_EQ(NV_RESULT_SUCCESS, device.EnableWriteLock(index, kNoAuth)); in TEST()
391 device.IsSpaceLocked(index, &write_lock, &read_lock)); in TEST()
395 device.WriteSpace(index, "test2", kNoAuth)); in TEST()
396 EXPECT_EQ(NV_RESULT_OPERATION_DISABLED, device.DeleteSpace(index, kNoAuth)); in TEST()
398 EXPECT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 4, kNoAuth, &data)); in TEST()
404 SafeScopedNvramDevice device; in TEST() local
405 ScopedNvramSpace space(&device, index, 32, {NV_CONTROL_BOOT_READ_LOCK}); in TEST()
408 device.IsSpaceLocked(index, &write_lock, &read_lock)); in TEST()
411 EXPECT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test", kNoAuth)); in TEST()
413 EXPECT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 4, kNoAuth, &data)); in TEST()
415 EXPECT_EQ(NV_RESULT_SUCCESS, device.EnableReadLock(index, kNoAuth)); in TEST()
417 device.IsSpaceLocked(index, &write_lock, &read_lock)); in TEST()
421 device.ReadSpace(index, 4, kNoAuth, &data)); in TEST()
422 EXPECT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test2", kNoAuth)); in TEST()
428 SafeScopedNvramDevice device; in TEST() local
429 ScopedNvramSpace space(&device, index, 32, {NV_CONTROL_WRITE_AUTHORIZATION}, in TEST()
431 EXPECT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test", password)); in TEST()
433 device.WriteSpace(index, "test2", kNoAuth)); in TEST()
435 device.WriteSpace(index, "test3", "bad_password")); in TEST()
436 EXPECT_EQ(NV_RESULT_ACCESS_DENIED, device.DeleteSpace(index, kNoAuth)); in TEST()
437 EXPECT_EQ(NV_RESULT_ACCESS_DENIED, device.DeleteSpace(index, "bad")); in TEST()
439 EXPECT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 4, kNoAuth, &data)); in TEST()
441 EXPECT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 4, password, &data)); in TEST()
447 SafeScopedNvramDevice device; in TEST() local
448 ScopedNvramSpace space(&device, index, 32, {NV_CONTROL_READ_AUTHORIZATION}, in TEST()
450 ASSERT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test", password)); in TEST()
451 EXPECT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test2", kNoAuth)); in TEST()
453 EXPECT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 4, password, &data)); in TEST()
456 device.ReadSpace(index, 4, kNoAuth, &data)); in TEST()
458 device.ReadSpace(index, 4, "bad_password", &data)); in TEST()
462 SafeScopedNvramDevice device; in TEST() local
464 ASSERT_TRUE(GetNextBurnSpace(&device, &index)); in TEST()
466 device.CreateSpace(index, 32, {NV_CONTROL_BOOT_WRITE_LOCK, in TEST()
470 EXPECT_EQ(NV_RESULT_SUCCESS, device.EnableReadLock(index, kNoAuth)); in TEST()
471 EXPECT_EQ(NV_RESULT_ACCESS_DENIED, device.EnableWriteLock(index, kNoAuth)); in TEST()
472 EXPECT_EQ(NV_RESULT_ACCESS_DENIED, device.EnableWriteLock(index, "bad")); in TEST()
473 EXPECT_EQ(NV_RESULT_SUCCESS, device.EnableWriteLock(index, kBurnSpaceAuth)); in TEST()
479 SafeScopedNvramDevice device; in TEST() local
480 ScopedNvramSpace space(&device, index, 32, in TEST()
484 EXPECT_EQ(NV_RESULT_ACCESS_DENIED, device.EnableReadLock(index, kNoAuth)); in TEST()
485 EXPECT_EQ(NV_RESULT_ACCESS_DENIED, device.EnableReadLock(index, "bad")); in TEST()
486 EXPECT_EQ(NV_RESULT_SUCCESS, device.EnableReadLock(index, password)); in TEST()
491 SafeScopedNvramDevice device; in TEST() local
492 ScopedNvramSpace space(&device, index, 32, {NV_CONTROL_WRITE_EXTEND}); in TEST()
493 ASSERT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test", kNoAuth)); in TEST()
495 EXPECT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 32, kNoAuth, &data)); in TEST()
498 EXPECT_EQ(NV_RESULT_SUCCESS, device.WriteSpace(index, "test2", kNoAuth)); in TEST()
499 EXPECT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 32, kNoAuth, &data)); in TEST()
506 SafeScopedNvramDevice device; in TEST() local
510 device.CreateSpace(index, 20, {NV_CONTROL_WRITE_EXTEND}, kNoAuth)); in TEST()
512 device.WriteSpace(index, "test", kNoAuth)); in TEST()
517 SafeScopedNvramDevice device; in TEST() local
519 ASSERT_EQ(NV_RESULT_SUCCESS, device.GetMaxSpaceSizeInBytes(&max_space_size)); in TEST()
523 device.CreateSpace(index, std::min<uint64_t>(max_space_size, 64), in TEST()
526 device.WriteSpace(index, "test", kNoAuth)); in TEST()
532 SafeScopedNvramDevice device; in TEST() local
533 ScopedNvramSpace space(&device, index, 32); in TEST()
535 ASSERT_EQ(NV_RESULT_SUCCESS, device.ReadSpace(index, 32, kNoAuth, &data)); in TEST()
541 SafeScopedNvramDevice device; in TEST() local
543 device.WriteSpace(index, "test", kNoAuth)); in TEST()
546 device.ReadSpace(index, 1, kNoAuth, &data)); in TEST()
548 device.EnableWriteLock(index, kNoAuth)); in TEST()
550 device.EnableReadLock(index, kNoAuth)); in TEST()