[BACK]Return to locore.S CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / i386 / i386

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/arch/i386/i386/locore.S between version 1.1.2.3 and 1.9

version 1.1.2.3, 2002/12/11 16:00:50 version 1.9, 2003/05/13 08:26:32
Line 90 
Line 90 
 #include "apm.h"  #include "apm.h"
 #include "lapic.h"  #include "lapic.h"
 #include "ioapic.h"  #include "ioapic.h"
   #include "ksyms.h"
   
 #include <sys/errno.h>  #include <sys/errno.h>
 #include <sys/syscall.h>  #include <sys/syscall.h>
Line 163 
Line 164 
  * XXX 4 == sizeof pde   * XXX 4 == sizeof pde
  */   */
         .set    _C_LABEL(PTmap),(PDSLOT_PTE << PDSHIFT)          .set    _C_LABEL(PTmap),(PDSLOT_PTE << PDSHIFT)
         .set    _C_LABEL(PTD),(_C_LABEL(PTmap) + PDSLOT_PTE * NBPG)          .set    _C_LABEL(PTD),(_C_LABEL(PTmap) + PDSLOT_PTE * PAGE_SIZE)
         .set    _C_LABEL(PTDpde),(_C_LABEL(PTD) + PDSLOT_PTE * 4)          .set    _C_LABEL(PTDpde),(_C_LABEL(PTD) + PDSLOT_PTE * 4)
   
 /*  /*
Line 173 
Line 174 
  * XXX 4 == sizeof pde   * XXX 4 == sizeof pde
  */   */
         .set    _C_LABEL(APTmap),(PDSLOT_APTE << PDSHIFT)          .set    _C_LABEL(APTmap),(PDSLOT_APTE << PDSHIFT)
         .set    _C_LABEL(APTD),(_C_LABEL(APTmap) + PDSLOT_APTE * NBPG)          .set    _C_LABEL(APTD),(_C_LABEL(APTmap) + PDSLOT_APTE * PAGE_SIZE)
         .set    _C_LABEL(APTDpde),(_C_LABEL(PTD) + PDSLOT_APTE * 4)          .set    _C_LABEL(APTDpde),(_C_LABEL(PTD) + PDSLOT_APTE * 4)
   
   
Line 199 
Line 200 
   
 #if NLAPIC > 0  #if NLAPIC > 0
 #ifdef __ELF__  #ifdef __ELF__
         .align  NBPG          .align  PAGE_SIZE
 #else  #else
         .align  12          .align  12
 #endif  #endif
Line 214  _C_LABEL(lapic_tpr):  
Line 215  _C_LABEL(lapic_tpr):  
 _C_LABEL(lapic_ppr):  _C_LABEL(lapic_ppr):
         .space  LAPIC_ISR-LAPIC_PPRI          .space  LAPIC_ISR-LAPIC_PPRI
 _C_LABEL(lapic_isr):  _C_LABEL(lapic_isr):
         .space  NBPG-LAPIC_ISR          .space  PAGE_SIZE-LAPIC_ISR
 #else  #else
 _C_LABEL(lapic_tpr):  _C_LABEL(lapic_tpr):
         .long 0          .long 0
Line 506  try586: /* Use the `cpuid' instruction. 
Line 507  try586: /* Use the `cpuid' instruction. 
  * text | data | bss | [syms] | page dir | proc0 kstack   * text | data | bss | [syms] | page dir | proc0 kstack
  *                            0          1       2      3   *                            0          1       2      3
  */   */
 #define PROC0PDIR       ((0)              * NBPG)  #define PROC0PDIR       ((0)              * PAGE_SIZE)
 #define PROC0STACK      ((1)              * NBPG)  #define PROC0STACK      ((1)              * PAGE_SIZE)
 #define SYSMAP          ((1+UPAGES)       * NBPG)  #define SYSMAP          ((1+UPAGES)       * PAGE_SIZE)
 #define TABLESIZE       ((1+UPAGES) * NBPG) /* + nkpde * NBPG */  #define TABLESIZE       ((1+UPAGES) * PAGE_SIZE) /* + nkpde * PAGE_SIZE */
   
         /* Find end of kernel image. */          /* Find end of kernel image. */
         movl    $RELOC(end),%edi          movl    $RELOC(end),%edi
 #if defined(DDB) && !defined(SYMTAB_SPACE)  #if (NKSYMS || defined(DDB) || defined(LKM)) && !defined(SYMTAB_SPACE)
         /* Save the symbols (if loaded). */          /* Save the symbols (if loaded). */
         movl    RELOC(esym),%eax          movl    RELOC(esym),%eax
         testl   %eax,%eax          testl   %eax,%eax
