diff options
author | marcel <marcel@FreeBSD.org> | 2002-03-30 07:32:08 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2002-03-30 07:32:08 +0000 |
commit | dd7885b88d86945bdfa6cda1778915c71dbdb7e5 (patch) | |
tree | 3b0440eb13c3a13e3e698ab7bd8807e59fb17a77 | |
parent | 64a996484de482b9b6f2a8b00e8e32761e2882ca (diff) | |
download | FreeBSD-src-dd7885b88d86945bdfa6cda1778915c71dbdb7e5.zip FreeBSD-src-dd7885b88d86945bdfa6cda1778915c71dbdb7e5.tar.gz |
Add a quick and dirty way to determine where we're loaded from. We
only care if it's network or not at this time. If we're loaded from
the network, we set currdev (=loaddev) so that the kernel is loaded
from the network as well. In all other cases we initialize to disk.
This makes netbooting more convenient and can easily be enhanced to
do more elaborate checking.
-rw-r--r-- | sys/boot/efi/loader/main.c | 36 | ||||
-rw-r--r-- | sys/boot/ia64/efi/main.c | 36 |
2 files changed, 56 insertions, 16 deletions
diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c index 97eea20..553b7fc 100644 --- a/sys/boot/efi/loader/main.c +++ b/sys/boot/efi/loader/main.c @@ -98,10 +98,15 @@ find_pal_proc(void) EFI_STATUS efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) { - int i; + static EFI_GUID imgid = LOADED_IMAGE_PROTOCOL; + static EFI_GUID netid = EFI_SIMPLE_NETWORK_PROTOCOL; EFI_PHYSICAL_ADDRESS mem; + EFI_LOADED_IMAGE *img; + EFI_SIMPLE_NETWORK *net; + EFI_STATUS status; struct ia64_pal_result res; char buf[32]; + int i; efi_init(image_handle, system_table); @@ -145,14 +150,29 @@ efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) printf("Memory: %ld k\n", memsize() / 1024); #endif - /* XXX presumes that biosdisk is first in devsw */ - currdev.d_dev = devsw[0]; + + /* + * XXX quick and dirty check to see if we're loaded from the + * network. If so, we set the default device to 'net'. In all + * other cases we set the default device to 'disk'. We presume + * fixed positions in devsw for both net and disk. + */ + BS->HandleProtocol(image_handle, &imgid, (VOID**)&img); + + status = BS->HandleProtocol(img->DeviceHandle, &netid, (VOID**)&net); + if (status == EFI_SUCCESS && net != NULL) { + currdev.d_dev = devsw[1]; /* XXX net */ + currdev.d_kind.netif.unit = 0; + } else { + currdev.d_dev = devsw[0]; /* XXX disk */ + currdev.d_kind.efidisk.unit = 0; + /* XXX should be able to detect this, default to autoprobe */ + currdev.d_kind.efidisk.slice = -1; + /* default to 'a' */ + currdev.d_kind.efidisk.partition = 0; + } + currdev.d_type = currdev.d_dev->dv_type; - currdev.d_kind.efidisk.unit = 0; - /* XXX should be able to detect this, default to autoprobe */ - currdev.d_kind.efidisk.slice = -1; - /* default to 'a' */ - currdev.d_kind.efidisk.partition = 0; #if 0 /* Create arc-specific variables */ diff --git a/sys/boot/ia64/efi/main.c b/sys/boot/ia64/efi/main.c index 97eea20..553b7fc 100644 --- a/sys/boot/ia64/efi/main.c +++ b/sys/boot/ia64/efi/main.c @@ -98,10 +98,15 @@ find_pal_proc(void) EFI_STATUS efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) { - int i; + static EFI_GUID imgid = LOADED_IMAGE_PROTOCOL; + static EFI_GUID netid = EFI_SIMPLE_NETWORK_PROTOCOL; EFI_PHYSICAL_ADDRESS mem; + EFI_LOADED_IMAGE *img; + EFI_SIMPLE_NETWORK *net; + EFI_STATUS status; struct ia64_pal_result res; char buf[32]; + int i; efi_init(image_handle, system_table); @@ -145,14 +150,29 @@ efi_main (EFI_HANDLE image_handle, EFI_SYSTEM_TABLE *system_table) printf("Memory: %ld k\n", memsize() / 1024); #endif - /* XXX presumes that biosdisk is first in devsw */ - currdev.d_dev = devsw[0]; + + /* + * XXX quick and dirty check to see if we're loaded from the + * network. If so, we set the default device to 'net'. In all + * other cases we set the default device to 'disk'. We presume + * fixed positions in devsw for both net and disk. + */ + BS->HandleProtocol(image_handle, &imgid, (VOID**)&img); + + status = BS->HandleProtocol(img->DeviceHandle, &netid, (VOID**)&net); + if (status == EFI_SUCCESS && net != NULL) { + currdev.d_dev = devsw[1]; /* XXX net */ + currdev.d_kind.netif.unit = 0; + } else { + currdev.d_dev = devsw[0]; /* XXX disk */ + currdev.d_kind.efidisk.unit = 0; + /* XXX should be able to detect this, default to autoprobe */ + currdev.d_kind.efidisk.slice = -1; + /* default to 'a' */ + currdev.d_kind.efidisk.partition = 0; + } + currdev.d_type = currdev.d_dev->dv_type; - currdev.d_kind.efidisk.unit = 0; - /* XXX should be able to detect this, default to autoprobe */ - currdev.d_kind.efidisk.slice = -1; - /* default to 'a' */ - currdev.d_kind.efidisk.partition = 0; #if 0 /* Create arc-specific variables */ |