Subversion Repositories HelenOS

Rev

Rev 2787 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2787 Rev 3536
Line 32... Line 32...
32
/** @file
32
/** @file
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/slab.h>
38
#include <mm/page.h>
-
 
39
#include <arch/mm/page.h>
38
#include <arch/trap/regwin.h>
40
#include <align.h>
39
#include <align.h>
41
 
40
 
42
void thr_constructor_arch(thread_t *t)
41
void thr_constructor_arch(thread_t *t)
43
{
42
{
44
    /*
43
    /*
Line 48... Line 47...
48
}
47
}
49
 
48
 
50
void thr_destructor_arch(thread_t *t)
49
void thr_destructor_arch(thread_t *t)
51
{
50
{
52
    if (t->arch.uspace_window_buffer) {
51
    if (t->arch.uspace_window_buffer) {
-
 
52
        uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
53
        /*
53
        /*
54
         * Mind the possible alignment of the userspace window buffer
54
         * Mind the possible alignment of the userspace window buffer
55
         * belonging to a killed thread.
55
         * belonging to a killed thread.
56
         */
56
         */
57
        frame_free(KA2PA(ALIGN_DOWN((uintptr_t)
57
        free((uint8_t *) ALIGN_DOWN(uw_buf, UWB_ALIGNMENT));
58
            t->arch.uspace_window_buffer, PAGE_SIZE)));
-
 
59
    }
58
    }
60
}
59
}
61
 
60
 
62
void thread_create_arch(thread_t *t)
61
void thread_create_arch(thread_t *t)
63
{
62
{
Line 65... Line 64...
65
        {
64
        {
66
        /*
65
        /*
67
         * The thread needs userspace window buffer and the object
66
         * The thread needs userspace window buffer and the object
68
         * returned from the slab allocator doesn't have any.
67
         * returned from the slab allocator doesn't have any.
69
         */
68
         */
70
        t->arch.uspace_window_buffer = frame_alloc(ONE_FRAME, FRAME_KA);
69
        t->arch.uspace_window_buffer = malloc(UWB_ASIZE, 0);
71
    } else {
70
    } else {
72
        uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
71
        uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
73
 
72
 
74
        /*
73
        /*
75
         * Mind the possible alignment of the userspace window buffer
74
         * Mind the possible alignment of the userspace window buffer
76
         * belonging to a killed thread.
75
         * belonging to a killed thread.
77
         */
76
         */
78
        t->arch.uspace_window_buffer = (uint8_t *) ALIGN_DOWN(uw_buf,
77
        t->arch.uspace_window_buffer = (uint8_t *) ALIGN_DOWN(uw_buf,
79
            PAGE_SIZE);
78
            UWB_ASIZE);
80
    }
79
    }
81
}
80
}
82
 
81
 
83
/** @}
82
/** @}
84
 */
83
 */