Revert "msm8976-common: Calculate TrustZone size at runtime"
This reverts commit e7edb4e11d
.
This commit is contained in:
parent
ab0d370b32
commit
bf560d630e
|
@ -32,11 +32,13 @@
|
||||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
#define ALPHABET_LEN 256
|
#define ALPHABET_LEN 256
|
||||||
|
#define KB 1024
|
||||||
|
|
||||||
#define TZ_PART_PATH "/dev/block/bootdevice/by-name/tz"
|
#define TZ_PART_PATH "/dev/block/bootdevice/by-name/tz"
|
||||||
#define TZ_VER_STR "QC_IMAGE_VERSION_STRING="
|
#define TZ_VER_STR "QC_IMAGE_VERSION_STRING="
|
||||||
#define TZ_VER_STR_LEN 24
|
#define TZ_VER_STR_LEN 24
|
||||||
#define TZ_VER_BUF_LEN 255
|
#define TZ_VER_BUF_LEN 255
|
||||||
|
#define TZ_SZ 4096 * KB /* MMAP 4096K of TZ, TZ partition is 4096K */
|
||||||
|
|
||||||
/* Boyer-Moore string search implementation from Wikipedia */
|
/* Boyer-Moore string search implementation from Wikipedia */
|
||||||
|
|
||||||
|
@ -119,7 +121,6 @@ static char * bm_search(const char *str, size_t str_len, const char *pat,
|
||||||
static int get_tz_version(char *ver_str, size_t len) {
|
static int get_tz_version(char *ver_str, size_t len) {
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int fd;
|
int fd;
|
||||||
int tz_size;
|
|
||||||
char *tz_data = NULL;
|
char *tz_data = NULL;
|
||||||
char *offset = NULL;
|
char *offset = NULL;
|
||||||
|
|
||||||
|
@ -129,27 +130,21 @@ static int get_tz_version(char *ver_str, size_t len) {
|
||||||
goto err_ret;
|
goto err_ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
tz_size = lseek64(fd, 0, SEEK_END);
|
tz_data = (char *) mmap(NULL, TZ_SZ, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
if (tz_size == -1) {
|
|
||||||
ret = errno;
|
|
||||||
goto err_fd_close;
|
|
||||||
}
|
|
||||||
|
|
||||||
tz_data = (char *) mmap(NULL, tz_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
|
||||||
if (tz_data == (char *)-1) {
|
if (tz_data == (char *)-1) {
|
||||||
ret = errno;
|
ret = errno;
|
||||||
goto err_fd_close;
|
goto err_fd_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do Boyer-Moore search across TZ data */
|
/* Do Boyer-Moore search across TZ data */
|
||||||
offset = bm_search(tz_data, tz_size, TZ_VER_STR, TZ_VER_STR_LEN);
|
offset = bm_search(tz_data, TZ_SZ, TZ_VER_STR, TZ_VER_STR_LEN);
|
||||||
if (offset != NULL) {
|
if (offset != NULL) {
|
||||||
strncpy(ver_str, offset + TZ_VER_STR_LEN, len);
|
strncpy(ver_str, offset + TZ_VER_STR_LEN, len);
|
||||||
} else {
|
} else {
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
munmap(tz_data, tz_size);
|
munmap(tz_data, TZ_SZ);
|
||||||
err_fd_close:
|
err_fd_close:
|
||||||
close(fd);
|
close(fd);
|
||||||
err_ret:
|
err_ret:
|
||||||
|
|
Loading…
Reference in New Issue