Update kernel

This commit is contained in:
Alex
2023-06-10 13:11:25 +03:00
parent dcdba03426
commit 41db477173
82 changed files with 6342 additions and 4079 deletions

View File

@ -1,294 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <types.h>
#include <memory.hpp>
#include <debug.h>
// TODO: complete implementation for everything
// TODO: https://wiki.osdev.org/C%2B%2B
#define ATEXIT_MAX_FUNCS 128
typedef unsigned uarch_t;
struct atexit_func_entry_t
{
/*
* Each member is at least 4 bytes large. Such that each entry is 12bytes.
* 128 * 12 = 1.5KB exact.
**/
void (*destructor_func)(void *);
void *obj_ptr;
void *dso_handle;
};
typedef enum
{
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
_URC_FATAL_PHASE2_ERROR = 2,
_URC_FATAL_PHASE1_ERROR = 3,
_URC_NORMAL_STOP = 4,
_URC_END_OF_STACK = 5,
_URC_HANDLER_FOUND = 6,
_URC_INSTALL_CONTEXT = 7,
_URC_CONTINUE_UNWIND = 8
} _Unwind_Reason_Code;
struct _Unwind_Context;
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, struct _Unwind_Exception *);
typedef int _Unwind_Action;
struct type_info
{
const char *name;
};
struct unexpected_handler
{
void (*unexpected)();
};
struct terminate_handler
{
void (*handler)();
};
struct _Unwind_Exception
{
_Unwind_Exception_Class exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
#if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__SEH__)
_Unwind_Word private_[6];
#else
_Unwind_Word private_1;
_Unwind_Word private_2;
#endif
} __attribute__((__aligned__));
struct __cxa_exception
{
#if __LP64__
size_t referenceCount;
#endif
type_info *exceptionType;
void (*exceptionDestructor)(void *);
unexpected_handler unexpectedHandler;
terminate_handler terminateHandler;
__cxa_exception *nextException;
int handlerCount;
#ifdef __ARM_EABI_UNWINDER__
__cxa_exception *nextPropagatingException;
int propagationCount;
#else
int handlerSwitchValue;
const unsigned char *actionRecord;
const unsigned char *languageSpecificData;
_Unwind_Ptr catchTemp;
void *adjustedPtr;
#endif
#if !__LP64__
size_t referenceCount;
#endif
_Unwind_Exception unwindHeader;
};
/* extern */ void *__dso_handle = 0;
atexit_func_entry_t __atexit_funcs[ATEXIT_MAX_FUNCS];
uarch_t __atexit_func_count = 0;
extern "C" int __cxa_atexit(void (*f)(void *), void *objptr, void *dso)
{
fixme("__cxa_atexit( %p %p %p ) triggered.", f, objptr, dso);
if (__atexit_func_count >= ATEXIT_MAX_FUNCS)
return -1;
__atexit_funcs[__atexit_func_count].destructor_func = f;
__atexit_funcs[__atexit_func_count].obj_ptr = objptr;
__atexit_funcs[__atexit_func_count].dso_handle = dso;
__atexit_func_count++;
return 0;
}
extern "C" void __cxa_finalize(void *f)
{
fixme("__cxa_finalize( %p ) triggered.", f);
uarch_t i = __atexit_func_count;
if (!f)
{
while (i--)
if (__atexit_funcs[i].destructor_func)
(*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr);
return;
}
while (i--)
if (__atexit_funcs[i].destructor_func == f)
{
(*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr);
__atexit_funcs[i].destructor_func = 0;
}
}
extern "C" _Unwind_Reason_Code __gxx_personality_v0(int version, _Unwind_Action actions, _Unwind_Exception_Class exception_class, _Unwind_Exception *ue_header, _Unwind_Context *context)
{
fixme("__gxx_personality_v0( %d %p %p %p %p ) triggered.", version, actions, exception_class, ue_header, context);
return _URC_NO_REASON;
}
extern "C" void _Unwind_Resume(struct _Unwind_Exception *exc) { fixme("_Unwind_Resume( %p ) triggered.", exc); }
static inline size_t align_exception_allocation_size(size_t s, size_t a) { return (s + a - 1) & ~(a - 1); }
void unexpected_header_stub() { fixme("unexpected() called."); }
void terminate_header_stub() { fixme("terminate() called."); }
extern "C" void *__cxa_allocate_exception(size_t thrown_size) throw()
{
fixme("__cxa_allocate_exception( %d ) triggered.", thrown_size);
size_t real_size = align_exception_allocation_size(thrown_size + sizeof(__cxa_exception), alignof(__cxa_exception));
__cxa_exception *header = (__cxa_exception *)kmalloc(real_size);
if (!header)
{
error("Failed to allocate exception.");
return nullptr;
}
header->referenceCount = 1;
header->exceptionType = nullptr;
header->exceptionDestructor = nullptr;
header->unexpectedHandler = {.unexpected = unexpected_header_stub};
header->terminateHandler = {.handler = terminate_header_stub};
header->nextException = nullptr;
header->handlerCount = -1;
header->handlerSwitchValue = 0;
header->actionRecord = nullptr;
header->languageSpecificData = nullptr;
header->catchTemp = 0;
header->adjustedPtr = nullptr;
return header + 1;
}
extern "C" void _Unwind_RaiseException(_Unwind_Exception *exc)
{
fixme("_Unwind_RaiseException( %p ) triggered.", exc);
__cxa_exception *header = ((__cxa_exception *)exc) - 1;
if (header->terminateHandler.handler)
{
debug("Calling terminate handler.");
header->terminateHandler.handler();
}
else
{
error("Unhandled exception.");
CPU::Stop();
}
CPU::Halt(true);
}
extern "C" void __cxa_throw(void *thrown_object, void *tinfo, void (*dest)(void *))
{
fixme("__cxa_throw( %p %p %p ) triggered.", thrown_object, tinfo, dest);
__cxa_exception *header = ((__cxa_exception *)thrown_object) - 1;
header->exceptionType = (type_info *)tinfo;
header->exceptionDestructor = dest;
_Unwind_RaiseException(&header->unwindHeader);
}
extern "C" void __cxa_rethrow() { fixme("__cxa_rethrow() triggered."); }
extern "C" void __cxa_pure_virtual() { fixme("__cxa_pure_virtual() triggered."); }
extern "C" void __cxa_throw_bad_array_new_length() { fixme("__cxa_throw_bad_array_new_length() triggered."); }
extern "C" void __cxa_free_exception(void *thrown_exception) { fixme("__cxa_free_exception( %p ) triggered.", thrown_exception); }
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
extern "C" void *__cxa_begin_catch(void *e) throw()
#else
extern "C" void *__cxa_begin_catch(void *e)
#endif
{
fixme("__cxa_begin_catch( %p ) triggered.", e);
return (void *)0;
}
extern "C" void __cxa_end_catch() { fixme("__cxa_end_catch() triggered."); }
__extension__ typedef int __guard __attribute__((mode(__DI__)));
extern "C" int __cxa_guard_acquire(__guard *g)
{
fixme("__cxa_guard_acquire( %p ) triggered.", g);
return !*(char *)(g);
}
extern "C" void __cxa_guard_release(__guard *g)
{
fixme("__cxa_guard_release( %p ) triggered.", g);
*(char *)g = 1;
}
extern "C" void __cxa_guard_abort(__guard *g) { fixme("__cxa_guard_abort( %p ) triggered.", g); }
// vtable for __cxxabiv1::__class_type_info
extern "C" void *_ZTVN10__cxxabiv117__class_type_infoE(void)
{
fixme("_ZTVN10__cxxabiv117__class_type_infoE() triggered.");
return (void *)0;
}
// vtable for __cxxabiv1::__si_class_type_info
extern "C" void *_ZTVN10__cxxabiv120__si_class_type_infoE(void)
{
fixme("_ZTVN10__cxxabiv120__si_class_type_infoE() triggered.");
return (void *)0;
}
// typeinfo for int
extern "C" void *_ZTIi(void)
{
fixme("_ZTIi() triggered.");
return (void *)0;
}
// typeinfo for unsigned char*
extern "C" void *_ZTIPh(void)
{
fixme("_ZTIPh() triggered.");
return (void *)0;
}
// typeinfo for char const*
extern "C" void *_ZTIPKc(void)
{
fixme("_ZTIPKc() triggered.");
return (void *)0;
}

