Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linkin C and Assembly Files

Status
Not open for further replies.

ekanth

Programmer
Jul 28, 2001
28
US
Writing an OS includes both C and Assembly langur\age programming. I'm not clear when to switch from asm to C. At which level or after what have been done could I switch to C programming. I would also thank you if you could suggest some optimal memory maps to follow.
Sincerely,
Ekanth
 
Ekaanth,
Compiler ur C code into Binary.
U can use gcc/ld which would be a very
powerful tool to do all such work.

Ur Entry Point in the "C" code should
know about certain things. For exp, it
might need to asssume that PM and paging
are already setup. Ur memory map during bootup
may be made available as a ".h" file. Continue
writing "C" code from there. for exp, memoruy initializn,
configuring Kernel Segments, kmem_allocations, Vm manager
etc.. In the Loader routine, do the loading of kernel ("C"
part), then initialize some basic GDT, minimal page-tables
etc.. and the make LongJump into where u have loaded
ur kernel. that would do

Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Hey ekaanth,
Try doing ur kernel as an ELF image.
I m not sure how complicated loading would be then.
But When u r an ELF, u will have lot of advantages
like, u can make Page-level protection for ur code,
and RODATA (read-only data) etc.. (trapping of bugs
in kernel code can b done in early stage of life, rather
letting the bug grow..)
moreover with SymBol info, things would be more cleaner.
but u need to spend some time learning ELF.
I haven't done ELF loading..but my colleagues have
done it..shouldnt be a problem..

Sarnath
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Sarnath,
Its not ekaanth, its ekanth...
 
Ok sir!
Do not rejoice that ur code works.
it might be a special case of an error :-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top