Line 561  try586: /* Use the `cpuid' instruction. 
Line 562  try586: /* Use the `cpuid' instruction. 
  */   */
 #define fillkpt         \  #define fillkpt         \
 1:      movl    %eax,(%ebx)     ; \  1:      movl    %eax,(%ebx)     ; \
         addl    $NBPG,%eax      ; /* increment physical address */ \          addl    $PAGE_SIZE,%eax ; /* increment physical address */ \
         addl    $4,%ebx         ; /* next pte */ \          addl    $4,%ebx         ; /* next pte */ \
         loop    1b              ;          loop    1b              ;
   
Line 1095  ENTRY(copyoutstr)
Line 1096  ENTRY(copyoutstr)
         /* Compute number of bytes in first page. */          /* Compute number of bytes in first page. */
         movl    %edi,%eax          movl    %edi,%eax
         andl    $PGOFSET,%eax          andl    $PGOFSET,%eax
         movl    $NBPG,%ecx          movl    $PAGE_SIZE,%ecx
         subl    %eax,%ecx               # ecx = NBPG - (src % NBPG)          subl    %eax,%ecx               # ecx = PAGE_SIZE - (src % PAGE_SIZE)
   
         GET_CURPCB(%eax)          GET_CURPCB(%eax)
         movl    $6f,PCB_ONFAULT(%eax)          movl    $6f,PCB_ONFAULT(%eax)
Line 1143  ENTRY(copyoutstr)
Line 1144  ENTRY(copyoutstr)
         jmp     copystr_return          jmp     copystr_return
   
 4:      /* Go to next page, if any. */  4:      /* Go to next page, if any. */
         movl    $NBPG,%ecx          movl    $PAGE_SIZE,%ecx
         testl   %edx,%edx          testl   %edx,%edx
         jnz     1b          jnz     1b
   
