Showing with 61 additions and 243 deletions.
  1. +16 −1 CHANGELOG.md
  2. +39 −12 src/boot.c
  3. +0 −47 src/fw/coreboot.c
  4. +0 −45 src/fw/coreboot.h
  5. +3 −44 src/romfile.c
  6. +0 −94 src/sercon.c
  7. +3 −0 src/util.h
17 changes: 16 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,6 +4,20 @@ Change log for PC Engines fork of SeaBIOS
Fourth digit in release number means PC Engines patch.

## [Unreleased]
## [rel-1.12.1.3] - 2019-07-05
### Fixed
- some corner cases for boot fallback functionality:
- CBFS payloads were still booting when no HD media found (fixed)
- CBFS payloads can be loaded only explicitly when entered to boot menu
with F10 key
- if no HD media present and PXE is disabled, after boot menu wait timeout
SeaBIOS will print that no bootable device has been found and will reboot
after 60 seconds, unless entered to boot menu to choose a CBFS payload

### Changed
- removed obsolete and unused code implemented by previous maintainers in older
SeaBIOS versions

## [rel-1.12.1.2] - 2019-06-04
### Changed
- increased maximum timeout values in SD interface to correctly detect and
Expand Down Expand Up @@ -99,7 +113,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.2...apu_support
[Unreleased]: https://github.com/pcengines/seabios/compare/rel-1.12.1.3...apu_support
[rel-1.12.1.3]: https://github.com/pcengines/seabios/compare/rel-1.12.1.2...rel-1.12.1.3
[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
Expand Down
51 changes: 39 additions & 12 deletions src/boot.c
Expand Up @@ -119,7 +119,7 @@ int find_pxen(void)

// search for 'boot from usb' bit value
// if it doesn't exist - set to enabled
static int find_usben(void)
int find_usben(void)
{
int i;
for (i=0; i < BootorderCount; i++)
Expand All @@ -130,6 +130,32 @@ static int find_usben(void)
return 1;
}

int find_scon(void)
{
int i = 0;
for (i=0; i < BootorderCount; i++)
{
if (glob_prefix("scon0", Bootorder[i]))
return 0;
if (glob_prefix("scon1", Bootorder[i]))
return 1;
}
return -1;
}

int find_com2en(void)
{
int i = 0;
for (i=0; i < BootorderCount; i++)
{
if (glob_prefix("com2en0", Bootorder[i]))
return 0;
if (glob_prefix("com2en1", Bootorder[i]))
return 1;
}
return -1;
}

#define FW_PCI_DOMAIN "/pci@i0cf8"

static char *
Expand Down Expand Up @@ -492,6 +518,9 @@ get_keystroke(int msec)
* Boot menu and BCV execution
****************************************************************/

static int pxen;
static int menu_key_pressed = 0;

#define DEFAULT_BOOTMENU_WAIT 2500

// Show IPL option menu.
Expand All @@ -501,7 +530,7 @@ interactive_bootmenu(void)
// XXX - show available drives?

int n_key = 0;
int pxen = find_pxen();
pxen = find_pxen();

if (! CONFIG_BOOTMENU || !romfile_loadint("etc/show-boot-menu", 1))
return;
Expand Down Expand Up @@ -547,6 +576,7 @@ interactive_bootmenu(void)
}
// Show menu items if menu-key is pressed
else {
menu_key_pressed = 1;
printf("Select boot device:\n\n");
wait_threads();

Expand Down Expand Up @@ -602,14 +632,14 @@ struct bev_s {
};
static struct bev_s BEV[20];
static int BEVCount;
static int HaveHDBoot, HaveFDBoot;
static int HaveHDBoot = 0;
static int HaveFDBoot;

static void
add_bev(int type, u32 vector)
{
if (type == IPL_TYPE_HARDDISK) {
if (type == IPL_TYPE_HARDDISK)
HaveHDBoot = 1;
}
if (type == IPL_TYPE_FLOPPY && HaveFDBoot++)
return;
if (BEVCount >= ARRAY_SIZE(BEV))
Expand Down Expand Up @@ -654,10 +684,6 @@ bcv_prepboot(void)
break;
}
}

// If nothing added a floppy/hd boot - add it manually.
add_bev(IPL_TYPE_FLOPPY, 0);
add_bev(IPL_TYPE_HARDDISK, 0);
}


Expand Down Expand Up @@ -794,7 +820,8 @@ do_boot(int seq_nr)
if (! CONFIG_BOOT)
panic("Boot support not compiled in.\n");

if (seq_nr >= BEVCount)
if (seq_nr >= BEVCount || (HaveHDBoot == 0 && pxen == 0 &&
menu_key_pressed == 0))
boot_fail();

