fixed two smaller bugs and some compiler warnings
This commit is contained in:
parent
75633d0697
commit
d5f60ef542
8 changed files with 13 additions and 12 deletions
|
@ -127,6 +127,7 @@
|
||||||
|
|
||||||
/** @brief A single entry in a page map */
|
/** @brief A single entry in a page map */
|
||||||
typedef size_t page_entry_t;
|
typedef size_t page_entry_t;
|
||||||
|
|
||||||
/** @brief General page map structure
|
/** @brief General page map structure
|
||||||
*
|
*
|
||||||
* This page map structure is a general type for all indirecton levels.
|
* This page map structure is a general type for all indirecton levels.
|
||||||
|
@ -241,13 +242,13 @@ page_map_t* get_boot_page_map(void);
|
||||||
/** @brief Setup a new page directory for a new user-level task
|
/** @brief Setup a new page directory for a new user-level task
|
||||||
*
|
*
|
||||||
* @param task Pointer to the task-specific task_t structure
|
* @param task Pointer to the task-specific task_t structure
|
||||||
* @param copy If true: PGD will be a copy of the kernel's address space PGD
|
* @param copy If true: copy userspace pages and tables
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - counter of allocated page tables
|
* - counter of allocated page tables
|
||||||
* - -ENOMEM (-12) on failure
|
* - -ENOMEM (-12) on failure
|
||||||
*/
|
*/
|
||||||
int create_page_map(struct task* task, int copy);
|
int copy_page_map(struct task* task, int copy);
|
||||||
|
|
||||||
/** @brief Delete all page map structures of the current task
|
/** @brief Delete all page map structures of the current task
|
||||||
*
|
*
|
||||||
|
|
|
@ -724,8 +724,8 @@ static int apic_probe(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
found_mp:
|
found_mp:
|
||||||
|
#endif
|
||||||
if (!apic_mp)
|
if (!apic_mp)
|
||||||
goto no_mp;
|
goto no_mp;
|
||||||
|
|
||||||
|
|
|
@ -343,12 +343,12 @@ init_paging:
|
||||||
; Enable longmode (compatibility mode)
|
; Enable longmode (compatibility mode)
|
||||||
mov ecx, 0xC0000080
|
mov ecx, 0xC0000080
|
||||||
rdmsr
|
rdmsr
|
||||||
or eax, 1 << 8 ; IA32_EFER.LME = 1
|
or eax, (1 << 8) | (1 << 11) ; IA32_EFER.LME = 1, IA32_EFER.NXE = 1
|
||||||
wrmsr
|
wrmsr
|
||||||
|
|
||||||
; Enable paging
|
; Enable paging
|
||||||
mov eax, cr0
|
mov eax, cr0
|
||||||
or eax, 1 << 31 | 1 << 0 ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit.
|
or eax, (1 << 31) | (1 << 0) ; Set the PG-bit, which is the 31nd bit, and the PE-bit, which is the 0th bit.
|
||||||
mov cr0, eax
|
mov cr0, eax
|
||||||
|
|
||||||
; Jump to 64-bit longmode
|
; Jump to 64-bit longmode
|
||||||
|
|
|
@ -236,7 +236,7 @@ void page_stats(size_t from, size_t to, int reset)
|
||||||
stats[i]++;
|
stats[i]++;
|
||||||
}
|
}
|
||||||
for (i=0; i<1; i++) { // IA-32e / PAE bits
|
for (i=0; i<1; i++) { // IA-32e / PAE bits
|
||||||
if (*entry & (1 << 63-i))
|
if (*entry & (1 << (63-i)))
|
||||||
stats[i+PAGE_BITS]++;
|
stats[i+PAGE_BITS]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ int copy_page_map(task_t* new_task, int copy)
|
||||||
if (BUILTIN_EXPECT(!new, 0))
|
if (BUILTIN_EXPECT(!new, 0))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
phyaddr = virt_to_phys(new);
|
phyaddr = virt_to_phys((size_t) new);
|
||||||
|
|
||||||
// lock tables
|
// lock tables
|
||||||
spinlock_lock(&kslock);
|
spinlock_lock(&kslock);
|
||||||
|
@ -378,15 +378,13 @@ int drop_page_map(void)
|
||||||
// lock tables
|
// lock tables
|
||||||
spinlock_irqsave_lock(&task->page_lock);
|
spinlock_irqsave_lock(&task->page_lock);
|
||||||
|
|
||||||
int ret = page_iterate(0, PAGE_MAP_PGT, NULL, cb); // TODO: check boundaries
|
page_iterate(0, PAGE_MAP_PGT, NULL, cb); // TODO: check boundaries
|
||||||
|
|
||||||
pfree(task->page_map, PAGE_SIZE);
|
pfree(task->page_map, PAGE_SIZE);
|
||||||
|
|
||||||
// unlock tables
|
// unlock tables
|
||||||
spinlock_irqsave_unlock(&task->page_lock);
|
spinlock_irqsave_unlock(&task->page_lock);
|
||||||
|
|
||||||
kprintf("drop_page_map: finished\n"); // TODO: remove
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <metalsvm/mailbox_types.h>
|
#include <metalsvm/mailbox_types.h>
|
||||||
#include <asm/tasks_types.h>
|
#include <asm/tasks_types.h>
|
||||||
#include <asm/atomic.h>
|
#include <asm/atomic.h>
|
||||||
|
#include <asm/page.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -62,7 +63,6 @@ extern "C" {
|
||||||
#define TASK_L2 (1 << 3)
|
#define TASK_L2 (1 << 3)
|
||||||
|
|
||||||
typedef int (*entry_point_t)(void*);
|
typedef int (*entry_point_t)(void*);
|
||||||
typedef struct page_map page_map_t;
|
|
||||||
|
|
||||||
/** @brief The task_t structure */
|
/** @brief The task_t structure */
|
||||||
typedef struct task {
|
typedef struct task {
|
||||||
|
|
2
mm/vma.c
2
mm/vma.c
|
@ -298,7 +298,7 @@ int drop_vma_list()
|
||||||
|
|
||||||
spinlock_lock(&task->vma_lock);
|
spinlock_lock(&task->vma_lock);
|
||||||
|
|
||||||
while (vma = task->vma_list) {
|
while ((vma = task->vma_list)) {
|
||||||
task->vma_list = vma->next;
|
task->vma_list = vma->next;
|
||||||
kfree(vma);
|
kfree(vma);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate...
|
// allocate...
|
||||||
|
int i;
|
||||||
for (i = 0; i < chunks; i++) {
|
for (i = 0; i < chunks; i++) {
|
||||||
test[i] = malloc(size);
|
test[i] = malloc(size);
|
||||||
if (test[i])
|
if (test[i])
|
||||||
|
|
|
@ -9,6 +9,7 @@ target remote localhost:1234
|
||||||
|
|
||||||
# Debugging 64bit code
|
# Debugging 64bit code
|
||||||
set architecture i386:x86-64
|
set architecture i386:x86-64
|
||||||
|
#break main
|
||||||
|
|
||||||
# Debugging userspace
|
# Debugging userspace
|
||||||
#add-symbol-file newlib/examples/memtest.sym 0x40200000
|
#add-symbol-file newlib/examples/memtest.sym 0x40200000
|
||||||
|
|
Loading…
Add table
Reference in a new issue