[coreboot] [PATCH] v3: variables can't be stored in ROM

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Sun Aug 10 01:36:35 CEST 2008


On 10.08.2008 01:20, Carl-Daniel Hailfinger wrote:
> On 10.08.2008 01:15, Peter Stuge wrote:
>   
>> On Sun, Aug 10, 2008 at 12:57:42AM +0200, Carl-Daniel Hailfinger wrote:
>>   
>>     
>>>> -static int console_loglevel(void)
>>>> +static int loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
>>>>       
>>>>         
>>> NACK that part. It will not work and/or it will crash. Sorry.
>>>
>>> I take the NACK back if you explain how you can store a variable
>>> (not a constant) in ROM.
>>>     
>>>       
>> Doesn't it live on the heap/stack in cache?
>>   
>>     
>
> Unfortunately not. It's a global variable (so not on stack) and we do
> nothing to allow global variables. Look at the hoops the printk buffer
> code is jumping through to get some sort of global variables.
>
> The good news is that the printk buffer helpers can be amended to store
> any number of global variables.
>   

Patch for a temporary fixup follows.


Variables can't be stored in ROM. It's called readonly for a reason.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: corebootv3-console_loglevel_global_revert/lib/console.c
===================================================================
--- corebootv3-console_loglevel_global_revert/lib/console.c	(Revision 729)
+++ corebootv3-console_loglevel_global_revert/lib/console.c	(Arbeitskopie)
@@ -8,8 +8,6 @@
 int vtxprintf(void (*)(unsigned char, void *arg), 
 		void *arg, const char *, va_list);
 
-static unsigned int loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
-
 /**
  * set the console log level
  * There are no invalid settings, although there are ones that 
@@ -21,7 +19,7 @@
 	if (level > BIOS_SPEW)
 		printk(BIOS_ALWAYS, "Warning: ridiculous log level setting: %d (max %d)\n", 
 			level, BIOS_SPEW);
-	loglevel = level;
+#warning Setting the log level is unimplemented
 }
 
 /**
@@ -31,7 +29,8 @@
  */
 static unsigned int console_loglevel(void)
 {
-	return loglevel;
+#warning This always returns the default loglevel
+	return CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
 }
 
 #ifdef CONFIG_CONSOLE_BUFFER


-- 
http://www.hailfinger.org/





More information about the coreboot mailing list