blob: 52a2146f77643d92416126da939ae31b6dc9426c [file] [log] [blame]
l.yangb8fdece2024-10-10 14:56:17 +08001
2#include <linux/module.h>
3#include <linux/kernel.h>
4#include <linux/init.h>
5#include <linux/cdev.h>
6#include <linux/semaphore.h>
7#include <linux/timer.h>
l.yangb8fdece2024-10-10 14:56:17 +08008#include <linux/ioport.h>
l.yangb8fdece2024-10-10 14:56:17 +08009#include <linux/poll.h>
10#include <linux/delay.h>
11#include <linux/wait.h>
12#include <linux/err.h>
13#include <linux/interrupt.h>
14#include <linux/sched.h>
15#include <linux/types.h>
16#include <linux/device.h>
17#include <linux/miscdevice.h>
l.yangb8fdece2024-10-10 14:56:17 +080018#include <linux/list.h>
19#include <linux/slab.h>
20#include <linux/sched.h>
l.yangb8fdece2024-10-10 14:56:17 +080021#include <asm/io.h>
l.yangb8fdece2024-10-10 14:56:17 +080022#include <linux/vmalloc.h>
23#include <linux/soc/zte/rpmsg.h>
l.yangb8fdece2024-10-10 14:56:17 +080024#include "pub_debug_info.h"
25#include "ringbuf.h"
l.yangafee7ee2024-10-10 15:01:10 +080026#include "ram_config.h"
27#include "ZspTrace.h"
28#include <linux/proc_fs.h>
29#include <asm/barrier.h>
30#include <asm/cache.h>
31#include <asm/cacheflush.h>
32#include <linux/seq_file.h>
33#include <linux/ktime.h>
34#include <linux/time.h>
l.yangb8fdece2024-10-10 14:56:17 +080035
l.yangafee7ee2024-10-10 15:01:10 +080036#if defined(_USE_ZXIC_DEBUG_INFO)
l.yangb8fdece2024-10-10 14:56:17 +080037/*******************************************************************************
38 * 宏定义 *
39 *******************************************************************************/
l.yangafee7ee2024-10-10 15:01:10 +080040#define DEBUG_INFO_AP_MEM_LEN (0x2000)
l.yangb8fdece2024-10-10 14:56:17 +080041#define DEBUG_INFO_READABLE_LEN (0x1400)
l.yangb8fdece2024-10-10 14:56:17 +080042#define DEBUG_INFO_READ_TIME_MSECS (10000)
43
l.yangb8fdece2024-10-10 14:56:17 +080044#define DEBUG_INFO_OK (0)
45#define DEBUG_INFO_ERROR (-1)
l.yangafee7ee2024-10-10 15:01:10 +080046#define DEBUG_READ_NOBLOCK (11)
l.yangb8fdece2024-10-10 14:56:17 +080047
l.yangafee7ee2024-10-10 15:01:10 +080048#define DEBUG_INFO_MAX_ID_LEN (16+3)
49#define DEBUG_INFO_MAX_DATA_LEN (128)
50#define DEBUG_INFO_MAX_TIME_LEN (0)//(20+3)
51#define DEBUG_INFO_MAX_DATE_LEN (19+3)
52#define DEBUG_INFO_MAX_TOTAL_LEN (DEBUG_INFO_MAX_ID_LEN + DEBUG_INFO_MAX_DATA_LEN + DEBUG_INFO_MAX_TIME_LEN)
53
54#define DEBUG_INFO_CORE_NUM (2)
l.yangb8fdece2024-10-10 14:56:17 +080055
56/*******************************************************************************
57 * 结构体定义 *
58 *******************************************************************************/
l.yangafee7ee2024-10-10 15:01:10 +080059typedef unsigned int UINT32;
l.yangb8fdece2024-10-10 14:56:17 +080060typedef unsigned short UINT16;
l.yangafee7ee2024-10-10 15:01:10 +080061typedef unsigned char UINT8;
62typedef unsigned long UINT64;
63typedef struct{
64 unsigned int head; /* 0x010a0a0a */
65 unsigned int datalen[DEBUG_INFO_CORE_NUM]; /* 数据内容长度 */
l.yangb8fdece2024-10-10 14:56:17 +080066} T_SAVE_FILE_DATA;
67
68/*******************************************************************************
69 * 全局变量 *
70 *******************************************************************************/
l.yangb8fdece2024-10-10 14:56:17 +080071static struct semaphore debug_sem;
l.yangb8fdece2024-10-10 14:56:17 +080072static int g_init_flag = 0;
l.yangafee7ee2024-10-10 15:01:10 +080073UINT32 *g_ps_debug_write_cnt;
74UINT32 *g_ps_debug_full_cnt;
75UINT32 g_ps_debug_read_cnt;
76UINT32 g_ps_debug_read_full_cnt;
77unsigned long g_debug_read_cnt;
78unsigned long g_ap_debug_write_cnt;
79unsigned long g_ap_debug_read_cnt;
80UINT8 *g_ap_debug_buffer_start;
81UINT8 *g_ap_debug_buffer_read;
82UINT8 *g_ap_debug_buffer_write;
83UINT8 *g_ap_debug_buffer_end;
84UINT8 *g_ps_debug_buffer_start;
85UINT8 *g_ps_debug_buffer_end;
86UINT8 *g_ps_debug_buffer_read;
87static DEFINE_SPINLOCK(debug_info_lock);
88static char g_ap_debug_buffer[DEBUG_INFO_AP_MEM_LEN];
89unsigned long g_debug_read_state = 0;
l.yangb8fdece2024-10-10 14:56:17 +080090
91/*******************************************************************************
92 * 内部函数定义 *
93 *******************************************************************************/
l.yangafee7ee2024-10-10 15:01:10 +080094static int sc_debug_info_read_to_user(char *buf, size_t count);
95static int sc_debug_info_record_from_user(const char *info, size_t count);
96static void sc_debug_info_from_ps(void *buf, unsigned int len);
l.yangb8fdece2024-10-10 14:56:17 +080097static void kernel_timer_timeout(struct timer_list *t);
98static ssize_t debug_info_read(struct file *fp, char __user *buf, size_t count, loff_t *pos);
99static ssize_t debug_info_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos);
100static int debug_info_open(struct inode *ip, struct file *fp);
101static long debug_info_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
102static int debug_info_release(struct inode *ip, struct file *fp);
l.yangafee7ee2024-10-10 15:01:10 +0800103extern u64 cop_time_get_value64(void);
104extern int seq_write(struct seq_file *seq, const void *data, size_t len);
l.yangb8fdece2024-10-10 14:56:17 +0800105static DEFINE_TIMER(timer, kernel_timer_timeout);
l.yangb8fdece2024-10-10 14:56:17 +0800106static const struct file_operations debug_info_fops = {
107 .owner = THIS_MODULE,
108 .read = debug_info_read,
109 .write = debug_info_write,
110 .open = debug_info_open,
111 .unlocked_ioctl = debug_info_ioctl,
112 .release = debug_info_release,
113};
114
115static struct miscdevice debug_info_device = {
116 .minor = MISC_DYNAMIC_MINOR,
117 .name = "debug_info",
118 .fops = &debug_info_fops,
119};
l.yangb8fdece2024-10-10 14:56:17 +0800120static void kernel_timer_timeout(struct timer_list *t)
l.yangafee7ee2024-10-10 15:01:10 +0800121{
l.yangb8fdece2024-10-10 14:56:17 +0800122 if (debug_sem.count == 0)
l.yangafee7ee2024-10-10 15:01:10 +0800123 {
l.yangb8fdece2024-10-10 14:56:17 +0800124 up(&debug_sem);
125 }
l.yangb8fdece2024-10-10 14:56:17 +0800126 /* Kernel Timer restart */
l.yangafee7ee2024-10-10 15:01:10 +0800127 mod_timer(&timer, jiffies + msecs_to_jiffies(DEBUG_INFO_READ_TIME_MSECS));
l.yangb8fdece2024-10-10 14:56:17 +0800128}
129
l.yangafee7ee2024-10-10 15:01:10 +0800130/* Started by AICoder, pid:y6ffbg9a06ieda114a190b4cb0ff4417bd78c0f4 */
l.yangb8fdece2024-10-10 14:56:17 +0800131static ssize_t debug_info_read(struct file *fp, char __user *buf, size_t count, loff_t *pos)
132{
133 int ret;
134 int rd_len;
135
l.yangafee7ee2024-10-10 15:01:10 +0800136 if (g_debug_read_state != DEBUG_READ_NOBLOCK)
l.yangb8fdece2024-10-10 14:56:17 +0800137 {
l.yangafee7ee2024-10-10 15:01:10 +0800138 ret = down_interruptible(&debug_sem);
139 if (ret < 0)
140 {
141 return ret;
142 }
l.yangb8fdece2024-10-10 14:56:17 +0800143 }
l.yangafee7ee2024-10-10 15:01:10 +0800144
145 rd_len = sc_debug_info_read_to_user(buf, count);
l.yangb8fdece2024-10-10 14:56:17 +0800146
147 return rd_len;
148}
l.yangafee7ee2024-10-10 15:01:10 +0800149/* Ended by AICoder, pid:y6ffbg9a06ieda114a190b4cb0ff4417bd78c0f4 */
l.yangb8fdece2024-10-10 14:56:17 +0800150
151static ssize_t debug_info_write(struct file *fp, const char __user *buf, size_t count, loff_t *pos)
152{
153 int wr_len = sc_debug_info_record_from_user(buf, count);
154
155 return wr_len;
156}
157
158static int debug_info_open(struct inode *ip, struct file *fp)
159{
160 return 0;
161}
162
l.yangafee7ee2024-10-10 15:01:10 +0800163/* Started by AICoder, pid:u635ed463ce5ab2145a109c3c0f54d149e6386b3 */
164static long debug_info_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) {
165 if (cmd == DEBUG_READ_NOBLOCK) {
166 g_debug_read_state = DEBUG_READ_NOBLOCK;
167 } else {
168 // 如果命令不匹配,返回错误码
169 return -EINVAL;
l.yangb8fdece2024-10-10 14:56:17 +0800170 }
l.yangafee7ee2024-10-10 15:01:10 +0800171
172 // 记录调试信息
173 sc_debug_info_record("debug_info", "read noblock!\n");
174
l.yangb8fdece2024-10-10 14:56:17 +0800175 return 0;
176}
l.yangafee7ee2024-10-10 15:01:10 +0800177/* Ended by AICoder, pid:u635ed463ce5ab2145a109c3c0f54d149e6386b3 */
l.yangb8fdece2024-10-10 14:56:17 +0800178
179static int debug_info_release(struct inode *ip, struct file *fp)
180{
181 return 0;
182}
183
l.yangafee7ee2024-10-10 15:01:10 +0800184static int ap_log_proc_show(struct seq_file *m, void *v)
l.yangb8fdece2024-10-10 14:56:17 +0800185{
l.yangafee7ee2024-10-10 15:01:10 +0800186 unsigned long writecnt = g_ap_debug_write_cnt;
l.yangb8fdece2024-10-10 14:56:17 +0800187
l.yangafee7ee2024-10-10 15:01:10 +0800188 if (writecnt > DEBUG_INFO_AP_MEM_LEN)
189 {
190 writecnt = DEBUG_INFO_AP_MEM_LEN;
191 }
192
193 seq_write(m, g_ap_debug_buffer_start, writecnt);
194
195 return 0;
196}
197
198static int ps_log_proc_show(struct seq_file *m, void *v)
199{
200 unsigned long writecnt = 0;
201 unsigned long fulllcnt = 0;
202
203 writecnt = *(UINT32 *)g_ps_debug_write_cnt;
204 fulllcnt = *(UINT32 *)g_ps_debug_full_cnt;
205
206 if (fulllcnt > 0)
207 {
208 writecnt = PS_DEBUG_INFO_SIZE;
209 }
210
211 //__inval_dcache_area((void *)g_ps_debug_buffer_start, writecnt);
212 seq_write(m, g_ps_debug_buffer_start, writecnt);
213
214 return 0;
215}
216
217UINT32 skip_end_null(char *buf, size_t count)
218{
219 UINT32 len = 0;
220 char *tmpbuf = buf;
221
222 while (count > 0)
223 {
224 if (*tmpbuf == '\0')
225 {
226 ++len;
227 tmpbuf -= 1;
228 count -= 1;
229 }
230 else
231 {
232 break;
233 }
234 }
235
236 return len;
237}
238
239int sc_debug_info_read_ap(char *buf, size_t count)
240{
241 UINT32 readLen = 0;
242 UINT32 updatelen = 0;
243 UINT32 readremainLen = 0;
244 UINT8 *readbuffaddr = 0;
245 UINT32 nullLen = 0;
246 char *tmpbuf = buf;
247
248 updatelen = g_ap_debug_write_cnt - g_ap_debug_read_cnt;
249 if (updatelen > DEBUG_INFO_AP_MEM_LEN)
250 updatelen = DEBUG_INFO_AP_MEM_LEN;
251
252 if(g_ap_debug_buffer_end - g_ap_debug_buffer_read >= updatelen)
253 {
254 readbuffaddr = g_ap_debug_buffer_read;
255 readLen = updatelen;
256 if (copy_to_user(tmpbuf , readbuffaddr, readLen))
257 {
258 return -EFAULT;
259 }
260 g_ap_debug_buffer_read += readLen;
261 }
262 else if(g_ap_debug_buffer_end - g_ap_debug_buffer_read < updatelen)
263 {
264 readbuffaddr = g_ap_debug_buffer_read;
265 readLen = g_ap_debug_buffer_end - readbuffaddr;
266 readremainLen = updatelen - readLen;
267 nullLen = skip_end_null(g_ap_debug_buffer_end - 1, readLen);
268 readLen = readLen - nullLen;
269 if (copy_to_user(tmpbuf, readbuffaddr, readLen))
270 {
271 return -EFAULT;
272 }
273 if (copy_to_user(tmpbuf + readLen, g_ap_debug_buffer_start, readremainLen))
274 {
275 return -EFAULT;
276 }
277 g_ap_debug_buffer_read = g_ap_debug_buffer_start + readremainLen;
278 }
279 else
280 {
281 panic("gaohf sc_debug_info_read_to_user error");
282 }
283 g_ap_debug_read_cnt = g_ap_debug_write_cnt;
284
285 return (readLen + readremainLen);
286}
287
288int sc_debug_info_read_ps(char *buf, size_t count)
289{
290 UINT32 readLen = 0;
291 UINT32 readremainLen = 0;
292 UINT8 *readbuffaddr = 0;
293 UINT32 fulllcnt = 0;
294 UINT32 fulllcntdiff = 0;
295 unsigned long writecnt = 0;
296 UINT32 nullLen = 0;
297 char *tmpbuf = buf;
298
299 writecnt = *(volatile UINT32 *)g_ps_debug_write_cnt;
300 fulllcnt = *(volatile UINT32 *)g_ps_debug_full_cnt;
301
302 if (fulllcnt >= g_ps_debug_read_full_cnt)
303 {
304 fulllcntdiff = fulllcnt - g_ps_debug_read_full_cnt;
305 }
306 else
307 {
308 fulllcntdiff = 0xFFFFFFFF - g_ps_debug_read_full_cnt + fulllcnt;
309 }
310 if(fulllcntdiff >= 2)
311 {
312 readbuffaddr = g_ps_debug_buffer_start + writecnt;
313 readLen = g_ps_debug_buffer_end - readbuffaddr;
314 readremainLen = writecnt;
315 nullLen = skip_end_null(g_ps_debug_buffer_end - 1, readLen);
316 readLen = readLen - nullLen;
317 if (copy_to_user(tmpbuf, readbuffaddr, readLen))
318 {
319 return -EFAULT;
320 }
321 if (copy_to_user(tmpbuf + readLen, g_ps_debug_buffer_start, readremainLen))
322 {
323 return -EFAULT;
324 }
325 g_ps_debug_buffer_read = g_ps_debug_buffer_start + readremainLen;
326 }
327 else if(fulllcntdiff == 0)
328 {
329 readbuffaddr = g_ps_debug_buffer_read;
330 readLen = writecnt - g_ps_debug_read_cnt;;
331 if (copy_to_user(tmpbuf , readbuffaddr, readLen))
332 {
333 return -EFAULT;
334 }
335 g_ps_debug_buffer_read += readLen;
336 }
337 else if(fulllcntdiff == 1)
338 {
339 readLen = writecnt >= g_ps_debug_read_cnt ? writecnt : g_ps_debug_read_cnt;
340 readLen = PS_DEBUG_INFO_SIZE - readLen;
341 readbuffaddr = g_ps_debug_buffer_read;
342 nullLen = skip_end_null(g_ps_debug_buffer_end - 1, readLen);
343 readLen = readLen - nullLen;
344 if (copy_to_user(tmpbuf, readbuffaddr, readLen))
345 {
346 return -EFAULT;
347 }
348 readremainLen = writecnt;
349 if (copy_to_user(tmpbuf + readLen , g_ps_debug_buffer_start, readremainLen))
350 {
351 return -EFAULT;
352 }
353 g_ps_debug_buffer_read = g_ps_debug_buffer_start + readremainLen;
354 }
355 else
356 {
357 panic("gaohf sc_debug_info_read_to_user error");
358 }
359 g_ps_debug_read_cnt = writecnt;
360 g_ps_debug_read_full_cnt = fulllcnt;
361
362 return (readLen + readremainLen);
363}
364
365int sc_debug_info_read_to_user(char *buf, size_t count)
366{
367 char *tmpbuf = 0;
368 int ret = 0;
369 int ap_len = 0;
370 int ps_len = 0;
371 T_SAVE_FILE_DATA fileDataHead;
372
373 if (g_init_flag == 0)
374 {
375 printk("debug_info not init.\n");
376 return DEBUG_INFO_ERROR;
377 }
378
379 if (count == 0 || buf == NULL )
380 {
381 printk("sc_debug_info_read_to_user count == 0 || buf == NULL \n");
382 return DEBUG_INFO_ERROR;
383 }
384 tmpbuf = buf + sizeof(T_SAVE_FILE_DATA);
385 ap_len = sc_debug_info_read_ap(tmpbuf, DEBUG_INFO_AP_MEM_LEN);
386 tmpbuf += ap_len;
387 ps_len = sc_debug_info_read_ps(tmpbuf, PS_DEBUG_INFO_SIZE);
388
389 fileDataHead.head = 0x010a0a0a;
390 fileDataHead.datalen[0] = ap_len;
391 fileDataHead.datalen[1] = ps_len;
392
393 if (copy_to_user(buf, &fileDataHead, sizeof(T_SAVE_FILE_DATA)))
394 {
395 printk("sc_debug_info_read_to_user copy_to_user error \n");
396 return -EFAULT;
397 }
398 return sizeof(T_SAVE_FILE_DATA) + ap_len + ps_len;
399}
400
401static int sc_debug_info_record_from_user(const char *info, size_t count)
402{
403 UINT32 cnt = 0;
404 int spacelen;
405 int msg_len = 0;
406 struct tm tm;
407 time64_t time;
408 unsigned long used_space;
409 char buffer[DEBUG_INFO_MAX_TOTAL_LEN];
410 unsigned long flags;
411 UINT8 *tmp_write_addr = buffer;
412
413 if (g_init_flag == 0 || info == NULL)
414 {
415 printk("debug_info not init or sc_debug_info_record_from_user info is NULL\n");
416 return DEBUG_INFO_ERROR;
417 }
418
419 if(count > DEBUG_INFO_MAX_DATA_LEN + DEBUG_INFO_MAX_ID_LEN)
420 {
421 printk("debug_info data too long\n");
422 return DEBUG_INFO_ERROR;
423 }
424
425 time = ktime_get_real_seconds();
426 time64_to_tm(time, 0, &tm);
427 cnt = snprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_DATE_LEN, "[%ld-%02d-%02d %d:%02d:%02d]", \
428 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
429 tmp_write_addr += cnt;
430 msg_len = cnt;
431
432 spin_lock_irqsave(&debug_info_lock, flags);
433 spacelen = g_ap_debug_buffer_end - g_ap_debug_buffer_write;
434 if (spacelen < msg_len + count)
435 {
436 g_ap_debug_write_cnt += spacelen;
437 memset(g_ap_debug_buffer_write, '\0', spacelen);
438 g_ap_debug_buffer_write = g_ap_debug_buffer_start;
439 }
440 memcpy(g_ap_debug_buffer_write, buffer, msg_len);
441 if (copy_from_user(g_ap_debug_buffer_write + msg_len, info, count))
442 return -EFAULT;
443 msg_len += count;
444 g_ap_debug_buffer_write += msg_len;
445 g_ap_debug_write_cnt += msg_len;
446 used_space = g_ap_debug_write_cnt - g_ap_debug_read_cnt;
447 spin_unlock_irqrestore(&debug_info_lock, flags);
448 if (used_space > DEBUG_INFO_READABLE_LEN)
449 {
450 if (debug_sem.count == 0)
451 {
452 up(&debug_sem);
453 }
454 }
455 return msg_len;
456}
457
458int sc_debug_info_vrecord(char *id, const char *format, va_list args)
459{
460 int spacelen;
461 int msg_len = 0;
462 int cnt = 0;
463 unsigned long used_space;
464 struct tm tm;
465 time64_t time;
466 char buffer[DEBUG_INFO_MAX_TOTAL_LEN];
467 unsigned long flags;
468 UINT8 *tmp_write_addr = buffer;
469
470 time = ktime_get_real_seconds();
471 time64_to_tm(time, 0, &tm);
472 cnt = snprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_DATE_LEN, "[%ld-%02d-%02d %d:%02d:%02d]", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
473 tmp_write_addr += cnt;
474 msg_len = cnt;
475
476 cnt = snprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_ID_LEN, "[%s]",id);
477 tmp_write_addr += cnt;
478 msg_len += cnt;
479 msg_len += vsnprintf((char *)tmp_write_addr, DEBUG_INFO_MAX_DATA_LEN, format, args);
480
481 spin_lock_irqsave(&debug_info_lock, flags);
482 spacelen = g_ap_debug_buffer_end - g_ap_debug_buffer_write;
483 if (spacelen < DEBUG_INFO_MAX_TOTAL_LEN)
484 {
485 g_ap_debug_write_cnt += spacelen;
486 memset(g_ap_debug_buffer_write, '\0', spacelen);
487 g_ap_debug_buffer_write = g_ap_debug_buffer_start;
488 }
489
490 memcpy(g_ap_debug_buffer_write, buffer, msg_len);
491 g_ap_debug_buffer_write += msg_len;
492 g_ap_debug_write_cnt += msg_len;
493 used_space = g_ap_debug_write_cnt - g_ap_debug_read_cnt;
494 spin_unlock_irqrestore(&debug_info_lock, flags);
495 if (used_space > DEBUG_INFO_READABLE_LEN)
496 {
497 if (debug_sem.count == 0)
498 {
499 up(&debug_sem);
500 }
501 }
502 return msg_len;
503}
504EXPORT_SYMBOL(sc_debug_info_vrecord);
505
506int sc_debug_info_record(char *id, const char *format, ...)
507{
508 va_list args;
509 int r;
510
511 if (g_init_flag == 0)
512 {
513 printk("debug_info not init.\n");
514 return DEBUG_INFO_ERROR;
515 }
516
517 va_start(args, format);
518 r = sc_debug_info_vrecord(id, format, args);
519 va_end(args);
520
521 return r;
522}
523EXPORT_SYMBOL(sc_debug_info_record);
524
525void early_debug_info_init(void)
526{
527 g_ap_debug_buffer_start = g_ap_debug_buffer;
528 g_ap_debug_buffer_write = g_ap_debug_buffer_start;
529 g_ap_debug_buffer_read = g_ap_debug_buffer_start;
530 g_ap_debug_buffer_end = g_ap_debug_buffer + DEBUG_INFO_AP_MEM_LEN;
531 g_ap_debug_read_cnt = 0;
532 g_ap_debug_write_cnt = 0;
533
534 g_init_flag = 1;
535 printk("cap early_debug_info_init success \n");
l.yangb8fdece2024-10-10 14:56:17 +0800536}
537
538static int __init debug_info_init(void)
539{
l.yangafee7ee2024-10-10 15:01:10 +0800540 int ret;
541
542 ret = misc_register(&debug_info_device);
l.yangb8fdece2024-10-10 14:56:17 +0800543 if (ret)
544 {
l.yangafee7ee2024-10-10 15:01:10 +0800545 printk("debug_info_init init.\n");
l.yangb8fdece2024-10-10 14:56:17 +0800546 return DEBUG_INFO_ERROR;
547 }
548
l.yangafee7ee2024-10-10 15:01:10 +0800549 g_ps_debug_write_cnt = (UINT32 *)ioremap(PS_DEBUG_INFO_LEN_ADDR_PA, PS_DEBUG_INFO_LEN_SIZE);
550 // printf("PS_DEBUG_INFO_LEN_ADDR_PA \n",)
551 g_ps_debug_full_cnt = (UINT32 *)((char *)g_ps_debug_write_cnt + 4);
552 g_ps_debug_buffer_start = (unsigned long)ioremap(PS_DEBUG_INFO_ADDR_PA, PS_DEBUG_INFO_SIZE);
553 g_ps_debug_buffer_read = g_ps_debug_buffer_start;
554 g_ps_debug_buffer_end = g_ps_debug_buffer_start + PS_DEBUG_INFO_SIZE;
555 g_ps_debug_read_cnt = 0;
556 g_ps_debug_read_full_cnt = 0;
l.yangb8fdece2024-10-10 14:56:17 +0800557 sema_init(&debug_sem, 0);
l.yangafee7ee2024-10-10 15:01:10 +0800558 proc_create_single("debug_info_cap", 0, NULL, ap_log_proc_show);
559 proc_create_single("debug_info_ap", 0, NULL, ps_log_proc_show);
560 mod_timer(&timer, jiffies + 1);
561 printk("cap debug_info_init success \n");
562 // g_init_flag = 1;
l.yangb8fdece2024-10-10 14:56:17 +0800563 return 0;
564}
565
566static void __exit debug_info_exit(void)
567{
568 misc_deregister(&debug_info_device);
l.yangb8fdece2024-10-10 14:56:17 +0800569 del_timer(&timer);
570}
571
l.yangb8fdece2024-10-10 14:56:17 +0800572module_init(debug_info_init);
573module_exit(debug_info_exit);
l.yangb8fdece2024-10-10 14:56:17 +0800574MODULE_DESCRIPTION("debug_info driver");
575MODULE_LICENSE("GPL");
576
l.yangb8fdece2024-10-10 14:56:17 +0800577#else
l.yangafee7ee2024-10-10 15:01:10 +0800578int sc_debug_info_record(char *id, const char *format, ...)
l.yangb8fdece2024-10-10 14:56:17 +0800579{
l.yangafee7ee2024-10-10 15:01:10 +0800580 return 0;
l.yangb8fdece2024-10-10 14:56:17 +0800581}
582#endif /* _USE_ZXIC_DEBUG_INFO */
583
l.yangafee7ee2024-10-10 15:01:10 +0800584