X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=include%2Fenv_internal.h;h=f30fd6159d87b8ad282583c3c2cd55ae75548289;hb=a29491ade0adf3dbb9dc51be8b45530edde1f1df;hp=88c36b32a1e573662215f68809173988d05e6c4e;hpb=4b5c4dd93a829416d159619e4a58e97e9b215206;p=platform%2Fkernel%2Fu-boot.git diff --git a/include/env_internal.h b/include/env_internal.h index 88c36b3..f30fd61 100644 --- a/include/env_internal.h +++ b/include/env_internal.h @@ -30,49 +30,23 @@ *************************************************************************/ #if defined(CONFIG_ENV_IS_IN_FLASH) -# ifndef CONFIG_ENV_ADDR -# define CONFIG_ENV_ADDR (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET) -# endif -# ifndef CONFIG_ENV_OFFSET -# define CONFIG_ENV_OFFSET (CONFIG_ENV_ADDR - CONFIG_SYS_FLASH_BASE) -# endif -# if !defined(CONFIG_ENV_ADDR_REDUND) && defined(CONFIG_ENV_OFFSET_REDUND) -# define CONFIG_ENV_ADDR_REDUND \ - (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET_REDUND) -# endif -# if defined(CONFIG_ENV_SECT_SIZE) || defined(CONFIG_ENV_SIZE) -# ifndef CONFIG_ENV_SECT_SIZE -# define CONFIG_ENV_SECT_SIZE CONFIG_ENV_SIZE -# endif -# ifndef CONFIG_ENV_SIZE -# define CONFIG_ENV_SIZE CONFIG_ENV_SECT_SIZE -# endif -# else -# error "Both CONFIG_ENV_SECT_SIZE and CONFIG_ENV_SIZE undefined" -# endif -# if defined(CONFIG_ENV_ADDR_REDUND) && !defined(CONFIG_ENV_SIZE_REDUND) -# define CONFIG_ENV_SIZE_REDUND CONFIG_ENV_SIZE +# if defined(CONFIG_ENV_ADDR_REDUND) && \ + ((CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \ + (CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SIZE) <= \ + (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)) +# define ENV_IS_EMBEDDED # endif # if (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE) && \ (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE) <= \ (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) # define ENV_IS_EMBEDDED # endif -# if defined(CONFIG_ENV_ADDR_REDUND) || defined(CONFIG_ENV_OFFSET_REDUND) -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif # ifdef CONFIG_ENV_IS_EMBEDDED # error "do not define CONFIG_ENV_IS_EMBEDDED in your board config" # error "it is calculated automatically for you" # endif #endif /* CONFIG_ENV_IS_IN_FLASH */ -#if defined(CONFIG_ENV_IS_IN_MMC) -# ifdef CONFIG_ENV_OFFSET_REDUND -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif -#endif - #if defined(CONFIG_ENV_IS_IN_NAND) # if defined(CONFIG_ENV_OFFSET_OOB) # ifdef CONFIG_ENV_OFFSET_REDUND @@ -80,48 +54,9 @@ # error "is set" # endif extern unsigned long nand_env_oob_offset; -# define CONFIG_ENV_OFFSET nand_env_oob_offset -# else -# ifndef CONFIG_ENV_OFFSET -# error "Need to define CONFIG_ENV_OFFSET when using CONFIG_ENV_IS_IN_NAND" -# endif -# ifdef CONFIG_ENV_OFFSET_REDUND -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif # endif /* CONFIG_ENV_OFFSET_OOB */ -# ifndef CONFIG_ENV_SIZE -# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_NAND" -# endif #endif /* CONFIG_ENV_IS_IN_NAND */ -#if defined(CONFIG_ENV_IS_IN_UBI) -# ifndef CONFIG_ENV_UBI_PART -# error "Need to define CONFIG_ENV_UBI_PART when using CONFIG_ENV_IS_IN_UBI" -# endif -# ifndef CONFIG_ENV_UBI_VOLUME -# error "Need to define CONFIG_ENV_UBI_VOLUME when using CONFIG_ENV_IS_IN_UBI" -# endif -# if defined(CONFIG_ENV_UBI_IS_VOLUME_REDUND) -# define CONFIG_SYS_REDUNDAND_ENVIRONMENT -# endif -# ifndef CONFIG_ENV_SIZE -# error "Need to define CONFIG_ENV_SIZE when using CONFIG_ENV_IS_IN_UBI" -# endif -# ifndef CONFIG_CMD_UBI -# error "Need to define CONFIG_CMD_UBI when using CONFIG_ENV_IS_IN_UBI" -# endif -#endif /* CONFIG_ENV_IS_IN_UBI */ - -/* Embedded env is only supported for some flash types */ -#ifdef CONFIG_ENV_IS_EMBEDDED -# if !defined(CONFIG_ENV_IS_IN_FLASH) && \ - !defined(CONFIG_ENV_IS_IN_NAND) && \ - !defined(CONFIG_ENV_IS_IN_ONENAND) && \ - !defined(CONFIG_ENV_IS_IN_SPI_FLASH) -# error "CONFIG_ENV_IS_EMBEDDED not supported for your flash type" -# endif -#endif - /* * For the flash types where embedded env is supported, but it cannot be * calculated automatically (i.e. NAND), take the board opt-in. @@ -175,7 +110,11 @@ typedef struct environment_s { extern env_t embedded_environment; #endif /* ENV_IS_EMBEDDED */ -extern const unsigned char default_environment[]; +#ifdef DEFAULT_ENV_IS_RW +extern char default_environment[]; +#else +extern const char default_environment[]; +#endif #ifndef DO_DEPS_ONLY @@ -218,8 +157,7 @@ struct env_driver { /** * load() - Load the environment from storage * - * This method is optional. If not provided, no environment will be - * loaded. + * This method is required for loading environment * * @return 0 if OK, -ve on error */ @@ -271,8 +209,78 @@ struct env_driver { #define env_save_ptr(x) NULL #endif +#define ENV_SAVE_PTR(x) (CONFIG_IS_ENABLED(SAVEENV) ? (x) : NULL) +#define ENV_ERASE_PTR(x) (CONFIG_IS_ENABLED(CMD_ERASEENV) ? (x) : NULL) + extern struct hsearch_data env_htab; +/** + * env_ext4_get_intf() - Provide the interface for env in EXT4 + * + * It is a weak function allowing board to overidde the default interface for + * U-Boot env in EXT4: CONFIG_ENV_EXT4_INTERFACE + * + * Return: string of interface, empty if not supported + */ +const char *env_ext4_get_intf(void); + +/** + * env_ext4_get_dev_part() - Provide the device and partition for env in EXT4 + * + * It is a weak function allowing board to overidde the default device and + * partition used for U-Boot env in EXT4: CONFIG_ENV_EXT4_DEVICE_AND_PART + * + * Return: string of device and partition + */ +const char *env_ext4_get_dev_part(void); + +/** + * arch_env_get_location()- Provide the best location for the U-Boot environment + * + * It is a weak function allowing board to overidde the environment location + * on architecture level. This has lower priority than env_get_location(), + * which can be defined on board level. + * + * @op: operations performed on the environment + * @prio: priority between the multiple environments, 0 being the + * highest priority + * Return: an enum env_location value on success, or -ve error code. + */ +enum env_location arch_env_get_location(enum env_operation op, int prio); + +/** + * env_get_location()- Provide the best location for the U-Boot environment + * + * It is a weak function allowing board to overidde the environment location + * on board level. This has higher priority than arch_env_get_location(), + * which can be defined on architecture level. + * + * @op: operations performed on the environment + * @prio: priority between the multiple environments, 0 being the + * highest priority + * Return: an enum env_location value on success, or -ve error code. + */ +enum env_location env_get_location(enum env_operation op, int prio); + +/** + * env_fat_get_intf() - Provide the interface for env in FAT + * + * It is a weak function allowing board to overidde the default interface for + * U-Boot env in FAT: CONFIG_ENV_FAT_INTERFACE + * + * Return: string of interface, empty if not supported + */ +const char *env_fat_get_intf(void); + +/** + * env_fat_get_dev_part() - Provide the device and partition for env in FAT + * + * It is a weak function allowing board to overidde the default device and + * partition used for U-Boot env in FAT: CONFIG_ENV_FAT_DEVICE_AND_PART + * + * Return: string of device and partition + */ +char *env_fat_get_dev_part(void); #endif /* DO_DEPS_ONLY */ #endif /* _ENV_INTERNAL_H_ */