summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authoramlal <amlal@el-mahrouss-logic.com>2024-03-25 09:12:58 +0100
committeramlal <amlal@el-mahrouss-logic.com>2024-03-25 09:12:58 +0100
commitf5e0bc85b06c84e0c6bc1da471630d02ff2ed7a3 (patch)
tree245708d11dbcd522319f924c3b3ebcc8af2ac033
parentab18ee1fd5fced5d6c75840f35455b609ed28223 (diff)
IMP: ke_io_read support.
Signed-off-by: amlal <amlal@el-mahrouss-logic.com>
-rw-r--r--Private/HALKit/AMD64/HalDebugOutput.cxx48
-rw-r--r--Private/HALKit/AMD64/HalInterruptAPI.asm2
-rw-r--r--Private/NewBoot/Source/makefile2
3 files changed, 23 insertions, 29 deletions
diff --git a/Private/HALKit/AMD64/HalDebugOutput.cxx b/Private/HALKit/AMD64/HalDebugOutput.cxx
index d2f4ed96..7eeae914 100644
--- a/Private/HALKit/AMD64/HalDebugOutput.cxx
+++ b/Private/HALKit/AMD64/HalDebugOutput.cxx
@@ -6,8 +6,8 @@
#include <ArchKit/ArchKit.hpp>
#include <KernelKit/DebugOutput.hpp>
-#include <NewKit/Utils.hpp>
#include <KernelKit/Framebuffer.hpp>
+#include <NewKit/Utils.hpp>
namespace HCore {
enum CommStatus {
@@ -22,13 +22,11 @@ constexpr short PORT = 0x3F8;
static int kState = kStateInvalid;
-/// @brief init COM1.
-/// @return
+/// @brief Init COM1.
+/// @return
bool serial_init() noexcept {
#ifdef __DEBUG__
- if (kState == kStateReady ||
- kState == kStateTransmit)
- 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)
@@ -51,13 +49,13 @@ bool serial_init() noexcept {
// If serial is not faulty set it in normal operation mode
// (not-loopback with IRQs enabled and OUT#1 and OUT#2 bits enabled)
HAL::Out8(Detail::PORT + 4, 0x0F);
-#endif // __DEBUG__
+#endif // __DEBUG__
return true;
}
} // namespace Detail
-EXTERN_C void ke_io_print(const char* bytes) {
+EXTERN_C void ke_io_write(const char* bytes) {
#ifdef __DEBUG__
Detail::serial_init();
@@ -75,7 +73,7 @@ EXTERN_C void ke_io_print(const char* bytes) {
}
Detail::kState = kStateReady;
-#endif // __DEBUG__
+#endif // __DEBUG__
}
EXTERN_C void ke_io_read(const char* bytes) {
@@ -88,39 +86,35 @@ EXTERN_C void ke_io_read(const char* bytes) {
SizeT index = 0;
- // send zero.
- HAL::Out8(Detail::PORT, 00);
+ while (true) {
+ auto in = HAL::In8(Detail::PORT);
- // get that zero.
- auto in = HAL::In8(Detail::PORT);
+ // if enter pressed -> break.
+ if (in == 0xD) {
+ break;
+ }
- while (in != '\n') {
- // if zero -> ignore.
- if (in == 0) {
- ++index;
- in = HAL::In8(Detail::PORT);
-
- continue;
+ if (in < '0' || in < 'A' || in < 'a') {
+ if (in != '@' || in != '!' || in != '?' || in != '.' || in != '/' ||
+ in != ':') {
+ continue;
+ }
}
((char*)bytes)[index] = in;
- if (in == 0)
- break;
-
++index;
- in = HAL::In8(Detail::PORT);
}
((char*)bytes)[index] = 0;
Detail::kState = kStateReady;
-#endif // __DEBUG__
+#endif // __DEBUG__
}
TerminalDevice TerminalDevice::Shared() noexcept {
- TerminalDevice out(HCore::ke_io_print, HCore::ke_io_read);
-
+ TerminalDevice out(HCore::ke_io_write, HCore::ke_io_read);
+
return out;
}
diff --git a/Private/HALKit/AMD64/HalInterruptAPI.asm b/Private/HALKit/AMD64/HalInterruptAPI.asm
index b62d2151..0abf463d 100644
--- a/Private/HALKit/AMD64/HalInterruptAPI.asm
+++ b/Private/HALKit/AMD64/HalInterruptAPI.asm
@@ -39,7 +39,7 @@ global kInterruptVectorTable
extern _hal_handle_mouse
extern idt_handle_gpf
extern idt_handle_pf
-extern ke_io_print
+extern ke_io_write
section .text
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index e4ed6cbe..0bded801 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -17,7 +17,7 @@ EMU=qemu-system-x86_64w.exe
endif
IMG=epm.img
-EMU_FLAGS=-net none -smp 2 -m 4G -M q35 -bios OVMF.fd -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -drive file=fat:rw:CDROM,index=2,format=raw -serial stdio
+EMU_FLAGS=-net none -smp 2 -m 4G -M q35 -bios OVMF.fd -device piix3-ide,id=ide -drive id=disk,file=$(IMG),format=raw,if=none -device ide-hd,drive=disk,bus=ide.0 -drive file=fat:rw:CDROM,index=2,format=raw -d int
LD_FLAGS=-e efi_main --subsystem=10
OBJ=$(wildcard *.o) $(wildcard ../../Objects/*.obj) $(wildcard HEL/AMD64/*.obj)