aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kernel.c9
-rw-r--r--src/mem/vmm.c14
-rw-r--r--src/mmap.c10
-rw-r--r--src/sched/test_roundrobin.cc2
4 files changed, 21 insertions, 14 deletions
diff --git a/src/kernel.c b/src/kernel.c
index 8d7560b..98269c1 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -19,7 +19,7 @@ FILE *stdout;
FILE *stderr;
void
-kmain()
+kmain(void)
{
stderr = uart_init(COM1);
vmm_map(0xb8000, 0xc03ff000);
@@ -28,13 +28,14 @@ kmain()
printf("glitch [version " VERSION "] [" CC "]\n");
fprintf(stderr, "glitch [version " VERSION "] [" CC "]\n");
{
+ struct CPUVersion v;
+
char vendor[13] = {'\0'};
unsigned int eax;
__get_cpuid(0, &eax, (unsigned int *)vendor, (unsigned int *)(vendor + 8), (unsigned int *)(vendor + 4));
- struct CPUVersion v;
__get_cpuid(1, (unsigned int *)&v, &eax, &eax, &eax);
- printf("CPU: %s family %u model %u stepping %u\n", vendor, family(v), model(v), v.stepping);
- fprintf(stderr, "CPU: %s family %u model %u stepping %u\n", vendor, family(v), model(v), v.stepping);
+ printf("cpuid: %s family %u model %u stepping %u\n", vendor, family(v), model(v), v.stepping);
+ fprintf(stderr, "cpuid: %s family %u model %u stepping %u\n", vendor, family(v), model(v), v.stepping);
}
pic_init();
diff --git a/src/mem/vmm.c b/src/mem/vmm.c
index f62eadf..a07dd72 100644
--- a/src/mem/vmm.c
+++ b/src/mem/vmm.c
@@ -16,15 +16,15 @@ to_vaddr(unsigned paddr)
unsigned int
vmm_map(unsigned int paddr, unsigned int vaddr)
{
- if (paddr & 0xfff || vaddr & 0xfff) return 0;
-
+ struct TableEntry *table;
const unsigned table_idx = vaddr >> 22; /* high 10 bits */
const unsigned entry_idx = (vaddr >> 12) & 0x3ff; /* low 10 bits */
- if (k_pagedir[table_idx].present == 0) return 0;
- struct TableEntry *table = (struct TableEntry *)to_vaddr(k_pagedir[table_idx].address << 12);
+ if (paddr & 0xfff || vaddr & 0xfff) return 0;
- table[entry_idx].address = paddr >> 12;
+ if (k_pagedir[table_idx].present == 0) return 0;
+ table = (struct TableEntry *)to_vaddr(k_pagedir[table_idx].address << 12);
+ table[entry_idx].address = (paddr >> 12) & 0xfffff;
table[entry_idx].present = 1;
table[entry_idx].writeable = 1;
@@ -34,10 +34,12 @@ vmm_map(unsigned int paddr, unsigned int vaddr)
void
alloc4M()
{
+ struct DirectoryEntry4MB *directory;
+
/* enable pse in cr4 */
__asm__("movl %cr4, %eax; orl $0x10, %eax; movl %eax, %cr4");
- struct DirectoryEntry4MB *directory = (struct DirectoryEntry4MB *)&k_pagedir[0x301];
+ directory = (struct DirectoryEntry4MB *)&k_pagedir[0x301];
directory->address_low = 0x1;
directory->present = 1;
directory->writeable = 1;
diff --git a/src/mmap.c b/src/mmap.c
index c28ce79..e5d4be6 100644
--- a/src/mmap.c
+++ b/src/mmap.c
@@ -1,4 +1,6 @@
#include "mmap.h"
+#include <multiboot2.h>
+
#ifdef DEBUG
#include <stdio.h>
#endif
@@ -7,17 +9,19 @@ __attribute__((section(".multiboot.text"))) unsigned
multiboot2_mmap(const struct multiboot_mmap_entry entries[], unsigned entry_count, unsigned bitmap[1024 * 32])
{
unsigned i, l;
+ multiboot_uint64_t avail_frames = 0;
+ multiboot_uint64_t n_frames;
+ multiboot_uint64_t table_idx;
/* clear out the bitmap */
for (i = 0; i < 1024 * 32; ++i) bitmap[i] = 0;
- unsigned avail_frames = 0;
/* loop through all the mmap_entry structures where type is MULTIBOOT_MEMORY_AVAILABLE */
for (i = 0; i < entry_count; ++i) {
if (entries[i].type != MULTIBOOT_MEMORY_AVAILABLE) continue;
/* number of frames in this entry */
- unsigned n_frames = entries[i].len / 4096;
+ n_frames = entries[i].len / 4096;
avail_frames += n_frames;
#ifdef DEBUG
@@ -26,7 +30,7 @@ multiboot2_mmap(const struct multiboot_mmap_entry entries[], unsigned entry_coun
#endif
/* the bitmap is an array of blocks, each holding 32 (2^5) values */
- unsigned table_idx = (entries[i].addr >> 17); /* get the upper 15 bits */
+ table_idx = (entries[i].addr >> 17); /* get the upper 15 bits */
while (n_frames != 0) {
if (n_frames >= 32) {
diff --git a/src/sched/test_roundrobin.cc b/src/sched/test_roundrobin.cc
index 1431788..89f60bf 100644
--- a/src/sched/test_roundrobin.cc
+++ b/src/sched/test_roundrobin.cc
@@ -43,7 +43,7 @@ TEST(roundrobin, RoundRobinQueue)
std::cout << "Completed in (us): " << duration << std::endl;
// test should complete in 250us unless running on valgrind
- if (!RUNNING_ON_VALGRIND) EXPECT_LE(duration, 250);
+ if (!RUNNING_ON_VALGRIND) { EXPECT_LE(duration, 250); }
EXPECT_EQ(queue.head, nullptr);
EXPECT_EQ(queue.tail, nullptr);