Rev 3022 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3022 | Rev 4055 | ||
|---|---|---|---|
| Line 24... | Line 24... | ||
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
27 | */ |
| 28 | 28 | ||
| 29 | /** @addtogroup ia32 |
29 | /** @addtogroup ia32 |
| 30 | * @{ |
30 | * @{ |
| 31 | */ |
31 | */ |
| 32 | /** @file |
32 | /** @file |
| 33 | */ |
33 | */ |
| 34 | 34 | ||
| Line 45... | Line 45... | ||
| 45 | * Change CPU protection level to 3, enter userspace. |
45 | * Change CPU protection level to 3, enter userspace. |
| 46 | * |
46 | * |
| 47 | */ |
47 | */ |
| 48 | void userspace(uspace_arg_t *kernel_uarg) |
48 | void userspace(uspace_arg_t *kernel_uarg) |
| 49 | { |
49 | { |
| 50 | ipl_t ipl; |
- | |
| 51 | - | ||
| 52 | ipl = interrupts_disable(); |
50 | ipl_t ipl = interrupts_disable(); |
| 53 | 51 | ||
| 54 | asm volatile ( |
52 | asm volatile ( |
| 55 | /* |
53 | /* |
| 56 | * Clear nested task flag. |
54 | * Clear nested task flag. |
| 57 | */ |
55 | */ |
| 58 | "pushfl\n" |
56 | "pushfl\n" |
| 59 | "pop %%eax\n" |
57 | "pop %%eax\n" |
| 60 | "and $0xffffbfff, %%eax\n" |
58 | "and $0xffffbfff, %%eax\n" |
| 61 | "push %%eax\n" |
59 | "push %%eax\n" |
| 62 | "popfl\n" |
60 | "popfl\n" |
| 63 | 61 | ||
| 64 | /* Set up GS register (TLS) */ |
62 | /* Set up GS register (TLS) */ |
| 65 | "movl %6, %%gs\n" |
63 | "movl %[tls_des], %%gs\n" |
| 66 | 64 | ||
| 67 | "pushl %0\n" |
65 | "pushl %[udata_des]\n" |
| 68 | "pushl %1\n" |
66 | "pushl %[stack_size]\n" |
| 69 | "pushl %2\n" |
67 | "pushl %[ipl]\n" |
| 70 | "pushl %3\n" |
68 | "pushl %[utext_des]\n" |
| 71 | "pushl %4\n" |
69 | "pushl %[entry]\n" |
| 72 | "movl %5, %%eax\n" |
70 | "movl %[uarg], %%eax\n" |
| - | 71 | ||
| - | 72 | /* %ebx is defined to hold pcb_ptr - set it to 0 */ |
|
| - | 73 | "xorl %%ebx, %%ebx\n" |
|
| - | 74 | ||
| 73 | "iret\n" |
75 | "iret\n" |
| 74 | : |
76 | : |
| 75 | : "i" (selector(UDATA_DES) | PL_USER), |
77 | : [udata_des] "i" (selector(UDATA_DES) | PL_USER), |
| 76 | "r" ((uint8_t *) kernel_uarg->uspace_stack + |
78 | [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + THREAD_STACK_SIZE), |
| 77 | THREAD_STACK_SIZE), |
- | |
| 78 | "r" (ipl), |
79 | [ipl] "r" (ipl), |
| 79 | "i" (selector(UTEXT_DES) | PL_USER), |
80 | [utext_des] "i" (selector(UTEXT_DES) | PL_USER), |
| 80 | "r" (kernel_uarg->uspace_entry), |
81 | [entry] "r" (kernel_uarg->uspace_entry), |
| 81 | "r" (kernel_uarg->uspace_uarg), |
82 | [uarg] "r" (kernel_uarg->uspace_uarg), |
| 82 | "r" (selector(TLS_DES)) |
83 | [tls_des] "r" (selector(TLS_DES)) |
| 83 | : "eax"); |
84 | : "eax"); |
| 84 | 85 | ||
| 85 | /* Unreachable */ |
86 | /* Unreachable */ |
| 86 | for(;;) |
87 | while (1); |
| 87 | ; |
- | |
| 88 | } |
88 | } |
| 89 | 89 | ||
| 90 | /** @} |
90 | /** @} |
| 91 | */ |
91 | */ |