Added the start of a userland boot loader test (i.e. userland platform

bindings for the stage2 boot loader).


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4617 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2003-09-11 17:28:58 +00:00
parent 0686bd4707
commit 572edf3377
8 changed files with 269 additions and 0 deletions
+70
View File
@@ -0,0 +1,70 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#include "Handle.h"
#include <SupportDefs.h>
#include <boot/platform.h>
#include <stdio.h>
#include <unistd.h>
Handle::Handle(int handle, bool takeOwnership)
:
fHandle(handle),
fOwnHandle(takeOwnership)
{
}
Handle::Handle(void)
:
fHandle(0)
{
}
Handle::~Handle()
{
if (fOwnHandle)
close(fHandle);
}
void
Handle::SetHandle(int handle, bool takeOwnership)
{
if (fHandle && fOwnHandle)
close(fHandle);
fHandle = handle;
fOwnHandle = takeOwnership;
}
ssize_t
Handle::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
{
return pread(fHandle, buffer, bufferSize, pos);
}
ssize_t
Handle::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
{
return pwrite(fHandle, buffer, bufferSize, pos);
}
off_t
Handle::Size() const
{
// ToDo: fix this!
return 1024LL * 1024 * 1024 * 1024;
// 1024 GB
}
+34
View File
@@ -0,0 +1,34 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef HANDLE_H
#define HANDLE_H
#include <boot/vfs.h>
#ifdef __cplusplus
class Handle : public Node {
public:
Handle(int handle, bool takeOwnership = true);
Handle();
virtual ~Handle();
void SetHandle(int handle, bool takeOwnership = true);
virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize);
virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize);
virtual off_t Size() const;
protected:
int fHandle;
bool fOwnHandle;
};
#endif /* __cplusplus */
#endif /* HANDLE_H */
+56
View File
@@ -0,0 +1,56 @@
SubDir OBOS_TOP src tests kernel boot loader ;
UsePrivateHeaders [ FDirName kernel ] ;
UsePrivateHeaders [ FDirName kernel disk_device_manager ] ;
UsePrivateHeaders [ FDirName storage ] ;
SubDirHdrs $(OBOS_TOP) headers private kernel arch $(OBOS_ARCH) ;
ObjectDefines
heap.cpp
main.cpp
vfs.cpp
partitions.cpp
stdio.cpp
RootFileSystem.cpp
:
malloc=boot_malloc free=boot_free
read_pos=boot_read_pos close=boot_close
;
# This lets the correct stdio.h header be available
# on the build platform.
# This will be fixed with the move to GNU's stdio header
if $(OS) = "LINUX" {
# SubDirC++Flags -include /usr/include/stdio.h ;
} else {
SubDirC++Flags -include /boot/develop/headers/posix/stdio.h ;
}
SimpleTest BootLoaderTest :
platform_start.cpp
#platform_console.cpp
platform_debug.cpp
platform_devices.cpp
platform_heap.cpp
Handle.cpp
main.cpp
vfs.cpp
partitions.cpp
heap.cpp
RootFileSystem.cpp
list.c
:
: -fno-builtin
;
# Tell Jam where to find the utility sources
SEARCH on [ FGristFiles list.c ]
= [ FDirName $(OBOS_TOP) src kernel core util ] ;
SEARCH on [ FGristFiles
main.cpp vfs.cpp partitions.cpp
heap.cpp RootFileSystem.cpp
] = [ FDirName $(OBOS_TOP) src kernel boot loader ] ;
@@ -0,0 +1,34 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#include <boot/platform.h>
#include <stdio.h>
#include <stdarg.h>
void
panic(const char *format, ...)
{
va_list args;
puts("*** PANIC ***");
va_start(args, format);
vprintf(format, args);
va_end(args);
}
void
dprintf(const char *format, ...)
{
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
}
@@ -0,0 +1,16 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#include <boot/platform.h>
status_t
platform_get_boot_devices(struct stage2_args *args, struct list *list)
{
return B_OK;
}
@@ -0,0 +1,29 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#include <boot/platform.h>
#include <stdlib.h>
#define HEAP_SIZE 32768
extern "C" void
platform_release_heap(void *base)
{
free(base);
}
extern "C" status_t
platform_init_heap(struct stage2_args *args, void **_base, void **_top)
{
*_base = malloc(HEAP_SIZE);
*_top = (void *)((uint8 *)*_base + HEAP_SIZE);
return B_OK;
}
@@ -0,0 +1,12 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#ifndef PLATFORM_STAGE2_ARGS_H
#define PLATFORM_STAGE2_ARGS_H
struct platform_stage2_args {
/* they are just empty! */
};
#endif /* PLATFORM_STAGE2_ARGS_H */
@@ -0,0 +1,18 @@
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
#include <boot/platform.h>
extern "C" int boot(struct stage2_args *args);
int
main(int argc, char **argv)
{
boot(NULL);
return 0;
}