Skip to contentSkip to conversation

Add firmware code

PATCH Applied Alexander Graf 2 participants 2 messages Apr 20, 2010 – May 18, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add firmware code

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

---

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
Makefile +2 -1
index a404fda..5523af7 100644
@@ -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
hw/s390-virtio.c +26 -0
index c36a8b2..898f442 100644
@@ -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) {
pc-bios/README +5 -0
index 437ef1c..be86dde 100644
@@ -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
+
pc-bios/s390-zipl.rom new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..915995087824864cfa362176886e94c4473d8c6f
GIT binary patch
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 4 lines · Alexander Graf

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.

Quoted 8 lines

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

Thanks, applied.

Quoted 154 lines

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
Makefile +2 -1
index a404fda..5523af7 100644
@@ -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
hw/s390-virtio.c +26 -0
index c36a8b2..898f442 100644
@@ -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) {
pc-bios/README +5 -0
index 437ef1c..be86dde 100644
@@ -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
+
pc-bios/s390-zipl.rom new file binary +0 -0
new file mode 100755
index 0000000000000000000000000000000000000000..915995087824864cfa362176886e94c4473d8c6f
GIT binary patch
Signature · 2 lines
-- 
1.6.0.2
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net