Showing with 35 additions and 10 deletions.
  1. +17 −1 CHANGELOG.md
  2. +1 −1 src/block.c
  3. +10 −4 src/boot.c
  4. +6 −3 src/hw/sdcard.c
  5. +1 −1 src/hw/usb-xhci.c
18 changes: 17 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,6 +4,21 @@ Change log for PC Engines fork of SeaBIOS
Fourth digit in release number means PC Engines patch.

## [Unreleased]
## [rel-1.12.1.2] - 2019-06-04
### Changed
- increased maximum timeout values in SD interface to correctly detect and
communicate with SD cards in SD 3.0 mode

### Added
- hard disk fallback boot functionality:
- SeaBIOS will now loop through all detected hard disks (SATA, mSATA, USB,
SD) according to bootorder and try to boot from it;
- SeaBIOS will try next device only if MBR of the current drive is not
valid, i.e. the current device is not bootable
- secondary payloads (memtest, sortbootorder) will not be loaded
automatically, but only when desired (user has to enter boot menu with
F10 key and choose the payload explicitly)

## [rel-1.12.1.1] - 2019-04-03
### Changed
- rebased on SeaBIOS official repository commit f4c6e4c
Expand Down Expand Up @@ -84,7 +99,8 @@ Fourth digit in release number means PC Engines patch.
### Fixed
- prevented from printing character multiple times

[Unreleased]: https://github.com/pcengines/seabios/compare/rel-1.12.1.1...apu_support
[Unreleased]: https://github.com/pcengines/seabios/compare/rel-1.12.1.2...apu_support
[rel-1.12.1.2]: https://github.com/pcengines/seabios/compare/rel-1.12.1.1...rel-1.12.1.2
[rel-1.12.1.1]: https://github.com/pcengines/seabios/compare/rel-1.12.0.1...rel-1.12.1.1
[rel-1.12.0.1]: https://github.com/pcengines/seabios/compare/rel-1.11.0.7...rel-1.12.0.1
[rel-1.11.0.7]: https://github.com/pcengines/seabios/compare/rel-1.11.0.6...rel-1.11.0.7
Expand Down
2 changes: 1 addition & 1 deletion src/block.c
Expand Up @@ -494,7 +494,6 @@ block_setup(void)
floppy_setup();
ata_setup();
ahci_setup();
sdcard_setup();
ramdisk_setup();
virtio_blk_setup();
virtio_scsi_setup();
Expand All @@ -504,6 +503,7 @@ block_setup(void)
pvscsi_setup();
mpt_scsi_setup();
nvme_setup();
sdcard_setup();
}

// Fallback handler for command requests not implemented by drivers
Expand Down
14 changes: 10 additions & 4 deletions src/boot.c
Expand Up @@ -607,8 +607,9 @@ static int HaveHDBoot, HaveFDBoot;
static void
add_bev(int type, u32 vector)
{
if (type == IPL_TYPE_HARDDISK && HaveHDBoot++)
return;
if (type == IPL_TYPE_HARDDISK) {
HaveHDBoot = 1;
}
if (type == IPL_TYPE_FLOPPY && HaveFDBoot++)
return;
if (BEVCount >= ARRAY_SIZE(BEV))
Expand Down Expand Up @@ -784,6 +785,8 @@ boot_fail(void)
reset();
}

int HDDSequence VARLOW = 0;

// Determine next boot method and attempt a boot using it.
static void
do_boot(int seq_nr)
Expand All @@ -803,13 +806,15 @@ do_boot(int seq_nr)
break;
case IPL_TYPE_HARDDISK:
printf("Booting from Hard Disk...\n");
boot_disk(0x80, 1);
boot_disk(0x80 | HDDSequence++, 1);
break;
case IPL_TYPE_CDROM:
boot_cdrom((void*)ie->vector);
break;
case IPL_TYPE_CBFS:
boot_cbfs((void*)ie->vector);
/* boot from CBFS only when hard disk present and as first selection */
if (HaveHDBoot && (seq_nr == 0))
boot_cbfs((void*)ie->vector);
break;
case IPL_TYPE_BEV:
boot_rom(ie->vector);
Expand All @@ -835,6 +840,7 @@ handle_18(void)
debug_enter(NULL, DEBUG_HDL_18);
int seq = BootSequence + 1;
BootSequence = seq;
printf("Trying next device: %d\n", BootSequence + 1);
do_boot(seq);
}

Expand Down
9 changes: 6 additions & 3 deletions src/hw/sdcard.c
Expand Up @@ -135,7 +135,7 @@ struct sdhci_s {
#define SDHCI_POWER_ON_TIME 5
#define SDHCI_CLOCK_ON_TIME 1 // 74 clock cycles
#define SDHCI_POWERUP_TIMEOUT 1000
#define SDHCI_PIO_TIMEOUT 1000 // XXX - this is just made up
#define SDHCI_PIO_TIMEOUT 3000 // XXX - this is just made up

// Internal 'struct drive_s' storage for a detected card
struct sddrive_s {
Expand Down Expand Up @@ -492,10 +492,13 @@ static void
sdcard_controller_setup(struct sdhci_s *regs, int prio)
{
// Initialize controller
u32 present_state = readl(&regs->present_state);
if (!(present_state & SP_CARD_INSERTED))
int state = sdcard_waitw((u16 *)(&regs->present_state) + 1,
SP_CARD_INSERTED >> 16);
if (state == -1) {
// No card present
dprintf(3, "%s: No card present!\n", __func__);
return;
}
dprintf(3, "sdhci@%p ver=%x cap=%x %x\n", regs
, readw(&regs->controller_version)
, readl(&regs->cap_lo), readl(&regs->cap_hi));
Expand Down
2 changes: 1 addition & 1 deletion src/hw/usb-xhci.c
Expand Up @@ -333,7 +333,7 @@ xhci_hub_detect(struct usbhub_s *hub, u32 port)
{
struct usb_xhci_s *xhci = container_of(hub->cntl, struct usb_xhci_s, usb);
u32 portsc = readl(&xhci->pr[port].portsc);
xhci_print_port_state(3, __func__, port, portsc);
xhci_print_port_state(8, __func__, port, portsc);
return (portsc & XHCI_PORTSC_CCS) ? 1 : 0;
}

Expand Down