Rebased to version 1.7.0

Support for virtio-scsi
Improved USB drive support
Several USB controller bug fixes and improvements
This commit is contained in:
Cole Robinson 2012-05-28 16:56:40 -04:00
parent a3de4de2b2
commit 67b1f390e7
7 changed files with 37 additions and 1927 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ seabios-0.5.1.tar.gz
seabios-0.6.0.tar.gz
/seabios-0.6.2.tar.gz
/seabios-1.6.3.tar.gz
/seabios-1.7.0.tar.gz

View File

@ -1,58 +1,27 @@
From 526d703a74752b66fd54ac4a9133a3de31c90549 Mon Sep 17 00:00:00 2001
From: Gleb Natapov <gleb@redhat.com>
Date: Sun, 11 Sep 2011 09:05:50 +0200
Subject: [PATCH] do not advertise S4/S3 in DSDT
RH-Author: Gleb Natapov <gleb@redhat.com>
Message-id: <20110911090550.GF21417@redhat.com>
Patchwork-id: 32631
O-Subject: [PATCHv2 RHEL6.2 SEABIOS] do not advertise S4/S3 in DSDT
Bugzilla: 736522
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
RH-Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
To compile Seabios with PM support run make "DSDT_CPP_FLAGS=-DDSDT_PM"
BZ: 736522
Upstream: local patch
Signed-off-by: Gleb Natapov <gleb@redhat.com>
--
Gleb.
Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
Makefile | 2 +-
src/acpi-dsdt.dsl | 2 ++
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index b185ac8..f5c7104 100644
--- a/Makefile
+++ b/Makefile
@@ -186,7 +186,7 @@ $(OUT)vgabios.bin: $(OUT)vgabios.bin.raw tools/buildrom.py
####### dsdt build rules
src/%.hex: src/%.dsl
@echo "Compiling DSDT"
- $(Q)cpp -P $< > $(OUT)$*.dsl.i
+ $(Q)cpp $(DSDT_CPP_FLAGS) -P $< > $(OUT)$*.dsl.i
$(Q)iasl -tc -p $(OUT)$* $(OUT)$*.dsl.i
$(Q)cp $(OUT)$*.hex $@
diff -rup seabios-1.7.0/Makefile mysea/Makefile
--- seabios-1.7.0/Makefile 2012-05-28 16:53:27.898842738 -0400
+++ mysea/Makefile 2012-05-28 16:50:37.307644939 -0400
@@ -221,7 +221,7 @@ $(OUT)vgabios.bin: $(OUT)vgabios.bin.raw
diff --git a/src/acpi-dsdt.dsl b/src/acpi-dsdt.dsl
index b54c558..1db5ae9 100644
--- a/src/acpi-dsdt.dsl
+++ b/src/acpi-dsdt.dsl
@@ -722,6 +722,7 @@ DefinitionBlock (
}
}
src/%.hex: src/%.dsl ./tools/acpi_extract_preprocess.py ./tools/acpi_extract.py
@echo "Compiling DSDT"
- $(Q)cpp -P $< > $(OUT)$*.dsl.i.orig
+ $(Q)cpp $(DSDT_CPP_FLAGS) -P $< > $(OUT)$*.dsl.i.orig
$(Q)$(PYTHON) ./tools/acpi_extract_preprocess.py $(OUT)$*.dsl.i.orig > $(OUT)$*.dsl.i
$(Q)iasl -l -tc -p $(OUT)$* $(OUT)$*.dsl.i
$(Q)$(PYTHON) ./tools/acpi_extract.py $(OUT)$*.lst > $(OUT)$*.off
diff -rup seabios-1.7.0/src/acpi-dsdt.dsl mysea/src/acpi-dsdt.dsl
--- seabios-1.7.0/src/acpi-dsdt.dsl 2012-04-14 22:27:40.000000000 -0400
+++ mysea/src/acpi-dsdt.dsl 2012-05-28 16:52:11.745575415 -0400
@@ -609,6 +609,7 @@ DefinitionBlock (
* Suspend
****************************************************************/
+#ifdef DSDT_PM
/*
* S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
* must match piix4 emulation.
@@ -740,6 +741,7 @@ DefinitionBlock (
@@ -627,6 +628,7 @@ DefinitionBlock (
Zero, /* reserved */
Zero /* reserved */
})
@ -60,6 +29,3 @@ index b54c558..1db5ae9 100644
Name (\_S5, Package (0x04)
{
Zero, /* PM1a_CNT.SLP_TYP */
--
1.7.4.4

View File

@ -1,275 +0,0 @@
From 5c244dfbfcc8b610eac30ffa39c009724843695b Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 5 Mar 2012 12:29:12 +0100
Subject: [PATCH 1/4] scsi: do not send MODE SENSE except to QEMU disks
This is the simplest way to avoid breaking boot on USB sticks that
stall when asked for the MODE SENSE page 4. Some old sticks do
not support the MODE SENSE command at all and just return a
"medium may have changed" unit attention condition when SeaBIOS
sends it!
Reported-by: Dave Frodin <dave@camp.se-eng.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry-picked from commit cb721714570520c02ae48efc26d3c04b8548d973)
---
src/blockcmd.c | 37 +++++++++++++++++++++++--------------
1 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/src/blockcmd.c b/src/blockcmd.c
index 9919acb..4f3131c 100644
--- a/src/blockcmd.c
+++ b/src/blockcmd.c
@@ -131,20 +131,29 @@ scsi_init_drive(struct drive_s *drive, const char *s, int *pdt, char **desc)
dprintf(1, "%s blksize=%d sectors=%d\n"
, s, drive->blksize, (unsigned)drive->sectors);
- struct cdbres_mode_sense_geom geomdata;
- ret = cdb_mode_sense_geom(&dop, &geomdata);
- if (ret == 0) {
- u32 cylinders;
- cylinders = geomdata.cyl[0] << 16;
- cylinders |= geomdata.cyl[1] << 8;
- cylinders |= geomdata.cyl[2];
- if (cylinders && geomdata.heads &&
- drive->sectors <= 0xFFFFFFFFULL &&
- ((u32)drive->sectors % (geomdata.heads * cylinders) == 0)) {
- drive->pchs.cylinders = cylinders;
- drive->pchs.heads = geomdata.heads;
- drive->pchs.spt = (u32)drive->sectors
- / (geomdata.heads * cylinders);
+ // We do not recover from USB stalls, so try to be safe and avoid
+ // sending the command if the (obsolete, but still provided by QEMU)
+ // fixed disk geometry page may not be supported.
+ //
+ // We could also send the command only to small disks (e.g. <504MiB)
+ // but some old USB keys only support a very small subset of SCSI which
+ // does not even include the MODE SENSE command!
+ //
+ if (! CONFIG_COREBOOT && memcmp(vendor, "QEMU ", 8) == 0) {
+ struct cdbres_mode_sense_geom geomdata;
+ ret = cdb_mode_sense_geom(&dop, &geomdata);
+ if (ret == 0) {
+ u32 cylinders;
+ cylinders = geomdata.cyl[0] << 16;
+ cylinders |= geomdata.cyl[1] << 8;
+ cylinders |= geomdata.cyl[2];
+ if (cylinders && geomdata.heads &&
+ drive->sectors <= 0xFFFFFFFFULL &&
+ ((u32)drive->sectors % (geomdata.heads * cylinders) == 0)) {
+ drive->pchs.cylinders = cylinders;
+ drive->pchs.heads = geomdata.heads;
+ drive->pchs.spt = (u32)drive->sectors / (geomdata.heads * cylinders);
+ }
}
}
--
1.7.9.1
From 04b3f8876a82eac4f06c8e89d6ca0e2c35f632a6 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Thu, 15 Mar 2012 16:10:53 +0100
Subject: [PATCH 2/4] Use OUT mode for all zero byte "scsi" transfers.
Upstream status: posted at
http://permalink.gmane.org/gmane.comp.bios.coreboot.seabios/3466
Some devices can get confused if asked to "read" data during a zero
byte transfer, so consider these transfers as "writes". (Reported by
Steve Goodrich.)
Also, extract out the code to determine the transfer direction into
cdb_is_read().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry-picked from commit 1fd9a89082b807a4bb4ab6ce1285df474cb75746)
---
src/blockcmd.c | 7 +++++++
src/blockcmd.h | 1 +
src/usb-msc.c | 4 ++--
src/virtio-scsi.c | 7 ++++---
4 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/blockcmd.c b/src/blockcmd.c
index 4f3131c..f77f3af 100644
--- a/src/blockcmd.c
+++ b/src/blockcmd.c
@@ -31,6 +31,13 @@ cdb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
}
}
+// Determine if the command is a request to pull data from the device
+int
+cdb_is_read(u8 *cdbcmd, u16 blocksize)
+{
+ return blocksize && cdbcmd[0] != CDB_CMD_WRITE_10;
+}
+
int
scsi_is_ready(struct disk_op_s *op)
{
diff --git a/src/blockcmd.h b/src/blockcmd.h
index bace649..4442ae1 100644
--- a/src/blockcmd.h
+++ b/src/blockcmd.h
@@ -100,6 +100,7 @@ struct cdbres_mode_sense_geom {
} PACKED;
// blockcmd.c
+int cdb_is_read(u8 *cdbcmd, u16 blocksize);
int cdb_get_inquiry(struct disk_op_s *op, struct cdbres_inquiry *data);
int cdb_get_sense(struct disk_op_s *op, struct cdbres_request_sense *data);
int cdb_test_unit_ready(struct disk_op_s *op);
diff --git a/src/usb-msc.c b/src/usb-msc.c
index cde08ce..8210a15 100644
--- a/src/usb-msc.c
+++ b/src/usb-msc.c
@@ -74,13 +74,13 @@ usb_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
cbw.dCBWSignature = CBW_SIGNATURE;
cbw.dCBWTag = 999; // XXX
cbw.dCBWDataTransferLength = bytes;
- cbw.bmCBWFlags = (cbw.CBWCB[0] == CDB_CMD_WRITE_10) ? USB_DIR_OUT : USB_DIR_IN;
+ cbw.bmCBWFlags = cdb_is_read(cdbcmd, blocksize) ? USB_DIR_IN : USB_DIR_OUT;
cbw.bCBWLUN = 0; // XXX
cbw.bCBWCBLength = USB_CDB_SIZE;
// Transfer cbw to device.
int ret = usb_msc_send(udrive_g, USB_DIR_OUT
- , MAKE_FLATPTR(GET_SEG(SS), &cbw), sizeof(cbw));
+ , MAKE_FLATPTR(GET_SEG(SS), &cbw), sizeof(cbw));
if (ret)
goto fail;
diff --git a/src/virtio-scsi.c b/src/virtio-scsi.c
index 9437116..76c5f29 100644
--- a/src/virtio-scsi.c
+++ b/src/virtio-scsi.c
@@ -31,7 +31,7 @@ struct virtio_lun_s {
static int
virtio_scsi_cmd(u16 ioaddr, struct vring_virtqueue *vq, struct disk_op_s *op,
- void *cdbcmd, u16 target, u16 lun, u32 len)
+ void *cdbcmd, u16 target, u16 lun, u16 blocksize)
{
struct virtio_scsi_req_cmd req;
struct virtio_scsi_resp_cmd resp;
@@ -44,7 +44,8 @@ virtio_scsi_cmd(u16 ioaddr, struct vring_virtqueue *vq, struct disk_op_s *op,
req.lun[3] = (lun & 0xff);
memcpy(req.cdb, cdbcmd, 16);
- int datain = (req.cdb[0] != CDB_CMD_WRITE_10);
+ u32 len = op->count * blocksize;
+ int datain = cdb_is_read(cdbcmd, blocksize);
int data_idx = (datain ? 2 : 1);
int out_num = (datain ? 1 : 2);
int in_num = (len ? 3 : 2) - out_num;
@@ -89,7 +90,7 @@ virtio_scsi_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
return virtio_scsi_cmd(GET_GLOBAL(vlun->ioaddr),
GET_GLOBAL(vlun->vq), op, cdbcmd,
GET_GLOBAL(vlun->target), GET_GLOBAL(vlun->lun),
- blocksize * op->count);
+ blocksize);
}
static int
--
1.7.9.1
From ff5cb1672acf63e2a82a765f04f4044ce5c19d6f Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 19 Mar 2012 11:44:05 +0100
Subject: [PATCH 3/4] virtio-scsi: Fix virtio-scsi after cdb_is_read changes.
The previous patch changes the way TEST_UNIT_READY is composed in the
buffers and breaks virtio-scsi.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry-picked from commit 8c313078917099a002d45f58d58ae2f4eb9a657f)
---
src/virtio-scsi.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/virtio-scsi.c b/src/virtio-scsi.c
index 76c5f29..0aa3388 100644
--- a/src/virtio-scsi.c
+++ b/src/virtio-scsi.c
@@ -46,9 +46,8 @@ virtio_scsi_cmd(u16 ioaddr, struct vring_virtqueue *vq, struct disk_op_s *op,
u32 len = op->count * blocksize;
int datain = cdb_is_read(cdbcmd, blocksize);
- int data_idx = (datain ? 2 : 1);
- int out_num = (datain ? 1 : 2);
- int in_num = (len ? 3 : 2) - out_num;
+ int in_num = (datain ? 2 : 1);
+ int out_num = (len ? 3 : 2) - in_num;
sg[0].addr = MAKE_FLATPTR(GET_SEG(SS), &req);
sg[0].length = sizeof(req);
@@ -56,8 +55,11 @@ virtio_scsi_cmd(u16 ioaddr, struct vring_virtqueue *vq, struct disk_op_s *op,
sg[out_num].addr = MAKE_FLATPTR(GET_SEG(SS), &resp);
sg[out_num].length = sizeof(resp);
- sg[data_idx].addr = op->buf_fl;
- sg[data_idx].length = len;
+ if (len) {
+ int data_idx = (datain ? 2 : 1);
+ sg[data_idx].addr = op->buf_fl;
+ sg[data_idx].length = len;
+ }
/* Add to virtqueue and kick host */
vring_add_buf(vq, sg, out_num, in_num, 0, 0);
--
1.7.9.1
From 9c70fa372c60e1195bc407fcd0064efc24f440a5 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Mon, 19 Mar 2012 11:37:30 +0100
Subject: [PATCH 4/4] ata: send TEST UNIT READY correctly
The ATAPI driver does not need to support writes, but it does needs to
avoid the PIO transfer and DRQ check when TEST UNIT READY is sent.
Since TEST UNIT READY has no payload, checking for not busy is enough.
This fixes a timeout when booting from CD/DVD, which fellaw@gmx.net
reported to cause boot failures.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
src/ata.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/ata.c b/src/ata.c
index b33dcb6..752db4a 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -642,13 +642,15 @@ atapi_cmd_data(struct disk_op_s *op, void *cdbcmd, u16 blocksize)
ret = -2;
goto fail;
}
- if (!(status & ATA_CB_STAT_DRQ)) {
- dprintf(6, "send_atapi_cmd : DRQ not set (status %02x)\n", status);
- ret = -3;
- goto fail;
- }
+ if (blocksize) {
+ if (!(status & ATA_CB_STAT_DRQ)) {
+ dprintf(6, "send_atapi_cmd : DRQ not set (status %02x)\n", status);
+ ret = -3;
+ goto fail;
+ }
- ret = ata_pio_transfer(op, 0, blocksize);
+ ret = ata_pio_transfer(op, 0, blocksize);
+ }
fail:
// Enable interrupts
--
1.7.9.1

View File

@ -1,27 +0,0 @@
commit a3fea015398d7c41db5b5d348fe3f6d76236b6be
Author: Paolo Bonzini <pbonzini@redhat.com>
Date: Fri Nov 18 15:59:24 2011 +0100
usb: fix boot paths
The fw paths for USB devices that SeaBIOS computes are off-by-one,
because QEMU builds those paths with a numbering that starts from one
(see usb_fill_port and usb_hub_initfn in QEMU). Fix that so that
the numbering agrees.
diff --git a/src/boot.c b/src/boot.c
index 119f290..93928d3 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -191,9 +191,9 @@ int bootprio_find_usb(struct pci_device *pci, u64 path)
for (i=56; i>0; i-=8) {
int port = (path >> i) & 0xff;
if (port != 0xff)
- p += snprintf(p, desc+sizeof(desc)-p, "/hub@%x", port);
+ p += snprintf(p, desc+sizeof(desc)-p, "/hub@%x", port+1);
}
- snprintf(p, desc+sizeof(desc)-p, "/*@%x", (u32)(path & 0xff));
+ snprintf(p, desc+sizeof(desc)-p, "/*@%x", (u32)(path & 0xff)+1);
return find_prio(desc);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,16 @@
Name: seabios
Version: 1.6.3
Release: 2%{?dist}
Version: 1.7.0
Release: 1%{?dist}
Summary: Open-source legacy BIOS implementation
Group: Applications/Emulators
License: LGPLv3
URL: http://www.coreboot.org/SeaBIOS
Source0: http://www.linuxtogo.org/~kevin/SeaBIOS/%{name}-%{version}.tar.gz
# Don't advertise guest support for S3/S4 (bz 741375)
# keep: Non upstream, carry it until someone needs s3/s4
Patch1: %{name}-do-not-advertise-S4-S3-in-DSDT.patch
Patch00: seabios-usb_fix_boot_paths.patch
Patch01: seabios-do-not-advertise-S4-S3-in-DSDT.patch
Patch02: seabios-virtio-scsi.patch
Patch03: seabios-usb-boot.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -29,7 +28,7 @@ SeaBIOS is an open-source legacy BIOS implementation which can be used as
a coreboot payload. It implements the standard BIOS calling interfaces
that a typical x86 proprietary BIOS implements.
%ifarch %{ix86} x86_64
%ifarch %{ix86} x86_64
%package bin
Summary: Seabios for x86
Buildarch: noarch
@ -42,27 +41,24 @@ that a typical x86 proprietary BIOS implements.
%prep
%setup -q
%patch1 -p1
%patch00 -p1
%patch01 -p1
%patch02 -p1
%patch03 -p1
# Makefile changes version to include date and buildhost
sed -i 's,VERSION=%{version}.*,VERSION=%{version},g' Makefile
%build
%ifarch %{ix86} x86_64
%ifarch %{ix86} x86_64
export CFLAGS="$RPM_OPT_FLAGS"
make
make
%endif
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT%{_datadir}/seabios
%ifarch %{ix86} x86_64
%ifarch %{ix86} x86_64
install -m 0644 out/bios.bin $RPM_BUILD_ROOT%{_datadir}/seabios
%endif
@ -75,7 +71,7 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,-)
%doc COPYING COPYING.LESSER README TODO
%ifarch %{ix86} x86_64
%ifarch %{ix86} x86_64
%files bin
%defattr(-,root,root,-)
%dir %{_datadir}/seabios/
@ -84,6 +80,12 @@ rm -rf $RPM_BUILD_ROOT
%changelog
* Mon May 28 2012 Cole Robinson <crobinso@redhat.com> - 1.7.0-1
- Rebased to version 1.7.0
- Support for virtio-scsi
- Improved USB drive support
- Several USB controller bug fixes and improvements
* Wed Mar 28 2012 Paolo Bonzini <pbonzini@redhat.com> - 1.6.3-2
- Fix bugs in booting from host (or redirected) USB pen drives

View File

@ -1 +1 @@
d7cd612ff34f9b910a63c2d73b25eef3 seabios-1.6.3.tar.gz
b3a6881a69a389e0463ce4e52d01c475 seabios-1.7.0.tar.gz