Merge lp:~xnox/debian-cd/s390x-el-torito into lp:~ubuntu-cdimage/debian-cd/ubun3

Proposed by Dimitri John Ledkov
Status: Merged
Merged at revision: 1928
Proposed branch: lp:~xnox/debian-cd/s390x-el-torito
Merge into: lp:~ubuntu-cdimage/debian-cd/ubun3
Diff against target: 197 lines (+175/-0)
2 files modified
tools/boot/xenial/boot-s390x (+6/-0)
tools/gen-s390-cd-kernel.pl (+169/-0)
To merge this branch: bzr merge lp:~xnox/debian-cd/s390x-el-torito
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+283798@code.launchpad.net

Description of the change

El Torito support for s390x.

It builds .iso images that sort of look right, however they verify yet fail to boot in qemu 2.5.
Hoping to build an El Torito enabled image, and request upstream support/feedback as to what is wrong with it.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/boot/xenial/boot-s390x'
2--- tools/boot/xenial/boot-s390x 2016-01-18 18:06:53 +0000
3+++ tools/boot/xenial/boot-s390x 2016-01-25 13:00:56 +0000
4@@ -49,6 +49,8 @@
5 cp -lf "$DI_DIR/generic/initrd.ubuntu" $imagedir
6 cp -lf "$DI_DIR/generic/kernel.ubuntu" $imagedir
7
8+$BASEDIR/tools/gen-s390-cd-kernel.pl --initrd=$imagedir/initrd.ubuntu --kernel=$imagedir/kernel.ubuntu --outfile=$imagedir/ubuntu.ikr
9+
10 # Create the files specifying offset and size of the initrd
11 perl -e "print pack('N', 0x1000000)" >"$imagedir/initrd.off"
12 perl -e "print pack('N', -s '$imagedir/initrd.ubuntu')" >"$imagedir/initrd.siz"
13@@ -61,6 +63,10 @@
14 # - README
15 cp $BASEDIR/data/$CODENAME/$ARCH/* $imagedir
16
17+add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-no-emul-boot"
18+add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-b"
19+add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "boot/ubuntu.ikr"
20+
21 # Include the boot$N/-tree into the iso-image
22 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "-J"
23 add_mkisofs_opt $CDDIR/../$N.mkisofs_opts "boot$N"
24
25=== added file 'tools/gen-s390-cd-kernel.pl'
26--- tools/gen-s390-cd-kernel.pl 1970-01-01 00:00:00 +0000
27+++ tools/gen-s390-cd-kernel.pl 2016-01-25 13:00:56 +0000
28@@ -0,0 +1,169 @@
29+#!/usr/bin/perl -w
30+#
31+# Generates a bootable CD-ROM for S/390
32+#
33+# Copyright (C) 2006 Novell Inc.
34+#
35+# This program is free software; you can redistribute it and/or
36+# modify it under the terms of the GNU General Public License
37+# as published by the Free Software Foundation; either version 2
38+# of the License, or (at your option) any later version.
39+#
40+# This program is distributed in the hope that it will be useful,
41+# but WITHOUT ANY WARRANTY; without even the implied warranty of
42+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43+# GNU General Public License for more details.
44+#
45+# You should have received a copy of the GNU General Public License
46+# along with this program; if not, write to the
47+# Free Software Foundation, Inc.,
48+# 51 Franklin Street,
49+# Fifth Floor,
50+# Boston, MA 02110-1301,
51+# USA.
52+#
53+# $Id: gen-s390-cd-kernel.pl 107 2009-03-06 11:48:14Z ro $
54+
55+use FileHandle;
56+use Getopt::Long;
57+use strict;
58+
59+# Help text
60+#
61+sub help($) {
62+ my $exitcode = shift || 1;
63+ print "Usage: $0 <OPTIONS> - generate a kernel image for CD-ROM boot\n";
64+ print "SYNOPSIS: $0 [--initrd=file] \n";
65+ print " [--parmfile=file] [--outfile=file] \n";
66+ print " [--kernel=file] [--cmdline=string] \n";
67+ exit $exitcode;
68+}
69+
70+# Parse command line options
71+my ($initrd, $image, $parmfile, $outfile, $cmdline ) =
72+ ('/boot/initrd','/boot/image', '', '/tmp/image.cd', 'root=/dev/sda2');
73+
74+Getopt::Long::Configure ("bundling");
75+eval {
76+ unless (GetOptions (
77+ 'i|initrd=s' => \$initrd,
78+ 'k|kernel=s' => \$image,
79+ 'p|parmfile=s' => \$parmfile,
80+ 'o|outfile=s' => \$outfile,
81+ 'c|cmdline=s' => \$cmdline,
82+ 'h|help' => sub { help(0); } )) {
83+ help(1);
84+ }
85+};
86+
87+if ($@) {
88+ print "$@";
89+ help(1);
90+}
91+
92+# Open input files
93+sysopen(image_fh,$image,O_RDONLY) or die "Cannot open $image: $!\n";
94+sysopen(initrd_fh,$initrd,O_RDONLY) or die "Cannot $initrd: $!\n";
95+
96+my $image_size = (stat(image_fh))[7];
97+my $initrd_size = (stat(initrd_fh))[7];
98+
99+# Get the size of the input files
100+printf("%s: offset 0x%x len 0x%x (%d blocks)\n",
101+ $image, 0, $image_size, ($image_size >> 12) + 1);
102+
103+# The kernel appearently needs some free space above the
104+# actual image (bss? stack?), so use this hard-coded
105+# limit (from include/asm-s390/setup.h)
106+
107+# my $initrd_offset = (($image_size >> 12) + 1) << 12;
108+my $initrd_offset = 0x1000000;
109+my $boot_size = ((($initrd_offset + $initrd_size) >> 12) + 1 ) << 12;
110+printf("%s: offset 0x%x len 0x%x (%d blocks)\n",
111+ $initrd, $initrd_offset, $initrd_size, ($initrd_size >>12) + 1);
112+printf("%s: len 0x%x (%d blocks)\n",
113+ $outfile, $initrd_offset + $initrd_size, $boot_size / 4096);
114+
115+# Get the kernel command line arguments
116+$cmdline .= " " if ($cmdline ne "");
117+
118+if ($parmfile ne "") {
119+ my $line;
120+
121+ $cmdline = '';
122+ open(parm_fh,$parmfile) or die "Cannot open $parmfile: $!\n";
123+ while($line=<parm_fh>) {
124+ chomp $line;
125+ $cmdline .= $line . " ";
126+ }
127+ close(parm_fh);
128+}
129+
130+if ($cmdline ne "") {
131+ chop $cmdline;
132+}
133+
134+# Max length for the kernel command line is 896 bytes
135+die "Kernel commandline too long (". length($cmdline) ." bytes)\n" if (length($cmdline) >= 896);
136+
137+# Now create the image file.
138+sysopen(out_fh,$outfile,O_RDWR|O_CREAT|O_TRUNC) or die "Cannot open $outfile: $!\n";
139+
140+# First fill the entire size with zeroes
141+sysopen(null_fh,"/dev/zero",O_RDONLY) or die "Cannot open /dev/zero: $!\n";
142+
143+my $buffer="";
144+my $blocks_read=0;
145+while ($blocks_read < ($boot_size >> 12)) {
146+ sysread(null_fh,$buffer, 4096);
147+ syswrite(out_fh,$buffer);
148+ $blocks_read += 1;
149+}
150+
151+print "Read $blocks_read blocks from /dev/zero\n";
152+close(null_fh);
153+
154+# Now copy the image file to location 0
155+sysseek(out_fh,0,0);
156+$blocks_read = 0;
157+while (sysread(image_fh,$buffer, 4096) != 0) {
158+ syswrite(out_fh,$buffer,4096);
159+ $blocks_read += 1;
160+}
161+
162+print "Read $blocks_read blocks from $image\n";
163+close(image_fh);
164+
165+# Then the initrd to location specified by initrd_offset
166+sysseek(out_fh,$initrd_offset,0);
167+$blocks_read = 0;
168+while (sysread(initrd_fh,$buffer, 4096) != 0) {
169+ syswrite(out_fh,$buffer,4096);
170+ $blocks_read += 1;
171+}
172+
173+print "Read $blocks_read blocks from $initrd\n";
174+
175+close(initrd_fh);
176+
177+# Now for the real black magic.
178+# If we are loading from CD-ROM or HMC, the kernel is already loaded
179+# in memory by the first loader itself.
180+print "Setting boot loader control to 0x10000\n";
181+
182+sysseek(out_fh,4,0 );
183+syswrite(out_fh,pack("N",0x80010000),4);
184+
185+print "Writing kernel commandline (". length($cmdline) ." bytes):\n$cmdline\n";
186+
187+sysseek(out_fh,0x10480,0);
188+syswrite(out_fh,$cmdline,length($cmdline));
189+
190+print "Setting initrd parameter: offset $initrd_offset size $initrd_size\n";
191+
192+sysseek(out_fh,0x1040C,0);
193+syswrite(out_fh,pack("N",$initrd_offset),4);
194+sysseek(out_fh,0x10414,0);
195+syswrite(out_fh,pack("N",$initrd_size),4);
196+
197+close(out_fh);

Subscribers

People subscribed via source and target branches