efi: Only scan the BLKIO MEDIA once

Scan only the BLOCK IO MEDIA once instead of each time for each type of
device (fd, cd and hdd).
Leave the mechanism to free and reprobe all devices if one day we want
to implement a "dev rescan" thing.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D14334
This commit is contained in:
Emmanuel Vadot 2018-02-14 18:05:37 +00:00
parent ca72e2e288
commit 8b75269237
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329268
3 changed files with 16 additions and 17 deletions

View File

@ -106,4 +106,7 @@ int wcscmp(CHAR16 *, CHAR16 *);
void cpy8to16(const char *, CHAR16 *, size_t);
void cpy16to8(const CHAR16 *, char *, size_t);
/* efipart.c */
int efipart_inithandles(void);
#endif /* _LOADER_EFILIB_H */

View File

@ -148,7 +148,7 @@ efiblk_pdinfo_count(pdinfo_list_t *pdi)
return (i);
}
static int
int
efipart_inithandles(void)
{
UINTN sz;
@ -176,6 +176,10 @@ efipart_inithandles(void)
efipart_handles = hin;
efipart_nhandles = sz;
#ifdef EFIPART_DEBUG
printf("%s: Got %d BLOCK IO MEDIA handle(s)\n", __func__,
efipart_nhandles);
#endif
return (0);
}
@ -319,11 +323,7 @@ efipart_updatefd(void)
static int
efipart_initfd(void)
{
int rv;
rv = efipart_inithandles();
if (rv != 0)
return (rv);
STAILQ_INIT(&fdinfo);
efipart_updatefd();
@ -439,11 +439,7 @@ efipart_updatecd(void)
static int
efipart_initcd(void)
{
int rv;
rv = efipart_inithandles();
if (rv != 0)
return (rv);
STAILQ_INIT(&cdinfo);
efipart_updatecd();
@ -685,11 +681,7 @@ efipart_updatehd(void)
static int
efipart_inithd(void)
{
int rv;
rv = efipart_inithandles();
if (rv != 0)
return (rv);
STAILQ_INIT(&hdinfo);
efipart_updatehd();

View File

@ -456,11 +456,15 @@ main(int argc, CHAR16 *argv[])
}
/*
* March through the device switch probing for things.
* Scan the BLOCK IO MEDIA handles then
* march through the device switch probing for things.
*/
for (i = 0; devsw[i] != NULL; i++)
if (devsw[i]->dv_init != NULL)
(devsw[i]->dv_init)();
if ((i = efipart_inithandles()) == 0) {
for (i = 0; devsw[i] != NULL; i++)
if (devsw[i]->dv_init != NULL)
(devsw[i]->dv_init)();
} else
printf("efipart_inithandles failed %d, expect failures", i);
printf("Command line arguments:");
for (i = 0; i < argc; i++)