Made the bootloader search for both kernel_x86 and kernel_x86_64 when built for x86 or x86_64.
This commit is contained in:
@@ -38,6 +38,18 @@ UsePrivateHeaders shared storage ;
|
|||||||
case "x86" :
|
case "x86" :
|
||||||
{
|
{
|
||||||
defines +=
|
defines +=
|
||||||
|
ALTERNATE_BOOT_ARCH=\\\"x86_64\\\"
|
||||||
|
|
||||||
|
BOOT_SUPPORT_PARTITION_EFI
|
||||||
|
|
||||||
|
#BOOT_SUPPORT_FILE_SYSTEM_FAT
|
||||||
|
;
|
||||||
|
}
|
||||||
|
case "x86_64" :
|
||||||
|
{
|
||||||
|
defines +=
|
||||||
|
ALTERNATE_BOOT_ARCH=\\\"x86\\\"
|
||||||
|
|
||||||
BOOT_SUPPORT_PARTITION_EFI
|
BOOT_SUPPORT_PARTITION_EFI
|
||||||
|
|
||||||
#BOOT_SUPPORT_FILE_SYSTEM_FAT
|
#BOOT_SUPPORT_FILE_SYSTEM_FAT
|
||||||
|
|||||||
@@ -24,11 +24,24 @@
|
|||||||
# error BOOT_ARCH has to be defined to differentiate the kernel per platform
|
# error BOOT_ARCH has to be defined to differentiate the kernel per platform
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define KERNEL_IMAGE "kernel_" BOOT_ARCH
|
#define KERNEL_IMAGE "kernel_" BOOT_ARCH
|
||||||
#define KERNEL_PATH "system/" KERNEL_IMAGE
|
#define KERNEL_PATH "system/" KERNEL_IMAGE
|
||||||
|
|
||||||
|
#ifdef ALTERNATE_BOOT_ARCH
|
||||||
|
# define ALTERNATE_KERNEL_IMAGE "kernel_" ALTERNATE_BOOT_ARCH
|
||||||
|
# define ALTERNATE_KERNEL_PATH "system/" ALTERNATE_KERNEL_IMAGE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static const char *sPaths[] = {
|
static const char *sKernelPaths[][2] = {
|
||||||
|
{ KERNEL_PATH, KERNEL_IMAGE },
|
||||||
|
#ifdef ALTERNATE_BOOT_ARCH
|
||||||
|
{ ALTERNATE_KERNEL_PATH, ALTERNATE_KERNEL_IMAGE },
|
||||||
|
#endif
|
||||||
|
{ NULL, NULL },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char *sAddonPaths[] = {
|
||||||
kVolumeLocalSystemKernelAddonsDirectory,
|
kVolumeLocalSystemKernelAddonsDirectory,
|
||||||
kVolumeLocalCommonKernelAddonsDirectory,
|
kVolumeLocalCommonKernelAddonsDirectory,
|
||||||
kVolumeLocalUserKernelAddonsDirectory,
|
kVolumeLocalUserKernelAddonsDirectory,
|
||||||
@@ -36,6 +49,22 @@ static const char *sPaths[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
find_kernel(Directory *volume, const char **name = NULL)
|
||||||
|
{
|
||||||
|
for (int32 i = 0; sKernelPaths[i][0] != NULL; i++) {
|
||||||
|
int fd = open_from(volume, sKernelPaths[i][0], O_RDONLY);
|
||||||
|
if (fd >= 0) {
|
||||||
|
if (name)
|
||||||
|
*name = sKernelPaths[i][1];
|
||||||
|
|
||||||
|
return fd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
is_bootable(Directory *volume)
|
is_bootable(Directory *volume)
|
||||||
{
|
{
|
||||||
@@ -43,7 +72,7 @@ is_bootable(Directory *volume)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// check for the existance of a kernel (for our platform)
|
// check for the existance of a kernel (for our platform)
|
||||||
int fd = open_from(volume, KERNEL_PATH, O_RDONLY);
|
int fd = find_kernel(volume);
|
||||||
if (fd < B_OK)
|
if (fd < B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -56,11 +85,12 @@ is_bootable(Directory *volume)
|
|||||||
status_t
|
status_t
|
||||||
load_kernel(stage2_args *args, Directory *volume)
|
load_kernel(stage2_args *args, Directory *volume)
|
||||||
{
|
{
|
||||||
int fd = open_from(volume, KERNEL_PATH, O_RDONLY);
|
const char *name;
|
||||||
|
int fd = find_kernel(volume, &name);
|
||||||
if (fd < B_OK)
|
if (fd < B_OK)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
dprintf("load kernel...\n");
|
dprintf("load kernel %s...\n", name);
|
||||||
|
|
||||||
elf_init();
|
elf_init();
|
||||||
status_t status = elf_load_image(fd, &gKernelArgs.kernel_image);
|
status_t status = elf_load_image(fd, &gKernelArgs.kernel_image);
|
||||||
@@ -78,7 +108,7 @@ load_kernel(stage2_args *args, Directory *volume)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
gKernelArgs.kernel_image.name = kernel_args_strdup(KERNEL_IMAGE);
|
gKernelArgs.kernel_image.name = kernel_args_strdup(name);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -129,9 +159,9 @@ load_module(Directory *volume, const char *name)
|
|||||||
if (strlcpy(moduleName, name, sizeof(moduleName)) > sizeof(moduleName))
|
if (strlcpy(moduleName, name, sizeof(moduleName)) > sizeof(moduleName))
|
||||||
return B_NAME_TOO_LONG;
|
return B_NAME_TOO_LONG;
|
||||||
|
|
||||||
for (int32 i = 0; sPaths[i]; i++) {
|
for (int32 i = 0; sAddonPaths[i]; i++) {
|
||||||
// get base path
|
// get base path
|
||||||
int baseFD = open_from(volume, sPaths[i], O_RDONLY);
|
int baseFD = open_from(volume, sAddonPaths[i], O_RDONLY);
|
||||||
if (baseFD < B_OK)
|
if (baseFD < B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -179,9 +209,9 @@ load_modules(stage2_args *args, Directory *volume)
|
|||||||
// ToDo: this should be mostly replaced by a hardware oriented detection mechanism
|
// ToDo: this should be mostly replaced by a hardware oriented detection mechanism
|
||||||
|
|
||||||
int32 i = 0;
|
int32 i = 0;
|
||||||
for (; sPaths[i]; i++) {
|
for (; sAddonPaths[i]; i++) {
|
||||||
char path[B_FILE_NAME_LENGTH];
|
char path[B_FILE_NAME_LENGTH];
|
||||||
snprintf(path, sizeof(path), "%s/boot", sPaths[i]);
|
snprintf(path, sizeof(path), "%s/boot", sAddonPaths[i]);
|
||||||
|
|
||||||
if (load_modules_from(volume, path) != B_OK)
|
if (load_modules_from(volume, path) != B_OK)
|
||||||
failed++;
|
failed++;
|
||||||
@@ -195,7 +225,7 @@ load_modules(stage2_args *args, Directory *volume)
|
|||||||
|
|
||||||
for (int32 i = 0; paths[i]; i++) {
|
for (int32 i = 0; paths[i]; i++) {
|
||||||
char path[B_FILE_NAME_LENGTH];
|
char path[B_FILE_NAME_LENGTH];
|
||||||
snprintf(path, sizeof(path), "%s/%s", sPaths[0], paths[i]);
|
snprintf(path, sizeof(path), "%s/%s", sAddonPaths[0], paths[i]);
|
||||||
load_modules_from(volume, path);
|
load_modules_from(volume, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,7 +250,7 @@ load_modules(stage2_args *args, Directory *volume)
|
|||||||
// as this piece will survive a more intelligent module
|
// as this piece will survive a more intelligent module
|
||||||
// loading approach...
|
// loading approach...
|
||||||
char path[B_FILE_NAME_LENGTH];
|
char path[B_FILE_NAME_LENGTH];
|
||||||
snprintf(path, sizeof(path), "%s/%s", sPaths[0], "file_systems");
|
snprintf(path, sizeof(path), "%s/%s", sAddonPaths[0], "file_systems");
|
||||||
load_modules_from(volume, path);
|
load_modules_from(volume, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user