diff --git a/src/system/boot/platform/openfirmware/devices.cpp b/src/system/boot/platform/openfirmware/devices.cpp index 9e0f5a5f41..03b00bfe4f 100644 --- a/src/system/boot/platform/openfirmware/devices.cpp +++ b/src/system/boot/platform/openfirmware/devices.cpp @@ -1,5 +1,6 @@ /* * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2010, Andreas Färber * All rights reserved. Distributed under the terms of the MIT License. */ @@ -10,6 +11,8 @@ #include #include #include +#include +#include #include #include #include @@ -20,6 +23,9 @@ #include "machine.h" +#define ENABLE_ISCSI + + char sBootPath[192]; @@ -46,14 +52,45 @@ platform_add_boot_device(struct stage2_args *args, NodeList *devicesList) status_t error = net_stack_init(); if (error != B_OK) return error; - + + ip_addr_t bootAddress = 0; + char* bootArgs = strrchr(sBootPath, ':'); + if (bootArgs != NULL) { + bootArgs++; + char* comma = strchr(bootArgs, ','); + if (comma != NULL && comma - bootArgs > 0) { + comma[0] = '\0'; + bootAddress = ip_parse_address(bootArgs); + comma[0] = ','; + } + } + if (bootAddress == 0) { + int package = of_finddevice("/options"); + char defaultServerIP[16]; + int bytesRead = of_getprop(package, "default-server-ip", + defaultServerIP, sizeof(defaultServerIP) - 1); + if (bytesRead != OF_FAILED && bytesRead > 1) { + defaultServerIP[bytesRead] = '\0'; + bootAddress = ip_parse_address(defaultServerIP); + } + } + // init a remote disk, if possible RemoteDisk *remoteDisk = RemoteDisk::FindAnyRemoteDisk(); - if (!remoteDisk) - return B_ENTRY_NOT_FOUND; + if (remoteDisk != NULL) { + devicesList->Add(remoteDisk); + return B_OK; + } - devicesList->Add(remoteDisk); - return B_OK; +#ifdef ENABLE_ISCSI + if (bootAddress != 0) { + if (iSCSITarget::DiscoverTargets(bootAddress, ISCSI_PORT, + devicesList)) + return B_OK; + } +#endif + + return B_ENTRY_NOT_FOUND; } if (strcmp("block", type) != 0) {