aed-debug.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. #include <linux/proc_fs.h>
  2. #include <linux/seq_file.h>
  3. #include <linux/delay.h>
  4. #include <linux/kthread.h>
  5. #include <linux/kallsyms.h>
  6. #include <linux/notifier.h>
  7. #include <linux/kprobes.h>
  8. #include <linux/cpumask.h>
  9. #include <linux/slab.h>
  10. #include <linux/kdebug.h>
  11. #include <linux/uaccess.h>
  12. #if defined(CONFIG_ARM_PSCI) || defined(CONFIG_ARM64)
  13. #include <mach/mt_secure_api.h>
  14. #endif
  15. #include <smp.h>
  16. #include "aed.h"
  17. #ifndef PARTIAL_BUILD
  18. #define BUFSIZE 128
  19. static int test_case;
  20. static int test_cpu;
  21. static struct task_struct *wk_tsk[NR_CPUS];
  22. #ifdef __aarch64__
  23. #undef BUG
  24. #define BUG() (*((unsigned *)0xaed) = 0xDEAD)
  25. #endif
  26. static int force_panic_hang(struct notifier_block *this, unsigned long event, void *ptr)
  27. {
  28. LOGW("\n ==> force panic flow hang\n");
  29. while (1)
  30. ;
  31. LOGW("\n You should not see this\n");
  32. return 0;
  33. }
  34. static struct notifier_block panic_test = {
  35. .notifier_call = force_panic_hang,
  36. .priority = INT_MAX,
  37. };
  38. void notrace wdt_atf_hang(void)
  39. {
  40. int cpu = get_HW_cpuid();
  41. LOGE(" CPU %d : wdt_atf_hang\n", cpu);
  42. local_fiq_disable();
  43. preempt_disable();
  44. local_irq_disable();
  45. while (1)
  46. ;
  47. }
  48. static int kwdt_thread_test(void *arg)
  49. {
  50. struct sched_param param = {.sched_priority = 99 };
  51. int cpu = get_HW_cpuid();
  52. sched_setscheduler(current, SCHED_FIFO, &param);
  53. set_current_state(TASK_INTERRUPTIBLE);
  54. LOGW("\n ==> kwdt_thread_test on CPU %d, test_case = %d\n", cpu, test_case);
  55. msleep(1000);
  56. if (test_case == 1) {
  57. if (cpu == test_cpu) {
  58. LOGW("\n CPU %d : disable preemption and local IRQ forever", cpu);
  59. preempt_disable();
  60. local_irq_disable();
  61. while (1)
  62. ;
  63. LOGW("\n Error : You should not see this !\n");
  64. } else {
  65. LOGW("\n CPU %d : Do nothing and exit\n ", cpu);
  66. }
  67. } else if (test_case == 2) {
  68. if (cpu == test_cpu) {
  69. msleep(1000);
  70. LOGW("\n CPU %d : disable preemption and local IRQ forever", cpu);
  71. preempt_disable();
  72. local_irq_disable();
  73. while (1)
  74. ;
  75. LOGE("\n Error : You should not see this !\n");
  76. } else {
  77. LOGW("\n CPU %d : disable irq\n ", cpu);
  78. local_irq_disable();
  79. while (1)
  80. ;
  81. LOGE("\n Error : You should not see this !\n");
  82. }
  83. } else if (test_case == 3) {
  84. if (cpu == test_cpu) {
  85. LOGW("\n CPU %d : register panic notifier and force hang\n", cpu);
  86. atomic_notifier_chain_register(&panic_notifier_list, &panic_test);
  87. preempt_disable();
  88. local_irq_disable();
  89. while (1)
  90. ;
  91. LOGE("\n Error : You should not see this !\n");
  92. } else {
  93. LOGW("\n CPU %d : Do nothing and exit\n ", cpu);
  94. }
  95. } else if (test_case == 4) {
  96. LOGW("\n CPU %d : disable preemption and local IRQ forever\n ", cpu);
  97. preempt_disable();
  98. local_irq_disable();
  99. while (1)
  100. ;
  101. LOGW("\n Error : You should not see this !\n");
  102. } else if (test_case == 5) {
  103. LOGW("\n CPU %d : disable preemption and local IRQ/FIQ forever\n ", cpu);
  104. local_fiq_disable();
  105. preempt_disable();
  106. local_irq_disable();
  107. while (1)
  108. ;
  109. LOGW("\n Error : You should not see this !\n");
  110. } else if (test_case == 6) {
  111. LOGW("\n CPU %d : disable preemption and local IRQ/FIQ forever\n ", cpu);
  112. local_fiq_disable();
  113. preempt_disable();
  114. local_irq_disable();
  115. while (1)
  116. ;
  117. LOGW("\n Error : You should not see this !\n");
  118. }
  119. return 0;
  120. }
  121. static ssize_t proc_generate_wdt_write(struct file *file,
  122. const char __user *buf, size_t size, loff_t *ppos)
  123. {
  124. unsigned int i = 0;
  125. char msg[4];
  126. unsigned char name[20] = { 0 };
  127. if ((size < 2) || (size > sizeof(msg))) {
  128. LOGW("\n size = %zx\n", size);
  129. return -EINVAL;
  130. }
  131. if (copy_from_user(msg, buf, size)) {
  132. LOGW("copy_from_user error");
  133. return -EFAULT;
  134. }
  135. test_case = (unsigned int)msg[0] - '0';
  136. test_cpu = (unsigned int)msg[2] - '0';
  137. LOGW("test_case = %d, test_cpu = %d", test_case, test_cpu);
  138. if ((msg[1] != ':') || (test_case < 1) || (test_case > 6)
  139. || (test_cpu < 0) || (test_cpu > nr_cpu_ids)) {
  140. LOGW("WDT test - Usage: [test case number(1~6):test cpu(0~%d)]\n", nr_cpu_ids);
  141. return -EINVAL;
  142. }
  143. if (test_case == 1) {
  144. LOGW("Test 1 : One CPU WDT timeout (smp_send_stop succeed)\n");
  145. } else if (test_case == 2) {
  146. LOGW("Test 2 : One CPU WDT timeout, other CPU disable irq (smp_send_stop fail in old design)\n");
  147. } else if (test_case == 3) {
  148. LOGW("Test 3 : WDT timeout and loop in panic flow\n");
  149. } else if (test_case == 4) {
  150. LOGW("Test 4 : All CPU WDT timeout (other CPU stop in the loop)\n");
  151. } else if (test_case == 5) {
  152. LOGW("Test 5 : Disable ALL CPU IRQ/FIQ (FIQ : HW_reboot, ATF : HWT\n");
  153. } else if (test_case == 6) {
  154. LOGW("Test 6 : (For ATF) HW_REBOOT : change SMC call back function and while loop\n");
  155. #ifdef CONFIG_ARM64
  156. mt_secure_call(MTK_SIP_KERNEL_WDT, (u64) &wdt_atf_hang, 0, 0);
  157. #endif
  158. #ifdef CONFIG_ARM_PSCI
  159. mt_secure_call(MTK_SIP_KERNEL_WDT, (u32) &wdt_atf_hang, 0, 0);
  160. #endif
  161. } else {
  162. LOGE("\n Unknown test_case %d\n", test_case);
  163. return -EINVAL;
  164. }
  165. /* create kernel threads and bind on every cpu */
  166. for (i = 0; i < nr_cpu_ids; i++) {
  167. sprintf(name, "wd-test-%d", i);
  168. LOGW("[WDK]thread name: %s\n", name);
  169. wk_tsk[i] = kthread_create(kwdt_thread_test, NULL, name);
  170. if (IS_ERR(wk_tsk[i])) {
  171. int ret = PTR_ERR(wk_tsk[i]);
  172. wk_tsk[i] = NULL;
  173. return ret;
  174. }
  175. kthread_bind(wk_tsk[i], i);
  176. }
  177. for (i = 0; i < nr_cpu_ids; i++) {
  178. LOGW(" wake_up_process(wk_tsk[%d])\n", i);
  179. wake_up_process(wk_tsk[i]);
  180. }
  181. return size;
  182. }
  183. static ssize_t proc_generate_wdt_read(struct file *file,
  184. char __user *buf, size_t size, loff_t *ppos)
  185. {
  186. char buffer[BUFSIZE];
  187. return sprintf(buffer, "WDT test - Usage: [test case number:test cpu]\n");
  188. }
  189. /*****************************BEGIN OOPS***************************/
  190. /**********BEGIN ISR trigger HWT**********/
  191. /* kprobe pre_handler: called just before the probed instruction is executed */
  192. static int handler_pre(struct kprobe *p, struct pt_regs *regs)
  193. {
  194. LOGI("process_name:[%s], pid = %d.\n", current->comm, current->pid);
  195. return 0;
  196. }
  197. /* kprobe post_handler: called after the probed instruction is executed */
  198. int flag = 1;
  199. void handler_post(struct kprobe *p, struct pt_regs *regs, unsigned long flags)
  200. {
  201. if (flag) {
  202. flag = 0;
  203. mdelay(30 * 1000);
  204. }
  205. }
  206. static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr);
  207. static struct kprobe kp_kpd_irq_handler = {
  208. .symbol_name = "kpd_irq_handler",
  209. .pre_handler = handler_pre,
  210. .post_handler = handler_post,
  211. .fault_handler = handler_fault,
  212. };
  213. /*
  214. * fault_handler: this is called if an exception is generated for any
  215. * instruction within the pre- or post-handler, or when Kprobes
  216. * single-steps the probed instruction.
  217. */
  218. static int handler_fault(struct kprobe *p, struct pt_regs *regs, int trapnr)
  219. {
  220. LOGE("fault_handler: p->addr = 0x%p, trap #%dn", p->addr, trapnr);
  221. unregister_kprobe(&kp_kpd_irq_handler);
  222. LOGI("kprobe at %p unregistered\n", kp_kpd_irq_handler.addr);
  223. /* Return 0 because we don't handle the fault. */
  224. return 0;
  225. }
  226. static int register_kprobe_kpd_irq_handler(void)
  227. {
  228. int ret = 0;
  229. /* All set to register with Kprobes */
  230. ret = register_kprobe(&kp_kpd_irq_handler);
  231. if (ret < 0)
  232. LOGI("register_kprobe failed, returned %d\n", ret);
  233. else
  234. LOGI("Planted kprobe at %p, press Vol+/- to trigger.\n", kp_kpd_irq_handler.addr);
  235. return ret;
  236. }
  237. /**********END ISR trigger HWT**********/
  238. /**********BEGIN panic case**********/
  239. static noinline int stack_overflow_routine(int x, int y, int z)
  240. {
  241. char a[4];
  242. char *p = a;
  243. int i;
  244. for (i = 0; i < (x + y + z) * 2; i++)
  245. *(p + i) = i;
  246. /* stack overflow */
  247. return a[0] + a[3];
  248. }
  249. static noinline void buffer_over_flow(void)
  250. {
  251. int n;
  252. LOGI("test case : buffer overflow\n");
  253. n = stack_overflow_routine(10, 1, 22);
  254. LOGI("%s: %d\n", __func__, n);
  255. }
  256. static noinline void access_null_pointer(void)
  257. {
  258. LOGI("test case : derefence Null pointer\n");
  259. *((unsigned *)0) = 0xDEAD;
  260. }
  261. static noinline void double_free(void)
  262. {
  263. char *p = kmalloc(32, GFP_KERNEL);
  264. int i;
  265. LOGI("test case : double free\n");
  266. for (i = 0; i < 32; i++)
  267. p[i] = (char)i;
  268. LOGI("aee_ut_ke: call free\n");
  269. kfree(p);
  270. LOGI("aee_ut_ke: call free again\n");
  271. kfree(p);
  272. }
  273. static noinline void devide_by_0(void)
  274. {
  275. int ZERO = 0;
  276. int number;
  277. LOGI("test case: division by %d\n", ZERO);
  278. number = 100 / ZERO;
  279. LOGI("%s: %d\n", __func__, number);
  280. }
  281. /**********END panic case**********/
  282. static ssize_t proc_generate_oops_read(struct file *file,
  283. char __user *buf, size_t size, loff_t *ppos)
  284. {
  285. int len;
  286. char buffer[BUFSIZE];
  287. len = snprintf(buffer, BUFSIZE, "Oops Generated!\n");
  288. if (copy_to_user(buf, buffer, len))
  289. LOGE("%s fail to output info.\n", __func__);
  290. BUG();
  291. return len;
  292. }
  293. static ssize_t proc_generate_oops_write(struct file *file,
  294. const char __user *buf, size_t size, loff_t *ppos)
  295. {
  296. char msg[6];
  297. int test_case, test_subcase, test_cpu;
  298. if ((size < 2) || (size > sizeof(msg))) {
  299. LOGW("%s: count = %zx\n", __func__, size);
  300. return -EINVAL;
  301. }
  302. if (copy_from_user(msg, buf, size)) {
  303. LOGW("%s: error\n", __func__);
  304. return -EFAULT;
  305. }
  306. test_case = (unsigned int)msg[0] - '0';
  307. test_subcase = (unsigned int)msg[2] - '0';
  308. test_cpu = (unsigned int)msg[4] - '0';
  309. LOGW("test_case = %d-%d, test_cpu = %d\n", test_case, test_subcase, test_cpu);
  310. switch (test_case) {
  311. case 1:
  312. switch (test_subcase) {
  313. case 1:
  314. buffer_over_flow();
  315. break;
  316. case 2:
  317. access_null_pointer();
  318. break;
  319. case 3:
  320. double_free();
  321. break;
  322. case 4:
  323. devide_by_0();
  324. break;
  325. default:
  326. break;
  327. }
  328. break;
  329. case 2:
  330. register_kprobe_kpd_irq_handler();
  331. break;
  332. case 3:
  333. panic("aee test");
  334. break;
  335. default:
  336. break;
  337. }
  338. return size;
  339. }
  340. static int nested_panic(struct notifier_block *this, unsigned long event, void *ptr)
  341. {
  342. LOGE("\n => force nested panic\n");
  343. BUG();
  344. return 0;
  345. }
  346. static struct notifier_block panic_blk = {
  347. .notifier_call = nested_panic,
  348. .priority = INT_MAX - 100,
  349. };
  350. static ssize_t proc_generate_nested_ke_read(struct file *file,
  351. char __user *buf, size_t size, loff_t *ppos)
  352. {
  353. int len = 0;
  354. atomic_notifier_chain_register(&panic_notifier_list, &panic_blk);
  355. LOGE("\n => panic_notifier_list registered\n");
  356. BUG();
  357. /* len = sprintf(page, "Nested panic generated\n"); */
  358. return len;
  359. }
  360. static ssize_t proc_generate_nested_ke_write(struct file *file,
  361. const char __user *buf, size_t size, loff_t *ppos)
  362. {
  363. char msg[6];
  364. int test_case, test_subcase, test_cpu;
  365. if ((size < 2) || (size > sizeof(msg))) {
  366. LOGW("%s: count = %zx\n", __func__, size);
  367. return -EINVAL;
  368. }
  369. if (copy_from_user(msg, buf, size)) {
  370. LOGW("%s: error\n", __func__);
  371. return -EFAULT;
  372. }
  373. test_case = (unsigned int)msg[0] - '0';
  374. test_subcase = (unsigned int)msg[2] - '0';
  375. test_cpu = (unsigned int)msg[4] - '0';
  376. LOGW("test_case = %d-%d, test_cpu = %d\n", test_case, test_subcase, test_cpu);
  377. switch (test_case) {
  378. case 1:
  379. register_die_notifier(&panic_blk);
  380. break;
  381. }
  382. BUG();
  383. return 0;
  384. }
  385. static ssize_t proc_generate_ee_read(struct file *file,
  386. char __user *buf, size_t size, loff_t *ppos)
  387. {
  388. #define TEST_EE_LOG_SIZE 2048
  389. #define TEST_EE_PHY_SIZE 65536
  390. char buffer[BUFSIZE];
  391. char *ptr, *log;
  392. int i;
  393. if ((*ppos)++)
  394. return 0;
  395. ptr = kmalloc(TEST_EE_PHY_SIZE, GFP_KERNEL);
  396. if (ptr == NULL) {
  397. LOGE("proc_generate_ee_read kmalloc fail\n");
  398. return sprintf(buffer, "kmalloc fail\n");
  399. }
  400. log = kmalloc(TEST_EE_LOG_SIZE, GFP_KERNEL);
  401. if (log == NULL) {
  402. LOGE("proc_generate_ee_read kmalloc fail\n");
  403. kfree(ptr);
  404. return sprintf(buffer, "kmalloc fail\n");
  405. }
  406. for (i = 0; i < TEST_EE_PHY_SIZE; i++)
  407. ptr[i] = (i % 26) + 'A';
  408. for (i = 0; i < TEST_EE_LOG_SIZE; i++)
  409. log[i] = i % 255;
  410. aed_md_exception_api((int *)log, TEST_EE_LOG_SIZE, (int *)ptr, TEST_EE_PHY_SIZE, __FILE__,
  411. DB_OPT_FTRACE);
  412. kfree(ptr);
  413. kfree(log);
  414. return sprintf(buffer, "Modem EE Generated\n");
  415. }
  416. static ssize_t proc_generate_ee_write(struct file *file,
  417. const char __user *buf, size_t size, loff_t *ppos)
  418. {
  419. return 0;
  420. }
  421. static ssize_t proc_generate_combo_read(struct file *file,
  422. char __user *buf, size_t size, loff_t *ppos)
  423. {
  424. #define TEST_COMBO_PHY_SIZE 65536
  425. char buffer[BUFSIZE];
  426. int i;
  427. char *ptr;
  428. if ((*ppos)++)
  429. return 0;
  430. ptr = kmalloc(TEST_COMBO_PHY_SIZE, GFP_KERNEL);
  431. if (ptr == NULL) {
  432. LOGE("proc_generate_combo_read kmalloc fail\n");
  433. return sprintf(buffer, "kmalloc fail\n");
  434. }
  435. for (i = 0; i < TEST_COMBO_PHY_SIZE; i++)
  436. ptr[i] = (i % 26) + 'A';
  437. aee_kernel_dal_show("Oops, MT662X is generating core dump, please wait up to 5 min\n");
  438. aed_combo_exception(NULL, 0, (int *)ptr, TEST_COMBO_PHY_SIZE, __FILE__);
  439. kfree(ptr);
  440. return sprintf(buffer, "Combo EE Generated\n");
  441. }
  442. static ssize_t proc_generate_combo_write(struct file *file,
  443. const char __user *buf, size_t size, loff_t *ppos)
  444. {
  445. return 0;
  446. }
  447. static ssize_t proc_generate_md32_read(struct file *file,
  448. char __user *buf, size_t size, loff_t *ppos)
  449. {
  450. #define TEST_MD32_PHY_SIZE 65536
  451. char buffer[BUFSIZE];
  452. int i;
  453. char *ptr;
  454. if ((*ppos)++)
  455. return 0;
  456. ptr = kmalloc(TEST_MD32_PHY_SIZE, GFP_KERNEL);
  457. if (ptr == NULL) {
  458. LOGE("proc_generate_md32_read kmalloc fail\n");
  459. return sprintf(buffer, "kmalloc fail\n");
  460. }
  461. for (i = 0; i < TEST_MD32_PHY_SIZE; i++)
  462. ptr[i] = (i % 26) + 'a';
  463. sprintf(buffer, "MD32 EE log here\n");
  464. aed_md32_exception((int *)buffer, (int)sizeof(buffer), (int *)ptr, TEST_MD32_PHY_SIZE,
  465. __FILE__);
  466. kfree(ptr);
  467. return sprintf(buffer, "MD32 EE Generated\n");
  468. }
  469. static ssize_t proc_generate_md32_write(struct file *file,
  470. const char __user *buf, size_t size, loff_t *ppos)
  471. {
  472. return 0;
  473. }
  474. static ssize_t proc_generate_scp_read(struct file *file,
  475. char __user *buf, size_t size, loff_t *ppos)
  476. {
  477. #define TEST_SCP_PHY_SIZE 65536
  478. char buffer[BUFSIZE];
  479. int i;
  480. char *ptr;
  481. if ((*ppos)++)
  482. return 0;
  483. ptr = kmalloc(TEST_SCP_PHY_SIZE, GFP_KERNEL);
  484. if (ptr == NULL) {
  485. LOGE("proc_generate_scp_read kmalloc fail\n");
  486. return sprintf(buffer, "kmalloc fail\n");
  487. }
  488. for (i = 0; i < TEST_SCP_PHY_SIZE; i++)
  489. ptr[i] = (i % 26) + 'a';
  490. sprintf(buffer, "SCP EE log here\n");
  491. aed_scp_exception((int *)buffer, (int)sizeof(buffer), (int *)ptr, TEST_SCP_PHY_SIZE, __FILE__);
  492. kfree(ptr);
  493. return sprintf(buffer, "SCP EE Generated\n");
  494. }
  495. static ssize_t proc_generate_scp_write(struct file *file,
  496. const char __user *buf, size_t size, loff_t *ppos)
  497. {
  498. return 0;
  499. }
  500. static ssize_t proc_generate_kernel_notify_read(struct file *file,
  501. char __user *buf, size_t size, loff_t *ppos)
  502. {
  503. char buffer[BUFSIZE];
  504. int len = snprintf(buffer, BUFSIZE,
  505. "Usage: write message with format \"R|W|E:Tag:You Message\" into this file to generate kernel warning\n");
  506. if (*ppos)
  507. return 0;
  508. if (copy_to_user(buf, buffer, len)) {
  509. LOGE("%s fail to output info.\n", __func__);
  510. return -EFAULT;
  511. }
  512. *ppos += len;
  513. return len;
  514. }
  515. static ssize_t proc_generate_kernel_notify_write(struct file *file,
  516. const char __user *buf, size_t size,
  517. loff_t *ppos)
  518. {
  519. char msg[164], *colon_ptr;
  520. if (size == 0)
  521. return -EINVAL;
  522. if ((size < 5) || (size >= sizeof(msg))) {
  523. LOGW("aed: %s size sould be >= 5 and <= %zx bytes.\n", __func__, sizeof(msg));
  524. return -EINVAL;
  525. }
  526. if (copy_from_user(msg, buf, size)) {
  527. LOGW("aed: %s unable to read message\n", __func__);
  528. return -EFAULT;
  529. }
  530. /* Be safe */
  531. msg[size] = 0;
  532. if (msg[1] != ':')
  533. return -EINVAL;
  534. colon_ptr = strchr(&msg[2], ':');
  535. if ((colon_ptr == NULL) || ((colon_ptr - msg) > 32)) {
  536. LOGW("aed: %s cannot find valid module name\n", __func__);
  537. return -EINVAL;
  538. }
  539. *colon_ptr = 0;
  540. switch (msg[0]) {
  541. case 'R':
  542. aee_kernel_reminding(&msg[2], colon_ptr + 1);
  543. break;
  544. case 'W':
  545. aee_kernel_warning(&msg[2], colon_ptr + 1);
  546. break;
  547. case 'E':
  548. aee_kernel_exception(&msg[2], colon_ptr + 1);
  549. break;
  550. default:
  551. return -EINVAL;
  552. }
  553. return size;
  554. }
  555. static ssize_t proc_generate_dal_read(struct file *file,
  556. char __user *buf, size_t size, loff_t *ppos)
  557. {
  558. char buffer[BUFSIZE];
  559. int len;
  560. if ((*ppos)++)
  561. return 0;
  562. aee_kernel_dal_show("Test for DAL\n");
  563. len = sprintf(buffer, "DAL Generated\n");
  564. return len;
  565. }
  566. static ssize_t proc_generate_dal_write(struct file *file,
  567. const char __user *buf, size_t size, loff_t *ppos)
  568. {
  569. return 0;
  570. }
  571. AED_FILE_OPS(generate_oops);
  572. AED_FILE_OPS(generate_nested_ke);
  573. AED_FILE_OPS(generate_kernel_notify);
  574. AED_FILE_OPS(generate_wdt);
  575. AED_FILE_OPS(generate_ee);
  576. AED_FILE_OPS(generate_combo);
  577. AED_FILE_OPS(generate_md32);
  578. AED_FILE_OPS(generate_scp);
  579. AED_FILE_OPS(generate_dal);
  580. int aed_proc_debug_init(struct proc_dir_entry *aed_proc_dir)
  581. {
  582. AED_PROC_ENTRY(generate-oops, generate_oops, S_IRUSR | S_IWUSR);
  583. AED_PROC_ENTRY(generate-nested-ke, generate_nested_ke, S_IRUSR);
  584. AED_PROC_ENTRY(generate-kernel-notify, generate_kernel_notify, S_IRUSR | S_IWUSR);
  585. AED_PROC_ENTRY(generate-wdt, generate_wdt, S_IRUSR | S_IWUSR);
  586. AED_PROC_ENTRY(generate-ee, generate_ee, S_IRUSR);
  587. AED_PROC_ENTRY(generate-combo, generate_combo, S_IRUSR);
  588. AED_PROC_ENTRY(generate-md32, generate_md32, S_IRUSR);
  589. AED_PROC_ENTRY(generate-scp, generate_scp, S_IRUSR);
  590. AED_PROC_ENTRY(generate-dal, generate_dal, S_IRUSR);
  591. return 0;
  592. }
  593. int aed_proc_debug_done(struct proc_dir_entry *aed_proc_dir)
  594. {
  595. remove_proc_entry("generate-oops", aed_proc_dir);
  596. remove_proc_entry("generate-nested-ke", aed_proc_dir);
  597. remove_proc_entry("generate-kernel-notify", aed_proc_dir);
  598. remove_proc_entry("generate-ee", aed_proc_dir);
  599. remove_proc_entry("generate-combo", aed_proc_dir);
  600. remove_proc_entry("generate-md32", aed_proc_dir);
  601. remove_proc_entry("generate-scp", aed_proc_dir);
  602. remove_proc_entry("generate-wdt", aed_proc_dir);
  603. remove_proc_entry("generate-dal", aed_proc_dir);
  604. return 0;
  605. }
  606. #else
  607. int aed_proc_debug_init(struct proc_dir_entry *aed_proc_dir)
  608. {
  609. return 0;
  610. }
  611. int aed_proc_debug_done(struct proc_dir_entry *aed_proc_dir)
  612. {
  613. return 0;
  614. }
  615. #endif