Line 1647  ENTRY(longjmp)
Line 1648  ENTRY(longjmp)
   
 /*****************************************************************************/  /*****************************************************************************/
   
 /*  
  * The following primitives manipulate the run queues.  
  * _whichqs tells which of the 32 queues _qs  
  * have processes in them.  Setrq puts processes into queues, Remrq  
  * removes them from queues.  The running process is on no queue,  
  * other processes are on a queue related to p->p_pri, divided by 4  
  * actually to shrink the 0-127 range of priorities into the 32 available  
  * queues.  
  */  
         .globl  _C_LABEL(sched_whichqs),_C_LABEL(sched_qs)          .globl  _C_LABEL(sched_whichqs),_C_LABEL(sched_qs)
         .globl  _C_LABEL(uvmexp),_C_LABEL(panic)          .globl  _C_LABEL(uvmexp),_C_LABEL(panic)
   
 /*  
  * void setrunqueue(struct lwp *p);  
  * Insert a process on the appropriate queue.  Should be called at splclock().  
  * See setrunqueue(9) for more details.  
  */  
 /* LINTSTUB: Func: void setrunqueue(struct lwp *p) */  
 NENTRY(setrunqueue)  
         movl    4(%esp),%eax  
 #ifdef DIAGNOSTIC  
         cmpl    $0,L_BACK(%eax) # should not be on q already  
         jne     1f  
         cmpl    $0,L_WCHAN(%eax)  
         jne     1f  
         cmpb    $SRUN,L_STAT(%eax)  
         jne     1f  
 #endif /* DIAGNOSTIC */  
         movzbl  L_PRIORITY(%eax),%edx  
         shrl    $2,%edx  
         btsl    %edx,_C_LABEL(sched_whichqs)    # set q full bit  
         leal    _C_LABEL(sched_qs)(,%edx,8),%edx # locate q hdr  
         movl    L_BACK(%edx),%ecx  
         movl    %edx,L_FORW(%eax)       # link process on tail of q  
         movl    %eax,L_BACK(%edx)  
         movl    %eax,L_FORW(%ecx)  
         movl    %ecx,L_BACK(%eax)  
         ret  
 #ifdef DIAGNOSTIC  
 1:      pushl   $2f  
         call    _C_LABEL(panic)  
         /* NOTREACHED */  
 2:      .asciz  "setrunqueue"  
 #endif /* DIAGNOSTIC */  
   
 /*  
  * void remrunqueue(struct lwp *p);  
  * Remove a process from its queue.  Should be called at splclock().  
  * See remrunqueue(9) for more details.  
  */  
 /* LINTSTUB: Func: void remrunqueue(struct lwp *p) */  
 NENTRY(remrunqueue)  
         movl    4(%esp),%ecx  
         movzbl  L_PRIORITY(%ecx),%eax  
 #ifdef DIAGNOSTIC  
         shrl    $2,%eax  
         btl     %eax,_C_LABEL(sched_whichqs)  
         jnc     1f  
 #endif /* DIAGNOSTIC */  
         movl    L_BACK(%ecx),%edx       # unlink process  
         movl    $0,L_BACK(%ecx)         # zap reverse link to indicate off list  
         movl    L_FORW(%ecx),%ecx  
         movl    %ecx,L_FORW(%edx)  
         movl    %edx,L_BACK(%ecx)  
         cmpl    %ecx,%edx               # q still has something?  
         jne     2f  
 #ifndef DIAGNOSTIC  
         shrl    $2,%eax  
 #endif  
         btrl    %eax,_C_LABEL(sched_whichqs)    # no; clear bit  
 2:      ret  
 #ifdef DIAGNOSTIC  
 1:      pushl   $3f  
         call    _C_LABEL(panic)  
         /* NOTREACHED */  
 3:      .asciz  "remrunqueue"  
 #endif /* DIAGNOSTIC */  
   
 #ifdef DIAGNOSTIC  #ifdef DIAGNOSTIC
 NENTRY(switch_error)  NENTRY(switch_error)
         pushl   $1f          pushl   $1f
Line 1751  ENTRY(cpu_switch)
Line 1677  ENTRY(cpu_switch)
 #ifdef DEBUG  #ifdef DEBUG
         cmpl    $IPL_SCHED,CPUVAR(ILEVEL)          cmpl    $IPL_SCHED,CPUVAR(ILEVEL)
         jae     1f          jae     1f
         pushl   2f          pushl   $2f
         call    _C_LABEL(panic)          call    _C_LABEL(panic)
         /* NOTREACHED */          /* NOTREACHED */
 2:      .asciz  "not splhigh() in cpu_switch!"  2:      .asciz  "not splsched() in cpu_switch!"
 1:  1:
 #endif /* DEBUG */  #endif /* DEBUG */
   
         movl    CPUVAR(CURLWP),%esi          movl    16(%esp),%esi           # current
   
         /*          /*
          * Clear curlwp so that we don't accumulate system time while idle.           * Clear curlwp so that we don't accumulate system time while idle.
Line 1775  ENTRY(cpu_switch)
Line 1701  ENTRY(cpu_switch)
          *   %eax - queue head, scratch, then zero           *   %eax - queue head, scratch, then zero
          *   %ebx - queue number           *   %ebx - queue number
          *   %ecx - cached value of whichqs           *   %ecx - cached value of whichqs
          *   %edx - next process in queue           *   %edx - next lwp in queue
          *   %esi - old lwp           *   %esi - old lwp
          *   %edi - new lwp           *   %edi - new lwp
          */           */
