root/entryother.S

/* [<][>][^][v][top][bottom][index][help] */
   1 #include "asm.h"
   2 #include "memlayout.h"
   3 #include "mmu.h"
   4         
   5 # Each non-boot CPU ("AP") is started up in response to a STARTUP
   6 # IPI from the boot CPU.  Section B.4.2 of the Multi-Processor
   7 # Specification says that the AP will start in real mode with CS:IP
   8 # set to XY00:0000, where XY is an 8-bit value sent with the
   9 # STARTUP. Thus this code must start at a 4096-byte boundary.
  10 #
  11 # Because this code sets DS to zero, it must sit
  12 # at an address in the low 2^16 bytes.
  13 #
  14 # Startothers (in main.c) sends the STARTUPs one at a time.
  15 # It copies this code (start) at 0x7000.  It puts the address of
  16 # a newly allocated per-core stack in start-4,the address of the
  17 # place to jump to (mpenter) in start-8, and the physical address
  18 # of entrypgdir in start-12.
  19 #
  20 # This code is identical to bootasm.S except:
  21 #   - it does not need to enable A20
  22 #   - it uses the address at start-4, start-8, and start-12
  23 
  24 .code16           
  25 .globl start
  26 start:
  27   cli            
  28 
  29   xorw    %ax,%ax
  30   movw    %ax,%ds
  31   movw    %ax,%es
  32   movw    %ax,%ss
  33 
  34   lgdt    gdtdesc
  35   movl    %cr0, %eax
  36   orl     $CR0_PE, %eax
  37   movl    %eax, %cr0
  38 
  39 //PAGEBREAK!
  40   ljmpl    $(SEG_KCODE<<3), $(start32)
  41 
  42 .code32
  43 start32:
  44   movw    $(SEG_KDATA<<3), %ax
  45   movw    %ax, %ds
  46   movw    %ax, %es
  47   movw    %ax, %ss
  48   movw    $0, %ax
  49   movw    %ax, %fs
  50   movw    %ax, %gs
  51 
  52   # Turn on page size extension for 4Mbyte pages
  53   movl    %cr4, %eax
  54   orl     $(CR4_PSE), %eax
  55   movl    %eax, %cr4
  56   # Use enterpgdir as our initial page table
  57   movl    (start-12), %eax
  58   movl    %eax, %cr3
  59   # Turn on paging.
  60   movl    %cr0, %eax
  61   orl     $(CR0_PE|CR0_PG|CR0_WP), %eax
  62   movl    %eax, %cr0
  63 
  64   # Switch to the stack allocated by startothers()
  65   movl    (start-4), %esp
  66   # Call mpenter()
  67   call   *(start-8)
  68 
  69   movw    $0x8a00, %ax
  70   movw    %ax, %dx
  71   outw    %ax, %dx
  72   movw    $0x8ae0, %ax
  73   outw    %ax, %dx
  74 spin:
  75   jmp     spin
  76 
  77 .p2align 2
  78 gdt:
  79   SEG_NULLASM
  80   SEG_ASM(STA_X|STA_R, 0, 0xffffffff)
  81   SEG_ASM(STA_W, 0, 0xffffffff)
  82 
  83 
  84 gdtdesc:
  85   .word   (gdtdesc - gdt - 1)
  86   .long   gdt
  87 

/* [<][>][^][v][top][bottom][index][help] */