Reorganized the boot platform dependencies in the kernel a bit.
Basically the architecture specific code is now responsible to init and make use of the platform specific code, now. The reason being that we have only one kernel per platform and thus cannot decide at compile time, which platform to use (if any). The PPC implementation features an abstract base class PPCPlatform (implemented for all supported platforms) through which platform support is provided. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15824 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a342fafcf4
commit
7afa713acb
@ -2,8 +2,8 @@
|
||||
* Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_PLATFORM_H
|
||||
#define _KERNEL_PLATFORM_H
|
||||
#ifndef _KERNEL_ARCH_PLATFORM_H
|
||||
#define _KERNEL_ARCH_PLATFORM_H
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
@ -13,12 +13,12 @@ struct kernel_args;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
status_t platform_init(struct kernel_args *kernelArgs);
|
||||
status_t platform_init_post_vm(struct kernel_args *kernelArgs);
|
||||
status_t arch_platform_init(struct kernel_args *kernelArgs);
|
||||
status_t arch_platform_init_post_vm(struct kernel_args *kernelArgs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
|
||||
#endif // _KERNEL_PLATFORM_H
|
||||
#endif // _KERNEL_ARCH_PLATFORM_H
|
32
headers/private/kernel/arch/ppc/arch_platform.h
Normal file
32
headers/private/kernel/arch/ppc/arch_platform.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _KERNEL_PPC_ARCH_PLATFORM_H
|
||||
#define _KERNEL_PPC_ARCH_PLATFORM_H
|
||||
|
||||
#include <arch/platform.h>
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class PPCPlatform {
|
||||
public:
|
||||
PPCPlatform();
|
||||
virtual ~PPCPlatform();
|
||||
|
||||
static PPCPlatform *Default();
|
||||
|
||||
virtual status_t Init(struct kernel_args *kernelArgs) = 0;
|
||||
virtual status_t InitSerialDebug(struct kernel_args *kernelArgs) = 0;
|
||||
virtual status_t InitPostVM(struct kernel_args *kernelArgs) = 0;
|
||||
|
||||
virtual char SerialDebugGetChar() = 0;
|
||||
virtual void SerialDebugPutChar(char c) = 0;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using BPrivate::PPCPlatform;
|
||||
|
||||
|
||||
#endif // _KERNEL_PPC_ARCH_PLATFORM_H
|
@ -4,12 +4,13 @@ KernelStaticLibrary libppc :
|
||||
arch_atomic.c
|
||||
arch_cpu.c
|
||||
arch_cpu_asm.S
|
||||
arch_debug_console.c
|
||||
arch_debug_console.cpp
|
||||
arch_debug.c
|
||||
arch_elf.c
|
||||
arch_exceptions.S
|
||||
arch_int.c
|
||||
arch_mmu.cpp
|
||||
arch_platform.cpp
|
||||
arch_real_time_clock.c
|
||||
arch_smp.c
|
||||
arch_system_info.c
|
||||
|
@ -7,19 +7,15 @@
|
||||
*/
|
||||
|
||||
|
||||
#include <arch_platform.h>
|
||||
#include <arch/debug_console.h>
|
||||
#include <boot/kernel_args.h>
|
||||
#include <kernel.h>
|
||||
#include <vm.h>
|
||||
#include <boot/kernel_args.h>
|
||||
#include <arch/debug_console.h>
|
||||
#include <platform/openfirmware/openfirmware.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
static int sInput = -1;
|
||||
static int sOutput = -1;
|
||||
|
||||
|
||||
char
|
||||
arch_debug_blue_screen_getchar(void)
|
||||
{
|
||||
@ -30,20 +26,14 @@ arch_debug_blue_screen_getchar(void)
|
||||
char
|
||||
arch_debug_serial_getchar(void)
|
||||
{
|
||||
int key;
|
||||
if (of_interpret("key", 0, 1, &key) == OF_FAILED)
|
||||
return 0;
|
||||
return (char)key;
|
||||
return PPCPlatform::Default()->SerialDebugGetChar();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
arch_debug_serial_putchar(const char c)
|
||||
{
|
||||
if (c == '\n')
|
||||
of_write(sOutput, "\r\n", 2);
|
||||
else
|
||||
of_write(sOutput, &c, 1);
|
||||
return PPCPlatform::Default()->SerialDebugPutChar(c);
|
||||
}
|
||||
|
||||
|
||||
@ -67,12 +57,7 @@ arch_debug_serial_early_boot_message(const char *string)
|
||||
status_t
|
||||
arch_debug_console_init(kernel_args *args)
|
||||
{
|
||||
if (of_getprop(gChosen, "stdin", &sInput, sizeof(int)) == OF_FAILED)
|
||||
return B_ERROR;
|
||||
if (of_getprop(gChosen, "stdout", &sOutput, sizeof(int)) == OF_FAILED)
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
return PPCPlatform::Default()->InitSerialDebug(args);
|
||||
}
|
||||
|
||||
|
172
src/system/kernel/arch/ppc/arch_platform.cpp
Normal file
172
src/system/kernel/arch/ppc/arch_platform.cpp
Normal file
@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <arch_platform.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <boot/kernel_args.h>
|
||||
#include <platform/openfirmware/openfirmware.h>
|
||||
#include <util/kernel_cpp.h>
|
||||
|
||||
|
||||
static PPCPlatform *sPPCPlatform;
|
||||
|
||||
|
||||
// constructor
|
||||
PPCPlatform::PPCPlatform()
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
PPCPlatform::~PPCPlatform()
|
||||
{
|
||||
}
|
||||
|
||||
// Default
|
||||
PPCPlatform *
|
||||
PPCPlatform::Default()
|
||||
{
|
||||
return sPPCPlatform;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Open Firmware
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
|
||||
class PPCOpenFirmware : public PPCPlatform {
|
||||
public:
|
||||
PPCOpenFirmware();
|
||||
virtual ~PPCOpenFirmware();
|
||||
|
||||
virtual status_t Init(struct kernel_args *kernelArgs);
|
||||
virtual status_t InitSerialDebug(struct kernel_args *kernelArgs);
|
||||
virtual status_t InitPostVM(struct kernel_args *kernelArgs);
|
||||
|
||||
virtual char SerialDebugGetChar();
|
||||
virtual void SerialDebugPutChar(char c);
|
||||
|
||||
private:
|
||||
int fInput;
|
||||
int fOutput;
|
||||
};
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
using BPrivate::PPCOpenFirmware;
|
||||
|
||||
|
||||
// OF debugger commands
|
||||
|
||||
// debug_command_of_exit
|
||||
static int
|
||||
debug_command_of_exit(int argc, char **argv)
|
||||
{
|
||||
of_exit();
|
||||
kprintf("of_exit() failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// debug_command_of_enter
|
||||
static int
|
||||
debug_command_of_enter(int argc, char **argv)
|
||||
{
|
||||
of_call_client_function("enter", 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// constructor
|
||||
PPCOpenFirmware::PPCOpenFirmware()
|
||||
: fInput(-1),
|
||||
fOutput(-1)
|
||||
{
|
||||
}
|
||||
|
||||
// destructor
|
||||
PPCOpenFirmware::~PPCOpenFirmware()
|
||||
{
|
||||
}
|
||||
|
||||
// Init
|
||||
status_t
|
||||
PPCOpenFirmware::Init(struct kernel_args *kernelArgs)
|
||||
{
|
||||
return of_init(
|
||||
(int(*)(void*))kernelArgs->platform_args.openfirmware_entry);
|
||||
}
|
||||
|
||||
// InitSerialDebug
|
||||
status_t
|
||||
PPCOpenFirmware::InitSerialDebug(struct kernel_args *kernelArgs)
|
||||
{
|
||||
if (of_getprop(gChosen, "stdin", &fInput, sizeof(int)) == OF_FAILED)
|
||||
return B_ERROR;
|
||||
if (of_getprop(gChosen, "stdout", &fOutput, sizeof(int)) == OF_FAILED)
|
||||
return B_ERROR;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// InitPostVM
|
||||
status_t
|
||||
PPCOpenFirmware::InitPostVM(struct kernel_args *kernelArgs)
|
||||
{
|
||||
add_debugger_command("of_exit", &debug_command_of_exit,
|
||||
"Exit to the Open Firmware prompt. No way to get back into the OS!");
|
||||
add_debugger_command("of_enter", &debug_command_of_enter,
|
||||
"Enter a subordinate Open Firmware interpreter. Quitting it returns "
|
||||
"to KDL.");
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// DebugSerialGetChar
|
||||
char
|
||||
PPCOpenFirmware::SerialDebugGetChar()
|
||||
{
|
||||
int key;
|
||||
if (of_interpret("key", 0, 1, &key) == OF_FAILED)
|
||||
return 0;
|
||||
return (char)key;
|
||||
}
|
||||
|
||||
// DebugSerialPutChar
|
||||
void
|
||||
PPCOpenFirmware::SerialDebugPutChar(char c)
|
||||
{
|
||||
if (c == '\n')
|
||||
of_write(fOutput, "\r\n", 2);
|
||||
else
|
||||
of_write(fOutput, &c, 1);
|
||||
}
|
||||
|
||||
|
||||
// # pragma mark -
|
||||
|
||||
|
||||
// static buffer for constructing the actual PPCPlatform
|
||||
static char *sPPCPlatformBuffer[sizeof(PPCOpenFirmware)];
|
||||
|
||||
status_t
|
||||
arch_platform_init(struct kernel_args *kernelArgs)
|
||||
{
|
||||
// only OpenFirmware supported for now
|
||||
if (true)
|
||||
sPPCPlatform = new(sPPCPlatformBuffer) PPCOpenFirmware;
|
||||
|
||||
return sPPCPlatform->Init(kernelArgs);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
arch_platform_init_post_vm(struct kernel_args *kernelArgs)
|
||||
{
|
||||
return sPPCPlatform->InitPostVM(kernelArgs);
|
||||
}
|
@ -10,6 +10,7 @@ KernelStaticLibrary libx86 :
|
||||
arch_debug_console.c
|
||||
arch_elf.c
|
||||
arch_int.c
|
||||
arch_platform.c
|
||||
# arch_selector.c
|
||||
arch_real_time_clock.c
|
||||
arch_smp.c
|
||||
|
20
src/system/kernel/arch/x86/arch_platform.c
Normal file
20
src/system/kernel/arch/x86/arch_platform.c
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2006, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <arch/platform.h>
|
||||
|
||||
|
||||
status_t
|
||||
arch_platform_init(struct kernel_args *kernelArgs)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
arch_platform_init_post_vm(struct kernel_args *kernelArgs)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <arch/platform.h>
|
||||
#include <boot_item.h>
|
||||
#include <cbuf.h>
|
||||
#include <cpu.h>
|
||||
@ -24,7 +25,6 @@
|
||||
#include <kscheduler.h>
|
||||
#include <ksyscalls.h>
|
||||
#include <messaging.h>
|
||||
#include <platform.h>
|
||||
#include <port.h>
|
||||
#include <real_time_clock.h>
|
||||
#include <sem.h>
|
||||
@ -82,7 +82,7 @@ _start(kernel_args *bootKernelArgs, int currentCPU)
|
||||
thread_id thread;
|
||||
|
||||
// init platform
|
||||
platform_init(&sKernelArgs);
|
||||
arch_platform_init(&sKernelArgs);
|
||||
|
||||
// setup debug output
|
||||
debug_init(&sKernelArgs);
|
||||
@ -104,7 +104,7 @@ _start(kernel_args *bootKernelArgs, int currentCPU)
|
||||
// the boot loader allocated region is not used anymore
|
||||
|
||||
// now we can use the heap and create areas
|
||||
platform_init_post_vm(&sKernelArgs);
|
||||
arch_platform_init_post_vm(&sKernelArgs);
|
||||
TRACE(("init driver_settings\n"));
|
||||
boot_item_init();
|
||||
driver_settings_init(&sKernelArgs);
|
||||
|
@ -1,21 +1,3 @@
|
||||
/*
|
||||
* Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
#include <boot/kernel_args.h>
|
||||
|
||||
status_t
|
||||
platform_init(struct kernel_args *kernelArgs)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
platform_init_post_vm(struct kernel_args *kernelArgs)
|
||||
{
|
||||
return B_OK;
|
||||
}
|
||||
Just a dummy. No BIOS services are required in the kernel.
|
||||
*/
|
||||
|
@ -5,5 +5,4 @@ SubDirC++Flags $(TARGET_KERNEL_PIC_CCFLAGS) ;
|
||||
|
||||
KernelStaticLibrary libopenfirmware.a :
|
||||
openfirmware.c
|
||||
platform.cpp
|
||||
;
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <platform.h>
|
||||
|
||||
#include <KernelExport.h>
|
||||
|
||||
#include <boot/kernel_args.h>
|
||||
#include <platform/openfirmware/openfirmware.h>
|
||||
|
||||
|
||||
static int
|
||||
debug_command_of_exit(int argc, char **argv)
|
||||
{
|
||||
of_exit();
|
||||
kprintf("of_exit() failed!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
debug_command_of_enter(int argc, char **argv)
|
||||
{
|
||||
of_call_client_function("enter", 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
platform_init(struct kernel_args *kernelArgs)
|
||||
{
|
||||
return of_init(
|
||||
(int(*)(void*))kernelArgs->platform_args.openfirmware_entry);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
platform_init_post_vm(struct kernel_args *kernelArgs)
|
||||
{
|
||||
add_debugger_command("of_exit", &debug_command_of_exit,
|
||||
"Exit to the Open Firmware prompt. No way to get back into the OS!");
|
||||
add_debugger_command("of_enter", &debug_command_of_enter,
|
||||
"Enter a subordinate Open Firmware interpreter. Quitting it returns "
|
||||
"to KDL.");
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user