From 6f7c2dc67727c81c614d4905d98b8c2183e6114b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 3 Sep 2003 01:53:41 +0000 Subject: [PATCH] Missing boot loader headers. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4462 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/boot/partitions.h | 35 ++++++++++ headers/private/kernel/boot/stdio.h | 66 +++++++++++++++++++ headers/private/kernel/boot/vfs.h | 83 ++++++++++++++++++++++++ 3 files changed, 184 insertions(+) create mode 100644 headers/private/kernel/boot/partitions.h create mode 100755 headers/private/kernel/boot/stdio.h create mode 100644 headers/private/kernel/boot/vfs.h diff --git a/headers/private/kernel/boot/partitions.h b/headers/private/kernel/boot/partitions.h new file mode 100644 index 0000000000..7989462bb2 --- /dev/null +++ b/headers/private/kernel/boot/partitions.h @@ -0,0 +1,35 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef KERNEL_BOOT_PARTITIONS_H +#define KERNEL_BOOT_PARTITIONS_H + + +#include +#include + + +class Partition : public partition_data, Node { + public: + Partition(int deviceFD); + virtual ~Partition(); + + virtual ssize_t ReadAt(void *cookie, off_t offset, void *buffer, size_t bufferSize); + virtual ssize_t WriteAt(void *cookie, off_t offset, const void *buffer, size_t bufferSize); + + private: + int fFD; +}; + +// DiskDeviceTypes we need/support in the boot loader +#define kPartitionTypeAmiga "Amiga RDB" +#define kPartitionTypeIntel "Intel" +#define kPartitionTypeApple "Apple" + +struct partition_module_info; +extern partition_module_info gAmigaPartitionModule; +extern partition_module_info gIntelPartitionModule; +extern partition_module_info gApplePartitionModule; + +#endif /* KERNEL_BOOT_PARTITIONS_H */ diff --git a/headers/private/kernel/boot/stdio.h b/headers/private/kernel/boot/stdio.h new file mode 100755 index 0000000000..2a404be15b --- /dev/null +++ b/headers/private/kernel/boot/stdio.h @@ -0,0 +1,66 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef _STDIO_H_ +#define _STDIO_H_ + // must match the one of the real stdio.h + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct FILE FILE; + // dummy definition of FILE + // In the boot loader, it really is a ConsoleNode + +extern FILE *stdin; +extern FILE *stdout; +extern FILE *stderr; + +#ifndef SEEK_SET +# define SEEK_SET 0 +#endif +#ifndef SEEK_CUR +# define SEEK_CUR 1 +#endif +#ifndef SEEK_END +# define SEEK_END 2 +#endif + +#define EOF -1 + +#define __PRINTFLIKE(a, b) + +extern int printf(char const *format, ...) __PRINTFLIKE(1,2); +extern int fprintf(FILE *stream, char const *format, ...) __PRINTFLIKE(2,3); +extern int sprintf(char *str, char const *format, ...) __PRINTFLIKE(2,3); +extern int snprintf(char *str, size_t size, char const *format, ...) __PRINTFLIKE(3,4); +extern int asprintf(char **ret, char const *format, ...) __PRINTFLIKE(2,3); +extern int vprintf(char const *format, va_list ap); +extern int vfprintf(FILE *stream, char const *format, va_list ap); +extern int vsprintf(char *str, char const *format, va_list ap); +extern int vsnprintf(char *str, size_t size, char const *format, va_list ap); +extern int vasprintf(char **ret, char const *format, va_list ap); + +// ToDo: not everything is or should be implemented here +extern int fgetc(FILE *); +extern char *fgets(char *, int, FILE *); +extern int fputc(int, FILE *); +extern int fputs(const char *, FILE*); +extern int getc(FILE *); +extern char *gets(char *); +extern int getw(FILE *); +extern int getchar(void); +extern int putc(int, FILE *); +extern int putchar(int); +extern int puts(const char *); +extern int putw(int, FILE *); + +#ifdef __cplusplus +} +#endif + +#endif /* _STDIO_H_ */ diff --git a/headers/private/kernel/boot/vfs.h b/headers/private/kernel/boot/vfs.h new file mode 100644 index 0000000000..0c8dbf1d45 --- /dev/null +++ b/headers/private/kernel/boot/vfs.h @@ -0,0 +1,83 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ +#ifndef KERNEL_BOOT_VFS_H +#define KERNEL_BOOT_VFS_H + + +#include + +#include +#include + + +#ifdef __cplusplus + +/** This is the base class for all VFS nodes */ + +class Node { + public: + Node(); + virtual ~Node(); + + virtual status_t Open(void **_cookie, int mode); + virtual status_t Close(void *cookie); + + virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) = 0; + virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize) = 0; + + protected: + list_link fLink; + int32 fRefCount; +}; + + +/** The console based nodes don't need cookies for I/O, they + * also don't support to change the stream position. + * Live is simple in the boot loader :-) + */ + +class ConsoleNode : public Node { + public: + ConsoleNode(); + + virtual ssize_t Read(void *buffer, size_t bufferSize); + virtual ssize_t Write(const void *buffer, size_t bufferSize); +}; + +class Descriptor { + public: + Descriptor(Node *node, void *cookie); + ~Descriptor(); + + ssize_t Read(off_t pos, void *buffer, size_t bufferSize); + ssize_t Read(void *buffer, size_t bufferSize); + ssize_t Write(off_t pos, const void *buffer, size_t bufferSize); + ssize_t Write(const void *buffer, size_t bufferSize); + + off_t Offset() const { return fOffset; } + int32 RefCount() const { return fRefCount; } + + status_t Acquire(); + status_t Release(); + + private: + Node *fNode; + void *fCookie; + off_t fOffset; + int32 fRefCount; +}; + +extern "C" { +#endif /* __cplusplus */ + +extern status_t vfs_init(stage2_args *args); +extern status_t mount_boot_file_systems(); +extern status_t add_partitions_for(int fd); + +#ifdef __cplusplus +} +#endif + +#endif /* KERNEL_BOOT_VFS_H */