summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/boot/amd64-desktop.make4
-rw-r--r--src/boot/src/HEL/AMD64/BootEFI.cpp2
-rw-r--r--src/boot/src/HEL/ARM64/BootEFI.cpp2
-rw-r--r--src/kernel/FirmwareKit/Handover.h5
-rw-r--r--src/kernel/HALKit/AMD64/HalKernelMain.cpp8
-rw-r--r--src/kernel/KernelKit/Semaphore.h8
-rw-r--r--src/kernel/src/HeapMgr.cpp11
-rw-r--r--src/libDDK/src/KernelAllocator.cpp4
8 files changed, 24 insertions, 20 deletions
diff --git a/src/boot/amd64-desktop.make b/src/boot/amd64-desktop.make
index 0854db60..9379dc60 100644
--- a/src/boot/amd64-desktop.make
+++ b/src/boot/amd64-desktop.make
@@ -49,12 +49,12 @@ DEBUG_MACRO = -D__DEBUG__
endif
ifeq ($(KVM_SUPPORT),)
-EMU_FLAGS=-M q35 -smp 4 -m 8G \
+EMU_FLAGS=-M q35 -smp 8 -m 8G \
-bios $(BIOS) -cdrom $(BOOT) -boot d
endif
ifneq ($(KVM_SUPPORT),)
-EMU_FLAGS=-M q35 -smp 4 -m 8G \
+EMU_FLAGS=-M q35 -smp 8 -m 8G \
-bios $(BIOS) -M q35 -cdrom $(BOOT) -boot d -accel kvm
endif
diff --git a/src/boot/src/HEL/AMD64/BootEFI.cpp b/src/boot/src/HEL/AMD64/BootEFI.cpp
index 4d004e54..70f440b3 100644
--- a/src/boot/src/HEL/AMD64/BootEFI.cpp
+++ b/src/boot/src/HEL/AMD64/BootEFI.cpp
@@ -120,8 +120,10 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
if (mp) {
mp->GetNumberOfProcessors(mp, &cnt_disabled, &cnt_enabled);
+ kHandoverHeader->f_NumberOfProcessors = cnt_enabled;
handover_hdr->f_HardwareTables.f_MultiProcessingEnabled = cnt_enabled > 1;
} else {
+ handover_hdr->f_NumberOfProcessors = 1;
handover_hdr->f_HardwareTables.f_MultiProcessingEnabled = NO;
}
diff --git a/src/boot/src/HEL/ARM64/BootEFI.cpp b/src/boot/src/HEL/ARM64/BootEFI.cpp
index 936f5dfb..a92b9a62 100644
--- a/src/boot/src/HEL/ARM64/BootEFI.cpp
+++ b/src/boot/src/HEL/ARM64/BootEFI.cpp
@@ -94,8 +94,10 @@ EFI_EXTERN_C EFI_API Int32 BootloaderMain(EfiHandlePtr image_handle, EfiSystemTa
if (mp) {
mp->GetNumberOfProcessors(mp, &cnt_disabled, &cnt_enabled);
+ kHandoverHeader->f_NumberOfProcessors = cnt_enabled;
kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled = cnt_enabled > 1;
} else {
+ kHandoverHeader->f_NumberOfProcessors = 1;
kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled = NO;
}
diff --git a/src/kernel/FirmwareKit/Handover.h b/src/kernel/FirmwareKit/Handover.h
index 8515cfa6..f3382f75 100644
--- a/src/kernel/FirmwareKit/Handover.h
+++ b/src/kernel/FirmwareKit/Handover.h
@@ -10,7 +10,7 @@
#include <NeKit/Config.h>
#define kHandoverMagic (0xBADCC)
-#define kHandoverVersion (0x0117)
+#define kHandoverVersion (0x0118)
/* Initial bitmap pointer location and size. */
#define kHandoverStructSz sizeof(HEL::BootInfoHeader)
@@ -79,7 +79,8 @@ struct BootInfoHeader final {
UInt32 f_PixelPerLine;
} f_GOP;
- UInt64 f_FirmwareSpecific[8];
+ UInt64 f_NumberOfProcessors;
+ UInt64 f_FirmwareSpecific[7];
};
enum {
diff --git a/src/kernel/HALKit/AMD64/HalKernelMain.cpp b/src/kernel/HALKit/AMD64/HalKernelMain.cpp
index 4c527572..97102865 100644
--- a/src/kernel/HALKit/AMD64/HalKernelMain.cpp
+++ b/src/kernel/HALKit/AMD64/HalKernelMain.cpp
@@ -157,9 +157,11 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) {
NeFileSystemMgr::Mount(new NeFileSystemMgr());
#endif
- cg_init();
- FBDrawBitMapInRegion(kBootLogo, BOOT_LOGO_WIDTH, BOOT_LOGO_HEIGHT, 10, 10);
- cg_clear();
+ for (SizeT idxCore{0}; idxCore < kHandoverHeader->f_NumberOfProcessors; ++idxCore) {
+ cg_init();
+ FBDrawBitMapInRegion(kBootLogo, BOOT_LOGO_WIDTH, BOOT_LOGO_HEIGHT, 10, 12 + BOOT_LOGO_WIDTH * idxCore);
+ cg_clear();
+ }
UserProcessScheduler::The().SwitchTeam(kRTUserTeam);
diff --git a/src/kernel/KernelKit/Semaphore.h b/src/kernel/KernelKit/Semaphore.h
index 4dc9a454..13f3eadb 100644
--- a/src/kernel/KernelKit/Semaphore.h
+++ b/src/kernel/KernelKit/Semaphore.h
@@ -29,7 +29,7 @@ using SemaphoreArr = UInt64[kSemaphoreCount];
/// @brief Checks if the semaphore is valid.
inline bool rtl_sem_is_valid(const SemaphoreArr& sem, const UInt64& owner = 0) {
- if (!sem) return false;
+ //if (!sem) return false;
return sem[kSemaphoreOwnerIndex] == owner && sem[kSemaphoreCountIndex] > 0;
}
@@ -37,7 +37,7 @@ inline bool rtl_sem_is_valid(const SemaphoreArr& sem, const UInt64& owner = 0) {
/// @param sem
/// @return
inline bool rtl_sem_release(SemaphoreArr& sem) {
- if (!sem) return false;
+ //if (!sem) return false;
sem[kSemaphoreOwnerIndex] = 0;
sem[kSemaphoreCountIndex] = 0;
@@ -50,7 +50,7 @@ inline bool rtl_sem_release(SemaphoreArr& sem) {
/// @param owner the owner to set, could be anything identifitable.
/// @return
inline bool rtl_sem_acquire(SemaphoreArr& sem, const UInt64& owner) {
- if (!sem) return false;
+ //if (!sem) return false;
if (!owner) {
err_global_get() = kErrorInvalidData;
@@ -70,7 +70,7 @@ inline bool rtl_sem_acquire(SemaphoreArr& sem, const UInt64& owner) {
/// @return
inline bool rtl_sem_wait(SemaphoreArr& sem, const UInt64& owner, const UInt64& timeout,
bool& condition) {
- if (!sem) return false;
+ //if (!sem) return false;
if (!rtl_sem_is_valid(sem, owner)) {
return false;
diff --git a/src/kernel/src/HeapMgr.cpp b/src/kernel/src/HeapMgr.cpp
index a7430824..eea230e1 100644
--- a/src/kernel/src/HeapMgr.cpp
+++ b/src/kernel/src/HeapMgr.cpp
@@ -28,6 +28,8 @@
#define kHeapMgrMagic (0xD4D75)
#define kHeapMgrAlignSz (4U)
+#define kHeapMgrSpinMax (255'000)
+
namespace Kernel {
/// @brief Implementation details.
@@ -63,8 +65,8 @@ namespace Detail {
};
/// @brief Check for heap address validity.
- /// @param heap_ptr The address_ptr to check.
/// @return Bool if the pointer is valid or not.
+ /// @param heap_ptr The address_ptr to check.
_Output auto mm_check_ptr_address(VoidPtr heap_ptr) -> Bool {
if (!heap_ptr) return false;
@@ -85,7 +87,7 @@ STATIC PageMgr kPageMgr;
/// @return The newly allocated pointer.
_Output VoidPtr mm_alloc_ptr(SizeT sz, Bool wr, Bool user, SizeT pad_amount) {
static Bool locked = false;
- LockDelegate<255> lock{&locked};
+ LockDelegate<kHeapMgrSpinMax> lock{&locked};
auto sz_fix = sz;
@@ -101,11 +103,6 @@ _Output VoidPtr mm_alloc_ptr(SizeT sz, Bool wr, Bool user, SizeT pad_amount) {
reinterpret_cast<Detail::MM_INFORMATION_BLOCK_PTR>(wrapper.VirtualAddress() +
sizeof(Detail::MM_INFORMATION_BLOCK));
- if (!heap_info_ptr) {
- locked = false;
- return nullptr;
- }
-
heap_info_ptr->fSize = sz_fix;
heap_info_ptr->fMagic = kHeapMgrMagic;
heap_info_ptr->fCRC32 = 0U; // dont fill it for now.
diff --git a/src/libDDK/src/KernelAllocator.cpp b/src/libDDK/src/KernelAllocator.cpp
index f2dd7b45..e81161a5 100644
--- a/src/libDDK/src/KernelAllocator.cpp
+++ b/src/libDDK/src/KernelAllocator.cpp
@@ -14,7 +14,7 @@
DDK_EXTERN void* kalloc(size_t sz) {
if (!sz) ++sz;
- void* ptr = ::ke_call_dispatch("mm_alloc_ptr", 1, &sz, sizeof(size_t));
+ void* ptr = ::ke_call_dispatch("mm_alloc_ptr", 1, &sz, sizeof(sz));
return ptr;
}
@@ -26,5 +26,5 @@ DDK_EXTERN void* kalloc(size_t sz) {
DDK_EXTERN void kfree(void* ptr) {
if (!ptr) return;
- ::ke_call_dispatch("mm_free_ptr", 1, ptr, 0);
+ ::ke_call_dispatch("mm_free_ptr", 1, ptr, sizeof(ptr));
}