public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH V2] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST
@ 2008-04-20 17:37 Matthias Fuchs
  2008-04-20 23:45 ` Wolfgang Denk
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias Fuchs @ 2008-04-20 17:37 UTC (permalink / raw)
  To: u-boot

This patch adds a configurable flash auto protection list that can be used
to make U-Boot protect flash regions in flash_init().

The idea has been discussed on the u-boot mailing list starting
on Nov 18th, 2007.

Even this patch brings a new feature it is used as a bugfix for 4xx
platforms where flash_init() does not completely protect the
monitor's flash range in all situations.

U-Boot protects the flash range from CFG_MONITOR_BASE to
(CFG_MONITOR_BASE + monitor_flash_len  - 1) by default. This does not
include the reset vector at 0xfffffffc.

Example:
#define CFG_FLASH_AUTOPROTECT_LIST {{0xfff80000, 0x80000}}

This config option will auto protect the last 512k of flash that
contains the bootloader on board like APC405 and PMC405.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
---
 drivers/mtd/cfi_flash.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index e3cfb8a..fad9e8b 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -169,6 +169,17 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS];		/* FLASH chips info */
 #define CFG_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
 #endif
 
+struct apl_s {
+	ulong start;
+	ulong size;
+};
+
+#if !defined(CFG_FLASH_AUTOPROTECT_LIST)
+struct apl_s apl[] = {};
+#else
+struct apl_s apl[] = CFG_FLASH_AUTOPROTECT_LIST;
+#endif
+
 typedef unsigned long flash_sect_t;
 
 /* CFI standard query structure */
@@ -1966,6 +1977,16 @@ unsigned long flash_init (void)
 		       CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
 		       flash_get_info(CFG_ENV_ADDR_REDUND));
 #endif
+
+	for (i = 0; i < ARRAY_SIZE(apl); i++) {
+		debug ("autoprotecting from %08x to %08x\n",
+		       apl[i].start, apl[i].start + apl[i].size - 1);
+		flash_protect (FLAG_PROTECT_SET,
+			       apl[i].start,
+			       apl[i].start + apl[i].size - 1,
+			       flash_get_info (apl[i].start));
+	}
+
 	return (size);
 }
 
-- 
1.5.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot-Users] [PATCH V2] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST
  2008-04-20 17:37 [U-Boot-Users] [PATCH V2] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST Matthias Fuchs
@ 2008-04-20 23:45 ` Wolfgang Denk
  2008-04-21  7:23   ` Matthias Fuchs
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Denk @ 2008-04-20 23:45 UTC (permalink / raw)
  To: u-boot

In message <200804201937.32557.matthias.fuchs@esd-electronics.com> you wrote:
> This patch adds a configurable flash auto protection list that can be used
> to make U-Boot protect flash regions in flash_init().
> 
> The idea has been discussed on the u-boot mailing list starting
> on Nov 18th, 2007.
> 
> Even this patch brings a new feature it is used as a bugfix for 4xx
> platforms where flash_init() does not completely protect the
> monitor's flash range in all situations.
> 
> U-Boot protects the flash range from CFG_MONITOR_BASE to
> (CFG_MONITOR_BASE + monitor_flash_len  - 1) by default. This does not
> include the reset vector at 0xfffffffc.
> 
> Example:
> #define CFG_FLASH_AUTOPROTECT_LIST {{0xfff80000, 0x80000}}
> 
> This config option will auto protect the last 512k of flash that
> contains the bootloader on board like APC405 and PMC405.
> 
> Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
> ---
>  drivers/mtd/cfi_flash.c |   21 +++++++++++++++++++++
>  1 files changed, 21 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
> index e3cfb8a..fad9e8b 100644
> --- a/drivers/mtd/cfi_flash.c
> +++ b/drivers/mtd/cfi_flash.c
> @@ -169,6 +169,17 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS];		/* FLASH chips info */
>  #define CFG_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
>  #endif
>  
> +struct apl_s {
> +	ulong start;
> +	ulong size;
> +};
> +
> +#if !defined(CFG_FLASH_AUTOPROTECT_LIST)
> +struct apl_s apl[] = {};
> +#else
> +struct apl_s apl[] = CFG_FLASH_AUTOPROTECT_LIST;
> +#endif

No. Please don't add any code nor data when CFG_FLASH_AUTOPROTECT_LIST
is undefined.

>  typedef unsigned long flash_sect_t;
>  
>  /* CFI standard query structure */
> @@ -1966,6 +1977,16 @@ unsigned long flash_init (void)
>  		       CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
>  		       flash_get_info(CFG_ENV_ADDR_REDUND));
>  #endif
> +
> +	for (i = 0; i < ARRAY_SIZE(apl); i++) {
> +		debug ("autoprotecting from %08x to %08x\n",
> +		       apl[i].start, apl[i].start + apl[i].size - 1);
> +		flash_protect (FLAG_PROTECT_SET,
> +			       apl[i].start,
> +			       apl[i].start + apl[i].size - 1,
> +			       flash_get_info (apl[i].start));
> +	}
> +

No. Please don't add any code nor data when CFG_FLASH_AUTOPROTECT_LIST
is undefined.

NAK.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Lady Nancy Astor:
    "Winston, if you were my husband, I'd put poison in your coffee."
Winston Churchill:
    "Nancy, if you were my wife, I'd drink it."

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot-Users] [PATCH V2] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST
  2008-04-20 23:45 ` Wolfgang Denk
