Changeset View
Changeset View
Standalone View
Standalone View
head/stand/efi/loader/main.c
Show First 20 Lines • Show All 759 Lines • ▼ Show 20 Lines | main(int argc, CHAR16 *argv[]) | ||||
archsw.arch_copyin = efi_copyin; | archsw.arch_copyin = efi_copyin; | ||||
archsw.arch_copyout = efi_copyout; | archsw.arch_copyout = efi_copyout; | ||||
archsw.arch_readin = efi_readin; | archsw.arch_readin = efi_readin; | ||||
archsw.arch_zfs_probe = efi_zfs_probe; | archsw.arch_zfs_probe = efi_zfs_probe; | ||||
/* Get our loaded image protocol interface structure. */ | /* Get our loaded image protocol interface structure. */ | ||||
BS->HandleProtocol(IH, &imgid, (VOID**)&img); | BS->HandleProtocol(IH, &imgid, (VOID**)&img); | ||||
/* | |||||
* Chicken-and-egg problem; we want to have console output early, but | |||||
* some console attributes may depend on reading from eg. the boot | |||||
* device, which we can't do yet. We can use printf() etc. once this is | |||||
* done. So, we set it to the efi console, then call console init. This | |||||
* gets us printf early, but also primes the pump for all future console | |||||
* changes to take effect, regardless of where they come from. | |||||
*/ | |||||
setenv("console", "efi", 1); | |||||
cons_probe(); | |||||
/* Tell ZFS probe code where we booted from, if zfs configured */ | /* Tell ZFS probe code where we booted from, if zfs configured */ | ||||
efizfs_set_preferred(img->DeviceHandle); | efizfs_set_preferred(img->DeviceHandle); | ||||
/* Init the time source */ | /* Init the time source */ | ||||
efi_time_init(); | efi_time_init(); | ||||
has_kbd = has_keyboard(); | has_kbd = has_keyboard(); | ||||
/* | /* | ||||
* XXX Chicken-and-egg problem; we want to have console output | |||||
* early, but some console attributes may depend on reading from | |||||
* eg. the boot device, which we can't do yet. We can use | |||||
* printf() etc. once this is done. | |||||
*/ | |||||
setenv("console", "efi", 1); | |||||
cons_probe(); | |||||
/* | |||||
* Initialise the block cache. Set the upper limit. | * Initialise the block cache. Set the upper limit. | ||||
*/ | */ | ||||
bcache_init(32768, 512); | bcache_init(32768, 512); | ||||
howto = parse_args(argc, argv); | howto = parse_args(argc, argv); | ||||
if (!has_kbd && (howto & RB_PROBE)) | if (!has_kbd && (howto & RB_PROBE)) | ||||
howto |= RB_SERIAL | RB_MULTIPLE; | howto |= RB_SERIAL | RB_MULTIPLE; | ||||
howto &= ~RB_PROBE; | howto &= ~RB_PROBE; | ||||
uhowto = parse_uefi_con_out(); | uhowto = parse_uefi_con_out(); | ||||
/* | /* | ||||
* We now have two notions of console. howto should be viewed as | * We now have two notions of console. howto should be viewed as | ||||
* overrides. If console is already set, don't set it again. | * overrides. If console is already set, don't set it again. | ||||
*/ | */ | ||||
#define VIDEO_ONLY 0 | #define VIDEO_ONLY 0 | ||||
#define SERIAL_ONLY RB_SERIAL | #define SERIAL_ONLY RB_SERIAL | ||||
#define VID_SER_BOTH RB_MULTIPLE | #define VID_SER_BOTH RB_MULTIPLE | ||||
#define SER_VID_BOTH (RB_SERIAL | RB_MULTIPLE) | #define SER_VID_BOTH (RB_SERIAL | RB_MULTIPLE) | ||||
#define CON_MASK (RB_SERIAL | RB_MULTIPLE) | #define CON_MASK (RB_SERIAL | RB_MULTIPLE) | ||||
if (strcmp(getenv("console"), "efi") == 0) { | if (strcmp(getenv("console"), "efi") == 0) { | ||||
if ((howto & CON_MASK) == 0) { | if ((howto & CON_MASK) == 0) { | ||||
/* No override, uhowto is controlling and efi cons is perfect */ | /* No override, uhowto is controlling and efi cons is perfect */ | ||||
howto = howto | (uhowto & CON_MASK); | howto = howto | (uhowto & CON_MASK); | ||||
setenv("console", "efi", 1); | |||||
} else if ((howto & CON_MASK) == (uhowto & CON_MASK)) { | } else if ((howto & CON_MASK) == (uhowto & CON_MASK)) { | ||||
/* override matches what UEFI told us, efi console is perfect */ | /* override matches what UEFI told us, efi console is perfect */ | ||||
setenv("console", "efi", 1); | |||||
} else if ((uhowto & (CON_MASK)) != 0) { | } else if ((uhowto & (CON_MASK)) != 0) { | ||||
/* | /* | ||||
* We detected a serial console on ConOut. All possible | * We detected a serial console on ConOut. All possible | ||||
* overrides include serial. We can't really override what efi | * overrides include serial. We can't really override what efi | ||||
* gives us, so we use it knowing it's the best choice. | * gives us, so we use it knowing it's the best choice. | ||||
*/ | */ | ||||
setenv("console", "efi", 1); | /* Do nothing */ | ||||
} else { | } else { | ||||
/* | /* | ||||
* We detected some kind of serial in the override, but ConOut | * We detected some kind of serial in the override, but ConOut | ||||
* has no serial, so we have to sort out which case it really is. | * has no serial, so we have to sort out which case it really is. | ||||
*/ | */ | ||||
switch (howto & CON_MASK) { | switch (howto & CON_MASK) { | ||||
case SERIAL_ONLY: | case SERIAL_ONLY: | ||||
setenv("console", "comconsole", 1); | setenv("console", "comconsole", 1); | ||||
▲ Show 20 Lines • Show All 592 Lines • Show Last 20 Lines |