Subversion Repositories HelenOS

Rev

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

Rev 3036 Rev 3425
Line 51... Line 51...
51
#include <synch/mutex.h>
51
#include <synch/mutex.h>
52
#include <adt/list.h>
52
#include <adt/list.h>
53
#include <adt/btree.h>
53
#include <adt/btree.h>
54
#include <lib/elf.h>
54
#include <lib/elf.h>
55
 
55
 
56
#ifdef __OBJC__
-
 
57
#include <lib/objc.h>
-
 
58
#endif
-
 
59
 
-
 
60
/**
56
/**
61
 * Defined to be true if user address space and kernel address space shadow each
57
 * Defined to be true if user address space and kernel address space shadow each
62
 * other.
58
 * other.
63
 */
59
 */
64
#define KERNEL_ADDRESS_SPACE_SHADOWED   KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
60
#define KERNEL_ADDRESS_SPACE_SHADOWED   KERNEL_ADDRESS_SPACE_SHADOWED_ARCH
Line 82... Line 78...
82
/** The page fault was resolved by as_page_fault(). */
78
/** The page fault was resolved by as_page_fault(). */
83
#define AS_PF_OK        1
79
#define AS_PF_OK        1
84
/** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
80
/** The page fault was caused by memcpy_from_uspace() or memcpy_to_uspace(). */
85
#define AS_PF_DEFER     2
81
#define AS_PF_DEFER     2
86
 
82
 
87
#ifdef __OBJC__
-
 
88
@interface as_t : base_t {
-
 
89
    @public
-
 
90
        /** Protected by asidlock. */
-
 
91
        link_t inactive_as_with_asid_link;
-
 
92
        /**
-
 
93
         * Number of processors on wich is this address space active.
-
 
94
         * Protected by asidlock.
-
 
95
         */
-
 
96
        count_t cpu_refcount;
-
 
97
        /**
-
 
98
         * Address space identifier.
-
 
99
         * Constant on architectures that do not support ASIDs.
-
 
100
         * Protected by asidlock.  
-
 
101
         */
-
 
102
        asid_t asid;
-
 
103
       
-
 
104
        /** Number of references (i.e tasks that reference this as). */
-
 
105
        atomic_t refcount;
-
 
106
 
-
 
107
        mutex_t lock;
-
 
108
       
-
 
109
        /** B+tree of address space areas. */
-
 
110
        btree_t as_area_btree;
-
 
111
       
-
 
112
        /** Non-generic content. */
-
 
113
        as_genarch_t genarch;
-
 
114
       
-
 
115
        /** Architecture specific content. */
-
 
116
        as_arch_t arch;
-
 
117
}
-
 
118
 
-
 
119
+ (pte_t *) page_table_create: (int) flags;
-
 
120
+ (void) page_table_destroy: (pte_t *) page_table;
-
 
121
- (void) page_table_lock: (bool) _lock;
-
 
122
- (void) page_table_unlock: (bool) unlock;
-
 
123
 
-
 
124
@end
-
 
125
 
-
 
126
#else
-
 
127
 
-
 
128
/** Address space structure.
83
/** Address space structure.
129
 *
84
 *
130
 * as_t contains the list of as_areas of userspace accessible
85
 * as_t contains the list of as_areas of userspace accessible
131
 * pages for one or more tasks. Ranges of kernel memory pages are not
86
 * pages for one or more tasks. Ranges of kernel memory pages are not
132
 * supposed to figure in the list as they are shared by all tasks and
87
 * supposed to figure in the list as they are shared by all tasks and
Line 166... Line 121...
166
    pte_t *(* page_table_create)(int flags);
121
    pte_t *(* page_table_create)(int flags);
167
    void (* page_table_destroy)(pte_t *page_table);
122
    void (* page_table_destroy)(pte_t *page_table);
168
    void (* page_table_lock)(as_t *as, bool lock);
123
    void (* page_table_lock)(as_t *as, bool lock);
169
    void (* page_table_unlock)(as_t *as, bool unlock);
124
    void (* page_table_unlock)(as_t *as, bool unlock);
170
} as_operations_t;
125
} as_operations_t;
171
#endif
-
 
172
 
126
 
173
/**
127
/**
174
 * This structure contains information associated with the shared address space
128
 * This structure contains information associated with the shared address space
175
 * area.
129
 * area.
176
 */