@ 2008-04-21  7:23   ` Matthias Fuchs
  2008-04-25 13:53     ` Stefan Roese
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias Fuchs @ 2008-04-21  7:23 UTC (permalink / raw)
  To: u-boot

Hi,

let me summarize: let's take my initial patch that I posted on Friday.
At least two people will be satisfied :-)

Matthias

On Monday 21 April 2008 01:45, Wolfgang Denk wrote:
> In message <200804201937.32557.matthias.fuchs@esd-electronics.com> you wrote:
> > This patch adds a configurable flash auto protection list that can be used
> > to make U-Boot protect flash regions in flash_init().
> > 
> > The idea has been discussed on the u-boot mailing list starting
> > on Nov 18th, 2007.
> > 
> > Even this patch brings a new feature it is used as a bugfix for 4xx
> > platforms where flash_init() does not completely protect the
> > monitor's flash range in all situations.
> > 
> > U-Boot protects the flash range from CFG_MONITOR_BASE to
> > (CFG_MONITOR_BASE + monitor_flash_len  - 1) by default. This does not
> > include the reset vector at 0xfffffffc.
> > 
> > Example:
> > #define CFG_FLASH_AUTOPROTECT_LIST {{0xfff80000, 0x80000}}
> > 
> > This config option will auto protect the last 512k of flash that
> > contains the bootloader on board like APC405 and PMC405.
> > 
> > Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
> > ---
> >  drivers/mtd/cfi_flash.c |   21 +++++++++++++++++++++
> >  1 files changed, 21 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
> > index e3cfb8a..fad9e8b 100644
> > --- a/drivers/mtd/cfi_flash.c
> > +++ b/drivers/mtd/cfi_flash.c
> > @@ -169,6 +169,17 @@ flash_info_t flash_info[CFG_MAX_FLASH_BANKS];		/* FLASH chips info */
> >  #define CFG_FLASH_CFI_WIDTH	FLASH_CFI_8BIT
> >  #endif
> >  
> > +struct apl_s {
> > +	ulong start;
> > +	ulong size;
> > +};
> > +
> > +#if !defined(CFG_FLASH_AUTOPROTECT_LIST)
> > +struct apl_s apl[] = {};
> > +#else
> > +struct apl_s apl[] = CFG_FLASH_AUTOPROTECT_LIST;
> > +#endif
> 
> No. Please don't add any code nor data when CFG_FLASH_AUTOPROTECT_LIST
> is undefined.
> 
> >  typedef unsigned long flash_sect_t;
> >  
> >  /* CFI standard query structure */
> > @@ -1966,6 +1977,16 @@ unsigned long flash_init (void)
> >  		       CFG_ENV_ADDR_REDUND + CFG_ENV_SIZE_REDUND - 1,
> >  		       flash_get_info(CFG_ENV_ADDR_REDUND));
> >  #endif
> > +
> > +	for (i = 0; i < ARRAY_SIZE(apl); i++) {
> > +		debug ("autoprotecting from %08x to %08x\n",
> > +		       apl[i].start, apl[i].start + apl[i].size - 1);
> > +		flash_protect (FLAG_PROTECT_SET,
> > +			       apl[i].start,
> > +			       apl[i].start + apl[i].size - 1,
> > +			       flash_get_info (apl[i].start));
> > +	}
> > +
> 
> No. Please don't add any code nor data when CFG_FLASH_AUTOPROTECT_LIST
> is undefined.
> 
> NAK.
> 
> Best regards,
> 
> Wolfgang Denk
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot-Users] [PATCH V2] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST
  2008-04-21  7:23   ` Matthias Fuchs
@ 2008-04-25 13:53     ` Stefan Roese
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2008-04-25 13:53 UTC (permalink / raw)
  To: u-boot

On Monday 21 April 2008, Matthias Fuchs wrote:
> let me summarize: let's take my initial patch that I posted on Friday.
> At least two people will be satisfied :-)

OK.

I applied the first version to the u-boot-cfi-flash repository.

Thanks.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-04-25 13:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-20 17:37 [U-Boot-Users] [PATCH V2] cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST Matthias Fuchs
2008-04-20 23:45 ` Wolfgang Denk
2008-04-21  7:23   ` Matthias Fuchs
2008-04-25 13:53     ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox