Rev 1854 | Rev 1987 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1854 | Rev 1857 | ||
|---|---|---|---|
| Line 33... | Line 33... | ||
| 33 | */ |
33 | */ |
| 34 | 34 | ||
| 35 | #include <proc/thread.h> |
35 | #include <proc/thread.h> |
| 36 | #include <arch/proc/thread.h> |
36 | #include <arch/proc/thread.h> |
| 37 | #include <mm/frame.h> |
37 | #include <mm/frame.h> |
| - | 38 | #include <mm/page.h> |
|
| - | 39 | #include <arch/mm/page.h> |
|
| - | 40 | #include <align.h> |
|
| 38 | 41 | ||
| 39 | void thr_constructor_arch(thread_t *t) |
42 | void thr_constructor_arch(thread_t *t) |
| 40 | { |
43 | { |
| 41 | /* |
44 | /* |
| 42 | * Allocate memory for uspace_window_buffer. |
45 | * Allocate memory for uspace_window_buffer. |
| Line 44... | Line 47... | ||
| 44 | t->arch.uspace_window_buffer = NULL; |
47 | t->arch.uspace_window_buffer = NULL; |
| 45 | } |
48 | } |
| 46 | 49 | ||
| 47 | void thr_destructor_arch(thread_t *t) |
50 | void thr_destructor_arch(thread_t *t) |
| 48 | { |
51 | { |
| 49 | if (t->arch.uspace_window_buffer) |
52 | if (t->arch.uspace_window_buffer) { |
| - | 53 | /* |
|
| - | 54 | * Mind the possible alignment of the userspace window buffer |
|
| - | 55 | * belonging to a killed thread. |
|
| - | 56 | */ |
|
| 50 | frame_free((uintptr_t) t->arch.uspace_window_buffer); |
57 | frame_free(ALIGN_DOWN((uintptr_t) t->arch.uspace_window_buffer, PAGE_SIZE)); |
| - | 58 | } |
|
| 51 | } |
59 | } |
| 52 | 60 | ||
| 53 | void thread_create_arch(thread_t *t) |
61 | void thread_create_arch(thread_t *t) |
| 54 | { |
62 | { |
| 55 | if ((t->flags & THREAD_FLAG_USPACE) && (!t->arch.uspace_window_buffer)) { |
63 | if ((t->flags & THREAD_FLAG_USPACE) && (!t->arch.uspace_window_buffer)) { |
| 56 | /* |
64 | /* |
| 57 | * The thread needs userspace window buffer and the object |
65 | * The thread needs userspace window buffer and the object |
| 58 | * returned from the slab allocator doesn't have any. |
66 | * returned from the slab allocator doesn't have any. |
| 59 | */ |
67 | */ |
| 60 | t->arch.uspace_window_buffer = frame_alloc(ONE_FRAME, 0); |
68 | t->arch.uspace_window_buffer = frame_alloc(ONE_FRAME, 0); |
| - | 69 | } else { |
|
| - | 70 | uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer; |
|
| - | 71 | ||
| - | 72 | /* |
|
| - | 73 | * Mind the possible alignment of the userspace window buffer |
|
| - | 74 | * belonging to a killed thread. |
|
| - | 75 | */ |
|
| - | 76 | t->arch.uspace_window_buffer = (uint8_t *) ALIGN_DOWN(uw_buf, PAGE_SIZE); |
|
| 61 | } |
77 | } |
| 62 | } |
78 | } |
| 63 | 79 | ||
| 64 | /** @} |
80 | /** @} |
| 65 | */ |
81 | */ |