Subversion Repositories HelenOS

Rev

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

Rev 1889 Rev 1890
Line 82... Line 82...
82
 * Each architecture decides what functions will be used to carry out
82
 * Each architecture decides what functions will be used to carry out
83
 * address space operations such as creating or locking page tables.
83
 * address space operations such as creating or locking page tables.
84
 */
84
 */
85
as_operations_t *as_operations = NULL;
85
as_operations_t *as_operations = NULL;
86
 
86
 
-
 
87
/**
-
 
88
 * Slab for as_t objects.
-
 
89
 */
-
 
90
static slab_cache_t *as_slab;
-
 
91
 
87
/** This lock protects inactive_as_with_asid_head list. It must be acquired before as_t mutex. */
92
/** This lock protects inactive_as_with_asid_head list. It must be acquired before as_t mutex. */
88
SPINLOCK_INITIALIZE(inactive_as_with_asid_lock);
93
SPINLOCK_INITIALIZE(inactive_as_with_asid_lock);
89
 
94
 
90
/**
95
/**
91
 * This list contains address spaces that are not active on any
96
 * This list contains address spaces that are not active on any
Line 103... Line 108...
103
 
108
 
104
/** Initialize address space subsystem. */
109
/** Initialize address space subsystem. */
105
void as_init(void)
110
void as_init(void)
106
{
111
{
107
    as_arch_init();
112
    as_arch_init();
-
 
113
   
-
 
114
    as_slab = slab_cache_create("as_slab", sizeof(as_t), 0, NULL, NULL, SLAB_CACHE_MAGDEFERRED);
-
 
115
   
108
    AS_KERNEL = as_create(FLAG_AS_KERNEL);
116
    AS_KERNEL = as_create(FLAG_AS_KERNEL);
109
    if (!AS_KERNEL)
117
    if (!AS_KERNEL)
110
        panic("can't create kernel address space\n");
118
        panic("can't create kernel address space\n");
111
   
119
   
112
}
120
}
Line 117... Line 125...
117
 */
125
 */
118
as_t *as_create(int flags)
126
as_t *as_create(int flags)
119
{
127
{
120
    as_t *as;
128
    as_t *as;
121
 
129
 
122
    as = (as_t *) malloc(sizeof(as_t), 0);
130
    as = (as_t *) slab_alloc(as_slab, 0);
123
    link_initialize(&as->inactive_as_with_asid_link);
131
    link_initialize(&as->inactive_as_with_asid_link);
124
    mutex_initialize(&as->lock);
132
    mutex_initialize(&as->lock);
125
    btree_create(&as->as_area_btree);
133
    btree_create(&as->as_area_btree);
126
   
134
   
127
    if (flags & FLAG_AS_KERNEL)
135
    if (flags & FLAG_AS_KERNEL)
Line 180... Line 188...
180
    btree_destroy(&as->as_area_btree);
188
    btree_destroy(&as->as_area_btree);
181
    page_table_destroy(as->page_table);
189
    page_table_destroy(as->page_table);
182
 
190
 
183
    interrupts_restore(ipl);
191
    interrupts_restore(ipl);
184
   
192
   
185
    free(as);
193
    slab_free(as_slab, as);
186
}
194
}
187
 
195
 
188
/** Create address space area of common attributes.
196
/** Create address space area of common attributes.
189
 *
197
 *
190
 * The created address space area is added to the target address space.
198
 * The created address space area is added to the target address space.
Line 796... Line 804...
796
             */
804
             */
797
             ASSERT(old->asid != ASID_INVALID);
805
             ASSERT(old->asid != ASID_INVALID);
798
             list_append(&old->inactive_as_with_asid_link, &inactive_as_with_asid_head);
806
             list_append(&old->inactive_as_with_asid_link, &inactive_as_with_asid_head);
799
        }
807
        }
800
        mutex_unlock(&old->lock);
808
        mutex_unlock(&old->lock);
-
 
809
 
-
 
810
        /*
-
 
811
         * Perform architecture-specific tasks when the address space
-
 
812
         * is being removed from the CPU.
-
 
813
         */
-
 
814
        as_deinstall_arch(old);
801
    }
815
    }
802
 
816
 
803
    /*
817
    /*
804
     * Second, prepare the new address space.
818
     * Second, prepare the new address space.
805
     */
819
     */