Source code for the Trusted Boot Module.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
#include <cmocka.h>
|
|
|
|
|
|
|
|
#include <bitops.h>
|
|
|
|
#include <flash.h>
|
|
|
|
#include <ftl.h>
|
|
|
|
#include <macros.h>
|
|
|
|
|
|
|
|
size_t __wrap_flash_read(struct flash_dev *dev, uint32_t addr,
|
|
|
|
void *data, size_t len)
|
|
|
|
{
|
|
|
|
const void *ret_data;
|
|
|
|
size_t ret_len;
|
|
|
|
|
|
|
|
(void)dev;
|
|
|
|
|
|
|
|
check_expected(addr);
|
|
|
|
check_expected(len);
|
|
|
|
|
|
|
|
ret_len = mock_type(size_t);
|
|
|
|
ret_data = mock_type(const void *);
|
|
|
|
|
|
|
|
if (len > ret_len)
|
|
|
|
len = ret_len;
|
|
|
|
|
|
|
|
if (len && ret_data)
|
|
|
|
memcpy(data, ret_data, len);
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t __wrap_flash_write(struct flash_dev *dev, uint32_t addr,
|
|
|
|
const void *data, size_t len)
|
|
|
|
{
|
|
|
|
void *ret_data;
|
|
|
|
size_t ret_len;
|
|
|
|
|
|
|
|
(void)dev;
|
|
|
|
|
|
|
|
check_expected(addr);
|
|
|
|
check_expected(len);
|
|
|
|
|
|
|
|
ret_len = mock_type(size_t);
|
|
|
|
ret_data = mock_type(void *);
|
|
|
|
|
|
|
|
if (len > ret_len)
|
|
|
|
len = ret_len;
|
|
|
|
|
|
|
|
if (len)
|
|
|
|
memcpy(ret_data, data, len);
|
|
|
|
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t __wrap_flash_write0(struct flash_dev *dev, uint32_t addr, size_t len)
|
|
|
|
{
|
|
|
|
(void)dev;
|
|
|
|
|
|
|
|
check_expected(addr);
|
|
|
|
check_expected(len);
|
|
|
|
|
|
|
|
return mock_type(int);
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t __wrap_flash_copy(struct flash_dev *dev, uint32_t dst, uint32_t src, size_t len)
|
|
|
|
{
|
|
|
|
(void)dev;
|
|
|
|
|
|
|
|
check_expected(dst);
|
|
|
|
check_expected(src);
|
|
|
|
check_expected(len);
|
|
|
|
|
|
|
|
return mock_type(int);
|
|
|
|
}
|
|
|
|
|
|
|
|
int __wrap_flash_is_erased(struct flash_dev *dev, uint32_t addr, size_t len)
|
|
|
|
{
|
|
|
|
(void)dev;
|
|
|
|
|
|
|
|
check_expected(addr);
|
|
|
|
check_expected(len);
|
|
|
|
|
|
|
|
return mock_type(int);
|
|
|
|
}
|