Rev 3386 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3386 | Rev 4153 | ||
---|---|---|---|
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" |
73 | 71 | ||
74 | /* %ebx is defined to hold pcb_ptr - set it to 0 */ |
72 | /* %ebx is defined to hold pcb_ptr - set it to 0 */ |
75 | "xorl %%ebx, %%ebx\n" |
73 | "xorl %%ebx, %%ebx\n" |
76 | 74 | ||
77 | "iret\n" |
75 | "iret\n" |
78 | : |
76 | : |
79 | : "i" (selector(UDATA_DES) | PL_USER), |
77 | : [udata_des] "i" (gdtselector(UDATA_DES) | PL_USER), |
80 | "r" ((uint8_t *) kernel_uarg->uspace_stack + |
78 | [stack_size] "r" ((uint8_t *) kernel_uarg->uspace_stack + THREAD_STACK_SIZE), |
81 | THREAD_STACK_SIZE), |
- | |
82 | "r" (ipl), |
79 | [ipl] "r" (ipl), |
83 | "i" (selector(UTEXT_DES) | PL_USER), |
80 | [utext_des] "i" (gdtselector(UTEXT_DES) | PL_USER), |
84 | "r" (kernel_uarg->uspace_entry), |
81 | [entry] "r" (kernel_uarg->uspace_entry), |
85 | "r" (kernel_uarg->uspace_uarg), |
82 | [uarg] "r" (kernel_uarg->uspace_uarg), |
86 | "r" (selector(TLS_DES)) |
83 | [tls_des] "r" (gdtselector(TLS_DES)) |
87 | : "eax"); |
84 | : "eax"); |
88 | 85 | ||
89 | /* Unreachable */ |
86 | /* Unreachable */ |
90 | for(;;) |
87 | while (1); |
91 | ; |
- | |
92 | } |
88 | } |
93 | 89 | ||
94 | /** @} |
90 | /** @} |
95 | */ |
91 | */ |