Line 1927  switch_resume:
Line 1853  switch_resume:
         SET_CURLWP(%edi,%ecx)          SET_CURLWP(%edi,%ecx)
   
         /* Skip context switch if same lwp. */          /* Skip context switch if same lwp. */
         movl    $1, %eax          movl    $1, %ebx
         cmpl    %edi,%esi          cmpl    %edi,%esi
         je      switch_return          je      switch_return
   
Line 2020  switch_restored:
Line 1946  switch_restored:
   
 /*  /*
  *  Check for restartable atomic sequences (RAS)   *  Check for restartable atomic sequences (RAS)
  *  XXX %edi reloads are not necessary here as %edi is callee-saved!  
  */   */
         movl    CPUVAR(CURLWP),%edi          movl    CPUVAR(CURLWP),%edi
         movl    L_PROC(%edi),%esi          movl    L_PROC(%edi),%esi
         cmpl    $0,P_NRAS(%esi)          cmpl    $0,P_NRAS(%esi)
         je      1f          je      1f
         movl    L_MD_REGS(%edi),%edx          movl    L_MD_REGS(%edi),%ebx
         movl    TF_EIP(%edx),%eax          movl    TF_EIP(%ebx),%eax
         pushl   %eax          pushl   %eax
         pushl   %esi          pushl   %esi
         call    _C_LABEL(ras_lookup)          call    _C_LABEL(ras_lookup)
         addl    $8,%esp          addl    $8,%esp
         cmpl    $-1,%eax          cmpl    $-1,%eax
         je      1f          je      1f
         movl    CPUVAR(CURLWP),%edi          movl    %eax,TF_EIP(%ebx)
         movl    L_MD_REGS(%edi),%edx  
         movl    %eax,TF_EIP(%edx)  
 1:  1:
         xor     %eax,%eax          xor     %ebx,%ebx
   
 switch_return:  switch_return:
 #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)  #if defined(MULTIPROCESSOR) || defined(LOCKDEBUG)
Line 2048  switch_return:
Line 1971  switch_return:
         call    _C_LABEL(Xspllower)     # process pending interrupts          call    _C_LABEL(Xspllower)     # process pending interrupts
         addl    $4,%esp          addl    $4,%esp
         movl    $IPL_HIGH,CPUVAR(ILEVEL)        # splhigh()          movl    $IPL_HIGH,CPUVAR(ILEVEL)        # splhigh()
   
           movl    %ebx,%eax
   
         popl    %edi          popl    %edi
         popl    %esi          popl    %esi
         popl    %ebx          popl    %ebx
         ret          ret
   
 #ifdef DIAGNOSTIC  
 NENTRY(preempt_error)  
         pushl   $1f  
         call    _C_LABEL(panic)  
         /* NOTREACHED */  
 1:      .asciz  "cpu_preempt"  
 #endif /* DIAGNOSTIC */  
   
 /*  /*
  * void cpu_preempt(struct lwp *current, struct lwp *next)   * void cpu_switchto(struct lwp *current, struct lwp *next)
  * Switch to the specified nexxt LWP.   * Switch to the specified next LWP.
  */   */
 ENTRY(cpu_preempt)  ENTRY(cpu_switchto)
         pushl   %ebx          pushl   %ebx
         pushl   %esi          pushl   %esi
         pushl   %edi          pushl   %edi
