Author: stepan Date: Sun May 30 15:44:32 2010 New Revision: 5600 URL: https://tracker.coreboot.org/trac/coreboot/changeset/5600
Log: don't generate C source code file but use objcopy to include the SMM blob.
Signed-off-by: Stefan Reinauer stepan@coresystems.de Acked-by: Stefan Reinauer stepan@coresystems.de
Modified: trunk/src/cpu/x86/smm/Makefile.inc trunk/src/southbridge/intel/i82801dx/i82801dx_smi.c trunk/src/southbridge/intel/i82801gx/i82801gx_smi.c
Modified: trunk/src/cpu/x86/smm/Makefile.inc ============================================================================== --- trunk/src/cpu/x86/smm/Makefile.inc Sun May 30 14:56:17 2010 (r5599) +++ trunk/src/cpu/x86/smm/Makefile.inc Sun May 30 15:44:32 2010 (r5600) @@ -1,12 +1,11 @@ ## ## This file is part of the coreboot project. ## -## Copyright (C) 2008 coresystems GmbH +## Copyright (C) 2008-2010 coresystems GmbH ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 2 of the License, or -## (at your option) any later version. +## the Free Software Foundation; version 2 of the License. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -19,7 +18,7 @@ ##
obj-$(CONFIG_HAVE_SMI_HANDLER) += smmrelocate.o -obj-$(CONFIG_HAVE_SMI_HANDLER) += smm_bin.o +obj-$(CONFIG_HAVE_SMI_HANDLER) += smm_wrap.o
smmobj-y += smmhandler.o smmobj-y += smihandler.o @@ -33,10 +32,9 @@ $(NM) -n $(obj)/cpu/x86/smm/smm.elf | sort > $(obj)/cpu/x86/smm/smm.map $(OBJCOPY) -O binary $(obj)/cpu/x86/smm/smm.elf $(obj)/cpu/x86/smm/smm
-$(obj)/cpu/x86/smm/smm_bin.c: $(obj)/cpu/x86/smm/smm - (echo 'unsigned char smm[] = {'; od -vtx1 $(obj)/cpu/x86/smm/smm | sed -e 's,^[0-9]* *,,' -e 's:[0-9a-f][0-9a-f] :0x&,:g' -e 's:[0-9a-f][0-9a-f]$$:0x&,:'; echo '}; unsigned int smm_len = '; wc -c $(obj)/cpu/x86/smm/smm |awk '{print $$1;}' ; echo ';') > $@ - -$(obj)/cpu/x86/smm/smm_bin.o: $(obj)/cpu/x86/smm/smm_bin.c - @printf " CC $(subst $(obj)/,,$(@))\n" - $(CC) $(CFLAGS) -c -o $@ $< +# change to the target path because objcopy will use the path name in its +# ELF symbol names. +$(obj)/cpu/x86/smm/smm_wrap.o: $(obj)/cpu/x86/smm/smm + @printf " OBJCOPY $(subst $(obj)/,,$(@))\n" + cd $(obj)/cpu/x86/smm; $(OBJCOPY) -I binary smm -O elf32-i386 -B i386 smm_wrap.o
Modified: trunk/src/southbridge/intel/i82801dx/i82801dx_smi.c ============================================================================== --- trunk/src/southbridge/intel/i82801dx/i82801dx_smi.c Sun May 30 14:56:17 2010 (r5599) +++ trunk/src/southbridge/intel/i82801dx/i82801dx_smi.c Sun May 30 15:44:32 2010 (r5600) @@ -30,8 +30,8 @@ #include <string.h> #include "i82801dx.h"
-extern unsigned char smm[]; -extern unsigned int smm_len; +extern unsigned char _binary_smm_start; +extern unsigned char _binary_smm_size;
/* I945 */ #define SMRAM 0x90 @@ -325,7 +325,7 @@ D_OPEN | G_SMRAME | C_BASE_SEG);
/* copy the real SMM handler */ - memcpy((void *)0xa0000, smm, smm_len); + memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size); wbinvd();
/* close the SMM memory window and enable normal SMM */
Modified: trunk/src/southbridge/intel/i82801gx/i82801gx_smi.c ============================================================================== --- trunk/src/southbridge/intel/i82801gx/i82801gx_smi.c Sun May 30 14:56:17 2010 (r5599) +++ trunk/src/southbridge/intel/i82801gx/i82801gx_smi.c Sun May 30 15:44:32 2010 (r5600) @@ -30,8 +30,8 @@ #include <string.h> #include "i82801gx.h"
-extern unsigned char smm[]; -extern unsigned int smm_len; +extern unsigned char _binary_smm_start; +extern unsigned char _binary_smm_size;
/* I945 */ #define SMRAM 0x9d @@ -325,7 +325,7 @@ D_OPEN | G_SMRAME | C_BASE_SEG);
/* copy the real SMM handler */ - memcpy((void *)0xa0000, smm, smm_len); + memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size); wbinvd();
/* close the SMM memory window and enable normal SMM */
repository service wrote:
+++ trunk/src/cpu/x86/smm/Makefile.inc Sun May 30 15:44:32 2010 (r5600)
..
- cd $(obj)/cpu/x86/smm; $(OBJCOPY) -I binary smm -O elf32-i386 -B i386 smm_wrap.o
Could use --redefine-sym and -N to manage symbol names. An example at http://www.coreboot.org/Initramfs
+++ trunk/src/southbridge/intel/i82801dx/i82801dx_smi.c Sun May 30 15:44:32 2010 (r5600)
..
+extern unsigned char _binary_smm_start; +extern unsigned char _binary_smm_size;
..
- memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size);
+++ trunk/src/southbridge/intel/i82801gx/i82801gx_smi.c Sun May 30 15:44:32 2010 (r5600)
..
- memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size);
Is the pointer to _size really right?
//Peter
Am 01.06.2010 07:44, schrieb Peter Stuge:
repository service wrote:
+++ trunk/src/cpu/x86/smm/Makefile.inc Sun May 30 15:44:32 2010 (r5600)
..
- cd $(obj)/cpu/x86/smm; $(OBJCOPY) -I binary smm -O elf32-i386 -B i386 smm_wrap.o
Could use --redefine-sym and -N to manage symbol names. An example at http://www.coreboot.org/Initramfs
We'd have to cope with all mangling rules that objcopy applies to the full path. This is more robust.
And we can't use the same symbols we used to use, as the semantics of size are different. Better use different ones, so any issue breaks the build instead of breaking runtime.
+++ trunk/src/southbridge/intel/i82801dx/i82801dx_smi.c Sun May 30 15:44:32 2010 (r5600)
..
+extern unsigned char _binary_smm_start; +extern unsigned char _binary_smm_size;
..
- memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size);
+++ trunk/src/southbridge/intel/i82801gx/i82801gx_smi.c Sun May 30 15:44:32 2010 (r5600)
..
- memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size);
Is the pointer to _size really right?
Yes, objcopy doesn't store the size as a value in memory, but simply stuffs another symbol into the symbol table. We don't want the value at *(number of bytes), which is what we'd get without the dereference.
Patrick
Patrick Georgi wrote:
Could use --redefine-sym and -N to manage symbol names.
We'd have to cope with all mangling rules that objcopy applies to the full path. This is more robust.
And we can't use the same symbols we used to use, as the semantics of size are different. Better use different ones, so any issue breaks the build instead of breaking runtime.
Sure thing.
+extern unsigned char _binary_smm_size;
..
- memcpy((void *)0xa0000, &_binary_smm_start, (size_t)&_binary_smm_size);
Is the pointer to _size really right?
Yes, objcopy doesn't store the size as a value in memory, but simply stuffs another symbol into the symbol table.
Nod.
We don't want the value at *(number of bytes), which is what we'd get without the dereference.
Without the *reference* - right?
How about this then? Maybe both for start and size.
extern unsigned char _binary_smm_size[];
//Peter
On 6/1/10 8:41 AM, Peter Stuge wrote:
We don't want the value at *(number of bytes), which is what we'd get without the dereference.
Without the *reference* - right?
How about this then? Maybe both for start and size.
extern unsigned char _binary_smm_size[];
Might work... It would sure be nicer than the current solution. if you can verify it does work, a patch would be very much appreciated!
Stefan