but it just wont compile
i am using NASM for asm and MinGW for c++
this is my NASM code for pagging
Code: Select all
[global _read_cr0]
_read_cr0:
mov eax, cr0
retn
[global _write_cr0]
_write_cr0:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov cr0, eax
pop ebp
retn
[global _read_cr3]
_read_cr3:
mov eax, cr3
retn
[global _write_cr3]
_write_cr3:
push ebp
mov ebp, esp
mov eax, [ebp+8]
mov cr3, eax
pop ebp
retn
[global _long_mode1]
_long_mode1:
; cr0.PG is alread at 0
; Set cr4.PAE
mov eax , cr4
or eax , 0x2000000
mov cr4 , eax
; L4PT loaded in pagging.cpp
retn
[global _long_mode2]
_long_mode2:
;Set EFER.LME
mov ecx , 0xC0000080
rdmsr
or eax , 0x100
wrmsr
rent
;rest in paging
Code: Select all
#include <system.h>
//this is 4mb of paging ten enables long mode
void pagtable_AND_LM_Setup() {
unsigned long *page_directory[4][1024] = (unsigned long *) 0x9C000;
unsigned long * address = 0; // holds the physical address of where a page is
unsigned int i;
// map the memory
for(i=0; i<1024; i++) {
unsigned int c;
for(c=0; c<1024; c++) {
page_directory[i][c] = address | 3; // attribute set to: supervisor level, read/write, present(011 in binary)
address = address + 4096; // 4096 = 4kb
};
// fill entrys of the page directory
page_directory[i] = page_directory[i] | 3;// attribute set to: supervisor level, read/write, present(011 in binary)
};
// write_cr3, read_cr3, write_cr0, and read_cr0 all come from the assembly function
long_mode1(); // start long mode int
write_cr3(page_directory); // put that page directory address into CR3
long_mode2(); // pagging int 2
write_cr0( read_cr0() | (unsigned long *) 0x80000000); // set the paging bit in CR0 to 1
}
code will not compile
![Crying or Very sad :cry:](./images/smilies/icon_cry.gif)
here is the compiler output
can anyone tell me why its not compileingC:\DOCUME~1\HandE\MYDOCU~1\HARRYH~1\HSim\OSCAT~1\src\b8>C:\MinGW\bin\c++ -Wall -
O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-built
in -I./include -c -o paging.o paging.cpp
paging.cpp: In function `void pagtable_AND_LM_Setup()':
paging.cpp:4: error: invalid initializer
paging.cpp:12: error: invalid operands of types `long unsigned int*' and `int' t
o binary `operator|'
paging.cpp:16: error: invalid operands of types `long unsigned int*[1024]' and `
int' to binary `operator|'
paging.cpp:23: error: cannot convert `long unsigned int* (*)[1024]' to `long uns
igned int*' for argument `1' to `void write_cr3(long unsigned int*)'
paging.cpp:25: error: invalid operands of types `long unsigned int*' and `long u
nsigned int*' to binary `operator|'
becouse i followed the tutorial step by step
and it dosen`t work whithout any mods ether