1/*
2 * Shell-like utility functions
3 *
4 * Copyright (C) 2015, Broadcom Corporation. All Rights Reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
15 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
16 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * $Id: wapi_utils.h 241182 2011-02-17 21:50:03Z $
19 */
20
21#ifndef _WAPI_UTILS_H_
22#define _WAPI_UTILS_H_
23
24/* WAPI ramfs directories */
25#define RAMFS_WAPI_DIR			__CONFIG_WAPI_CONF__
26#define CONFIG_DIR			"config"
27#define WAPI_WAI_DIR			RAMFS_WAPI_DIR"/"CONFIG_DIR
28#define WAPI_AS_DIR			RAMFS_WAPI_DIR"/"CONFIG_DIR"/as1000"
29
30#define WAPI_TGZ_TMP_FILE		RAMFS_WAPI_DIR"/config.tgz"
31
32#define WAPI_AS_CER_FILE		WAPI_AS_DIR"/as.cer"
33
34/* WAPI partition magic number: "wapi" */
35#define WAPI_MTD_MAGIC			"\077\061\070\069"
36
37typedef struct {
38	unsigned int magic;
39	unsigned int len;
40	unsigned short checksum;
41} wapi_mtd_hdr_t;
42
43/*
44 * Write a file to an MTD device
45 * @param	path	file to write or a URL
46 * @param	mtd	path to or partition name of MTD device
47 * @return	0 on success and errno on failure
48 */
49int wapi_mtd_backup();
50
51/*
52 * Read MTD device to file
53 * @param	path	file to write or a URL
54 * @param	mtd	path to or partition name of MTD device
55 * @return	0 on success and errno on failure
56 */
57int wapi_mtd_restore();
58
59#endif /* _WAPI_UTILS_H_ */
60