summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/AMD64
diff options
context:
space:
mode:
Diffstat (limited to 'dev/kernel/HALKit/AMD64')
-rw-r--r--dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc3
-rw-r--r--dev/kernel/HALKit/AMD64/HalDebugOutput.cc46
-rw-r--r--dev/kernel/HALKit/AMD64/HalKernelMain.cc3
-rw-r--r--dev/kernel/HALKit/AMD64/Paging.h4
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc6
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc10
-rw-r--r--dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc4
7 files changed, 54 insertions, 22 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
index 641fb8e4..84c35615 100644
--- a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
+++ b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc
@@ -128,7 +128,8 @@ EXTERN_C Kernel::Void idt_handle_breakpoint(Kernel::UIntPtr rip) {
if (process.Leak().Status != Kernel::ProcessStatusKind::kRunning) {
Kernel::kout << "Kernel: SIGTRAP\r";
- while (YES);
+ while (YES)
+ ;
}
kIsScheduling = NO;
diff --git a/dev/kernel/HALKit/AMD64/HalDebugOutput.cc b/dev/kernel/HALKit/AMD64/HalDebugOutput.cc
index bd8fe734..5d14f214 100644
--- a/dev/kernel/HALKit/AMD64/HalDebugOutput.cc
+++ b/dev/kernel/HALKit/AMD64/HalDebugOutput.cc
@@ -57,6 +57,8 @@ namespace Detail {
TerminalDevice::~TerminalDevice() = default;
+STATIC SizeT kX = kFontSizeX, kY = kFontSizeY;
+
EXTERN_C void ke_utf_io_write(IDeviceObject<const Utf8Char*>* obj, const Utf8Char* bytes) {
NE_UNUSED(bytes);
NE_UNUSED(obj);
@@ -76,11 +78,36 @@ EXTERN_C void ke_utf_io_write(IDeviceObject<const Utf8Char*>* obj, const Utf8Cha
index = 0;
len = urt_string_len(bytes);
+ Char tmp_str[2];
+
while (index < len) {
if (bytes[index] == '\r') HAL::rt_out8(Detail::kPort, '\r');
HAL::rt_out8(Detail::kPort, bytes[index] == '\r' ? '\n' : bytes[index]);
+ tmp_str[0] = (bytes[index] > 127) ? '?' : bytes[index];
+ tmp_str[1] = 0;
+
+ fb_render_string(tmp_str, kY, kX, RGB(0xff, 0xff, 0xff));
+
+ if (bytes[index] == '\r') {
+ kY += kFontSizeY;
+ kX = kFontSizeX;
+ }
+
+ kX += kFontSizeX;
+
+ if (kX > kHandoverHeader->f_GOP.f_Width) {
+ kX = kFontSizeX;
+ }
+
+ if (kY > kHandoverHeader->f_GOP.f_Height) {
+ kY = kFontSizeY;
+
+ FBDrawInRegion(fb_get_clear_clr(), FB::FBAccessibilty::Height(), FB::FBAccessibilty::Width(),
+ 0, 0);
+ }
+
++index;
}
@@ -107,32 +134,31 @@ EXTERN_C void ke_io_write(IDeviceObject<const Char*>* obj, const Char* bytes) {
index = 0;
len = rt_string_len(bytes);
- STATIC SizeT x = kFontSizeX, y = kFontSizeY;
+ Char tmp_str[2];
while (index < len) {
if (bytes[index] == '\r') HAL::rt_out8(Detail::kPort, '\r');
HAL::rt_out8(Detail::kPort, bytes[index] == '\r' ? '\n' : bytes[index]);
- char tmp_str[2];
tmp_str[0] = bytes[index];
tmp_str[1] = 0;
- fb_render_string(tmp_str, y, x, RGB(0xff, 0xff, 0xff));
+ fb_render_string(tmp_str, kY, kX, RGB(0xff, 0xff, 0xff));
if (bytes[index] == '\r') {
- y += kFontSizeY;
- x = kFontSizeX;
+ kY += kFontSizeY;
+ kX = kFontSizeX;
}
- x += kFontSizeX;
+ kX += kFontSizeX;
- if (x > kHandoverHeader->f_GOP.f_Width) {
- x = kFontSizeX;
+ if (kX > kHandoverHeader->f_GOP.f_Width) {
+ kX = kFontSizeX;
}
- if (y > kHandoverHeader->f_GOP.f_Height) {
- y = kFontSizeY;
+ if (kY > kHandoverHeader->f_GOP.f_Height) {
+ kY = kFontSizeY;
FBDrawInRegion(fb_get_clear_clr(), FB::FBAccessibilty::Height(), FB::FBAccessibilty::Width(),
0, 0);
diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
index f41979bb..2747439a 100644
--- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc
+++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc
@@ -146,7 +146,8 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept {
kTeams[team_index].Id() = team_index;
- while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index]));
+ while (!UserProcessScheduler::The().SwitchTeam(kTeams[team_index]))
+ ;
timer.Wait();
diff --git a/dev/kernel/HALKit/AMD64/Paging.h b/dev/kernel/HALKit/AMD64/Paging.h
index 3c7107bc..cfba232c 100644
--- a/dev/kernel/HALKit/AMD64/Paging.h
+++ b/dev/kernel/HALKit/AMD64/Paging.h
@@ -55,9 +55,7 @@ namespace Detail {
PageEnable = 31,
};
- inline UInt8 control_register_cast(ControlRegisterBits reg) {
- return static_cast<UInt8>(reg);
- }
+ inline UInt8 control_register_cast(ControlRegisterBits reg) { return static_cast<UInt8>(reg); }
} // namespace Detail
auto mm_alloc_bitmap(Boolean wr, Boolean user, SizeT size, Bool is_page, SizeT pad = 0) -> VoidPtr;
diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
index 42242dbe..a3079e0c 100644
--- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc
@@ -265,6 +265,9 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
if (timeout > kTimeout) {
kout << "Disk hangup!\r";
kSATAHba->Ports[kSATAIndex].Ci = 0;
+ err_global_get() = kErrorDiskIsCorrupted;
+ rtl_dma_free(size_buffer);
+
return;
}
@@ -293,7 +296,8 @@ STATIC Void drv_std_input_output_ahci(UInt64 lba, UInt8* buffer, SizeT sector_sz
goto ahci_io_end;
} else {
kout << "Warning: Disk still busy after command completion!\r";
- while (kSATAHba->Ports[kSATAIndex].Tfd & (kSATASRBsy | kSATASRDrq));
+ while (kSATAHba->Ports[kSATAIndex].Tfd & (kSATASRBsy | kSATASRDrq))
+ ;
}
ahci_io_end:
diff --git a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc
index 4688203f..39efb7d3 100644
--- a/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/DMA+Generic.cc
@@ -105,7 +105,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz - 1) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
@@ -123,7 +123,8 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz
rt_out8(kATADevice.Bar(0x20) + 0x00, 0x09); // Start DMA engine
- while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01);
+ while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01)
+ ;
rt_out8(kATADevice.Bar(0x20) + 0x00, 0x00); // Stop DMA engine
@@ -146,7 +147,7 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz - 1)) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
@@ -162,7 +163,8 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS
rt_out8(IO + 0x00, 0x09); // Start DMA engine
- while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01);
+ while (rt_in8(kATADevice.Bar(0x20) + ATA_REG_STATUS) & 0x01)
+ ;
rt_out8(kATADevice.Bar(0x20) + 0x00, 0x00); // Stop DMA engine
diff --git a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc
index b22330e4..aec21ee4 100644
--- a/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc
+++ b/dev/kernel/HALKit/AMD64/Storage/PIO+Generic.cc
@@ -118,7 +118,7 @@ Void drv_pio_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT Sect
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);
@@ -143,7 +143,7 @@ Void drv_pio_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT Sec
rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz));
- rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF);
+ rt_out8(IO + ATA_REG_LBA0, (Lba) &0xFF);
rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8);
rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16);
rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24);