View File

@ -0,0 +1,103 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <typeinfo>
#include <debug.h>
namespace __cxxabiv1
{
__class_type_info::~__class_type_info() {}
bool __class_type_info::__do_upcast(const __class_type_info *Destination,
const void *Object,
__upcast_result &__restrict Result) const
{
if (*this != *Destination)
return false;
Result.dst_ptr = Object;
Result.base_type = nonvirtual_base_type;
Result.part2dst = __contained_public;
return true;
}
bool __class_type_info::__do_upcast(const __class_type_info *DestinationType,
void **ObjectPointer) const
{
__upcast_result Result(__vmi_class_type_info::__flags_unknown_mask);
__do_upcast(DestinationType, *ObjectPointer, Result);
if (!((Result.part2dst &
__class_type_info::__contained_public) ==
__class_type_info::__contained_public))
return false;
*ObjectPointer = const_cast<void *>(Result.dst_ptr);
return true;
}
bool __class_type_info::__do_catch(const type_info *ThrowType,
void **ThrowObject,
unsigned Outer) const
{
if (*this == *ThrowType)
return true;
if (Outer >= 4)
return false;
return ThrowType->__do_upcast(this, ThrowObject);
}
bool __class_type_info::__do_dyncast(ptrdiff_t,
__sub_kind AccessPath,
const __class_type_info *DestinationType,
const void *ObjectPointer,
const __class_type_info *SourceType,
const void *SourcePointer,
__dyncast_result &__restrict Result) const
{
if (ObjectPointer == SourcePointer &&
*this == *SourceType)
{
Result.whole2src = AccessPath;
return false;
}
if (*this == *DestinationType)
{
Result.dst_ptr = ObjectPointer;
Result.whole2dst = AccessPath;
Result.dst2src = __not_contained;
return false;
}
return false;
}
__class_type_info::__sub_kind __class_type_info::__do_find_public_src(ptrdiff_t,
const void *ObjectPointer,
const __class_type_info *,
const void *SourcePointer) const
{
if (SourcePointer == ObjectPointer)
return __contained_public;
return __not_contained;
}
}

