diff options
| author | Alexey Gavrilov <rebovas@yahoo.com> | 2024-03-27 19:49:10 +0700 |
|---|---|---|
| committer | Alexey Gavrilov <rebovas@yahoo.com> | 2024-03-27 19:49:10 +0700 |
| commit | e51dea0b6e34c2959b3b0f4a5db6b11d4b619960 (patch) | |
| tree | e6a457ec4b2758c0c3bef78df475ad52d92a7ab4 | |
| parent | e0bac2387b373316337b177fe8aa9851b0d5e870 (diff) | |
Some updates: rename memAddr, define architecture
| -rw-r--r-- | arch/SecondaryInit.h | 4 | ||||
| -rw-r--r-- | arch/x86/PrimaryInit.h | 2 | ||||
| -rw-r--r-- | drivers/acpi/Acpi.cpp | 16 | ||||
| -rw-r--r-- | drivers/acpi/Acpi.h | 8 | ||||
| -rw-r--r-- | include/StringOperations.cpp | 6 | ||||
| -rw-r--r-- | include/StringOperations.h | 10 | ||||
| -rw-r--r-- | include/arch | 6 | ||||
| -rw-r--r-- | include/types.h | 17 | ||||
| -rw-r--r-- | kernel/kernel.c | 6 |
9 files changed, 49 insertions, 26 deletions
diff --git a/arch/SecondaryInit.h b/arch/SecondaryInit.h index f9aa5be..f11c7be 100644 --- a/arch/SecondaryInit.h +++ b/arch/SecondaryInit.h @@ -1,4 +1,8 @@ +#include <arch> + +#if defined(__IAPC) #include "x86/PrimaryInit.h" +#endif class SecondaryInitialization : protected PrimaryInitialization { diff --git a/arch/x86/PrimaryInit.h b/arch/x86/PrimaryInit.h index 8d16549..243c731 100644 --- a/arch/x86/PrimaryInit.h +++ b/arch/x86/PrimaryInit.h @@ -2,8 +2,6 @@ #include "io/VGADisplay.h" -#define x86_ARCH - class PrimaryInitialization { protected: diff --git a/drivers/acpi/Acpi.cpp b/drivers/acpi/Acpi.cpp index 207c9bb..6551c6a 100644 --- a/drivers/acpi/Acpi.cpp +++ b/drivers/acpi/Acpi.cpp @@ -3,10 +3,10 @@ const char *Rsdp::signatureString = "RSD PTR "; const uint8 Rsdp::validFieldRevision = 2; -const memAddr Rsdp::romAreaStart = 0xe0000; -const memAddr Rsdp::romAreaEnd = 0xfffff; -const memAddr Rsdp::ebdaAreaStart = 0x80000; -const memAddr Rsdp::ebdaAreaEnd = 0x803ff; +const uintptr Rsdp::romAreaStart = 0xe0000; +const uintptr Rsdp::romAreaEnd = 0xfffff; +const uintptr Rsdp::ebdaAreaStart = 0x80000; +const uintptr Rsdp::ebdaAreaEnd = 0x803ff; const uint8 Rsdp::checksunFieldSize = 20; const uint8 Entry::size = 4; const uint8 sizeWithoutIcs = 44; @@ -45,7 +45,7 @@ uint8 Rsdp::checksumCheck() const uint8 check = 0; for(uint32 offset = 0; offset < checksunFieldSize; offset++) { - check += *(uint8 *)((memAddr)this + offset); + check += *(uint8 *)((uintptr)this + offset); } return check; }; @@ -55,13 +55,15 @@ uint8 DescHeader::checksumCheck() const uint8 check = 0; for(uint32 offset = 0; offset < length; offset++) { - check += *(uint8 *)((memAddr)this + offset); + check += *(uint8 *)((uintptr)this + offset); } return check; }; const Ics *Madt::getIcs(uint8 index) const { + if(header.checksumCheck()) return nullptr; + uint32 icsBytesRemain = header.getLength() - ::sizeWithoutIcs; uint16 indexAmass = 0; const Ics *icsPtr = (Ics *)(&icsBegin); @@ -73,7 +75,7 @@ const Ics *Madt::getIcs(uint8 index) const { icsBytesRemain -= icsPtr->getLength(); indexAmass++; - icsPtr = (Ics *)((memAddr)icsPtr + icsPtr->getLength()); + icsPtr = (Ics *)((uintptr)icsPtr + icsPtr->getLength()); } } diff --git a/drivers/acpi/Acpi.h b/drivers/acpi/Acpi.h index 6a5c806..506ab99 100644 --- a/drivers/acpi/Acpi.h +++ b/drivers/acpi/Acpi.h @@ -154,10 +154,10 @@ class Rsdp const static uint8 validFieldRevision; // RSDP memory address areas in IA-PC systems const static char *signatureString; - const static memAddr romAreaStart; - const static memAddr romAreaEnd; - const static memAddr ebdaAreaStart; - const static memAddr ebdaAreaEnd; + const static uintptr romAreaStart; + const static uintptr romAreaEnd; + const static uintptr ebdaAreaStart; + const static uintptr ebdaAreaEnd; private: const static uint8 checksunFieldSize; const char signature[8]; diff --git a/include/StringOperations.cpp b/include/StringOperations.cpp index 01e7a76..055892e 100644 --- a/include/StringOperations.cpp +++ b/include/StringOperations.cpp @@ -6,7 +6,7 @@ MemArea::MemArea() start = final = NULL; }; -MemArea::MemArea(const memAddr start, const memAddr final) +MemArea::MemArea(const uintptr start, const uintptr final) { this->start = start; this->final = final; @@ -17,12 +17,12 @@ MemArea::MemArea(const memAddr start, const memAddr final) } }; -memAddr MemArea::begin() +uintptr MemArea::begin() { return start; } -memAddr MemArea::end() +uintptr MemArea::end() { if(start == final) return start; else return final + 1; diff --git a/include/StringOperations.h b/include/StringOperations.h index 81d7144..5d2826c 100644 --- a/include/StringOperations.h +++ b/include/StringOperations.h @@ -7,15 +7,15 @@ class MemArea { private: - memAddr start, final; + uintptr start, final; public: MemArea(); - MemArea(const memAddr start, const memAddr final); - memAddr begin(); - memAddr end(); + MemArea(const uintptr start, const uintptr final); + uintptr begin(); + uintptr end(); bool valid(); - typedef memAddr iterator; + typedef uintptr iterator; }; class StringOperations diff --git a/include/arch b/include/arch new file mode 100644 index 0000000..f5fc8f7 --- /dev/null +++ b/include/arch @@ -0,0 +1,6 @@ +#ifndef ARCH_H +#define ARCH_H + +#define __IAPC + +#endif diff --git a/include/types.h b/include/types.h index e578adb..f7c0eb6 100644 --- a/include/types.h +++ b/include/types.h @@ -1,13 +1,24 @@ -#define NULL 0 +#ifndef TYPES_H +#define TYPES_H + +#include <arch> +#define NULL 0 + +#if defined(__IAPC) typedef unsigned char uint8; typedef unsigned short int uint16; typedef unsigned long uint32; typedef unsigned long long uint64; #if defined(__x86_64) - typedef uint64 memAddr; + typedef uint64 uintptr; #else - typedef uint32 memAddr; + typedef uint32 uintptr; +#endif +#else + #error IA-PC only support +#endif + #endif diff --git a/kernel/kernel.c b/kernel/kernel.c index 1fb167f..36fb0fd 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -2,7 +2,6 @@ #include "../drivers/acpi/Acpi.h" #include <StringOperations.h> - void empty() {}; void main() @@ -27,6 +26,9 @@ void main() madt->getIcs(4), madt->getIcs(5), madt->getIcs(6), - madt->getIcs(7)}; + madt->getIcs(7), + madt->getIcs(8)}; + const IoapicStruct *ioapicStruct = (IoapicStruct *)icsEntry[1]; + out::display << '\n'; empty(); }; |
