blob: 8fdc7ad5a0bf28c4337238a2003696563324fb72 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2018 MediaTek Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24#include <malloc.h>
25#include <platform/mtk_wdt.h>
26#include <stdint.h>
27#include <string.h>
28
29#include "aee.h"
30#include "kdump.h"
31
32static int null_write_cb(void *handle, void *buf, int size)
33{
34 return size;
35}
36
37int kdump_null_output(const struct mrdump_control_block *mrdump_cb, const struct kzip_addlist *memlist)
38{
39 voprintf_info("Output to null\n");
40 mtk_wdt_restart();
41
42 bool ok = true;
43 mtk_wdt_restart();
44 struct kzip_file *zf = kzip_open(NULL, null_write_cb);
45 if (zf != NULL) {
46 if (!kzip_add_file(zf, memlist, "SYS_COREDUMP"))
47 ok = false;
48 kzip_close(zf);
49 zf = NULL;
50 } else {
51 ok = false;
52 }
53 mtk_wdt_restart();
54 if (ok) {
55 mrdump_status_ok("NULL-OUTPUT\n");
56 }
57 return ok ? 0 : -1;
58}