efi: change eficonfig ordering so memconf() is first, dont fallback to fs when /cfg/pxe/ file isnt there

having the memconf() (*e820=) last clutters the screen.
do it first, so we can read *acpi= and *bootscreen=
prints.

we want to continue using tftp even when the /cfg/pxe/$ether
file is not found. only when we detect no pxe/dhcp session,
then we switch to local filesystem (non-network boot).
This commit is contained in:
cinap_lenrek 2014-10-24 00:40:09 +02:00
parent 3bb7ad61aa
commit fa3e71ab80
4 changed files with 57 additions and 36 deletions

View file

@ -266,7 +266,7 @@ Found:
*s++ = ' ';
*s++ = '0', *s++ = 'x';
s = hexfmt(s, 16, gop->Mode->FrameBufferBase), *s++ = '\n';
s = hexfmt(s, 0, gop->Mode->FrameBufferBase), *s++ = '\n';
*s = '\0';
print(*cfg);
@ -276,9 +276,9 @@ Found:
void
eficonfig(char **cfg)
{
screenconf(cfg);
acpiconf(cfg);
memconf(cfg);
acpiconf(cfg);
screenconf(cfg);
}
EFI_STATUS
@ -290,9 +290,9 @@ efimain(EFI_HANDLE ih, EFI_SYSTEM_TABLE *st)
IH = ih;
ST = st;
f = pxeinit();
if(f == nil)
f = fsinit();
f = nil;
if(pxeinit(&f) && fsinit(&f))
print("no boot devices\n");
for(;;){
kern = configure(f, path);

View file

@ -7,8 +7,8 @@ extern char hex[];
void usleep(int t);
void jump(void *pc);
void* pxeinit(void);
void* fsinit(void);
int pxeinit(void **pf);
int fsinit(void **pf);
void* (*open)(char *name);
int (*read)(void *f, void *data, int len);

View file

@ -83,8 +83,8 @@ fsclose(void *f)
eficall(((EFI_FILE_PROTOCOL*)f)->Close, f);
}
void*
fsinit(void)
int
fsinit(void **pf)
{
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *fs;
@ -92,15 +92,18 @@ fsinit(void)
fsroot = nil;
if(eficall(ST->BootServices->LocateProtocol,
&EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, nil, &fs))
return nil;
return -1;
if(eficall(fs->OpenVolume, fs, &fsroot)){
fsroot = nil;
return nil;
return -1;
}
read = fsread;
close = fsclose;
open = fsopen;
return fsopen("/plan9.ini");
if(pf != nil)
*pf = fsopen("/plan9.ini");
return 0;
}

View file

@ -70,6 +70,11 @@ typedef struct {
UINT8 DhcpDiscover[1472];
UINT8 DhcpAck[1472];
UINT8 ProxyOffer[1472];
UINT8 PxeDiscover[1472];
UINT8 PxeReply[1472];
UINT8 PxeBisReply[1472];
} EFI_PXE_BASE_CODE_MODE;
typedef struct {
@ -308,19 +313,17 @@ pxeopen(char *name)
memmove(&t->dip, dhcp->BootpSiAddr, 4);
memmove(&t->sip, pxe->Mode->StationIp, 4);
if(tftpopen(t, name) == 0)
return t;
return nil;
if(tftpopen(t, name))
return nil;
return t;
}
void*
pxeinit(void)
int
pxeinit(void **pf)
{
EFI_PXE_BASE_CODE_MODE *mode;
EFI_HANDLE *Handles;
UINTN Count;
char ini[24];
uchar *mac;
void *f;
int i;
pxe = nil;
@ -329,31 +332,46 @@ pxeinit(void)
Handles = nil;
if(eficall(ST->BootServices->LocateHandleBuffer,
ByProtocol, &EFI_PXE_BASE_CODE_PROTOCOL_GUID, nil, &Count, &Handles))
return nil;
return -1;
for(i=0; i<Count; i++){
pxe = nil;
if(eficall(ST->BootServices->HandleProtocol,
Handles[i], &EFI_PXE_BASE_CODE_PROTOCOL_GUID, &pxe))
continue;
if(pxe->Mode != nil && pxe->Mode->Started)
break;
mode = pxe->Mode;
if(mode == nil || mode->UsingIpv6 || mode->Started == 0)
continue;
if(mode->DhcpAckReceived){
dhcp = (EFI_PXE_BASE_CODE_DHCPV4_PACKET*)mode->DhcpAck;
goto Found;
}
if(mode->PxeReplyReceived){
dhcp = (EFI_PXE_BASE_CODE_DHCPV4_PACKET*)mode->PxeReply;
goto Found;
}
}
dhcp = (EFI_PXE_BASE_CODE_DHCPV4_PACKET*)pxe->Mode->DhcpAck;
mac = dhcp->BootpHwAddr;
memmove(ini, "/cfg/pxe/", 9);
for(i=0; i<6; i++){
ini[9+i*2+0] = hex[mac[i] >> 4];
ini[9+i*2+1] = hex[mac[i] & 0xF];
}
ini[9+12] = '\0';
return -1;
Found:
open = pxeopen;
read = pxeread;
close = pxeclose;
if((f = pxeopen(ini)) != nil)
return f;
return pxeopen("/cfg/pxe/default");
if(pf != nil){
char ini[24];
uchar *mac;
mac = dhcp->BootpHwAddr;
memmove(ini, "/cfg/pxe/", 9);
for(i=0; i<6; i++){
ini[9+i*2+0] = hex[mac[i] >> 4];
ini[9+i*2+1] = hex[mac[i] & 0xF];
}
ini[9+12] = '\0';
if((*pf = pxeopen(ini)) == nil)
*pf = pxeopen("/cfg/pxe/default");
}
return 0;
}