grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help regarding booting application processor


From: address@hidden
Subject: Re: Help regarding booting application processor
Date: Wed, 24 Feb 2010 01:30:04 -0600

On Wed, Feb 24, 2010 at 12:57 AM, Swapnil Pimpale
<address@hidden> wrote:
> Hi all,
>
>  I am a final year engineering student and I am doing my project in
> GRUB-1.97~beta4 and Linux Kernel 2.6.24.7.
>
>  I am working on Intel Core 2 Duo architecture. I want to boot a
> separate kernel on the second core.
>  As of now, I have brought up the halted AP from the GRUB by sending
> IPIs in the INIT-SIPI-SIPI sequence. I have also allocated a 4KB page
> below 1MB and asked the AP to jump to that address.
>
>  I am trying to put the BSP in while(1) loop and I want the AP to
> switch from real to protected mode and then jump to start of kernel.
> But whenever I do a jump to 1MB the system reboots.

Remember that the RAM physical address space is shared between both
processors.  You'll need to tell Linux not to touch the second core
and not to touch the memory used by your second OS.  I think you can
accomplish both of these goals using the right kernel command line.
Then you'll have to divide up other hardware, like PCI devices, so
that only one OS accesses any given device.  For example, the second
OS won't be able to use a hard disk connected to a SATA controller
visible to the first one.  Especially the second kernel needs to be
written not to address the PCI bus controller(s), including
enumeration of bus devices.

If you can't partition the hardware like this then you'll need a
hypervisor, which uses protected mode to intercept and virtualize
attempted hardware access from the other OS.

>  I am using the following code as the trampoline code for the AP.
>
>  Can someone please let me know what is wrong in the following code.

Probably you've stomped on a shared resource being used by the first
processor.  Even if you run an infinite while loop on the first core,
it can still execute interrupt service routines installed by grub (or
by the second kernel, if not careful about interrupt-processor masks)
which would access grub global data structures.  If you overwrite
anything you may end up with a protection fault or invalid instruction
exception, both of which would probably vector back to BIOS startup
code.

>  Awaiting your reply,
>
> Thanks,
> Swapnil Pimpale
>
> ----- trampoline.S -----
> /* Tell GAS to generate 16-bit instructions so that this code works
>          in real mode. */
>
> #include <grub/symbol.h>
> #include <grub/i386/pc/memory.h>
>
>
> .align 4096
> .code16
> FUNCTION(TRAMPOLINE_CODE)
> initial:
>
>       mov     %cs, %ax
>       mov     %ax, %ds
>       cli
>
>       lidtl   idtdesc - initial
>       lgdtl   gdtdesc - initial
>
>       mov $0x9e00, %bx                   // 9e00 is the cs
>       shl $4, %ebx
>       movl $(gdt - initial + 8), %eax
>       movl %ebx, %eax
>
>        mov $0x10, %bx
>        xor %ecx, %ecx
>        mov $0xb800, %cx                 // address of video RAM in %cx
>        shl $4, %ecx
>        mov $0x0744, %dx                 // for printing D
>        xor %eax, %eax
>        pushw %ax
>        mov $0x08, %ax
>        pushw %ax
>        xor %eax, %eax
>        mov $0x9e00, %ax
>        shl $4, %eax
>        add protcseg - initial, %eax
>        pushl %eax
>
>       xor %eax, %eax
>       movl %cr0, %eax                 // turn on the PE bit
>       orl $0x1, %eax
>       movl %eax, %cr0
>
>      jmp l1
>
> l1:
>
>  mov %bx, %ds
>  mov %dx, (%ecx)                 // Print D
>  add $2, %ecx
>  add $1, %dx
>
>  ADDR32 ljmpl $0x8,$((protcseg - initial) + (0x9e00 << 4))
>
>  .align 256
>  .code32
>  protcseg:
>
> l3:
>  mov %dx, (%ecx)
>
>  movw %bx, %es
>  movw %bx, %fs
>  movw %bx, %gs
>  movw %bx, %ss
>
> l4:
> // The following is the code used by /loader/i386/linux.c for entering Linux
>  mov $0x8c000, %esi
>  xor %ebx, %ebx
>  mov $0x8c000, %eax
>  jmp *0x214(%eax)         // System reboots here
>
> l5:
>       jmp l5
>
>
> .p2align 2
> gdt:
>       .word   0, 0
>       .byte   0, 0, 0, 0
>
>       .word   0xFFFF, 0
>       .byte   0, 0x9A, 0xCF, 0
>
>       .word   0xFFFF, 0
>       .byte   0, 0x92, 0xCF, 0
>
>       .word   0xFFFF, 0
>       .byte   0, 0x9E, 0, 0
>
>       .word   0xFFFF, 0
>       .byte   0, 0x92, 0, 0
>
> gdtdesc:
>       .word   0x27
>       .long   gdt
>
> idtdesc:
>       .word 0
>       .long 0
> FUNCTION(TRAMPOLINE_END)
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]