Implemented load_kernel(), load_modules() now traverses the
/boot/beos/system/add-ons/boot directory for boot modules (it currently only prints out all the modules found). Not yet tested! git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5049 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
21a3fff594
commit
384be72972
@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "loader.h"
|
#include "loader.h"
|
||||||
|
#include "elf.h"
|
||||||
|
|
||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <boot/stage2.h>
|
#include <boot/stage2.h>
|
||||||
@ -19,6 +20,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define KERNEL_IMAGE "kernel_" BOOT_ARCH
|
#define KERNEL_IMAGE "kernel_" BOOT_ARCH
|
||||||
|
#define KERNEL_PATH "beos/system/" KERNEL_IMAGE
|
||||||
|
|
||||||
|
|
||||||
|
// temp. VFS API
|
||||||
|
extern Node *get_node_from(int fd);
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -28,7 +34,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, "beos/system/" KERNEL_IMAGE, O_RDONLY);
|
int fd = open_from(volume, KERNEL_PATH, O_RDONLY);
|
||||||
if (fd < B_OK)
|
if (fd < B_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -41,21 +47,29 @@ is_bootable(Directory *volume)
|
|||||||
status_t
|
status_t
|
||||||
load_kernel(stage2_args *args, Directory *volume)
|
load_kernel(stage2_args *args, Directory *volume)
|
||||||
{
|
{
|
||||||
if (!is_bootable(volume))
|
int fd = open_from(volume, KERNEL_PATH, O_RDONLY);
|
||||||
return B_ENTRY_NOT_FOUND;
|
if (fd < B_OK)
|
||||||
|
return fd;
|
||||||
|
|
||||||
puts("load kernel...");
|
puts("load kernel...");
|
||||||
|
|
||||||
// ToDo: really load that thing :)
|
preloaded_image image;
|
||||||
|
status_t status = elf_load_image(fd, &image);
|
||||||
|
|
||||||
void *cookie;
|
close(fd);
|
||||||
|
|
||||||
|
if (status < B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
puts("kernel loaded successfully");
|
||||||
|
/* void *cookie;
|
||||||
if (volume->Open(&cookie, O_RDONLY) == B_OK) {
|
if (volume->Open(&cookie, O_RDONLY) == B_OK) {
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
while (volume->GetNextEntry(cookie, name, sizeof(name)) == B_OK)
|
while (volume->GetNextEntry(cookie, name, sizeof(name)) == B_OK)
|
||||||
printf("\t%s\n", name);
|
printf("\t%s\n", name);
|
||||||
|
|
||||||
volume->Close(cookie);
|
volume->Close(cookie);
|
||||||
}
|
}*/
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +77,25 @@ load_kernel(stage2_args *args, Directory *volume)
|
|||||||
status_t
|
status_t
|
||||||
load_modules(stage2_args *args, Directory *volume)
|
load_modules(stage2_args *args, Directory *volume)
|
||||||
{
|
{
|
||||||
|
// we don't have readdir() & co. yet...
|
||||||
|
|
||||||
|
int fd = open_from(volume, "beos/system/add-ons/boot", O_RDONLY);
|
||||||
|
if (fd < B_OK)
|
||||||
|
return fd;
|
||||||
|
|
||||||
|
Directory *modules = (Directory *)get_node_from(fd);
|
||||||
|
if (modules == NULL)
|
||||||
|
return B_ENTRY_NOT_FOUND;
|
||||||
|
|
||||||
|
void *cookie;
|
||||||
|
if (modules->Open(&cookie, O_RDONLY) == B_OK) {
|
||||||
|
char name[B_FILE_NAME_LENGTH];
|
||||||
|
while (modules->GetNextEntry(cookie, name, sizeof(name)) == B_OK)
|
||||||
|
printf("\t%s\n", name);
|
||||||
|
|
||||||
|
modules->Close(cookie);
|
||||||
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user