// Boot the given BEV type.
Expand All @@ -812,8 +839,8 @@ do_boot(int seq_nr)
boot_cdrom((void*)ie->vector);
break;
case IPL_TYPE_CBFS:
/* boot from CBFS only when hard disk present and as first selection */
if (HaveHDBoot && (seq_nr == 0))
/* boot from CBFS only as first selection */
if (seq_nr == 0)
boot_cbfs((void*)ie->vector);
break;
case IPL_TYPE_BEV:
Expand Down
47 changes: 0 additions & 47 deletions src/fw/coreboot.c
Expand Up @@ -17,7 +17,6 @@
#include "stacks.h" // yield
#include "string.h" // memset
#include "util.h" // coreboot_preinit
#include "coreboot.h" // cbfs_romfile overrides


/****************************************************************
Expand All @@ -35,13 +34,6 @@ struct cb_header {

#define CB_SIGNATURE 0x4f49424C // "LBIO"

// Generic cb record
//
struct cb_record {
u32 tag;
u32 size;
};

struct cb_memory_range {
u64 start;
u64 size;
Expand Down Expand Up @@ -170,45 +162,6 @@ find_cb_table(void)
static struct cb_memory *CBMemTable;
const char *CBvendor = "", *CBpart = "";

char *
get_cbmem_file(char * filename, int * size)
{
char *f = NULL;
struct cbfile_record *cbf = NULL;
struct file_container *cbmem_file_ptr =NULL;
unsigned long temp;

dprintf(3, "looking for file \"%s\" in cbmem\n", filename);

if ( size ) *size = 0;

// First we need to find the coreboot table
struct cb_header *cbh = find_cb_table();

if (cbh) {
// Now find the file entry
cbf = find_cb_subtable(cbh, CB_TAG_FILE);
}

cbmem_file_ptr = (struct file_container *) (u32) cbf->forward;

// If we found the FILE table we now need to walk through each entry.
while (cbmem_file_ptr->file_signature == CBMEM_ID_FILE) {

if (!strcmp( cbmem_file_ptr->file_name, filename ) ) {

f = (char *)cbmem_file_ptr->file_data;
if ( size ) *size = cbmem_file_ptr->file_size;
break;
}
dprintf(3, "found file \"%s\" in cbmem\n", cbmem_file_ptr->file_name);
temp = (u32) cbmem_file_ptr + sizeof(struct file_container) + cbmem_file_ptr->file_size;
temp = ALIGN(temp, 16);
cbmem_file_ptr = (struct file_container *) temp;
}
return f;
}

// Populate max ram and e820 map info by scanning for a coreboot table.
void
coreboot_preinit(void)
Expand Down
45 changes: 0 additions & 45 deletions src/fw/coreboot.h

This file was deleted.

47 changes: 3 additions & 44 deletions src/romfile.c
Expand Up @@ -9,7 +9,6 @@
#include "output.h" // dprintf
#include "romfile.h" // struct romfile_s
#include "string.h" // memcmp
#include "fw/coreboot.h" // cbfs_romfile overrides

static struct romfile_s *RomfileRoot VARVERIFY32INIT;

Expand All @@ -29,16 +28,8 @@ __romfile_findprefix(const char *prefix, int prefixlen, struct romfile_s *prev)
if (prev)
cur = prev->next;
while (cur) {
if (memcmp(prefix, cur->name, prefixlen) == 0) {

int dont_hide;
// Check if we should hide this
char *data = get_cbmem_file( (char *) cur->name, &dont_hide );
if (!data) // no override for this file
return cur;
if (dont_hide) // We know it and shouldn't hide
return cur;
}
if (memcmp(prefix, cur->name, prefixlen) == 0)
return cur;
cur = cur->next;
}
return NULL;
Expand All @@ -61,17 +52,6 @@ romfile_find(const char *name)
void *
romfile_loadfile(const char *name, int *psize)
{
// First try to read a file override from cbmem
char *data = get_cbmem_file( (char *) name, psize );

if ( data ) {
if ( !*psize ) {
dprintf(3, "Hiding romfile '%s'\n", name);
return NULL;
}
return data;
}

struct romfile_s *file = romfile_find(name);
if (!file)
return NULL;
Expand All @@ -80,7 +60,7 @@ romfile_loadfile(const char *name, int *psize)
if (!filesize)
return NULL;

data = malloc_tmphigh(filesize+1);
char *data = malloc_tmphigh(filesize+1);
if (!data) {
warn_noalloc();
return NULL;
Expand All @@ -103,27 +83,6 @@ romfile_loadfile(const char *name, int *psize)
u64
romfile_loadint(const char *name, u64 defval)
{
int size;

// First try to read a file override from cbmem
char *data = get_cbmem_file( (char *) name, &size );

if ( data ) {
u64 val = 0;

switch (size){
case 1:
case 2:
case 4:
case 8:
memcpy(&val, data, size);
break;
default:
return defval;
}
return val;
}

struct romfile_s *file = romfile_find(name);
if (!file)
return defval;
Expand Down