View File

@ -0,0 +1,221 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <cxxabi.h>
#include <memory.hpp>
#include <debug.h>
#include <smp.hpp>
#include "../../kernel.h"
void __dso_handle_stub() { stub; }
/* extern */ void *__dso_handle = (void *)&__dso_handle_stub;
namespace __cxxabiv1
{
atexit_func_entry_t __atexit_funcs[ATEXIT_MAX_FUNCS];
uarch_t __atexit_func_count = 0;
__cxa_eh_globals *__cxa_get_globals() noexcept
{
return &GetCurrentCPU()->EHGlobals;
}
extern "C" int __cxa_atexit(void (*f)(void *), void *objptr, void *dso)
{
debug("Registering atexit function %p( %p, %p )",
f, objptr, dso);
if (__atexit_func_count >= ATEXIT_MAX_FUNCS)
return -1;
__atexit_funcs[__atexit_func_count].destructor_func = f;
__atexit_funcs[__atexit_func_count].obj_ptr = objptr;
__atexit_funcs[__atexit_func_count].dso_handle = dso;
__atexit_func_count++;
return 0;
}
extern "C" void __cxa_finalize(void *f)
{
fixme("__cxa_finalize( %p ) called.", f);
uarch_t i = __atexit_func_count;
if (!f)
{
while (i--)
if (__atexit_funcs[i].destructor_func)
(*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr);
return;
}
while (i--)
if (__atexit_funcs[i].destructor_func == f)
{
(*__atexit_funcs[i].destructor_func)(__atexit_funcs[i].obj_ptr);
__atexit_funcs[i].destructor_func = 0;
}
}
extern "C" _Unwind_Reason_Code __gxx_personality_v0(int version, _Unwind_Action actions, _Unwind_Exception_Class exception_class, _Unwind_Exception *ue_header, _Unwind_Context *context)
{
fixme("__gxx_personality_v0( %d %p %p %p %p ) called.", version, actions, exception_class, ue_header, context);
return _URC_NO_REASON;
}
extern "C" void *__cxa_begin_catch(void *thrown_object) noexcept
{
function("%p", thrown_object);
__cxa_exception *Exception = (__cxa_exception *)thrown_object - 1;
__cxa_eh_globals *Globals = __cxa_get_globals();
Exception->handlerCount++;
Globals->uncaughtExceptions--;
Exception->nextException = Globals->caughtExceptions;
Globals->caughtExceptions = Exception;
return Exception + 1;
}
extern "C" void __cxa_end_catch()
{
fixme("__cxa_end_catch() called.");
}
static __always_inline inline size_t align_exception_allocation_size(size_t a, size_t b)
{
return (a + b - 1) & ~(b - 1);
}
static __always_inline inline void INIT_EXCEPTION_CLASS(_Unwind_Exception_Class *c)
{
char *ptr = (char *)c;
ptr[0] = 'G';
ptr[1] = 'N';
ptr[2] = 'U';
ptr[3] = 'C';
ptr[4] = 'C';
ptr[5] = '+';
ptr[6] = '+';
ptr[7] = '\0';
}
void unexpected_header_stub() { fixme("unexpected() called."); }
void terminate_header_stub()
{
if (TaskManager && !TaskManager->IsPanic())
{
TaskManager->KillThread(TaskManager->GetCurrentThread(), Tasking::KILL_CXXABI_EXCEPTION);
TaskManager->Schedule();
}
error("No task manager to kill thread!");
CPU::Stop(); /* FIXME: Panic */
}
void exception_cleanup_stub(_Unwind_Reason_Code Code,
_Unwind_Exception *Exception)
{
fixme("exception_cleanup( %d %p ) called.",
Code, Exception);
}
extern "C" void *__cxa_allocate_exception(size_t thrown_size) throw()
{
debug("Allocating exception of size %d.", thrown_size);
size_t alloc_size = align_exception_allocation_size(thrown_size + sizeof(__cxa_exception), alignof(__cxa_exception));
__cxa_exception *Exception = (__cxa_exception *)kmalloc(alloc_size);
memset(Exception, 0, alloc_size);
return Exception + 1;
}
extern "C" __noreturn void __cxa_throw(void *thrown_object,
std::type_info *tinfo,
void (*dest)(void *))
{
trace("Throwing exception of type \"%s\". ( object: %p, destructor: %p )",
tinfo->name(), thrown_object, dest);
__cxa_eh_globals *Globals = __cxa_get_globals();
Globals->uncaughtExceptions++;
__cxa_exception *Exception = (__cxa_exception *)thrown_object - 1;
Exception->exceptionType = (std::type_info *)tinfo;
Exception->exceptionDestructor = dest;
Exception->unexpectedHandler = &unexpected_header_stub;
Exception->terminateHandler = &terminate_header_stub;
Exception->unwindHeader.exception_cleanup = &exception_cleanup_stub;
INIT_EXCEPTION_CLASS(&Exception->unwindHeader.exception_class);
Exception->adjustedPtr = thrown_object;
_Unwind_RaiseException(&Exception->unwindHeader);
__cxa_begin_catch(&Exception->unwindHeader);
error("Uncaught exception!");
CPU::Stop(); /* FIXME: Panic */
}
extern "C" void __cxa_rethrow()
{
fixme("__cxa_rethrow() called.");
}
extern "C" void __cxa_pure_virtual()
{
fixme("__cxa_pure_virtual() called.");
}
extern "C" void __cxa_throw_bad_array_new_length()
{
fixme("__cxa_throw_bad_array_new_length() called.");
}
extern "C" void __cxa_free_exception(void *thrown_exception)
{
fixme("__cxa_free_exception( %p ) called.",
thrown_exception);
}
__extension__ typedef int __guard __attribute__((mode(__DI__)));
extern "C" int __cxa_guard_acquire(__guard *g)
{
fixme("__cxa_guard_acquire( %p ) called.", g);
return !*(char *)(g);
}
extern "C" void __cxa_guard_release(__guard *g)
{
fixme("__cxa_guard_release( %p ) called.", g);
*(char *)g = 1;
}
extern "C" void __cxa_guard_abort(__guard *g)
{
fixme("__cxa_guard_abort( %p ) called.", g);
}
extern "C" __noreturn void __cxa_bad_typeid()
{
fixme("__cxa_bad_typeid() called.");
CPU::Stop(); /* FIXME: Crash the system */
}
}

