LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Linux Kernel Questions - learning the sourcecode (https://www.linuxquestions.org/questions/programming-9/linux-kernel-questions-learning-the-sourcecode-4175460792/)

GrahamVH 05-05-2013 10:29 AM

Linux Kernel Questions - learning the sourcecode
 
Howdy,
I'm attempting to learn the general structure of the Linux kernel for the purpose of debugging and greater understanding. I'm looking to ask C related questions about the linux kernel regarding things I don't understand. First off, Is this a good place to do this?

Second an actual kernel question (using linux-3.8.11):
I have decided to go about this by starting with following the boot process. I figure I can follow this into a general structure for how each piece of the kernel ties together.
I'm currently stumped on this function in arch/x86/boot/pm.c:
Code:

void go_to_protected_mode(void)
{
        /* Hook before leaving real mode, also disables interrupts */
        realmode_switch_hook();

        /* Enable the A20 gate */
        if (enable_a20()) {
                puts("A20 gate not responding, unable to boot...\n");
                die();
        }

        /* Reset coprocessor (IGNNE#) */
        reset_coprocessor();

        /* Mask all interrupts in the PIC */
        mask_all_interrupts();

        /* Actual transition to protected mode... */
        setup_idt();
        setup_gdt();
        protected_mode_jump(boot_params.hdr.code32_start,
                            (u32)&boot_params + (ds() << 4));
}


On the last line I can't seem to find the function protected_mode_jump using my cscope map. Without knowing about that function, I can't reliably determine where to go from this point. I feel I must be missing something obvious, but what?

mina86 05-06-2013 01:26 AM

That's because it's written in Assembly: http://lxr.linux.no/linux+*/arch/x86/boot/pmjump.S#L24 I recommend either using “git grep” in source code tree or [url=http://lxr.linux.no/linux/]LXR[/url.

In general, I wouldn't recommend trying to figure out kernel by following the boot process. There's a lot of weird stuff happening when kernel starts and to understand all of it, you'd have to dig into a whole lot of subsystems (eg. memory management, block, etc).

Instead you could first try reading through Understanding the Linux Kernel or Linux Device Drivers.

GrahamVH 05-06-2013 07:10 PM

Thanks Mina,
I forgot that cscope only looks at c files :P.


All times are GMT -5. The time now is 07:30 AM.