diff mbox

[S390] Add firmware code

Message ID 1271785033-17659-1-git-send-email-agraf@suse.de
State New
Headers show

Commit Message

Alexander Graf April 20, 2010, 5:37 p.m. UTC
This patch adds a firmware blob to the S390 target. The blob is a simple
implementation of a virtio client that tries to read the second stage
bootloader from sectors described as of offset 0x20 in the MBR.

In combination with an updated zipl this allows for booting from virtio
block devices. This firmware is built from the same sources as the second
stage bootloader. You can find a virtio capable s390-tools in this repo:

git://repo.or.cz/s390-tools.git

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - Update bootloader code to support booting from non-virtio aware
    zipl disks. Now you don't need to modify zipl in the guest anymore
    just to boot.
  - Add safety checks
  - Add documentation on where to find the sources
  - Make bios optional

v2 -> v3:

  - Add brackets

v3 -> v4:

  - Add s390-zipl.rom to BLOBs
---
 Makefile              |    3 ++-
 hw/s390-virtio.c      |   26 ++++++++++++++++++++++++++
 pc-bios/README        |    5 +++++
 pc-bios/s390-zipl.rom |  Bin 0 -> 3344 bytes
 4 files changed, 33 insertions(+), 1 deletions(-)
 create mode 100755 pc-bios/s390-zipl.rom