130
 */
Line 247... Line 201...
247
    void (* share)(as_area_t *area);
201
    void (* share)(as_area_t *area);
248
} mem_backend_t;
202
} mem_backend_t;
249
 
203
 
250
extern as_t *AS_KERNEL;
204
extern as_t *AS_KERNEL;
251
 
205
 
252
#ifndef __OBJC__
-
 
253
extern as_operations_t *as_operations;
206
extern as_operations_t *as_operations;
254
#endif
-
 
255
 
-
 
256
extern link_t inactive_as_with_asid_head;
207
extern link_t inactive_as_with_asid_head;
257
 
208
 
258
extern void as_init(void);
209
extern void as_init(void);
259
 
210
 
260
extern as_t *as_create(int flags);
211
extern as_t *as_create(int flags);
Line 267... Line 218...
267
    mem_backend_data_t *backend_data);
218
    mem_backend_data_t *backend_data);
268
extern int as_area_destroy(as_t *as, uintptr_t address);   
219
extern int as_area_destroy(as_t *as, uintptr_t address);   
269
extern int as_area_resize(as_t *as, uintptr_t address, size_t size, int flags);
220
extern int as_area_resize(as_t *as, uintptr_t address, size_t size, int flags);
270
int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
221
int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
271
    as_t *dst_as, uintptr_t dst_base, int dst_flags_mask);
222
    as_t *dst_as, uintptr_t dst_base, int dst_flags_mask);
-
 
223
extern int as_area_change_flags(as_t *as, int flags, uintptr_t address);
272
 
224
 
273
extern int as_area_get_flags(as_area_t *area);
225
extern int as_area_get_flags(as_area_t *area);
274
extern bool as_area_check_access(as_area_t *area, pf_access_t access);
226
extern bool as_area_check_access(as_area_t *area, pf_access_t access);
275
extern size_t as_area_get_size(uintptr_t base);
227
extern size_t as_area_get_size(uintptr_t base);
276
extern int as_area_make_writeable(uintptr_t address);
228
extern int as_area_make_writeable(uintptr_t address);
Line 299... Line 251...
299
/* Backend declarations and functions. */
251
/* Backend declarations and functions. */
300
extern mem_backend_t anon_backend;
252
extern mem_backend_t anon_backend;
301
extern mem_backend_t elf_backend;
253
extern mem_backend_t elf_backend;
302
extern mem_backend_t phys_backend;
254
extern mem_backend_t phys_backend;
303
 
255
 
-
 
256
/**
-
 
257
 * This flags is passed when running the loader, otherwise elf_load()
-
 
258
 * would return with a EE_LOADER error code.
-
 
259
 */
-
 
260
#define ELD_F_NONE  0
-
 
261
#define ELD_F_LOADER    1
-
 
262
 
304
extern unsigned int elf_load(elf_header_t *header, as_t *as);
263
extern unsigned int elf_load(elf_header_t *header, as_t *as, int flags);
305
 
264
 
306
/* Address space area related syscalls. */
265
/* Address space area related syscalls. */
307
extern unative_t sys_as_area_create(uintptr_t address, size_t size, int flags);
266
extern unative_t sys_as_area_create(uintptr_t address, size_t size, int flags);
308
extern unative_t sys_as_area_resize(uintptr_t address, size_t size, int flags);
267
extern unative_t sys_as_area_resize(uintptr_t address, size_t size, int flags);
-
 
268
extern unative_t sys_as_area_change_flags(uintptr_t address, int flags);
309
extern unative_t sys_as_area_destroy(uintptr_t address);
269
extern unative_t sys_as_area_destroy(uintptr_t address);
310
 
270
 
311
/* Introspection functions. */
271
/* Introspection functions. */
312
extern void as_print(as_t *as);
272
extern void as_print(as_t *as);
313
 
273