0002-env-split-fw_env.h-in-public-and-private-parts.patch 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. From 4c3ec6eb73e178a0c5fa58489fae92578cfe1ac3 Mon Sep 17 00:00:00 2001
  2. From: Stefano Babic <sbabic@denx.de>
  3. Date: Sun, 8 Jan 2017 17:50:10 +0100
  4. Subject: [PATCH v1 2/4] env: split fw_env.h in public and private parts
  5. Move U-Boot private data into a separate file. This
  6. lets export fw_env.h to be used by external programs
  7. that want to change the environment using the library
  8. built in tools/env.
  9. Signed-off-by: Stefano Babic <sbabic@denx.de>
  10. ---
  11. common/env_flags.c | 1 +
  12. tools/env/fw_env.c | 1 +
  13. tools/env/fw_env.h | 51 +-----------------------------------------
  14. tools/env/fw_env_main.c | 1 +
  15. tools/env/fw_env_private.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++
  16. 5 files changed, 59 insertions(+), 50 deletions(-)
  17. create mode 100644 tools/env/fw_env_private.h
  18. diff --git a/common/env_flags.c b/common/env_flags.c
  19. index 921d377..3c50620 100644
  20. --- a/common/env_flags.c
  21. +++ b/common/env_flags.c
  22. @@ -11,6 +11,7 @@
  23. #ifdef USE_HOSTCC /* Eliminate "ANSI does not permit..." warnings */
  24. #include <stdint.h>
  25. #include <stdio.h>
  26. +#include "fw_env_private.h"
  27. #include "fw_env.h"
  28. #include <env_attr.h>
  29. #include <env_flags.h>
  30. diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
  31. index 862a0b1..fc3f4ce 100644
  32. --- a/tools/env/fw_env.c
  33. +++ b/tools/env/fw_env.c
  34. @@ -34,6 +34,7 @@
  35. # include <mtd/mtd-user.h>
  36. #endif
  37. +#include "fw_env_private.h"
  38. #include "fw_env.h"
  39. struct env_opts default_opts = {
  40. diff --git a/tools/env/fw_env.h b/tools/env/fw_env.h
  41. index 0d7130a..3e5539d 100644
  42. --- a/tools/env/fw_env.h
  43. +++ b/tools/env/fw_env.h
  44. @@ -5,57 +5,8 @@
  45. * SPDX-License-Identifier: GPL-2.0+
  46. */
  47. -#include <uboot_aes.h>
  48. #include <stdint.h>
  49. -
  50. -/* Pull in the current config to define the default environment */
  51. -#include <linux/kconfig.h>
  52. -
  53. -#ifndef __ASSEMBLY__
  54. -#define __ASSEMBLY__ /* get only #defines from config.h */
  55. -#include <config.h>
  56. -#undef __ASSEMBLY__
  57. -#else
  58. -#include <config.h>
  59. -#endif
  60. -
  61. -/*
  62. - * To build the utility with the static configuration
  63. - * comment out the next line.
  64. - * See included "fw_env.config" sample file
  65. - * for notes on configuration.
  66. - */
  67. -#define CONFIG_FILE "/etc/fw_env.config"
  68. -
  69. -#ifndef CONFIG_FILE
  70. -#define HAVE_REDUND /* For systems with 2 env sectors */
  71. -#define DEVICE1_NAME "/dev/mtd1"
  72. -#define DEVICE2_NAME "/dev/mtd2"
  73. -#define DEVICE1_OFFSET 0x0000
  74. -#define ENV1_SIZE 0x4000
  75. -#define DEVICE1_ESIZE 0x4000
  76. -#define DEVICE1_ENVSECTORS 2
  77. -#define DEVICE2_OFFSET 0x0000
  78. -#define ENV2_SIZE 0x4000
  79. -#define DEVICE2_ESIZE 0x4000
  80. -#define DEVICE2_ENVSECTORS 2
  81. -#endif
  82. -
  83. -#ifndef CONFIG_BAUDRATE
  84. -#define CONFIG_BAUDRATE 115200
  85. -#endif
  86. -
  87. -#ifndef CONFIG_BOOTDELAY
  88. -#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
  89. -#endif
  90. -
  91. -#ifndef CONFIG_BOOTCOMMAND
  92. -#define CONFIG_BOOTCOMMAND \
  93. - "bootp; " \
  94. - "setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} " \
  95. - "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; " \
  96. - "bootm"
  97. -#endif
  98. +#include <uboot_aes.h>
  99. struct env_opts {
  100. #ifdef CONFIG_FILE
  101. diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
  102. index 443de36..b8bff26 100644
  103. --- a/tools/env/fw_env_main.c
  104. +++ b/tools/env/fw_env_main.c
  105. @@ -34,6 +34,7 @@
  106. #include <stdlib.h>
  107. #include <sys/file.h>
  108. #include <unistd.h>
  109. +#include "fw_env_private.h"
  110. #include "fw_env.h"
  111. #define CMD_PRINTENV "fw_printenv"
  112. diff --git a/tools/env/fw_env_private.h b/tools/env/fw_env_private.h
  113. new file mode 100644
  114. index 0000000..0c27da0
  115. --- /dev/null
  116. +++ b/tools/env/fw_env_private.h
  117. @@ -0,0 +1,55 @@
  118. +/*
  119. + * (C) Copyright 2002-2008
  120. + * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  121. + *
  122. + * SPDX-License-Identifier: GPL-2.0+
  123. + */
  124. +
  125. +/* Pull in the current config to define the default environment */
  126. +#include <linux/kconfig.h>
  127. +
  128. +#ifndef __ASSEMBLY__
  129. +#define __ASSEMBLY__ /* get only #defines from config.h */
  130. +#include <config.h>
  131. +#undef __ASSEMBLY__
  132. +#else
  133. +#include <config.h>
  134. +#endif
  135. +
  136. +/*
  137. + * To build the utility with the static configuration
  138. + * comment out the next line.
  139. + * See included "fw_env.config" sample file
  140. + * for notes on configuration.
  141. + */
  142. +#define CONFIG_FILE "/etc/fw_env.config"
  143. +
  144. +#ifndef CONFIG_FILE
  145. +#define HAVE_REDUND /* For systems with 2 env sectors */
  146. +#define DEVICE1_NAME "/dev/mtd1"
  147. +#define DEVICE2_NAME "/dev/mtd2"
  148. +#define DEVICE1_OFFSET 0x0000
  149. +#define ENV1_SIZE 0x4000
  150. +#define DEVICE1_ESIZE 0x4000
  151. +#define DEVICE1_ENVSECTORS 2
  152. +#define DEVICE2_OFFSET 0x0000
  153. +#define ENV2_SIZE 0x4000
  154. +#define DEVICE2_ESIZE 0x4000
  155. +#define DEVICE2_ENVSECTORS 2
  156. +#endif
  157. +
  158. +#ifndef CONFIG_BAUDRATE
  159. +#define CONFIG_BAUDRATE 115200
  160. +#endif
  161. +
  162. +#ifndef CONFIG_BOOTDELAY
  163. +#define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */
  164. +#endif
  165. +
  166. +#ifndef CONFIG_BOOTCOMMAND
  167. +#define CONFIG_BOOTCOMMAND \
  168. + "bootp; " \
  169. + "setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} "\
  170. + "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; "\
  171. + "bootm"
  172. +#endif
  173. --
  174. 2.7.4