Ignore:
Timestamp:
2013-10-07T20:00:34Z (11 years ago)
Author:
Jakub Klama <jakub.klama@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a73ebf0
Parents:
80d9d83
Message:

First attempt to implement preemptive trap handlers
and switch to userspace. Preemptive traps are needed
for at least page faults, as page fault handling code
can trigger window underflow/overflow exceptions.

This commit also introduces userspace window buffer
for saving userspace register windows (just as in
sparc64).

These changes are unfinished and far from working
correctly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/sparc32/src/proc/thread.c

    r80d9d83 r1f12fab  
    3333 */
    3434
     35#include <arch/regwin.h>
    3536#include <proc/thread.h>
     37
     38void thr_constructor_arch(thread_t *t)
     39{
     40        t->arch.uspace_window_buffer = NULL;
     41}
     42
     43void thr_destructor_arch(thread_t *t)
     44{
     45        if (t->arch.uspace_window_buffer) {
     46                uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
     47                /*
     48                 * Mind the possible alignment of the userspace window buffer
     49                 * belonging to a killed thread.
     50                 */
     51                free((uint8_t *) ALIGN_DOWN(uw_buf, UWB_ALIGNMENT));
     52        }
     53}
    3654
    3755void thread_create_arch(thread_t *t)
    3856{
     57        if ((t->uspace) && (!t->arch.uspace_window_buffer))
     58                {
     59                /*
     60                 * The thread needs userspace window buffer and the object
     61                 * returned from the slab allocator doesn't have any.
     62                 */
     63                t->arch.uspace_window_buffer = malloc(UWB_ASIZE, 0);
     64        } else {
     65                uintptr_t uw_buf = (uintptr_t) t->arch.uspace_window_buffer;
     66
     67                /*
     68                 * Mind the possible alignment of the userspace window buffer
     69                 * belonging to a killed thread.
     70                 */
     71                t->arch.uspace_window_buffer = (uint8_t *) ALIGN_DOWN(uw_buf,
     72                    UWB_ASIZE);
     73        }
    3974}
    4075
Note: See TracChangeset for help on using the changeset viewer.