forked from SerenityOS/serenity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kernel: Add per platform Processor.h headers
The platform independent Processor.h file includes the shared processor code and includes the specific platform header file. All references to the Arch/x86/Processor.h file have been replaced with a reference to Arch/Processor.h.
- Loading branch information
1 parent
23676be
commit 545ce5b
Showing
25 changed files
with
199 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2018-2021, James Mintram <[email protected]> | ||
* Copyright (c) 2018-2021, Andreas Kling <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/Function.h> | ||
#include <Kernel/Arch/x86/ASM_wrapper.h> | ||
|
||
namespace Kernel { | ||
|
||
namespace Memory { | ||
class PageDirectory; | ||
} | ||
|
||
struct ProcessorMessageEntry; | ||
struct DeferredCallEntry; | ||
|
||
enum class ProcessorSpecificDataID { | ||
MemoryManager, | ||
__Count, | ||
}; | ||
struct ProcessorMessage { | ||
using CallbackFunction = Function<void()>; | ||
|
||
enum Type { | ||
FlushTlb, | ||
Callback, | ||
}; | ||
Type type; | ||
Atomic<u32> refs; | ||
union { | ||
ProcessorMessage* next; // only valid while in the pool | ||
alignas(CallbackFunction) u8 callback_storage[sizeof(CallbackFunction)]; | ||
struct { | ||
Memory::PageDirectory const* page_directory; | ||
u8* ptr; | ||
size_t page_count; | ||
} flush_tlb; | ||
}; | ||
|
||
volatile bool async; | ||
|
||
ProcessorMessageEntry* per_proc_entries; | ||
|
||
CallbackFunction& callback_value() | ||
{ | ||
return *bit_cast<CallbackFunction*>(&callback_storage); | ||
} | ||
|
||
void invoke_callback() | ||
{ | ||
VERIFY(type == Type::Callback); | ||
callback_value()(); | ||
} | ||
}; | ||
|
||
struct ProcessorMessageEntry { | ||
ProcessorMessageEntry* next; | ||
ProcessorMessage* msg; | ||
}; | ||
|
||
struct DeferredCallEntry { | ||
using HandlerFunction = Function<void()>; | ||
|
||
DeferredCallEntry* next; | ||
alignas(HandlerFunction) u8 handler_storage[sizeof(HandlerFunction)]; | ||
bool was_allocated; | ||
|
||
HandlerFunction& handler_value() | ||
{ | ||
return *bit_cast<HandlerFunction*>(&handler_storage); | ||
} | ||
|
||
void invoke_handler() | ||
{ | ||
handler_value()(); | ||
} | ||
}; | ||
|
||
} | ||
|
||
#if ARCH(X86_64) || ARCH(I386) | ||
# include <Kernel/Arch/x86/Processor.h> | ||
#elif ARCH(AARCH64) | ||
# include <Kernel/Arch/aarch64/Processor.h> | ||
#else | ||
# error "Unknown architecture" | ||
#endif | ||
|
||
namespace Kernel { | ||
template<typename T> | ||
class ProcessorSpecific { | ||
public: | ||
static void initialize() | ||
{ | ||
Processor::current().set_specific(T::processor_specific_data_id(), new T); | ||
} | ||
static T& get() | ||
{ | ||
return *Processor::current().get_specific<T>(); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2018-2021, James Mintram <[email protected]> | ||
* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <AK/Array.h> | ||
#include <AK/Concepts.h> | ||
#include <AK/Function.h> | ||
#include <AK/Types.h> | ||
|
||
namespace Kernel { | ||
|
||
class Thread; | ||
|
||
//FIXME This needs to go behind some sort of platform abstraction | ||
// it is used between Thread and Processor. | ||
struct [[gnu::aligned(16)]] FPUState | ||
{ | ||
u8 buffer[512]; | ||
}; | ||
|
||
class Processor { | ||
public: | ||
void set_specific(ProcessorSpecificDataID /*specific_id*/, void* /*ptr*/) { } | ||
template<typename T> | ||
T* get_specific() { return 0; } | ||
|
||
ALWAYS_INLINE static void pause() { } | ||
ALWAYS_INLINE static void wait_check() { } | ||
|
||
ALWAYS_INLINE static bool is_initialized() | ||
{ | ||
return false; | ||
} | ||
|
||
ALWAYS_INLINE static u32 current_id() | ||
{ | ||
return 0; | ||
} | ||
|
||
ALWAYS_INLINE static Thread* current_thread() | ||
{ | ||
return 0; | ||
} | ||
|
||
ALWAYS_INLINE static FlatPtr current_in_irq() | ||
{ | ||
return 0; | ||
} | ||
|
||
ALWAYS_INLINE static void enter_critical() { } | ||
ALWAYS_INLINE static void leave_critical() { } | ||
ALWAYS_INLINE static u32 in_critical() | ||
{ | ||
return 0; | ||
} | ||
|
||
ALWAYS_INLINE static Processor& current() { return *((Processor*)0); } | ||
|
||
static void deferred_call_queue(Function<void()> /* callback */) { } | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.