View File

@ -0,0 +1,23 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <typeinfo>
namespace __cxxabiv1
{
__fundamental_type_info::~__fundamental_type_info() {}
}

View File

@ -0,0 +1,88 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <typeinfo>
namespace __cxxabiv1
{
__pbase_type_info::~__pbase_type_info() {}
bool __pbase_type_info::__do_catch(const type_info *ThrowType,
void **ThrowObject,
unsigned outer) const
{
#ifndef __GXX_RTTI
return false;
#else
if (*this == *ThrowType)
return true;
if (*ThrowType == typeid(nullptr))
{
if (typeid(*this) == typeid(__pointer_type_info))
{
*ThrowObject = nullptr;
return true;
}
else if (typeid(*this) == typeid(__pointer_to_member_type_info))
{
if (this->Pointee->__is_function_p())
{
using pmf_type = void (__pbase_type_info::*)();
static const pmf_type pmf = nullptr;
*ThrowObject = const_cast<pmf_type *>(&pmf);
return true;
}
else
{
using pm_type = int __pbase_type_info::*;
static const pm_type pm = nullptr;
*ThrowObject = const_cast<pm_type *>(&pm);
return true;
}
}
}
if (typeid(*this) != typeid(*ThrowType))
return false;
if (!(outer & 1))
return false;
const __pbase_type_info *ThrownType =
static_cast<const __pbase_type_info *>(ThrowType);
unsigned TypeFlags = ThrownType->Flags;
const unsigned FlagQualificationMask = __transaction_safe_mask | __noexcept_mask;
unsigned ThrowFlagQualification = (TypeFlags & FlagQualificationMask);
unsigned CatchFlagQualification = (Flags & FlagQualificationMask);
if (ThrowFlagQualification & ~CatchFlagQualification)
TypeFlags &= CatchFlagQualification;
if (CatchFlagQualification & ~ThrowFlagQualification)
return false;
if (TypeFlags & ~Flags)
return false;
if (!(Flags & __const_mask))
outer &= ~1;
return __pointer_catch(ThrownType, ThrowObject, outer);
#endif
}
}

