static uint32_t optee_log_mode = 1;
static struct timer_list optee_log_timer;
static uint8_t line_buff[OPTEE_LOG_LINE_MAX];
+static uint32_t looped = 0;
static void *g_shm_va;
static bool init_shm(phys_addr_t shm_pa, uint32_t shm_size)
read_size = 0;
else if (reader < writer)
read_size = writer - reader;
- else
+ else {
+ looped = 1;
read_size = ctl->total_size - reader;
+ }
if (read_size > len)
read_size = len;
size_t len = 0;
char *line = line_buff;
+ if (size == 0)
+ return 0;
+
do {
const char *next = memchr(text, '\n', text_size);
size_t line_size;
return len;
}
-static ssize_t log_buff_dump(char *buf, size_t size)
+static ssize_t log_buff_dump(void)
{
ssize_t len;
char *ptr = NULL;
+ unsigned int writer = 0;
struct optee_log_ctl_s *ctl = optee_log_ctl;
if (!ctl)
return 0;
- len = ctl->reader;
- if (len == 0)
- return 0;
+ writer = ctl->writer;
- ptr = optee_log_buff;
- if (len > size) {
- ptr += len - size;
- len = size;
+ if (looped) {
+ ptr = optee_log_buff + writer;
+ len = ctl->total_size - writer;
+
+ log_print_text(ptr, len);
}
- memcpy(buf, ptr, len);
- return len;
+ ptr = optee_log_buff;
+ len = writer;
+
+ log_print_text(ptr, len);
+
+ return 0;
}
static void log_buff_reset(void)
static ssize_t log_buff_show(struct class *cla,
struct class_attribute *attr, char *buf)
{
- return log_buff_dump(buf, OPTEE_LOG_READ_MAX);
+ log_buff_dump();
+
+ return 0;
}
static struct class_attribute log_class_attrs[] = {