fixed some typos, added comments and some code cleanup
This commit is contained in:
parent
491bb39465
commit
1fc3e40c4e
4 changed files with 17 additions and 17 deletions
|
@ -70,7 +70,7 @@ stublet:
|
||||||
; jump to the boot processors's C code
|
; jump to the boot processors's C code
|
||||||
extern main
|
extern main
|
||||||
call main
|
call main
|
||||||
jmp $
|
jmp $ ; infinitive loop
|
||||||
|
|
||||||
global cpu_init
|
global cpu_init
|
||||||
cpu_init:
|
cpu_init:
|
||||||
|
@ -112,7 +112,7 @@ global read_ip
|
||||||
read_ip:
|
read_ip:
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
pop DWORD [eax] ; Get the return address
|
pop DWORD [eax] ; Get the return address
|
||||||
add esp, 4 ; Dirty Hack! read_ip cleanup the stacl
|
add esp, 4 ; Dirty Hack! read_ip cleanup the stack
|
||||||
jmp [eax] ; Return. Can't use RET because return
|
jmp [eax] ; Return. Can't use RET because return
|
||||||
; address popped off the stack.
|
; address popped off the stack.
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ extern kernel_end
|
||||||
extern apic_mp
|
extern apic_mp
|
||||||
|
|
||||||
; We use a special name to map this section at the begin of our kernel
|
; We use a special name to map this section at the begin of our kernel
|
||||||
; => Multiboot needs its magic number at the begin of the kernel
|
; => Multiboot needs its magic number at the beginning of the kernel
|
||||||
SECTION .mboot
|
SECTION .mboot
|
||||||
global start
|
global start
|
||||||
start:
|
start:
|
||||||
|
@ -42,19 +42,19 @@ mboot:
|
||||||
; Multiboot macros to make a few lines more readable later
|
; Multiboot macros to make a few lines more readable later
|
||||||
MULTIBOOT_PAGE_ALIGN equ 1<<0
|
MULTIBOOT_PAGE_ALIGN equ 1<<0
|
||||||
MULTIBOOT_MEMORY_INFO equ 1<<1
|
MULTIBOOT_MEMORY_INFO equ 1<<1
|
||||||
; MULTIBOOT_AOUT_KLUDGE equ 1<<16
|
; MULTIBOOT_AOUT_KLUDGE equ 1<<16
|
||||||
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
|
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
|
||||||
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO ; | MULTIBOOT_AOUT_KLUDGE
|
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO ; | MULTIBOOT_AOUT_KLUDGE
|
||||||
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
|
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
|
||||||
EXTERN code, bss, end
|
EXTERN code, bss, end
|
||||||
|
|
||||||
; This is the GRUB Multiboot header. A boot signature
|
; This is the GRUB Multiboot header. A boot signature
|
||||||
dd MULTIBOOT_HEADER_MAGIC
|
dd MULTIBOOT_HEADER_MAGIC
|
||||||
dd MULTIBOOT_HEADER_FLAGS
|
dd MULTIBOOT_HEADER_FLAGS
|
||||||
dd MULTIBOOT_CHECKSUM
|
dd MULTIBOOT_CHECKSUM
|
||||||
|
|
||||||
ALIGN 4
|
ALIGN 4
|
||||||
; we need already a valid GDT to switch in the 64bit modus
|
; we need already a valid GDT to switch in the 64bit mode
|
||||||
GDT64: ; Global Descriptor Table (64-bit).
|
GDT64: ; Global Descriptor Table (64-bit).
|
||||||
.Null: equ $ - GDT64 ; The null descriptor.
|
.Null: equ $ - GDT64 ; The null descriptor.
|
||||||
dw 0 ; Limit (low).
|
dw 0 ; Limit (low).
|
||||||
|
@ -81,7 +81,7 @@ GDT64: ; Global Descriptor Table (64-bit).
|
||||||
dw $ - GDT64 - 1 ; Limit.
|
dw $ - GDT64 - 1 ; Limit.
|
||||||
dq GDT64 ; Base.
|
dq GDT64 ; Base.
|
||||||
|
|
||||||
times 256 DD 0
|
times 256 DD 0 ; stack for booting
|
||||||
startup_stack:
|
startup_stack:
|
||||||
|
|
||||||
SECTION .data
|
SECTION .data
|
||||||
|
@ -129,8 +129,8 @@ smp_entry:
|
||||||
|
|
||||||
; 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 PM-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 ; According to the multiboot spec the PE-bit has to be set by bootloader already!
|
||||||
|
|
||||||
mov edi, [esp+4] ; set argumet for smp_start
|
mov edi, [esp+4] ; set argumet for smp_start
|
||||||
lgdt [GDT64.Pointer] ; Load the 64-bit global descriptor table.
|
lgdt [GDT64.Pointer] ; Load the 64-bit global descriptor table.
|
||||||
|
@ -342,7 +342,7 @@ Lc:
|
||||||
|
|
||||||
; 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 PM-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
|
||||||
|
|
||||||
pop ebx ; restore pointer to multiboot structure
|
pop ebx ; restore pointer to multiboot structure
|
||||||
|
|
|
@ -71,7 +71,7 @@ page_dir_t* get_boot_pgd(void)
|
||||||
/*
|
/*
|
||||||
* TODO: We create a full copy of the current task. Copy-On-Access will be the better solution.
|
* TODO: We create a full copy of the current task. Copy-On-Access will be the better solution.
|
||||||
*
|
*
|
||||||
* No PGD locking is needed because onls create_pgd use this function and holds already the
|
* No PGD locking is needed because only create_pgd use this function and holds already the
|
||||||
* PGD lock.
|
* PGD lock.
|
||||||
*/
|
*/
|
||||||
inline static size_t copy_page_table(task_t* task, uint32_t pgd_index, page_table_t* pgt, int* counter)
|
inline static size_t copy_page_table(task_t* task, uint32_t pgd_index, page_table_t* pgt, int* counter)
|
||||||
|
@ -650,7 +650,7 @@ static void pagefault_handler(struct state *s)
|
||||||
memset((void*) viraddr, 0x00, PAGE_SIZE);
|
memset((void*) viraddr, 0x00, PAGE_SIZE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
kprintf("Could not map 0x%x at 0x%x\n", phyaddr, viraddr);
|
kprintf("Could not map 0x%x at 0x%x\n", phyaddr, viraddr);
|
||||||
put_page(phyaddr);
|
put_page(phyaddr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@
|
||||||
extern const void kernel_start;
|
extern const void kernel_start;
|
||||||
extern const void kernel_end;
|
extern const void kernel_end;
|
||||||
|
|
||||||
// boot task's page directory and page directory lock
|
// boot task's page directory and p:age directory lock
|
||||||
extern page_dir_t boot_pgd;
|
extern page_dir_t boot_pgd; // TODO: initialization done in entry64.asm
|
||||||
static spinlock_t kslock = SPINLOCK_INIT;
|
static spinlock_t kslock = SPINLOCK_INIT;
|
||||||
static int paging_enabled = 0;
|
static int paging_enabled = 0;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ page_dir_t* get_boot_pgd(void)
|
||||||
|
|
||||||
int create_pgd(task_t* task, int copy)
|
int create_pgd(task_t* task, int copy)
|
||||||
{
|
{
|
||||||
// Currently, we support only kernel tasks
|
// TODO: Currently, we support only kernel tasks
|
||||||
// => all tasks are able to use the same pgd
|
// => all tasks are able to use the same pgd
|
||||||
|
|
||||||
if (BUILTIN_EXPECT(!paging_enabled, 0))
|
if (BUILTIN_EXPECT(!paging_enabled, 0))
|
||||||
|
@ -130,7 +130,7 @@ size_t virt_to_phys(size_t viraddr)
|
||||||
|
|
||||||
spinlock_irqsave_lock(&task->pgd_lock);
|
spinlock_irqsave_lock(&task->pgd_lock);
|
||||||
|
|
||||||
// Currently, we allocate pages only in kernel space.
|
// TODO: Currently, we allocate pages only in kernel space.
|
||||||
// => physical address of the page table is identical of the virtual address
|
// => physical address of the page table is identical of the virtual address
|
||||||
pgt = (page_table_t*) (task->pgd->entries[idx_pd4] & PAGE_MASK);
|
pgt = (page_table_t*) (task->pgd->entries[idx_pd4] & PAGE_MASK);
|
||||||
if (!pgt)
|
if (!pgt)
|
||||||
|
|
Loading…
Add table
Reference in a new issue