diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-10 13:26:40 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-10 13:26:40 +0100 |
| commit | 94d7585ae766d777f41d07b1a98051d12a6a0256 (patch) | |
| tree | be61851ffe4e0eeb0fe539db4e14ca94519021c9 | |
| parent | a22ddb45201f40e41902b4c189c31c6418742c8a (diff) | |
Kernel: See below.
- WiP on debug protocol.
| -rw-r--r-- | .vscode/settings.json | 5 | ||||
| -rw-r--r-- | Private/CompilerKit/CompilerKit.hpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalDebugOutput.cxx | 49 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalDebugPort.cxx | 23 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalKernelMain.cxx | 14 | ||||
| -rw-r--r-- | Private/KernelKit/DebugOutput.hpp | 35 | ||||
| -rw-r--r-- | Private/KernelKit/DeviceManager.hpp | 1 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 2 | ||||
| -rw-r--r-- | Private/makefile | 3 |
9 files changed, 96 insertions, 38 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..253de998 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "*.rsrc": "cpp" + } +}
\ No newline at end of file diff --git a/Private/CompilerKit/CompilerKit.hpp b/Private/CompilerKit/CompilerKit.hpp index 5fde300e..34f69ccc 100644 --- a/Private/CompilerKit/CompilerKit.hpp +++ b/Private/CompilerKit/CompilerKit.hpp @@ -30,4 +30,6 @@ +#include <CompilerKit/Version.hxx> + #endif /* ifndef _INC_CL_HPP */ diff --git a/Private/HALKit/AMD64/HalDebugOutput.cxx b/Private/HALKit/AMD64/HalDebugOutput.cxx index 24973eb7..d2f4ed96 100644 --- a/Private/HALKit/AMD64/HalDebugOutput.cxx +++ b/Private/HALKit/AMD64/HalDebugOutput.cxx @@ -11,9 +11,9 @@ namespace HCore { enum CommStatus { + kStateInvalid, kStateReady = 0xCF, kStateTransmit = 0xFC, - kStateInvalid, kStateCnt = 3 }; @@ -26,7 +26,9 @@ static int kState = kStateInvalid; /// @return bool serial_init() noexcept { #ifdef __DEBUG__ - if (kState == kStateReady) return true; + if (kState == kStateReady || + kState == kStateTransmit) + return true; HAL::Out8(PORT + 1, 0x00); // Disable all interrupts HAL::Out8(PORT + 3, 0x80); // Enable DLAB (set baud rate divisor) @@ -76,8 +78,49 @@ EXTERN_C void ke_io_print(const char* bytes) { #endif // __DEBUG__ } +EXTERN_C void ke_io_read(const char* bytes) { +#ifdef __DEBUG__ + Detail::serial_init(); + + if (!bytes || Detail::kState != kStateReady) return; + + Detail::kState = kStateTransmit; + + SizeT index = 0; + + // send zero. + HAL::Out8(Detail::PORT, 00); + + // get that zero. + auto in = HAL::In8(Detail::PORT); + + while (in != '\n') { + // if zero -> ignore. + if (in == 0) { + ++index; + in = HAL::In8(Detail::PORT); + + continue; + } + + ((char*)bytes)[index] = in; + + if (in == 0) + break; + + ++index; + in = HAL::In8(Detail::PORT); + } + + ((char*)bytes)[index] = 0; + + Detail::kState = kStateReady; +#endif // __DEBUG__ +} + TerminalDevice TerminalDevice::Shared() noexcept { - TerminalDevice out(HCore::ke_io_print, nullptr); + TerminalDevice out(HCore::ke_io_print, HCore::ke_io_read); + return out; } diff --git a/Private/HALKit/AMD64/HalDebugPort.cxx b/Private/HALKit/AMD64/HalDebugPort.cxx index 326bb8bc..b8127b1a 100644 --- a/Private/HALKit/AMD64/HalDebugPort.cxx +++ b/Private/HALKit/AMD64/HalDebugPort.cxx @@ -8,32 +8,11 @@ //! @brief UART debug via packets. #include <ArchKit/ArchKit.hpp> - -#define kDebugMaxPorts 16 - -#define kDebugUnboundPort 0xFFFF - -#define kDebugMag0 'X' -#define kDebugMag1 'D' -#define kDebugMag2 'B' -#define kDebugMag3 'G' - -#define kDebugSourceFile 0 -#define kDebugLine 33 -#define kDebugTeam 43 -#define kDebugEOP 49 +#include <KernelKit/DebugOutput.hpp> // after that we have start of additional data. namespace HCore { -typedef Char rt_debug_type[255]; - -class DebuggerPorts final { - public: - Int16 fPort[kDebugMaxPorts]; - Int16 fBoundCnt; -}; - void rt_debug_listen(DebuggerPorts* theHook) noexcept { if (theHook == nullptr) return; diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx index 535a4fc9..6716a989 100644 --- a/Private/HALKit/AMD64/HalKernelMain.cxx +++ b/Private/HALKit/AMD64/HalKernelMain.cxx @@ -75,21 +75,17 @@ EXTERN_C void RuntimeMain( /// END POST - /// Mounts a NewFS block. - HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager()); - /// We already have an install of HCore. if (HandoverHeader->f_Bootloader == kInstalledMedia) { + /// Mounts a NewFS block. + HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager()); + /// TODO: Parse system configuration. } else { HCore::kcout << "HCoreKrnl: Running setup...\r\n"; - // Open file from first hard-drive. - HCore::PEFLoader img("/System/HCoreInstallWizard.exe"); - - MUST_PASS(img.IsLoaded()); - /// Run the server executive. - HCore::Utils::execute_from_image(img); + //HCore::Forms::SetupWizardControl wizard; + //wizard.ShowDialog(); } HCore::ke_stop(RUNTIME_CHECK_BOOTSTRAP); diff --git a/Private/KernelKit/DebugOutput.hpp b/Private/KernelKit/DebugOutput.hpp index b9930cb2..683c0903 100644 --- a/Private/KernelKit/DebugOutput.hpp +++ b/Private/KernelKit/DebugOutput.hpp @@ -7,10 +7,23 @@ #pragma once #include <KernelKit/DeviceManager.hpp> +#include <CompilerKit/CompilerKit.hpp> #include <NewKit/OwnPtr.hpp> #include <NewKit/Stream.hpp> -#include "CompilerKit/CompilerKit.hpp" +#define kDebugMaxPorts 16 + +#define kDebugUnboundPort 0x0FEED + +#define kDebugMag0 'H' +#define kDebugMag1 'D' +#define kDebugMag2 'B' +#define kDebugMag3 'G' + +#define kDebugSourceFile 0 +#define kDebugLine 33 +#define kDebugTeam 43 +#define kDebugEOP 49 namespace HCore { // @brief Emulates a VT100 terminal. @@ -35,6 +48,26 @@ inline TerminalDevice end_line() { selfTerm << "\n"; return selfTerm; } + +inline TerminalDevice carriage_return() { + TerminalDevice selfTerm = TerminalDevice::Shared(); + selfTerm << "\r"; + return selfTerm; +} + +inline TerminalDevice get_buffer(Char* buf) { + TerminalDevice selfTerm = TerminalDevice::Shared(); + selfTerm >> buf; + return selfTerm; +} + +typedef Char rt_debug_type[255]; + +class DebuggerPorts final { + public: + Int16 fPort[kDebugMaxPorts]; + Int16 fBoundCnt; +}; } // namespace HCore #ifdef kcout diff --git a/Private/KernelKit/DeviceManager.hpp b/Private/KernelKit/DeviceManager.hpp index 9efd51a1..9f014c1a 100644 --- a/Private/KernelKit/DeviceManager.hpp +++ b/Private/KernelKit/DeviceManager.hpp @@ -103,6 +103,7 @@ enum { kDeviceTypeSCSI, kDeviceTypeSHCI, kDeviceTypeUSB, + kDeviceTypeMedia, kDeviceTypeCount, }; } // namespace HCore diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 057a5d44..511a4894 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -35,7 +35,7 @@ bootloader-amd64: .PHONY: run-efi-amd64 run-efi-amd64: - $(EMU) -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -d int + $(EMU) -net none -smp 2 -m 4G -M q35 -bios OVMF.fd -drive file=fat:rw:CDROM,index=1,format=raw -serial stdio .PHONY: download-edk download-edk: diff --git a/Private/makefile b/Private/makefile index 5267bc9c..fbbad166 100644 --- a/Private/makefile +++ b/Private/makefile @@ -35,7 +35,7 @@ MOVEALL=./MoveAll.sh .PHONY: h-core-amd64 h-core-amd64: - $(CC) $(CCFLAGS) Source/*.cxx HALKit/AMD64/PCI/*.cxx Source/Network/*.cxx\ + $(CC) $(CCFLAGS) $(DEBUG) Source/*.cxx HALKit/AMD64/PCI/*.cxx Source/Network/*.cxx\ Source/Storage/*.cxx HALKit/AMD64/*.cxx HALKit/AMD64/*.cpp HALKit/AMD64/*.s $(ASM) $(ASMFLAGS) HALKit/AMD64/HalInterruptRouting.asm $(ASM) $(ASMFLAGS) HALKit/AMD64/HalSMPCoreManager.asm @@ -48,7 +48,6 @@ OBJCOPY=x86_64-w64-mingw32-objcopy .PHONY: link-amd64 link-amd64: $(LD) $(LDFLAGS) $(LDOBJ) -o $(KERNEL) - cp $(KERNEL) Root/System .PHONY: all all: h-core-amd64 link-amd64 |
