[PATCH] RFC: Change ofmem_common.c to set memory translation properties by reference
by Mark Cave-Ayland
Hi folks,
The attached patch changes OFMEM so that instead of allocating new space
within the Forth dictionary every time the /memory and /virtual-memory
available/translations nodes are updated, we simply change the property
to point directly to a static buffer. This has the effect of saving
substantial amounts of memory during OpenSolaris 10 boot (in fact the
final dictionary size after boot is now < 256K once again).
Blue/Andreas: please could you take a look at this patch and make sure
it doesn't break anything in your SPARC64/PPC tests?
On the plus side, with this patch applied Milax gets to the end of its
natural boot without crashing giving the following output:
OpenBIOS for Sparc64
Configuration device id QEMU version 1 machine id 0
kernel cmdline
CPUs: 1 x SUNW,UltraSPARC-IIi
UUID: 00000000-0000-0000-0000-000000000000
Welcome to OpenBIOS v1.0 built on Oct 14 2010 20:18
Type 'help' for detailed information
Trying cdrom:f...
Not a bootable ELF image
Not a bootable a.out image
Loading FCode image...
Loaded 7084 bytes
entry point is 0x4000
Ignoring failed claim for va 1000000 memsz bf34e!
Ignoring failed claim for va 1402000 memsz 303b3!
Ignoring failed claim for va 1800000 memsz 60a30!
Jumping to entry point 00000000010071d8 for type 0000000000000001...
switching to new context: entry point 0x10071d8 stack 0x00000000ffe06b49
warning:interpret: exception -13 caught
SunOS Release 5.11 Version MilaX_0.3.2 64-bit
Copyright 1983-2008 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
spacex@:interpret: exception -13 caught
kdbg-words:interpret: exception -13 caught
cb-r/w:interpret: exception -13 caught
(Can't load tod module) EXIT
-1 >
Does anyone know what the tod modules does? Is it Time Of Day (i.e. we
are missing some kind of hardware clock emulation?)
ATB,
Mark.
--
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063
Sirius Labs: http://www.siriusit.co.uk/labs
8 years, 7 months
[PATCH] ESP : Fix SCSI READ command length
by Olivier DANET
Signed-off-by: Olivier Danet <odanet(a)caramail.com>
---
diff -rup a/drivers/esp.c b/drivers/esp.c
--- a/drivers/esp.c 2011-01-27 15:11:52.000000000 +0100
+++ b/drivers/esp.c 2011-01-27 15:13:34.000000000 +0100
@@ -147,7 +147,7 @@ ob_sd_read_sector(esp_private_t *esp, sd
sd->id, offset);
// Setup command = Read(10)
- memset(esp->buffer, 0, 10);
+ memset(esp->buffer, 0, 11);
esp->buffer[0] = 0x80;
esp->buffer[1] = READ_10;
@@ -159,7 +159,7 @@ ob_sd_read_sector(esp_private_t *esp, sd
esp->buffer[8] = 0;
esp->buffer[9] = 1;
- if (do_command(esp, sd, 10, sd->bs))
+ if (do_command(esp, sd, 11, sd->bs))
return 0;
return 0;
8 years, 9 months
State of AIX
by Grieve, Shane
I have been following the AIX booting issue for a while now and was
wondering if there is any progress. I have access to AIX hardware and I
am happy to help test.
Thanks
Shane
8 years, 9 months
[PATCH 4/4] ppc: avoid runtime relocations
by Blue Swirl
Because the sizes of cells and pointers do not match on PPC64,
relocations of an ucell array using the address of the array itself
can't be computed by the linker.
Use a fixed address on PPC64 for the array, so we can use a fixed
ucell sized constant for the relocation offset.
Signed-off-by: Blue Swirl <blauwirbel(a)gmail.com>
---
arch/ppc/build.xml | 6 +-----
arch/ppc/qemu/kernel.c | 23 ++++++++++++++++++-----
arch/ppc/qemu/ofmem.c | 2 +-
arch/ppc64/qemu/ldscript | 7 +++++++
4 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/arch/ppc/build.xml b/arch/ppc/build.xml
index 4aec62f..8468799 100644
--- a/arch/ppc/build.xml
+++ b/arch/ppc/build.xml
@@ -60,11 +60,7 @@
<executable name="target/include/qemu-dict.h" target="target"
condition="QEMU">
<rule><![CDATA[
- $(call quiet-command,true, " GEN $(TARGET_DIR)$@")
- @echo "static const char forth_dictionary[] = {" > $@
- @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
- | sed 's/0x ,//g' >> $@
- @echo "};" >> $@]]></rule>
+ $(call quiet-command,$(ODIR)/forthstrap -x -D $@ -d $< </dev/null, "
GEN $(TARGET_DIR)$@")]]></rule>
<external-object source="openbios-qemu.dict"/>
</executable>
diff --git a/arch/ppc/qemu/kernel.c b/arch/ppc/qemu/kernel.c
index 4cae525..b26fba5 100644
--- a/arch/ppc/qemu/kernel.c
+++ b/arch/ppc/qemu/kernel.c
@@ -17,7 +17,6 @@
*
*/
-#include "qemu-dict.h"
#include "config.h"
#include "dict.h"
#include "libopenbios/bindings.h"
@@ -27,7 +26,19 @@
#include "kernel.h"
#define MEMORY_SIZE (256*1024) /* 256K ram for hosted system */
-#define DICTIONARY_SIZE (512*1024) /* 512K for the dictionary */
+/* 512K for the dictionary */
+#define DICTIONARY_SIZE (512 * 1024 / sizeof(ucell))
+#ifdef __powerpc64__
+#define DICTIONARY_BASE 0xfff08000 /* this must match the value in ldscript! */
+#define DICTIONARY_SECTION __attribute__((section(".data.dict")))
+#else
+#define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary))
+#define DICTIONARY_SECTION
+#endif
+
+static ucell forth_dictionary[DICTIONARY_SIZE] DICTIONARY_SECTION = {
+#include "qemu-dict.h"
+};
static ucell *memory;
@@ -82,10 +93,12 @@ init_memory( void )
int
initialize_forth( void )
{
- dict = malloc(DICTIONARY_SIZE);
- dictlimit = DICTIONARY_SIZE;
+ dict = (unsigned char *)forth_dictionary;
+ dicthead = (ucell)FORTH_DICTIONARY_END;
+ last = (ucell *)((unsigned char *)forth_dictionary +
+ FORTH_DICTIONARY_LAST);
+ dictlimit = sizeof(forth_dictionary);
- load_dictionary( forth_dictionary, sizeof(forth_dictionary) );
forth_init();
PUSH_xt( bind_noname_func(arch_of_init) );
diff --git a/arch/ppc/qemu/ofmem.c b/arch/ppc/qemu/ofmem.c
index 4c6825e..f6cf8cd 100644
--- a/arch/ppc/qemu/ofmem.c
+++ b/arch/ppc/qemu/ofmem.c
@@ -55,7 +55,7 @@ extern void setup_mmu(unsigned long code_base);
#define HASH_BITS 15
#endif
#define HASH_SIZE (2 << HASH_BITS)
-#define OFMEM_SIZE (2 * 1024 * 1024)
+#define OFMEM_SIZE (1 * 1024 * 1024 + 512 * 1024)
#define SEGR_USER BIT(2)
#define SEGR_BASE 0x0400
diff --git a/arch/ppc64/qemu/ldscript b/arch/ppc64/qemu/ldscript
index 7a22903..fbbcc54 100644
--- a/arch/ppc64/qemu/ldscript
+++ b/arch/ppc64/qemu/ldscript
@@ -6,6 +6,7 @@ OUTPUT_ARCH(powerpc:common64)
BASE_ADDR = 0xfff00000;
/* As NVRAM is at 0xfff04000, the .text needs to be after that
+ * The value in arch/ppc/qemu/kernel.c must match this value!
*/
TEXT_ADDR = 0xfff08000;
@@ -26,6 +27,12 @@ SECTIONS
. = TEXT_ADDR;
/* Normal sections */
+ .data.dict ALIGN(4096): {
+ _dict_start = .;
+ *(.data.dict)
+ _dict_end = .;
+ }
+
.text ALIGN(4096): {
*(.text)
*(.text.*)
--
1.6.2.4
8 years, 10 months
[commit] r1018 - in trunk/openbios-devel/arch: ppc ppc/qemu ppc64/qemu
by repository service
Author: blueswirl
Date: Sun Jan 30 14:07:40 2011
New Revision: 1018
URL: http://tracker.coreboot.org/trac/openbios/changeset/1018
Log:
ppc: avoid runtime relocations
Because the sizes of cells and pointers do not match on PPC64,
relocations of an ucell array using the address of the array itself
can't be computed by the linker.
Use a fixed address on PPC64 for the array, so we can use a fixed
ucell sized constant for the relocation offset.
Signed-off-by: Blue Swirl <blauwirbel(a)gmail.com>
Modified:
trunk/openbios-devel/arch/ppc/build.xml
trunk/openbios-devel/arch/ppc/qemu/kernel.c
trunk/openbios-devel/arch/ppc/qemu/ofmem.c
trunk/openbios-devel/arch/ppc64/qemu/ldscript
Modified: trunk/openbios-devel/arch/ppc/build.xml
==============================================================================
--- trunk/openbios-devel/arch/ppc/build.xml Sun Jan 30 14:07:37 2011 (r1017)
+++ trunk/openbios-devel/arch/ppc/build.xml Sun Jan 30 14:07:40 2011 (r1018)
@@ -60,11 +60,7 @@
<executable name="target/include/qemu-dict.h" target="target" condition="QEMU">
<rule><![CDATA[
- $(call quiet-command,true, " GEN $(TARGET_DIR)$@")
- @echo "static const char forth_dictionary[] = {" > $@
- @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
- | sed 's/0x ,//g' >> $@
- @echo "};" >> $@]]></rule>
+ $(call quiet-command,$(ODIR)/forthstrap -x -D $@ -d $< </dev/null, " GEN $(TARGET_DIR)$@")]]></rule>
<external-object source="openbios-qemu.dict"/>
</executable>
Modified: trunk/openbios-devel/arch/ppc/qemu/kernel.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/kernel.c Sun Jan 30 14:07:37 2011 (r1017)
+++ trunk/openbios-devel/arch/ppc/qemu/kernel.c Sun Jan 30 14:07:40 2011 (r1018)
@@ -17,7 +17,6 @@
*
*/
-#include "qemu-dict.h"
#include "config.h"
#include "dict.h"
#include "libopenbios/bindings.h"
@@ -27,7 +26,19 @@
#include "kernel.h"
#define MEMORY_SIZE (256*1024) /* 256K ram for hosted system */
-#define DICTIONARY_SIZE (512*1024) /* 512K for the dictionary */
+/* 512K for the dictionary */
+#define DICTIONARY_SIZE (512 * 1024 / sizeof(ucell))
+#ifdef __powerpc64__
+#define DICTIONARY_BASE 0xfff08000 /* this must match the value in ldscript! */
+#define DICTIONARY_SECTION __attribute__((section(".data.dict")))
+#else
+#define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary))
+#define DICTIONARY_SECTION
+#endif
+
+static ucell forth_dictionary[DICTIONARY_SIZE] DICTIONARY_SECTION = {
+#include "qemu-dict.h"
+};
static ucell *memory;
@@ -82,10 +93,12 @@
int
initialize_forth( void )
{
- dict = malloc(DICTIONARY_SIZE);
- dictlimit = DICTIONARY_SIZE;
+ dict = (unsigned char *)forth_dictionary;
+ dicthead = (ucell)FORTH_DICTIONARY_END;
+ last = (ucell *)((unsigned char *)forth_dictionary +
+ FORTH_DICTIONARY_LAST);
+ dictlimit = sizeof(forth_dictionary);
- load_dictionary( forth_dictionary, sizeof(forth_dictionary) );
forth_init();
PUSH_xt( bind_noname_func(arch_of_init) );
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c
==============================================================================
--- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sun Jan 30 14:07:37 2011 (r1017)
+++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Sun Jan 30 14:07:40 2011 (r1018)
@@ -55,7 +55,7 @@
#define HASH_BITS 15
#endif
#define HASH_SIZE (2 << HASH_BITS)
-#define OFMEM_SIZE (2 * 1024 * 1024)
+#define OFMEM_SIZE (1 * 1024 * 1024 + 512 * 1024)
#define SEGR_USER BIT(2)
#define SEGR_BASE 0x0400
Modified: trunk/openbios-devel/arch/ppc64/qemu/ldscript
==============================================================================
--- trunk/openbios-devel/arch/ppc64/qemu/ldscript Sun Jan 30 14:07:37 2011 (r1017)
+++ trunk/openbios-devel/arch/ppc64/qemu/ldscript Sun Jan 30 14:07:40 2011 (r1018)
@@ -6,6 +6,7 @@
BASE_ADDR = 0xfff00000;
/* As NVRAM is at 0xfff04000, the .text needs to be after that
+ * The value in arch/ppc/qemu/kernel.c must match this value!
*/
TEXT_ADDR = 0xfff08000;
@@ -26,6 +27,12 @@
. = TEXT_ADDR;
/* Normal sections */
+ .data.dict ALIGN(4096): {
+ _dict_start = .;
+ *(.data.dict)
+ _dict_end = .;
+ }
+
.text ALIGN(4096): {
*(.text)
*(.text.*)
8 years, 10 months
[commit] r1017 - trunk/openbios-devel/arch/x86
by repository service
Author: blueswirl
Date: Sun Jan 30 14:07:37 2011
New Revision: 1017
URL: http://tracker.coreboot.org/trac/openbios/changeset/1017
Log:
x86: avoid runtime relocations
Signed-off-by: Blue Swirl <blauwirbel(a)gmail.com>
Modified:
trunk/openbios-devel/arch/x86/build.xml
trunk/openbios-devel/arch/x86/builtin.c
trunk/openbios-devel/arch/x86/openbios.c
Modified: trunk/openbios-devel/arch/x86/build.xml
==============================================================================
--- trunk/openbios-devel/arch/x86/build.xml Sun Jan 30 14:07:34 2011 (r1016)
+++ trunk/openbios-devel/arch/x86/build.xml Sun Jan 30 14:07:37 2011 (r1017)
@@ -55,11 +55,7 @@
<executable name="target/include/static-dict.h" target="target" condition="IMAGE_ELF_EMBEDDED">
<rule><![CDATA[
- $(call quiet-command,true, " GEN $(TARGET_DIR)$@")
- @echo "static const char forth_dictionary[] = {" > $@
- @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
- | sed 's/0x ,//g' >> $@
- @echo "};" >> $@]]></rule>
+ $(call quiet-command,$(ODIR)/forthstrap -x -D $@ -d $< </dev/null, " GEN $(TARGET_DIR)$@")]]></rule>
<external-object source="openbios-x86.dict"/>
</executable>
Modified: trunk/openbios-devel/arch/x86/builtin.c
==============================================================================
--- trunk/openbios-devel/arch/x86/builtin.c Sun Jan 30 14:07:34 2011 (r1016)
+++ trunk/openbios-devel/arch/x86/builtin.c Sun Jan 30 14:07:37 2011 (r1017)
@@ -13,12 +13,20 @@
* wrap an array around the hex'ed dictionary file
*/
+/* 256K for the dictionary */
+#define DICTIONARY_SIZE (256 * 1024 / sizeof(ucell))
+#define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary))
+
+static ucell forth_dictionary[DICTIONARY_SIZE] = {
#include "static-dict.h"
+};
void collect_multiboot_info(struct sys_info *info);
void collect_multiboot_info(struct sys_info *info)
{
info->dict_start=(unsigned long *)forth_dictionary;
- info->dict_end=(unsigned long *)((ucell)forth_dictionary +
- sizeof(forth_dictionary));
+ info->dict_end = (unsigned long *)FORTH_DICTIONARY_END;
+ info->dict_last = (ucell *)((unsigned char *)forth_dictionary +
+ FORTH_DICTIONARY_LAST);
+ info->dict_limit = sizeof(forth_dictionary);
}
Modified: trunk/openbios-devel/arch/x86/openbios.c
==============================================================================
--- trunk/openbios-devel/arch/x86/openbios.c Sun Jan 30 14:07:34 2011 (r1016)
+++ trunk/openbios-devel/arch/x86/openbios.c Sun Jan 30 14:07:37 2011 (r1017)
@@ -22,9 +22,6 @@
void collect_sys_info(struct sys_info *info);
-#define DICTIONARY_SIZE (256*1024) /* 256K for the dictionary */
-static unsigned char intdict[DICTIONARY_SIZE];
-
#ifdef CONFIG_DRIVER_PCI
static const pci_arch_t default_pci_host = {
.name = "Intel,i440FX",
@@ -84,12 +81,11 @@
collect_sys_info(&sys_info);
- dict=intdict;
- dictlimit = DICTIONARY_SIZE;
+ dict = (unsigned char *)sys_info.dict_start;
+ dicthead = (cell)sys_info.dict_end;
+ last = sys_info.dict_last;
+ dictlimit = sys_info.dict_limit;
- load_dictionary((char *)sys_info.dict_start,
- (unsigned long)sys_info.dict_end -
- (unsigned long)sys_info.dict_start);
forth_init();
relocate(&sys_info);
8 years, 10 months
[commit] r1016 - trunk/openbios-devel/arch/sparc64
by repository service
Author: blueswirl
Date: Sun Jan 30 14:07:34 2011
New Revision: 1016
URL: http://tracker.coreboot.org/trac/openbios/changeset/1016
Log:
sparc64: avoid runtime relocations
Signed-off-by: Blue Swirl <blauwirbel(a)gmail.com>
Modified:
trunk/openbios-devel/arch/sparc64/build.xml
trunk/openbios-devel/arch/sparc64/builtin.c
trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
trunk/openbios-devel/arch/sparc64/openbios.c
Modified: trunk/openbios-devel/arch/sparc64/build.xml
==============================================================================
--- trunk/openbios-devel/arch/sparc64/build.xml Sun Jan 30 14:07:31 2011 (r1015)
+++ trunk/openbios-devel/arch/sparc64/build.xml Sun Jan 30 14:07:34 2011 (r1016)
@@ -40,11 +40,7 @@
<executable name="target/include/static-dict.h" target="target" condition="IMAGE_ELF_EMBEDDED">
<rule><![CDATA[
- $(call quiet-command,true, " GEN $(TARGET_DIR)$@")
- @echo "static const char forth_dictionary[] = {" > $@
- @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
- | sed 's/0x ,//g' >> $@
- @echo "};" >> $@]]></rule>
+ $(call quiet-command,$(ODIR)/forthstrap -x -D $@ -d $< </dev/null, " GEN $(TARGET_DIR)$@")]]></rule>
<external-object source="openbios-sparc64.dict"/>
</executable>
Modified: trunk/openbios-devel/arch/sparc64/builtin.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/builtin.c Sun Jan 30 14:07:31 2011 (r1015)
+++ trunk/openbios-devel/arch/sparc64/builtin.c Sun Jan 30 14:07:34 2011 (r1016)
@@ -14,12 +14,20 @@
* wrap an array around the hex'ed dictionary file
*/
+/* 512K for the dictionary */
+#define DICTIONARY_SIZE (512 * 1024 / sizeof(ucell))
+#define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary))
+
+static ucell forth_dictionary[DICTIONARY_SIZE] = {
#include "static-dict.h"
+};
void collect_multiboot_info(struct sys_info *info);
void collect_multiboot_info(struct sys_info *info)
{
info->dict_start=(unsigned long *)forth_dictionary;
- info->dict_end=(unsigned long *)((ucell)forth_dictionary +
- sizeof(forth_dictionary));
+ info->dict_end = (unsigned long *)FORTH_DICTIONARY_END;
+ info->dict_last = (ucell *)((unsigned char *)forth_dictionary +
+ FORTH_DICTIONARY_LAST);
+ info->dict_limit = sizeof(forth_dictionary);
}
Modified: trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sun Jan 30 14:07:31 2011 (r1015)
+++ trunk/openbios-devel/arch/sparc64/ofmem_sparc64.c Sun Jan 30 14:07:34 2011 (r1016)
@@ -20,7 +20,7 @@
#define OF_MALLOC_BASE ((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8))
-#define MEMSIZE ((256 + 512 + 512) * 1024)
+#define MEMSIZE ((256 + 512) * 1024)
static union {
char memory[MEMSIZE];
ofmem_t ofmem;
Modified: trunk/openbios-devel/arch/sparc64/openbios.c
==============================================================================
--- trunk/openbios-devel/arch/sparc64/openbios.c Sun Jan 30 14:07:31 2011 (r1015)
+++ trunk/openbios-devel/arch/sparc64/openbios.c Sun Jan 30 14:07:34 2011 (r1016)
@@ -33,7 +33,6 @@
#define APB_MEM_BASE 0x1ff00000000ULL
#define MEMORY_SIZE (512*1024) /* 512K ram for hosted system */
-#define DICTIONARY_SIZE (512*1024) /* 512K for the dictionary */
static ucell *memory;
@@ -617,12 +616,11 @@
collect_sys_info(&sys_info);
- dict = malloc(DICTIONARY_SIZE);
- dictlimit = DICTIONARY_SIZE;
+ dict = (unsigned char *)sys_info.dict_start;
+ dicthead = (cell)sys_info.dict_end;
+ last = sys_info.dict_last;
+ dictlimit = sys_info.dict_limit;
- load_dictionary((char *)sys_info.dict_start,
- (unsigned long)sys_info.dict_end
- - (unsigned long)sys_info.dict_start);
forth_init();
#ifdef CONFIG_DEBUG_BOOT
8 years, 10 months
[commit] r1015 - in trunk/openbios-devel: arch/sparc32 include/libopenbios kernel
by repository service
Author: blueswirl
Date: Sun Jan 30 14:07:31 2011
New Revision: 1015
URL: http://tracker.coreboot.org/trac/openbios/changeset/1015
Log:
sparc32: avoid runtime relocations
The Forth dictionary was relocated at run time, incurring also
a copy operation. The source dictionary remained in memory.
It was not possible to run forthstrap without any input files
besides the base dictionary.
Make forthstrap generate a hex dump which can be included in C,
but also contains relocations, so that relocations are performed
by the linker at compile time. Allow dictionary compilation
with no source files.
Don't allocate the dictionary dynamically; reduce ofmem supply
accordingly.
Signed-off-by: Blue Swirl <blauwirbel(a)gmail.com>
Modified:
trunk/openbios-devel/arch/sparc32/build.xml
trunk/openbios-devel/arch/sparc32/builtin.c
trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
trunk/openbios-devel/arch/sparc32/openbios.c
trunk/openbios-devel/include/libopenbios/sys_info.h
trunk/openbios-devel/kernel/bootstrap.c
Modified: trunk/openbios-devel/arch/sparc32/build.xml
==============================================================================
--- trunk/openbios-devel/arch/sparc32/build.xml Sat Jan 8 20:44:38 2011 (r1014)
+++ trunk/openbios-devel/arch/sparc32/build.xml Sun Jan 30 14:07:31 2011 (r1015)
@@ -42,11 +42,7 @@
<executable name="target/include/static-dict.h" target="target" condition="IMAGE_ELF_EMBEDDED">
<rule><![CDATA[
- $(call quiet-command,true, " GEN $(TARGET_DIR)$@")
- @echo "static const char forth_dictionary[] = {" > $@
- @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
- | sed 's/0x ,//g' >> $@
- @echo "};" >> $@]]></rule>
+ $(call quiet-command,$(ODIR)/forthstrap -x -D $@ -d $< </dev/null, " GEN $(TARGET_DIR)$@")]]></rule>
<external-object source="openbios-sparc32.dict"/>
</executable>
Modified: trunk/openbios-devel/arch/sparc32/builtin.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/builtin.c Sat Jan 8 20:44:38 2011 (r1014)
+++ trunk/openbios-devel/arch/sparc32/builtin.c Sun Jan 30 14:07:31 2011 (r1015)
@@ -14,12 +14,20 @@
* wrap an array around the hex'ed dictionary file
*/
+/* 256K for the dictionary */
+#define DICTIONARY_SIZE (256 * 1024 / sizeof(ucell))
+#define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary))
+
+static ucell forth_dictionary[DICTIONARY_SIZE] = {
#include "static-dict.h"
+};
void collect_multiboot_info(struct sys_info *info);
void collect_multiboot_info(struct sys_info *info)
{
info->dict_start=(unsigned long *)forth_dictionary;
- info->dict_end=(unsigned long *)((ucell)forth_dictionary +
- sizeof(forth_dictionary));
+ info->dict_end = (unsigned long *)FORTH_DICTIONARY_END;
+ info->dict_last = (ucell *)((unsigned char *)forth_dictionary +
+ FORTH_DICTIONARY_LAST);
+ info->dict_limit = sizeof(forth_dictionary);
}
Modified: trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sat Jan 8 20:44:38 2011 (r1014)
+++ trunk/openbios-devel/arch/sparc32/ofmem_sparc32.c Sun Jan 30 14:07:31 2011 (r1015)
@@ -21,7 +21,7 @@
#define OF_MALLOC_BASE ((char*)OFMEM + ALIGN_SIZE(sizeof(ofmem_t), 8))
-#define MEMSIZE (512 * 1024)
+#define MEMSIZE (256 * 1024)
static union {
char memory[MEMSIZE];
ofmem_t ofmem;
Modified: trunk/openbios-devel/arch/sparc32/openbios.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/openbios.c Sat Jan 8 20:44:38 2011 (r1014)
+++ trunk/openbios-devel/arch/sparc32/openbios.c Sun Jan 30 14:07:31 2011 (r1015)
@@ -28,7 +28,6 @@
#include "libopenbios/ofmem.h"
#define MEMORY_SIZE (16*1024) /* 16K ram for hosted system */
-#define DICTIONARY_SIZE (256*1024) /* 256K for the dictionary */
#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
#define FW_CFG_SUN4M_DEPTH (FW_CFG_ARCH_LOCAL + 0x00)
@@ -968,12 +967,11 @@
collect_sys_info(&sys_info);
- dict = malloc(DICTIONARY_SIZE);
- dictlimit = DICTIONARY_SIZE;
+ dict = (unsigned char *)sys_info.dict_start;
+ dicthead = (cell)sys_info.dict_end;
+ last = sys_info.dict_last;
+ dictlimit = sys_info.dict_limit;
- load_dictionary((char *)sys_info.dict_start,
- (unsigned long)sys_info.dict_end
- - (unsigned long)sys_info.dict_start);
forth_init();
#ifdef CONFIG_DEBUG_BOOT
Modified: trunk/openbios-devel/include/libopenbios/sys_info.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/sys_info.h Sat Jan 8 20:44:38 2011 (r1014)
+++ trunk/openbios-devel/include/libopenbios/sys_info.h Sun Jan 30 14:07:31 2011 (r1015)
@@ -20,6 +20,8 @@
} *memrange;
unsigned long *dict_start;
unsigned long *dict_end;
+ cell dict_limit;
+ ucell *dict_last;
};
extern void *elf_boot_notes;
Modified: trunk/openbios-devel/kernel/bootstrap.c
==============================================================================
--- trunk/openbios-devel/kernel/bootstrap.c Sat Jan 8 20:44:38 2011 (r1014)
+++ trunk/openbios-devel/kernel/bootstrap.c Sun Jan 30 14:07:31 2011 (r1015)
@@ -96,6 +96,11 @@
* dictionary related functions.
*/
+/*
+ * Compare two dictionaries constructed at different addresses. When
+ * the cells don't match, a need for relocation is detected and the
+ * corresponding bit in reloc_table bitmap is set.
+ */
static void relocation_table(unsigned char * dict_one, unsigned char *dict_two, int length)
{
ucell *d1=(ucell *)dict_one, *d2=(ucell *)dict_two;
@@ -237,6 +242,54 @@
#endif
}
+/*
+ * Write dictionary as a list of ucell hex values to filename. Array
+ * header and end lines are not generated.
+ *
+ * Cells with relocations are output using the expression
+ * DICTIONARY_BASE + value.
+ *
+ * Define some helpful constants.
+ */
+static void write_dictionary_hex(const char *filename)
+{
+ FILE *f;
+ ucell *walk;
+
+ f = fopen(filename, "w");
+ if (!f) {
+ printk("panic: can't write to dictionary '%s'.\n", filename);
+ exit(1);
+ }
+
+ for (walk = (ucell *)dict; walk < (ucell *)(dict + dicthead); walk++) {
+ int pos, bit, l;
+ ucell val;
+
+ l = (walk - (ucell *)dict);
+ pos = l / BITS;
+ bit = l & ~(-BITS);
+
+ val = read_ucell(walk);
+ if (relocation_address[pos] & target_ucell((ucell)1ULL << bit)) {
+ fprintf(f, "DICTIONARY_BASE + 0x%" FMT_CELL_x
+ ",\n", val);
+ } else {
+ fprintf(f, "0x%" FMT_CELL_x",\n", val);
+ }
+ }
+
+ fprintf(f, "#define FORTH_DICTIONARY_LAST 0x%" FMT_CELL_x"\n",
+ (ucell)((unsigned long)last - (unsigned long)dict));
+ fprintf(f, "#define FORTH_DICTIONARY_END 0x%" FMT_CELL_x"\n",
+ (ucell)dicthead);
+ fclose(f);
+
+#ifdef CONFIG_DEBUG_DICTIONARY
+ printk("wrote dictionary to file %s.\n", filename);
+#endif
+}
+
static ucell read_dictionary(char *fil)
{
int ilen;
@@ -1032,7 +1085,8 @@
" write kernel console output to log file\n" \
" -s|--segfault install segfault handler\n" \
" -M|--dependency-dump file\n" \
- " dump dependencies in Makefile format\n\n"
+ " dump dependencies in Makefile format\n\n" \
+ " -x|--hexdump output format is C language hex dump\n"
#else
#define USAGE "Usage: %s [options] [dictionary file|source file]\n\n" \
" -h show this help\n" \
@@ -1045,8 +1099,9 @@
" write to output.dict\n" \
" -c output.log\n" \
" write kernel console output to log file\n" \
- " -s install segfault handler\n\n"
- " -M file dump dependencies in Makefile format\n\n"
+ " -s install segfault handler\n\n" \
+ " -M file dump dependencies in Makefile format\n\n" \
+ " -x output format is C language hex dump\n"
#endif
int main(int argc, char *argv[])
@@ -1054,15 +1109,15 @@
struct sigaction sa;
unsigned char *ressources=NULL; /* All memory used by us */
- char *dictname = NULL;
+ const char *dictname = NULL;
char *basedict = NULL;
char *consolefile = NULL;
char *depfilename = NULL;
unsigned char *bootstrapdict[2];
- int c, cnt;
+ int c, cnt, hexdump = 0;
- const char *optstring = "VvhsI:d:D:c:M:?";
+ const char *optstring = "VvhsI:d:D:c:M:x?";
while (1) {
#ifdef __GLIBC__
@@ -1077,6 +1132,7 @@
{"target-dictionary", 1, NULL, 'D'},
{"console", 1, NULL, 'c'},
{"dependency-dump", 1, NULL, 'M'},
+ {"hexdump", 0, NULL, 'x'},
};
/*
@@ -1132,11 +1188,17 @@
depfilename = optarg;
}
break;
+ case 'x':
+ hexdump = 1;
+ break;
default:
return 1;
}
}
+ if (!dictname) {
+ dictname = "bootstrap.dict";
+ }
if (verbose) {
printk(BANNER);
printk("Using source dictionary '%s'\n", basedict);
@@ -1144,7 +1206,7 @@
printk("Dumping dependencies to '%s'\n", depfilename);
}
- if (argc < optind + 1) {
+ if (argc < optind) {
printk(USAGE, argv[0]);
return 1;
}
@@ -1243,7 +1305,11 @@
#endif
{
relocation_table( bootstrapdict[0], bootstrapdict[1], dicthead);
- write_dictionary( dictname ? dictname : "bootstrap.dict");
+ if (hexdump) {
+ write_dictionary_hex(dictname);
+ } else {
+ write_dictionary(dictname);
+ }
}
free(ressources);
8 years, 10 months
[PATCH 0/4] Avoid runtime relocations v2
by Blue Swirl
I changed dictionary array cells' relocation expression to a more
flexible one and moved the array header so that the ELF section of the
array can be adjusted on PPC64. Now all architectures use the same
methods.
AMD64-unix, Sparc32, Sparc64, PPC32 and PPC64 seem to work.
Blue Swirl (4):
sparc32: avoid runtime relocations
sparc64: avoid runtime relocations
x86: avoid runtime relocations
ppc: avoid runtime relocations
arch/ppc/build.xml | 6 +--
arch/ppc/qemu/kernel.c | 23 +++++++++--
arch/ppc/qemu/ofmem.c | 2 +-
arch/ppc64/qemu/ldscript | 7 +++
arch/sparc32/build.xml | 6 +--
arch/sparc32/builtin.c | 12 +++++-
arch/sparc32/ofmem_sparc32.c | 2 +-
arch/sparc32/openbios.c | 10 ++---
arch/sparc64/build.xml | 6 +--
arch/sparc64/builtin.c | 12 +++++-
arch/sparc64/ofmem_sparc64.c | 2 +-
arch/sparc64/openbios.c | 10 ++---
arch/x86/build.xml | 6 +--
arch/x86/builtin.c | 12 +++++-
arch/x86/openbios.c | 12 ++----
include/libopenbios/sys_info.h | 2 +
kernel/bootstrap.c | 82 ++++++++++++++++++++++++++++++++++++----
17 files changed, 150 insertions(+), 62 deletions(-)
8 years, 10 months
[PATCH 3/4] x86: avoid runtime relocations
by Blue Swirl
Signed-off-by: Blue Swirl <blauwirbel(a)gmail.com>
---
arch/x86/build.xml | 6 +-----
arch/x86/builtin.c | 12 ++++++++++--
arch/x86/openbios.c | 12 ++++--------
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/arch/x86/build.xml b/arch/x86/build.xml
index 8317209..02cecce 100644
--- a/arch/x86/build.xml
+++ b/arch/x86/build.xml
@@ -55,11 +55,7 @@
<executable name="target/include/static-dict.h" target="target"
condition="IMAGE_ELF_EMBEDDED">
<rule><![CDATA[
- $(call quiet-command,true, " GEN $(TARGET_DIR)$@")
- @echo "static const char forth_dictionary[] = {" > $@
- @cat $< | hexdump -ve '1/0 "\t" 8/1 "0x%02x, " 1/0 "\n"' \
- | sed 's/0x ,//g' >> $@
- @echo "};" >> $@]]></rule>
+ $(call quiet-command,$(ODIR)/forthstrap -x -D $@ -d $< </dev/null, "
GEN $(TARGET_DIR)$@")]]></rule>
<external-object source="openbios-x86.dict"/>
</executable>
diff --git a/arch/x86/builtin.c b/arch/x86/builtin.c
index a649172..f7d8aba 100644
--- a/arch/x86/builtin.c
+++ b/arch/x86/builtin.c
@@ -13,12 +13,20 @@
* wrap an array around the hex'ed dictionary file
*/
+/* 256K for the dictionary */
+#define DICTIONARY_SIZE (256 * 1024 / sizeof(ucell))
+#define DICTIONARY_BASE ((ucell)((char *)&forth_dictionary))
+
+static ucell forth_dictionary[DICTIONARY_SIZE] = {
#include "static-dict.h"
+};
void collect_multiboot_info(struct sys_info *info);
void collect_multiboot_info(struct sys_info *info)
{
info->dict_start=(unsigned long *)forth_dictionary;
- info->dict_end=(unsigned long *)((ucell)forth_dictionary +
- sizeof(forth_dictionary));
+ info->dict_end = (unsigned long *)FORTH_DICTIONARY_END;
+ info->dict_last = (ucell *)((unsigned char *)forth_dictionary +
+ FORTH_DICTIONARY_LAST);
+ info->dict_limit = sizeof(forth_dictionary);
}
diff --git a/arch/x86/openbios.c b/arch/x86/openbios.c
index 24b886d..dd444fa 100644
--- a/arch/x86/openbios.c
+++ b/arch/x86/openbios.c
@@ -22,9 +22,6 @@
void collect_sys_info(struct sys_info *info);
-#define DICTIONARY_SIZE (256*1024) /* 256K for the dictionary */
-static unsigned char intdict[DICTIONARY_SIZE];
-
#ifdef CONFIG_DRIVER_PCI
static const pci_arch_t default_pci_host = {
.name = "Intel,i440FX",
@@ -84,12 +81,11 @@ int openbios(void)
collect_sys_info(&sys_info);
- dict=intdict;
- dictlimit = DICTIONARY_SIZE;
+ dict = (unsigned char *)sys_info.dict_start;
+ dicthead = (cell)sys_info.dict_end;
+ last = sys_info.dict_last;
+ dictlimit = sys_info.dict_limit;
- load_dictionary((char *)sys_info.dict_start,
- (unsigned long)sys_info.dict_end -
- (unsigned long)sys_info.dict_start);
forth_init();
relocate(&sys_info);
--
1.6.2.4
8 years, 10 months