Replace more usage of stdint.h types with Luna's Types.h

This commit is contained in:
apio 2022-11-19 22:25:03 +01:00
parent 83bcac7a16
commit 847f2b4f4c
3 changed files with 13 additions and 16 deletions

View File

@ -199,8 +199,8 @@ static IDTEntry idt[256];
struct IDTR struct IDTR
{ {
uint16_t limit; u16 limit;
uint64_t offset; u64 offset;
} __attribute__((packed)); } __attribute__((packed));
static void idt_add_handler(short num, void* handler, u8 type_attr) static void idt_add_handler(short num, void* handler, u8 type_attr)

View File

@ -8,9 +8,9 @@ const usize ARCH_TIMER_FREQ = 10;
void Timer::arch_init() void Timer::arch_init()
{ {
constexpr u16 divisor = (uint16_t)(base_frequency / (ARCH_TIMER_FREQ * 1000)); constexpr u16 divisor = (u16)(base_frequency / (ARCH_TIMER_FREQ * 1000));
static_assert(divisor >= 100); static_assert(divisor >= 100);
IO::outb(PIT_CHANNEL_0, (uint8_t)(divisor & 0xFF)); IO::outb(PIT_CHANNEL_0, (u8)(divisor & 0xFF));
IO::outb(0x80, 0); // short delay IO::outb(0x80, 0); // short delay
IO::outb(PIT_CHANNEL_0, (uint8_t)((divisor & 0xFF00) >> 8)); IO::outb(PIT_CHANNEL_0, (u8)((divisor & 0xFF00) >> 8));
} }

View File

@ -33,10 +33,10 @@ static bool page_bitmap_read(u64 index)
static void page_bitmap_set(u64 index, bool value) static void page_bitmap_set(u64 index, bool value)
{ {
uint64_t byteIndex = index / 8; u64 byte_index = index / 8;
uint8_t bitIndexer = 0b10000000 >> (index % 8); u8 mask = 0b10000000 >> (index % 8);
page_virtual_bitmap_addr[byteIndex] &= (uint8_t)(~bitIndexer); page_virtual_bitmap_addr[byte_index] &= (u8)(~mask);
if (value) { page_virtual_bitmap_addr[byteIndex] |= bitIndexer; } if (value) { page_virtual_bitmap_addr[byte_index] |= mask; }
} }
namespace MemoryManager namespace MemoryManager
@ -61,7 +61,7 @@ namespace MemoryManager
// walk the memory map // walk the memory map
MMapEnt* ptr = &bootboot.mmap; MMapEnt* ptr = &bootboot.mmap;
uint64_t mmap_entries = (bootboot.size - 128) / 16; u64 mmap_entries = (bootboot.size - 128) / 16;
for (u64 i = 0; i < mmap_entries; i++) for (u64 i = 0; i < mmap_entries; i++)
{ {
u64 size = MMapEnt_Size(ptr); u64 size = MMapEnt_Size(ptr);
@ -92,17 +92,14 @@ namespace MemoryManager
memset(page_bitmap_addr, 0xFF, page_bitmap_size); memset(page_bitmap_addr, 0xFF, page_bitmap_size);
ptr = &bootboot.mmap; ptr = &bootboot.mmap;
for (uint64_t i = 0; i < mmap_entries; i++) for (u64 i = 0; i < mmap_entries; i++)
{ {
uint64_t index = MMapEnt_Ptr(ptr) / ARCH_PAGE_SIZE; u64 index = MMapEnt_Ptr(ptr) / ARCH_PAGE_SIZE;
if (!MMapEnt_IsFree(ptr)) { reserved_mem += MMapEnt_Size(ptr); } if (!MMapEnt_IsFree(ptr)) { reserved_mem += MMapEnt_Size(ptr); }
else else
{ {
free_mem += MMapEnt_Size(ptr); free_mem += MMapEnt_Size(ptr);
for (uint64_t j = 0; j < (MMapEnt_Size(ptr) / ARCH_PAGE_SIZE); j++) for (u64 j = 0; j < (MMapEnt_Size(ptr) / ARCH_PAGE_SIZE); j++) { page_bitmap_set(index + j, false); }
{
page_bitmap_set(index + j, false);
}
} }
ptr++; ptr++;
} }