- Main Page
- Data Structures
- Files
- Directories

- Search for |

- File List
- Globals

# ap-boot.S

Go to the documentation of this file.

    00001 /*
    00002  * Okay, this file contains the code that's going to bootstrap the AP cpus
    00003  */
    00004
    00005
    00006         .globl  ap_trampoline_start,ap_trampoline_end
    00007         .text
    00008         .code16
    00009 ap_trampoline_start:
    00010         cli
    00011         cld
    00012
    00013         movw    %cs,%ax         // The CPU knows its CS already, so lets use it for the other segments
    00014         movw    %ax,%ds
    00015         movw    %ax,%es
    00016         movw    %ax,%ss
    00017
    00018         // Do some bochs-specific bullshit
    00019         mov     $0x31,%al // '1'
    00020         mov     $0xe9,%dx
    00021         outb    %al,%dx
    00022         //lgdt    ap_gdt;
    00023         lgdt    ap_trampoline_gdt_limit - ap_trampoline_start
    00024         movl    %cr0,%eax
    00025         orl     $0x1,%eax
    00026         movl    %eax,%cr0       // PMODE!
    00027
    00028 .code32
    00029         .byte 0x66
    00030         ljmp    $0x08,$(ap_trampoline_32 - ap_trampoline_start)         // 0x08 == KERNEL_CS
    00031
    00032 ap_trampoline_32:
    00033         mov     $0x32,%al // '2'
    00034         mov     $0xe9,%dx
    00035         outb    %al,%dx
    00036
    00037         mov     $0x10,%ax
    00038         mov     %ax,%ds
    00039         mov     %ax,%es
    00040         mov     %ax,%fs
    00041         mov     %ax,%gs
    00042         mov     %ax,%ss
    00043
    00044         // Spinlock
    00045         mov     ap_trampoline_spl - ap_trampoline_start,%edi
    00046 ap_spl:
    00047         //cmp   $1,(%edi)
    00048         //je    ap_spl
    00049
    00050         mov     $1,%eax      // Value to be set
    00051         xchgl   (%edi),%eax
    00052         cmp     $0,%eax
    00053         je      ap_spl
    00054         // /Spinlock
    00055
    00056         mov     $0x30,%al // '0'
    00057         mov     $0xe9,%dx
    00058         outb    %al,%dx
    00059
    00060         mov     ap_trampoline_stackptr - ap_trampoline_start,%ebx
    00061         mov     %ebx,%esp
    00062         add     $0x1000,%ebx
    00063         mov     %ebx,ap_trampoline_stackptr - ap_trampoline_start
    00064
    00065         mov     $0x31,%al // '1'
    00066         mov     $0xe9,%dx
    00067         outb    %al,%dx
    00068
    00069         // spinunlock
    00070         mov     $0,%eax
    00071         mov     ap_trampoline_spl - ap_trampoline_start,%edi
    00072         xchgl   (%edi),%eax
    00073         // /spinunlock
    00074
    00075         mov     $0x33,%al // '3'
    00076         mov     $0xe9,%dx
    00077         outb    %al,%dx
    00078
    00079         mov     ap_trampoline_epoint,%eax
    00080         call    *%eax
    00081 1:
    00082         hlt
    00083         jmp     1b              // Halt if we ever get here somehow
    00084
    00085         // Stack.. This sucks, since CPU initialization isn't serialized
    00086 ap_trampoline_stackptr:
    00087         .long   0x10000         // 256KB
    00088 ap_trampoline_epoint:
    00089         .long   c_ap_boot
    00090
    00091 ap_trampoline_spl:
    00092         .long   0
    00093 ap_gdt:
    00094         .long ubixGDT
    00095
    00096         // GDT
    00097 ap_trampoline_gdt:
    00098         .word   0
    00099 ap_trampoline_gdt_limit:
    00100         .word   128     // Room for 32 descriptors
    00101 ap_trampoline_gdt_base:
    00102         .long   0x20000         // 128KB (move this later)
    00103
    00104
    00105 ap_trampoline_end: