wip: change the C function set_mem_size to asm
This commit is contained in:
parent
5fccbf3708
commit
3c87632b0c
@ -23,7 +23,7 @@ extern uint32_t _kernel_end;
|
||||
extern uint32_t boot_page_directory;
|
||||
extern uint32_t *page_directory;
|
||||
extern uint32_t page_table_default[1024];
|
||||
extern uint32_t mem_size;
|
||||
extern uint64_t mem_size;
|
||||
|
||||
uint32_t *virt_to_phys(uint32_t *virt_addr);
|
||||
void init_memory(void);
|
||||
|
@ -34,6 +34,7 @@ boot_page_table1:
|
||||
# The kernel entry point.
|
||||
.section .multiboot.text, "a"
|
||||
.global _start
|
||||
.global end_mem
|
||||
.type _start, @function
|
||||
_start:
|
||||
# Physical address of boot_page_table1.
|
||||
@ -89,6 +90,10 @@ _start:
|
||||
movl $(boot_page_directory - 0xC0000000), %ecx
|
||||
movl %ecx, %cr3
|
||||
|
||||
jmp set_mem_size
|
||||
|
||||
end_mem:
|
||||
|
||||
# Enable paging and the write-protect bit.
|
||||
movl %cr0, %ecx
|
||||
orl $0x80000000, %ecx
|
||||
@ -113,9 +118,6 @@ _start:
|
||||
# Set up the stack.
|
||||
mov $stack_top, %esp
|
||||
|
||||
push %eax
|
||||
push %ebx
|
||||
|
||||
# Enter the high-level kernel.
|
||||
call kernel_main
|
||||
|
||||
|
@ -31,7 +31,8 @@
|
||||
* feeling qui me donnerait envie de continuer dans une relation "couple" sur le
|
||||
* long terme. Je sais pas trop comment le dire sans que ça te blesse, c'est pas
|
||||
* personnel ou quoi c'est cool quand on parle et tout mais juste je ne pense
|
||||
* pas pouvoir faire marcher une relation comme celle là :( */ /* Voilà je voulais juste te le dire pour pas que tu te mettes quelque chose en
|
||||
* pas pouvoir faire marcher une relation comme celle là :( */
|
||||
/* Voilà je voulais juste te le dire pour pas que tu te mettes quelque chose en
|
||||
* tête qui n'arrivera pas, je trouve ça plus correct */
|
||||
|
||||
static void set_mem_size(multiboot_info_t *mbd, uint32_t magic)
|
||||
@ -54,14 +55,14 @@ static void set_mem_size(multiboot_info_t *mbd, uint32_t magic)
|
||||
}
|
||||
}
|
||||
|
||||
void kernel_main(multiboot_info_t *mbd, uint32_t magic)
|
||||
void kernel_main(void)
|
||||
{
|
||||
terminal_initialize();
|
||||
init_gdt();
|
||||
init_idt();
|
||||
init_memory();
|
||||
load_drivers();
|
||||
set_mem_size(mbd, magic);
|
||||
/* set_mem_size(mbd, magic); */
|
||||
kprintf(KERN_ALERT
|
||||
"I see no way to confuse an array of 256 seg:off pairs with a "
|
||||
"complex 8*unknown quantity -byte descriptor table. -- Troy "
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
uint32_t *page_directory = &boot_page_directory;
|
||||
uint32_t page_table_default[1024] __attribute__((aligned(4096)));
|
||||
uint32_t mem_size;
|
||||
uint64_t mem_size;
|
||||
|
||||
void init_memory(void)
|
||||
{
|
||||
|
27
src/set_mem_size.s
Normal file
27
src/set_mem_size.s
Normal file
@ -0,0 +1,27 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.section .text
|
||||
.global set_mem_size
|
||||
|
||||
set_mem_size:
|
||||
xor ebx, ebx
|
||||
.L1:
|
||||
// loop condition
|
||||
cmp ebx, [eax + 64]
|
||||
jge end_mem
|
||||
|
||||
// declare mmmt
|
||||
mov ecx, [eax + 68]
|
||||
add ecx, ebx
|
||||
|
||||
// check if the mmmt->type is available (1)
|
||||
cmp DWORD PTR [ecx + 20], 1
|
||||
jne .L2
|
||||
// add the size of the block
|
||||
mov edx, [ecx + 12]
|
||||
add DWORD PTR mem_size, edx
|
||||
mov edx, [ecx + 16]
|
||||
add DWORD PTR mem_size + 4, edx
|
||||
.L2:
|
||||
add ebx, 24
|
||||
jmp .L1
|
Loading…
Reference in New Issue
Block a user