Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/smp/boot-smp.S need to be fixed.

0001 /* -*- Mode: asm; comment-start: "\/*"; comment-end: "*\/"; indent-tabs-mode: nil -*- */
0002 /*                    The Quest Operating System
0003  *  Copyright (C) 2005-2010  Richard West, Boston University
0004  *
0005  *  This program is free software: you can redistribute it and/or modify
0006  *  it under the terms of the GNU General Public License as published by
0007  *  the Free Software Foundation, either version 3 of the License, or
0008  *  (at your option) any later version.
0009  *
0010  *  This program is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  *  GNU General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU General Public License
0016  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 #include "kernel.h"
0020 #include "smp/smp.h"
0021         .text
0022         .align 0x10
0023         .code16
0024 
0025         /* This code gets loaded by smp.c into address MP_BOOTADDR
0026          * for the application processor to start. */
0027 
0028         /* These symbols are linked at segment 0x10100 but will be later
0029          * placed at segment MP_BOOTADDR>>4, so some care has to be taken with
0030          * addresses */
0031         .globl patch_code_start
0032         .globl patch_code_end
0033         .globl status_code
0034         .globl ap_stack_ptr
0035 patch_code_start:
0036         jmp 1f
0037 
0038 status_code:    
0039         .long 0                /* status indicator */
0040 ap_stack_ptr:                  /* C stack for AP */
0041         .long 0                
0042 
0043 1: 
0044         /* Entering in 16-bit real mode */
0045         movw %cs, %dx
0046         movw %dx, %ds
0047         
0048         lgdtl patch_gdt_ptr - patch_code_start /* using ds segment */
0049 
0050         xorw %dx, %dx
0051         movw %dx, %ds
0052 
0053         movl %cr4, %eax /* EAX is temporary for CR4 */
0054         orl $0x10, %eax /* Set PSE bit of CR4 */
0055         movl %eax, %cr4
0056 
0057         movl $pgd, %eax
0058         movl %eax, %cr3
0059         movl %cr0, %eax /* need to set bit 31 of CR0 - see 3-18 in Manual vol 3 */
0060         orl $0x80000001, %eax
0061         movl %eax, %cr0 /* and enter protected mode as well */
0062 
0063         /* flush icache */
0064         ljmpl $0x08, $ap_pmode - patch_code_start + MP_BOOTADDR
0065 
0066         .align 0x10
0067         .code32
0068 ap_pmode:  
0069         movw $0x10, %ax /* Set DS-SS to refer to KERNEL DS */
0070         movw %ax, %ds
0071         movw %ax, %es
0072         movw %ax, %fs
0073         movw %ax, %gs
0074         movw %ax, %ss
0075                 
0076         xorw %ax, %ax
0077         lldt %ax        
0078 
0079 
0080         /* setup our stack */
0081         movl $ap_stack_ptr - patch_code_start + MP_BOOTADDR, %eax
0082         movl (%eax), %eax
0083         addl $0x1000, %eax
0084         movl %eax, %esp
0085 
0086         /* Allocate pages and GDT entry to setup per-CPU memory space */
0087         lcall $0x8, $percpu_per_cpu_init
0088 
0089         /* Write 1 to status indicator */
0090         movl $status_code - patch_code_start + MP_BOOTADDR, %eax
0091         movl $0x1, (%eax)
0092         
0093         /* call back into C */
0094         lcall $0x8, $ap_init
0095         
0096 patch_gdt_ptr:  
0097         .short 0x7FF     /* length in bytes - 256 descriptors */
0098         .long  KERN_GDT   /* linear address */
0099 patch_code_end: 
0100 
0101 /* vi: set et sw=8 sts=8: */