View File

@ -0,0 +1,42 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <typeinfo>
namespace __cxxabiv1
{
__pointer_type_info::~__pointer_type_info() {}
bool __pointer_type_info::__is_pointer_p() const { return true; }
bool __pointer_type_info::__pointer_catch(const __pbase_type_info *ThrownType,
void **ThrowObject,
unsigned Outer) const
{
#ifndef __GXX_RTTI
return false;
#else
if (Outer < 2 && *this->Pointee == typeid(void))
return !ThrownType->Pointee->__is_function_p();
return __pbase_type_info::__pointer_catch(ThrownType,
ThrowObject,
Outer);
#endif
}
}

View File

@ -0,0 +1,102 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <typeinfo>
#include <debug.h>
namespace __cxxabiv1
{
template <typename T>
inline const T *adjust_pointer(const void *Base,
ptrdiff_t Offset)
{
return reinterpret_cast<const T *>(reinterpret_cast<const char *>(Base) + Offset);
}
__si_class_type_info::~__si_class_type_info() {}
__class_type_info::__sub_kind __si_class_type_info::
__do_find_public_src(ptrdiff_t SourceToDestination,
const void *ObjectPointer,
const __class_type_info *SourceType,
const void *SourcePointer) const
{
if (SourcePointer == ObjectPointer && *this == *SourceType)
return __contained_public;
return this->BaseType->__do_find_public_src(SourceToDestination,
ObjectPointer,
SourceType,
SourcePointer);
}
bool __si_class_type_info::__do_dyncast(ptrdiff_t SourceToDestination,
__sub_kind AccessPath,
const __class_type_info *DestinationType,
const void *ObjectPointer,
const __class_type_info *SourceType,
const void *SourcePointer,
__dyncast_result &__restrict Result) const
{
if (*this == *DestinationType)
{
Result.dst_ptr = ObjectPointer;
Result.whole2dst = AccessPath;
if (SourceToDestination == -2)
{
Result.dst2src = __not_contained;
return false;
}
if (SourceToDestination >= 0)
{
Result.dst2src = adjust_pointer<void>(ObjectPointer,
SourceToDestination) == SourcePointer
? __contained_public
: __not_contained;
}
return false;
}
if (ObjectPointer == SourcePointer &&
*this == *SourceType)
{
Result.whole2src = AccessPath;
return false;
}
return this->BaseType->__do_dyncast(SourceToDestination,
AccessPath,
DestinationType,
ObjectPointer,
SourceType,
SourcePointer,
Result);
}
bool __si_class_type_info::__do_upcast(const __class_type_info *Destination,
const void *ObjectPointer,
__upcast_result &__restrict Result) const
{
if (__class_type_info::__do_upcast(Destination, ObjectPointer, Result))
return true;
return this->BaseType->__do_upcast(Destination, ObjectPointer, Result);
}
}

View File

@ -0,0 +1,41 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <unwind.h>
#include <cxxabi.h>
#include <debug.h>
#include <cpu.hpp>
#include <smp.hpp>
#include "../../kernel.h"
using namespace __cxxabiv1;
#if (1) /* Stubs if libgcc is not present */
extern "C" _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *Exception)
{
fixme("_Unwind_RaiseException( %p ) called.", Exception);
error("Unhandled exception.");
return _URC_FATAL_PHASE1_ERROR;
// return _URC_NO_REASON;
}
extern "C" void _Unwind_Resume(struct _Unwind_Exception *Exception)
{
fixme("_Unwind_Resume( %p ) called.", Exception);
}
#endif

39
Library/std/typeinfo.cpp Normal file
View File

@ -0,0 +1,39 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#include <typeinfo>
#include <debug.h>
namespace std
{
type_info::~type_info() {}
bool type_info::__do_catch(const type_info *ThrowType,
void **ThrowObject,
unsigned Outer) const
{
stub;
return false;
}
bool type_info::__do_upcast(const __cxxabiv1::__class_type_info *Target,
void **ObjectPointer) const
{
stub;
return false;
}
}