Line 2077  ENTRY(cpu_preempt)
Line 1994  ENTRY(cpu_preempt)
         pushl   $2f          pushl   $2f
         call    _C_LABEL(panic)          call    _C_LABEL(panic)
         /* NOTREACHED */          /* NOTREACHED */
 2:      .asciz  "not splsched() in cpu_preempt!"  2:      .asciz  "not splsched() in cpu_switchto!"
 1:  1:
 #endif /* DEBUG */  #endif /* DEBUG */
   
         movl    CPUVAR(CURLWP),%esi          movl    16(%esp),%esi           # current
         movl    20(%esp),%edi           # next          movl    20(%esp),%edi           # next
   
         /*          /*
Line 2090  ENTRY(cpu_preempt)
Line 2007  ENTRY(cpu_preempt)
          * the correct queue if it happens to get called from the spllower()           * the correct queue if it happens to get called from the spllower()
          * below and changes the priority.  (See corresponding comment in           * below and changes the priority.  (See corresponding comment in
          * usrret()).           * usrret()).
            *
            * XXX Is this necessary?  We know we won't go idle.
          */           */
         movl    $0,CPUVAR(CURLWP)          movl    $0,CPUVAR(CURLWP)
   
 preempt_dequeue:  
         /*          /*
          * We're running at splhigh(), but it's otherwise okay to take           * We're running at splhigh(), but it's otherwise okay to take
          * interrupts here.           * interrupts here.
          */           */
         sti          sti
   
         movzbl  L_PRIORITY(%edi),%eax  
 #ifdef DIAGNOSTIC  
         shrl    $2,%eax  
         btl     %eax,_C_LABEL(sched_whichqs)  
         jnc     _C_LABEL(preempt_error)  
 #endif /* DIAGNOSTIC */  
         movl    L_BACK(%edi),%edx       # unlink process  
         movl    $0,L_BACK(%edi)         # zap reverse link to indicate off list  
         movl    L_FORW(%edi),%ecx  
         movl    %ecx,L_FORW(%edx)  
         movl    %edx,L_BACK(%ecx)  
         cmpl    %ecx,%edx               # q still has something?  
         jne     3f  
 #ifndef DIAGNOSTIC  
         shrl    $2,%eax  
 #endif  
         btrl    %eax,_C_LABEL(sched_whichqs)    # no; clear bit  
   
 3:  
         /* Jump into the middle of cpu_switch */          /* Jump into the middle of cpu_switch */
         xorl    %eax,%eax          xorl    %eax,%eax
         jmp     switch_resume          jmp     switch_resume
   
 /*  /*
  * void switch_exit(struct lwp *l);   * void switch_exit(struct lwp *l, void (*exit)(struct lwp *));
  * Switch to the appropriate idle context (lwp0's if uniprocessor; the cpu's   * Switch to the appropriate idle context (lwp0's if uniprocessor; the cpu's
  * if multiprocessor) and deallocate the address space and kernel stack for p.   * if multiprocessor) and deallocate the address space and kernel stack for p.
  * Then jump into cpu_switch(), as if we were in the idle proc all along.   * Then jump into cpu_switch(), as if we were in the idle proc all along.
Line 2134  preempt_dequeue:
Line 2033  preempt_dequeue:
 #endif  #endif
         .globl  _C_LABEL(uvmspace_free),_C_LABEL(kernel_map)          .globl  _C_LABEL(uvmspace_free),_C_LABEL(kernel_map)
         .globl  _C_LABEL(uvm_km_free),_C_LABEL(tss_free)          .globl  _C_LABEL(uvm_km_free),_C_LABEL(tss_free)
 /* LINTSTUB: Func: void switch_exit(struct lwp *l) */  /* LINTSTUB: Func: void switch_exit(struct lwp *l, void (*exit)(struct lwp *)) */
 ENTRY(switch_exit)  ENTRY(switch_exit)
         movl    4(%esp),%edi            # old process          movl    4(%esp),%edi            # old process
           movl    8(%esp),%eax            # exit func
 #ifndef MULTIPROCESSOR  #ifndef MULTIPROCESSOR
         movl    $_C_LABEL(lwp0),%ebx          movl    $_C_LABEL(lwp0),%ebx
         movl    L_ADDR(%ebx),%esi          movl    L_ADDR(%ebx),%esi
