Pick a Free OS

User login

Navigation

For Kernel_Newbies By a Kernel_Newbie

%eax; movl %eax , %cr0 ; // set up page directory in cr3 and enable the Paging

Bit (Most Significant bit as is evident in the bitmask.)in cr0) . It should be

noted that the Kernel is at offset __PAGE_OFFSET (asm-i386/page.h) which starts

at 0xC0000000 or 3 GB virtual memory. This is evident from the vmlinux.lds

script written by Martin Mares,(arch/i386/vmlinux.lds) which describes the

composition of the vmlinux object. {Please read linker script tutorials from

GNU,as that would enable you to follow vmlinux.lds,and also some variables which

are directly linked in the script, like __start_ksymtab, __stop_ksymtab

,etc.etc, which are defined in vmlinux.lds file. If you dont get to that,and try

ruminating over the extern declarations of start_ksymtab and stop_ksymtab in

kernel/module.c, then you would never get out of your search_module.) The linker

script defines the sections which make the vmlinux object, and the sections like

.text.init, .data.init,.initcall.init,.exitcall.exit, are freed up later,to

reclaim the memory used by those sections. (check out include/linux/init.h for

the macro definitions. They use a special GCC magic to define the sections, like

in #define __initdata __attribute__((__section__(\".data.init\"))) , and use it

like: static char init[] __initdata = \"remove_windows\"; Check out the tutorials

or the vmlinux.lds script for details regarding its usage.This is a

performance_hack in the Linux Kernel which I presume is not there in most of the

Kernels.) The first 8 MB page mappings are initialised in pg0 and pg1.The

empty_zero_page which is a globally shared page follows up after pg1. The

swapper_pg_dir which is the page_directory for init, is initialised for the

first 0-8M identity mappings with the Kernel Offset __PAGE_OFFSET. When you read

the table,please bear in mind that swapper_pg_dir is located at 0x1000 with

reference to the kernel loaded at 1MB. Hence the swapper_pg_dir starts off with

a mapping of 0x102007 instead of 0x101007 ( I might be wrong,but I have a

hunch,that I have got it right.) The page directory is split up into 2 parts:

Total = 1024 entries: 3 GIG FOR USER, AND 1 GIG FOR KERNEL which has a direct

mapping with __PAGE_OFFSET -> a.k.a __pa(kaddr) == phys_addr: and

__va(phys_addr) = kern_addr: