blob: 73f57b60e225bd1f0ba5e9d9c0655d06ab22e726 [file] [log] [blame]
/*
* Copyright (c) 2018 MediaTek Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __ENV_H__
#define __ENV_H__
#ifdef MTK_COMBO_NAND_SUPPORT
extern unsigned int mtk_nand_erasesize(void);
#define CFG_ENV_SIZE 0x8000 //(32KB)
#define CFG_ENV_OFFSET mtk_nand_erasesize()
#else
#define CFG_ENV_SIZE 0x4000 //(16KB)
#define CFG_ENV_OFFSET 0x20000 //(128KB)
#endif
#define CFG_ENV_DATA_SIZE (CFG_ENV_SIZE-sizeof(g_env.checksum)-sizeof(g_env.sig)-sizeof(g_env.sig_1))
#define CFG_ENV_DATA_OFFSET (sizeof(g_env.sig))
#define CFG_ENV_SIG_1_OFFSET (CFG_ENV_SIZE - sizeof(g_env.checksum)-sizeof(g_env.sig_1))
#define CFG_ENV_CHECKSUM_OFFSET (CFG_ENV_SIZE - sizeof(g_env.checksum))
#define ENV_SIG "ENV_v1"
typedef struct env_struct {
char sig[8]; // "ENV_v1"
char *env_data;
char sig_1[8]; //"ENV_v1"
int checksum; // checksum for env_data
} env_t;
extern void env_init(void);
extern char *get_env(char *name);
extern int set_env(char *name,char *value);
extern void print_env(void);
#endif