[freenos] Re: Ask a simple question about freenos

  • From: Niek Linnenbank <nieklinnenbank@xxxxxxxxx>
  • To: 张陈华 <zch051383471952@xxxxxxxxx>
  • Date: Sat, 12 Dec 2009 12:18:11 +0000

Hello,

I got the INITRUN() trick from Linux actually. It's basically a way to
execute a set of functions. It works like this: in every compiled object (.o
files) you fill the '.init' section with a pointer to the function you want
to be executed. I use these
macro for it: INITFUNC() and INITCLASS(), for a C function and C++ function,
respectively. An extra argument 'level' is used to give the functions a
priority. When the whole kernel is compiled, you'll have a list of function
pointers in the .init[0-9] sections starting at initStart to initEnd. The
kernel linker script defines those symbols: kernel/X86/kernel.ld. Then the
only thing INITRUN() needs to do is loop and execute each function.

The user programs are extracted from the BootImage loaded by GRUB in the
Kernel::Kernel() constructor function :-)

Regards,

Niek

On Fri, Dec 11, 2009 at 1:57 PM, 张陈华 <zch051383471952@xxxxxxxxx> wrote:

> hi niek,
>
>   I get a problem ,when i read the freenos source code ,
> to the Kernel entry point
>
> C void kmain (
>  )
>
> Kernel <http://dl.dropbox.com/u/1110700/html/classKernel.html> entry
> point.
>
> References 
> Scheduler::executeNext()<http://dl.dropbox.com/u/1110700/html/Scheduler_8cpp_source.html#l00030>,
> initEnd<http://dl.dropbox.com/u/1110700/html/group__kernel.html#gab70a3b38a2de19bfe52c0f4470f976a0>,
> INITRUN <http://dl.dropbox.com/u/1110700/html/Init_8h_source.html#l00083>,
> initStart<http://dl.dropbox.com/u/1110700/html/group__kernel.html#ga2a1551405cad7b149dae0de1ad99697a>,
> and 
> scheduler<http://dl.dropbox.com/u/1110700/html/group__kernel.html#ga0af0114c406f687347d551154125b00c>
> .
>
> 00023 {
> 00024     /* Initialize kernel. */
> 00025     INITRUN 
> <http://dl.dropbox.com/u/1110700/html/Init_8h.html#a75ec068c5c49826d461c50b5ac40682f>(&initStart
>  
> <http://dl.dropbox.com/u/1110700/html/group__kernel.html#ga2a1551405cad7b149dae0de1ad99697a>,
>  &initEnd 
> <http://dl.dropbox.com/u/1110700/html/group__kernel.html#gab70a3b38a2de19bfe52c0f4470f976a0>);
> 00026
> 00027     /* Start scheduling. */
> 00028     scheduler 
> <http://dl.dropbox.com/u/1110700/html/group__kernel.html#ga0af0114c406f687347d551154125b00c>->executeNext
>  
> <http://dl.dropbox.com/u/1110700/html/classScheduler.html#a575ef1263a42d46bcba2aa40f7d2ddc6>();
> 00029 }
>
>
> does  the INITRUN initialize  these processes ,
> /srv/input/keyboard/server
> /srv/video/vga/server
> /srv/terminal/server
> /srv/log/server
> /srv/ata/server
> /srv/filesystem/proc/server
> /srv/filesystem/grub/server
> /srv/filesystem/linn/server /dev/ata0 0x400000 /usr
> /srv/serial/server
> /srv/pci/server
> /srv/pci/detect
> /srv/time/server
> /bin/sh/sh
>
> i am very confused about the
>
> INITRUN 
> <http://dl.dropbox.com/u/1110700/html/Init_8h.html#a75ec068c5c49826d461c50b5ac40682f>(&initStart
>  
> <http://dl.dropbox.com/u/1110700/html/group__kernel.html#ga2a1551405cad7b149dae0de1ad99697a>,
>  &initEnd 
> <http://dl.dropbox.com/u/1110700/html/group__kernel.html#gab70a3b38a2de19bfe52c0f4470f976a0>);
>
> because i just trace the INITRUN define
>
> #define INITRUN ( from,
>
> to
>  )
>  *Value:*
>
> { \
>         Address 
> <http://dl.dropbox.com/u/1110700/html/group__types.html#ga153192b394630b5bbd32e3a430673674>
>  *i; \
>
>         \
>         for (i = (from); i < (to); i++) \
>         { \
>             (*(InitHandler 
> <http://dl.dropbox.com/u/1110700/html/Init_8h.html#a2c4c24cb6689ec2adc307adeb09f9824>
>  **) i)(); \
>
>         } \
>     }
>
>
> i don't know about initStart ,initEnd .
> how to connect the INTRUN(),to initialize the rc processes.
>
>
> --
> alex zhang
>



-- 
Niek Linnenbank

WWW: http://www.nieklinnenbank.nl/
BLOG: http://nieklinnenbank.wordpress.com/
FUN:    http://www.FreeNOS.org/

Other related posts:

  • » [freenos] Re: Ask a simple question about freenos - Niek Linnenbank