Changeset 1760


Ignore:
Timestamp:
Jan 17, 2005, 2:14:01 AM (21 years ago)
Author:
bird
Message:

Check if fxsave/fxrstor is supported before using them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/386/__fork.s

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r1759 r1760  
    44 * fork() 'syscall'.
    55 *
    6  * Copyright (c) 2004 knut st. osmundsen <bird-srcspam@anduin.net>
     6 * Copyright (c) 2004-2005 knut st. osmundsen <bird-srcspam@anduin.net>
    77 * Copyright (c) 2004 nickk
    88 *
     
    3030    .globl  LABEL(__fork)
    3131
     32    .data
     33fHaveFXSR:
     34    .byte -1
     35
    3236    .text
    3337
     
    4650    subl    $512, %esp
    4751    movl    $0, 0(%esp)                 /* paranoia!!!!!!! touch the stack page preventing faults in fxsave. */
     52
     53    /* check if the cpu support fxsave. */
     54l_retest:
     55    cmpb    $1, fHaveFXSR
     56    je      l_fxsave
     57    cmpb    $0, fHaveFXSR
     58    jne     l_check_cpuid
     59    jmp     l_fnsave
     60
     61    /* check cpuid for fxrs - ASSUME all processors have cpuid eax=1! */
     62l_check_cpuid:
     63    push    %ebx
     64    mov     $1, %eax
     65    cpuid
     66    pop     %ebx
     67    testl   $0x1000000, %edx  /* bit 24 - fxsr */
     68    setnz   fHaveFXSR
     69    jnz     l_fxsave
     70
     71l_fnsave:
     72    fnsave  0(%esp)
     73    jmp     l_after_save
     74l_fxsave:
    4875    fxsave  0(%esp)
     76l_after_save:
    4977    pushf
    50     pushl       %ebx
    51     pushl       %esi
    52     pushl       %edi
     78    pushl   %ebx
     79    pushl   %esi
     80    pushl   %edi
    5381    pushl   %ebp
    5482    pushl   %gs
     
    6391     */
    6492    movl    %esp, %eax
    65     pushl       %eax
     93    pushl   %eax
    6694    pushl   $fork_ret
    67     call        LABEL(__libc_fork)
    68     addl        $12, %esp                   /* 12 = 8 + fs:[0]. */
     95    call    LABEL(__libc_fork)
     96    addl    $12, %esp                   /* 12 = 8 + fs:[0]. */
    6997    popl    %fs
    7098    jmp     fork_skip_regs
     
    83111    popl    %ebx
    84112    popf
    85     fxrstor     0(%esp)
     113    cmpb    $1, fHaveFXSR               /* check which way it was saved. */
     114    je      l_fxrstor
     115    frstor  0(%esp)
     116    jmp     l_after_restore
     117l_fxrstor:
     118    fxrstor 0(%esp)
     119l_after_restore:
    86120
    87121fork_skip_regs:
Note: See TracChangeset for help on using the changeset viewer.