Re: [SeaBIOS] [PATCH v3 2/2] Add multiboot support.

2015-06-01 Thread Kevin O'Connor
On Thu, May 21, 2015 at 12:42:21PM -0400, Kevin O'Connor wrote:
> On Tue, May 19, 2015 at 08:53:05PM +0200, Vladimir 'φ-coder/phcoder' 
> Serbinenko wrote:
> > I've been successfully using SeaBIOS as secondary bootloader. In more
> > details
> > I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary
> > is on
> > the HDD and loaded by GRUB when needed. This has an unfortunate consequence
> > that I have to keep vga oprom in flash even if usually I boot without
> > it. This
> > patches makes bios.bin.elf multiboot executable with files passed as
> > modules.
> 
> Thanks.  Are you okay with the patch below instead?  In particular,
> are you okay with the copyright notice I added to multiboot.c?

FYI, I applied this patch - thanks.

-Kevin

___
SeaBIOS mailing list
SeaBIOS@seabios.org
http://www.seabios.org/mailman/listinfo/seabios

Re: [SeaBIOS] [PATCH v3 2/2] Add multiboot support.

2015-05-22 Thread Vladimir 'φ-coder/phcoder' Serbinenko
On 21.05.2015 18:42, Kevin O'Connor wrote:
> On Tue, May 19, 2015 at 08:53:05PM +0200, Vladimir 'φ-coder/phcoder' 
> Serbinenko wrote:
>> I've been successfully using SeaBIOS as secondary bootloader. In more
>> details
>> I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary
>> is on
>> the HDD and loaded by GRUB when needed. This has an unfortunate consequence
>> that I have to keep vga oprom in flash even if usually I boot without
>> it. This
>> patches makes bios.bin.elf multiboot executable with files passed as
>> modules.
> 
> Thanks.  Are you okay with the patch below instead?  In particular,
> are you okay with the copyright notice I added to multiboot.c?
> 
Can we add "or later" clause? Otherwise looks fine and is tested
> The biggest change I made is to the way layoutrom.py places the
> multiboot header.  The other changes are mostly minor (indentation,
> malloc checks, minor name changes).
> 
> BTW, is there anything that prevents seabios from overwriting the
> additional "module files" prior to it copying them?
> 
Looking at memory map document it seems that unlike what I've thought
you do use memory at 1G. We probably need some code before malloc init
to go through modules and find highest used address by modules. Is it ok
if I do such adjustment?
> -Kevin
> 
> 
>>From f6fea7e9fda4cce24eabfbc1cfea93501beefa29 Mon Sep 17 00:00:00 2001
> From: Vladimir Serbinenko 
> Date: Mon, 18 May 2015 19:07:16 +0200
> Subject: [PATCH] Add multiboot support.
> 
> I've been successfully using SeaBIOS as secondary bootloader. In more details
> I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary is on
> the HDD and loaded by GRUB when needed. This has an unfortunate consequence
> that I have to keep vga oprom in flash even if usually I boot without it. This
> patches makes bios.bin.elf multiboot executable with files passed as modules.
> Example:
> 
> menuentry "SeaBIOS (mb)" --unrestricted {
>root=ahci0,2
>multiboot /bios.bin.elf
>module /vgabios_x230.rom name=pci8086,0166.rom
> }
> 
> the parameter name= specifies under which name SeaBIOS will see it.
> 
> Signed-off-by: Vladimir Serbinenko 
> Signed-off-by: Kevin O'Connor 
> ---
>  Makefile |   2 +-
>  scripts/layoutrom.py |   8 ++
>  src/Kconfig  |   7 ++
>  src/fw/multiboot.c   | 111 ++
>  src/post.c   |   1 +
>  src/romlayout.S  |   2 +
>  src/std/multiboot.h  | 260 
> +++
>  src/util.h   |   3 +
>  8 files changed, 393 insertions(+), 1 deletion(-)
>  create mode 100644 src/fw/multiboot.c
>  create mode 100644 src/std/multiboot.h
> 
> diff --git a/Makefile b/Makefile
> index 3ee61af..0573c69 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -40,7 +40,7 @@ SRC16=$(SRCBOTH)
>  SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c romfile.c x86.c optionroms.c \
>  pmm.c font.c boot.c bootsplash.c jpeg.c bmp.c \
>  hw/ahci.c hw/pvscsi.c hw/usb-xhci.c hw/usb-hub.c hw/sdcard.c \
> -fw/coreboot.c fw/lzmadecode.c fw/csm.c fw/biostables.c \
> +fw/coreboot.c fw/lzmadecode.c fw/multiboot.c fw/csm.c fw/biostables.c \
>  fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c 
> fw/xen.c \
>  fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c
>  SRC32SEG=string.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio.c
> diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py
> index dd770fe..b976fb0 100755
> --- a/scripts/layoutrom.py
> +++ b/scripts/layoutrom.py
> @@ -161,6 +161,7 @@ def getSectionsPrefix(sections, prefix):
>  # The sections (and associated information) to be placed in output rom
>  class LayoutInfo:
>  sections = None
> +config = None
>  genreloc = None
>  sec32init_start = sec32init_end = sec32init_align = None
>  sec32low_start = sec32low_end = None
> @@ -172,6 +173,7 @@ class LayoutInfo:
>  # Determine final memory addresses for sections
>  def doLayout(sections, config, genreloc):
>  li = LayoutInfo()
> +li.config = config
>  li.sections = sections
>  li.genreloc = genreloc
>  # Determine 16bit positions
> @@ -399,6 +401,10 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
>  filesections32flat = getSectionsFileid(li.sections, '32flat')
>  out = outXRefs([], exportsyms=li.varlowsyms
> , forcedelta=li.final_sec32low_start-li.sec32low_start)
> +multiboot_header = ""
> +if li.config.get('CONFIG_MULTIBOOT'):
> +multiboot_header = "LONG(0x1BADB002) LONG(0) LONG(-0x1BADB002)"
> +sec32all_start -= 3 * 4
>  out += outXRefs(filesections32flat, exportsyms=[li.entrysym]) + """
>  _reloc_min_align = 0x%x ;
>  zonefseg_start = 0x%x ;
> @@ -415,6 +421,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
>  .text code32flat_start : {
>  %s
>  %s
> +%s
>  code32flat_end = ABSOLUTE(.) ;
>  } :text
>  """ % (li.sec32init_align,
> @@ 

Re: [SeaBIOS] [PATCH v3 2/2] Add multiboot support.

2015-05-21 Thread Kevin O'Connor
On Tue, May 19, 2015 at 08:53:05PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko 
wrote:
> I've been successfully using SeaBIOS as secondary bootloader. In more
> details
> I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary
> is on
> the HDD and loaded by GRUB when needed. This has an unfortunate consequence
> that I have to keep vga oprom in flash even if usually I boot without
> it. This
> patches makes bios.bin.elf multiboot executable with files passed as
> modules.

Thanks.  Are you okay with the patch below instead?  In particular,
are you okay with the copyright notice I added to multiboot.c?

The biggest change I made is to the way layoutrom.py places the
multiboot header.  The other changes are mostly minor (indentation,
malloc checks, minor name changes).

BTW, is there anything that prevents seabios from overwriting the
additional "module files" prior to it copying them?

-Kevin


From f6fea7e9fda4cce24eabfbc1cfea93501beefa29 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko 
Date: Mon, 18 May 2015 19:07:16 +0200
Subject: [PATCH] Add multiboot support.

I've been successfully using SeaBIOS as secondary bootloader. In more details
I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary is on
the HDD and loaded by GRUB when needed. This has an unfortunate consequence
that I have to keep vga oprom in flash even if usually I boot without it. This
patches makes bios.bin.elf multiboot executable with files passed as modules.
Example:

menuentry "SeaBIOS (mb)" --unrestricted {
   root=ahci0,2
   multiboot /bios.bin.elf
   module /vgabios_x230.rom name=pci8086,0166.rom
}

the parameter name= specifies under which name SeaBIOS will see it.

Signed-off-by: Vladimir Serbinenko 
Signed-off-by: Kevin O'Connor 
---
 Makefile |   2 +-
 scripts/layoutrom.py |   8 ++
 src/Kconfig  |   7 ++
 src/fw/multiboot.c   | 111 ++
 src/post.c   |   1 +
 src/romlayout.S  |   2 +
 src/std/multiboot.h  | 260 +++
 src/util.h   |   3 +
 8 files changed, 393 insertions(+), 1 deletion(-)
 create mode 100644 src/fw/multiboot.c
 create mode 100644 src/std/multiboot.h

diff --git a/Makefile b/Makefile
index 3ee61af..0573c69 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ SRC16=$(SRCBOTH)
 SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c romfile.c x86.c optionroms.c \
 pmm.c font.c boot.c bootsplash.c jpeg.c bmp.c \
 hw/ahci.c hw/pvscsi.c hw/usb-xhci.c hw/usb-hub.c hw/sdcard.c \
-fw/coreboot.c fw/lzmadecode.c fw/csm.c fw/biostables.c \
+fw/coreboot.c fw/lzmadecode.c fw/multiboot.c fw/csm.c fw/biostables.c \
 fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c 
fw/xen.c \
 fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c
 SRC32SEG=string.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio.c
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py
index dd770fe..b976fb0 100755
--- a/scripts/layoutrom.py
+++ b/scripts/layoutrom.py
@@ -161,6 +161,7 @@ def getSectionsPrefix(sections, prefix):
 # The sections (and associated information) to be placed in output rom
 class LayoutInfo:
 sections = None
+config = None
 genreloc = None
 sec32init_start = sec32init_end = sec32init_align = None
 sec32low_start = sec32low_end = None
@@ -172,6 +173,7 @@ class LayoutInfo:
 # Determine final memory addresses for sections
 def doLayout(sections, config, genreloc):
 li = LayoutInfo()
+li.config = config
 li.sections = sections
 li.genreloc = genreloc
 # Determine 16bit positions
@@ -399,6 +401,10 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
 filesections32flat = getSectionsFileid(li.sections, '32flat')
 out = outXRefs([], exportsyms=li.varlowsyms
, forcedelta=li.final_sec32low_start-li.sec32low_start)
+multiboot_header = ""
+if li.config.get('CONFIG_MULTIBOOT'):
+multiboot_header = "LONG(0x1BADB002) LONG(0) LONG(-0x1BADB002)"
+sec32all_start -= 3 * 4
 out += outXRefs(filesections32flat, exportsyms=[li.entrysym]) + """
 _reloc_min_align = 0x%x ;
 zonefseg_start = 0x%x ;
@@ -415,6 +421,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
 .text code32flat_start : {
 %s
 %s
+%s
 code32flat_end = ABSOLUTE(.) ;
 } :text
 """ % (li.sec32init_align,
@@ -428,6 +435,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
li.sec32init_start,
li.sec32init_end,
sec32all_start,
+   multiboot_header,
relocstr,
outRelSections(li.sections, 'code32flat_start'))
 out = COMMONHEADER + out + COMMONTRAILER + """
diff --git a/src/Kconfig b/src/Kconfig
index 45ca59c..7be59a2 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -102,6 +102,13 @@ endchoice
 default y
 help
 Support floppy images in coreboot flash.
+config MULTIBOOT
+depends on 

[SeaBIOS] [PATCH v3 2/2] Add multiboot support.

2015-05-19 Thread Vladimir 'φ-coder/phcoder' Serbinenko
From 7ecb31e60ca5cde8f7649414a0463ff70fbe2865 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko 
Date: Mon, 18 May 2015 19:07:16 +0200
Subject: [PATCH 2/2] Add multiboot support.

I've been successfully using SeaBIOS as secondary bootloader. In more
details
I have GRUB2-as-payload in flash together with coreboot. SeaBIOS binary
is on
the HDD and loaded by GRUB when needed. This has an unfortunate consequence
that I have to keep vga oprom in flash even if usually I boot without
it. This
patches makes bios.bin.elf multiboot executable with files passed as
modules.
Example:

menuentry "SeaBIOS (mb)" --unrestricted {
   root=ahci0,2
   multiboot /bios.bin.elf
   module /vgabios_x230.rom name=pci8086,0166.rom
}

the parameter name= specifies under which name SeaBIOS will see it.

Signed-off-by: Vladimir Serbinenko 
---
 Makefile |   3 +-
 scripts/layoutrom.py |  16 +++-
 src/Kconfig  |   7 ++
 src/fw/coreboot.c|   2 +
 src/fw/multiboot.c   | 114 ++
 src/post.c   |   1 +
 src/romlayout.S  |   3 +-
 src/std/multiboot.h  | 260
+++
 src/util.h   |   1 +
 9 files changed, 403 insertions(+), 4 deletions(-)
 create mode 100644 src/fw/multiboot.c
 create mode 100644 src/std/multiboot.h

diff --git a/Makefile b/Makefile
index 3ee61af..f69f1f7 100644
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,8 @@ SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c
romfile.c x86.c optionroms.c \
 hw/ahci.c hw/pvscsi.c hw/usb-xhci.c hw/usb-hub.c hw/sdcard.c \
 fw/coreboot.c fw/lzmadecode.c fw/csm.c fw/biostables.c \
 fw/paravirt.c fw/shadow.c fw/pciinit.c fw/smm.c fw/smp.c fw/mtrr.c
fw/xen.c \
-fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c
+fw/acpi.c fw/mptable.c fw/pirtable.c fw/smbios.c fw/romfile_loader.c \
+fw/multiboot.c
 SRC32SEG=string.c output.c pcibios.c apm.c stacks.c hw/pci.c hw/serialio.c
 DIRS=src src/hw src/fw vgasrc

diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py
index dd770fe..b793f33 100755
--- a/scripts/layoutrom.py
+++ b/scripts/layoutrom.py
@@ -356,7 +356,7 @@ def getRelocs(sections, tosection, type=None):
 and (type is None or reloc.type == type))]

 # Output the linker scripts for all required sections.
-def writeLinkerScripts(li, out16, out32seg, out32flat):
+def writeLinkerScripts(li, out16, out32seg, out32flat, mb_section):
 # Write 16bit linker script
 filesections16 = getSectionsFileid(li.sections, '16')
 out = outXRefs(filesections16, useseg=1) + """
@@ -399,6 +399,11 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
 filesections32flat = getSectionsFileid(li.sections, '32flat')
 out = outXRefs([], exportsyms=li.varlowsyms
, forcedelta=li.final_sec32low_start-li.sec32low_start)
+if mb_section is None:
+mbstr = ""
+else:
+mbstr = "*(%s)" % mb_section
+sec32all_start -= 12
 out += outXRefs(filesections32flat, exportsyms=[li.entrysym]) + """
 _reloc_min_align = 0x%x ;
 zonefseg_start = 0x%x ;
@@ -415,6 +420,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
 .text code32flat_start : {
 %s
 %s
+%s
 code32flat_end = ABSOLUTE(.) ;
 } :text
 """ % (li.sec32init_align,
@@ -428,6 +434,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
li.sec32init_start,
li.sec32init_end,
sec32all_start,
+   mbstr,
relocstr,
outRelSections(li.sections, 'code32flat_start'))
 out = COMMONHEADER + out + COMMONTRAILER + """
@@ -649,6 +656,11 @@ def main():
 anchorsections = [entrysym.section] + [
 section for section in allsections
 if section.name.startswith('.fixedaddr.')]
+mb_header = symbols['32flat'].get('mb_head')
+if mb_header is not None:
+mb_section = mb_header.section.name
+else:
+mb_section = None
 keepsections = findReachable(anchorsections, checkKeep, symbols)
 sections = [section for section in allsections if section in
keepsections]

@@ -685,7 +697,7 @@ def main():
 li.entrysym = entrysym

 # Write out linker script files.
-writeLinkerScripts(li, out16, out32seg, out32flat)
+writeLinkerScripts(li, out16, out32seg, out32flat, mb_section)

 if __name__ == '__main__':
 main()
diff --git a/src/Kconfig b/src/Kconfig
index 45ca59c..385ce49 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -102,6 +102,13 @@ endchoice
 default y
 help
 Support floppy images in coreboot flash.
+config MULTIBOOT
+depends on COREBOOT
+bool "multiboot support"
+default y
+help
+Add multiboot header in bios.bin.raw and accept files supplied
+   as multiboot modules.
 config ENTRY_EXTRASTACK
 bool "Use internal stack for 16bit interrupt entry points"
 default y
diff --git a/src/fw/coreboot.c b/src/fw/coreboot.c
index 8fd8449.