Line 2155  ENTRY(switch_exit)
Line 2055  ENTRY(switch_exit)
         movl    PCB_ESP(%esi),%esp          movl    PCB_ESP(%esi),%esp
         movl    PCB_EBP(%esi),%ebp          movl    PCB_EBP(%esi),%ebp
   
         /* Load TSS info. */          /* Save exit func. */
 #ifdef MULTIPROCESSOR          pushl   %eax
         movl    CPUVAR(GDT),%eax  
 #else  
         /* Load TSS info. */  
         movl    _C_LABEL(gdt),%eax  
 #endif  
   
         /* Switch address space. */  
         movl    PCB_CR3(%esi),%ecx  
         movl    %ecx,%cr3  
   
         /* Switch TSS. */  
         andl    $~0x0200,4-SEL_KPL(%eax,%edx,1)  
         ltr     %dx  
   
         /* We're always in the kernel, so we don't need the LDT. */  
   
         /* Restore cr0 (including FPU state). */  
         movl    PCB_CR0(%esi),%ecx  
         movl    %ecx,%cr0  
   
         /* Record new pcb. */  
         SET_CURPCB(%esi)  
   
         /* Interrupts are okay again. */  
         sti  
   
         /*  
          * Schedule the dead process's vmspace and stack to be freed.  
          */  
         pushl   %edi                    /* exit2(l) */  
         call    _C_LABEL(exit2)  
         addl    $4,%esp  
   
         /* Jump into cpu_switch() with the right state. */  
         xorl    %esi,%esi  
         movl    %esi,CPUVAR(CURLWP)  
         jmp     idle_start  
   
 /*  
  * switch_lwp_exit(struct lwp *l);  
  * Switch to the appropriate idle context (lwp0's if uniprocessor; the cpu's  
  * if multiprocessor) and deallocate the kernel stack for l.  
  * Then jump into cpu_switch(), as if we were in the idle proc all along.  
  */  
 #ifndef MULTIPROCESSOR  
         .globl  _C_LABEL(lwp0)  
 #endif  
         .globl  _C_LABEL(uvmspace_free),_C_LABEL(kernel_map)  
         .globl  _C_LABEL(uvm_km_free),_C_LABEL(tss_free)  
 /* LINTSTUB: Func: void switch_lwp_exit(struct lwp *l) */  
 ENTRY(switch_lwp_exit)  
         movl    4(%esp),%edi            # old process  
 #ifndef MULTIPROCESSOR  
         movl    $_C_LABEL(lwp0),%ebx  
         movl    L_ADDR(%ebx),%esi  
         movl    L_MD_TSS_SEL(%ebx),%edx  
 #else  
         movl    CPUVAR(IDLE_PCB),%esi  
         movl    CPUVAR(IDLE_TSS_SEL),%edx  
 #endif  
         /* In case we fault... */  
         movl    $0,CPUVAR(CURLWP)  
   
         /* Restore the idle context. */  
         cli  
   
         /* Restore stack pointers. */  
         movl    PCB_ESP(%esi),%esp  
         movl    PCB_EBP(%esi),%ebp  
   
         /* Load TSS info. */          /* Load TSS info. */
 #ifdef MULTIPROCESSOR  #ifdef MULTIPROCESSOR
Line 2258  ENTRY(switch_lwp_exit)
Line 2089  ENTRY(switch_lwp_exit)
         /*          /*
          * Schedule the dead process's vmspace and stack to be freed.           * Schedule the dead process's vmspace and stack to be freed.
          */           */
         pushl   %edi                    /* lwp_exit2(l) */          movl    0(%esp),%eax            /* %eax = exit func */
         call    _C_LABEL(lwp_exit2)          movl    %edi,0(%esp)            /* {lwp_}exit2(l) */
           call    *%eax
         addl    $4,%esp          addl    $4,%esp
   
         /* Jump into cpu_switch() with the right state. */          /* Jump into cpu_switch() with the right state. */

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.9

CVSweb <webmaster@jp.NetBSD.org>