diff --git a/pc-bios/s390-zipl.rom b/pc-bios/s390-zipl.rom
new file mode 100755
index 0000000000000000000000000000000000000000..915995087824864cfa362176886e94c4473d8c6f
GIT binary patch
literal 3344
zcmZuzdvH|M8UOC?hP%xJ4gtdQD4v7`l7hGiv0$LMH$WPE;37(cwKWR~A(EFNp#nu#
zjrGx5msD)4?YIcxbf7IeIIT_5@%rc=j5CFH8Xolzf_G>;?jK$-r6`Zv-*+|vE!~-W
z_nhy3&)@erM_t@PYRLbQ<GPPh*p3n9w5m&=)LX($^#`b2m5Ed@2~tzYuu5F&msF^_
zybHYv_cav~6a}9nAQk|n?~tT%he}93BWbFdOMcZuWAX1(T{J-rQJy2*U(wEI1&!|?
zPsN}FRGH_gOCqK12h6JjhPy8ogoS^rA@5_;%)IH=QCO`s2;RJl=XE>*=nFYQ3JN$;
zNmQiDh@6P<(a!#-DcoN~CAATIRHlR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wrV6%K*Q|PcSD-@5!F0Qsxhy-uvyji%Mq~&wS#UXP?{sBlGz)-wA)MY~gor
zzQz18SYJr=nR8}5wD@*2$&#koQC~GZI_n!HW_<0shQ{?x8=8N65ae?gAKuu~+ScCj
zNasGa)9f|>@z|!W?#<tObj#M?9ALRue(}rC@%QTk=Kk;Vew$UjWa+Y+Z`Lk1fAZq4
z*UasA+<DjCEAEM{yw`l`@t^Mb*@G8W-FN@$Z`G}N;EMTk@JGrk=2hPM_4x~KGtHN=
z&mu9G3UY~VUMy)@m29kt=aR(!`fuy<*j+@;ZJXmQ%?+|O-qgH~*2kM$8XIIwd%U5!
ztx0ZbY-(+6>&hLWcXqe6F@0-uM+<aqZtm=AZhxq=G2Sr3F(SzvRgzY;%Pf-?k?Y&L
z+ZyJ|ns`eKt63Xgw^4Sr!**MDyhQ@Ccy~*egvHJ+BR=F(P1Yyyv2uCOD!IP1y;W|A
QcQ(j|=1m*F6cobyFEAqGg#Z8m

literal 0
HcmV?d00001

Comments

Aurelien Jarno May 18, 2010, 7:14 p.m. UTC | #1
On Tue, Apr 20, 2010 at 07:37:13PM +0200, Alexander Graf wrote:
> This patch adds a firmware blob to the S390 target. The blob is a simple
> implementation of a virtio client that tries to read the second stage
> bootloader from sectors described as of offset 0x20 in the MBR.
> 
> In combination with an updated zipl this allows for booting from virtio
> block devices. This firmware is built from the same sources as the second
> stage bootloader. You can find a virtio capable s390-tools in this repo:
> 
> git://repo.or.cz/s390-tools.git
> 
> Signed-off-by: Alexander Graf <agraf@suse.de>
> 

Thanks, applied.

> v1 -> v2:
> 
>   - Update bootloader code to support booting from non-virtio aware
>     zipl disks. Now you don't need to modify zipl in the guest anymore
>     just to boot.
>   - Add safety checks
>   - Add documentation on where to find the sources
>   - Make bios optional
> 
> v2 -> v3:
> 
>   - Add brackets
> 
> v3 -> v4:
> 
>   - Add s390-zipl.rom to BLOBs
> ---
>  Makefile              |    3 ++-
>  hw/s390-virtio.c      |   26 ++++++++++++++++++++++++++
>  pc-bios/README        |    5 +++++
>  pc-bios/s390-zipl.rom |  Bin 0 -> 3344 bytes
>  4 files changed, 33 insertions(+), 1 deletions(-)
>  create mode 100755 pc-bios/s390-zipl.rom
> 
> diff --git a/Makefile b/Makefile
> index a404fda..5523af7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -178,7 +178,8 @@ pxe-e1000.bin \
>  pxe-ne2k_pci.bin pxe-pcnet.bin \
>  pxe-rtl8139.bin pxe-virtio.bin \
>  bamboo.dtb petalogix-s3adsp1800.dtb \
> -multiboot.bin linuxboot.bin
> +multiboot.bin linuxboot.bin \
> +s390-zipl.rom
>  else
>  BLOBS=
>  endif
> diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
> index c36a8b2..898f442 100644
> --- a/hw/s390-virtio.c
> +++ b/hw/s390-virtio.c
> @@ -52,6 +52,10 @@
>  #define INITRD_PARM_SIZE                0x010410UL
>  #define PARMFILE_START                  0x001000UL
>  
> +#define ZIPL_START			0x009000UL
> +#define ZIPL_LOAD_ADDR			0x009000UL
> +#define ZIPL_FILENAME			"s390-zipl.rom"
> +
>  #define MAX_BLK_DEVS                    10
>  
>  static VirtIOS390Bus *s390_bus;
> @@ -188,6 +192,28 @@ static void s390_init(ram_addr_t ram_size,
>  
>          env->psw.addr = KERN_IMAGE_START;
>          env->psw.mask = 0x0000000180000000ULL;
> +    } else {
> +        ram_addr_t bios_size = 0;
> +        char *bios_filename;
> +
> +        /* Load zipl bootloader */
> +        if (bios_name == NULL) {
> +            bios_name = ZIPL_FILENAME;
> +        }
> +
> +        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
> +        bios_size = load_image(bios_filename, qemu_get_ram_ptr(ZIPL_LOAD_ADDR));
> +
> +        if ((long)bios_size < 0) {
> +            hw_error("could not load bootloader '%s'\n", bios_name);
> +        }
> +
> +        if (bios_size > 4096) {
> +            hw_error("stage1 bootloader is > 4k\n");
> +        }
> +
> +        env->psw.addr = ZIPL_START;
> +        env->psw.mask = 0x0000000180000000ULL;
>      }
>  
>      if (initrd_filename) {
> diff --git a/pc-bios/README b/pc-bios/README
> index 437ef1c..be86dde 100644
> --- a/pc-bios/README
> +++ b/pc-bios/README
> @@ -28,3 +28,8 @@
>    virtio 1af4:1000
>  
>    http://rom-o-matic.net/
> +
> +- The S390 zipl loader is an addition to the official IBM s390-tools
> +  package. That fork is maintained in its own git repository at:
> +  git://repo.or.cz/s390-tools.git
> +
> diff --git a/pc-bios/s390-zipl.rom b/pc-bios/s390-zipl.rom
> new file mode 100755
> index 0000000000000000000000000000000000000000..915995087824864cfa362176886e94c4473d8c6f
> GIT binary patch
> literal 3344
> zcmZuzdvH|M8UOC?hP%xJ4gtdQD4v7`l7hGiv0$LMH$WPE;37(cwKWR~A(EFNp#nu#
> zjrGx5msD)4?YIcxbf7IeIIT_5@%rc=j5CFH8Xolzf_G>;?jK$-r6`Zv-*+|vE!~-W
> z_nhy3&)@erM_t@PYRLbQ<GPPh*p3n9w5m&=)LX($^#`b2m5Ed@2~tzYuu5F&msF^_
> zybHYv_cav~6a}9nAQk|n?~tT%he}93BWbFdOMcZuWAX1(T{J-rQJy2*U(wEI1&!|?
> zPsN}FRGH_gOCqK12h6JjhPy8ogoS^rA@5_;%)IH=QCO`s2;RJl=XE>*=nFYQ3JN$;
> zNmQiDh@6P<(a!#-DcoN~CAATIRHlRsDu`ByK%KAyY!Q?I6{yK%IMNPMFm!9*{HtEb
> zQY*=bkqkzK9POl`F&vG^{1~KQDG$7`R4b&9CBfr!gdL)Q_AL;N3ZHp3bJVQ|e#ZdB
> zfV$+>!OLnqs}AKbK5mL5CCZdjKIJ=t+2Cn0ICAj3(;oy@Lv)iPqd^Kh8P1`8AKef1
> zidbGpr*&lIAvveN7!qL`rAo<wq<|zmQj>s#l)zz)j0RMXcM9K0h43sOiis$rP~r%-
> z;zZAJ3`fsl9gT>5%@Gkna|rrS6Y%yEw*xT=&pXwDnCf?N9rVx)cwC6@0ZRxYWKF5o
> z^e*pn&?}&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*j+@;ZJXmQ%?+|O-qgH~*2kM$8XIIwd%U5!
> ztx0ZbY-(+6>&hLWcXqe6F@0-uM+<aqZtm=AZhxq=G2Sr3F(SzvRgzY;%Pf-?k?Y&L
> z+ZyJ|ns`eKt63Xgw^4Sr!**MDyhQ@Ccy~*egvHJ+BR=F(P1Yyyv2uCOD!IP1y;W|A
> QcQ(j|=1m*F6cobyFEAqGg#Z8m
> 
> literal 0
> HcmV?d00001
> 
> -- 
> 1.6.0.2
> 
> 
> 
>
diff mbox

Patch

diff --git a/Makefile b/Makefile
index a404fda..5523af7 100644
--- a/Makefile
+++ b/Makefile
@@ -178,7 +178,8 @@  pxe-e1000.bin \
 pxe-ne2k_pci.bin pxe-pcnet.bin \
 pxe-rtl8139.bin pxe-virtio.bin \
 bamboo.dtb petalogix-s3adsp1800.dtb \
-multiboot.bin linuxboot.bin
+multiboot.bin linuxboot.bin \
+s390-zipl.rom
 else
 BLOBS=
 endif
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index c36a8b2..898f442 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -52,6 +52,10 @@ 
 #define INITRD_PARM_SIZE                0x010410UL
 #define PARMFILE_START                  0x001000UL
 
+#define ZIPL_START			0x009000UL
+#define ZIPL_LOAD_ADDR			0x009000UL
+#define ZIPL_FILENAME			"s390-zipl.rom"
+
 #define MAX_BLK_DEVS                    10
 
 static VirtIOS390Bus *s390_bus;
@@ -188,6 +192,28 @@  static void s390_init(ram_addr_t ram_size,
 
         env->psw.addr = KERN_IMAGE_START;
         env->psw.mask = 0x0000000180000000ULL;
+    } else {
+        ram_addr_t bios_size = 0;
+        char *bios_filename;
+
+        /* Load zipl bootloader */
+        if (bios_name == NULL) {
+            bios_name = ZIPL_FILENAME;
+        }
+
+        bios_filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
+        bios_size = load_image(bios_filename, qemu_get_ram_ptr(ZIPL_LOAD_ADDR));
+
+        if ((long)bios_size < 0) {
+            hw_error("could not load bootloader '%s'\n", bios_name);
+        }
+
+        if (bios_size > 4096) {
+            hw_error("stage1 bootloader is > 4k\n");
+        }
+
+        env->psw.addr = ZIPL_START;
+        env->psw.mask = 0x0000000180000000ULL;
     }
 
     if (initrd_filename) {
diff --git a/pc-bios/README b/pc-bios/README
index 437ef1c..be86dde 100644
--- a/pc-bios/README
+++ b/pc-bios/README
@@ -28,3 +28,8 @@ 
   virtio 1af4:1000
 
   http://rom-o-matic.net/
+
+- The S390 zipl loader is an addition to the official IBM s390-tools
+  package. That fork is maintained in its own git repository at:
+  git://repo.or.cz/s390-tools.git
+